/* MoneyMzansi: one stylesheet for the whole site.
   Light tokens follow BRIEF.md section 3 exactly. Dark mode (approved by the owner) redefines
   the same tokens under [data-theme="dark"], so components only ever use var(--c-*). */

/* ============ Fonts (self-hosted Inter, Latin subset, SIL OFL: /fonts/OFL.txt) ============ */
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/inter-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/inter-latin-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/inter-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Arial tuned to Inter's metrics, so text doesn't jump when Inter arrives (keeps layout shift low). */
@font-face {
  font-family: 'Inter Fallback'; src: local('Arial'), local('Helvetica Neue'), local('Helvetica');
  size-adjust: 107.4%; ascent-override: 90.2%; descent-override: 22.5%; line-gap-override: 0%;
}

/* ============ Tokens ============ */
:root {
  /* Brief section 3 */
  --c-primary: #0B6E4F;
  --c-primary-dark: #08553D;
  --c-primary-soft: #E6F2ED;
  --c-accent: #F2A900;
  --c-text: #1F2933;
  --c-muted: #5F6B76;
  --c-border: #E3E8EC;
  --c-surface: #F7F9FA;
  --c-bg: #FFFFFF;
  --c-danger: #B42318;
  --c-warn-soft: #FFF6E0;
  --c-chart-3: #5B6B7A;
  --c-chart-4: #2F6EB5; /* added with owner approval: 4th chart series */

  /* Derived tokens, so dark mode can retune each role separately */
  --c-primary-ink: #0B6E4F;        /* green text and icons */
  --c-primary-line: #0B6E4F;       /* green borders on selected controls */
  --c-on-primary: #FFFFFF;         /* text on a solid green fill */
  --c-elevated: #FFFFFF;           /* cards and panels */
  --c-input: #FFFFFF;
  --c-border-strong: #C9D1D8;
  --c-input-line: #8A96A1;         /* 3:1 against the input background (WCAG 1.4.11) */
  --c-hover: #F1F4F6;
  --c-result: #E6F2ED;
  --c-result-line: rgba(11, 110, 79, .14);
  --c-danger-soft: #FEF3F2;
  --c-warn-line: #F3D48A;
  --c-warn-ink: #8A5A00;
  --c-focus: #0B6E4F;
  --c-series-0: var(--c-primary);
  --c-series-1: var(--c-accent);
  --c-series-2: var(--c-chart-3);
  --c-series-3: var(--c-chart-4);
  --c-header: rgba(255, 255, 255, .92);

  --font: 'Inter', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --fs-12: 0.75rem;
  --fs-14: 0.875rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-20: 1.25rem;
  --fs-24: 1.5rem;
  --fs-32: 2rem;
  --fs-40: 2.5rem;

  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  --r-card: 12px;
  --r-ctl: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .06);
  --tap: 44px;
  --max: 1080px;
  --gutter: 16px;
  --header-h: 64px;

  color-scheme: light;
}

/* Dark: deep neutral surfaces, brand green lifted for contrast, gold kept as the one accent.
   Contrast (WCAG AA) checked for text, muted text, links, buttons and borders on every surface. */
:root[data-theme="dark"] {
  --c-primary: #14875F;            /* fills: white text on it is 4.6:1 */
  --c-primary-dark: #0F7352;
  --c-primary-soft: #11261E;
  --c-accent: #F2B533;
  --c-text: #E7ECF0;
  --c-muted: #9DA9B4;
  --c-border: #252E37;
  --c-surface: #12181E;
  --c-bg: #0D1115;
  --c-danger: #FF8A7F;
  --c-warn-soft: #272012;
  --c-chart-3: #8D9CAA;
  --c-chart-4: #66A3E9;

  --c-primary-ink: #5CCB9F;
  --c-primary-line: #3AA87D;
  --c-on-primary: #FFFFFF;
  --c-elevated: #151C23;
  --c-input: #0F1419;
  --c-border-strong: #3A4652;
  --c-input-line: #5D6A76;
  --c-hover: #1B232B;
  --c-result: #10241C;
  --c-result-line: rgba(92, 203, 159, .16);
  --c-danger-soft: #2A1513;
  --c-warn-line: #5E4818;
  --c-warn-ink: #F2B533;
  --c-focus: #5CCB9F;
  --c-series-0: #3DBE8B;
  --c-header: rgba(13, 17, 21, .9);

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .02);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);

  color-scheme: dark;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + var(--s-4));
}
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: var(--fs-16);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--s-3); font-weight: 700; color: var(--c-text); text-wrap: balance; }
h1 { font-size: var(--fs-32); letter-spacing: -0.025em; }
h2 { font-size: var(--fs-24); letter-spacing: -0.015em; }
h3 { font-size: var(--fs-18); font-weight: 600; letter-spacing: -0.005em; }
p { margin: 0 0 var(--s-4); }
p, li { text-wrap: pretty; }
a { color: var(--c-primary-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--c-primary-dark); text-decoration-thickness: 2px; }
:root[data-theme="dark"] a:hover { color: var(--c-text); }
strong { font-weight: 600; }
img, svg { max-width: 100%; }
ul, ol { padding-left: 1.25em; }
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table, input, output, dd, data, .num, .result-headline, .sticky-value, .chart-legend, .chart-tip { font-variant-numeric: tabular-nums; }
::selection { background: var(--c-primary-soft); color: var(--c-text); }

:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

@media (min-width: 768px) {
  h1 { font-size: var(--fs-40); }
}

/* ============ Layout ============ */
.container { max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 768px) { :root { --gutter: 24px; } }
main { display: block; padding-bottom: var(--s-8); }

/* ============ Header ============ */
.skip-link {
  position: absolute; left: var(--s-2); top: -100px; z-index: 100;
  background: var(--c-primary); color: var(--c-on-primary); padding: var(--s-2) var(--s-4); border-radius: var(--r-ctl); font-weight: 600;
}
.skip-link:focus { top: var(--s-2); color: var(--c-on-primary); }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--c-header); border-bottom: 1px solid var(--c-border);
  -webkit-backdrop-filter: saturate(160%) blur(10px); backdrop-filter: saturate(160%) blur(10px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: var(--header-h); gap: var(--s-4); }
.wordmark {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap);
  font-size: var(--fs-20); font-weight: 700; text-decoration: none; letter-spacing: -0.02em; color: var(--c-text);
}
.wordmark:hover { color: var(--c-text); }
.logo-mark { width: 30px; height: 30px; flex: none; }
.logo-mark-bg { fill: var(--c-primary); }
.wm-mzansi { color: var(--c-text); }
.wm-money { color: var(--c-primary-ink); }

.site-nav { display: flex; align-items: center; gap: var(--s-1); }
.nav-menu { position: relative; }
.nav-toggle {
  list-style: none; display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: var(--tap); min-width: var(--tap); padding: 0 var(--s-3);
  border-radius: var(--r-ctl); font-weight: 600; font-size: var(--fs-16); cursor: pointer; user-select: none; color: var(--c-text);
}
.nav-toggle::-webkit-details-marker { display: none; }
.nav-toggle::marker { content: ''; }
.nav-toggle:hover, .nav-menu[open] .nav-toggle { background: var(--c-hover); }
.nav-toggle-label::after {
  content: ''; display: inline-block; width: 6px; height: 6px; margin-left: var(--s-2);
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-3px) rotate(45deg); transition: transform .15s;
}
.nav-menu[open] .nav-toggle-label::after { transform: translateY(0) rotate(-135deg); }
.nav-burger { display: none; width: 24px; height: 24px; }
.nav-link, .nav-about {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s-3);
  border-radius: var(--r-ctl); color: var(--c-text); font-weight: 600; text-decoration: none;
}
.nav-link:hover, .nav-about:hover { background: var(--c-hover); color: var(--c-text); }
.nav-about { display: none; }

.nav-panel {
  position: absolute; right: 0; top: calc(100% + var(--s-2)); width: min(680px, 92vw);
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-5) var(--s-6);
  padding: var(--s-5) var(--s-6); background: var(--c-elevated); border: 1px solid var(--c-border);
  border-radius: var(--r-card); box-shadow: var(--shadow-lg);
}
.nav-group-title { font-size: var(--fs-12); font-weight: 600; color: var(--c-muted); margin: 0 0 var(--s-1); text-transform: uppercase; letter-spacing: .08em; }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group a {
  display: flex; align-items: center; min-height: 40px; padding: var(--s-1) var(--s-2); margin: 0 calc(-1 * var(--s-2));
  border-radius: var(--r-ctl); color: var(--c-text); text-decoration: none; font-size: var(--fs-16); line-height: 1.35;
}
.nav-group a:hover { background: var(--c-hover); color: var(--c-primary-ink); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--tap); height: var(--tap); padding: 0; border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--c-muted); transition: background-color .15s, color .15s;
}
.theme-toggle:hover { background: var(--c-hover); color: var(--c-text); }
.theme-icon { width: 20px; height: 20px; }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }

@media (max-width: 767.98px) {
  .nav-menu { position: static; }
  .nav-toggle-label, .nav-link { display: none; }
  .nav-burger { display: block; }
  .nav-toggle { padding: 0; justify-content: center; }
  .nav-panel {
    position: fixed; left: 0; right: 0; top: var(--header-h); width: auto; grid-template-columns: 1fr; gap: var(--s-5);
    border-radius: 0; border-width: 0 0 1px; padding: var(--s-5) var(--gutter) var(--s-6);
    max-height: calc(100dvh - var(--header-h)); overflow-y: auto; box-shadow: var(--shadow-lg);
  }
  .nav-group a { min-height: var(--tap); }
  .nav-about { display: flex; border-top: 1px solid var(--c-border); border-radius: 0; padding: var(--s-4) 0 0; margin-top: 0; }
  .site-nav { gap: 0; }
}

/* ============ Footer ============ */
.site-footer { background: var(--c-surface); border-top: 1px solid var(--c-border); padding: var(--s-7) 0 var(--s-6); font-size: var(--fs-14); color: var(--c-muted); }
.footer-top { display: grid; grid-template-columns: 1fr; gap: var(--s-6); padding-bottom: var(--s-6); }
.footer-brand .wordmark { font-size: var(--fs-18); }
.footer-tagline { max-width: 40ch; margin: var(--s-3) 0 0; line-height: 1.55; }
.footer-cols { display: grid; grid-template-columns: 1fr; gap: var(--s-5); }
.footer-col h2 { font-size: var(--fs-12); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--c-muted); margin-bottom: var(--s-2); }
.footer-col ul, .footer-links { list-style: none; margin: 0; padding: 0; }
.footer-col a, .footer-links a { display: inline-flex; align-items: center; min-height: 36px; color: var(--c-text); text-decoration: none; line-height: 1.35; }
.footer-col a:hover, .footer-links a:hover { color: var(--c-primary-ink); text-decoration: underline; }
.footer-bottom { padding-top: var(--s-5); border-top: 1px solid var(--c-border); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 var(--s-5); margin-bottom: var(--s-3); }
.footer-links a { min-height: var(--tap); font-weight: 600; }
.footer-meta { margin: 0 0 var(--s-1); }
@media (max-width: 767.98px) { .footer-col a { min-height: var(--tap); } }
@media (min-width: 560px) { .footer-cols { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) {
  .footer-top { grid-template-columns: minmax(240px, 1fr) 2.6fr; gap: var(--s-7); }
  .footer-cols { grid-template-columns: repeat(4, 1fr); }
}

/* ============ Components: buttons, chips, icons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-4); border: 1px solid var(--c-primary); border-radius: var(--r-ctl);
  background: var(--c-primary); color: var(--c-on-primary); font-weight: 600; font-size: var(--fs-16); line-height: 1.2;
  text-decoration: none; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color: var(--c-on-primary); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: var(--c-elevated); color: var(--c-primary-ink); border-color: var(--c-border-strong); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--c-primary-soft); border-color: var(--c-primary-line); color: var(--c-primary-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-muted); }
.btn-ghost:hover { background: var(--c-hover); border-color: transparent; color: var(--c-text); }
.btn .icon { width: 18px; height: 18px; }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s-3);
  border: 1px solid var(--c-border-strong); border-radius: 999px; background: var(--c-elevated); color: var(--c-text);
  font-size: var(--fs-14); font-weight: 600; font-variant-numeric: tabular-nums; transition: background-color .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--c-primary-line); color: var(--c-primary-ink); }
.chip[aria-pressed="true"] { background: var(--c-primary-soft); border-color: var(--c-primary-line); color: var(--c-primary-ink); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ============ Calculator page ============ */
.breadcrumbs { font-size: var(--fs-14); color: var(--c-muted); padding: var(--s-2) 0 0; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
.breadcrumbs li { display: inline-flex; align-items: center; }
.breadcrumbs li + li::before { content: '/'; margin: 0 var(--s-2); color: var(--c-border-strong); }
.breadcrumbs a { color: var(--c-muted); display: inline-flex; align-items: center; min-height: var(--tap); text-decoration: none; }
.breadcrumbs a:hover { color: var(--c-primary-ink); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--c-text); font-weight: 600; }

.page-intro { padding: var(--s-3) 0 var(--s-5); }
.page-intro h1 { margin-bottom: var(--s-3); }
.lead { font-size: var(--fs-18); color: var(--c-muted); max-width: 64ch; margin: 0; line-height: 1.55; }

.calc-card {
  display: grid; grid-template-columns: 1fr; gap: var(--s-5);
  background: var(--c-elevated); border: 1px solid var(--c-border); border-radius: var(--r-card);
  box-shadow: var(--shadow-md); padding: var(--s-4);
}
@media (min-width: 480px) { .calc-card { padding: var(--s-5); } }
@media (min-width: 900px) {
  .calc-card { grid-template-columns: 380px 1fr; gap: var(--s-6); padding: var(--s-6); align-items: start; }
}

.calc-inputs { display: flex; flex-direction: column; gap: var(--s-5); min-width: 0; }
.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.field.is-disabled .field-label { color: var(--c-muted); }
.field-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-2); }
.field-head .field-label { margin-bottom: 0; }
.field-label { display: block; font-weight: 600; font-size: var(--fs-16); margin-bottom: var(--s-2); padding: 0; color: var(--c-text); }
.hint { font-size: var(--fs-14); color: var(--c-muted); margin: var(--s-2) 0 0; line-height: 1.45; }
.field-error { display: flex; align-items: flex-start; gap: var(--s-2); margin: var(--s-2) 0 0; font-size: var(--fs-14); font-weight: 600; color: var(--c-danger); line-height: 1.45; }
.field-error[hidden] { display: none; }
.field-error .icon { margin-top: 1px; }
.field-pair { display: grid; grid-template-columns: 1fr; gap: var(--s-5); }
@media (min-width: 480px) { .field-pair { grid-template-columns: 1fr 1fr; gap: var(--s-4); } }
.mode-note { font-size: var(--fs-14); color: var(--c-muted); margin: 0; padding: var(--s-2) var(--s-3); background: var(--c-surface); border-radius: var(--r-ctl); line-height: 1.45; }

.input {
  width: 100%; min-height: 48px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--c-input-line); border-radius: var(--r-ctl); background: var(--c-input); color: var(--c-text);
  font-size: var(--fs-18); font-weight: 500; line-height: 1.3; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--c-muted); opacity: 1; font-weight: 400; }
.input:hover { border-color: var(--c-text); }
.input:focus-visible, .input:focus { outline: 2px solid var(--c-focus); outline-offset: 2px; border-color: var(--c-primary-line); }
.input[aria-invalid="true"] { border-color: var(--c-danger); background: var(--c-danger-soft); }
.input:disabled { background: var(--c-surface); color: var(--c-muted); border-color: var(--c-border); cursor: not-allowed; }
.input[readonly] { background: var(--c-surface); }
input[type="search"].input::-webkit-search-cancel-button { cursor: pointer; }

.input-affix { position: relative; display: flex; align-items: center; }
.affix { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; color: var(--c-muted); font-size: var(--fs-18); font-weight: 500; pointer-events: none; }
.affix-prefix { left: var(--s-3); }
.affix-suffix { right: var(--s-3); }
.input-affix:has(.affix-prefix) .input { padding-left: calc(var(--s-3) + 1.25em); }
.input-affix:has(.affix-suffix) .input { padding-right: calc(var(--s-3) + 1.5em); }

/* Range slider kept in sync with a text field (inputs.js data-sync). */
.range {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: var(--tap); margin: var(--s-1) 0 0;
  background: transparent; cursor: pointer; touch-action: pan-y;
}
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--c-border); }
.range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--c-border); }
.range::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--c-primary); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: var(--c-elevated); border: 2px solid var(--c-primary-line); box-shadow: var(--shadow-md);
}
.range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--c-elevated); border: 2px solid var(--c-primary-line); box-shadow: var(--shadow-md);
}
.range:focus { outline: none; }
.range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.range:focus-visible::-moz-range-thumb { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.range:disabled { opacity: .5; cursor: not-allowed; }

/* Segmented toggle: visually hidden radios + labels */
.segmented { display: inline-flex; flex-wrap: wrap; margin: 0; padding: 3px; border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-surface); gap: 2px; min-width: 0; }
.segmented-field .segmented { display: flex; }
.segmented-field .segmented label { flex: 1 1 0; }
.segmented input {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.segmented label {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: calc(var(--tap) - 6px); padding: 0 var(--s-3); border: 1px solid transparent; border-radius: 7px;
  font-weight: 600; font-size: var(--fs-16); color: var(--c-muted); cursor: pointer; transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented label:hover { color: var(--c-text); }
.segmented input:checked + label { background: var(--c-elevated); color: var(--c-primary-ink); border-color: var(--c-primary-line); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.segmented input:disabled + label { opacity: .5; cursor: not-allowed; }
.segmented--sm { padding: 2px; }
/* 40px label + 2px padding + 1px border keeps the tap target at 44px or more. */
.segmented--sm label { font-size: var(--fs-14); min-height: 40px; padding: 0 var(--s-3); }

.stepper { display: flex; align-items: stretch; gap: var(--s-2); max-width: 220px; }
.stepper .input { text-align: center; flex: 1 1 auto; min-width: 0; }
.stepper-btn {
  flex: none; width: 48px; min-height: 48px; border: 1px solid var(--c-input-line); border-radius: var(--r-ctl);
  background: var(--c-elevated); color: var(--c-primary-ink); font-size: var(--fs-20); font-weight: 600; line-height: 1;
  transition: background-color .15s, border-color .15s;
}
.stepper-btn:hover { background: var(--c-primary-soft); border-color: var(--c-primary-line); }
.stepper-btn:disabled { color: var(--c-muted); background: var(--c-surface); border-color: var(--c-border); cursor: not-allowed; }

/* ============ Results ============ */
.calc-results { min-width: 0; }
.result-card { background: var(--c-result); border: 1px solid var(--c-result-line); border-radius: var(--r-card); padding: var(--s-5); }
@media (min-width: 900px) { .result-card { padding: var(--s-6); } }
.result-label { font-size: var(--fs-14); font-weight: 600; color: var(--c-muted); margin: 0 0 var(--s-2); letter-spacing: .01em; }
.result-headline {
  display: inline-block; margin: 0 0 var(--s-5); font-size: var(--fs-32); font-weight: 700; line-height: 1.1;
  color: var(--c-text); letter-spacing: -0.025em; padding-bottom: 6px; border-bottom: 4px solid var(--c-accent);
  overflow-wrap: anywhere;
}
@media (min-width: 900px) { .result-headline { font-size: var(--fs-40); } }
.result-list { margin: 0 0 var(--s-4); }
.result-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); padding: 10px 0; border-bottom: 1px solid var(--c-result-line); }
.result-row:last-child { border-bottom: 0; }
.result-row dt { color: var(--c-text); flex: 1 1 0; min-width: 0; }
.result-row dd { margin: 0; font-weight: 600; text-align: right; color: var(--c-text); flex: 0 1 auto; max-width: 50%; }
.result-sub { font-size: var(--fs-12); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: var(--s-5) 0 var(--s-1); color: var(--c-primary-ink); }

/* Optional mini stat grid inside the result card (e.g. "with extra payment" vs "without"). */
.result-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin: 0 0 var(--s-4); }
.result-compare > div { padding: var(--s-3); background: var(--c-elevated); border: 1px solid var(--c-result-line); border-radius: var(--r-ctl); min-width: 0; }
.result-compare dt, .result-compare .compare-label { font-size: var(--fs-12); font-weight: 600; color: var(--c-muted); margin: 0 0 2px; }
.result-compare dd, .result-compare .compare-value { margin: 0; font-size: var(--fs-18); font-weight: 700; color: var(--c-text); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.callout { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-radius: var(--r-ctl); font-size: var(--fs-14); line-height: 1.5; margin-top: var(--s-4); }
.callout[hidden] { display: none; }
.callout p { margin: 0; }
.callout .icon { margin-top: 2px; }
.callout-warn { background: var(--c-warn-soft); border: 1px solid var(--c-warn-line); color: var(--c-text); }
.callout-warn .icon { color: var(--c-warn-ink); }
.callout-info { background: var(--c-elevated); border: 1px solid var(--c-border); color: var(--c-text); }
.callout-info .icon { color: var(--c-primary-ink); }

.estimate-note { font-size: var(--fs-14); color: var(--c-muted); margin: var(--s-3) 0 0; }

/* ============ Share bar ============ */
.share-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: var(--s-4) 0 var(--s-6); }
.share-status { font-size: var(--fs-14); color: var(--c-primary-ink); font-weight: 600; }
.share-status:empty { display: none; }
.share-fallback { flex: 1 1 100%; }
.share-fallback[hidden] { display: none; }
.share-fallback label { display: block; font-size: var(--fs-14); font-weight: 600; margin-bottom: var(--s-1); }
.share-fallback .input { font-size: var(--fs-14); }
@media (max-width: 479.98px) {
  .share-bar .btn { flex: 1 1 auto; }
}

/* ============ Panels and charts ============ */
.panel { background: var(--c-elevated); border: 1px solid var(--c-border); border-radius: var(--r-card); box-shadow: var(--shadow); padding: var(--s-4); margin-bottom: var(--s-5); min-width: 0; }
.panel > h2 { font-size: var(--fs-20); margin-bottom: var(--s-4); }
@media (min-width: 480px) { .panel { padding: var(--s-5); } }
@media (min-width: 900px) { .panel { padding: var(--s-5) var(--s-6) var(--s-6); } }

.chart { min-width: 0; }
.chart-plot { position: relative; width: 100%; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-grid { stroke: var(--c-border); stroke-width: 1; shape-rendering: crispEdges; fill: none; }
.chart-axis { fill: var(--c-muted); font-size: 12px; }
.chart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-line.is-dashed, .is-dashed { stroke-dasharray: 6 5; }
.chart-guide { stroke: var(--c-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-marker { stroke: var(--c-muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-marker-label { fill: var(--c-text); font-size: 12px; font-weight: 600; }
.chart-dot { stroke: var(--c-elevated); stroke-width: 2; }
.chart-bar { shape-rendering: crispEdges; }
.donut-seg { stroke: var(--c-elevated); stroke-width: 2; cursor: pointer; }
.donut-seg:hover { opacity: .88; }
.donut-center-label { fill: var(--c-muted); font-size: 13px; }
.donut-center-value { fill: var(--c-text); font-size: 20px; font-weight: 700; }

.stroke-0 { stroke: var(--c-series-0); }
.stroke-1 { stroke: var(--c-series-1); }
.stroke-2 { stroke: var(--c-series-2); }
.stroke-3 { stroke: var(--c-series-3); }
.fill-0 { fill: var(--c-series-0); }
.fill-1 { fill: var(--c-series-1); }
.fill-2 { fill: var(--c-series-2); }
.fill-3 { fill: var(--c-series-3); }
.bg-0 { background: var(--c-series-0); }
.bg-1 { background: var(--c-series-1); }
.bg-2 { background: var(--c-series-2); }
.bg-3 { background: var(--c-series-3); }

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 260px;
  padding: var(--s-2) var(--s-3); background: var(--c-elevated); color: var(--c-text); border: 1px solid var(--c-border);
  border-radius: var(--r-ctl); box-shadow: var(--shadow-lg);
  font-size: var(--fs-14); line-height: 1.45;
}
.chart-tip[hidden] { display: none; }
.chart-tip-title { font-weight: 600; margin-bottom: var(--s-1); }
.chart-tip-row { display: flex; align-items: center; gap: var(--s-2); }
.chart-tip-row span:last-child { margin-left: auto; padding-left: var(--s-3); font-weight: 600; white-space: nowrap; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

.chart-legend { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2) var(--s-5); margin: var(--s-4) 0 0; padding: 0; font-size: var(--fs-14); color: var(--c-text); }
.chart-legend li { display: inline-flex; align-items: center; gap: var(--s-2); }

/* ============ Tables ============ */
.table-block { min-width: 0; }
.table-wrap { overflow: auto; max-height: 32rem; border: 1px solid var(--c-border); border-radius: var(--r-ctl); -webkit-overflow-scrolling: touch; background: var(--c-elevated); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); }
.data-table th, .data-table td { padding: 10px var(--s-3); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--c-border); }
.data-table thead th { position: sticky; top: 0; z-index: 1; background: var(--c-surface); font-weight: 600; font-size: var(--fs-12); text-transform: uppercase; letter-spacing: .06em; color: var(--c-muted); border-bottom-color: var(--c-border-strong); }
.data-table tbody th { font-weight: 400; }
.data-table tbody tr:nth-child(even) > * { background: var(--c-surface); }
.data-table tbody tr:hover > * { background: var(--c-hover); }
.data-table .num { text-align: right; }
.data-table tr.is-sub > * { color: var(--c-muted); }
.data-table tfoot > tr > *, .data-table tr.total > * { font-weight: 700; background: var(--c-result); border-bottom: 0; color: var(--c-text); }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table tfoot tr:first-child > * { border-top: 1px solid var(--c-border-strong); }
.table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
.copy-status { font-size: var(--fs-14); color: var(--c-primary-ink); font-weight: 600; }
.copy-status:empty { display: none; }

/* ============ Ad and partner slots ============ */
.ad-slot { position: relative; display: flex; align-items: center; justify-content: center; min-height: 250px; margin: var(--s-5) 0; background: var(--c-surface); border: 1px dashed var(--c-border-strong); border-radius: var(--r-ctl); }
.ad-label { position: absolute; top: var(--s-1); left: var(--s-2); font-size: var(--fs-12); color: var(--c-muted); text-transform: uppercase; letter-spacing: .05em; }
.ad-slot--guide-mid { max-width: 68ch; }
.ad-slot--sidebar { display: none; }
@media (min-width: 1080px) { .ad-slot--sidebar { display: flex; min-height: 600px; } }

.partner-slot { margin: var(--s-5) 0; }
.partner-label { font-size: var(--fs-12); color: var(--c-muted); margin: 0 0 var(--s-1); }
.partner-card { display: block; padding: var(--s-4); border: 1px solid var(--c-border); border-radius: var(--r-card); background: var(--c-elevated); box-shadow: var(--shadow); color: var(--c-text); text-decoration: none; }
.partner-card:hover { border-color: var(--c-primary-line); color: var(--c-text); }

/* ============ Guide, FAQ, related ============ */
.guide { max-width: 68ch; margin: var(--s-8) 0 var(--s-6); font-size: var(--fs-18); line-height: 1.7; }
.guide h2 { margin-top: var(--s-7); font-size: var(--fs-24); }
.guide > h2:first-child { margin-top: 0; font-size: var(--fs-32); }
.guide h3 { margin-top: var(--s-5); }
.guide li { margin-bottom: var(--s-2); }
.guide li::marker { color: var(--c-muted); }
.guide-updated { font-size: var(--fs-14); color: var(--c-muted); }
.guide-example { background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--c-primary-line); border-radius: var(--r-ctl); padding: var(--s-4) var(--s-5); margin: var(--s-4) 0 var(--s-5); font-size: var(--fs-16); font-variant-numeric: tabular-nums; }
.guide-example > :last-child { margin-bottom: 0; }
@media (max-width: 479.98px) { .guide { font-size: var(--fs-16); } .guide > h2:first-child { font-size: var(--fs-24); } }

.faq { max-width: 68ch; margin: var(--s-7) 0; }
.faq-item { border-bottom: 1px solid var(--c-border); }
.faq-item:first-of-type { border-top: 1px solid var(--c-border); }
.faq-item summary {
  list-style: none; position: relative; display: flex; align-items: center; min-height: 60px;
  padding: var(--s-3) var(--s-7) var(--s-3) 0; font-weight: 600; cursor: pointer; line-height: 1.4;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::marker { content: ''; }
.faq-item summary::after {
  content: ''; position: absolute; right: var(--s-3); top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--c-primary-ink); border-bottom: 2px solid var(--c-primary-ink);
  transform: translateY(-70%) rotate(45deg); transition: transform .15s;
}
.faq-item[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
.faq-item summary:hover { color: var(--c-primary-ink); }
.faq-answer { padding: 0 0 var(--s-4); color: var(--c-text); }
.faq-answer > :last-child { margin-bottom: 0; }

.related { margin: var(--s-7) 0 var(--s-6); }
.tile-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
@media (min-width: 560px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .tile-grid { grid-template-columns: repeat(3, 1fr); gap: var(--s-4); } }
.tile {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto 1fr; column-gap: var(--s-4);
  align-items: start; padding: var(--s-4) var(--s-5) var(--s-4) var(--s-4); background: var(--c-elevated); border: 1px solid var(--c-border);
  border-radius: var(--r-card); box-shadow: var(--shadow); color: var(--c-text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.tile:hover { border-color: var(--c-primary-line); box-shadow: var(--shadow-md); color: var(--c-text); text-decoration: none; }
a.tile:hover .tile-name { color: var(--c-primary-ink); }
.tile-icon { grid-row: 1 / span 2; display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 10px; background: var(--c-primary-soft); color: var(--c-primary-ink); }
.tile-icon svg, .cat-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-name { font-weight: 600; line-height: 1.35; padding-right: var(--s-4); }
.tile-blurb { grid-column: 2; font-size: var(--fs-14); color: var(--c-muted); line-height: 1.5; margin-top: 2px; }
.tile-arrow {
  position: absolute; top: calc(var(--s-4) + 8px); right: var(--s-4); width: 7px; height: 7px;
  border-top: 2px solid var(--c-muted); border-right: 2px solid var(--c-muted); transform: rotate(45deg); transition: transform .15s, border-color .15s;
}
a.tile:hover .tile-arrow { border-color: var(--c-primary-ink); transform: translateX(2px) rotate(45deg); }
.tile.is-soon { box-shadow: none; background: var(--c-surface); color: var(--c-muted); pointer-events: none; }
.tile.is-soon .tile-icon { background: var(--c-border); color: var(--c-muted); }
.tile.is-soon .tile-name { color: var(--c-muted); }
.tile-badge { grid-column: 2; justify-self: start; margin-top: var(--s-2); padding: 2px var(--s-2); border: 1px solid var(--c-border); border-radius: 999px; background: var(--c-elevated); font-size: var(--fs-12); font-weight: 600; color: var(--c-muted); }

.figures-checked, .disclaimer-line { font-size: var(--fs-14); color: var(--c-muted); max-width: 68ch; }
.figures-checked { margin-top: var(--s-6); padding-top: var(--s-4); border-top: 1px solid var(--c-border); }
.figures-checked a, .disclaimer-line a { color: var(--c-muted); }
.figures-checked a:hover, .disclaimer-line a:hover { color: var(--c-primary-ink); }

/* ============ Sticky mobile result ============ */
.sticky-result {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  min-height: 56px; padding: var(--s-2) var(--gutter) calc(var(--s-2) + env(safe-area-inset-bottom, 0px));
  background: var(--c-elevated); border-top: 1px solid var(--c-border); box-shadow: 0 -6px 20px rgba(16, 24, 40, .08);
}
:root[data-theme="dark"] .sticky-result { box-shadow: 0 -6px 20px rgba(0, 0, 0, .5); }
.sticky-result[hidden] { display: none; }
.sticky-label { font-size: var(--fs-14); color: var(--c-muted); font-weight: 600; }
.sticky-value { font-size: var(--fs-20); font-weight: 700; color: var(--c-text); border-bottom: 3px solid var(--c-accent); line-height: 1.2; letter-spacing: -0.01em; }
@media (max-width: 899.98px) {
  body:has(.sticky-result:not([hidden])) { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 900px) { .sticky-result { display: none !important; } }

/* ============ Home ============ */
.hero { background: var(--c-surface); border-bottom: 1px solid var(--c-border); padding: var(--s-7) 0 var(--s-6); }
@media (min-width: 768px) { .hero { padding: 80px 0 var(--s-7); } }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-4); padding: 4px var(--s-3);
  border: 1px solid var(--c-border-strong); border-radius: 999px; background: var(--c-elevated);
  font-size: var(--fs-14); font-weight: 600; color: var(--c-text);
}
.eyebrow::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c-primary); }
.hero h1 { max-width: 18ch; margin-bottom: var(--s-4); font-size: 2.25rem; letter-spacing: -0.03em; line-height: 1.08; }
@media (min-width: 768px) { .hero h1 { font-size: 3.25rem; } }
.hero-sub { font-size: var(--fs-18); color: var(--c-muted); max-width: 54ch; margin: 0; line-height: 1.55; }
@media (min-width: 768px) { .hero-sub { font-size: var(--fs-20); } }

.finder { max-width: 560px; margin-top: var(--s-6); }
.finder-label { display: block; font-weight: 600; margin-bottom: var(--s-2); }
.finder-field { position: relative; }
.finder-field .icon { position: absolute; left: var(--s-4); top: 50%; transform: translateY(-50%); color: var(--c-muted); pointer-events: none; width: 20px; height: 20px; }
.finder-field .input { min-height: 56px; padding-left: 48px; font-size: var(--fs-18); border-radius: 10px; box-shadow: var(--shadow); }
.finder-status { font-size: var(--fs-14); color: var(--c-muted); margin: var(--s-2) 0 0; min-height: 1.5em; }
.finder-empty { padding: var(--s-6) var(--s-5); text-align: center; color: var(--c-muted); background: var(--c-surface); border: 1px dashed var(--c-border-strong); border-radius: var(--r-card); margin: 0 0 var(--s-7); }

.trust-list { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin: var(--s-5) 0 0; padding: 0; font-size: var(--fs-14); font-weight: 600; color: var(--c-text); }
.trust-list li { display: inline-flex; align-items: center; gap: var(--s-2); }
.trust-list .icon { color: var(--c-primary-ink); width: 18px; height: 18px; }

.home-sections { padding-top: var(--s-7); }
.category-section { margin: 0 0 var(--s-7); }
.category-section h2 { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-24); margin-bottom: var(--s-4); }
.cat-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--c-primary-soft); color: var(--c-primary-ink); flex: none; }
.home-about { max-width: 68ch; padding-top: var(--s-6); border-top: 1px solid var(--c-border); }
.home-about h2 { font-size: var(--fs-24); }
.home-about p { color: var(--c-text); }

/* ============ Simple article pages (About, legal, 404) ============ */
.article { max-width: 68ch; padding: var(--s-6) 0 var(--s-6); font-size: var(--fs-18); line-height: 1.7; }
.article h1 { margin-bottom: var(--s-3); }
.article h2 { font-size: var(--fs-24); margin-top: var(--s-7); }
.article h3 { margin-top: var(--s-5); }
.article li { margin-bottom: var(--s-2); }
.article-updated { font-size: var(--fs-14); color: var(--c-muted); margin-bottom: var(--s-6); }
.article .lead { margin-bottom: var(--s-5); font-size: var(--fs-20); }
.article-note { font-size: var(--fs-16); padding: var(--s-4) var(--s-5); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-ctl); }
.contact-email { font-size: var(--fs-20); font-weight: 600; padding: var(--s-4) var(--s-5); background: var(--c-elevated); border: 1px solid var(--c-border); border-radius: var(--r-ctl); display: inline-block; user-select: all; }
@media (max-width: 479.98px) { .article { font-size: var(--fs-16); } }

.not-found { padding: var(--s-8) 0 var(--s-6); max-width: 720px; }
.not-found .code { font-size: var(--fs-14); font-weight: 600; color: var(--c-muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: var(--s-2); }
.category-links { list-style: none; margin: var(--s-5) 0 var(--s-6); padding: 0; display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
@media (min-width: 560px) { .category-links { grid-template-columns: 1fr 1fr; } }
.category-link {
  display: flex; align-items: center; gap: var(--s-3); min-height: 64px; padding: var(--s-3) var(--s-4);
  border: 1px solid var(--c-border); border-radius: var(--r-card); background: var(--c-elevated); box-shadow: var(--shadow);
  color: var(--c-text); font-weight: 600; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.category-link:hover { border-color: var(--c-primary-line); box-shadow: var(--shadow-md); color: var(--c-primary-ink); text-decoration: none; }

/* ============ Utilities ============ */
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

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

@media print {
  .site-header, .site-footer, .share-bar, .sticky-result, .ad-slot, .partner-slot, .theme-toggle, .table-actions, .related { display: none !important; }
  .calc-card, .panel { box-shadow: none; }
  body { background: #fff; color: #000; }
}

/* Stacked segmented toggle for longer option labels (full-width choices on phones). */
.segmented--stack { display: flex; flex-direction: column; width: 100%; }
@media (min-width: 640px) { .segmented--stack { flex-direction: row; } .segmented--stack label { flex: 1 1 0; text-align: center; } }

/* The hidden attribute always wins over component display rules. */
[hidden] { display: none !important; }

/* Tip jar link in the footer. */
.footer-tip { margin-top: var(--s-4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); color: var(--c-muted); font-size: var(--fs-14); }
.btn-tip { min-height: 44px; }
