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

:root {
    /* Default theme: Midnight Gold (the original look) */
    --bg-primary:   #080e1a;
    --bg-secondary: #0d1b2e;
    --bg-card:      #111f38;
    --bg-input:     #162d52;
    --bg-table-alt: #0f1e35;
    --gold:         #c9a84c;
    --gold-light:   #e8c96b;
    --gold-dark:    #9a7a2a;
    --text-primary: #e2e8f0;
    --text-muted:   #7a90a8;
    --success:      #38d499;
    --warning:      #f5a623;
    --danger:       #e74c3c;
    --border:       #1e3a5f;
    /* Text color for content sitting ON TOP of a gold/accent button.
       Dark themes have a light gold accent → near-black text reads well.
       Light themes override this to white because their accent is dark. */
    --on-gold:      #080e1a;
}

/* ── ALTERNATE THEMES ───────────────────────────────────────────────────────
   Each theme overrides the same variables. data-theme is set on <html> by
   js/theme.js (or a tiny inline boot script) BEFORE first paint — see the
   FOUC-prevention <script> in every page's <head>. The variable names stay
   identical across themes so all downstream rules keep working unchanged. */

:root[data-theme="slate"] {
    --bg-primary:   #0a0f14;
    --bg-secondary: #131a22;
    --bg-card:      #1a232e;
    --bg-input:     #243240;
    --bg-table-alt: #16202b;
    --gold:         #5fbcd3;   /* cyan-blue accent */
    --gold-light:   #88d7ee;
    --gold-dark:    #3a8aa3;
    --text-primary: #e6ecf3;
    --text-muted:   #8b9bad;
    --success:      #4ade80;
    --warning:      #fbbf24;
    --danger:       #f87171;
    --border:       #2a3a4d;
}

:root[data-theme="forest"] {
    --bg-primary:   #0d1410;
    --bg-secondary: #14201a;
    --bg-card:      #1a2a22;
    --bg-input:     #233b2e;
    --bg-table-alt: #182520;
    --gold:         #c08552;   /* bronze accent */
    --gold-light:   #e0a878;
    --gold-dark:    #8d5e3a;
    --text-primary: #e6ebe5;
    --text-muted:   #93a499;
    --success:      #78c97e;
    --warning:      #d4a85a;
    --danger:       #c97474;
    --border:       #2a4135;
}

:root[data-theme="plum"] {
    --bg-primary:   #15101a;
    --bg-secondary: #1f1828;
    --bg-card:      #2a2235;
    --bg-input:     #382d47;
    --bg-table-alt: #221a2e;
    --gold:         #d889a3;   /* dusty-rose accent */
    --gold-light:   #f0a8be;
    --gold-dark:    #a06479;
    --text-primary: #ece4f0;
    --text-muted:   #a698b3;
    --success:      #7dd6a0;
    --warning:      #e8a872;
    --danger:       #e87878;
    --border:       #3a2d50;
}

:root[data-theme="paper"] {
    /* Light theme — for sun-side users. The existing dark-on-dark element
       fills (e.g. input boxes) get inverted by the variable swap; chart
       canvases remain dark-painted (Chart.js inline colors), so they
       contrast against the page like printed plates. */
    --bg-primary:   #faf8f3;
    --bg-secondary: #f1ede2;
    --bg-card:      #ffffff;
    --bg-input:     #f5f1e6;
    --bg-table-alt: #faf6ec;
    --gold:         #a88b3e;
    --gold-light:   #c9a84c;
    --gold-dark:    #6e5520;
    --text-primary: #1a2235;
    --text-muted:   #5e6e80;
    --success:      #2a8b5f;
    --warning:      #b8771a;
    --danger:       #c0392b;
    --border:       #d8d3c4;
    --on-gold:      #ffffff;   /* dark amber button → white text */
}

:root[data-theme="carbon"] {
    /* High-contrast techy look: near-black + electric cyan accent */
    --bg-primary:   #050507;
    --bg-secondary: #0e0e12;
    --bg-card:      #181820;
    --bg-input:     #25252e;
    --bg-table-alt: #131318;
    --gold:         #00d4ff;
    --gold-light:   #4fe5ff;
    --gold-dark:    #008cb3;
    --text-primary: #f0f0f5;
    --text-muted:   #888899;
    --success:      #00ff88;
    --warning:      #ffb84d;
    --danger:       #ff5577;
    --border:       #2a2a35;
}

:root[data-theme="ocean"] {
    /* Deep teal + warm coral accent */
    --bg-primary:   #051a1f;
    --bg-secondary: #0a2730;
    --bg-card:      #103540;
    --bg-input:     #154550;
    --bg-table-alt: #0a2030;
    --gold:         #ff8b6b;
    --gold-light:   #ffaa90;
    --gold-dark:    #c66848;
    --text-primary: #e0eef0;
    --text-muted:   #6f9098;
    --success:      #5ce0c0;
    --warning:      #f5b86c;
    --danger:       #f47878;
    --border:       #1d4858;
}

:root[data-theme="sunset"] {
    /* Warm dark burgundy + amber accent */
    --bg-primary:   #1a0d10;
    --bg-secondary: #2a1418;
    --bg-card:      #3a1d22;
    --bg-input:     #4a262e;
    --bg-table-alt: #2f1a1f;
    --gold:         #f0a060;
    --gold-light:   #ffc080;
    --gold-dark:    #b87538;
    --text-primary: #f5e8e0;
    --text-muted:   #b59590;
    --success:      #88c098;
    --warning:      #ffc848;
    --danger:       #f06868;
    --border:       #4a2830;
}

:root[data-theme="navy-linen"] {
    /* Light theme with all-navy lettering — clean financial-document feel */
    --bg-primary:   #f5f3ee;
    --bg-secondary: #ece8de;
    --bg-card:      #ffffff;
    --bg-input:     #f0ede2;
    --bg-table-alt: #faf6ec;
    --gold:         #2c4a8a;   /* navy accent (headings, links) */
    --gold-light:   #4570c0;   /* brighter navy for hover */
    --gold-dark:    #0d1f3a;   /* deepest navy for pressed/strong */
    --text-primary: #1a2845;   /* navy body text */
    --text-muted:   #5a6a85;
    --success:      #2a7a4f;
    --warning:      #b06a14;
    --danger:       #b03228;
    --border:       #c8c0a8;
    --on-gold:      #ffffff;   /* navy button → white text */
}

:root[data-theme="sepia"] {
    /* Warm light theme — book/paper feel, easier on eyes than pure white */
    --bg-primary:   #f4ebd9;
    --bg-secondary: #ede2c8;
    --bg-card:      #faf3e2;
    --bg-input:     #f8eedb;
    --bg-table-alt: #f0e6d0;
    --gold:         #8b6914;
    --gold-light:   #b88a30;
    --gold-dark:    #5e470a;
    --text-primary: #2a1f0e;
    --text-muted:   #6b5a3e;
    --success:      #5c8a3d;
    --warning:      #b87510;
    --danger:       #a83838;
    --border:       #d8c89e;
    --on-gold:      #ffffff;   /* sepia-brown button → white text */
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
    /* Fine diagonal pinstripes — classic banker / ledger-paper feel.
       Color is driven by --pattern-stripe so each theme can tune the
       contrast (very subtle dark on light themes, very subtle light
       on dark themes). */
    background-image: repeating-linear-gradient(
        135deg,
        transparent 0,
        transparent 12px,
        var(--pattern-stripe, rgba(255, 255, 255, 0.020)) 12px,
        var(--pattern-stripe, rgba(255, 255, 255, 0.020)) 13px
    );
    background-attachment: fixed;
}
/* Light themes: dark pinstripe on a linen / cream background */
:root[data-theme="navy-linen"],
:root[data-theme="paper"],
:root[data-theme="sepia"] {
    --pattern-stripe: rgba(20, 30, 60, 0.045);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ── CUSTOM DROPDOWN (replaces native <select> for consistent look) ── */
/* Native select is preserved in DOM for form data, but hidden. The wrapper,
   button, and list are the visible UI. Looks the same on every device. */
.cselect { position: relative; width: 100%; }

.cselect-native {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
    margin: 0; padding: 0; border: 0;
}

.cselect-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-align: left;
    min-height: 42px;
    transition: border-color 0.15s;
}
.cselect-btn:hover,
.cselect-open .cselect-btn,
.cselect-btn:focus { outline: none; border-color: var(--gold-dark); }

.cselect-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cselect-chevron {
    color: var(--gold);
    font-size: 0.72rem;
    margin-left: 0.6rem;
    transition: transform 0.2s;
}
.cselect-open .cselect-chevron { transform: rotate(180deg); }

.cselect-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--gold-dark);
    border-radius: 8px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 6px 24px rgba(0,0,0,0.6);
}
.cselect-open .cselect-list { display: block; }

.cselect-group {
    padding: 0.45rem 0.85rem;
    background: var(--bg-secondary);
    color: var(--gold);
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--border);
}

.cselect-item {
    padding: 0.7rem 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.88rem;
    border-top: 1px solid rgba(201,168,76,0.08);
    transition: background 0.1s;
}
.cselect-item:first-child { border-top: none; }
.cselect-item:hover {
    background: var(--bg-input);
    color: var(--gold);
}
.cselect-item.selected {
    background: rgba(201,168,76,0.12);
    color: var(--gold);
    font-weight: 600;
}
.cselect-item.selected::after {
    content: ' ✓';
    color: var(--gold);
    font-weight: 700;
    margin-left: 0.3rem;
}

/* ── NAVBAR ──
   Two-row layout on desktop: row 1 = brand + right-side controls
   (theme picker, language picker, auth); row 2 = navigation links
   spanning the full width. This keeps the bar uncluttered as more
   sections are added.
   The mobile media query (≤1280px) overrides this to a hamburger
   drawer pattern — see further down. */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 0.35rem;
    min-height: 64px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

.nav-brand {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    text-decoration: none;
}

.nav-brand span { color: var(--text-primary); font-weight: 400; }

.nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
    order: 10;            /* push to the second row */
    flex-basis: 100%;     /* take the full width on row 2 */
    justify-content: center;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-links a:hover { color: var(--gold); background: rgba(201,168,76,0.08); }
.nav-links a.active { color: var(--gold); background: rgba(201,168,76,0.12); }

/* ── NAV DROPDOWNS (Retirement Planning, Real Estate, etc.) ── */
/* The toggle is a plain inline anchor. The chevron is a pure inline
   character (no inline-block, no transform) so it doesn't enlarge the
   line-box vs sibling plain links — keeping every item vertically
   aligned. To "rotate" on open, we swap the glyph instead. */
.nav-dropdown { position: relative; }
.nav-dropdown > .nav-dropdown-toggle { cursor: pointer; }
.nav-dropdown > .nav-dropdown-toggle::after {
    content: ' ▾';
    font-size: 0.75em;
    opacity: 0.7;
}
.nav-dropdown.open > .nav-dropdown-toggle::after { content: ' ▴'; }
.nav-dropdown:has(a.active) > .nav-dropdown-toggle {
    color: var(--gold);
    background: rgba(201,168,76,0.12);
}

/* ── TOOL ABOUT BLOCK + FIELD HELP TOOLTIPS ─────────────────────────────── */

/* The "About this tool" block sits between the section-header and the
   scenarios bar / form. Uses native <details> for collapse, no JS. Open
   by default on first visit (handled by js/theme.js), then remembered
   collapsed in localStorage so repeat visitors aren't nagged. */
.tool-about {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}
.tool-about-details {
    margin: 0.75rem 0 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.tool-about-summary {
    cursor: pointer;
    padding: 0.7rem 1rem;
    color: var(--gold);
    font-size: 0.95rem;
    font-weight: 600;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: background 0.15s;
}
.tool-about-summary:hover { background: rgba(201, 168, 76, 0.08); }
.tool-about-summary::marker { content: ''; }
.tool-about-summary::-webkit-details-marker { display: none; }
/* Right-side affordance: explicit text label + chevron, not just chevron.
   Far more discoverable than a tiny ▾ symbol on its own. */
.tool-about-summary::after {
    content: 'Click to expand ▾';
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.tool-about-details[open] .tool-about-summary::after {
    content: 'Click to hide ▴';
    color: var(--gold);
}

/* Close button at the end of the About content — obvious "I'm done, hide
   this" affordance for users who finish reading. Spans the full width
   and sits below the four About sections. */
.tool-about-close {
    grid-column: 1 / -1;
    margin-top: 0.5rem;
    padding: 0.55rem 1rem;
    background: rgba(201, 168, 76, 0.08);
    color: var(--gold);
    border: 1px solid var(--gold-dark);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}
.tool-about-close:hover {
    background: var(--gold);
    color: var(--on-gold);
    border-color: var(--gold);
}
.tool-about-content {
    padding: 0.5rem 1rem 1.1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
}
.tool-about-section h4 {
    color: var(--gold);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0.5rem 0 0.4rem;
}
.tool-about-section p,
.tool-about-section ol,
.tool-about-section ul {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.55;
    margin: 0;
}
.tool-about-section ol,
.tool-about-section ul {
    padding-left: 1.25rem;
}
.tool-about-section li { margin-bottom: 0.3rem; }
@media (max-width: 768px) {
    .tool-about-content { grid-template-columns: 1fr; }
    .tool-about { padding: 0 1rem; }
}

/* Field-level help — small (?) icon next to a label. Click toggles a
   popover with the explanation. The popover is appended to <body> by
   js/theme.js and absolutely positioned next to the icon. */
.field-help {
    display: inline-flex;
    width: 16px;
    height: 16px;
    margin-left: 0.35rem;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    cursor: help;
    user-select: none;
    vertical-align: middle;
    transition: all 0.15s;
    font-style: normal;
}
.field-help:hover {
    color: var(--gold);
    border-color: var(--gold);
}
.field-help.open {
    background: var(--gold);
    color: var(--on-gold);
    border-color: var(--gold);
}
.field-help-popover {
    position: absolute;
    z-index: 200;
    max-width: 280px;
    padding: 0.65rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--gold);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.5;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

/* Hide About + tooltips in PDF print */
@media print {
    .tool-about, .field-help, .field-help-popover { display: none !important; }
}

/* ── TOOL-FAMILY SUB-TABS (under section-header on grouped tool pages) ── */
.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: 1400px;
    margin: 0 auto 0.4rem;
    padding: 0.5rem 1rem 0;
}
.tool-tab {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    transition: all 0.15s;
}
.tool-tab:hover {
    color: var(--gold);
    border-color: var(--gold);
}
.tool-tab.active {
    color: var(--bg-primary);
    background: var(--gold);
    border-color: var(--gold);
    font-weight: 600;
}
.tool-tabs-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    align-self: center;
    margin-right: 0.35rem;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    margin-top: 0.3rem;
    padding: 0.4rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    list-style: none;
    z-index: 80;
}
.nav-dropdown.open > .nav-dropdown-menu,
.nav-dropdown:focus-within > .nav-dropdown-menu { display: block; }
.nav-dropdown-menu li { margin: 0; }
.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 5px;
    white-space: nowrap;
}
.nav-dropdown-menu a:hover { color: var(--gold); background: rgba(201,168,76,0.08); }
.nav-dropdown-menu a.active { color: var(--gold); background: rgba(201,168,76,0.12); }

/* ── NAVBAR AUTH SLOT ── */
.nav-auth {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: 0.75rem;
}
/* Theme picker takes the auto-margin so it (and everything after it)
   right-aligns. Without this the picker would sit pinned to the last
   nav-link in the middle of the bar. */
.theme-picker { margin-left: auto; }

.nav-auth-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-auth-link:hover { color: var(--gold); background: rgba(201,168,76,0.08); }

/* ── THEME PICKER (palette button + popover) ── */
.theme-picker { position: relative; display: inline-block; }
.theme-picker-btn {
    /* Match the .nav-auth-link styling — no border, muted-on-default,
       gold-on-hover with the same subtle gold-tinted background. */
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
}
.theme-picker-btn:hover {
    color: var(--gold);
    background: rgba(201,168,76,0.08);
}
.theme-picker-btn-label { letter-spacing: 0.02em; }
/* On narrow viewports the label drops out so the icon alone fits. */
@media (max-width: 900px) {
    .theme-picker-btn { padding: 0.45rem 0.55rem; gap: 0; }
    .theme-picker-btn-label { display: none; }
}
.theme-picker-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.4rem;
    padding: 0.5rem;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    z-index: 100;
}
.theme-picker.open .theme-picker-menu { display: block; }
.theme-picker-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 0.5rem;
    padding: 0 0.4rem;
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.55rem;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}
.theme-option:hover { background: rgba(201,168,76,0.08); }
.theme-option.active { background: rgba(201,168,76,0.14); color: var(--gold); }
.theme-swatch {
    display: inline-flex;
    width: 36px;
    height: 22px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.theme-swatch span { flex: 1 1 0; }
.theme-option.active .theme-check { color: var(--gold); }
.theme-check { margin-left: auto; opacity: 0; }
.theme-option.active .theme-check { opacity: 1; }

.theme-picker-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0.4rem;
}
.theme-size-icon {
    display: inline-flex;
    width: 36px;
    height: 22px;
    align-items: center;
    justify-content: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    color: var(--gold);
}

/* ── LARGER PRINT MODE ── accessibility size scaler that scales the whole
   site by bumping root font-size. Most rule sizes are in `rem`, so they
   inherit the bump automatically. Padding/spacing remains proportional. */
:root[data-print-size="large"] {
    font-size: 18px;     /* baseline up from 16px ≈ 12.5% bigger */
}
:root[data-print-size="large"] body { line-height: 1.65; }
:root[data-print-size="large"] input,
:root[data-print-size="large"] select,
:root[data-print-size="large"] textarea {
    font-size: 1rem;
    padding: 0.6rem 0.85rem;
}
:root[data-print-size="large"] button { font-size: 0.95rem; }
:root[data-print-size="large"] .form-group label { font-size: 0.95rem; }
:root[data-print-size="large"] .stat-value { font-size: 1.3rem; }
:root[data-print-size="large"] .stat-label { font-size: 0.8rem; }
:root[data-print-size="large"] table { font-size: 0.92rem; }

.nav-auth-cta {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--on-gold) !important;
    font-weight: 600;
}
.nav-auth-cta:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-light)) !important;
    color: var(--on-gold) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(201,168,76,0.3);
}

.nav-user-email {
    color: var(--text-muted);
    font-size: 0.78rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── AUTH PAGES (login/register/verify) ── */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 3rem 1.5rem 5rem;
    min-height: calc(100vh - 64px);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2.5rem 2.25rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 4px 40px rgba(0,0,0,0.35);
}

.auth-card h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.auth-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
    line-height: 1.55;
}

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

.auth-form label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.form-hint { color: var(--text-muted); font-weight: 400; font-size: 0.72rem; }

.auth-form input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.65rem 0.85rem;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: 'Inter', sans-serif;
}
.auth-form input:focus { outline: none; border-color: var(--gold-dark); }

.auth-submit {
    width: 100%;
    padding: 0.78rem;
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.auth-error {
    background: rgba(231,76,60,0.1);
    border: 1px solid rgba(231,76,60,0.3);
    color: var(--danger);
    border-radius: 6px;
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.auth-success {
    background: rgba(56,212,153,0.08);
    border: 1px solid rgba(56,212,153,0.3);
    color: var(--success);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.auth-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1.5rem;
}

.auth-footer a { color: var(--gold); text-decoration: none; }
.auth-footer a:hover { color: var(--gold-light); text-decoration: underline; }

.auth-verify-status {
    text-align: center;
    padding: 1.25rem 0;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

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

/* ── HERO ── */
.hero {
    background: linear-gradient(160deg, var(--bg-primary) 0%, var(--bg-card) 50%, var(--bg-primary) 100%);
    text-align: center;
    padding: 1.25rem 2rem 1.5rem;
    position: relative;
    overflow: hidden;
}
.kids-pill {
    position: relative;
    z-index: 2;
    display: inline-block;
    margin-bottom: 0.85rem;
    padding: 0.4rem 1rem;
    background: color-mix(in srgb, var(--gold) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
    border-radius: 999px;
    color: var(--gold);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
}
.kids-pill:hover {
    background: color-mix(in srgb, var(--gold) 28%, transparent);
    transform: translateY(-1px);
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 60%,
        color-mix(in srgb, var(--gold) 8%, transparent) 0%,
        transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 0.25rem;
    line-height: 1.15;
}

.hero p {
    color: var(--text-muted);
    font-size: 0.88rem;
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.5;
}

.hero-divider {
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 0.5rem auto;
}

/* ── START-HERE STRIPE (homepage entry-point cards) ── */
.start-here {
    max-width: 1400px;
    margin: 1.25rem auto 0;
    padding: 0 2rem;
}
.start-here-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.6rem;
}
.start-here-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
}
.start-here-card {
    display: block;
    padding: 1rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--gold-dark);
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    transition: all 0.2s;
    /* Tile is now a <button> — reset native button look so the design matches. */
    font: inherit;
    text-align: left;
    cursor: pointer;
    width: 100%;
}
.start-here-card:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--gold) 14%, transparent);
}
.start-here-card.active {
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, var(--bg-card));
    box-shadow: 0 8px 24px color-mix(in srgb, var(--gold) 22%, transparent);
}

.start-here-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
    margin-top: 0;
}
.start-here-panel.open {
    max-height: 2400px;
    margin-top: 0.85rem;
}
.bundle-panel-inner {
    padding: 1.1rem 1.2rem;
    background: var(--bg-card);
    border: 1px solid var(--gold);
    border-radius: 10px;
}
.bundle-panel-intro {
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0 0 0.9rem 0;
}
.bundle-tool-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.55rem;
}
.bundle-tool {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
}
.bundle-tool:hover {
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 5%, var(--bg-input));
    transform: translateX(2px);
}
.bundle-tool-icon {
    font-size: 1.1rem;
    line-height: 1.2;
    flex-shrink: 0;
}
.bundle-tool-name {
    font-weight: 600;
    color: var(--gold);
    font-size: 0.88rem;
    line-height: 1.3;
    margin-bottom: 0.15rem;
}
.bundle-tool-why {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.45;
}
@media (max-width: 700px) {
    .bundle-tool-grid { grid-template-columns: 1fr; }
}
.start-here-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.4rem;
}
.start-here-card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 0.3rem;
}
.start-here-card-sub {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}

.features-section-label {
    max-width: 1400px;
    margin: 1.5rem auto 0.4rem;
    padding: 0 2rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── FEATURE CARDS ── */
.features {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    padding: 0.5rem 2rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem 1.25rem;
    text-align: center;
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.feature-card:hover {
    border-color: var(--gold-dark);
    transform: translateY(-4px);
    box-shadow: 0 8px 40px rgba(201,168,76,0.12);
}

.feature-icon { font-size: 2.2rem; margin-bottom: 0.75rem; display: block; }

.feature-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
    position: relative;
    display: inline-block;
    transition: color 0.2s;
}

.feature-card h3::after {
    content: ' →';
    opacity: 0;
    margin-left: 0.2rem;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-4px);
    display: inline-block;
}

.feature-card:hover h3 { color: var(--gold-light); }
.feature-card:hover h3::after { opacity: 1; transform: translateX(0); }

.feature-card p {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.55;
}

/* Sub-tool link list inside grouped feature cards. The links must NOT
   inherit browser-default purple/blue. */
.feature-links {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.feature-links li { margin: 0; }
.feature-links a {
    display: block;
    padding: 0.45rem 0.75rem;
    color: var(--gold);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(201,168,76,0.04);
    transition: all 0.15s;
}
.feature-links a:hover {
    color: var(--gold-light);
    background: rgba(201,168,76,0.12);
    border-color: var(--gold);
}
.feature-links a:visited { color: var(--gold); }
.feature-links a:visited:hover { color: var(--gold-light); }

/* Grouped feature cards aren't <a> wrappers, so their hover treatment
   needs to come from their own pseudo state — keep the lift + glow. */
.feature-group {
    cursor: default;
}
.feature-group:hover {
    transform: none;
    border-color: var(--gold-dark);
    box-shadow: 0 8px 40px rgba(201,168,76,0.12);
}
.feature-group h3::after { display: none; }

/* ── SECTION HEADER ── */
.section-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
}

.section-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--gold);
    margin-bottom: 0.5rem;
}

.section-header p { color: var(--text-muted); font-size: 0.95rem; }

/* ── PAGE LAYOUT ── */
.page-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 2rem;
    align-items: start;
}

.page-content.full-width {
    grid-template-columns: 1fr;
    max-width: 1200px;
}

/* Stacked layout: form full-width on top, results full-width below.
   Form sections arrange in a responsive multi-column grid. */
.page-content-stacked {
    grid-template-columns: 1fr;
    max-width: 1600px;
}
.page-content-stacked .form-card {
    position: static;
    max-height: none;
    overflow: visible;
}
.form-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.5rem 1.5rem;
    margin-bottom: 1rem;
}
.form-section-grid .form-section { margin-bottom: 0; }

/* ── FORM CARD ── */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
}

/* Header row with the Parameters title + always-visible Recalculate button */
.form-card > h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

/* When "Show all columns" is checked: widen the page, let the table grow to its
   natural width (all 13 columns), and fall back to horizontal scroll if the
   viewport still can't contain it. */
.page-content.full-details {
    max-width: 1800px;
}
.page-content.full-details .table-wrapper {
    overflow-x: auto;
}
.page-content.full-details table {
    width: max-content;
    min-width: 100%;
}

/* ── SCENARIOS BAR (Save / Load, visible to logged-in users) ── */
.scenarios-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--gold-dark);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    margin-bottom: 1rem;
}

.scenarios-label {
    font-size: 0.82rem;
    color: var(--gold);
    font-weight: 600;
    margin-right: 0.25rem;
}

.scenarios-bar-inner select,
.scenarios-bar-inner input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.38rem 0.6rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
}

.scenarios-bar-inner select { min-width: 180px; }
.scenarios-name { flex: 1; min-width: 160px; }
.scenarios-name:focus,
.scenarios-bar-inner select:focus { outline: none; border-color: var(--gold-dark); }

.btn-scenario-save {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--on-gold);
    border: none;
    border-radius: 5px;
    padding: 0.42rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-scenario-save:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    transform: translateY(-1px);
}

.btn-scenario-delete {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.42rem 0.85rem;
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-scenario-delete:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.scenarios-status {
    font-size: 0.78rem;
    min-width: 80px;
}
.scenarios-status.ok    { color: var(--success); }
.scenarios-status.error { color: var(--danger); }

.show-all-toggle {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
}
.show-all-toggle input {
    accent-color: var(--gold);
    cursor: pointer;
}
.show-all-toggle:hover { color: var(--text-primary); }

.btn-calculate-inline {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--on-gold);
    border: none;
    border-radius: 6px;
    padding: 0.45rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.btn-calculate-inline:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    transform: translateY(-1px);
    box-shadow: 0 2px 12px rgba(201,168,76,0.3);
}

.form-card h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: var(--gold);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.form-section { margin-bottom: 1.4rem; }

.form-section h3 {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gold-dark);
    margin-bottom: 0.65rem;
}

.form-group { margin-bottom: 0.75rem; }

.form-group label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.28rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.52rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus { outline: none; border-color: var(--gold-dark); }


.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }

.btn-calculate {
    width: 100%;
    padding: 0.85rem;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--on-gold);
    font-weight: 700;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    margin-top: 0.5rem;
    letter-spacing: 0.02em;
}

.btn-calculate:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(201,168,76,0.3);
}

/* ── TABS ── */
.tab-group {
    display: flex;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.48rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--gold);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.collapsible { display: none; }
.collapsible.visible { display: block; }

/* Stacked results column (chart card + stats/table card side by side in right column) */
.results-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

/* ── RESULTS CARD ── */
.results-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
}

.results-card > h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: var(--gold);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ── SUMMARY STATS ── */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    text-align: center;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.35rem;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }
.stat-value.warning  { color: var(--warning); }

/* ── CHART ── */
.chart-container {
    margin-bottom: 1.5rem;
    height: 280px;
    position: relative;
}

/* Corner labels above left/right y-axes; colored to match their data series. */
.chart-with-corner-labels { padding-top: 1.25rem; }
.chart-label-left,
.chart-label-right {
    position: absolute;
    top: 0;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    z-index: 5;
    pointer-events: none;
}
.chart-label-left  { left: 6px; color: #e8c96b; }
.chart-label-right { right: 6px; color: #e09070; }

/* ── TABLE ── */
.table-wrapper {
    border-radius: 8px;
    border: 1px solid var(--border);
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.78rem; font-variant-numeric: tabular-nums; }

.page-content, .page-content > .results-card { min-width: 0; }

thead th, tbody td { padding: 0.5rem 0.4rem !important; }

/* On mobile, freeze BOTH the first column (row identifier — Age / Year /
   Month / Date) AND the last column (the bottom-line number — End Balance
   / Cumulative / etc.) so the user keeps the most important context at
   the edges while panning the middle. Sticky cells get solid backgrounds
   matching the row's natural fill (header / odd / even / hover); inset
   shadows on the inward edges signal "more content scrolling past me". */
@media (max-width: 768px) {
    table th:first-child,
    table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--bg-card);
        box-shadow: inset -6px 0 6px -6px rgba(0, 0, 0, 0.4);
    }
    table th:last-child,
    table td:last-child {
        position: sticky;
        right: 0;
        z-index: 2;
        background: var(--bg-card);
        box-shadow: inset 6px 0 6px -6px rgba(0, 0, 0, 0.4);
    }
    tbody tr:nth-child(even) td:first-child,
    tbody tr:nth-child(even) td:last-child  { background: var(--bg-table-alt); }
    tbody tr:hover td:first-child,
    tbody tr:hover td:last-child            { background: var(--bg-secondary); }
    thead th:first-child,
    thead th:last-child {
        background: var(--bg-secondary);
        z-index: 6;
    }
}

/* ── CUSTOM EXPENSE ROWS (retirement page) ── */
/* Two-row layout: name + delete on top, amount + end-age below.
   Keeps the name and the amount readable in the narrow sidebar. */
.expense-row {
    display: grid;
    grid-template-columns: 1fr auto 58px 26px;
    column-gap: 0.4rem;
    row-gap: 0.35rem;
    padding: 0.5rem 0.55rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    align-items: center;
}
.expense-row > .expense-name     { grid-column: 1 / 4; grid-row: 1; }
.expense-row > .btn-delete-exp   { grid-column: 4;     grid-row: 1; }
.expense-row > .expense-amt-wrap { grid-column: 1;     grid-row: 2; }
.expense-row > .expense-until    { grid-column: 2;     grid-row: 2; text-align: right; padding: 0 0.1rem 0 0.25rem; }
.expense-row > .expense-end-age  { grid-column: 3;     grid-row: 2; }
.expense-row .expense-name {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.38rem 0.55rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    width: 100%;
}
.expense-row .expense-amt-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 0.4rem;
}
.expense-row .expense-amt-wrap > span { color: var(--text-muted); font-size: 0.82rem; }
.expense-row .expense-amount {
    background: transparent;
    border: none;
    padding: 0.38rem 0;
    color: var(--gold);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    text-align: right;
    width: 100%;
}
.expense-row .expense-amount:focus { outline: none; }
.expense-row .expense-amount::-webkit-outer-spin-button,
.expense-row .expense-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.expense-row .expense-amount[type=number] { -moz-appearance: textfield; }
.expense-row .expense-until { font-size: 0.7rem; color: var(--text-muted); text-align: center; }
.expense-row .expense-end-age {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.38rem 0.35rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    text-align: center;
    width: 100%;
}
.btn-delete-exp {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0;
    transition: all 0.15s;
}
.btn-delete-exp:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(231,76,60,0.1);
}

/* ── DEBT PAYOFF — debt row cards in the sidebar ── */
.debt-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.4rem;
    padding: 0.65rem 0.7rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 0.6rem;
    align-items: start;
}
.debt-row .debt-name {
    grid-column: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.38rem 0.55rem;
    color: var(--gold);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    width: 100%;
}
.debt-order-controls {
    grid-column: 2;
    display: flex;
    gap: 0.25rem;
    align-items: center;
}
.debt-arrow {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 22px;
    height: 26px;
    padding: 0;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.debt-arrow:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold);
}
.debt-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
.debt-arrow-active {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(201,168,76,0.08);
}
.debt-row .debt-fields {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.35rem;
}
.debt-row .debt-field { display: flex; flex-direction: column; gap: 0.2rem; }
.debt-row .debt-field label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.debt-row .debt-dollar {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 0.35rem;
}
.debt-row .debt-dollar > span { color: var(--text-muted); font-size: 0.8rem; }
.debt-row .debt-dollar > input {
    background: transparent;
    border: none;
    padding: 0.34rem 0;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    text-align: right;
    width: 100%;
}
.debt-row .debt-dollar > input:focus { outline: none; }
.debt-row .debt-dollar > input::-webkit-outer-spin-button,
.debt-row .debt-dollar > input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.debt-row .debt-dollar > input[type=number] { -moz-appearance: textfield; }

.debt-add-row {
    margin-top: 0.5rem;
}
.debt-add-row select {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: var(--bg-input);
    border: 1px dashed var(--gold);
    border-radius: 6px;
    color: var(--gold);
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

.debt-comparison {
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    background: rgba(201, 168, 76, 0.06);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.debt-comparison:empty { display: none; }

/* ── SS OPTIMIZER ── */
.fra-info {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(201, 168, 76, 0.06);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--gold);
}
.ss-recommendation {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(56, 212, 153, 0.06);
    border-left: 3px solid var(--success, #38d499);
    border-radius: 4px;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
}
.row-highlight {
    background: rgba(201, 168, 76, 0.10) !important;
}

.estate-checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}
.estate-checklist li {
    display: flex;
    gap: 0.7rem;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.5rem;
    background: var(--bg-input);
    border-left: 3px solid var(--gold);
    border-radius: 4px;
    font-size: 0.88rem;
    line-height: 1.45;
}
.estate-checklist-icon {
    font-size: 1.15rem;
    line-height: 1.2;
    flex-shrink: 0;
}
.estate-checklist-detail {
    margin-top: 0.2rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
}
.row-highlight td:first-child { color: var(--gold); font-weight: 700; }

/* ── FINANCIAL HEALTH DASHBOARD ── */
.health-hero {
    text-align: center;
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.health-hero-grade {
    font-family: 'Playfair Display', serif;
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}
.health-hero-score {
    font-size: 1.4rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-top: 0.2rem;
}
.health-hero-out-of {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 400;
}
.health-hero-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    margin: 0.75rem auto 0.6rem;
    max-width: 360px;
    overflow: hidden;
}
.health-hero-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s, background-color 0.3s;
}
.health-hero-summary {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 0.5rem;
}

.health-metrics {
    grid-template-columns: repeat(2, 1fr) !important;
}
.health-metric {
    text-align: left;
    padding: 0.85rem 1rem;
    border-left-width: 4px;
    border-left-style: solid;
}
.health-metric.band-healthy  { border-left-color: var(--success); }
.health-metric.band-ok       { border-left-color: var(--gold); }
.health-metric.band-warning  { border-left-color: var(--warning); }
.health-metric.band-critical { border-left-color: var(--danger); }
.health-metric .stat-value { font-size: 1.4rem; }
.health-metric-band {
    font-size: 0.78rem;
    font-weight: 600;
    margin-top: 0.2rem;
}
.health-metric.band-healthy  .health-metric-band { color: var(--success); }
.health-metric.band-ok       .health-metric-band { color: var(--gold); }
.health-metric.band-warning  .health-metric-band { color: var(--warning); }
.health-metric.band-critical .health-metric-band { color: var(--danger); }
.health-metric-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    line-height: 1.35;
}

.action-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.action-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 0.7rem;
    padding: 0.85rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.action-priority {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.55rem;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-muted);
    min-width: 70px;
    text-align: center;
}
.action-priority-critical  { background: rgba(231,76,60,0.15);  color: var(--danger); }
.action-priority-high      { background: rgba(245,166,35,0.15); color: var(--warning); }
.action-priority-medium    { background: rgba(201,168,76,0.15); color: var(--gold); }
.action-priority-next,
.action-priority-levelup,
.action-priority-leveup    { background: rgba(56,212,153,0.15); color: var(--success); }
.action-content { flex: 1; }
.action-title {
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    line-height: 1.35;
}
.action-detail {
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.55;
}

/* ── MONTE CARLO TOGGLE ── */
.mc-toggle-row {
    margin-top: 0.6rem;
    margin-bottom: 0;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.88rem;
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--gold);
    cursor: pointer;
    margin: 0;
}
.checkbox-label:hover { color: var(--gold); }

thead { position: sticky; top: 0; z-index: 5; }

thead th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.7rem 0.65rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

thead th:first-child { text-align: center; }

tbody tr { border-bottom: 1px solid rgba(30,58,95,0.4); transition: background 0.12s; }
tbody tr:nth-child(even) { background: var(--bg-table-alt); }
tbody tr:hover { background: rgba(201,168,76,0.05); }

tbody td { padding: 0.55rem 0.65rem; text-align: right; white-space: nowrap; }
tbody td:first-child { text-align: center; font-weight: 600; color: var(--gold); }

.prepay-input {
    width: 110px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    color: var(--gold);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    text-align: right;
    transition: border-color 0.15s, background 0.15s;
}
.prepay-input:hover  { border-color: var(--gold-dark); }
.prepay-input:focus  { outline: none; border-color: var(--gold); background: rgba(201,168,76,0.08); }
.prepay-input::-webkit-outer-spin-button,
.prepay-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.prepay-input[type=number] { -moz-appearance: textfield; }

.bal-good    { color: var(--success); }
.bal-warn    { color: var(--warning); }
.bal-danger  { color: var(--danger); }
.col-income  { color: var(--success); }
.col-expense { color: #e09070; }
.col-tax     { color: #a878c8; }

/* ── PLACEHOLDER ── */
.results-placeholder {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.results-placeholder .icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.35; display: block; }

/* ── BUDGET PAGE ── */
.budget-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.month-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.month-nav button {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 0.45rem 1.2rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.month-nav button:hover { border-color: var(--gold-dark); color: var(--gold); }

.month-display {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: var(--gold);
    min-width: 220px;
    text-align: center;
}

.savings-banner {
    padding: 1.25rem 1.75rem;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
    border-left-width: 4px;
}

.savings-banner.surplus { border-left-color: var(--success); }
.savings-banner.deficit { border-left-color: var(--danger); }

.savings-banner .s-label { font-size: 0.85rem; color: var(--text-muted); }
.savings-banner .s-title { font-family: 'Playfair Display', serif; font-size: 1rem; color: var(--text-primary); }

.savings-banner .s-amount {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.savings-banner .s-amount.surplus { color: var(--success); }
.savings-banner .s-amount.deficit { color: var(--danger); }

.budget-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.budget-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.budget-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.budget-panel-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--gold);
}

.btn-add {
    padding: 0.35rem 0.9rem;
    background: rgba(201,168,76,0.12);
    border: 1px solid var(--gold-dark);
    color: var(--gold);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
}

.btn-add:hover { background: rgba(201,168,76,0.22); }

.budget-entry {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid rgba(30,58,95,0.4);
}

.budget-entry:last-child { border-bottom: none; }

/* ── EXPENSE CATEGORY HEADERS ── */
.category-header {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0 0.3rem;
    margin-top: 0.75rem;
    border-bottom: 1px solid var(--border);
}

#expenseRows .category-header:first-child { margin-top: 0; }

.category-name {
    color: var(--gold-dark);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.category-total {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.btn-category-add {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: 4px;
    padding: 0.12rem 0.5rem;
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.6;
}

.btn-category-add:hover {
    color: var(--gold);
    border-color: var(--gold-dark);
    background: rgba(201,168,76,0.08);
    opacity: 1;
}

/* ── BUDGET ROWS (inline editable) ── */
.budget-row {
    display: grid;
    grid-template-columns: 1fr 130px 120px 30px;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(30,58,95,0.4);
}

.budget-row:last-of-type { border-bottom: none; }

.row-name {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.87rem;
    font-family: 'Inter', sans-serif;
    width: 100%;
}
.row-name:hover  { border-color: var(--border); background: var(--bg-input); }
.row-name:focus  { outline: none; border-color: var(--gold-dark); background: var(--bg-input); }

.row-category {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: 'Inter', sans-serif;
    width: 100%;
}
.row-category:focus { outline: none; border-color: var(--gold-dark); }
.row-category option { background: var(--bg-card); }

.row-amount-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 0.4rem;
}
.row-amount-wrap:focus-within { border-color: var(--gold-dark); }

.row-dollar { color: var(--text-muted); font-size: 0.85rem; margin-right: 0.25rem; }

.row-amount {
    background: transparent;
    border: none;
    padding: 0.35rem 0;
    color: var(--text-primary);
    font-size: 0.87rem;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    text-align: right;
    width: 100%;
    font-weight: 600;
}
.row-amount:focus { outline: none; }
.row-amount.income  { color: var(--success); }
.row-amount.expense { color: var(--text-primary); }
.row-amount::-webkit-outer-spin-button,
.row-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.row-amount[type=number] { -moz-appearance: textfield; }

/* ── ADD ROW BUTTON ── */
.btn-add-row {
    width: 100%;
    padding: 0.55rem;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
    margin-top: 0.5rem;
}
.btn-add-row:hover {
    border-color: var(--gold-dark);
    color: var(--gold);
    background: rgba(201,168,76,0.05);
}

/* ── HOUSING TOGGLE (Mortgage / Rent) ── */
.housing-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.housing-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.housing-tabs {
    display: flex;
    background: var(--bg-input);
    border-radius: 8px;
    padding: 3px;
}

.housing-tab {
    padding: 0.38rem 1rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}

.housing-tab:hover { color: var(--text-primary); }

.housing-tab.active {
    background: var(--bg-card);
    color: var(--gold);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.btn-allocate {
    margin-left: auto;
    padding: 0.45rem 0.9rem;
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-allocate:hover {
    background: var(--gold);
    color: var(--bg-primary);
}

.allocate-status {
    margin-left: 0.5rem;
    font-size: 0.82rem;
    color: var(--success, #38d499);
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}
.allocate-status.visible { opacity: 1; }

/* ── RECALCULATE FLOATING BUTTON ─────────────────────────────────────────── */
/* Same gold pill styling as the Save-to-PDF button, stacked above it on
   the bottom-right edge. Hidden in print. */
.recalc-floating-btn {
    position: fixed;
    right: 1.25rem;
    bottom: 5rem;
    z-index: 100;
    padding: 0.65rem 1.1rem;
    background: var(--gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.45), 0 0 0 1px rgba(232,201,107,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
    font-family: 'Inter', sans-serif;
}
.recalc-floating-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.55), 0 0 0 1px rgba(232,201,107,0.55);
}

/* ── SAVE-TO-PDF FLOATING BUTTON ─────────────────────────────────────────── */
.export-pdf-btn {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 100;
    padding: 0.65rem 1.1rem;
    background: var(--gold);
    color: var(--bg-primary);
    border: none;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.45), 0 0 0 1px rgba(232,201,107,0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}
.export-pdf-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.55), 0 0 0 1px rgba(232,201,107,0.55);
}
.export-pdf-btn:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

/* ── PRINT / SAVE-TO-PDF ─────────────────────────────────────────────────── */
@media print
{
    /* Force a wide, desktop-style layout regardless of actual screen width.
       Landscape + scale=65 in the print dialog usually fits wide tables; the
       user can adjust in the dialog. */
    @page { size: A4 landscape; margin: 10mm; }

    html, body {
        background: #fff !important;
        color: #000 !important;
        width: auto !important;
        min-width: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Remove anything that isn't content */
    .navbar,
    footer,
    #scenariosBar,
    .btn-allocate,
    .allocate-status,
    .export-pdf-btn,
    .recalc-floating-btn,
    .btn-delete,
    .btn-delete-exp,
    .btn-add-row,
    .btn-category-add,
    .scenarios-bar-inner,
    #navAuth,
    .tab-btn,
    .tab-switcher
    {
        display: none !important;
    }

    /* Keep the dark theme colors rather than trying to light-theme charts;
       dark-on-light looks weird for dashboards. Uncomment a block here if
       you ever want to invert for paper printing. */
    :root,
    body,
    .page-content,
    .budget-container,
    .main-split,
    .growth-hero,
    .budget-panel,
    .stat-box,
    .scenarios-bar-inner,
    .results-card,
    .chart-container
    {
        background-color: var(--bg-primary) !important;
    }
    body { color: var(--text-primary) !important; }

    /* Flow the page linearly in print: form first, then chart + summary,
       then full-width table. Side-by-side grids waste space and cause each
       column to paginate independently (leaving blank regions across pages). */
    .page-content {
        display: block !important;
        max-width: none !important;
        padding: 0.5rem 1rem !important;
        gap: 0.5rem !important;
    }
    .main-split { display: block !important; max-width: none !important; }

    .section-header {
        padding: 0.5rem 1rem !important;
        margin: 0 0 0.4rem !important;
        text-align: left !important;
    }
    .section-header h1 { font-size: 1.2rem !important; margin: 0 !important; }
    .section-header p  { font-size: 0.75rem !important; margin: 0.1rem 0 0 !important; }
    .budget-grid      { display: grid !important; grid-template-columns: 1fr 1fr !important; }
    .debt-row { break-inside: avoid !important; page-break-inside: avoid !important; }
    /* Breakdown donuts side-by-side in PDF (mobile CSS collapses this to
       one column at <1024px viewport, which is always true when printing
       from a narrow browser window). */
    .budget-chart-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
        height: 260px !important;
    }
    .budget-chart-grid > div { position: relative !important; }
    .budget-chart-grid canvas { max-width: 100% !important; max-height: 100% !important; }
    .summary-grid     { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; }
    .growth-stats     { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; }

    /* Pack the Parameters form into a 3-column flex layout so it fits in a
       fraction of the vertical space. CSS multi-column was unreliable across
       page breaks (content filled col 1 to full page height before spilling).
       Flex-wrap is predictable: each .form-section is a fixed-width block. */
    .params-card, .form-card {
        max-width: none !important;
        padding: 0.75rem 1rem !important;
        margin: 0 !important;
        background: var(--bg-card) !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem 1rem !important;
        align-items: flex-start !important;
    }
    .form-card > h2 {
        flex: 1 0 100% !important;
        margin: 0 0 0.3rem !important;
        padding-bottom: 0.3rem !important;
        font-size: 1rem !important;
    }
    .form-card .form-section {
        flex: 1 1 calc(33.333% - 1rem) !important;
        min-width: 220px !important;
        margin: 0 !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }
    .form-card .form-section h3 {
        margin: 0 0 0.25rem !important;
        font-size: 0.72rem !important;
        letter-spacing: 0.05em !important;
    }
    .form-card .form-group {
        margin-bottom: 0.35rem !important;
    }
    .form-card .form-group label {
        font-size: 0.72rem !important;
        margin-bottom: 0.15rem !important;
    }
    .form-card .form-group input,
    .form-card .form-group select,
    .form-card .form-group .cselect-btn {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.8rem !important;
    }
    /* Hide the inline "↻ Recalculate" button and the filing tabs */
    .form-card .btn-calculate-inline,
    .form-card .tab-group { display: none !important; }

    /* Results/chart full width */
    .chart-card, .results-card, .growth-hero, .budget-panel {
        width: 100% !important;
        max-width: none !important;
    }
    .chart-container, .hero-chart {
        height: 320px !important;
    }

    /* Tables should never overflow off the page */
    .table-wrapper, .results-table-wrapper {
        max-height: none !important;
        overflow: visible !important;
    }
    table { width: 100% !important; font-size: 0.65rem !important; }
    table thead th, table tbody td {
        padding: 0.18rem 0.35rem !important;
        line-height: 1.15 !important;
    }

    /* Loan schedule: hide the interactive 'Your Prepayment' column + helper
       text. Scoped via :has() so it only targets the amortization table
       (which contains .prepay-input inputs), not retirement/budget tables. */
    .prepay-input { display: none !important; }
    table:has(.prepay-input) thead tr > th:nth-child(5),
    table:has(.prepay-input) tbody tr > td:nth-child(5) {
        display: none !important;
    }
    .results-card:has(.prepay-input) > p,
    button[onclick*="clearCustomPrepayments"] { display: none !important; }

    /* Charts: ensure they render at their intended size */
    canvas { max-width: 100% !important; height: auto !important; }

    /* Avoid splitting a card or chart across pages when possible */
    .growth-hero, .budget-panel, .chart-card, .results-card, .stat-box,
    .scenarios-bar-inner, .chart-container
    {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* ── SETUP CARD (empty-month state) ── */
.setup-card {
    background: var(--bg-card);
    border: 1px solid var(--gold-dark);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
    box-shadow: 0 0 40px rgba(201,168,76,0.08);
}

.setup-card h2 {
    font-family: 'Playfair Display', serif;
    color: var(--gold);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.setup-card > p {
    color: var(--text-muted);
    font-size: 0.92rem;
    max-width: 560px;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

.setup-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.75rem;
    max-width: 640px;
    margin: 0 auto 1rem;
    align-items: end;
}

.setup-input-group { text-align: left; }

.setup-input-group label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.setup-input-group input,
.setup-input-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
}
.setup-input-group input:focus,
.setup-input-group select:focus { outline: none; border-color: var(--gold-dark); }

.setup-apply {
    white-space: nowrap;
    padding: 0.6rem 1.25rem !important;
}

.setup-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

.btn-link {
    background: none;
    border: none;
    color: var(--gold);
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
    padding: 0;
    text-decoration: underline;
}
.btn-link:hover { color: var(--gold-light); }

.btn-reset {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}
.btn-reset:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(231,76,60,0.05);
}

@media (max-width: 768px) {
    .setup-form { grid-template-columns: 1fr; }
    .budget-row { grid-template-columns: 1fr 1fr; }
    .budget-row .row-category { grid-column: 1; }
    .budget-row .row-amount-wrap { grid-column: 2; }
    .budget-row .btn-delete { grid-column: 2; justify-self: end; }
}

.entry-name { flex: 1; font-size: 0.875rem; }
.entry-category {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 0.18rem 0.5rem;
    border-radius: 4px;
}

.entry-amount {
    font-size: 0.875rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 90px;
    text-align: right;
}

.entry-amount.income  { color: var(--success); }
.entry-amount.expense { color: #e09070; }

.btn-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem 0.35rem;
    transition: color 0.2s;
    opacity: 0.5;
    border-radius: 4px;
}

.btn-delete:hover { color: var(--danger); opacity: 1; background: rgba(231,76,60,0.1); }

.panel-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 0 0;
    font-weight: 600;
    font-size: 0.875rem;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    color: var(--text-muted);
}

.panel-total .total-amount { font-size: 1.05rem; color: var(--text-primary); }

/* ── CHILD ROWS (Education Plan) ── */
.child-row {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.6rem;
}

.child-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
}

.child-name {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    color: var(--gold);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

.child-name:focus { outline: none; border-color: var(--gold-dark); }

.btn-delete-child {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0;
    transition: all 0.2s;
}

.btn-delete-child:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(231,76,60,0.1);
}

.child-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.child-row-grid .form-group { margin-bottom: 0; }

.child-row-grid label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.child-row-grid input {
    font-size: 0.82rem;
    padding: 0.4rem 0.5rem;
}

/* ── TEMPLATE BUTTON ── */
.btn-template {
    background: linear-gradient(135deg, var(--gold-dark), var(--gold)) !important;
    color: var(--on-gold) !important;
    border: none !important;
    padding: 0.45rem 1.1rem !important;
    font-weight: 600 !important;
    font-size: 0.88rem !important;
    margin-left: 1rem;
    border-radius: 6px !important;
    cursor: pointer;
    font-family: 'Inter', sans-serif !important;
    transition: all 0.2s;
}

.btn-template:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-light)) !important;
    color: var(--on-gold) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 12px rgba(201,168,76,0.3);
}

/* ── TEMPLATE MODAL ── */
.modal-wide {
    width: 720px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
}

.template-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.template-input-group label,
.template-slider-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.template-input-group input,
.template-input-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
}


.template-slider-group { margin-bottom: 1.25rem; }

.slider-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.slider-row input[type="range"] {
    flex: 1;
    accent-color: var(--gold);
    cursor: pointer;
}

.slider-value {
    min-width: 54px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

.template-table-wrapper {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.template-table {
    width: 100%;
    font-size: 0.82rem;
    margin: 0;
}

.template-table thead th {
    background: var(--bg-secondary);
    padding: 0.55rem 0.75rem;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: left;
}

.template-table tbody tr { border-bottom: 1px solid rgba(30,58,95,0.4); }
.template-table tbody tr:last-child { border-bottom: none; }
.template-table tbody td { padding: 0.45rem 0.75rem; }

.template-table tfoot td {
    padding: 0.65rem 0.75rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    font-weight: 600;
    color: var(--gold);
    font-size: 0.88rem;
}

.tpl-type-need   { color: #5090d0; font-size: 0.72rem; }
.tpl-type-want   { color: #e8c96b; font-size: 0.72rem; }
.tpl-type-save   { color: var(--success); font-size: 0.72rem; }
.tpl-type-give   { color: #a878c8; font-size: 0.72rem; }
.tpl-type-income { color: var(--success); font-size: 0.72rem; font-weight: 600; }

.tpl-amount-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: 'Inter', sans-serif;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.tpl-amount-input:focus { outline: none; border-color: var(--gold-dark); }

.template-warning {
    background: rgba(245,166,35,0.1);
    border: 1px solid rgba(245,166,35,0.3);
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--warning);
}

.template-growth-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.5rem;
}

.tpl-growth-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.55rem;
}

.tpl-growth-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
}

.tpl-growth-grid > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem;
    background: var(--bg-card);
    border-radius: 6px;
}

.tpl-yr {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.tpl-amt {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

/* ── MAIN SPLIT: chart left, budget right ── */
.main-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: start;
}

.main-split #budgetGrid {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 0;
}

.main-split .growth-hero {
    margin-bottom: 0;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

@media (max-width: 1100px) {
    .main-split { grid-template-columns: 1fr; }
    .main-split .growth-hero {
        position: static;
        max-height: none;
        overflow: visible;
    }
}

/* ── SAVINGS GROWTH HERO ── */
.growth-hero {
    background: linear-gradient(155deg,
        var(--bg-secondary) 0%,
        var(--bg-card) 45%,
        var(--bg-input) 100%);
    border: 1px solid var(--gold-dark);
    border-radius: 14px;
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 50px color-mix(in srgb, var(--gold) 12%, transparent);
    position: relative;
    overflow: hidden;
}

.growth-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 60%;
    height: 200%;
    background: radial-gradient(ellipse at center, rgba(201,168,76,0.08) 0%, transparent 65%);
    pointer-events: none;
}

.growth-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    position: relative;
}

.growth-hero-title { flex: 1; min-width: 220px; }

.hero-eyebrow {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    color: var(--gold-dark);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.hero-amount {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.hero-amount.deficit { color: var(--danger); }

.hero-amount-unit {
    font-family: 'Inter', sans-serif;
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.4rem;
    letter-spacing: 0;
}

.hero-sub {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.45rem;
    line-height: 1.5;
    max-width: 520px;
}

.hero-chart {
    height: 360px !important;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .growth-hero { padding: 1.25rem; }
    .hero-amount { font-size: 2rem; }
    .hero-chart { height: 260px !important; }
    .growth-hero-top { flex-direction: column; align-items: stretch; }
}

/* ── LEGACY SAVINGS GROWTH CARD (kept for css hooks) ── */
.growth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.growth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.growth-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--gold);
    margin: 0;
}

.growth-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 0.85rem 0 1rem;
    border-top: 1px solid rgba(201,168,76,0.15);
    border-bottom: 1px solid rgba(201,168,76,0.15);
    margin-bottom: 1rem;
}

.growth-control-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.growth-control-row label { font-weight: 500; }

.growth-controls input[type="number"] {
    width: 64px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    text-align: right;
}

.growth-controls select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
}


.growth-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.growth-stat {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    text-align: center;
}

#growthMilestones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.milestone {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    font-size: 0.82rem;
}

.milestone strong { color: var(--gold); }
.milestone .m-years { color: var(--text-muted); font-size: 0.75rem; }

@media (max-width: 768px) {
    .growth-stats { grid-template-columns: repeat(2, 1fr); }
    .tpl-growth-grid { grid-template-columns: repeat(2, 1fr); }
    .template-form { grid-template-columns: 1fr; }
}

.budget-chart-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.budget-chart-panel h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 1rem;
}

.budget-chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    height: 240px;
}

.empty-state {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1.5rem 0;
    text-align: center;
}

/* ── MODAL ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.72);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    width: 400px;
    max-width: 92vw;
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

.modal h3 {
    font-family: 'Playfair Display', serif;
    color: var(--gold);
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

.modal-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

.btn-primary {
    flex: 1;
    padding: 0.72rem;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    color: var(--on-gold);
    font-weight: 700;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-primary:hover { background: linear-gradient(135deg, var(--gold), var(--gold-light)); }

.btn-secondary {
    flex: 1;
    padding: 0.72rem;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--text-muted); color: var(--text-primary); }

/* ── LEGAL PAGES (disclaimer, terms, privacy) ── */
.legal-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    color: var(--text-primary);
    line-height: 1.7;
}
.legal-container h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    color: var(--gold);
    margin-bottom: 0.25rem;
}
.legal-container h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: var(--gold);
    margin: 2rem 0 0.6rem;
}
.legal-container h3 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin: 1.25rem 0 0.4rem;
    font-weight: 600;
}
.legal-container p {
    margin-bottom: 0.85rem;
    color: var(--text-primary);
    font-size: 0.92rem;
}
.legal-container ul {
    margin: 0 0 0.85rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.92rem;
}
.legal-container ul li { margin-bottom: 0.35rem; }
.legal-container a { color: var(--gold); text-decoration: none; }
.legal-container a:hover { text-decoration: underline; }
.legal-container strong { color: var(--gold-light); }
.legal-container code {
    background: var(--bg-input);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85rem;
}
.legal-updated {
    color: var(--text-muted) !important;
    font-size: 0.82rem !important;
    margin-bottom: 1.5rem !important;
}

/* ── FOOTER ── */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 4rem;
}

footer a { color: var(--gold-dark); text-decoration: none; }

/* ── RESPONSIVE / MOBILE ── */

/* Tablet: collapse split layouts */
@media (max-width: 1024px) {
    .page-content { grid-template-columns: 1fr; }
    .page-content.full-details { max-width: 100%; }
    .form-card { position: static; max-height: none; overflow: visible; }
    .budget-grid { grid-template-columns: 1fr; }
    .budget-chart-grid { grid-template-columns: 1fr; height: auto; }
    .features { grid-template-columns: repeat(2, 1fr); }
}

/* ── MOBILE HAMBURGER + NAV DRAWER ── */
/* Breakpoint sits at 1280px (not the usual 768px) because the desktop nav
   has 8 dropdowns + brand + theme picker + auth, which measures ~1300px on
   one row. Below 1280px the items wrap and misalign — hamburger drawer
   kicks in instead. */
.nav-hamburger { display: none; }

@media (max-width: 1280px) {
    .navbar {
        flex-wrap: wrap;
        padding: 0 1rem;
        position: relative;
    }

    .nav-hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 44px;
        height: 44px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-left: auto;
        gap: 5px;
    }
    .nav-hamburger span {
        display: block;
        width: 22px;
        height: 2px;
        background: var(--gold);
        border-radius: 1px;
        transition: all 0.25s ease;
    }
    .navbar.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .navbar.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; }
    .navbar.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* Hide horizontal nav-links + nav-auth; show as stacked drawer below navbar */
    .nav-links,
    .nav-auth {
        display: none;
        width: 100%;
        order: 10;
        padding: 0.5rem 0 0.75rem;
    }
    .navbar.nav-open .nav-links,
    .navbar.nav-open .nav-auth {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }
    .navbar.nav-open {
        padding-bottom: 0.75rem;
        box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    }
    /* Drawer (hamburger opened): explicit dark navy background + full-width extension */
    .navbar.nav-open .nav-links,
    .navbar.nav-open .nav-auth {
        background: var(--bg-secondary);
        margin: 0 -1rem;
        padding: 0.5rem 1rem 0.75rem;
    }
    .navbar.nav-open .nav-auth {
        border-top: 1px solid var(--border);
        margin-top: 0.25rem;
        padding: 0.75rem 1rem 0.5rem;
    }
    .nav-links li { list-style: none; margin: 0; padding: 0; }
    .navbar.nav-open .nav-links a {
        display: block;
        padding: 0.85rem 1rem;
        border-radius: 6px;
        text-align: left;
        font-size: 0.95rem;
    }
    .navbar.nav-open .nav-auth-link {
        display: block;
        width: 100%;
        padding: 0.85rem 1rem;
        border-radius: 6px;
        text-align: center;
        font-size: 0.95rem;
        font-weight: 600;
        box-sizing: border-box;
    }
    .navbar.nav-open .nav-auth-cta { padding: 0.95rem 1rem; }
    .navbar.nav-open .nav-user-email {
        max-width: none;
        padding: 0.6rem 1rem;
        text-align: center;
        background: var(--bg-input);
        border-radius: 6px;
        font-size: 0.88rem;
    }
    /* Mobile drawer: flatten dropdowns into inline items so the user can
       see every page in the list. Hide the toggle's chevron and reveal
       the inner <a>s. */
    .navbar.nav-open .nav-dropdown-toggle::after { display: none; }
    .navbar.nav-open .nav-dropdown-menu {
        display: block !important;
        position: static !important;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        background: transparent;
        min-width: 0;
    }
    .navbar.nav-open .nav-dropdown-menu a {
        padding-left: 1.5rem;
        font-size: 0.85rem;
        color: var(--text-muted);
    }
    .navbar.nav-open .nav-dropdown-menu a.active {
        color: var(--gold);
    }
}

/* ── MOBILE LAYOUT / SIZING ── */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.4rem; }
    .features { grid-template-columns: 1fr; }
    .start-here-grid { grid-template-columns: 1fr; }
    .start-here, .features-section-label { padding: 0 1rem; }
    .page-content { padding: 1rem; gap: 1rem; }
    .budget-container { padding: 1rem; }
    .section-header { padding: 1.5rem 1rem 1rem; }
    .section-header h1 { font-size: 1.6rem; }
    .results-card { padding: 1rem; }
    .form-card { padding: 1rem; }

    /* Form rows become single-column on narrow */
    .form-row { grid-template-columns: 1fr; }

    /* Summary stat boxes: 2-per-row on mobile instead of many-per-row */
    .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .stat-box { padding: 0.7rem 0.75rem; }
    .stat-box .stat-value { font-size: 0.95rem; }

    /* Section header button (↻ Recalculate) stays on same line but shrinks */
    .btn-calculate-inline { padding: 0.35rem 0.7rem; font-size: 0.75rem; }

    /* Hero amount in budget page scales down */
    .hero-amount { font-size: 1.8rem; }
    .hero-amount-unit { font-size: 0.9rem; }
    .hero-chart { height: 260px !important; }
    .growth-hero { padding: 1rem; }
    .growth-hero-top { flex-direction: column; align-items: stretch; }
    .growth-stats { grid-template-columns: repeat(2, 1fr); }

    /* Scenarios bar: stack controls vertically */
    .scenarios-bar-inner {
        flex-direction: column;
        align-items: stretch;
        padding: 0.6rem 0.75rem;
    }
    .scenarios-bar-inner select,
    .scenarios-name { width: 100%; min-width: 0; }

    /* Budget rows: name full width, category + amount + delete on second line */
    .budget-row {
        grid-template-columns: 1fr auto 30px;
        grid-template-rows: auto auto;
        gap: 0.35rem;
    }
    .budget-row .row-name     { grid-column: 1 / 4; grid-row: 1; }
    .budget-row .row-category { grid-column: 1;     grid-row: 2; }
    .budget-row .row-amount-wrap { grid-column: 2;  grid-row: 2; min-width: 110px; }
    .budget-row .btn-delete   { grid-column: 3;     grid-row: 2; }

    /* Category headers stay tidy */
    .category-header { grid-template-columns: 1fr auto auto; }

    /* Tables: slightly smaller font + tighter padding, but still scroll horizontally */
    .table-wrapper { max-height: 480px; overflow-x: auto; }
    table { width: max-content; min-width: 100%; font-size: 0.72rem; }
    thead th, tbody td { padding: 0.4rem 0.5rem !important; }

    /* Retirement housing toggle etc. */
    .housing-toggle { flex-wrap: wrap; }

    /* Auth cards take full width with smaller padding */
    .auth-card { padding: 1.5rem 1.25rem; }
    .auth-container { padding: 1.5rem 1rem 3rem; }

    /* Child rows (education) stay 2-col but compact */
    .child-row-grid { grid-template-columns: 1fr 1fr; gap: 0.35rem; }

    /* Ensure inputs are at least 16px font on mobile to prevent iOS zoom */
    .form-group input,
    .form-group select,
    .row-name, .row-amount, .row-category,
    .auth-form input,
    .setup-input-group input, .setup-input-group select { font-size: 16px; }

    /* Touch-friendly minimum sizes for interactive elements */
    .btn-delete, .btn-delete-exp, .btn-delete-child { min-width: 32px; min-height: 32px; }
    .btn-calculate { padding: 1rem; font-size: 1rem; }

    /* Chart corner labels: keep legible */
    .chart-label-left, .chart-label-right { font-size: 0.72rem; }

    /* Template table on budget: make it touch-scrollable */
    .template-table-wrapper { overflow-x: auto; }
}

/* ── EXTRA SMALL (<480px): tighter further ── */
@media (max-width: 480px) {
    .navbar { height: 56px; padding: 0 0.75rem; }
    .nav-brand { font-size: 1.25rem; }
    .section-header h1 { font-size: 1.3rem; }
    .hero-amount { font-size: 1.5rem; }
    .hero-chart { height: 220px !important; }

    /* Summary stats: back to 1-col if viewport is very narrow */
    .summary-grid { grid-template-columns: 1fr; }
    .growth-stats { grid-template-columns: 1fr; }

    /* Hide age/years labels that were already compact */
    .scenarios-label { font-size: 0.78rem; }
}

