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

/* Brand: gold/amber chrome on paper; green is reserved for money figures.
   Themes via data-theme on <html> */
:root,
html[data-theme="dark"] {
    --primary: #d97706;
    --primary-hover: #b45309;
    --primary-soft: rgba(217, 119, 6, 0.15);
    --secondary: #f59e0b;
    --accent: #fbbf24;
    --bg: #171412;
    --bg-elevated: #201b17;
    --card: rgba(255, 255, 255, 0.04);
    --card-border: rgba(255, 255, 255, 0.1);
    --text: #faf7f0;
    --text-muted: #a8a29e;
    --input-bg: rgba(255, 255, 255, 0.08);
    --input-text: #faf7f0;
    --header-bg: #171412;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --sidebar-hover: rgba(217, 119, 6, 0.12);
    color-scheme: dark;
}

html[data-theme="light"] {
    --primary: #b45309;
    --primary-hover: #92400e;
    --primary-soft: rgba(217, 119, 6, 0.12);
    --secondary: #d97706;
    --accent: #f59e0b;
    --bg: #faf7f0;
    --bg-elevated: #ffffff;
    --card: #ffffff;
    --card-border: rgba(180, 83, 9, 0.14);
    --text: #1c1917;
    --text-muted: #57534e;
    --input-bg: #faf5ec;
    --input-text: #1c1917;
    --header-bg: #ffffff;
    --shadow: 0 8px 24px rgba(28, 25, 23, 0.08);
    --sidebar-hover: rgba(217, 119, 6, 0.08);
    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    overflow-x: hidden;
    max-width: 100vw;
}

.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
}

.nav-active {
    color: var(--primary);
}

.nav-inactive {
    color: #94a3b8;
}

/* Only the active screen may show. Must beat .main-content > section { display:flex } */
.screen {
    display: none !important;
}

.screen.active {
    display: flex !important;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

.card {
    background: var(--card);
    border-radius: 2rem;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
    color: var(--text);
}

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid var(--card-border);
    background: var(--card);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.theme-toggle .theme-icon-sun { display: none; }
.theme-toggle .theme-icon-moon { display: inline; }

html[data-theme="light"] .theme-toggle .theme-icon-sun { display: inline; }
html[data-theme="light"] .theme-toggle .theme-icon-moon { display: none; }

/* Light theme: make common Tailwind slate/blue utility patches readable */
html[data-theme="light"] .text-slate-100,
html[data-theme="light"] .text-slate-200,
html[data-theme="light"] .text-white {
    color: var(--text) !important;
}

html[data-theme="light"] .bg-white\/5,
html[data-theme="light"] .bg-white\/10 {
    background: var(--primary-soft) !important;
}

html[data-theme="light"] .border-white\/10,
html[data-theme="light"] .border-white\/15 {
    border-color: var(--card-border) !important;
}

html[data-theme="light"] .sidebar-item.nav-inactive {
    color: var(--text-muted);
}

html[data-theme="light"] .sidebar-item:hover {
    background: var(--sidebar-hover);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-radius: 1rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary:active {
    transform: scale(0.95);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

/* Theme-safe accent text: readable on paper (light) AND dark cards.
   Use these instead of Tailwind -300 shades on themed surfaces. */
.money-claim {
    color: #047857;
}

.accent-warn {
    color: #b45309;
}

.accent-danger {
    color: #dc2626;
}

.accent-info {
    color: #2563eb;
}

html[data-theme="dark"] .money-claim {
    color: #34d399;
}

html[data-theme="dark"] .accent-warn {
    color: #fbbf24;
}

html[data-theme="dark"] .accent-danger {
    color: #f87171;
}

html[data-theme="dark"] .accent-info {
    color: #93c5fd;
}

/* Claim-board filter chips (classes assigned in app.js setBoardFilter) */
.board-chip {
    background: var(--input-bg);
    color: var(--text-muted);
    border-color: var(--card-border);
}

.board-chip.is-active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(217, 119, 6, 0.45);
}

.status-available {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.status-coming-soon {
    background: #e2e8f0;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

input:focus,
select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.auth-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    transition: all 0.3s ease;
}

.auth-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* Tab Styling */
#tab-analytics,
#tab-receipts {
    transition: all 0.2s ease;
}

#tab-analytics:hover,
#tab-receipts:hover {
    color: #b45309;
}

/* Filter Button Styling */
#needs-review-btn,
#bulk-select-btn,
#smart-filters-btn {
    transition: all 0.2s ease;
}

#needs-review-btn.active,
#bulk-select-btn.active {
    background: #b45309;
    color: white;
}

/* Floating TAX INFO Button Animation */
button[onclick="openTaxInfo()"] {
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Search Input Styling */
input[type="text"]::placeholder {
    color: #94a3b8;
}

/* Empty State Styling */
#empty-state {
    min-height: 300px;
}

#empty-state svg {
    opacity: 0.6;
}

/* New styles for Insights page */

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

.chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    /* Allows clicks to pass through to the chart */
}

.chart-center-text .amount {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
}

.chart-center-text .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.progress-bar-container {
    background-color: #e2e8f0;
    /* slate-200 */
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.progress-bar-fill {
    background-color: var(--primary);
    height: 100%;
    width: 0%;
    /* Will be set by JS */
    border-radius: 999px;
    transition: width 0.5s ease-in-out;
}

.horizontal-progress-bar-container {
    background-color: #e2e8f0;
    /* slate-200 */
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.horizontal-progress-bar-fill {
    background-color: var(--primary);
    height: 100%;
    width: 0%;
    /* Will be set by JS */
    border-radius: 999px;
    transition: width 0.5s ease-in-out;
}

/* Modal & Dialog Enhancements */
.modal-overlay {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.modal-content {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.premium-dialog {
    background: #0f172a;
    border-radius: 2.5rem;
    color: var(--text);
}

.premium-btn-confirm {
    background: linear-gradient(135deg, #b45309 0%, #f59e0b 100%);
    box-shadow: 0 10px 15px -3px rgba(0, 119, 182, 0.3);
}

.premium-btn-cancel {
    background: var(--card-border);
    color: #475569;
}

.premium-btn-cancel:hover {
    background: #e2e8f0;
}

/* ————————————————————————————————————————————————————————————
 * Till-roll: SlipSaver's tax verdict, printed back like a thermal receipt.
 * Applied to #sars-claim-summary in the slip modal. Warm paper, monospace
 * ink, torn zigzag top/bottom edges, dashed line-item rules. Claim-money
 * figures stay green (money = --claim); everything else is receipt ink.
 * ———————————————————————————————————————————————————————————— */
.till-roll {
    --till-paper: #fbfaf4;
    --till-ink: #33322c;
    --till-faint: #8a887e;
    position: relative;
    background: var(--till-paper);
    color: var(--till-ink);
    font-family: var(--font-data, 'IBM Plex Mono', ui-monospace, monospace);
    border-radius: 2px;
    padding: 18px 18px 14px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), 0 14px 26px -16px rgba(6, 20, 15, 0.4);
    /* faint thermal-paper horizontal grain */
    background-image: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.014) 0 1px, transparent 1px 3px);
}

/* torn-off zigzag bottom edge — paper triangles over the dark modal surface,
 * like a slip torn from the printer roll. The top stays straight (printer feed). */
.till-roll::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -8px;
    height: 8px;
    background:
        linear-gradient(-45deg, var(--till-paper) 8px, transparent 0) 0 0,
        linear-gradient(45deg, var(--till-paper) 8px, transparent 0) 0 0;
    background-repeat: repeat-x;
    background-size: 16px 16px;
}

.till-head {
    text-align: center;
    margin-bottom: 8px;
}

.till-brand {
    font-weight: 700;
    letter-spacing: 0.42em;
    font-size: 0.9rem;
    margin-right: -0.42em;
    /* re-centre the letter-spacing */
}

.till-sub {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: var(--till-faint);
    margin-top: 2px;
}

.till-badge-row {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.till-rule {
    border: 0;
    border-top: 1.5px solid var(--till-ink);
    opacity: 0.6;
    margin: 10px 0;
}

.till-rule.dashed {
    border-top: 1px dashed var(--till-faint);
    opacity: 1;
}

.till-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.till-row.col {
    flex-direction: column;
    gap: 2px;
}

.till-q {
    font-size: 0.66rem;
    letter-spacing: 0.02em;
    color: var(--till-faint);
    text-transform: uppercase;
}

.till-a {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--till-ink);
    margin-top: 2px;
    line-height: 1.3;
}

.till-amt {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--till-faint);
    /* not-claimable default */
}

.till-amt.claim {
    color: var(--claim);
}

.till-missing {
    margin-top: 6px;
    padding-left: 16px;
    list-style: square;
    font-size: 0.7rem;
    color: #9a5b12;
}

.till-input {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(154, 91, 18, 0.06);
    border: 1px dashed #c99a4e;
    border-radius: 4px;
}

.till-note {
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--till-faint);
    margin-top: 8px;
}

.till-foot {
    text-align: center;
    font-size: 0.56rem;
    letter-spacing: 0.14em;
    color: var(--till-faint);
    margin-top: 10px;
}

/* faux barcode strip under the footer text */
.till-foot::after {
    content: "";
    display: block;
    height: 26px;
    margin: 8px auto 0;
    width: 62%;
    background-image: repeating-linear-gradient(90deg,
            var(--till-ink) 0 1px, transparent 1px 2px,
            var(--till-ink) 2px 5px, transparent 5px 7px,
            var(--till-ink) 7px 8px, transparent 8px 11px);
    opacity: 0.72;
}

.icon-box {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.icon-box-error {
    background: #fee2e2;
    color: #ef4444;
}

.icon-box-success {
    background: #dcfce7;
    color: #22c55e;
}

.icon-box-info {
    background: #e0f2fe;
    color: #0ea5e9;
}

.icon-box-warning {
    background: #fef3c7;
    color: #f59e0b;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-up {
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ========================================
   RESPONSIVE LAYOUT SYSTEM
   ======================================== */

/* App Layout Container */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    max-width: 100vw;
    overflow: hidden;
}

/* Keep whole app chrome inside the viewport.
   IMPORTANT: #app-ui { display:flex } used to beat Tailwind .hidden
   (class specificity loses to ID), so login + app stacked ("stuck" UI). */
#app-ui {
    display: none;
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

#app-ui:not(.hidden) {
    display: flex;
}

#app-ui.hidden {
    display: none !important;
}

/* Auth must fully cover app when visible; never stack with app chrome.
   Light theme matches the landing page. Overlay itself scrolls so short
   mobile viewports (keyboard open) can reach logo + form + button.
   Pattern: outer scrolls; inner min-height:100% centers when short and
   grows when tall — never use justify-center on the scroll container. */
#auth-overlay,
#auth-overlay.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 0% 0%, rgba(217, 119, 6, 0.14) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(180, 83, 9, 0.10) 0%, transparent 50%),
        #faf7f0 !important;
    opacity: 1 !important;
    box-sizing: border-box;
    text-align: center;
    color: #1c1917;
}

#auth-overlay .auth-overlay-inner {
    box-sizing: border-box;
    width: 100%;
    min-height: 100%;
    min-height: 100dvh;
    margin: 0 auto;
    padding:
        max(1.5rem, env(safe-area-inset-top, 0px))
        max(1.25rem, env(safe-area-inset-right, 0px))
        max(1.5rem, env(safe-area-inset-bottom, 0px))
        max(1.25rem, env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

#auth-overlay .auth-brand {
    margin-bottom: 1.5rem;
}

#auth-overlay .auth-logo {
    height: 6.5rem;
    width: auto;
    object-fit: contain;
    margin: 0 auto 1rem;
    display: block;
}

#auth-overlay .auth-tagline {
    margin: 0 auto;
    max-width: 18rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.45;
    color: #4b5563;
}

#auth-overlay .auth-card {
    width: 100%;
    max-width: 24rem;
    padding: 1.75rem 1.5rem;
    border-radius: 1.75rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(180, 83, 9, 0.15);
    box-shadow:
        0 20px 50px -20px rgba(180, 83, 9, 0.22),
        0 4px 16px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
    box-sizing: border-box;
}

#auth-overlay .auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#auth-overlay .auth-field label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7280;
    padding-left: 0.25rem;
}

#auth-overlay .auth-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.95rem 1.15rem;
    border-radius: 1rem;
    border: 1.5px solid #e3e8e4;
    background: #f8faf9;
    color: #14201b;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    /* 16px+ avoids iOS zoom-on-focus which breaks layout */
}

#auth-overlay .auth-field input::placeholder {
    color: #9ca3af;
}

#auth-overlay .auth-field input:focus {
    border-color: #d97706;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.12);
}

#auth-overlay .auth-google-wrap {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    width: 100%;
}

#auth-overlay .auth-google-wrap.hidden {
    display: none !important;
}

#auth-overlay .auth-google-btn-host {
    width: 100%;
    display: flex;
    justify-content: center;
    min-height: 44px;
}

/* GIS iframe button can overflow — keep it inside the card */
#auth-overlay .auth-google-btn-host > div {
    width: 100% !important;
    display: flex !important;
    justify-content: center;
}

#auth-overlay .auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

#auth-overlay .auth-divider::before,
#auth-overlay .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e3e8e4;
}

#auth-overlay .auth-submit {
    width: 100%;
    margin-top: 0.25rem;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 1rem;
    background: #b45309;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 24px -8px rgba(180, 83, 9, 0.45);
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

#auth-overlay .auth-submit:hover {
    background: #92400e;
}

#auth-overlay .auth-submit:active {
    transform: scale(0.98);
}

#auth-overlay .auth-demo-hint {
    margin: 0;
    text-align: center;
    font-size: 0.7rem;
    color: #6b7280;
}

#auth-overlay .auth-demo-hint.hidden {
    display: none;
}

#auth-overlay .auth-back {
    display: block;
    margin-top: 0.25rem;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    text-decoration: none;
    transition: color 0.15s ease;
}

#auth-overlay .auth-back:hover {
    color: #b45309;
}

#auth-overlay .auth-title {
    margin: 0 0 1rem;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
}

#auth-overlay .auth-toggle-line {
    margin: 0.9rem 0 0;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
}

#auth-overlay .auth-toggle-line a {
    color: #b45309;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

#auth-overlay .auth-toggle-line a:hover {
    text-decoration: underline;
}

#auth-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

@media (max-width: 480px) {
    #auth-overlay .auth-logo {
        height: 5rem;
    }

    #auth-overlay .auth-card {
        padding: 1.35rem 1.15rem;
        border-radius: 1.35rem;
    }

    #auth-overlay .auth-tagline {
        font-size: 0.9375rem;
        margin-bottom: 0;
    }
}

/* Sidebar Navigation (Desktop/Tablet) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg);
    border-right: 1px solid var(--card-border);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.5rem 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
}

.sidebar-logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: inherit;
}

.sidebar-item:hover {
    background: var(--sidebar-hover);
}

.sidebar-item.nav-active {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28);
}

.sidebar-item.nav-inactive {
    color: #64748b;
}

.sidebar-item-secondary {
    margin-top: auto;
    border-top: 1px solid var(--card-border);
    padding-top: 1rem;
}

.sidebar-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

.sidebar-text {
    flex: 1;
}

/* Desktop Header */
.desktop-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--header-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 2rem;
}

.desktop-header h1 {
    color: var(--text) !important;
}

.desktop-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
}

/* Mobile Header */
.mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.hamburger-btn {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: 0.5rem;
    transition: background 0.2s;
}

.hamburger-btn:hover {
    background: #f8fafc;
}

.mobile-logout-btn {
    padding: 0.5rem;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.mobile-logout-btn:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 45;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Main Content Area
   IMPORTANT: with a fixed 260px sidebar, never use width:100% + margin-left:260px
   or the page overflows the window (search/filter bars cut off). */
.main-content {
    flex: 1 1 auto;
    padding: 1.25rem 1rem 5rem;
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow-x: hidden !important;
    overflow-y: auto;
    min-width: 0;
    min-height: 0; /* critical for flex child scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Do NOT force display on sections here — it overrode .screen { display:none }
   and made every page (Home/AI/Insights/Business/Profile) show at once. */
.main-content > section.screen.active {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
    padding-bottom: 1rem;
}

/* Every card/row must shrink inside the content column */
.main-content .card,
.main-content .grid,
.main-content input,
.main-content select,
.main-content button,
.main-content img {
    max-width: 100%;
    box-sizing: border-box;
}

#screen-profile,
#screen-home,
#screen-insights {
    max-width: 100%;
    overflow-x: hidden;
}

#screen-profile .card {
    overflow: hidden;
}

#screen-profile .flex {
    min-width: 0;
    flex-wrap: wrap;
}

#screen-profile .flex-1,
#screen-profile .space-y-1 {
    min-width: 0;
    max-width: 100%;
}

/* Danger zone text stays inside the card */
#screen-profile .card p,
#screen-profile .card li,
#screen-profile .card h4 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Single primary scan button */
.scan-combo-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin: 0;
    border: none;
    border-radius: 999px;
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(217, 119, 6, 0.28);
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.scan-combo-primary:hover {
    background: var(--primary-hover);
}

.scan-combo-primary:active {
    transform: scale(0.99);
}

/* Home search / filters stay inside the content column */
#receipts-section,
#screen-home,
#screen-ai,
#screen-insights,
#screen-business,
#screen-profile {
    max-width: 100%;
    min-width: 0;
}

#receipt-search {
    max-width: 100%;
    width: 100%;
}

#receipts-section .grid {
    width: 100%;
    max-width: 100%;
}

#receipts-section select {
    min-width: 0;
    max-width: 100%;
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Mobile (<768px) - Default styles above */
@media (max-width: 767px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .desktop-header {
        display: none;
    }

    .mobile-header {
        display: flex;
    }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar {
        width: 220px;
    }

    .mobile-header {
        display: flex;
    }

    .desktop-header {
        display: none;
    }

    .main-content {
        margin-left: 220px;
        width: calc(100% - 220px);
        max-width: calc(100vw - 220px);
        height: 100vh;
        padding: 1.25rem 1.25rem 5rem;
    }

    .desktop-header-content {
        max-width: 100%;
    }

    /* Responsive grids for tablets */
    #screen-insights .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop (≥1024px) */
@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        width: 260px;
    }

    .mobile-header {
        display: none;
    }

    .desktop-header {
        display: block;
        margin-left: 260px;
        width: calc(100% - 260px);
        max-width: calc(100vw - 260px);
        box-sizing: border-box;
        padding: 1rem 1.5rem;
    }

    .desktop-header-content {
        max-width: 960px;
        margin: 0;
    }

    .main-content {
        margin-left: 260px;
        width: calc(100% - 260px);
        max-width: calc(100vw - 260px);
        height: 100vh;
        padding: 1.25rem 1.5rem 5rem;
    }

    .sidebar-overlay {
        display: none !important;
    }

    /* Responsive grids for desktop */
    #screen-insights .space-y-4>.card:first-child {
        grid-column: span 1;
    }

    /* Stats cards in grid */
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* Large Desktop (≥1280px) */
@media (min-width: 1280px) {
    .main-content {
        padding: 2rem 2.5rem 6rem;
        /* Cap content width inside the remaining viewport, not the full 100vw */
        max-width: calc(100vw - 260px);
    }

    .desktop-header-content {
        max-width: 1100px;
    }
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 1024px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Responsive text sizes */
@media (max-width: 767px) {

    h1,
    .text-3xl {
        font-size: 1.75rem;
    }

    h2,
    .text-2xl {
        font-size: 1.5rem;
    }
}

/* Responsive card layouts */
@media (min-width: 768px) {
    .responsive-grid-2 {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .responsive-grid-3 {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ========================================
   PHASE 3: ONBOARDING WIZARD
   ======================================== */

.wizard-step {
    animation: wizardSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes wizardSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ========================================
   PHASE 3: SMART FILTER CHIPS
   ======================================== */

.chip-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    overflow-x: auto;
    max-width: 100%;
    padding: 0.25rem 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.chip-bar::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
    padding: 0.5rem 0.875rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--card-border);
    color: #475569;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.filter-chip:hover {
    background: #e2e8f0;
}

.filter-chip.active {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--secondary) 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.28);
}

/* ========================================
   PHASE 3: EXPORT MODAL
   ======================================== */

.export-option-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    padding: 1rem;
    border-radius: 1.25rem;
    border: 2px solid var(--card-border);
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-option-btn:hover {
    border-color: #b45309;
    background: #f8fafc;
    box-shadow: 0 4px 12px rgba(0, 119, 182, 0.1);
    transform: translateY(-1px);
}

.export-option-btn:active {
    transform: scale(0.98);
}

/* Toast Progress Animation */
@keyframes toastProgress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.animate-toast-progress {
    animation: toastProgress 4s linear forwards;
}
/* ---- Theme polish: headings & muted copy use CSS vars ---- */
#greeting-text,
.main-content h1,
.main-content h2,
.main-content h3,
.main-content h4 {
    color: var(--text);
}

html[data-theme="light"] .text-slate-800,
html[data-theme="light"] .text-slate-900 {
    color: var(--text) !important;
}

html[data-theme="light"] .text-slate-400,
html[data-theme="light"] .text-slate-500 {
    color: var(--text-muted) !important;
}

html[data-theme="light"] .bg-slate-100 {
    background-color: var(--input-bg) !important;
    color: var(--input-text) !important;
}

html[data-theme="light"] body {
    background-color: var(--bg);
    color: var(--text);
}

html[data-theme="dark"] #greeting-text {
    color: var(--text);
}
