/* ==========================================================================
   SmartFinClub — Design System
   Single stylesheet. No framework, no CDN, no build step required.
   Sections:
     1. Tokens
     2. Reset & base
     3. Layout primitives
     4. Typography
     5. Buttons
     6. Forms & inputs
     7. Cards
     8. Header & navigation
     9. Footer
    10. Hero & homepage
    11. Calculator shell
    12. Results
    13. Tables
    14. Charts
    15. Accordion / FAQ
    16. Modal
    17. Toast
    18. Breadcrumbs
    19. Alerts, disclaimers, badges
    20. Article / prose content
    21. Ad slots
    22. Utilities
    23. Print
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette */
  --navy: #0f172a;
  --navy-800: #1e293b;
  --slate: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --bg: #f8fafc;
  --white: #ffffff;

  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-darker: #047857;
  --emerald-light: #d1fae5;
  --emerald-tint: #ecfdf5;

  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --warning-dark: #b45309;

  --error: #ef4444;
  --error-light: #fee2e2;
  --error-dark: #b91c1c;

  --info: #0284c7;
  --info-light: #e0f2fe;
  --info-dark: #075985;

  /* Chart series — colour-blind aware ordering, each also distinguishable by
     position and always paired with a text label. */
  --c1: #0f172a;
  --c2: #10b981;
  --c3: #0284c7;
  --c4: #f59e0b;
  --c5: #8b5cf6;
  --c6: #ec4899;
  --c7: #64748b;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fs-3xl: 1.875rem;
  --fs-4xl: 2.25rem;
  --fs-5xl: 3rem;

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Radii */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Shadows — restrained */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --sh: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --sh-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --sh-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

  --border: 1px solid var(--slate-200);
  --maxw: 1200px;
  --maxw-prose: 72ch;
  --header-h: 68px;
  --transition: 150ms ease;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.65;
  color: var(--slate);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg, video, canvas { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-4);
  color: var(--navy);
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.875rem, 1.3rem + 2.4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
h3 { font-size: clamp(1.2rem, 1.08rem + 0.5vw, 1.4rem); }
h4 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--emerald-darker); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--navy); }

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.35rem; }
li { margin-bottom: var(--sp-2); }

hr { border: 0; border-top: var(--border); margin: var(--sp-8) 0; }

code, kbd, samp { font-family: var(--font-mono); font-size: 0.9em; }

/* Focus — always visible, never removed */
:focus-visible {
  outline: 3px solid var(--emerald-dark);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--emerald-light); color: var(--navy); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--navy); color: var(--white);
  padding: var(--sp-3) var(--sp-5); border-radius: 0 0 var(--r) 0;
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { left: 0; color: var(--white); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------------------
   3. LAYOUT PRIMITIVES
   -------------------------------------------------------------------------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--sp-5); }
.container-narrow { max-width: 860px; }
.container-prose { max-width: var(--maxw-prose); }

.section { padding-block: clamp(2.5rem, 1.5rem + 4vw, 5rem); }
.section--tight { padding-block: clamp(2rem, 1.2rem + 3vw, 3.5rem); }
.section--navy { background: var(--navy); color: var(--slate-300); }
.section--navy h1, .section--navy h2, .section--navy h3 { color: var(--white); }
.section--white { background: var(--white); }
.section--tint { background: var(--emerald-tint); }

.grid { display: grid; gap: var(--sp-6); }
/* Grid and flex items default to min-width:auto, which means they refuse to
   shrink below their content. A wide table inside one then pushes the whole
   page sideways on a narrow screen instead of scrolling inside its own
   container. Every layout child here is explicitly allowed to shrink. */
.grid > *, .calc-layout > *, .hero-grid > *, .footer-grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }

.stack > * + * { margin-top: var(--sp-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }

.section-head { margin-bottom: var(--sp-8); max-width: 60ch; }
.section-head p { color: var(--slate-600); font-size: var(--fs-lg); margin-bottom: 0; }
.section-head--center { margin-inline: auto; text-align: center; }

.eyebrow {
  display: inline-block; font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--emerald-darker); margin-bottom: var(--sp-3);
}
.section--navy .eyebrow { color: var(--emerald); }

/* --------------------------------------------------------------------------
   4. TYPOGRAPHY HELPERS
   -------------------------------------------------------------------------- */
.lead { font-size: var(--fs-lg); color: var(--slate-600); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.muted { color: var(--slate-500); }
.strong { font-weight: 700; color: var(--navy); }
.num { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.pos { color: var(--emerald-darker); }
.neg { color: var(--error-dark); }

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 46px; padding: var(--sp-3) var(--sp-6);
  font-family: inherit; font-size: var(--fs-base); font-weight: 600; line-height: 1.2;
  border-radius: var(--r); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: background-color var(--transition), color var(--transition),
              border-color var(--transition), transform var(--transition);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--emerald-dark); color: var(--white); }
.btn-primary:hover { background: var(--emerald-darker); color: var(--white); }

.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { background: var(--navy-800); color: var(--white); }

.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--slate-300); }
.btn-secondary:hover { background: var(--slate-100); color: var(--navy); border-color: var(--slate-400); }

.btn-ghost { background: transparent; color: var(--slate); border-color: transparent; }
.btn-ghost:hover { background: var(--slate-100); color: var(--navy); }

.btn-outline-light { background: transparent; color: var(--white); border-color: rgba(255,255,255,0.35); }
.btn-outline-light:hover { background: rgba(255,255,255,0.1); color: var(--white); border-color: var(--white); }

.btn-sm { min-height: 38px; padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }
.btn-lg { min-height: 54px; padding: var(--sp-4) var(--sp-8); font-size: var(--fs-lg); }
.btn-block { width: 100%; }

.btn .spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   6. FORMS & INPUTS
   -------------------------------------------------------------------------- */
.field { margin-bottom: var(--sp-5); }
.field:last-child { margin-bottom: 0; }

.field label, .field .field-label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  color: var(--navy); margin-bottom: var(--sp-2);
}
.field-help { font-size: var(--fs-xs); color: var(--slate-500); margin-top: var(--sp-1); line-height: 1.5; }

.input-wrap { position: relative; display: flex; align-items: stretch; }

.input, select.input, textarea.input {
  width: 100%; min-height: 46px;
  padding: var(--sp-3) var(--sp-4);
  font-family: inherit; font-size: var(--fs-base); color: var(--navy);
  background: var(--white); border: 1px solid var(--slate-300);
  border-radius: var(--r); transition: border-color var(--transition), box-shadow var(--transition);
  font-variant-numeric: tabular-nums;
}
.input:hover { border-color: var(--slate-400); }
.input:focus { outline: none; border-color: var(--emerald-dark); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.input:focus-visible { outline: none; }
textarea.input { min-height: 130px; resize: vertical; line-height: 1.6; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9' fill='none'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--sp-4) center;
  padding-right: var(--sp-10);
}

/* Affix (currency $ / percent %) */
.has-prefix .input { padding-left: 2rem; }
.has-suffix .input { padding-right: 2.6rem; }
.affix {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
  color: var(--slate-500); font-size: var(--fs-base); pointer-events: none; font-weight: 500;
}
.affix-prefix { left: var(--sp-4); }
.affix-suffix { right: var(--sp-4); }

/* Validation states */
.field.is-invalid .input { border-color: var(--error); }
.field.is-invalid .input:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18); }
.field-error {
  display: none; align-items: flex-start; gap: var(--sp-2);
  margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--error-dark); font-weight: 500;
}
.field.is-invalid .field-error { display: flex; }
.field-error::before { content: "\26A0"; flex: none; line-height: 1.5; }

/* Checkbox & radio */
.check {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  font-size: var(--fs-sm); color: var(--slate); cursor: pointer; line-height: 1.55;
}
.check input[type="checkbox"], .check input[type="radio"] {
  flex: none; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--emerald-dark); cursor: pointer;
}
.check + .check { margin-top: var(--sp-3); }

/* Range slider paired with a number box */
.range-row { display: grid; grid-template-columns: 1fr 108px; gap: var(--sp-3); align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--emerald-dark); height: 24px; cursor: pointer; }

/* Segmented toggle (Basic / Advanced) */
.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--slate-100); border-radius: var(--r-full); border: var(--border);
}
.segmented button {
  appearance: none; border: 0; cursor: pointer;
  padding: var(--sp-2) var(--sp-5); min-height: 38px;
  font-family: inherit; font-size: var(--fs-sm); font-weight: 600;
  color: var(--slate-600); background: transparent; border-radius: var(--r-full);
  transition: background-color var(--transition), color var(--transition);
}
.segmented button:hover { color: var(--navy); }
.segmented button[aria-selected="true"] { background: var(--white); color: var(--navy); box-shadow: var(--sh-sm); }

/* Repeatable rows (debt lists, lots, children) */
.repeat-row {
  display: grid; gap: var(--sp-3); align-items: end;
  padding: var(--sp-4); margin-bottom: var(--sp-3);
  background: var(--slate-100); border: var(--border); border-radius: var(--r);
}
.repeat-row .field { margin-bottom: 0; min-width: 0; }
.repeat-row .row-remove { justify-self: start; }
@media (min-width: 720px) {
  .repeat-row { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)) auto; }
}

.fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-6); }
.fieldset legend {
  padding: 0; margin-bottom: var(--sp-4);
  font-size: var(--fs-sm); font-weight: 700; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.form-status { margin-top: var(--sp-5); }

/* --------------------------------------------------------------------------
   7. CARDS
   -------------------------------------------------------------------------- */
.card {
  background: var(--white); border: var(--border);
  border-radius: var(--r-lg); padding: var(--sp-6); box-shadow: var(--sh-sm);
}
.card--pad-lg { padding: clamp(1.5rem, 1rem + 2vw, 2.5rem); }
.card--flush { padding: 0; overflow: hidden; }

.tool-card {
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--white); border: var(--border); border-radius: var(--r-lg);
  padding: var(--sp-6); text-decoration: none; color: inherit;
  box-shadow: var(--sh-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.tool-card:hover { border-color: var(--emerald); box-shadow: var(--sh-md); transform: translateY(-2px); color: inherit; }
.tool-card { min-width: 0; overflow-wrap: break-word; }
.tool-card h3 { margin: 0; font-size: var(--fs-lg); }
.tool-card p { margin: 0; font-size: var(--fs-sm); color: var(--slate-600); flex: 1; }
.tool-card .tool-card-go { font-size: var(--fs-sm); font-weight: 600; color: var(--emerald-darker); }
.tool-card-icon {
  width: 42px; height: 42px; border-radius: var(--r);
  display: grid; place-items: center; background: var(--emerald-tint); flex: none;
}
.tool-card-icon svg { width: 22px; height: 22px; stroke: var(--emerald-darker); fill: none; stroke-width: 1.9; }

.category-card {
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: clamp(1.5rem, 1rem + 2vw, 2.25rem);
  background: var(--white); border: var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.category-card ul { list-style: none; padding: 0; margin: 0; flex: 1; }
.category-card li { margin-bottom: var(--sp-2); font-size: var(--fs-sm); }
.category-card li a { color: var(--slate); text-decoration: none; }
.category-card li a:hover { color: var(--emerald-darker); text-decoration: underline; }

.stat-tile { padding: var(--sp-5); background: var(--white); border: var(--border); border-radius: var(--r-lg); }
.stat-tile .stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em; color: var(--slate-500); font-weight: 700; }
.stat-tile .stat-value { font-size: var(--fs-2xl); font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   8. HEADER & NAVIGATION
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: var(--border);
}
.site-header .container {
  display: flex; align-items: center; gap: var(--sp-4);
  min-height: var(--header-h);
}

.brand { display: inline-flex; align-items: center; gap: var(--sp-3); text-decoration: none; margin-right: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: var(--navy); display: grid; place-items: center;
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-name { font-weight: 800; font-size: var(--fs-lg); color: var(--navy); letter-spacing: -0.02em; }
.brand-name span { color: var(--emerald-dark); }

.nav { display: flex; align-items: center; gap: var(--sp-1); }
/* :not(.btn) matters — the "Start Calculating" call to action is an <a> that
   must keep its button styling rather than inheriting the plain nav link. */
.nav a:not(.btn), .nav .nav-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  padding: var(--sp-2) var(--sp-3); min-height: 40px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--slate);
  text-decoration: none; border-radius: var(--r-sm);
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.nav a:not(.btn):hover, .nav .nav-trigger:hover { background: var(--slate-100); color: var(--navy); }
.nav a[aria-current="page"]:not(.btn) { color: var(--emerald-darker); }
.nav .btn { margin-left: var(--sp-2); }
.nav-trigger svg { width: 11px; height: 11px; transition: transform var(--transition); }
.nav-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }

.nav-item { position: relative; }
.nav-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 70;
  min-width: 268px; padding: var(--sp-2);
  background: var(--white); border: var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); list-style: none; margin: 0;
}
.nav-menu[hidden] { display: none; }
.nav-menu li { margin: 0; }
.nav-menu a {
  display: block; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm);
  font-weight: 500; font-size: var(--fs-sm); color: var(--slate);
}
.nav-menu a:hover { background: var(--emerald-tint); color: var(--emerald-darker); }

.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 46px; height: 46px; border: var(--border); border-radius: var(--r);
  background: var(--white); cursor: pointer; color: var(--navy);
}
.nav-toggle svg { width: 22px; height: 22px; }
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-open { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 1023px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; inset: var(--header-h) 0 0 0; z-index: 55;
    display: block; overflow-y: auto;
    padding: var(--sp-5) var(--sp-5) var(--sp-16);
    background: var(--white); border-top: var(--border);
  }
  .nav[hidden] { display: none; }
  .nav-item { border-bottom: var(--border); }
  .nav > a:not(.btn), .nav .nav-trigger { width: 100%; min-height: 54px; font-size: var(--fs-base); border-radius: 0; }
  .nav > a:not(.btn) { border-bottom: var(--border); }
  .nav .nav-trigger { justify-content: space-between; }
  .nav-menu {
    position: static; box-shadow: none; border: 0; padding: 0 0 var(--sp-3) var(--sp-3);
    min-width: 0; background: transparent;
  }
  .nav-menu a { min-height: 46px; display: flex; align-items: center; }
  .nav .btn { margin: var(--sp-5) 0 0; width: 100%; min-height: 50px; }
  body.nav-open { overflow: hidden; }
}

/* --------------------------------------------------------------------------
   9. FOOTER
   -------------------------------------------------------------------------- */
.site-footer { background: var(--navy); color: var(--slate-400); padding-block: var(--sp-16) var(--sp-8); font-size: var(--fs-sm); }
.site-footer a { color: var(--slate-300); text-decoration: none; }
.site-footer a:hover { color: var(--white); text-decoration: underline; }
.footer-grid { display: grid; gap: var(--sp-8); grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); }
.footer-brand { grid-column: 1 / -1; max-width: 34ch; }
@media (min-width: 900px) { .footer-brand { grid-column: auto; max-width: none; } }
.footer-brand .brand-name { color: var(--white); }
.footer-brand p { color: var(--slate-400); margin-top: var(--sp-4); }
.footer-col h3 {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--white); margin-bottom: var(--sp-4); font-weight: 700;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: var(--sp-2); }
.footer-bottom {
  margin-top: var(--sp-12); padding-top: var(--sp-6);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: space-between;
  font-size: var(--fs-xs); color: var(--slate-500);
}
.footer-legal-note {
  margin-top: var(--sp-6); padding: var(--sp-4);
  background: rgba(255,255,255,0.04); border-radius: var(--r);
  font-size: var(--fs-xs); line-height: 1.6; color: var(--slate-400);
}

/* --------------------------------------------------------------------------
   10. HERO & HOMEPAGE
   -------------------------------------------------------------------------- */
.hero { background: var(--navy); color: var(--slate-300); padding-block: clamp(3rem, 2rem + 6vw, 6rem); position: relative; overflow: hidden; }
.hero::after {
  content: ""; position: absolute; inset: auto -10% -60% 55%;
  height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,0.16), transparent 68%);
  pointer-events: none;
}
.hero .container { position: relative; z-index: 1; }
.hero-grid { display: grid; gap: var(--sp-10); align-items: center; }
@media (min-width: 1000px) { .hero-grid { grid-template-columns: 1.05fr 0.95fr; gap: var(--sp-12); } }
.hero h1 { color: var(--white); font-size: clamp(2.1rem, 1.4rem + 3.2vw, 3.4rem); margin-bottom: var(--sp-5); }
.hero-sub { font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem); color: var(--slate-300); max-width: 56ch; margin-bottom: var(--sp-8); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.hero-trust { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin-top: var(--sp-8); font-size: var(--fs-sm); color: var(--slate-400); }
.hero-trust span { display: inline-flex; align-items: center; gap: var(--sp-2); }
.hero-trust svg { width: 17px; height: 17px; stroke: var(--emerald); fill: none; stroke-width: 2; flex: none; }

.hero-preview { background: var(--white); border-radius: var(--r-xl); padding: var(--sp-6); box-shadow: var(--sh-lg); color: var(--slate); }
.hero-preview-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.hero-preview-head strong { color: var(--navy); font-size: var(--fs-sm); }
.hero-preview-result {
  padding: var(--sp-5); background: var(--emerald-tint);
  border: 1px solid var(--emerald-light); border-radius: var(--r); text-align: center; margin-top: var(--sp-5);
}
.hero-preview-result .label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em; color: var(--emerald-darker); font-weight: 700; }
.hero-preview-result .value { font-size: var(--fs-3xl); font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.2; }

/* Tool search */
.tool-search { position: relative; max-width: 560px; }
.tool-search .input { padding-left: 2.9rem; min-height: 52px; }
.tool-search svg {
  position: absolute; left: var(--sp-4); top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; stroke: var(--slate-500); fill: none; stroke-width: 2; pointer-events: none;
}
.search-meta { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--slate-500); }
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }
.chip {
  appearance: none; cursor: pointer; font-family: inherit;
  padding: var(--sp-2) var(--sp-4); min-height: 38px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--slate-600);
  background: var(--white); border: var(--border); border-radius: var(--r-full);
  transition: all var(--transition);
}
.chip:hover { border-color: var(--slate-400); color: var(--navy); }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--white); }

.empty-state { padding: var(--sp-12) var(--sp-5); text-align: center; border: 2px dashed var(--slate-300); border-radius: var(--r-lg); color: var(--slate-500); }
.empty-state h3 { color: var(--slate); }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; display: grid; gap: var(--sp-5); }
.steps li { counter-increment: step; display: flex; gap: var(--sp-4); margin: 0; }
.steps li::before {
  content: counter(step); flex: none;
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--emerald-tint); color: var(--emerald-darker);
  display: grid; place-items: center; font-weight: 800; font-size: var(--fs-sm);
}
.section--navy .steps li::before { background: rgba(16,185,129,0.16); color: var(--emerald); }
.steps li strong { display: block; color: var(--navy); }
.section--navy .steps li strong { color: var(--white); }

/* --------------------------------------------------------------------------
   11. CALCULATOR SHELL
   -------------------------------------------------------------------------- */
.calc-layout { display: grid; gap: var(--sp-6); align-items: start; min-width: 0; }
@media (min-width: 1024px) { .calc-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.06fr); gap: var(--sp-8); } }

.calc-panel {
  background: var(--white); border: var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
  min-width: 0; overflow: hidden;
}
.calc-panel-head {
  display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-6); border-bottom: var(--border);
}
.calc-panel-head h2 { margin: 0; font-size: var(--fs-lg); }
.calc-panel-body { padding: var(--sp-6); min-width: 0; }

.calc-inputs { display: grid; gap: var(--sp-5); min-width: 0; }
.calc-inputs > * { min-width: 0; }
@media (min-width: 520px) { .calc-inputs { grid-template-columns: 1fr 1fr; } }
.calc-inputs .field.span-2 { grid-column: 1 / -1; }
@media (max-width: 519px) { .calc-inputs .field.span-2 { grid-column: auto; } }

.advanced-only[hidden] { display: none; }

.calc-actions {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6); border-top: var(--border); background: var(--slate-100);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.calc-actions .btn { flex: 1 1 auto; }

@media (min-width: 1024px) { .calc-results-sticky { position: sticky; top: calc(var(--header-h) + var(--sp-5)); } }

/* --------------------------------------------------------------------------
   12. RESULTS
   -------------------------------------------------------------------------- */
.result-primary {
  padding: clamp(1.5rem, 1rem + 2vw, 2rem); text-align: center;
  background: linear-gradient(160deg, #ecfdf5, #f8fafc);
  border: 1px solid var(--emerald-light); border-radius: var(--r-lg);
}
.result-primary .result-label {
  font-size: var(--fs-sm); font-weight: 700; color: var(--emerald-darker);
  text-transform: uppercase; letter-spacing: 0.07em;
}
.result-primary .result-value {
  font-size: clamp(2.1rem, 1.4rem + 3.2vw, 3.1rem); font-weight: 800;
  color: var(--navy); line-height: 1.1; font-variant-numeric: tabular-nums;
  margin: var(--sp-2) 0; overflow-wrap: anywhere;
}
.result-primary .result-note { font-size: var(--fs-sm); color: var(--slate-600); margin: 0; }

.metric-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); min-width: 0; }
.metric-grid > * { min-width: 0; }
.metric {
  padding: var(--sp-4); background: var(--white);
  border: var(--border); border-radius: var(--r);
}
.metric .metric-label { font-size: var(--fs-xs); color: var(--slate-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.4; }
.metric .metric-value { font-size: var(--fs-xl); font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; margin-top: var(--sp-1); overflow-wrap: anywhere; }
.metric .metric-sub { font-size: var(--fs-xs); color: var(--slate-500); margin-top: 2px; }
.metric.metric-pos { border-color: var(--emerald-light); background: var(--emerald-tint); }
.metric.metric-pos .metric-value { color: var(--emerald-darker); }
.metric.metric-warn { border-color: #fde68a; background: var(--warning-light); }
.metric.metric-warn .metric-value { color: var(--warning-dark); }

.result-block { min-width: 0; }
.result-block + .result-block { margin-top: var(--sp-6); }
.result-block h3 { font-size: var(--fs-base); text-transform: uppercase; letter-spacing: 0.06em; color: var(--slate-500); margin-bottom: var(--sp-4); }

.observations { list-style: none; padding: 0; margin: 0; }
.observations li {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) 0;
  border-bottom: var(--border); font-size: var(--fs-sm); margin: 0;
}
.observations li:last-child { border-bottom: 0; }
.observations li::before { content: "\2192"; color: var(--emerald-dark); font-weight: 700; flex: none; }

.assumption-list { list-style: none; padding: 0; margin: 0; font-size: var(--fs-sm); }
.assumption-list li {
  display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: space-between;
  padding: var(--sp-2) 0; border-bottom: 1px dashed var(--slate-200); margin: 0;
}
.assumption-list li:last-child { border-bottom: 0; }
.assumption-list .assumption-value { font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }

.results-empty { padding: var(--sp-10) var(--sp-5); text-align: center; color: var(--slate-500); }
.results-empty svg { width: 44px; height: 44px; stroke: var(--slate-300); fill: none; stroke-width: 1.5; margin: 0 auto var(--sp-4); }

/* --------------------------------------------------------------------------
   13. TABLES
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: var(--border); border-radius: var(--r); background: var(--white);
  max-width: 100%; min-width: 0;
}
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 460px; }
table.data caption { text-align: left; padding: var(--sp-3) var(--sp-4); color: var(--slate-500); font-size: var(--fs-xs); }
table.data th, table.data td { padding: var(--sp-3) var(--sp-4); text-align: right; border-bottom: var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--slate-100); color: var(--navy); font-weight: 700;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
table.data tbody tr:nth-child(even) { background: #fbfcfd; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td { font-weight: 700; color: var(--navy); background: var(--slate-100); }
.table-scroll-hint { font-size: var(--fs-xs); color: var(--slate-500); margin-top: var(--sp-2); }
@media (min-width: 720px) { .table-scroll-hint { display: none; } }
.table-limit { max-height: 420px; overflow-y: auto; }

/* --------------------------------------------------------------------------
   14. CHARTS
   -------------------------------------------------------------------------- */
.chart-container { position: relative; width: 100%; height: 300px; }
@media (min-width: 640px) { .chart-container { height: 340px; } }
.chart-container canvas { max-width: 100%; }
.chart-caption { font-size: var(--fs-xs); color: var(--slate-500); margin-top: var(--sp-3); text-align: center; }
.chart-fallback { padding: var(--sp-6); text-align: center; color: var(--slate-500); font-size: var(--fs-sm); border: 2px dashed var(--slate-300); border-radius: var(--r); }
.chart-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }

/* --------------------------------------------------------------------------
   15. ACCORDION / FAQ
   -------------------------------------------------------------------------- */
.accordion { border: var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--white); }
.accordion-item + .accordion-item { border-top: var(--border); }
.accordion-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  width: 100%; padding: var(--sp-5); min-height: 56px;
  font-family: inherit; font-size: var(--fs-base); font-weight: 600; color: var(--navy);
  text-align: left; background: var(--white); border: 0; cursor: pointer;
}
.accordion-trigger:hover { background: var(--slate-100); }
.accordion-trigger .acc-icon { flex: none; width: 20px; height: 20px; position: relative; }
.accordion-trigger .acc-icon::before,
.accordion-trigger .acc-icon::after {
  content: ""; position: absolute; background: var(--emerald-dark); border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}
.accordion-trigger .acc-icon::before { top: 9px; left: 2px; width: 16px; height: 2px; }
.accordion-trigger .acc-icon::after { top: 2px; left: 9px; width: 2px; height: 16px; }
.accordion-trigger[aria-expanded="true"] .acc-icon::after { transform: scaleY(0); opacity: 0; }
.accordion-panel { padding: 0 var(--sp-5) var(--sp-5); color: var(--slate-600); }
.accordion-panel[hidden] { display: none; }
.accordion-panel > :first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   16. MODAL
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--sp-4); overflow-y: auto;
  background: rgba(15, 23, 42, 0.6);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 520px; margin: auto;
  background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
}
.modal-head { display: flex; align-items: flex-start; gap: var(--sp-4); padding: var(--sp-6) var(--sp-6) var(--sp-4); }
.modal-head h2 { margin: 0; font-size: var(--fs-xl); flex: 1; }
.modal-close {
  flex: none; width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 0; background: var(--slate-100); color: var(--slate); cursor: pointer;
  display: grid; place-items: center; font-size: 1.3rem; line-height: 1;
}
.modal-close:hover { background: var(--slate-200); color: var(--navy); }
.modal-body { padding: 0 var(--sp-6) var(--sp-6); }
.modal-foot { padding: var(--sp-5) var(--sp-6); border-top: var(--border); background: var(--slate-100); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* --------------------------------------------------------------------------
   17. TOAST
   -------------------------------------------------------------------------- */
.toast-region {
  position: fixed; z-index: 120; right: var(--sp-4); bottom: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  max-width: calc(100vw - 2rem); width: 360px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4); background: var(--navy); color: var(--white);
  border-radius: var(--r); box-shadow: var(--sh-lg);
  font-size: var(--fs-sm); pointer-events: auto;
  animation: toast-in 200ms ease;
}
.toast strong { display: block; }
.toast.toast-error { background: var(--error-dark); }
.toast.toast-success { background: var(--emerald-darker); }
.toast-dismiss { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 var(--sp-1); opacity: 0.8; }
.toast-dismiss:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   18. BREADCRUMBS
   -------------------------------------------------------------------------- */
.breadcrumb { padding-block: var(--sp-4); font-size: var(--fs-sm); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding: 0; margin: 0; }
.breadcrumb li { display: flex; align-items: center; gap: var(--sp-2); margin: 0; }
.breadcrumb li + li::before { content: "/"; color: var(--slate-400); }
.breadcrumb a { color: var(--slate-600); text-decoration: none; }
.breadcrumb a:hover { color: var(--emerald-darker); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--navy); font-weight: 600; }

/* --------------------------------------------------------------------------
   19. ALERTS, DISCLAIMERS, BADGES
   -------------------------------------------------------------------------- */
.alert {
  display: flex; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r); border: 1px solid; font-size: var(--fs-sm); line-height: 1.6;
}
.alert p:last-child { margin-bottom: 0; }
.alert strong { display: block; margin-bottom: 2px; }
.alert::before { flex: none; font-weight: 700; line-height: 1.6; }
.alert-info { background: var(--info-light); border-color: #bae6fd; color: var(--info-dark); }
.alert-info::before { content: "i"; width: 18px; height: 18px; border-radius: 50%; background: var(--info); color: #fff; display: grid; place-items: center; font-size: 12px; margin-top: 3px; }
.alert-warning { background: var(--warning-light); border-color: #fcd34d; color: var(--warning-dark); }
.alert-warning::before { content: "\26A0"; }
.alert-error { background: var(--error-light); border-color: #fecaca; color: var(--error-dark); }
.alert-error::before { content: "\26A0"; }
.alert-success { background: var(--emerald-tint); border-color: var(--emerald-light); color: var(--emerald-darker); }
.alert-success::before { content: "\2713"; }

.disclaimer {
  padding: var(--sp-5); background: var(--slate-100);
  border: var(--border); border-left: 4px solid var(--slate-400); border-radius: var(--r);
  font-size: var(--fs-sm); color: var(--slate-600); line-height: 1.65;
}
.disclaimer strong { color: var(--navy); display: block; margin-bottom: var(--sp-2); }
.disclaimer p:last-child { margin-bottom: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--sp-3); border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.02em;
  background: var(--slate-100); color: var(--slate-600); border: var(--border);
}
.badge-emerald { background: var(--emerald-tint); color: var(--emerald-darker); border-color: var(--emerald-light); }
.badge-navy { background: var(--navy); color: var(--white); border-color: var(--navy); }
.badge-warning { background: var(--warning-light); color: var(--warning-dark); border-color: #fcd34d; }

.tax-year-note {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-full);
  background: var(--warning-light); border: 1px solid #fcd34d;
  color: var(--warning-dark); font-size: var(--fs-xs); font-weight: 700;
}

/* --------------------------------------------------------------------------
   20. ARTICLE / PROSE CONTENT
   -------------------------------------------------------------------------- */
.prose { max-width: var(--maxw-prose); color: var(--slate); min-width: 0; overflow-wrap: break-word; }
.prose.prose-wide { max-width: none; }
.prose h2 { margin-top: var(--sp-12); padding-top: var(--sp-2); }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: var(--sp-8); }
.prose ul, .prose ol { margin-bottom: var(--sp-5); }
.prose li { line-height: 1.65; }
.prose .table-wrap { margin-bottom: var(--sp-6); }
.prose blockquote {
  margin: var(--sp-6) 0; padding: var(--sp-4) var(--sp-5);
  border-left: 4px solid var(--emerald); background: var(--emerald-tint);
  border-radius: 0 var(--r) var(--r) 0; color: var(--slate);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.formula {
  display: block; max-width: 100%; padding: var(--sp-4) var(--sp-5); margin: var(--sp-5) 0;
  background: var(--navy); color: #e2e8f0; border-radius: var(--r);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.7;
  overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch;
}
.key-points {
  list-style: none; padding: var(--sp-5); margin: 0 0 var(--sp-6);
  background: var(--white); border: var(--border); border-radius: var(--r-lg);
}
.key-points li { display: flex; gap: var(--sp-3); font-size: var(--fs-sm); }
.key-points li::before { content: "\2713"; color: var(--emerald-dark); font-weight: 800; flex: none; }

.toc { padding: var(--sp-5); background: var(--white); border: var(--border); border-radius: var(--r-lg); }
.toc h2 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: var(--sp-3); color: var(--slate-500); }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li { margin-bottom: var(--sp-2); font-size: var(--fs-sm); }

.related-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.related-card {
  display: block; padding: var(--sp-4); background: var(--white);
  border: var(--border); border-radius: var(--r); text-decoration: none; color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.related-card:hover { border-color: var(--emerald); box-shadow: var(--sh-sm); color: inherit; }
.related-card strong { display: block; color: var(--navy); font-size: var(--fs-sm); margin-bottom: 3px; }
.related-card span { font-size: var(--fs-xs); color: var(--slate-500); }

/* --------------------------------------------------------------------------
   21. AD SLOTS
   -------------------------------------------------------------------------- */
.ad-slot { margin-block: var(--sp-8); }
.ad-slot-inner {
  display: grid; place-items: center; min-height: 96px;
  border: 1px dashed var(--slate-300); border-radius: var(--r);
  background: var(--slate-100); color: var(--slate-400);
  font-size: var(--fs-xs); letter-spacing: 0.09em; text-transform: uppercase; font-weight: 600;
}
.ad-label { display: block; font-size: var(--fs-xs); color: var(--slate-400); text-transform: uppercase; letter-spacing: 0.09em; margin-bottom: var(--sp-2); font-weight: 600; }

/* --------------------------------------------------------------------------
   22. UTILITIES
   -------------------------------------------------------------------------- */
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mt-10 { margin-top: var(--sp-10); }
.mt-12 { margin-top: var(--sp-12); }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* --------------------------------------------------------------------------
   23. PRINT
   -------------------------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .calc-actions, .ad-slot, .nav-toggle,
  .breadcrumb, .toast-region, .modal-backdrop, .chart-tabs, .skip-link { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, .calc-panel, .result-primary { border: 1px solid #999; box-shadow: none; break-inside: avoid; }
  .table-limit { max-height: none; overflow: visible; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}
