* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0f172a;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --text-dark: #0f172a;
    --text-light: #64748b;
    --bg-light: #f8fafc;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-light);
    min-height: 100vh;
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1e293b 100%);
}

.login-container {
    background: var(--white);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.login-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-color);
    color: var(--white);
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-btn:hover {
    background: var(--accent-hover);
}

.error-message {
    color: var(--danger-color);
    margin-top: 1rem;
    text-align: center;
    font-size: 0.875rem;
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.back-to-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 0.2s;
}

.back-to-home-btn:hover {
    color: var(--accent-color);
}

.back-to-home-btn span {
    font-size: 1.125rem;
}

/* App Screen */
.app-screen {
    min-height: 100vh;
}

.admin-header {
    background: var(--primary-color);
    color: var(--white);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.mode-btn, .logout-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn {
    background: var(--accent-color);
    color: var(--white);
}

.mode-btn:hover {
    background: var(--accent-hover);
}

.logout-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Dashboard */
.dashboard-header {
    margin-bottom: 2rem;
}

.dashboard-header h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.model-count {
    color: var(--text-light);
    font-size: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.card-info {
    color: var(--text-light);
    font-size: 0.875rem;
}

.empty-message {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.add-button {
    background: var(--accent-color);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.add-button:hover {
    background: var(--accent-hover);
}

.import-button {
    background: var(--success-color);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.import-button:hover {
    background: #059669;
}

/* Model Header */
.model-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.model-nav-buttons {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.nav-model-btn {
    background: var(--accent-color);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.nav-model-btn:hover {
    background: var(--accent-hover);
}

.model-title {
    flex: 1;
    min-width: 200px;
}

.back-button {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.back-button:hover {
    background: var(--white);
    border-color: var(--accent-color);
}

.model-title {
    font-size: 2rem;
    color: var(--text-dark);
}

.button-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.delete-button {
    background: var(--danger-color);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.delete-button:hover {
    background: #dc2626;
}

/* Repairs */
.repairs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.repair {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: all 0.2s;
}

.repair.draggable {
    cursor: move;
}

.repair.out-of-stock {
    opacity: 0.7;
}

.repair-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
}

.repair-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.drag-handle {
    color: var(--text-light);
    cursor: grab;
    font-size: 1.25rem;
    user-select: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-light);
    padding: 0.25rem 0.5rem;
}

.repair-header h4 {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.out-of-stock-badge {
    background: #fee2e2;
    color: #dc2626;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.low-margin-badge {
    background: #fef3c7;
    color: #d97706;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.75rem;
    border: 1px solid #fcd34d;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.edit-name-btn, .remove-repair-btn, .duplicate-repair-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
    padding: 0.25rem 0.5rem;
    transition: transform 0.2s;
}

.edit-name-btn:hover, .remove-repair-btn:hover, .duplicate-repair-btn:hover {
    transform: scale(1.1);
}

.repair-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stock-control {
    display: flex;
    align-items: center;
}

.stock-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-dark);
}

.stock-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.repair-summary {
    padding: 1rem 1.5rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.repair-summary > .low-margin-badge {
    width: 100%;
    margin-bottom: 0.5rem;
    order: -1;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
}

.summary-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-dark);
}

.summary-item.highlight .summary-value {
    font-size: 1.25rem;
}

.summary-item.competitor-price {
    margin-left: auto;
}

.competitor-value {
    color: #fca5a5;
    font-weight: 600;
}

.repair-content {
    padding: 1.5rem;
}

.repair-section {
    margin-bottom: 1.5rem;
}

.repair-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.field-item.editable {
    flex-wrap: wrap;
}

.field-label {
    min-width: 120px;
    font-weight: 500;
    color: var(--text-dark);
}

.field-value {
    font-weight: 600;
    color: var(--text-dark);
}

.field-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    min-width: 150px;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.field-unit {
    color: var(--text-light);
    font-size: 0.875rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.calc-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 6px;
}

.calc-item.highlight {
    background: var(--accent-color);
    color: var(--white);
}

.calc-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    opacity: 0.8;
}

.calc-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.profit.good {
    color: var(--success-color);
}

.profit.bad {
    color: var(--danger-color);
}

.calc-item.highlight .profit {
    color: var(--white);
}

.comment-container {
    margin-top: 0.5rem;
}

.comment-display {
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 6px;
    color: var(--text-dark);
    line-height: 1.6;
}

.comment-display.empty {
    color: var(--text-light);
    font-style: italic;
}

.comment-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9375rem;
    font-family: inherit;
    resize: vertical;
}

.comment-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .repair-summary {
        flex-direction: column;
        gap: 1rem;
    }

    .calc-grid {
        grid-template-columns: 1fr;
    }
}
