:root {
    --bg: #f7f7f5;
    --surface: #ffffff;
    --ink: #15171a;
    --ink-2: #5d636d;
    --ink-3: #8a909a;
    --rule: #e3e4e7;
    --rule-2: #d3d5da;
    --accent: #2445c9;
    --accent-soft: #edf0fc;
    --green: #17794c;
    --red: #c13a22;
    --amber: #9a6200;
    --radius: 8px;
    --c: var(--accent); --c-soft: var(--accent-soft); --c-line: #d5dcf7;
    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

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

/* One colour per step; components inside a step pick it up through --accent. */
[data-step="exit"]    { --c: #2445c9; --c-soft: #edf0fc; --c-line: #d5dcf7; }
[data-step="data"]    { --c: #6b3fc6; --c-soft: #f3eefc; --c-line: #e1d5f6; }
[data-step="run"]     { --c: #0d7660; --c-soft: #e7f4f0; --c-line: #c6e5dc; }
[data-step="payback"] { --c: #b9520d; --c-soft: #fcf0e6; --c-line: #f2d5bd; }
.sheet[data-step] { --accent: var(--c); --accent-soft: var(--c-soft); }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 2px; }

/* Top bar */
.masthead {
    position: sticky; top: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    height: 56px; padding: 0 clamp(16px, 4vw, 40px);
    background: rgba(247, 247, 245, 0.88);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand span { color: var(--accent); }
.stepper { display: flex; gap: 4px; }
.stepper a {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; text-decoration: none; color: var(--ink-2);
    padding: 6px 12px; border-radius: 999px; transition: background 0.15s, color 0.15s;
}
.stepper a i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.stepper a b { font-weight: 500; color: var(--ink-3); font-size: 0.8rem; }
.stepper a:hover { background: #ececea; color: var(--ink); }
.stepper a.active { background: var(--c-soft); color: var(--c); }
.stepper a.active b { color: var(--c); }

main { max-width: 1040px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); }

/* Hero */
.hero { padding: 72px 0 44px; }
.kicker { font-size: 0.875rem; color: var(--ink-2); margin-bottom: 16px; }
h1 {
    font-weight: 600; font-size: clamp(2.2rem, 5.2vw, 3.6rem);
    line-height: 1.08; letter-spacing: -0.025em; max-width: 18ch;
}
h1 em { font-style: normal; color: var(--accent); }
.lede { max-width: 60ch; font-size: 1.125rem; color: var(--ink-2); margin-top: 18px; }

.headline-card {
    margin-top: 40px;
    display: grid; grid-template-columns: repeat(3, 1fr);
    background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
}
.headline-card > div { padding: 22px 24px; border-right: 1px solid var(--rule); }
.headline-card > div:last-child { border-right: 0; }
.headline-card .lbl { font-size: 0.8rem; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.headline-card .lbl::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.headline-card .val {
    font-size: clamp(1.4rem, 2.8vw, 2.1rem); font-weight: 600; letter-spacing: -0.02em; white-space: nowrap;
    line-height: 1.2; margin: 6px 0 4px;
}
.headline-card > div:last-child .val { color: var(--c); }
.headline-card .sub { font-size: 0.85rem; color: var(--ink-2); }

/* Sections */
.sheet {
    background: var(--surface); border: 1px solid var(--rule); border-radius: 16px;
    margin: 0 0 32px; overflow: clip;
    box-shadow: 0 1px 2px rgba(20, 22, 26, 0.04);
}
.sheet-head {
    position: relative;
    display: grid; grid-template-columns: 48px 1fr auto; gap: 18px; align-items: center;
    padding: 24px 28px 22px;
    background: linear-gradient(180deg, var(--c-soft), var(--surface));
    border-bottom: 1px solid var(--c-line);
}
.sheet-head::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.sheet-icon {
    width: 48px; height: 48px; border-radius: 12px; background: var(--c);
    display: grid; place-items: center;
}
.sheet-icon svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet-num { display: block; font-size: 0.78rem; font-weight: 600; color: var(--c); margin-bottom: 2px; }
.sheet-title h2 { margin: 0; }
.sheet-sum { text-align: right; line-height: 1.25; }
.sheet-sum strong { display: block; font-size: 1.45rem; font-weight: 600; color: var(--c); letter-spacing: -0.02em; white-space: nowrap; }
.sheet-sum strong small { font-size: 0.85rem; font-weight: 500; }
.sheet-sum span { font-size: 0.8rem; color: var(--ink-2); }
.sheet-body { padding: 26px 28px 30px; }
.sheet-body > .note:first-child { margin-top: 0; margin-bottom: 18px; }
h2 {
    font-weight: 600; font-size: 1.5rem; line-height: 1.25; letter-spacing: -0.015em; margin-bottom: 20px;
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px;
}
h2 small { font-size: 0.95rem; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }
h3 {
    display: flex; align-items: baseline; gap: 8px;
    font-size: 0.95rem; font-weight: 600;
    margin: 32px 0 12px; padding-top: 22px; border-top: 1px solid var(--rule);
}
h3::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--c); align-self: center; flex: none; }
.sheet-body > h3:first-child, .note + h3 { margin-top: 8px; }
.unit { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-3); font-weight: 400; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 20px; align-items: end; }
.grid + .grid { margin-top: 16px; }
.grid.four { grid-template-columns: repeat(4, 1fr); }

label {
    display: grid; grid-template-columns: auto 1fr; column-gap: 6px; row-gap: 6px; align-items: baseline;
    font-size: 0.875rem; font-weight: 500; color: var(--ink);
}
label > input[type="number"], label > select { grid-column: 1 / -1; }
.toggle, .fx { display: flex; }

input[type="number"], select {
    font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
    background: var(--surface); border: 1px solid var(--rule-2); border-radius: 6px;
    padding: 9px 11px; width: 100%; outline: none; height: 40px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
select {
    appearance: none; padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235d636d' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
input[type="number"]:hover, select:hover { border-color: var(--ink-3); }
input[type="number"]:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input::placeholder { color: var(--ink-3); }

.toggle { flex-direction: row; align-items: center; gap: 10px; margin-top: 18px; cursor: pointer; font-weight: 400; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

.fx { flex-direction: row; align-items: center; gap: 8px; margin-top: 14px; font-size: 0.85rem; font-weight: 400; color: var(--ink-2); }
.fx input { width: 90px; height: 32px; padding: 4px 8px; }

.note { color: var(--ink-2); font-size: 0.875rem; margin-top: 8px; max-width: 72ch; }

/* Result panels */
.ledger { margin-top: 24px; background: #fcfcfb; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.ledger .row {
    display: flex; justify-content: space-between; gap: 16px;
    padding: 11px 16px; border-bottom: 1px solid var(--rule); font-size: 0.925rem;
}
.ledger .row:last-child { border-bottom: 0; }
.ledger .row > span:last-child { white-space: nowrap; font-weight: 500; }
.ledger .row.total { background: var(--c); color: #fff; font-weight: 600; }
.ledger .row .strike { text-decoration: line-through; color: var(--ink-3); margin-right: 8px; font-weight: 400; }
.ledger .row.muted { color: var(--ink-3); }
.ledger .row.muted > span:last-child { text-decoration: line-through; }
.ledger .row.muted-note { color: var(--red); font-size: 0.85rem; background: #fdf3f1; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span {
    display: inline-block; padding: 6px 12px; border: 1px solid var(--rule-2); border-radius: 999px;
    font-size: 0.85rem; cursor: pointer; background: var(--surface); color: var(--ink);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip span:hover { border-color: var(--ink-3); }
.chip input:checked + span { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* Tables */
.compare { margin-top: 28px; overflow-x: auto; }
table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
    font-size: 0.875rem; overflow: hidden;
}
th, td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; }
thead th {
    font-size: 0.78rem; font-weight: 500; color: var(--ink-2); background: #fafafa;
    vertical-align: bottom;
}
thead th a { color: var(--ink); font-weight: 600; text-decoration: none; }
thead th a:hover { color: var(--accent); }
td:first-child { color: var(--ink); }
tr.total td { background: color-mix(in srgb, var(--c) 82%, black); color: #fff; font-weight: 600; border-bottom: 0; }
tr.saving td { font-weight: 600; }
td.best, th.best { background: var(--accent-soft); }
tr.total td.best { background: var(--c); color: #fff; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 60%, white); }
.pos { color: var(--green); }
.neg { color: var(--red); }
td .flag { font-size: 0.68rem; color: var(--amber); vertical-align: super; margin-left: 2px; cursor: help; }

.pick { display: block; width: max-content; margin: 6px 0 0 auto; padding: 2px 8px; border-radius: 999px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: #fff; background: var(--c); }
.pick.alt { color: var(--c); background: var(--surface); box-shadow: inset 0 0 0 1px var(--c-line); }
.tag {
    display: inline-block; font-size: 0.7rem; font-weight: 500;
    padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
}
.tag.warn { color: var(--amber); background: #fbf2e1; }
.tag.ok { color: var(--green); background: #e8f4ed; }

.footnotes { margin-top: 10px; font-size: 0.8rem; color: var(--ink-2); list-style: none; }
.footnotes li { margin-top: 4px; }

/* Service mapping */
.gaps { margin-top: 20px; overflow-x: auto; }
.sheet-body { min-width: 0; }
.gaps table td { white-space: normal; text-align: left; font-size: 0.85rem; }
.gaps table th { text-align: left; }
.gaps tr.total td { font-size: 0.8rem; }
.s-native { color: var(--green); }
.s-partial { color: var(--amber); }
.s-none { color: var(--red); }

/* Payback */
.payback-hero {
    margin-top: 28px; display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center;
    background: var(--accent-soft); border: 1px solid var(--c-line); border-radius: 12px; padding: 24px 28px;
}
.payback-hero .big { font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1; color: var(--accent); }
.payback-hero p { font-size: 1rem; max-width: 56ch; }
.payback-hero.never { background: #fdf3f1; border-color: #f3d6cf; }
.payback-hero.never .big { color: var(--red); }

/* Route choice */
.route { max-width: 260px; }
#routes { margin-top: 14px; }
#routes td .strike { text-decoration: line-through; color: var(--ink-3); }

/* Timeline */
.timeline { margin-top: 32px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px 18px 8px; }
.timeline h3 { margin: 16px 0 4px; padding-top: 0; border-top: 0; }
.tl-row {
    display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 90px; gap: 16px; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 0.875rem;
}
.tl-row > span:last-child { text-align: right; white-space: nowrap; font-weight: 500; }
.tl-track { height: 8px; background: #f0f1f3; border-radius: 999px; overflow: hidden; }
.tl-bar { height: 100%; min-width: 4px; border-radius: 999px; }
.tl-bar.build { background: var(--accent); }
.tl-bar.data { background: #6b3fc6; }
.tl-bar.run { background: color-mix(in srgb, var(--c) 45%, white); }
.tl-row.total { border-bottom: 0; font-weight: 600; }

/* Share */
.cta {
    display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center;
    background: var(--surface); border: 1px solid var(--rule); border-radius: 12px;
    padding: 32px; margin: 8px 0 48px;
}
.cta h2 { margin-bottom: 8px; }
.cta p { color: var(--ink-2); }
.cta-actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
    display: block; text-align: center; padding: 10px 16px; border-radius: 6px;
    font-family: var(--sans); font-size: 0.925rem; font-weight: 500;
    border: 1px solid var(--rule-2); color: var(--ink); background: var(--surface); text-decoration: none; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f3f3f1; border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, black); }

.fineprint { border-top: 1px solid var(--rule); padding: 40px 0 48px; }
.fineprint h2 { font-size: 1.15rem; }
.fineprint ul { padding-left: 18px; color: var(--ink-2); font-size: 0.85rem; max-width: 80ch; }
.fineprint li { margin-top: 6px; }

.footer { text-align: center; padding: 24px; border-top: 1px solid var(--rule); font-size: 0.85rem; color: var(--ink-3); }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
    html { scroll-behavior: auto; }
}

@media (max-width: 760px) {
    .brand { display: none; }
    .masthead { justify-content: center; padding: 0 8px; }
    .stepper a { padding: 6px 8px; gap: 6px; font-size: 0.8rem; }
    .stepper a b { display: none; }
    .hero { padding: 48px 0 32px; }
    .sheet { border-radius: 12px; margin-bottom: 20px; }
    .sheet-head { grid-template-columns: 40px 1fr; gap: 12px 14px; padding: 20px 18px 18px; }
    .sheet-icon { width: 40px; height: 40px; border-radius: 10px; }
    .sheet-sum { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
    .sheet-body { padding: 20px 18px 24px; }
    h2 { font-size: 1.3rem; }
    .grid, .grid.four { grid-template-columns: 1fr 1fr; }
    .headline-card { grid-template-columns: 1fr; }
    .headline-card > div { border-right: 0; border-bottom: 1px solid var(--rule); }
    .headline-card > div:last-child { border-bottom: 0; }
    .cta { grid-template-columns: 1fr; padding: 24px; }
    .payback-hero { grid-template-columns: 1fr; gap: 12px; }
    .tl-row { grid-template-columns: 1fr 80px; }
    .tl-track { grid-column: 1 / -1; grid-row: 2; }
}

@media print {
    body { background: #fff; }
    .masthead, .cta, .chips, .toggle, .fx { display: none !important; }
    input, select { border: 0; padding: 0; background: none; height: auto; }
}

/* ---------- Payback chart ---------- */
.chart { margin-top: 8px; }
.chart h3 { border-top: 0; padding-top: 0; margin-top: 24px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; padding: 0; font-size: 0.82rem; color: var(--ink-2); }
.legend i, .tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-plot { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .zero { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .ax { font: 11px var(--mono); fill: var(--ink-3); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.best { stroke-width: 3; }
.chart .end { font: 500 12px var(--sans); fill: var(--ink); }
.chart .end tspan { fill: var(--ink-2); font-family: var(--mono); font-weight: 400; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; top: 8px; min-width: 190px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--rule-2); border-radius: 10px; box-shadow: 0 6px 20px rgba(20, 23, 26, 0.08); font-size: 0.82rem; pointer-events: none; }
.tip strong { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 0; color: var(--ink-2); }
.tip span { margin-left: auto; padding-left: 14px; font-family: var(--mono); color: var(--ink); }
@media print { .tip, .chart .cross, .chart .dot { display: none; } }
