/* Finance Calculator — single stylesheet, no external fonts (fast first paint). */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --ink: #14211f;
  --ink-2: #44514e;
  --muted: #6a7572;
  --line: #e2ddd2;
  --brand: #0b5d52;
  --brand-ink: #ffffff;
  --brand-soft: #dcefea;
  --accent: #e9a23b;
  --accent-ink: #2b1c03;
  --series-1: #0b5d52;
  --series-2: #e9a23b;
  --series-3: #6b8f88;
  --danger: #b4361f;
  --ok: #1f7a4d;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 33, 31, .05), 0 8px 24px rgba(20, 33, 31, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1615;
    --surface: #161f1e;
    --surface-2: #1d2827;
    --ink: #e8efed;
    --ink-2: #c1ccc9;
    --muted: #93a19d;
    --line: #2a3735;
    --brand: #4fb8a6;
    --brand-ink: #062521;
    --brand-soft: #173a35;
    --accent: #f0b456;
    --series-1: #4fb8a6;
    --series-2: #f0b456;
    --series-3: #7e9a95;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg { max-width: 100%; }
a { color: var(--brand); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 1.1rem + .6vw, 1.55rem); }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: 8px; top: -60px; background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 8px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.header-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand-mark { width: 30px; height: 30px; color: var(--brand); flex: none; }
.site-nav { margin-left: auto; display: flex; gap: 4px; }
.site-nav a { color: var(--ink-2); text-decoration: none; padding: 8px 11px; border-radius: 8px; font-size: .94rem; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 10px; width: 42px; height: 42px; color: var(--ink); cursor: pointer; }
.nav-toggle svg { width: 22px; height: 22px; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; place-items: center; }
  .site-nav { display: none; position: absolute; left: 0; right: 0; top: 60px; flex-direction: column; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; box-shadow: var(--shadow); }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; font-size: 1rem; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn svg { width: 18px; height: 18px; }

/* Page sections */
.page-head { padding: 28px 0 8px; }
.page-head p { color: var(--ink-2); max-width: 70ch; }
.section { padding: 18px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card, .calc-layout + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 1.15rem; }

/* Home */
.hero { padding: 40px 0 20px; }
.hero h1 { max-width: 20ch; }
.hero p { font-size: 1.1rem; color: var(--ink-2); max-width: 60ch; }
.calc-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.calc-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.calc-card:hover { transform: translateY(-2px); border-color: var(--brand); }
.calc-card .icon { width: 42px; height: 42px; border-radius: 11px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 6px; }
.calc-card .icon svg { width: 24px; height: 24px; }
.calc-card h2 { font-size: 1.1rem; margin: 0; }
.calc-card p { margin: 0; color: var(--ink-2); font-size: .95rem; }
.calc-card .go { margin-top: auto; padding-top: 10px; color: var(--brand); font-weight: 600; font-size: .92rem; }
.features { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.features h3 { margin-bottom: 4px; }
.features p { color: var(--ink-2); margin: 0; font-size: .95rem; }

/* Calculator layout */
.calc-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .calc-layout { grid-template-columns: 1fr; } }
.calc-inputs { display: grid; gap: 22px; }
.field { display: grid; gap: 8px; }
.field-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.field label { font-weight: 600; font-size: .96rem; }
.field-input { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 10px; min-width: 130px; max-width: 170px; }
.field-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-input span { color: var(--muted); font-size: .9rem; }
.field-input input { width: 100%; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--ink); text-align: right; padding: 8px 4px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.field-input input::-webkit-outer-spin-button, .field-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field-input input:focus { outline: none; }
.field-range { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.field-error { color: var(--danger); font-size: .85rem; min-height: 0; }
select.select { font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 10px; min-height: 42px; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.segmented button { font: inherit; font-size: .9rem; border: 0; background: transparent; color: var(--ink-2); padding: 7px 12px; border-radius: 8px; cursor: pointer; min-height: 36px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; --fill: 50%; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--brand) var(--fill), var(--line) var(--fill)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--brand); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); }

/* Results */
.result-hero { padding: 18px; border-radius: var(--radius-sm); background: var(--brand); color: var(--brand-ink); margin-bottom: 16px; }
.result-hero .label { font-size: .9rem; opacity: .9; }
.result-hero .value { font-size: clamp(1.8rem, 1.4rem + 2vw, 2.4rem); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.15; }
.result-hero .sub { font-size: .88rem; opacity: .85; margin-top: 2px; }
.result-body { display: grid; grid-template-columns: 170px 1fr; gap: 18px; align-items: center; }
@media (max-width: 420px) { .result-body { grid-template-columns: 1fr; justify-items: center; } }
.summary { list-style: none; margin: 0; padding: 0; width: 100%; }
.summary li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .95rem; }
.summary li:last-child { border-bottom: 0; }
.summary .k { color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.summary .v { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.swatch-1 { background: var(--series-1); } .swatch-2 { background: var(--series-2); } .swatch-3 { background: var(--series-3); }
.note { font-size: .86rem; color: var(--muted); margin: 12px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare > div { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.compare h3 { font-size: .95rem; margin-bottom: 6px; color: var(--ink-2); }
.compare .big { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.compare .worse { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
@media (max-width: 420px) { .compare { grid-template-columns: 1fr; } }

/* Charts */
.donut { width: 170px; height: 170px; }
.donut text { fill: var(--ink); font-family: var(--font); }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart .tick-label { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
.chart .bar-1 { fill: var(--series-1); } .chart .bar-2 { fill: var(--series-2); }
.chart .line-1 { stroke: var(--series-1); }
.chart rect:hover { opacity: .8; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .88rem; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 520px; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
table.data caption { text-align: left; padding: 10px 12px; color: var(--muted); font-size: .85rem; }
table.data th, table.data td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; color: var(--ink-2); z-index: 1; }
table.data tbody tr:hover { background: var(--surface-2); }

/* Prose / legal */
.prose { max-width: 75ch; }
.prose h2 { margin-top: 1.6em; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .35em; }
.formula { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; overflow-x: auto; font-size: .9rem; }
details.faq { border-bottom: 1px solid var(--line); padding: 12px 0; }
details.faq summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
details.faq p { margin: 8px 0 0; color: var(--ink-2); }
.placeholder-warning { border: 1px dashed var(--danger); color: var(--danger); padding: 8px 12px; border-radius: 8px; font-size: .9rem; }

/* Forms */
.form { display: grid; gap: 14px; max-width: 560px; }
.form label { font-weight: 600; display: block; margin-bottom: 6px; }
.form input, .form textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form .hp { position: absolute; left: -9999px; }
.form-status { padding: 10px 12px; border-radius: 8px; font-size: .95rem; }
.form-status.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.form-status.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }

/* Browser-run app */
.device-frame { width: 100%; max-width: 460px; margin: 0 auto; height: min(88vh, 900px); min-height: 560px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.device-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.app-run-layout { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 860px) { .app-run-layout { grid-template-columns: 1fr; } }
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; margin-bottom: 14px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: .9rem; }

/* App promo (bottom placement) */
.app-promo { background: var(--brand-soft); border-top: 1px solid var(--line); margin-top: 28px; }
.app-promo-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 14px; flex-wrap: wrap; }
.app-promo strong { display: block; }
.app-promo span { color: var(--ink-2); font-size: .92rem; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 30px 0 18px; font-size: .94rem; }
.app-promo:not([hidden]) + .site-footer { margin-top: 0; }
.footer-grid { display: grid; gap: 24px; grid-template-columns: 2fr 1fr 1fr; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }
.footer-heading { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.footer-links { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.footer-links a { color: var(--ink-2); text-decoration: none; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }
.brand-footer { margin-bottom: 8px; }
.footer-bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 22px; padding-top: 14px; color: var(--muted); font-size: .85rem; }

/* Inside the Android app the native banner sits at the bottom; keep clear of it. */
html.in-app .site-header { position: static; }
html.in-app .app-promo, html.in-app a[href="/app/"] { display: none !important; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .site-header, .site-footer, .app-promo, .actions, .calc-inputs input[type="range"] { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; }
}
