:root {
    --navy: #0f1f38;
    --navy-light: #1a2b4a;
    --slate: #4a5568;
    --muted: #718096;
    --pale: #e2e8f0;
    --surface: #f7fafc;
    --gold: #c9a23e;
    --gold-light: #e8c96a;
    --green: #2f855a;
    --green-pale: #c6f6d5;
    --red: #c53030;
    --red-pale: #fed7d7;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-sm: 6px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--surface);
    color: var(--navy);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }

/* Header */
.site-header {
    text-align: center;
    padding: 48px 16px 32px;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    margin-bottom: 32px;
    position: relative;
}
.site-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}
.site-header h1 {
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}
.site-header .tagline {
    font-size: 1.05rem;
    color: rgba(255,255,255,0.75);
    font-weight: 400;
    max-width: 520px;
    margin: 0 auto;
}
.trust-strip {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.55);
    flex-wrap: wrap;
}
.trust-strip span { display: inline-flex; align-items: center; gap: 5px; }

/* Dark Mode Toggle */
.dark-toggle {
    position: absolute;
    top: 16px; right: 16px;
    display: flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: rgba(255,255,255,0.7);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.dark-toggle:hover { background: rgba(255,255,255,0.15); }
.dark-toggle svg { width: 14px; height: 14px; }

/* Calculator Grid */
.calculator-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.calc-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--pale);
    padding: 24px;
    text-decoration: none;
    color: var(--navy);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    display: block;
}
.calc-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--gold);
}
.calc-card .icon {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}
.calc-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--navy-light);
}
.calc-card p {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.5;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 20px;
    border: 1px solid var(--pale);
}
.card h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--slate);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.field { margin-bottom: 4px; }
.field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--slate);
    margin-bottom: 6px;
}
.field input[type="number"],
.field select {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--pale);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--navy);
    font-size: 1rem;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,162,62,0.12);
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.slider-row input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: var(--pale);
    border-radius: 3px;
    outline: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px; height: 18px;
    background: var(--gold);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.slider-row input[type="range"]::-moz-range-thumb {
    width: 18px; height: 18px;
    background: var(--gold);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.slider-val {
    min-width: 64px;
    text-align: right;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--navy-light);
    font-variant-numeric: tabular-nums;
}

.calc-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.calc-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}
.calc-btn:active { transform: translateY(0); }

/* Results */
.results { display: none; }
.results.visible { display: block; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
@media (max-width: 640px) { .metrics { grid-template-columns: 1fr; } }

.metric {
    background: var(--surface);
    border: 1px solid var(--pale);
    border-radius: var(--radius-sm);
    padding: 18px 16px;
    transition: box-shadow 0.15s;
}
.metric:hover { box-shadow: var(--shadow); }
.metric .label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 6px;
}
.metric .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.metric.primary {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    border-color: transparent;
    color: var(--white);
}
.metric.primary .label { color: rgba(255,255,255,0.65); }
.metric.primary .value { color: var(--gold-light); font-size: 2rem; }
.metric.positive .value { color: var(--green); }
.metric.negative .value { color: var(--red); }

/* Chart */
.chart-wrap {
    margin-top: 20px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--pale);
}
.chart-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
    letter-spacing: 0.8px;
}
.chart-area {
    height: 220px;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    padding-bottom: 28px;
}
.chart-bar {
    flex: 1;
    min-width: 6px;
    border-radius: 3px 3px 0 0;
    position: relative;
    transition: height 0.5s ease;
    display: flex;
    flex-direction: column-reverse;
    align-items: stretch;
    overflow: hidden;
}
.chart-bar .stack-contrib { flex-shrink: 0; background: var(--green); opacity: 0.55; width: 100%; }
.chart-bar .stack-interest { flex-shrink: 0; background: var(--gold); opacity: 0.75; width: 100%; }
.chart-bar .year-label {
    position: absolute;
    bottom: -22px; left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--muted);
    white-space: nowrap;
}
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--muted);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* Comparison */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.88rem;
}
.comparison-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--slate);
    border-bottom: 2px solid var(--pale);
}
.comparison-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--pale);
    color: var(--navy);
    font-variant-numeric: tabular-nums;
}
.comparison-table tr:hover td { background: rgba(0,0,0,0.015); }
.comparison-table .highlight td { font-weight: 600; }
.comparison-table .highlight.pos td { color: var(--green); background: var(--green-pale); }
.comparison-table .highlight.neg td { color: var(--red); background: var(--red-pale); }
.comparison-table .diff td {
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--red);
    background: var(--red-pale);
}

/* Insight */
.insight {
    margin-top: 16px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #f0f4ff 0%, #fff 100%);
    border-left: 4px solid var(--gold);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.92rem;
    color: var(--slate);
    line-height: 1.7;
}
.insight strong { color: var(--navy-light); }

/* Scenarios */
.scenario-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 12px;
}
@media (max-width: 640px) { .scenario-cards { grid-template-columns: 1fr; } }
.scenario-card {
    border: 1.5px solid var(--pale);
    border-radius: var(--radius-sm);
    padding: 16px;
    background: var(--white);
}
.scenario-card h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 8px;
}
.scenario-card .num { font-size: 1.3rem; font-weight: 700; color: var(--navy); }
.scenario-card .sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* Amortization */
.amort-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.85rem;
}
.amort-table th {
    text-align: left;
    padding: 8px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--slate);
    border-bottom: 2px solid var(--pale);
}
.amort-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--pale);
    font-variant-numeric: tabular-nums;
}
.amort-table tr:hover td { background: rgba(0,0,0,0.015); }
.amort-scroll { max-height: 300px; overflow-y: auto; margin-top: 4px; }

/* Tabs */
.tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.tab-btn {
    padding: 10px 18px;
    border: 1.5px solid var(--pale);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
}
.tab-btn:hover { border-color: var(--gold); color: var(--navy); }
.tab-btn.active {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: var(--white);
    border-color: transparent;
}
.tab-section { display: none; }
.tab-section.active { display: block; }

/* FAQ */
.faq-list { margin-top: 6px; }
.faq-item {
    border: 1px solid var(--pale);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.faq-item:hover { border-color: #cbd5e0; }
.faq-item summary {
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--navy-light);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '';
    width: 8px; height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.2s;
}
.faq-item[open] summary::after { transform: rotate(-135deg); }
.faq-item .answer {
    padding: 0 16px 16px;
    font-size: 0.9rem;
    color: var(--slate);
    line-height: 1.7;
}
.faq-item .answer a { color: var(--navy-light); text-decoration: underline; }
.faq-item .answer a:hover { color: var(--gold); }

/* Footer */
.site-footer {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--pale);
    margin-top: 20px;
}
.site-footer a { color: var(--gold); text-decoration: none; font-weight: 500; }
.site-footer a:hover { text-decoration: underline; }
.site-footer p { margin-bottom: 6px; }
.disclaimer {
    max-width: 640px;
    margin: 0 auto;
    font-size: 0.75rem;
    color: #a0aec0;
    line-height: 1.6;
}
.footer-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    text-align: left;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--pale);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--navy);
    color: var(--white);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
    pointer-events: none;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Cookie banner */
.cookie-banner {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.97); border-top: 2px solid var(--gold);
    padding: 16px 20px; z-index: 9999; display: none;
    font-size: 13px; color: var(--navy);
    backdrop-filter: blur(10px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}
.cookie-banner.visible { display: block; }
.cookie-banner .inner { max-width: 960px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.cookie-banner .inner span { flex: 1; min-width: 200px; }
.cookie-banner .btn-row { display: flex; gap: 8px; flex-shrink: 0; }
.cookie-btn {
    padding: 8px 18px; border: 1px solid var(--gold); border-radius: var(--radius-sm); cursor: pointer;
    font-family: inherit; font-size: 12px; font-weight: 600; letter-spacing: 0.5px;
    transition: all 0.2s;
}
.cookie-btn.accept { background: linear-gradient(135deg, var(--navy), var(--navy-light)); color: #fff; border-color: transparent; }
.cookie-btn.accept:hover { opacity: 0.9; }
.cookie-btn.decline { background: transparent; color: var(--muted); border-color: var(--pale); }
.cookie-btn.decline:hover { color: var(--navy); }

/* Dark Mode */
body.dark-mode {
    --navy: #0a1628;
    --navy-light: #142035;
    --slate: #a0aec0;
    --muted: #718096;
    --pale: #2d3748;
    --surface: #1a202c;
    --white: #171923;
}
body.dark-mode .site-header { background: linear-gradient(180deg, #050e1a 0%, #0a1628 100%); }
body.dark-mode .card, body.dark-mode .calc-card { background: #171923; border-color: #2d3748; }
body.dark-mode .metric { background: #1a202c; }
body.dark-mode .chart-wrap, body.dark-mode .faq-item { background: #1a202c; }
body.dark-mode .field input, body.dark-mode .field select { background: #171923; color: #e2e8f0; border-color: #2d3748; }
body.dark-mode .field input:focus, body.dark-mode .field select:focus { box-shadow: 0 0 0 3px rgba(201,162,62,0.2); }
body.dark-mode .slider-row input[type="range"] { background: #2d3748; }
body.dark-mode .slider-row input[type="range"]::-webkit-slider-thumb { border-color: #171923; }
body.dark-mode .slider-row input[type="range"]::-moz-range-thumb { border-color: #171923; }
body.dark-mode .calc-btn { color: #ffffff; }
body.dark-mode .tab-btn { background: #1a202c; color: #718096; border-color: #2d3748; }
body.dark-mode .tab-btn.active { background: var(--gold); color: var(--navy); }
body.dark-mode .tab-btn:hover { border-color: var(--gold); color: #e2e8f0; }
body.dark-mode .cookie-banner { background: rgba(23,25,35,0.97); border-top-color: var(--gold); color: #a0aec0; }
body.dark-mode .cookie-btn.decline { color: #718096; border-color: #2d3748; }
body.dark-mode .site-header h1 { color: #e2e8f0; }
body.dark-mode .metric .value { color: #e2e8f0; }
body.dark-mode .metric .label { color: #a0aec0; }
body.dark-mode .scenario-card .num { color: #e2e8f0; }
body.dark-mode .scenario-card .sub { color: #a0aec0; }
body.dark-mode .scenario-card h4 { color: #a0aec0; }
body.dark-mode .comparison-table td { color: #a0aec0; }
body.dark-mode .comparison-table th { color: #718096; }
body.dark-mode .comparison-table .highlight.pos td { color: #68d391; }
body.dark-mode .comparison-table .highlight.neg td { color: #fc8181; }
body.dark-mode .comparison-table .diff td { color: #fc8181; background: rgba(197,48,48,0.15); }
body.dark-mode .insight { background: linear-gradient(135deg, #1a2338 0%, #171923 100%); color: #a0aec0; }
body.dark-mode .insight strong { color: var(--gold); }
body.dark-mode .field label { color: #a0aec0; }
body.dark-mode .card h2 { color: #a0aec0; }
body.dark-mode .chart-title { color: #a0aec0; }
body.dark-mode .slider-val { color: #a0aec0; }
body.dark-mode .tagline { color: rgba(255,255,255,0.6); }
body.dark-mode .calc-card h3 { color: #e2e8f0; }
body.dark-mode .calc-card p { color: #a0aec0; }
body.dark-mode .site-footer { color: #718096; }
body.dark-mode .disclaimer { color: #718096; }
body.dark-mode .faq-item summary { color: #e2e8f0; }
body.dark-mode .faq-item summary::after { border-color: #718096; }
body.dark-mode .faq-item .answer { color: #a0aec0; }
body.dark-mode .faq-item[open] summary { color: var(--gold); }
body.dark-mode .amort-table td { color: #a0aec0; }
body.dark-mode .amort-table th { color: #718096; }
body.dark-mode .amort-table tr:hover td { background: rgba(255,255,255,0.02); }

@media (max-width: 600px) {
    .cookie-banner .inner { flex-direction: column; text-align: center; }
}

/* Print */
@media print {
    .site-header { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .metric.primary { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .calc-btn, .action-bar, .tab-bar { display: none; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .tab-section { display: block !important; }
}
