/* ================================================================
   LLOS.ai Calculator Series — Shared Styles v2
   Used by: emi.html, eligibility.html, and all future calculator pages
   Visual language: Premium fintech — clean, airy, confident
   ================================================================ */

/* ── Theme Variables ── */
:root {
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    --primary-glow: rgba(37,99,235,0.12);
    --accent-bg: #eff6ff;
    --accent-border: #bfdbfe;
    --cyan: #06b6d4;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --bg: #f8fafc;
    --surface: rgba(255,255,255,0.72);
    --surface-solid: #ffffff;
    --border: #e2e8f0;
    --border-light: rgba(226,232,240,0.5);
    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --ok-border: #86efac;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    --warn-border: #fcd34d;
    --bad: #dc2626;
    --bad-soft: #fee2e2;
    --bad-border: #fca5a5;
    --radius: 14px;
    --radius-lg: 1.25rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 20px -2px rgba(0,0,0,0.06), 0 2px 6px -2px rgba(0,0,0,0.03);
    --shadow-lg: 0 12px 40px -8px rgba(0,0,0,0.1);
    --shadow-panel: 0 1px 2px rgba(0,0,0,0.04), 0 4px 24px -4px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; width: 100%; max-width: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background:
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(191,219,254,0.25) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 85% 75%, rgba(165,243,252,0.2) 0%, transparent 50%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    line-height: 1.6;
    letter-spacing: -0.011em;
}

.heading-font { font-family: 'Inter', sans-serif; font-weight: 800; letter-spacing: -0.025em; }
.serif { font-family: 'Merriweather', serif; }

/* ── Container ── */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.25rem;
    overflow-x: hidden;
}
@media (min-width: 640px) { .container { padding: 0 2rem; } }
@media (min-width: 1024px) { .container { padding: 0 2.5rem; } }

/* ================================================================
   NAVIGATION
   ================================================================ */
.calc-nav {
    background: rgba(255,255,255,0.88);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow-x: hidden;
    max-width: 100%;
}

.calc-nav .container { padding: 0 1.25rem; }
@media (min-width: 640px) { .calc-nav .container { padding: 0 2rem; } }

.calc-nav .logo {
    font-size: 1.125rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    letter-spacing: -0.03em;
}

.calc-nav a.nav-link {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
    letter-spacing: 0;
}
.calc-nav a.nav-link:hover { color: var(--primary); }

/* ================================================================
   HERO SECTION
   ================================================================ */
.calc-hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(ellipse 100% 100% at 0% 0%, rgba(37,99,235,0.06) 0%, transparent 50%),
        radial-gradient(ellipse 60% 80% at 100% 100%, rgba(6,182,212,0.05) 0%, transparent 50%),
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    padding: 2rem 0 2.25rem;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
@media (min-width: 768px) { .calc-hero { padding: 2.5rem 0 2.75rem; } }

/* Subtle grid dots */
.calc-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(37,99,235,0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
}

.breadcrumbs {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 500;
}
.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .sep { margin: 0 0.5rem; color: #cbd5e1; }

.calc-hero h1 {
    font-size: clamp(1.5rem, 3.5vw, 2.125rem);
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.15;
    letter-spacing: -0.03em;
}
.calc-hero .byline {
    font-size: 0.9375rem;
    font-style: italic;
    color: var(--text-secondary);
    max-width: 560px;
    line-height: 1.5;
    font-family: 'Merriweather', serif;
    font-weight: 300;
}
.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.75rem;
    background: var(--surface-solid);
    color: var(--primary);
    border-radius: 50px;
    font-size: 0.6875rem;
    font-weight: 600;
    border: 1px solid var(--accent-border);
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(37,99,235,0.08);
    letter-spacing: 0.02em;
}

/* ================================================================
   NUMBER FORMAT TOGGLE
   ================================================================ */
.format-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.375rem 0.25rem 0.75rem;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
}
.format-toggle button {
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    border: none;
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--text-muted);
}
.format-toggle button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 4px rgba(37,99,235,0.25);
}

/* ================================================================
   CALCULATOR LAYOUT
   ================================================================ */
.calc-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin: 1.75rem 0;
}
@media (min-width: 1024px) {
    .calc-layout {
        grid-template-columns: 1fr 400px;
        gap: 1.75rem;
        align-items: start;
    }
}
@media (min-width: 1280px) {
    .calc-layout {
        grid-template-columns: 1fr 420px;
    }
}

/* ── Input Panel ── */
.input-panel {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-panel);
    overflow-x: hidden;
    max-width: 100%;
}
@media (min-width: 768px) { .input-panel { padding: 1.75rem; } }

.input-panel h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    letter-spacing: -0.02em;
}
.input-panel h2 i {
    color: var(--primary);
    font-size: 0.9375rem;
}

/* ── Section dividers inside inputs ── */
.input-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-light);
}
.input-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.input-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ================================================================
   DUAL INPUT (Slider + Text)
   ================================================================ */
.dual-input {
    margin-bottom: 1.25rem;
}
.dual-input:last-child { margin-bottom: 0; }

.dual-input-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.625rem;
}
.dual-input-label label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.dual-input-label .tooltip-trigger,
.toggle-group-label .tooltip-trigger {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5625rem;
    font-weight: 700;
    cursor: help;
    flex-shrink: 0;
    transition: all 0.2s;
}
.dual-input-label .tooltip-trigger:hover,
.toggle-group-label .tooltip-trigger:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.dual-input-value {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.dual-input-controls {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}
.dual-input-controls input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    transition: background 0.2s;
}
.dual-input-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--surface-solid);
    border: 2.5px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    transition: transform 0.15s, box-shadow 0.15s;
}
.dual-input-controls input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px var(--primary-glow), 0 1px 4px rgba(0,0,0,0.1);
}
.dual-input-controls input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px var(--primary-glow), 0 1px 4px rgba(0,0,0,0.1);
}
.dual-input-controls input[type="range"]::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--surface-solid);
    border: 2.5px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.dual-input-controls input[type="text"],
.dual-input-controls input[type="number"] {
    width: 92px;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
    background: var(--bg);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.dual-input-controls input[type="text"]:focus,
.dual-input-controls input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--surface-solid);
}
.dual-input-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    flex-shrink: 0;
    min-width: 20px;
}

/* Range fill (JS sets background gradient) */
.dual-input-controls input[type="range"].filled {
    /* Background set dynamically by JS */
}

/* ── Toggle Switch ── */
.toggle-group {
    margin-bottom: 1.25rem;
}
.toggle-group-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.toggle-buttons {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg);
}
.toggle-buttons button {
    padding: 0.4375rem 0.875rem;
    border: none;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: var(--text-muted);
    white-space: nowrap;
}
.toggle-buttons button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 1px 3px rgba(37,99,235,0.2);
}
.toggle-buttons button:not(:last-child) {
    border-right: 1px solid var(--border);
}

/* ── Dropdown Select ── */
.calc-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    cursor: pointer;
    transition: border-color 0.2s;
}
.calc-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--surface-solid);
}

/* ── Expandable Section ── */
.expandable {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
    background: var(--surface-solid);
}
.expandable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    background: var(--bg);
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: background 0.15s;
}
.expandable-header:hover { background: var(--accent-bg); }
.expandable-header i {
    transition: transform 0.2s;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.expandable.open .expandable-header i { transform: rotate(180deg); }
.expandable-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.expandable.open .expandable-body {
    max-height: 800px;
}
.expandable-content {
    padding: 1.25rem;
    overflow-x: hidden;
    max-width: 100%;
}

/* ================================================================
   RESULTS PANEL (Sticky)
   ================================================================ */
.results-panel {
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-panel);
    overflow-x: hidden;
    max-width: 100%;
}
@media (min-width: 1024px) {
    .results-panel {
        position: sticky;
        top: 72px;
        max-height: calc(100vh - 90px);
        overflow-y: auto;
    }
}

.results-panel h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.results-panel h2 i { color: var(--primary); font-size: 0.875rem; }

/* Big result number */
.result-hero {
    text-align: center;
    padding: 1.25rem 1rem;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0c4a6e 100%);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    position: relative;
    overflow: hidden;
}
/* Subtle shimmer overlay */
.result-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.04) 50%, transparent 70%);
    pointer-events: none;
}
.result-hero-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.6);
    margin-bottom: 0.25rem;
}
.result-hero-value {
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    font-weight: 800;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

/* Result row */
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
}
.result-row:last-child { border-bottom: none; }
.result-row-label {
    color: var(--text-muted);
    font-weight: 500;
    min-width: 0;
    overflow-wrap: break-word;
    flex: 1;
}
.result-row-value {
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    text-align: right;
}

/* Result card for special outputs */
.result-card {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.875rem;
    border: 1px solid;
}
.result-card.safe {
    background: var(--ok-soft);
    border-color: var(--ok-border);
    color: #15803d;
}
.result-card.moderate {
    background: var(--warn-soft);
    border-color: var(--warn-border);
    color: #92400e;
}
.result-card.risky {
    background: var(--bad-soft);
    border-color: var(--bad-border);
    color: #991b1b;
}
.result-card-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}
.result-card-value {
    font-size: 1.25rem;
    font-weight: 800;
}

/* Highlighted result rows (APR, special metrics) */
.result-row-blue {
    background: rgba(239,246,255,0.6);
    border-radius: 10px;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--accent-border);
}
.result-row-blue .result-row-label { font-weight: 600; color: var(--primary); }
.result-row-blue .result-row-value { color: var(--primary); }

.result-row-cyan {
    background: rgba(236,254,255,0.6);
    border-radius: 10px;
    padding: 0.75rem 0.875rem;
    border: 1px solid #a5f3fc;
    margin-top: 0.5rem;
}
.result-row-cyan .result-row-label { font-weight: 600; color: #0e7490; }
.result-row-cyan .result-row-value { color: #0e7490; }

/* Chart canvas wrapper */
.chart-wrap {
    margin: 1rem 0;
    position: relative;
}
.chart-wrap canvas {
    width: 100% !important;
    max-height: 180px;
}

/* ── Mobile sticky results bar ── */
@media (max-width: 1023px) {
    .results-mobile-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 90;
        background: rgba(255,255,255,0.95);
        -webkit-backdrop-filter: saturate(180%) blur(16px);
        backdrop-filter: saturate(180%) blur(16px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 24px rgba(0,0,0,0.08);
        padding: 0.75rem 1.25rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        transition: transform 0.3s ease;
    }
    .results-mobile-bar .mobile-emi {
        font-size: 1.0625rem;
        font-weight: 800;
        color: var(--text);
    }
    .results-mobile-bar .mobile-label {
        font-size: 0.6875rem;
        color: var(--text-muted);
        font-weight: 500;
    }
    .results-mobile-bar .mobile-expand {
        padding: 0.5rem 1rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 10px;
        font-size: 0.75rem;
        font-weight: 600;
        cursor: pointer;
        box-shadow: 0 1px 4px rgba(37,99,235,0.25);
    }
    body.has-mobile-bar { padding-bottom: 72px; }
}
@media (min-width: 1024px) {
    .results-mobile-bar { display: none; }
}

/* ================================================================
   COMPARE MODE (2 lenders side by side)
   ================================================================ */
.compare-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px dashed var(--accent-border);
    border-radius: 10px;
    margin-bottom: 1rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    transition: all 0.2s;
}
.compare-toggle:hover {
    background: var(--accent-bg);
    border-style: solid;
}
.compare-toggle i {
    font-size: 1rem;
}

.compare-grid {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.compare-grid.active { display: grid; }
@media (max-width: 768px) {
    .compare-grid { grid-template-columns: 1fr; }
}
.compare-col {
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    background: var(--bg);
}
.compare-col.winner {
    border-color: var(--ok);
    background: rgba(220,252,231,0.3);
}
.compare-col-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-align: center;
}
.winner-badge {
    position: absolute;
    top: -10px; right: 12px;
    background: var(--ok);
    color: white;
    font-size: 0.625rem;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ================================================================
   AMORTIZATION TABLE
   ================================================================ */
.amort-section {
    margin: 1.75rem 0;
}
.amort-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-solid);
}
.amort-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.amort-table th {
    background: var(--bg);
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    position: sticky;
    top: 0;
}
.amort-table th:first-child { text-align: center; }
.amort-table td {
    padding: 0.625rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border-light);
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}
.amort-table td:first-child {
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
}
.amort-table tbody tr:hover {
    background: var(--accent-bg);
}

/* ================================================================
   CONSTRAINT BARS (for Eligibility)
   ================================================================ */
.constraint-bar {
    margin-bottom: 1rem;
}
.constraint-bar-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.constraint-bar-label { color: var(--text-muted); }
.constraint-bar-value { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.constraint-bar-track {
    height: 8px;
    border-radius: 4px;
    background: var(--bg);
    overflow: hidden;
    border: 1px solid var(--border-light);
}
.constraint-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease, background-color 0.3s;
}
.constraint-bar-fill.safe { background: var(--ok); }
.constraint-bar-fill.moderate { background: var(--warn); }
.constraint-bar-fill.risky { background: var(--bad); }

/* ================================================================
   GLOSSARY (Chip Cloud + Tooltip)
   ================================================================ */
.glossary-section {
    margin: 2.25rem 0;
    text-align: center;
}
.glossary-section h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}
.glossary-section .glossary-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.glossary-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.glossary-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    border-radius: 999px;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}
.glossary-chip:hover,
.glossary-chip:focus {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.1);
}
.glossary-chip .icon { font-size: 0.9375rem; line-height: 1; }

.chip-tip {
    position: fixed;
    z-index: 200;
    min-width: 0;
    max-width: min(92vw, 400px);
    background: var(--text);
    color: rgba(255,255,255,0.95);
    padding: 1rem 1.125rem;
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    line-height: 1.6;
    font-size: 0.8125rem;
    font-weight: 400;
}
.chip-tip.show { opacity: 1; visibility: visible; }
.chip-tip .arrow {
    position: absolute;
    width: 12px; height: 12px;
    background: var(--text);
    transform: rotate(45deg);
}

/* ================================================================
   QUIZ SECTION
   ================================================================ */
.quiz-section {
    margin: 2.25rem 0;
    background: var(--surface-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
}
@media (min-width: 768px) { .quiz-section { padding: 2rem; } }

.quiz-section h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 0.375rem;
    letter-spacing: -0.02em;
}
.quiz-section .quiz-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.quiz-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}
.quiz-counter {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
}
.quiz-score {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--ok);
}
.quiz-nav button {
    padding: 0.4375rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface-solid);
    color: var(--text-secondary);
}
.quiz-nav button:hover:not(:disabled) {
    background: var(--accent-bg);
    border-color: var(--accent-border);
    color: var(--primary);
}
.quiz-nav button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.quiz-question {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.quiz-options {
    display: grid;
    gap: 0.75rem;
}
.quiz-option {
    position: relative;
}
.quiz-option label {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--surface-solid);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.2s;
    line-height: 1.5;
    color: var(--text-secondary);
}
.quiz-option label:hover {
    border-color: var(--accent-border);
    background: var(--accent-bg);
    color: var(--text);
}
.quiz-option input[type="radio"] {
    flex-shrink: 0;
    width: 18px; height: 18px;
    accent-color: var(--primary);
    margin-top: 1px;
}
.quiz-option .explanation {
    display: none;
    margin-top: 0.625rem;
    padding: 0.875rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    line-height: 1.6;
    border-left: 3px solid;
}
.quiz-option.selected.correct label {
    background: var(--ok-soft);
    border-color: var(--ok);
    color: var(--text);
}
.quiz-option.selected.wrong label {
    background: var(--bad-soft);
    border-color: var(--bad);
    color: var(--text);
}
.quiz-option.correct .explanation {
    display: block;
    border-left-color: var(--ok);
    background: #f0fdf4;
}
.quiz-option.wrong .explanation {
    display: block;
    border-left-color: var(--bad);
    background: #fef2f2;
}
.quiz-option.show-correct .explanation {
    display: block;
    border-left-color: var(--ok);
    background: #f0fdf4;
}

/* Quiz summary */
.quiz-summary {
    text-align: center;
    padding: 2rem 1rem;
}
.quiz-summary-score {
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}
.quiz-summary-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.quiz-retry {
    padding: 0.75rem 2rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 1px 4px rgba(37,99,235,0.25);
}
.quiz-retry:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37,99,235,0.3);
}

/* ================================================================
   FAQ SECTION
   ================================================================ */
.calc-faq-section {
    background: var(--surface-solid);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin: 2.25rem 0;
    border: 1px solid var(--border);
}
@media (min-width: 768px) { .calc-faq-section { padding: 2rem; } }

.calc-faq-section h2 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.faq-item {
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
}
.faq-item:last-child { border-bottom: none; }

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    cursor: pointer;
    gap: 1rem;
    font-weight: 600;
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: color 0.15s;
}
.faq-question:hover { color: var(--primary); }

.faq-icon {
    flex-shrink: 0;
    transition: transform 0.2s;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}
.faq-item.open .faq-icon { transform: rotate(180deg); }

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.7;
}
.faq-item.open .faq-answer {
    max-height: 500px;
    margin-top: 0.75rem;
    padding-top: 0.5rem;
}

/* ================================================================
   FOOTER
   ================================================================ */
.calc-footer {
    background: var(--surface-solid);
    border-top: 1px solid var(--border);
    padding-top: 2.5rem;
    padding-bottom: 1.25rem;
    margin-top: 2rem;
    overflow-x: hidden;
    max-width: 100%;
}

/* ================================================================
   INLINE TOOLTIP (for ? marks next to inputs)
   ================================================================ */
.inline-tip {
    position: fixed;
    z-index: 200;
    max-width: 280px;
    background: var(--text);
    color: rgba(255,255,255,0.93);
    padding: 0.75rem 0.875rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    pointer-events: none;
}
.inline-tip.show { opacity: 1; visibility: visible; }

/* ================================================================
   ERROR / WARNING MESSAGES
   ================================================================ */
.input-warning {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4375rem 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
    display: none;
}
.input-warning.show { display: block; }
.input-warning.warn {
    background: var(--warn-soft);
    color: #92400e;
    border: 1px solid var(--warn-border);
}
.input-warning.error {
    background: var(--bad-soft);
    color: #991b1b;
    border: 1px solid var(--bad-border);
}

/* ================================================================
   MOBILE RESPONSIVE FIXES
   ================================================================ */
@media (max-width: 640px) {
    /* ── GLOBAL MOBILE CONTAINMENT ── */
    body {
        padding-left: 0; padding-right: 0;
        background-attachment: scroll;
    }
    .container { padding: 0 1rem; overflow-x: hidden; }
    .calc-nav, .calc-hero, .calc-footer,
    .glossary-section, .quiz-section, .calc-faq-section,
    .amort-section, .calc-layout { overflow-x: hidden; max-width: 100%; }

    /* ── NAV ── */
    .calc-nav .container > div > div:first-child {
        min-width: 0; flex: 1; overflow: hidden;
    }
    .calc-nav .container > div > div:first-child > span:last-child {
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .calc-nav .logo { font-size: 0.9375rem; flex-shrink: 0; }
    .calc-nav a.nav-link { font-size: 0.75rem; padding: 0; }
    .calc-nav .container > div > div:last-child { gap: 0.5rem; }
    .calc-nav .container > div > div:first-child { gap: 0.375rem; }

    /* ── HERO ── */
    .calc-hero { padding: 1.25rem 0 1.5rem; }
    .calc-hero::before { background-size: 20px 20px; }
    .calc-hero h1 { font-size: 1.375rem; }
    .calc-hero .byline { font-size: 0.8125rem; line-height: 1.4; }
    .hero-badge { font-size: 0.625rem; padding: 0.25rem 0.625rem; margin-bottom: 0.5rem; }
    .breadcrumbs { font-size: 0.75rem; margin-bottom: 0.625rem; }
    .format-toggle { font-size: 0.6875rem; }
    .format-toggle button { font-size: 0.625rem; padding: 0.25rem 0.5rem; }

    /* ── CALCULATOR LAYOUT ── */
    .calc-layout { margin: 1rem 0; gap: 1rem; }

    /* ── INPUT PANEL ── */
    .input-panel { padding: 1rem; border-radius: var(--radius); }
    .input-panel h2 { font-size: 0.9375rem; margin-bottom: 0.875rem; }
    .input-section { margin-bottom: 1rem; padding-bottom: 1rem; }
    .input-section-title { font-size: 0.625rem; margin-bottom: 0.625rem; }

    /* ── DUAL INPUTS ── */
    .dual-input { margin-bottom: 1rem; }
    .dual-input-label { margin-bottom: 0.5rem; }
    .dual-input-label label { font-size: 0.8125rem; min-width: 0; }
    .dual-input-value { font-size: 0.8125rem; flex-shrink: 0; }
    .dual-input-controls { gap: 0.625rem; min-width: 0; }
    .dual-input-controls input[type="range"] { min-width: 0; }
    .dual-input-controls input[type="text"],
    .dual-input-controls input[type="number"] { width: 76px; font-size: 0.75rem; padding: 0.375rem 0.5rem; flex-shrink: 0; }
    .dual-input-controls input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; }
    .dual-input-controls input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; }

    /* ── TOGGLES ── */
    .toggle-group { margin-bottom: 1rem; }
    .toggle-group-label { font-size: 0.8125rem; margin-bottom: 0.375rem; min-width: 0; }
    .toggle-buttons { max-width: 100%; flex-wrap: wrap; }
    .toggle-buttons button { font-size: 0.6875rem; padding: 0.3rem 0.625rem; }

    /* ── RESULTS PANEL ── */
    .results-panel { padding: 1rem; border-radius: var(--radius); }
    .results-panel h2 { font-size: 0.75rem; margin-bottom: 0.75rem; }
    .result-hero { padding: 1rem 0.75rem; }
    .result-hero-value { font-size: 1.375rem; }
    .result-row { font-size: 0.75rem; padding: 0.625rem 0; gap: 0.5rem; }
    .result-row-label { font-size: 0.6875rem; }
    .result-row-value { font-size: 0.75rem; }

    /* ── HIGHLIGHTED RESULT ROWS ── */
    .result-row-blue, .result-row-cyan {
        padding: 0.625rem 0.75rem;
        font-size: 0.6875rem;
    }

    /* ── CHARTS ── */
    .chart-wrap canvas { max-height: 180px; }

    /* ── GLOSSARY ── */
    .glossary-section { margin: 1.5rem 0; }
    .glossary-section h2 { font-size: 1.0625rem; overflow-wrap: break-word; }
    .glossary-cloud { gap: 0.375rem; }
    .glossary-chip { font-size: 0.6875rem; padding: 0.375rem 0.625rem; gap: 0.25rem; }
    .glossary-chip .icon { font-size: 0.875rem; }
    .chip-tip { max-width: calc(100vw - 1.5rem); font-size: 0.75rem; padding: 0.75rem; }

    /* ── QUIZ ── */
    .quiz-section { margin: 1.5rem 0; padding: 1.25rem; }
    .quiz-section h2 { font-size: 1.0625rem; }
    .quiz-nav { flex-wrap: wrap; gap: 0.375rem; justify-content: center; }
    .quiz-question { font-size: 0.875rem; }
    .quiz-option label { padding: 0.75rem 0.625rem; font-size: 0.8125rem; gap: 0.5rem; }
    .quiz-option .explanation { font-size: 0.75rem; padding: 0.625rem; }

    /* ── FAQ ── */
    .calc-faq-section { margin: 1.5rem 0; padding: 1.25rem; }
    .calc-faq-section h2 { font-size: 1.0625rem; }
    .faq-question { font-size: 0.875rem; }
    .faq-answer { font-size: 0.8125rem; }

    /* ── COMPARE ── */
    .compare-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .compare-col { padding: 0.875rem; }

    /* ── AMORTIZATION ── */
    .amort-table { font-size: 0.75rem; }
    .amort-table th { padding: 0.5rem 0.5rem; font-size: 0.625rem; }
    .amort-table td { padding: 0.5rem 0.5rem; }

    /* ── FOOTER ── */
    .calc-footer { padding-top: 1.5rem; padding-bottom: 1rem; margin-top: 1.5rem; }

    /* ── EXPANDABLE ── */
    .expandable-header { padding: 0.75rem; font-size: 0.75rem; }
    .expandable-content { padding: 1rem; }

    /* ── CONSTRAINT BARS ── */
    .constraint-bar-header { font-size: 0.6875rem; }
}

@media (max-width: 380px) {
    .container { padding: 0 0.75rem; }
    .calc-hero h1 { font-size: 1.25rem; }
    .calc-nav .logo { font-size: 0.875rem; }
    .dual-input-controls input[type="text"],
    .dual-input-controls input[type="number"] { width: 64px; font-size: 0.6875rem; }
    .toggle-buttons button { font-size: 0.625rem; padding: 0.25rem 0.5rem; }
    .result-row { font-size: 0.6875rem; }
    .glossary-chip { font-size: 0.625rem; padding: 0.3rem 0.5rem; }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
    .calc-nav, .results-mobile-bar, .quiz-section, .format-toggle { display: none !important; }
    .results-panel { position: static !important; }
    body { background: white !important; }
    .input-panel, .results-panel { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ================================================================
   UTILITY
   ================================================================ */
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
