@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Colors light theme */
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-active: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --primary: #6366f1;
    --primary-light: rgba(99, 102, 241, 0.1);
    --border: #e2e8f0;
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    
    --font-outfit: 'Outfit', sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

[data-theme="dark"] {
    /* Colors dark theme */
    --bg-primary: #0b0f19;
    --bg-card: #151c2c;
    --bg-active: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #818cf8;
    --primary-light: rgba(129, 140, 248, 0.15);
    --border: #223049;
    
    --success: #34d399;
    --success-light: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-outfit);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem;
    flex: 1;
}

/* App Header */
header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.5rem;
}

.brand-info h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.brand-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Toggle Theme Button */
.btn-toggle-theme {
    background: none;
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-toggle-theme:hover {
    background-color: var(--bg-active);
}

/* Navigation Tabs */
.tabs-nav {
    display: flex;
    gap: 0.5rem;
    background-color: var(--bg-card);
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    background: none;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background-color: var(--bg-active);
}

.tab-btn.active {
    color: white;
    background-color: var(--primary);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* Content Views */
.tab-view {
    display: none;
}

.tab-view.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards Grid Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-card-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.icon-blue { background-color: rgba(99, 102, 241, 0.1); color: var(--primary); }
.icon-green { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.icon-orange { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.icon-red { background-color: rgba(239, 68, 68, 0.1); color: var(--danger); }

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-card-footer {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Charts and grids */
.dashboard-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Common form inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: #4f46e5;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}

.btn-secondary {
    background-color: var(--bg-active);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--border);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Tables styling */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

th {
    background-color: var(--bg-active);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--bg-active);
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.badge-success {
    background-color: var(--success-light);
    color: var(--success);
}

.badge-danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge-warning {
    background-color: var(--warning-light);
    color: var(--warning);
}

/* Client Directory grid */
.client-directory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-bar {
    position: relative;
    max-width: 320px;
    width: 100%;
}

.search-bar input {
    width: 100%;
    padding-left: 2.5rem;
}

.search-bar::before {
    content: "🔍";
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.zone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.zone-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

.zone-card-header {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-light);
    color: var(--primary);
    display: flex;
    justify-content: space-between;
}

.zone-client-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.zone-client-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background-color: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: transform 0.1s;
}

.zone-client-item:hover {
    transform: translateX(4px);
    background-color: var(--bg-active);
}

.zone-client-name {
    font-weight: 500;
}

.zone-client-tel {
    color: var(--text-secondary);
}

/* Sales Tracking Delivery selector */
.delivery-selector-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Modal styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10005;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    max-width: 500px;
    width: 90%;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.settings-suppliers-hero {
    background: linear-gradient(135deg, rgba(34,197,94,0.10), rgba(59,130,246,0.08));
    border: 1px solid rgba(34,197,94,0.22);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.settings-suppliers-table th,
.settings-suppliers-table td {
    vertical-align: top;
}

.settings-suppliers-table td {
    padding: 0.55rem;
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
}

.settings-suppliers-table .supplier-name {
    font-weight: 700;
    color: var(--text-primary);
}

.settings-suppliers-table .supplier-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* Interactive custom number input inside tables */
.qty-input {
    width: 70px;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
    font-size: 0.85rem;
}

/* Floating message toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.52rem 0.8rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 10100;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    line-height: 1.25;
    max-width: min(360px, calc(100vw - 1rem));
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }

.update-reminder-banner {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 10090;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    width: min(360px, calc(100vw - 1rem));
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(245, 158, 11, 0.28);
    background: linear-gradient(135deg, rgba(245,158,11,0.10), rgba(59,130,246,0.08));
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
}

.update-reminder-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.2;
    font-size: 0.8rem;
}

.update-reminder-text strong {
    font-size: 0.83rem;
}

.update-reminder-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .modal-content {
        width: calc(100vw - 1rem);
        padding: 0.85rem;
    }

    .toast {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.75rem;
        width: auto;
        max-width: none;
        font-size: 0.78rem;
    }

    .update-reminder-banner {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 0.75rem;
        width: auto;
        max-width: none;
        padding: 0.5rem 0.65rem;
        gap: 0.45rem;
    }

    .update-reminder-text {
        font-size: 0.76rem;
    }

    .update-reminder-actions {
        gap: 0.3rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .update-reminder-actions .btn {
        padding: 0.3rem 0.55rem !important;
        font-size: 0.72rem !important;
    }
}

/* ==========================================================================
   PRINT STYLES (PDF EXPORT)
   ========================================================================== */
@media print {
    @page {
        size: portrait;
        margin: 10mm 10mm 10mm 10mm;
    }
    
    body.print-view-sales,
    body.print-view-expenses {
        @page {
            size: landscape;
            margin: 10mm 10mm 10mm 10mm;
        }
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 10pt !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Hide standard UI elements that shouldn't appear in PDF exports */
    body.print-active header,
    body.print-active .tabs-nav,
    body.print-active button,
    body.print-active .btn,
    body.print-active .btn-pdf,
    body.print-active .modal,
    body.print-active .search-bar,
    body.print-active #clientSearchInput,
    body.print-active .client-directory-header,
    body.print-active #disbursement-form button,
    body.print-active #disbursement-form input[type="text"],
    body.print-active #expense-form button,
    body.print-active #expense-form input[type="text"],
    body.print-active #expense-form div[style*="border-top"],
    body.print-active #disbursement-form div[style*="justify-content"] {
        display: none !important;
    }

    /* Hide the interactive "Action" columns from tables in print mode */
    body.print-active #view-sales table th:last-child,
    body.print-active #view-sales table td:last-child,
    body.print-active #disbursement-form table th:last-child,
    body.print-active #disbursement-form table td:last-child,
    body.print-active table:has(#broken-eggs-table-body) th:last-child,
    body.print-active table:has(#broken-eggs-table-body) td:last-child {
        display: none !important;
    }

    /* Clean checkboxes in print: hide unchecked, style checked as highlighted badges */
    body.print-active label:has(input[type="checkbox"]:not(:checked)) {
        display: none !important;
    }
    
    body.print-active input[type="checkbox"] {
        display: none !important;
    }
    
    body.print-active label:has(input[type="checkbox"]:checked) {
        font-weight: bold !important;
        border: 1px solid #000000 !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
        background: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Style select elements as clean text without dropdown arrows */
    body.print-active select {
        border: none !important;
        background: transparent !important;
        appearance: none !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        color: #000000 !important;
        font-weight: bold !important;
        font-size: 11pt !important;
        padding: 0 !important;
        margin: 0 !important;
        pointer-events: none !important;
        width: auto !important;
        text-align-last: left !important;
    }

    /* Hide views except active print view */
    body.print-active .tab-view {
        display: none !important;
    }

    body.print-view-dashboard #view-dashboard,
    body.print-view-sales #view-sales,
    body.print-view-expenses #view-expenses,
    body.print-view-clients #view-clients {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.print-active .container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Table styling for print */
    body.print-active table {
        border-collapse: collapse !important;
        width: 100% !important;
        page-break-inside: auto;
        font-size: 8pt !important; /* Slightly smaller font to guarantee columns fit */
        color: #000000 !important;
    }
    
    body.print-active tr {
        page-break-inside: avoid !important;
        page-break-after: auto !important;
    }

    body.print-active thead {
        display: table-header-group !important;
    }

    body.print-active tfoot {
        display: table-footer-group !important;
    }

    body.print-active th {
        background-color: #f1f5f9 !important;
        color: #000000 !important;
        border: 1px solid #cbd5e1 !important;
        font-weight: bold !important;
        padding: 4px 6px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body.print-active td {
        border: 1px solid #cbd5e1 !important;
        padding: 4px 6px !important;
        color: #000000 !important;
        background: transparent !important;
        word-break: break-word !important;
    }

    /* Flatten forms inputs in tables/cards */
    body.print-active input[type="number"],
    body.print-active input[type="text"] {
        border: none !important;
        background: transparent !important;
        color: #000000 !important;
        box-shadow: none !important;
        outline: none !important;
        padding: 0 !important;
        margin: 0 !important;
        font-weight: 500 !important;
        width: 100% !important;
        font-size: inherit !important;
    }

    /* Stats Grid for Dashboard print */
    body.print-active .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 12px !important;
        margin-bottom: 20px !important;
    }

    body.print-active .stat-card {
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 10px !important;
        page-break-inside: avoid !important;
    }

    body.print-active .stat-card-icon {
        display: none !important;
    }

    body.print-active .stat-card-value {
        font-size: 1.4rem !important;
        font-weight: 700 !important;
        color: #000000 !important;
    }

    body.print-active .dashboard-row {
        display: block !important;
    }

    body.print-active .card {
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        background: transparent !important;
        padding: 15px !important;
        margin-bottom: 20px !important;
        page-break-inside: avoid !important;
    }

    body.print-active .chart-container {
        height: 220px !important;
        page-break-inside: avoid !important;
    }

    body.print-active canvas {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Client view zone grid print */
    body.print-active .zone-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }

    body.print-active .zone-card {
        border: 1px solid #cbd5e1 !important;
        box-shadow: none !important;
        background: transparent !important;
        page-break-inside: avoid !important;
    }
}

/* ==========================================
   AUTH SCREEN & PRODUCT SELECTION
   ========================================== */

#auth-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 100%);
    overflow-y: auto;
    padding: 2rem 1rem;
    box-sizing: border-box;
}

#auth-screen::before {
    content: '';
    position: fixed;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%236366f1' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

#auth-screen.hidden {
    display: none;
}

/* Login Panel */
.auth-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.5s ease;
    margin: auto 0;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo-icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 0.5rem;
    filter: drop-shadow(0 0 20px rgba(99,102,241,0.6));
}

.auth-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
}

.auth-logo p {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
    margin-top: 0.25rem;
}

.auth-form-group {
    margin-bottom: 1.25rem;
}

.auth-form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-form-group input:not([type="checkbox"]) {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}

.auth-form-group input::placeholder {
    color: rgba(255,255,255,0.3);
}

.auth-form-group input:not([type="checkbox"]):focus {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.6);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.auth-error {
    background: rgba(239,68,68,0.15);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 10px;
    color: #fca5a5;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    display: none;
}

.auth-error.show { display: block; }

.btn-auth {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    margin-top: 0.5rem;
}

.btn-auth:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(99,102,241,0.4);
}

.auth-hint {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.35);
}

/* Product Selection Screen */
/* Product Selection Screen */
#product-select-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 800px;
    margin: auto 0;
    padding: 1rem 0;
    text-align: center;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

#product-select-screen.visible { display: flex; }

.product-screen-header {
    margin-bottom: 1.5rem;
    animation: fadeInUp 0.4s ease;
}

.product-screen-header .welcome-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border-radius: 9999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.78rem;
    color: #e2e8f0;
    margin-bottom: 0.75rem;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-screen-header h2 {
    font-size: 2.2rem;
    font-weight: 850;
    margin-bottom: 0.25rem;
    letter-spacing: -0.7px;
    background: linear-gradient(135deg, #ffffff 30%, #cbd5e1 70%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.product-screen-header p {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.45);
    font-weight: 400;
}

.product-cards-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
    animation: fadeInUp 0.5s ease 0.1s both;
    margin-bottom: 1rem;
}

.product-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 2rem 1.5rem;
    width: 170px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.product-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 0;
}

.product-card.active-product:hover::before {
    opacity: 1;
}

#product-card-oeufs::before {
    background: radial-gradient(circle at center, rgba(245, 158, 11, 0.15) 0%, transparent 70%);
}
#product-card-poissons::before {
    background: radial-gradient(circle at center, rgba(6, 182, 212, 0.15) 0%, transparent 70%);
}

.product-card:hover {
    transform: translateY(-6px) scale(1.02);
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
}

#product-card-oeufs:hover {
    box-shadow: 0 15px 30px rgba(245, 158, 11, 0.12), 0 0 0 1px rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.35);
}
#product-card-poissons:hover {
    box-shadow: 0 15px 30px rgba(6, 182, 212, 0.12), 0 0 0 1px rgba(6, 182, 212, 0.2);
    border-color: rgba(6, 182, 212, 0.35);
}

.product-card.active-product {
    border-color: rgba(255, 255, 255, 0.12);
}

.product-card-icon-container {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1rem;
    transition: all 0.4s ease;
    z-index: 1;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.05);
}

#product-card-oeufs .product-card-icon-container {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
}
#product-card-oeufs:hover .product-card-icon-container {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.25);
}

#product-card-poissons .product-card-icon-container {
    background: rgba(6, 182, 212, 0.08);
    border-color: rgba(6, 182, 212, 0.2);
}
#product-card-poissons:hover .product-card-icon-container {
    background: rgba(6, 182, 212, 0.18);
    border-color: rgba(6, 182, 212, 0.35);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.25);
}

.product-card-icon {
    font-size: 2.25rem;
    line-height: 1;
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.25));
}

.product-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.25rem;
    z-index: 1;
    letter-spacing: -0.2px;
}

.product-card-status {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    z-index: 1;
}

.product-card.coming-soon {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(255,255,255,0.01);
    border-style: dashed;
}

.product-card.coming-soon:hover {
    transform: none;
    box-shadow: none;
    border-color: rgba(255,255,255,0.08);
}

.coming-soon-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.25);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fbbf24;
    letter-spacing: 0.5px;
}

.product-screen-footer {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    animation: fadeInUp 0.5s ease 0.2s both;
    color: rgba(255,255,255,0.35);
    font-size: 0.8rem;
}

.btn-logout-product {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 9999px;
    padding: 0.4rem 1.15rem;
    color: #fca5a5;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout-product:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}

/* Responsive Scaling for Short Heights */
@media (max-height: 720px) {
    .product-screen-header {
        margin-bottom: 1rem;
    }
    .product-screen-header h2 {
        font-size: 1.8rem;
    }
    .product-screen-header .welcome-tag {
        margin-bottom: 0.5rem;
        padding: 0.25rem 0.75rem;
        font-size: 0.72rem;
    }
    .product-cards-row {
        gap: 1rem;
        margin-bottom: 0.75rem;
    }
    .product-card {
        padding: 1.5rem 1rem;
        width: 145px;
        border-radius: 16px;
    }
    .product-card-icon-container {
        width: 50px;
        height: 50px;
        margin-bottom: 0.75rem;
    }
    .product-card-icon {
        font-size: 1.8rem;
    }
    .product-card-name {
        font-size: 0.95rem;
    }
    .product-card-status {
        font-size: 0.7rem;
    }
    .product-screen-footer {
        margin-top: 1rem;
        gap: 0.4rem;
    }
}

/* Header user info */
.header-user-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-active);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.9rem 0.35rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-user-badge .user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
}

.btn-logout-header {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-logout-header:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.btn-password-header {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-password-header:hover {
    background: var(--bg-active);
    color: var(--primary);
}

/* Admin: User management modal */
.user-role-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.user-role-badge.admin {
    background: rgba(99,102,241,0.15);
    color: var(--primary);
    border: 1px solid rgba(99,102,241,0.3);
}

.user-role-badge.gestionnaire {
    background: rgba(16,185,129,0.12);
    color: var(--success);
    border: 1px solid rgba(16,185,129,0.3);
}

.user-role-badge.vendeur {
    background: rgba(245,158,11,0.12);
    color: var(--warning);
    border: 1px solid rgba(245,158,11,0.3);
}

/* Broken eggs alternating row colors */
.broken-row-group-a {
    background-color: rgba(99, 102, 241, 0.07) !important;
}

.broken-row-group-b {
    background-color: transparent !important;
}

[data-theme="dark"] .broken-row-group-a {
    background-color: rgba(99, 102, 241, 0.12) !important;
}

/* Reset button in admin zone */
.btn-reset-danger {
    background: var(--danger-light);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset-danger:hover {
    background: var(--danger);
    color: white;
}

/* Authentication Screen Signatures & Links */
.auth-signature {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.75rem;
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.auth-bottom-link {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    z-index: 100;
    letter-spacing: 0.5px;
}

.auth-bottom-link:hover {
    color: var(--primary);
}

/* Product Selection Settings Wheel Trigger */
.product-settings-trigger {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-settings-trigger:hover {
    background: rgba(255,255,255,0.15) !important;
    border-color: rgba(255,255,255,0.3) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.product-settings-trigger:active {
    transform: translateY(0);
}

/* Settings Modal Specifics */
.settings-tabs .tab-btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.settings-tabs .tab-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.settings-tabs .tab-btn:hover:not(.active) {
    background: var(--bg-active);
    color: var(--text-primary);
}

/* ============================================
   RESPONSIVE & MOBILE COMPATIBILITY (TABLETS & MOBILE)
   ============================================ */

/* Force vertical overflow containment for tables with inline vertical scrolls and add momentum scrolling */
div[style*="overflow-y: auto"],
.table-responsive,
.settings-modal-body {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

html, body {
    overflow-x: hidden;
    width: 100%;
}

@media (max-width: 768px) {
    /* Header layout */
    header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem !important;
        align-items: stretch;
        text-align: center;
    }
    
    .brand {
        justify-content: center;
    }
    
    .header-controls {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Modal responsiveness */
    .modal-content {
        width: 95% !important;
        padding: 1rem !important;
        margin: 10px !important;
    }

    /* Stack grid layouts */
    .dashboard-row,
    #view-expenses .dashboard-row {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    #expense-inputs-container {
        grid-template-columns: 1fr !important;
    }
    
    #create-user-form,
    #settings-create-user-form {
        grid-template-columns: 1fr !important;
    }
    
    #create-user-form button,
    #settings-create-user-form button {
        grid-column: span 1 !important;
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    /* Login screen adjustments */
    .auth-panel {
        padding: 1.5rem !important;
        max-width: 90% !important;
    }
    
    .auth-logo-icon {
        font-size: 2.5rem !important;
    }
    
    .auth-logo h1 {
        font-size: 1.75rem !important;
    }

    /* Product screen adjustments */
    .product-screen-header h2 {
        font-size: 1.75rem !important;
    }
    
    .product-card {
        width: 100% !important;
        max-width: 280px;
        padding: 1.5rem 1rem !important;
    }

    /* Tab navigation buttons compact view */
    .tab-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.8rem !important;
    }

    /* Table cells compact padding */
    th, td {
        padding: 0.5rem 0.4rem !important;
        font-size: 0.8rem !important;
    }
}
