:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e2e8f0;
    --text: #172033;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1e3a8a;
    --accent: #0f766e;
    --danger: #b91c1c;
    --warning-bg: #fff7ed;
    --warning-border: #fed7aa;
    --radius: 8px;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-light: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.55;
}

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

.page-header {
    background: #0f172a;
    color: #f8fafc;
}

.topbar {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 18px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.home-button,
.disclaimer-link,
.preset-actions button {
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.home-button,
.disclaimer-link {
    color: #fff;
    padding: 9px 14px;
    background: rgba(255, 255, 255, 0.12);
}

.home-button:hover,
.disclaimer-link:hover,
.preset-actions button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.hero {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 54px 0 64px;
}

.eyebrow {
    margin: 0 0 10px;
    color: #93c5fd;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    max-width: 900px;
    margin-bottom: 16px;
    font-size: clamp(2rem, 5vw, 4.1rem);
    line-height: 1.05;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 12px;
    font-size: 1.08rem;
    line-height: 1.25;
}

.lead {
    max-width: 820px;
    margin-bottom: 0;
    color: #cbd5e1;
    font-size: 1.08rem;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: -32px auto 0;
    padding-bottom: 36px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-light);
}

.intro-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: center;
    padding: 24px;
}

.intro-card p,
.section-heading p,
.ter-card p,
.explanation p,
.footer-note {
    color: var(--muted);
}

.formula-box {
    padding: 18px;
    border-radius: var(--radius);
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.formula-box span,
.metric span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.formula-box strong {
    display: block;
    color: var(--primary-dark);
    font-size: 1.1rem;
}

.workspace {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-top: 18px;
}

.controls {
    padding: 20px;
    position: sticky;
    top: 16px;
}

.section-heading p {
    margin-bottom: 16px;
    font-size: 0.92rem;
}

.preset-actions {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
}

.preset-actions button {
    width: 100%;
    padding: 10px 12px;
    color: #fff;
    background: var(--primary);
    font-size: 0.92rem;
}

.preset-actions button:nth-child(2) {
    background: var(--accent);
}

.control-group {
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 800;
}

.dual-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 10px;
    align-items: center;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

input[type="number"] {
    width: 100%;
    padding: 9px 10px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font: inherit;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.warning {
    display: none;
    margin: 14px 0 0;
    padding: 12px;
    color: #9a3412;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.warning.visible {
    display: block;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.metric {
    padding: 18px;
}

.metric strong {
    display: block;
    color: var(--text);
    font-size: clamp(1.25rem, 2vw, 1.7rem);
    line-height: 1.15;
}

.metric.emphasis {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.metric.emphasis strong {
    color: var(--primary-dark);
}

.ter-card {
    margin-top: 12px;
    padding: 20px;
    border-left: 4px solid var(--primary);
}

.ter-card p {
    margin-bottom: 0;
}

.final-tax-card {
    margin-top: 12px;
    padding: 20px;
}

.final-tax-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.final-tax-grid div {
    padding: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.final-tax-grid span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.final-tax-grid strong {
    display: block;
    color: var(--text);
    font-size: 1.16rem;
    line-height: 1.2;
}

.final-tax-note {
    margin: 14px 0 0;
    color: var(--muted);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.chart-card {
    padding: 18px;
    min-width: 0;
}

.chart-card.wide {
    grid-column: 1 / -1;
}

.chart-wrap {
    position: relative;
    height: 360px;
}

.chart-card.wide .chart-wrap {
    height: 390px;
}

.explanation {
    margin-top: 18px;
    padding: 24px;
}

.key-message {
    margin-bottom: 0;
    padding: 16px;
    color: var(--primary-dark) !important;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    font-weight: 800;
}

.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto 32px;
}

.site-footer .container,
.site-footer .disclaimer {
    max-width: none;
    margin: 0;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-light);
}

.footer-note {
    margin: 14px 0 0;
    font-size: 0.92rem;
    text-align: center;
}

@media (max-width: 920px) {
    .intro-card,
    .workspace,
    .charts-grid {
        grid-template-columns: 1fr;
    }

    .controls {
        position: static;
    }
}

@media (max-width: 620px) {
    .topbar {
        align-items: stretch;
    }

    .home-button,
    .disclaimer-link {
        text-align: center;
        flex: 1;
    }

    .hero {
        padding: 38px 0 52px;
    }

    .page-shell {
        width: min(100% - 20px, 1180px);
    }

    .intro-card,
    .controls,
    .ter-card,
    .chart-card,
    .explanation {
        padding: 16px;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .final-tax-grid {
        grid-template-columns: 1fr;
    }

    .dual-input {
        grid-template-columns: 1fr;
    }

    input[type="number"] {
        font-size: 16px;
    }

    .chart-wrap,
    .chart-card.wide .chart-wrap {
        height: 320px;
    }
}
