/* ============================================================
   Cosmic Books — Design System
   Modern fintech: flat neutrals, one accent, tight rhythm.

   Theming: every colour is a token. Dark mode re-declares the
   SAME tokens under [data-theme="dark"], including an inverted
   --gray-* ramp, so any rule (or inline style) written against
   var(--gray-N) flips correctly without being touched.
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Accent */
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --primary-soft: #eef2ff;
    --primary-rgb: 79, 70, 229;

    /* Semantic */
    --success: #059669;
    --success-light: #34d399;
    --success-soft: #ecfdf5;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --danger: #dc2626;
    --danger-light: #f87171;
    --danger-soft: #fef2f2;
    --info: #0284c7;
    --info-soft: #f0f9ff;

    /* Legacy aliases (kept: referenced by existing markup) */
    --secondary: #1e293b;
    --secondary-light: #334155;
    --light: #f8fafc;
    --dark: #0f172a;

    /* Neutral ramp — slate. Inverted under dark. */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Surfaces & text */
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --surface-3: #eef2f7;
    --surface-inset: #f8fafc;
    --border: #e4e9f0;
    --border-strong: #cfd8e3;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #64748b;

    /* Sidebar */
    --sidebar-width: 270px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #475569;
    --sidebar-text-active: #0f172a;
    --sidebar-hover: #f1f5f9;
    --sidebar-active: #eef2ff;
    --sidebar-border: #e4e9f0;
    --sidebar-section: #94a3b8;

    /* Depth — hairlines first, shadow second */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
    --shadow-md: 0 2px 4px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .06);
    --shadow-lg: 0 4px 8px rgba(15, 23, 42, .04), 0 12px 28px rgba(15, 23, 42, .10);
    --shadow-xl: 0 8px 16px rgba(15, 23, 42, .06), 0 24px 48px rgba(15, 23, 42, .14);
    --ring: 0 0 0 3px rgba(var(--primary-rgb), .18);

    --radius: 10px;
    --radius-sm: 8px;
    --radius-lg: 14px;
    --radius-pill: 999px;
}

[data-theme="dark"] {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --primary-soft: #1e1b4b;
    --primary-rgb: 99, 102, 241;

    --success: #10b981;
    --success-light: #34d399;
    --success-soft: #052e21;
    --warning: #f59e0b;
    --warning-soft: #3a2606;
    --danger: #f05252;
    --danger-light: #f87171;
    --danger-soft: #3d1414;
    --info: #38bdf8;
    --info-soft: #082f49;

    --secondary: #cbd5e1;
    --secondary-light: #e2e8f0;
    --light: #161b26;
    --dark: #e6edf7;

    /* Inverted ramp — 50 is darkest, 900 is lightest */
    --gray-50:  #161b26;
    --gray-100: #1c2230;
    --gray-200: #29313f;
    --gray-300: #3b4453;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #aab6c8;
    --gray-700: #c4cede;
    --gray-800: #dce4ef;
    --gray-900: #eef2f8;

    --surface: #161b26;
    --surface-2: #0d1117;
    --surface-3: #1c2230;
    --surface-inset: #11161f;
    --border: #29313f;
    --border-strong: #3b4453;
    --text: #e6edf7;
    --text-2: #aab6c8;
    --text-3: #8b97a8;

    --sidebar-bg: #11161f;
    --sidebar-text: #aab6c8;
    --sidebar-text-active: #ffffff;
    --sidebar-hover: #1c2230;
    --sidebar-active: #232a4d;
    --sidebar-border: #242c39;
    --sidebar-section: #6b7688;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
    --shadow: 0 1px 3px rgba(0, 0, 0, .38);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .44);
    --shadow-lg: 0 12px 28px rgba(0, 0, 0, .52);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, .60);
    --ring: 0 0 0 3px rgba(var(--primary-rgb), .32);

    color-scheme: dark;
}

html { background: var(--surface-2); }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--surface-2);
    color: var(--text);
    line-height: 1.55;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* Money and any figure should align in a column. */
td, th, input[type="number"],
.stat-info h3, .amount, .receipt-amount,
.ratio-value, .fs-line, .je-totals,
.credit-card-balance .amount {
    font-variant-numeric: tabular-nums;
}

a { color: var(--primary); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- Login ---------- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
}

/* Soft accent wash — replaces the old animated rainbow gradient. */
.login-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(900px 480px at 15% -10%, rgba(var(--primary-rgb), .16), transparent 60%),
        radial-gradient(760px 420px at 105% 110%, rgba(16, 185, 129, .12), transparent 60%);
    pointer-events: none;
}

.login-box {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    padding: 40px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-box h1 {
    text-align: center;
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -.02em;
    color: var(--text);
    margin-bottom: 4px;
}

.login-logo {
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
}

/* The logo mark comes in a light-theme and a dark-theme version (public/brand/); only the theme's one shows. */
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .login-logo.logo-dark { display: block !important; }
[data-theme="dark"] .sidebar-logo.logo-dark { display: inline-block !important; }

/* ---------- App Layout ---------- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    z-index: 1000;
}

.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 99px;
    border: 2px solid var(--sidebar-bg);
}
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    background: var(--sidebar-bg);
    z-index: 2;
}

.sidebar-header h2 {
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.015em;
    color: var(--sidebar-text-active);
}

.sidebar-logo {
    width: 30px;
    height: 30px;
    flex: none;
}

.sidebar-nav { padding: 12px 12px 32px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 1px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--primary);
    font-weight: 600;
}

[data-theme="dark"] .nav-item.active { color: var(--primary-light); }

.nav-section {
    font-size: 10.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--sidebar-section);
    padding: 0 12px 6px;
    margin-top: 18px;
}

.sidebar-nav .nav-section { margin-top: 18px; }
.sidebar-nav .nav-section:first-child { margin-top: 4px; }

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    background: var(--surface-2);
    min-width: 0;
}

/* ---------- Top Bar ---------- */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 32px;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar h1 {
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -.02em;
    color: var(--text);
}

.user-menu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
    padding: 6px 12px;
    border-left: 1px solid var(--border);
}

.user-info .name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.user-info .role {
    font-size: 11px;
    color: var(--text-3);
    text-transform: capitalize;
}

/* Theme toggle */
.theme-toggle {
    flex: none;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.theme-toggle:hover {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--primary-light);
}
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Page Content ---------- */
.page-content { padding: 28px 32px 56px; }

.page {
    display: none;
    animation: fadeIn .22s ease;
}

.page.active { display: block; }

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.card-header h2 {
    font-size: 14.5px;
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--text);
}

/* A search box living in a card header. .form-control is width:100%, which in a
   flex header would shove the title and buttons aside; this caps it and pushes
   it to the right beside the actions. flex-wrap on .card-header drops it onto
   its own line on narrow screens. */
.card-header .table-search {
    flex: 1 1 220px;
    max-width: 340px;
    margin-left: auto;
}

.card-body { padding: 20px; }
.card-body > .table-container:only-child,
.card-body > table:only-child { margin: -20px; width: calc(100% + 40px); }

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.stat-card:hover { border-color: var(--border-strong); }

.clickable-card { cursor: pointer; }
.clickable-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    font-size: 18px;
    line-height: 1;
}

/* Tinted, not glossy — the number is the hero, not the chip. */
.stat-icon.blue   { background: rgba(79, 70, 229, .10);  color: #4f46e5; }
.stat-icon.green  { background: rgba(5, 150, 105, .10);  color: #059669; }
.stat-icon.orange { background: rgba(217, 119, 6, .12);  color: #d97706; }
.stat-icon.red    { background: rgba(220, 38, 38, .10);  color: #dc2626; }
.stat-icon.purple { background: rgba(139, 92, 246, .12); color: #8b5cf6; }

[data-theme="dark"] .stat-icon.blue   { background: rgba(129, 140, 248, .16); color: #a5b4fc; }
[data-theme="dark"] .stat-icon.green  { background: rgba(52, 211, 153, .16);  color: #6ee7b7; }
[data-theme="dark"] .stat-icon.orange { background: rgba(251, 191, 36, .16);  color: #fcd34d; }
[data-theme="dark"] .stat-icon.red    { background: rgba(248, 113, 113, .16); color: #fca5a5; }
[data-theme="dark"] .stat-icon.purple { background: rgba(167, 139, 250, .18); color: #c4b5fd; }

.stat-info { min-width: 0; }

.stat-info h3 {
    font-size: 23px;
    font-weight: 650;
    letter-spacing: -.025em;
    line-height: 1.15;
    color: var(--text);
}

.stat-info p {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    margin-top: 3px;
}

/* ---------- Tables ---------- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 11px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-inset);
    font-weight: 600;
    color: var(--text-3);
    white-space: nowrap;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    position: sticky;
    top: 0;
    z-index: 1;
}

td { color: var(--text-2); font-size: 13.5px; }
td strong, td b { color: var(--text); font-weight: 600; }

tbody tr { transition: background .1s ease; }
tbody tr:hover { background: var(--surface-inset); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.65;
    white-space: nowrap;
    border: 1px solid transparent;
}

/* Status dot — instant scan down a column of rows. */
.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.badge-success   { background: var(--success-soft); color: #047857; border-color: rgba(5, 150, 105, .22); }
.badge-warning   { background: var(--warning-soft); color: #b45309; border-color: rgba(217, 119, 6, .22); }
.badge-danger    { background: var(--danger-soft);  color: #b91c1c; border-color: rgba(220, 38, 38, .22); }
.badge-info      { background: var(--info-soft);    color: #0369a1; border-color: rgba(2, 132, 199, .22); }
.badge-secondary { background: var(--surface-3);    color: var(--text-2); border-color: var(--border); }

[data-theme="dark"] .badge-success { background: rgba(16, 185, 129, .13); color: #6ee7b7; border-color: rgba(16, 185, 129, .26); }
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, .13); color: #fcd34d; border-color: rgba(245, 158, 11, .26); }
[data-theme="dark"] .badge-danger  { background: rgba(240, 82, 82, .13);  color: #fca5a5; border-color: rgba(240, 82, 82, .26); }
[data-theme="dark"] .badge-info    { background: rgba(56, 189, 248, .13); color: #7dd3fc; border-color: rgba(56, 189, 248, .26); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.45;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
    transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease;
}

.btn:active { transform: translateY(.5px); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:focus-visible { box-shadow: var(--ring); }

.btn-success { background: var(--success); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover { filter: brightness(.93); }

.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover { filter: brightness(.93); }

.btn-warning { background: var(--warning); color: #fff; box-shadow: var(--shadow-sm); }
.btn-warning:hover { filter: brightness(.93); }

.btn-secondary {
    background: var(--surface);
    color: var(--text-2);
    border-color: var(--border-strong);
}
.btn-secondary:hover {
    background: var(--surface-3);
    color: var(--text);
    border-color: var(--gray-400);
}

.btn-sm { padding: 5px 11px; font-size: 12.5px; }

.btn-icon {
    padding: 6px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}
.btn-icon:hover {
    background: var(--surface-3);
    color: var(--primary);
    border-color: var(--primary-light);
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--primary);
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.link-button:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }

.form-group label,
.section-divider h4 + label {
    display: block;
    margin-bottom: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.form-control:hover:not(:focus) { border-color: var(--gray-400); }

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.form-control::placeholder { color: var(--gray-400); }
.form-control:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 32px;
}

textarea.form-control { line-height: 1.55; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.form-grid { gap: 16px; }

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.section-divider {
    margin: 24px 0 16px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.section-divider h4 {
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3);
    margin-bottom: 12px;
}

.checkbox-label,
.recon-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
}

input[type="checkbox"], input[type="radio"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
    flex: none;
}

/* ---------- Search & Filter Bar ---------- */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 18px;
}

.search-box {
    position: relative;
    flex: 1 1 240px;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}
.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 13px;
    pointer-events: none;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(10px) scale(.985);
    transition: transform .18s cubic-bezier(.4, 0, .2, 1);
}

.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex: none;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -.015em;
    color: var(--text);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background .12s, color .12s;
}
.modal-close:hover { background: var(--surface-3); color: var(--danger); }

/* Most modals wrap their body and footer in a <form>, which makes the form -- not
   .modal-body -- the flex child of .modal. A plain block form has no height
   constraint, so it grew to its full content height, .modal's max-height clipped
   it, and .modal-body never became a scroll container because nothing bounded it:
   anything below the fold in a tall form was simply unreachable. It only showed on
   forms taller than the viewport, so the biggest one (Edit Client) surfaced it.
   The form has to be both a flex ITEM of .modal and a flex CONTAINER for the body. */
.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

/* min-height:0 is the load-bearing part. A flex item defaults to min-height:auto,
   which refuses to shrink below its content -- that alone defeats overflow-y:auto
   inside any flex column, whether the body sits under a form or directly in .modal. */
.modal-body { padding: 22px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    background: var(--surface-inset);
    flex: none;
    flex-wrap: wrap;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
    border: 1px solid transparent;
    border-left-width: 3px;
}

.alert-success { background: var(--success-soft); color: #047857; border-color: rgba(5, 150, 105, .25); border-left-color: var(--success); }
.alert-danger  { background: var(--danger-soft);  color: #b91c1c; border-color: rgba(220, 38, 38, .25); border-left-color: var(--danger); }
.alert-warning { background: var(--warning-soft); color: #b45309; border-color: rgba(217, 119, 6, .25); border-left-color: var(--warning); }
.alert-info    { background: var(--info-soft);    color: #0369a1; border-color: rgba(2, 132, 199, .25); border-left-color: var(--info); }

[data-theme="dark"] .alert-success { background: rgba(16, 185, 129, .10); color: #6ee7b7; }
[data-theme="dark"] .alert-danger  { background: rgba(240, 82, 82, .10);  color: #fca5a5; }
[data-theme="dark"] .alert-warning { background: rgba(245, 158, 11, .10); color: #fcd34d; }
[data-theme="dark"] .alert-info    { background: rgba(56, 189, 248, .10); color: #7dd3fc; }

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: 380px;
    padding: 12px 16px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn .24s cubic-bezier(.4, 0, .2, 1);
}

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

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ---------- Spinner & Loading ---------- */
.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}

.processing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-light);
    border-radius: var(--radius);
    color: var(--primary-dark);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
}

[data-theme="dark"] .processing-indicator { color: var(--primary-light); }

.processing-indicator .spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
    flex: none;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-3);
    font-size: 13.5px;
}

.empty-state i {
    display: block;
    font-size: 34px;
    margin-bottom: 12px;
    color: var(--gray-300);
}

/* ---------- Action Buttons ---------- */
.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ---------- Invoice / Quote line items ---------- */
.invoice-item,
.quote-item {
    display: grid;
    gap: 10px;
    padding: 14px;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.tpl-row {
    padding: 6px;
    border-radius: var(--radius-sm);
}
.tpl-row:hover { background: var(--surface-inset); }
.tpl-desc { font-weight: 500; }
.tpl-qty, .tpl-price { font-variant-numeric: tabular-nums; }
.tpl-active { color: var(--success); }

/* ---------- Mobile Menu Button ---------- */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 0 7px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex: none;
}

.mobile-menu-btn:hover { background: var(--surface-3); }

.mobile-menu-btn span {
    display: block;
    height: 1.5px;
    width: 100%;
    background: var(--text-2);
    border-radius: 2px;
    transition: transform .22s ease, opacity .22s ease;
}

.mobile-menu-btn.active span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.mobile-menu-btn.active span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.active span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

/* ---------- Sidebar Close (mobile) ---------- */
.sidebar-close {
    display: none;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 30px;
    height: 30px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
}
.sidebar-close:hover { background: var(--surface); color: var(--danger); }

/* ---------- Mobile Overlay ---------- */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
}

.mobile-overlay.active { opacity: 1; visibility: visible; }

/* ---------- Upload Drop Zone ---------- */
.upload-zone {
    position: relative;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 36px 24px;
    text-align: center;
    background: var(--surface-inset);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.upload-zone.dragover { border-style: solid; }

.upload-zone-icon { font-size: 34px; margin-bottom: 10px; color: var(--gray-400); }
.upload-zone h3 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-zone p { font-size: 13px; color: var(--text-3); }
.upload-zone input[type="file"] { display: none; }

/* ---------- Receipts ---------- */
.receipt-preview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.receipt-image {
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.receipt-image img { max-width: 100%; height: auto; display: block; }

.receipt-image iframe,
.receipt-image embed {
    width: 100%;
    height: 520px;
    border: none;
    display: block;
}

.receipt-form { min-width: 0; }

.receipt-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 16px;
}

.receipt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-strong);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.receipt-card:hover { box-shadow: var(--shadow-md); }
.receipt-card.needs-info { border-left-color: var(--warning); }
.receipt-card.pending { border-left-color: var(--info); }

.receipt-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13.5px;
    color: var(--text);
}

.receipt-card-body { padding: 13px 15px; }
.receipt-card-body p { font-size: 12.5px; color: var(--text-3); margin-bottom: 5px; }
.receipt-card-body p strong { color: var(--text-2); font-weight: 600; }

.receipt-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 15px;
    border-top: 1px solid var(--border);
    background: var(--surface-inset);
    flex-wrap: wrap;
}

.receipt-amount {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -.02em;
    color: var(--text);
}

.receipt-tab-content { padding-top: 4px; }

/* ---------- Confidence Indicator ---------- */
.confidence-bar,
.progress-bar {
    height: 5px;
    background: var(--surface-3);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width .3s ease;
}

.confidence-fill.high { background: var(--success); }
.confidence-fill.medium { background: var(--warning); }
.confidence-fill.low { background: var(--danger); }

.confidence-label { font-size: 11.5px; color: var(--text-3); font-weight: 500; }

/* ---------- Missing Field Highlight ---------- */
.field-missing {
    border-color: var(--warning) !important;
    background: var(--warning-soft) !important;
}

.field-missing-label { color: var(--warning); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 9px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-3);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: color .12s ease, border-color .12s ease;
    margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 650;
}

.tab.active .tab-badge { background: var(--primary); color: #fff; }

/* ---------- Credit Card Display ---------- */
.credit-card-display {
    position: relative;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    min-height: 158px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.credit-card-display::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .05);
}

.credit-card-name {
    position: relative;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .01em;
}

.credit-card-number {
    position: relative;
    font-size: 17px;
    letter-spacing: .14em;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, .78);
}

.credit-card-details {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
}

.credit-card-balance { text-align: right; }

.credit-card-balance .amount {
    display: block;
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -.02em;
}

.credit-card-balance .label {
    display: block;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .6);
}

/* ---------- Payment Account Selector ---------- */
.payment-account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.payment-account-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .12s ease, background .12s ease;
}

.payment-account-option:hover { border-color: var(--primary-light); background: var(--surface-inset); }

.payment-account-option.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: var(--ring);
}

.payment-account-option input[type="radio"] { flex: none; }
.payment-account-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.payment-account-balance { font-size: 12px; color: var(--text-3); }

/* ---------- Guide Page ---------- */
.guide-content { max-width: 940px; }

.guide-toc {
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 24px;
}

.guide-toc h3 { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-bottom: 10px; }
.guide-toc ul { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 5px; }
.guide-toc a { color: var(--primary); text-decoration: none; font-size: 13.5px; }
.guide-toc a:hover { text-decoration: underline; }

.guide-section {
    padding-bottom: 26px;
    margin-bottom: 26px;
    border-bottom: 1px solid var(--border);
}
.guide-section:last-child { border-bottom: none; }

.guide-section h3 { font-size: 18px; font-weight: 650; letter-spacing: -.02em; color: var(--text); margin-bottom: 12px; }
.guide-section h4 { font-size: 15px; font-weight: 650; color: var(--text); margin: 20px 0 8px; }
.guide-section h5 { font-size: 13.5px; font-weight: 650; color: var(--text-2); margin: 14px 0 6px; }
.guide-section p { margin-bottom: 10px; color: var(--text-2); }
.guide-section ol, .guide-section ul { margin: 0 0 12px 20px; color: var(--text-2); }
.guide-section li { margin-bottom: 5px; }
.guide-section li ul { margin-top: 5px; }
.guide-section .alert { margin: 14px 0; }
.guide-section table { margin: 14px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.guide-section table td { padding: 9px 13px; font-size: 13.5px; }
.guide-section table td:first-child { font-weight: 600; color: var(--text); width: 30%; }

.workflow-steps {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 14px 0;
}
.workflow-steps .badge { font-size: 12px; }

/* ---------- Financial Statements ---------- */
.fs-statement {
    max-width: 820px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 30px;
}

.fs-statement h2 {
    font-size: 18px;
    font-weight: 650;
    letter-spacing: -.02em;
    text-align: center;
    color: var(--text);
}

.fs-statement h3 {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: var(--text-3);
    margin-bottom: 22px;
}

.fs-statement .fs-section { margin-bottom: 22px; }

.fs-statement .fs-section-title {
    font-size: 10.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-3);
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.fs-statement .fs-line {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 5px 0;
    font-size: 13.5px;
    color: var(--text-2);
}

.fs-statement .fs-line.fs-indent { padding-left: 20px; }

.fs-statement .fs-line.fs-subtotal {
    font-weight: 600;
    color: var(--text);
    border-top: 1px solid var(--border);
    margin-top: 5px;
    padding-top: 7px;
}

.fs-statement .fs-line.fs-total {
    font-weight: 650;
    color: var(--text);
    border-top: 1px solid var(--border-strong);
    margin-top: 6px;
    padding-top: 8px;
}

.fs-statement .fs-line.fs-grand-total {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    border-top: 2px solid var(--text);
    border-bottom: 3px double var(--text);
    margin-top: 8px;
    padding: 9px 0;
}

.fs-balanced {
    text-align: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    margin-top: 18px;
    border: 1px solid transparent;
}

.fs-balanced.balanced { background: var(--success-soft); color: #047857; border-color: rgba(5, 150, 105, .25); }
.fs-balanced.unbalanced { background: var(--danger-soft); color: #b91c1c; border-color: rgba(220, 38, 38, .25); }

[data-theme="dark"] .fs-balanced.balanced { background: rgba(16, 185, 129, .12); color: #6ee7b7; }
[data-theme="dark"] .fs-balanced.unbalanced { background: rgba(240, 82, 82, .12); color: #fca5a5; }

.fs-chart-area {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.fs-chart-area canvas { max-height: 300px; }

/* ---------- Account Type Colours ---------- */
.acct-type-asset     { color: #2563eb; }
.acct-type-liability { color: #dc2626; }
.acct-type-equity    { color: #7c3aed; }
.acct-type-revenue   { color: #059669; }
.acct-type-expense   { color: #d97706; }

[data-theme="dark"] .acct-type-asset     { color: #7dd3fc; }
[data-theme="dark"] .acct-type-liability { color: #fca5a5; }
[data-theme="dark"] .acct-type-equity    { color: #c4b5fd; }
[data-theme="dark"] .acct-type-revenue   { color: #6ee7b7; }
[data-theme="dark"] .acct-type-expense   { color: #fcd34d; }

.type-header-row td {
    background: var(--surface-3);
    font-weight: 650;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-2);
    padding: 8px 16px;
}

/* ---------- Journal Entry Lines ---------- */
.je-lines-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
}

.je-lines-table th {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    padding: 8px 10px;
    background: var(--surface-inset);
    position: static;
}

.je-lines-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.je-lines-table input,
.je-lines-table select { width: 100%; }
.je-account { min-width: 180px; }
.je-line-desc { min-width: 150px; }
.je-debit, .je-credit { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }

.je-totals {
    display: flex;
    justify-content: flex-end;
    gap: 26px;
    padding: 12px 14px;
    background: var(--surface-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13.5px;
}

.je-totals .balanced { color: var(--success); }
.je-totals .unbalanced { color: var(--danger); }

/* ---------- Ratio Cards ---------- */
.ratio-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
}
.ratio-item:last-child { border-bottom: none; }

.ratio-label { font-size: 13.5px; color: var(--text-2); font-weight: 500; }

.ratio-value {
    font-size: 13px;
    font-weight: 650;
    padding: 3px 11px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.ratio-good    { background: var(--success-soft); color: #047857; }
.ratio-caution { background: var(--warning-soft); color: #b45309; }
.ratio-poor    { background: var(--danger-soft);  color: #b91c1c; }

[data-theme="dark"] .ratio-good    { background: rgba(16, 185, 129, .13); color: #6ee7b7; }
[data-theme="dark"] .ratio-caution { background: rgba(245, 158, 11, .13); color: #fcd34d; }
[data-theme="dark"] .ratio-poor    { background: rgba(240, 82, 82, .13);  color: #fca5a5; }

/* ---------- Tax Centre ---------- */
.tax-form-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.tax-form-table th {
    background: var(--surface-inset);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    padding: 9px 13px;
    position: static;
}

.tax-form-table td { padding: 8px 13px; font-size: 13.5px; }
.tax-form-table tr:hover { background: var(--surface-inset); }

.tax-form-table .line-number {
    font-variant-numeric: tabular-nums;
    color: var(--text-3);
    font-size: 12px;
    width: 70px;
}

.tax-form-table .tax-total {
    font-weight: 650;
    color: var(--text);
    background: var(--surface-inset);
}

/* ---------- Charts ---------- */
.chart-container {
    position: relative;
    min-height: 260px;
    margin-bottom: 18px;
}

.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}
.chart-row .chart-container { margin-bottom: 0; }

/* ---------- AP Aging ---------- */
.aging-current { color: var(--success); }
.aging-30      { color: var(--warning); }
.aging-60      { color: #ea580c; }
.aging-90      { color: var(--danger); }
.aging-90plus  { color: #991b1b; font-weight: 700; }

[data-theme="dark"] .aging-60     { color: #fb923c; }
[data-theme="dark"] .aging-90plus { color: #fca5a5; }

/* ---------- Cash-flow projections (reconciliation) ---------- */
.projected-row td {
    color: var(--text-3);
    font-style: italic;
    background: var(--surface-inset);
}

.projected-row .projected-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
    font-style: normal;
}

.balance-projected { color: var(--primary); font-weight: 600; }
.projections-on .balance-actual { display: none; }
.projections-on .balance-projected { display: inline; }
.projections-on .projected-row { display: table-row; }
.projected-row { display: none; }

.hidden-transaction-row td {
    background: var(--surface-3);
    color: var(--text-3);
    opacity: .85;
}

.projection-route {
    font-size: 11.5px;
    color: var(--text-3);
}

/* ---------- Mapping admin ---------- */
.mapping-admin-table td { vertical-align: middle; }
.mapping-admin-table select { width: 100%; max-width: 280px; }

.mapping-default-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    background: var(--info-soft);
    color: #0369a1;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

[data-theme="dark"] .mapping-default-tag { background: rgba(56, 189, 248, .13); color: #7dd3fc; }

/* ============================================
   AI ASSISTANT
   ============================================ */
.ai-assistant-wrap {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 150px);
    min-height: 420px;
}

.ai-chat-log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 4px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-empty-state {
    margin: auto;
    text-align: center;
    max-width: 560px;
    color: var(--text-2);
}

.ai-empty-icon { font-size: 44px; }
.ai-empty-state h3 { margin: 10px 0 4px; font-size: 17px; font-weight: 650; letter-spacing: -.02em; color: var(--text); }

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 18px;
}

.ai-chip {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    color: var(--text-2);
    border-radius: var(--radius-pill);
    padding: 7px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}

.ai-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.ai-msg { display: flex; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-assistant { justify-content: flex-start; }

.ai-bubble {
    max-width: 76%;
    padding: 11px 15px;
    border-radius: var(--radius);
    line-height: 1.55;
    font-size: 13.5px;
    word-wrap: break-word;
}

.ai-msg-user .ai-bubble {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-msg-assistant .ai-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    max-width: 92%;
}

.ai-bubble ul, .ai-bubble ol { margin: 6px 0; padding-left: 20px; }
.ai-bubble li { margin: 2px 0; }
.ai-bubble code {
    background: var(--surface-3);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ai-msg-user .ai-bubble code { background: rgba(255, 255, 255, .18); }
.ai-bubble p { margin: 0 0 8px; }
.ai-bubble p:last-child { margin-bottom: 0; }
.ai-bubble strong { font-weight: 700; }
.ai-bubble em { font-style: italic; }
.ai-bubble .ai-h { margin: 10px 0 6px; line-height: 1.3; font-weight: 700; }
.ai-bubble h1.ai-h { font-size: 17px; }
.ai-bubble h2.ai-h { font-size: 15px; }
.ai-bubble h3.ai-h, .ai-bubble h4.ai-h, .ai-bubble h5.ai-h, .ai-bubble h6.ai-h { font-size: 13.5px; }
.ai-bubble *:first-child { margin-top: 0; }
.ai-bubble hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.ai-bubble blockquote {
    margin: 6px 0;
    padding: 4px 12px;
    border-left: 3px solid var(--border-strong);
    color: var(--text-3);
}
.ai-bubble a { color: var(--primary); text-decoration: underline; }
.ai-msg-user .ai-bubble a { color: #fff; }

.ai-table-wrap { overflow-x: auto; margin: 8px 0; }
.ai-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.ai-table th, .ai-table td {
    border: 1px solid var(--border);
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}
.ai-table thead th {
    background: var(--surface-inset);
    font-weight: 650;
    color: var(--text-2);
    position: static;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12.5px;
}
.ai-table tbody tr:nth-child(even) { background: var(--surface-inset); }
.ai-error { color: var(--danger); }

.ai-typing { display: inline-flex; gap: 4px; align-items: center; }
.ai-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-400);
    display: inline-block;
    animation: aiBlink 1.2s infinite both;
}
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.ai-confirm-card {
    align-self: flex-start;
    max-width: 76%;
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    border-left-width: 3px;
    border-radius: var(--radius);
    padding: 12px 15px;
}

.ai-confirm-summary { font-size: 13.5px; color: var(--text); margin-bottom: 10px; }
.ai-confirm-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ai-confirm-card.ai-done {
    background: var(--success-soft);
    border-color: var(--success);
    color: #047857;
}
.ai-confirm-card.ai-cancelled {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: var(--text-3);
}

[data-theme="dark"] .ai-confirm-card.ai-done { color: #6ee7b7; }
[data-theme="dark"] .ai-confirm-card.ai-done .ai-confirm-summary,
[data-theme="dark"] .ai-confirm-card.ai-cancelled .ai-confirm-summary { color: inherit; }

.ai-input-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: border-color .12s, box-shadow .12s;
}
.ai-input-bar:focus-within { border-color: var(--primary); box-shadow: var(--ring); }

.ai-input {
    flex: 1 1 auto;
    resize: none;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.55;
    max-height: 160px;
    padding: 8px 4px;
    color: var(--text);
    background: transparent;
}
.ai-input::placeholder { color: var(--gray-400); }

.ai-mic-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-3);
    font-size: 17px;
    cursor: pointer;
    transition: background .12s;
    user-select: none;
}
.ai-mic-btn:hover { background: var(--surface-2); }
.ai-mic-btn.recording {
    background: var(--danger);
    border-color: var(--danger);
    animation: aiPulse 1s infinite;
}
@keyframes aiPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.ai-speak-toggle {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 15px;
    cursor: pointer;
    color: var(--text-3);
    padding: 0 4px;
}

.ai-send-btn { flex: 0 0 auto; }

/* ---------- Utility Classes ---------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-3); }
.mb-0 { margin-bottom: 0; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 99px;
    border: 3px solid var(--surface-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ---------- Selection ---------- */
::selection { background: rgba(var(--primary-rgb), .22); color: inherit; }

/* ============================================
   DARK MODE — inline-style neutralisers

   Parts of the UI are rendered by JS with hardcoded
   light colours in style="" attributes. Rather than
   edit that JS (it backs the Android app), match the
   attribute and re-map the colour here.
   ============================================ */
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:#ffffff"],
[data-theme="dark"] [style*="background: #ffffff"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"],
[data-theme="dark"] [style*="background:#fafafa"],
[data-theme="dark"] [style*="background:#f9fafb"],
[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] [style*="background:#f8f9fa"],
[data-theme="dark"] [style*="background:#f3f4f6"],
[data-theme="dark"] [style*="background: #f3f4f6"],
[data-theme="dark"] [style*="background:#f4f6f8"],
[data-theme="dark"] [style*="background:#eee"],
[data-theme="dark"] [style*="background:#e0e0e0"] {
    background: var(--surface-3) !important;
}

/* Tinted status panels rendered inline by app.js. These were missed by the
   neutral ramp above because they are not greys — a pale green success panel
   stays at luminance 0.95 in dark mode, and the .text-muted inside it turns
   light, giving light-on-light. Keep the semantic hue, drop the lightness.
   Found on the Receipts screen: "Linked to Recurring Expense" (app.js). */
[data-theme="dark"] [style*="background:#e8f5e9"],
[data-theme="dark"] [style*="background: #e8f5e9"] {
    background: rgba(34, 197, 94, 0.12) !important;
    color: var(--text) !important;
}
[data-theme="dark"] [style*="background:#e8f5e9"] .text-muted,
[data-theme="dark"] [style*="background: #e8f5e9"] .text-muted {
    color: var(--text-2) !important;
}

[data-theme="dark"] [style*="color:#1f2937"],
[data-theme="dark"] [style*="color: #1f2937"],
[data-theme="dark"] [style*="color:#111827"],
[data-theme="dark"] [style*="color: #111827"],
[data-theme="dark"] [style*="color:#334155"],
[data-theme="dark"] [style*="color:#000"] {
    color: var(--text) !important;
}

[data-theme="dark"] [style*="color:#6b7280"],
[data-theme="dark"] [style*="color: #6b7280"],
[data-theme="dark"] [style*="color:#64748b"],
[data-theme="dark"] [style*="color: #64748b"],
[data-theme="dark"] [style*="color:#9ca3af"],
[data-theme="dark"] [style*="color:#94a3b8"] {
    color: var(--text-3) !important;
}

[data-theme="dark"] [style*="border:1px solid #e5e7eb"],
[data-theme="dark"] [style*="border: 1px solid #e5e7eb"],
[data-theme="dark"] [style*="border:1px solid #eee"],
[data-theme="dark"] [style*="border:1px solid #ddd"],
[data-theme="dark"] [style*="border:1px solid #e0e0e0"],
[data-theme="dark"] [style*="border-bottom:1px solid #e5e7eb"],
[data-theme="dark"] [style*="border-top:1px solid #e5e7eb"] {
    border-color: var(--border) !important;
}

/* Soft status tints rendered inline by JS */
[data-theme="dark"] [style*="background:#dcfce7"],
[data-theme="dark"] [style*="background: #dcfce7"] { background: rgba(16, 185, 129, .14) !important; }
[data-theme="dark"] [style*="background:#fee2e2"],
[data-theme="dark"] [style*="background: #fee2e2"] { background: rgba(240, 82, 82, .14) !important; }
[data-theme="dark"] [style*="background:#fef3c7"],
[data-theme="dark"] [style*="background: #fef3c7"] { background: rgba(245, 158, 11, .14) !important; }
[data-theme="dark"] [style*="background:#dbeafe"],
[data-theme="dark"] [style*="background:#f0f9ff"],
[data-theme="dark"] [style*="background:#e0f2fe"] { background: rgba(56, 189, 248, .14) !important; }
[data-theme="dark"] [style*="background:#e0f2f1"] { background: rgba(45, 212, 191, .14) !important; }

/* ---------- PWA stage 1: sign-in codes, security page, phone fixes ---------- */
.login-code-input { font-size: 22px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; font-size: 13.5px; color: var(--text-2); cursor: pointer; }
.check-row input { width: 18px; height: 18px; }
.btn-link { background: none; border: none; color: var(--primary); box-shadow: none; }
.btn-link:hover { text-decoration: underline; }

.sec-stack { display: grid; gap: 18px; max-width: 760px; }
.sec-status { display: flex; gap: 12px; align-items: flex-start; line-height: 1.5; }
.sec-status .text-muted { font-size: 13px; margin-top: 2px; }
.sec-dot { flex: 0 0 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--gray-400, #94a3b8); }
.sec-status.on .sec-dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.sec-status.off .sec-dot { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.sec-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.sec-form .form-control { flex: 1 1 180px; width: auto; }
.sec-form .check-row { flex-basis: 100%; margin: 0; }
.sec-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.sec-details { margin-top: 14px; }
.sec-details summary { cursor: pointer; color: var(--primary); font-size: 13.5px; font-weight: 500; }
.sec-steps { padding-left: 20px; margin: 0; display: grid; gap: 16px; line-height: 1.5; }
.sec-qr { margin: 12px 0; }
.sec-qr img { display: block; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--border); max-width: 100%; height: auto; }
.sec-secret { display: block; margin: 10px 0; padding: 10px 12px; border-radius: 8px; background: var(--surface-inset); font-size: 15px; letter-spacing: .06em; word-break: break-all; }
.sec-note { margin-top: 16px; font-size: 13px; }
.sec-devices { display: grid; gap: 2px; }
.sec-device { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.sec-device:last-child { border-bottom: none; }
.sec-device .text-muted { font-size: 12.5px; margin-top: 2px; }

.forecast-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pay-summary { margin-bottom: 14px; padding: 10px 12px; border-radius: 8px; background: var(--surface-inset); font-size: 13.5px; line-height: 1.5; }
.pay-summary:empty { display: none; }
.receipt-camera-row { display: none; margin-top: 12px; }
.receipt-camera-row .btn { width: 100%; }
@media (pointer: coarse) { .receipt-camera-row { display: block; } }

/* ---------- Claude chat ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 150px); height: calc(100dvh - 150px); max-width: 820px; min-height: 360px; }
.chat-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.chat-status:empty { display: none; }
.chat-status .chat-hint { flex: 1 1 140px; min-width: 0; }
.chat-status-actions { display: flex; gap: 12px; margin-left: auto; white-space: nowrap; }
.chat-pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px 4px 10px; border-radius: 999px; font-weight: 600; font-size: 12.5px; background: var(--surface-3); color: var(--text-2); }
.chat-pill .sec-dot { margin-top: 0; }
.chat-pill.listening { background: var(--success-soft); color: var(--success); }
.chat-pill.listening .sec-dot { background: var(--success); }
.chat-pill.stale .sec-dot, .chat-pill.offline .sec-dot { background: var(--warning); }
.chat-log { flex: 1 1 auto; min-height: 38vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; -webkit-overflow-scrolling: touch; }
.chat-empty { margin: auto; max-width: 420px; text-align: center; color: var(--text-3); line-height: 1.6; padding: 24px; }
.chat-msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; line-height: 1.5; font-size: 14px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.chat-msg.mine { align-self: flex-end; background: var(--primary); color: #fff; border-color: transparent; border-bottom-right-radius: 4px; }
.chat-msg.theirs { align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.kind-question { border-color: rgba(79, 70, 229, .45); box-shadow: 0 0 0 2px var(--primary-soft); }
.chat-msg.kind-alert { border-color: rgba(220, 38, 38, .45); background: var(--danger-soft); }
.chat-title { font-weight: 650; margin-bottom: 4px; color: var(--text); }
.chat-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-msg.theirs .chat-body { color: var(--text-2); }
.chat-quote { font-size: 12px; opacity: .8; border-left: 2px solid currentColor; padding-left: 8px; margin-bottom: 6px; overflow-wrap: anywhere; }
.chat-meta { font-size: 11.5px; margin-top: 6px; opacity: .72; }
.chat-meta a { color: inherit; }
.chat-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chat-replybtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.chat-compose { border-top: 1px solid var(--border); padding-top: 10px; }
.chat-compose-row { display: flex; gap: 8px; align-items: flex-end; }
.chat-compose textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 15px; line-height: 1.45; }
.chat-compose textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.chat-compose .btn { min-height: 44px; }
.chat-replying { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }

.chat-tasks { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 8px 12px; margin-bottom: 10px; }
.chat-tasks:empty { display: none; }
.chat-tasks-head { font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); cursor: pointer; list-style: none; }
.chat-tasks-head::-webkit-details-marker { display: none; }
.chat-tasks-head::before { content: '▸ '; }
.chat-tasks-box[open] .chat-tasks-head::before { content: '▾ '; }
/* Capped so the list can never crowd out the conversation. */
.chat-tasks-list { max-height: 34vh; overflow-y: auto; margin-top: 6px; }
.chat-task { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13.5px; line-height: 1.45; }
.chat-task:first-child { border-top: 0; }
.chat-task-text { min-width: 0; }
.chat-task-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chat-task .text-muted { font-size: 12px; margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .mobile-menu-btn { display: flex; }
    .mobile-overlay { display: block; }

    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-xl); }
    .sidebar.open { transform: translateX(0); }

    .sidebar-close { display: flex; align-items: center; justify-content: center; }

    .main-content { margin-left: 0; }

    .top-bar { gap: 12px; padding: 0 20px; }
    .top-bar h1 {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-content { padding: 22px 20px 48px; }

    /* Touch-friendly nav */
    .nav-item { padding: 12px 14px; min-height: 44px; }

    .receipt-preview { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    /* Four forecast numbers read better as a 2×2 than a column of four. */
    .stats-grid.forecast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .forecast-grid .stat-card { padding: 12px 14px; }
    .forecast-grid .stat-info h3 { font-size: 17px; }
    .sec-device { flex-direction: column; align-items: stretch; }
    .sec-form .btn { flex: 1 1 100%; }
    .form-row { grid-template-columns: 1fr; }
    .page-content { padding: 16px 14px 44px; }

    .top-bar { padding: 0 14px; height: 56px; }
    .top-bar h1 { font-size: 15px; }

    .user-info { padding: 4px 0 4px 10px; }
    .user-info .name { font-size: 12px; }
    .user-info .role { font-size: 10px; }

    .card-header {
        padding: 14px 16px;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    .card-header .btn { width: 100%; }
    .card-body { padding: 16px; }
    .card-body > .table-container:only-child,
    .card-body > table:only-child { margin: -16px; width: calc(100% + 32px); }

    .filter-bar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 100%; }

    .modal { max-height: 94vh; }
    .modal-body { padding: 18px; }
    .modal-footer { padding: 14px 18px; }
    .modal-footer .btn { flex: 1 1 auto; }

    .stat-info h3 { font-size: 21px; }

    th, td { padding: 10px 12px; }

    .ai-bubble, .ai-msg-assistant .ai-bubble, .ai-confirm-card { max-width: 94%; }
    .ai-assistant-wrap { height: calc(100vh - 130px); }

    .fs-statement { padding: 20px 18px; }
    .chart-row { grid-template-columns: 1fr; }
    .receipt-cards { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .page-content { padding: 12px 12px 40px; }
    .login-box { padding: 30px 22px; }
    .stat-card { padding: 15px 16px; gap: 12px; }
    .stat-icon { width: 36px; height: 36px; font-size: 16px; }
    .stat-info h3 { font-size: 19px; }
    .action-buttons { width: 100%; }
    .action-buttons .btn { flex: 1 1 auto; }
    .je-totals { flex-direction: column; gap: 6px; align-items: flex-end; }
    .toast-container { left: 12px; right: 12px; top: 12px; }
    .toast { min-width: 0; max-width: none; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar,
    .top-bar,
    .card-header button,
    .filter-row,
    .filter-bar,
    .form-row,
    .action-buttons,
    .mobile-overlay,
    .toast-container {
        display: none !important;
    }

    .main-content { margin-left: 0 !important; background: #fff !important; }
    .page-content { padding: 0 !important; }
    .fs-statement { max-width: 100%; border: none; padding: 0; }
    .card {
        box-shadow: none !important;
        border: none !important;
        break-inside: avoid;
    }
    body { background: #fff !important; color: #000 !important; }
}

/* Sign-in codes required (Access Control Policy v1.0 s5): until this session has a code, only the Security page. */
body.mfa-gate .sidebar .nav-item:not([data-page="security"]),
body.mfa-gate .sidebar .nav-section,
body.mfa-gate .sidebar .nav-group-title { display: none !important; }
.mfa-gate-banner { border-left: 4px solid var(--warning, #d97706); margin-bottom: 16px; }
.mfa-gate-banner p { margin: 6px 0 0; }
.step-up-dialog { border: 1px solid var(--border, #e2e8f0); border-radius: 12px; padding: 20px 22px; max-width: 360px; width: 90%;
    position: fixed; inset: 0; margin: auto; height: fit-content; box-shadow: 0 20px 40px rgba(15, 23, 42, .25); }
.step-up-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.step-up-dialog h3 { margin: 0 0 6px; }
.step-up-dialog input { margin-top: 8px; text-align: center; font-size: 20px; letter-spacing: 6px; }
.step-up-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Tenancy (T1): the business this session works in, under the app name; a picker when there are several. */
.business-switch { padding: 0 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.business-name { font-size: 13px; color: var(--sidebar-text, var(--text-2)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.business-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.business-select { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface, #fff); color: var(--text); font: inherit; font-size: 13px; }
