/* =========================================================================
   everyday finance calc — stylesheet
   Mobile-first.  Two themes driven by [data-theme] on <html>.
   No external fonts or assets: the page works offline.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Noto Sans", sans-serif;
  --font-serif: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg:          #f4f6fb;
  --bg-alt:      #eceff7;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #eef2f9;
  --ink:         #101828;
  --ink-2:       #475467;
  --ink-3:       #6b7a90;
  --line:        #dfe4ee;
  --line-strong: #c6cede;

  --brand:       #2563eb;
  --brand-dark:  #1d4ed8;
  --brand-soft:  #e7efff;
  --accent:      #0d9488;
  --good:        #059669;
  --good-soft:   #dcfce7;
  --warn:        #b45309;
  --warn-soft:   #fef3c7;
  --bad:         #dc2626;
  --bad-soft:    #fee2e2;

  --radius:      14px;
  --radius-sm:   9px;
  --shadow-sm:   0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.05);
  --shadow:      0 4px 6px -2px rgba(16,24,40,.05), 0 12px 20px -6px rgba(16,24,40,.10);
  --shadow-lg:   0 20px 40px -12px rgba(16,24,40,.22);

  --header-h:    62px;
  --maxw:        1500px;
}

html[data-theme="dark"] {
  --bg:          #0b1120;
  --bg-alt:      #0e1626;
  --surface:     #121c2e;
  --surface-2:   #16233a;
  --surface-3:   #1c2b45;
  --ink:         #e8eefb;
  --ink-2:       #a6b4cc;
  --ink-3:       #8494ae;
  --line:        #23324c;
  --line-strong: #33445f;

  --brand:       #5b93ff;
  --brand-dark:  #7aa9ff;
  --brand-soft:  #16294b;
  --accent:      #2dd4bf;
  --good:        #34d399;
  --good-soft:   #0d3b2f;
  --warn:        #fbbf24;
  --warn-soft:   #402d0b;
  --bad:         #f87171;
  --bad-soft:    #3d1417;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
  --shadow:      0 6px 18px -6px rgba(0,0,0,.55);
  --shadow-lg:   0 24px 48px -16px rgba(0,0,0,.7);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: clamp(1.6rem, 4.2vw, 2.3rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.55rem); }
h3 { font-size: 1.08rem; }
p  { margin: 0 0 1em; }
a  { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-3);
       padding: .1em .35em; border-radius: 4px; }
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--brand); color: #fff; padding: .7rem 1.1rem;
  border-radius: 0 0 var(--radius-sm) 0; font-weight: 600;
}
.skip-link:focus { left: 0; color: #fff; }

/* =========================================================================
   Header
   ========================================================================= */
.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem clamp(.7rem, 2vw, 1.4rem);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit;
         margin-right: auto; min-width: 0; }
.brand-mark { width: 32px; height: 32px; flex: none; color: var(--brand); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1.02rem; letter-spacing: -.02em; white-space: nowrap; }
.brand-text small { color: var(--ink-3); font-size: .72rem; white-space: nowrap;
                    overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .brand-text small { display: none; } }

.header-tools { display: flex; align-items: center; gap: .5rem; }
.search-wrap { position: relative; display: none; }
.search-wrap .search-icon { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%);
                            width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
#calcSearch {
  font: inherit; font-size: .9rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: .48rem .8rem .48rem 2.05rem; width: 230px;
  transition: width .18s ease, border-color .18s ease;
}
#calcSearch:focus { width: 280px; border-color: var(--brand); outline: none;
                    box-shadow: 0 0 0 3px var(--brand-soft); }
@media (min-width: 700px) { .search-wrap { display: block; } }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 10px; cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: block; }

.nav-toggle {
  display: inline-flex; align-items: center; gap: .45rem;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 10px; padding: .45rem .65rem; font: inherit; font-size: .85rem;
  font-weight: 600; cursor: pointer;
}
.nav-toggle-text { display: none; }
.burger, .burger::before, .burger::after {
  display: block; width: 17px; height: 2px; background: currentColor; border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5.5px; }
.burger::after  { top: 5.5px; }
.nav-toggle[aria-expanded="true"] .burger { background: transparent; }
.nav-toggle[aria-expanded="true"] .burger::before { transform: translateY(5.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .burger::after  { transform: translateY(-5.5px) rotate(-45deg); }
@media (min-width: 1060px) { .nav-toggle { display: none; } }

/* =========================================================================
   Advertising slots — space is reserved so content never jumps
   ========================================================================= */
.ad-rail { display: flex; justify-content: center; padding: .85rem clamp(.7rem, 2vw, 1.4rem); }
.ad-rail.inline { padding-inline: 0; }
.ad-slot {
  position: relative; width: 100%;
  background: repeating-linear-gradient(135deg,
              var(--surface-2), var(--surface-2) 11px,
              var(--surface-3) 11px, var(--surface-3) 22px);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  display: grid; place-items: center; overflow: hidden;
}
.ad-label {
  position: absolute; top: 5px; left: 8px;
  font-size: .58rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.ad-inner { display: grid; place-items: center; width: 100%; height: 100%; }
.ad-placeholder { color: var(--ink-3); font-size: .78rem; text-align: center; line-height: 1.4; }
/* Reserved sizes (min-height prevents cumulative layout shift) */
.ad-leaderboard { max-width: 728px; min-height: 100px; }
@media (min-width: 760px) { .ad-leaderboard { min-height: 90px; } }
.ad-rectangle   { max-width: 336px; min-height: 280px; }
.ad-skyscraper  { display: none; max-width: 300px; min-height: 600px; margin-top: 1.25rem; }
@media (min-width: 1060px) { .ad-skyscraper { display: grid; } }

/* =========================================================================
   Layout: sidebar + main
   ========================================================================= */
.layout {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: clamp(1rem, 2vw, 1.8rem);
  padding: 0 clamp(.7rem, 2vw, 1.4rem) 2.5rem;
}
@media (min-width: 1060px) {
  .layout { grid-template-columns: 268px minmax(0, 1fr); align-items: start; }
}

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 80;
  width: min(84vw, 320px);
  background: var(--surface); border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .24s ease;
  box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }
.sidebar-scroll { height: 100%; overflow-y: auto; padding: 1rem .85rem 2.5rem;
                  overscroll-behavior: contain; }
@media (min-width: 1060px) {
  .sidebar {
    position: sticky; top: calc(var(--header-h) + 12px); inset: auto;
    width: auto; transform: none; box-shadow: none; background: transparent;
    border-right: 0; max-height: calc(100vh - var(--header-h) - 28px);
  }
  .sidebar-scroll { padding: 0 .25rem 1rem 0; }
}
.nav-scrim {
  position: fixed; inset: 0; z-index: 70; background: rgba(8,14,26,.5);
  backdrop-filter: blur(2px);
}
@media (min-width: 1060px) { .nav-scrim { display: none !important; } }

.side-home {
  display: block; font-size: .82rem; font-weight: 600; color: var(--ink-3);
  text-decoration: none; padding: .35rem .55rem .7rem;
}
.side-home:hover { color: var(--brand); }
@media (min-width: 1060px) { .side-home { display: none; } }

.nav-group { margin-bottom: 1.05rem; }
.nav-group-title {
  font-size: .66rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 800; padding: 0 .55rem .3rem;
}
.nav-link {
  display: flex; align-items: center; gap: .55rem;
  padding: .46rem .55rem; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-size: .875rem; line-height: 1.3;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--surface-3); color: var(--ink); }
.nav-link.active {
  background: var(--brand-soft); color: var(--brand-dark);
  font-weight: 650; border-left-color: var(--brand);
}
html[data-theme="dark"] .nav-link.active { color: var(--brand-dark); }
.nav-icon { width: 17px; height: 17px; flex: none; color: var(--ink-3); }
.nav-link:hover .nav-icon { color: var(--brand); }
.nav-link.active .nav-icon { color: var(--brand); }
.nav-group.filtered-out, .nav-link.filtered-out { display: none; }
.nav-empty { padding: .6rem .55rem; color: var(--ink-3); font-size: .85rem; }

/* =========================================================================
   Panels
   ========================================================================= */
.main { min-width: 0; padding-top: .4rem; }
.panel[hidden] { display: none; }
.panel { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Hero ---------- */
.hero { padding: 1.4rem 0 1.1rem; }
.hero h1 { font-family: var(--font-serif); font-size: clamp(1.75rem, 5vw, 2.7rem);
           letter-spacing: -.02em; max-width: 22ch; }
.hero-sub { color: var(--ink-2); font-size: clamp(1rem, 2.1vw, 1.1rem); max-width: 68ch; }
.hero-badges { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge {
  font-size: .74rem; font-weight: 650; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  padding: .25rem .6rem; border-radius: 999px;
}

/* ---------- Callouts ---------- */
.callout {
  border: 1px solid var(--line); border-left: 4px solid var(--brand);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: .85rem 1rem; margin: 0 0 1.4rem; font-size: .92rem; color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--ink); }
.callout-warn { border-left-color: var(--warn); background: var(--warn-soft); }
html[data-theme="dark"] .callout-warn { color: #f3e3c0; }
html[data-theme="dark"] .callout-warn strong { color: #fff3d6; }
.callout-info { border-left-color: var(--brand); background: var(--brand-soft); }

/* ---------- Home grid of calculator cards ---------- */
.home-group { margin-bottom: 2rem; }
.home-group-head { display: flex; align-items: baseline; gap: .7rem; margin-bottom: .7rem;
                   border-bottom: 1px solid var(--line); padding-bottom: .45rem; }
.home-group-head h2 { margin: 0; }
.home-group-head span { color: var(--ink-3); font-size: .8rem; }
.card-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.calc-card {
  display: flex; flex-direction: column; gap: .3rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .95rem 1rem; text-decoration: none; color: inherit;
  box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .16s ease,
                                             border-color .16s ease;
}
.calc-card:hover { transform: translateY(-2px); box-shadow: var(--shadow);
                   border-color: var(--brand); color: inherit; }
.calc-card-top { display: flex; align-items: center; gap: .6rem; }
.calc-card-icon {
  width: 34px; height: 34px; flex: none; padding: 7px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand);
}
.calc-card:hover .calc-card-icon { background: var(--brand); color: #fff; }
.calc-card h3 { margin: 0; font-size: 1rem; }
.calc-card p { margin: 0; font-size: .85rem; color: var(--ink-2); line-height: 1.45; }

/* ---------- FAQ ---------- */
.faq { margin-top: 2.4rem; }
.faq-item { background: var(--surface); border: 1px solid var(--line);
            border-radius: var(--radius-sm); margin-bottom: .55rem; }
.faq-item summary { cursor: pointer; padding: .8rem 1rem; font-weight: 620; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--ink-3); font-weight: 700; }
.faq-item[open] summary::after { content: "–"; }
.faq-item .faq-body { padding: 0 1rem 1rem; color: var(--ink-2); font-size: .92rem; }
.faq-item .faq-body p:last-child { margin-bottom: 0; }

/* =========================================================================
   Calculator panel internals
   ========================================================================= */
.calc-head { padding: 1.1rem 0 .9rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.crumb { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em;
         color: var(--ink-3); font-weight: 800; margin-bottom: .3rem; }
.calc-head h1 { margin-bottom: .35rem; }
.calc-title { display: flex; align-items: center; gap: .6rem; }
.calc-title-icon {
  width: 40px; height: 40px; flex: none; padding: 8px; border-radius: 11px;
  background: var(--brand-soft); color: var(--brand);
}
@media (max-width: 520px) { .calc-title-icon { width: 32px; height: 32px; padding: 6px; } }
.calc-lede { color: var(--ink-2); max-width: 72ch; margin: 0; }

.calc-body { display: grid; gap: 1.2rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 940px) {
  .calc-body { grid-template-columns: minmax(300px, 350px) minmax(0, 1fr); }
  .calc-inputs { position: sticky; top: calc(var(--header-h) + 12px); }
}

/* ---------- Inputs ---------- */
.calc-inputs {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow-sm);
}
.inputs-head { display: flex; align-items: center; justify-content: space-between;
               gap: .5rem; margin-bottom: .7rem; }
.inputs-head h2 { margin: 0; font-size: .95rem; text-transform: uppercase;
                  letter-spacing: .08em; color: var(--ink-3); }
.btn {
  font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  padding: .35rem .7rem; border-radius: 8px;
}
.btn:hover { background: var(--surface-3); color: var(--ink); }
.btn-icon { display: inline-flex; align-items: center; gap: .4rem; }
.btn-icon svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.field-set { border: 0; margin: 0 0 .9rem; padding: 0; }
.field-set legend {
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 800;
  color: var(--ink-3); padding: 0; margin-bottom: .45rem;
}
.field { margin-bottom: .8rem; }
.field > label, .field-label {
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
  font-size: .84rem; font-weight: 620; color: var(--ink); margin-bottom: .28rem;
}
.field-note { font-weight: 500; color: var(--ink-3); font-size: .76rem; text-align: right; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .affix {
  position: absolute; color: var(--ink-3); font-size: .88rem; pointer-events: none;
  font-weight: 600;
}
.input-wrap .affix-pre  { left: .68rem; }
.input-wrap .affix-post { right: .68rem; }
.field input[type="number"], .field input[type="text"], .field select {
  font: inherit; font-size: .95rem; font-variant-numeric: tabular-nums;
  width: 100%; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .52rem .68rem; min-height: 42px;
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button, .field input::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
/* Room for the $ / % affixes.  Declared after the shorthand `padding` above so
   it is not silently overridden by it. */
.field .input-wrap.has-pre  input { padding-left: 1.7rem; }
.field .input-wrap.has-post input { padding-right: 2.7rem; }
.field .input-wrap.has-post input.affix-wide { padding-right: 3.6rem; }
.field input:focus, .field select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 19px, calc(100% - 10px) 19px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.field input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: transparent; cursor: pointer; margin: .25rem 0 0; padding: 0;
  min-height: 0; border: 0;
}
.field input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px; background: var(--surface-3);
  border: 1px solid var(--line);
}
.field input[type="range"]::-moz-range-track {
  height: 5px; border-radius: 3px; background: var(--surface-3); border: 1px solid var(--line);
}
.field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--surface); margin-top: -7px;
  box-shadow: var(--shadow-sm);
}
.field input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--brand);
  border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
.field .help { font-size: .76rem; color: var(--ink-3); margin: .28rem 0 0; line-height: 1.4; }
.field .help.live-note { font-style: italic; }
.field.invalid input { border-color: var(--bad); }
.field-error { margin: .3rem 0 0; font-size: .8rem; color: var(--bad); }
.field-error[hidden] { display: none; }
.calc-notice { margin: 0 0 1rem; }
.calc-notice[hidden] { display: none; }
.check-field { display: flex; align-items: flex-start; gap: .55rem; }
.check-field input { width: 18px; height: 18px; min-height: 0; margin-top: .18rem; accent-color: var(--brand); }
.check-field label { font-size: .86rem; font-weight: 600; display: block; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.grid-2 .field { margin-bottom: 0; }

/* Repeating rows (debt list) */
.row-table { width: 100%; border-collapse: collapse; font-size: .82rem;
             table-layout: fixed; }
.row-table th { text-align: left; font-size: .62rem; text-transform: uppercase;
                letter-spacing: .05em; color: var(--ink-3); padding: 0 .15rem .25rem;
                font-weight: 800; }
.row-table th:nth-child(1) { width: 34%; }
.row-table th:nth-child(2) { width: 25%; }
.row-table th:nth-child(3) { width: 19%; }
.row-table th:nth-child(4) { width: 22%; }
.row-table td { padding: .1rem .15rem; }
.row-table input { font: inherit; font-size: .8rem; width: 100%; color: var(--ink);
                   background: var(--surface-2); border: 1px solid var(--line-strong);
                   border-radius: 7px; padding: .35rem .3rem; min-height: 34px;
                   text-align: right; }
.row-table td:first-child input { text-align: left; }
.row-table input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

/* ---------- Results ---------- */
.calc-results { min-width: 0; display: grid; gap: 1.1rem; grid-template-columns: minmax(0, 1fr); }
.metric-grid { display: grid; gap: .65rem; min-width: 0;
                grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.metric {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem .9rem; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.metric::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
                  background: var(--line-strong); }
.metric.hero-metric { grid-column: span 2; }
@media (max-width: 520px) { .metric.hero-metric { grid-column: span 1; } }
.metric.hero-metric .metric-value { font-size: clamp(1.5rem, 6vw, 2rem); }
.metric.tone-good::before { background: var(--good); }
.metric.tone-warn::before { background: var(--warn); }
.metric.tone-bad::before  { background: var(--bad); }
.metric.tone-brand::before { background: var(--brand); }
.metric-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
                color: var(--ink-3); font-weight: 750; }
.metric-value { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums;
                letter-spacing: -.02em; margin-top: .1rem; }
.metric.tone-good .metric-value { color: var(--good); }
.metric.tone-bad  .metric-value { color: var(--bad); }
.metric.tone-warn .metric-value { color: var(--warn); }
.metric-sub { font-size: .78rem; color: var(--ink-3); margin-top: .12rem; line-height: 1.35; }

.result-block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow-sm); min-width: 0; overflow: hidden;
}
.result-block > h3 { font-size: .95rem; margin-bottom: .1rem; }
.result-block > .block-note { font-size: .82rem; color: var(--ink-3); margin: 0 0 .7rem; }

.verdict { display: flex; gap: .7rem; align-items: flex-start; padding: .85rem 1rem;
           border-radius: var(--radius); border: 1px solid var(--line);
           background: var(--surface-2); font-size: .92rem; }
.verdict .v-icon { flex: none; display: grid; place-items: center; margin-top: 1px; }
.verdict .v-icon svg { width: 21px; height: 21px; }
.verdict.good .v-icon { color: var(--good); }
.verdict.warn .v-icon { color: var(--warn); }
.verdict.bad  .v-icon { color: var(--bad); }
.verdict:not(.good):not(.warn):not(.bad) .v-icon { color: var(--brand); }
.verdict.good { background: var(--good-soft); border-color: transparent; }
.verdict.warn { background: var(--warn-soft); border-color: transparent; }
.verdict.bad  { background: var(--bad-soft);  border-color: transparent; }
.verdict p { margin: 0; }
.verdict strong { display: block; margin-bottom: .1rem; }
html[data-theme="dark"] .verdict.good, html[data-theme="dark"] .verdict.warn,
html[data-theme="dark"] .verdict.bad { color: var(--ink); }

.chart-pair { display: grid; gap: 1.1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1280px) {
  .chart-pair.two-up { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- Data table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -.4rem; padding: 0 .4rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .84rem;
             font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th, table.data td { padding: .42rem .6rem; text-align: right;
                               border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 800; border-bottom: 2px solid var(--line-strong);
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; }
.table-actions { display: flex; justify-content: space-between; align-items: center;
                 gap: .6rem; margin-top: .6rem; flex-wrap: wrap; }
.table-actions .hint { font-size: .78rem; color: var(--ink-3); margin: 0; }

/* ---------- Explanation ---------- */
.explain { background: var(--surface); border: 1px solid var(--line);
           border-radius: var(--radius); overflow: hidden; }
.explain > summary {
  cursor: pointer; padding: .85rem 1rem; font-weight: 680; list-style: none;
  display: flex; align-items: center; gap: .5rem;
}
.explain > summary::-webkit-details-marker { display: none; }
.explain-icon { width: 18px; height: 18px; flex: none; color: var(--brand); }
.explain > summary::after { content: "Show"; margin-left: auto; font-size: .78rem;
                            font-weight: 600; color: var(--brand); }
.explain[open] > summary::after { content: "Hide"; }
.explain .prose { padding: 0 1rem 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }

.prose { color: var(--ink-2); font-size: .93rem; max-width: 78ch; }
.prose h2 { font-size: 1.1rem; color: var(--ink); margin-top: 1.5rem; }
.prose h3 { font-size: .97rem; color: var(--ink); margin-top: 1.2rem; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.15rem; margin: 0 0 1em; }
.prose li { margin-bottom: .3rem; }
.prose .formula {
  display: block; font-family: var(--font-mono); font-size: .85rem; background: var(--surface-2);
  border: 1px solid var(--line); border-left: 3px solid var(--brand);
  padding: .7rem .85rem; border-radius: var(--radius-sm); margin: .8rem 0;
  overflow-x: auto; white-space: pre; color: var(--ink);
}
.prose dl { margin: 0 0 1em; }
.prose dt { font-weight: 650; color: var(--ink); margin-top: .6rem; }
.prose dd { margin: .1rem 0 0; }

/* =========================================================================
   Charts
   ========================================================================= */
.chart { width: 100%; min-width: 0; }
.chart-title { font-size: .9rem; margin: 0 0 .2rem; color: var(--ink); }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-caption { font-size: .78rem; color: var(--ink-3); margin: .5rem 0 0; line-height: 1.45; }
.chart-empty { font-size: .85rem; color: var(--ink-3); padding: 2rem 0; text-align: center; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-grid.vertical { stroke-dasharray: 3 4; opacity: .65; }
.chart-axis { stroke: var(--line-strong); stroke-width: 1; }
.chart-zero { stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .8; }
.chart-tick { font-size: 11px; fill: var(--ink-3); font-family: var(--font-sans);
              font-variant-numeric: tabular-nums; }
.chart-axis-label { font-size: 11.5px; fill: var(--ink-3); font-weight: 700;
                    font-family: var(--font-sans); letter-spacing: .04em; }
.chart-marker { stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-marker-label { font-size: 11px; font-weight: 700; font-family: var(--font-sans); }
.chart-hover-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-overlay { cursor: crosshair; }
.chart-bar { transition: opacity .15s ease; }
.chart-slice { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.donut-center-value { font-size: 17px; font-weight: 800; fill: var(--ink);
                      font-family: var(--font-sans); }
.donut-center-sub { font-size: 10.5px; fill: var(--ink-3); font-family: var(--font-sans);
                    text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }

.chart-legend { display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin-top: .55rem;
                font-size: .78rem; color: var(--ink-2); }
.chart-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.chart-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.chart-swatch.dashed { background-image: linear-gradient(90deg,
                        rgba(255,255,255,.85) 40%, transparent 40%); }
.donut-legend { flex-direction: column; gap: .25rem; }

.chart-tooltip {
  position: fixed; z-index: 300; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: .5rem .65rem;
  font-size: .8rem; font-family: var(--font-sans); min-width: 130px;
  font-variant-numeric: tabular-nums;
}
.chart-tooltip .tt-head { font-weight: 750; margin-bottom: .25rem; font-size: .78rem;
                          color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: .4rem; line-height: 1.5; }
.chart-tooltip .tt-row i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.chart-tooltip .tt-name { flex: 1; color: var(--ink-2); }
.chart-tooltip .tt-val { font-weight: 700; }
.chart-tooltip .tt-extra { margin-top: .3rem; padding-top: .3rem; border-top: 1px solid var(--line);
                           color: var(--ink-3); font-size: .74rem; }

/* =========================================================================
   Footer
   ========================================================================= */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-alt); margin-top: 1rem; }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 1.6rem clamp(.9rem, 2vw, 1.4rem) .8rem;
  display: grid; gap: 1.4rem; grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 700px) {
  .footer-inner { grid-template-columns: 2fr 1fr 1fr; gap: 2rem; }
}
.footer-col h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em;
                 color: var(--ink-3); font-weight: 800; margin-bottom: .6rem; }
.footer-note { font-size: .86rem; color: var(--ink-2); max-width: 46ch; margin: 0; }
.footer-note.data-stamp { margin-top: .6rem; font-size: .78rem; color: var(--ink-3); }
.footer-note.data-stamp:empty { display: none; }
.footer-links { list-style: none; margin: 0; padding: 0; }
.footer-links li { margin-bottom: .3rem; }
.footer-links a { font-size: .86rem; color: var(--ink-2); text-decoration: none; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }

.footer-disclaimer {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 clamp(.9rem, 2vw, 1.4rem) .4rem;
}
.footer-disclaimer p {
  font-size: .8rem; color: var(--ink-3); line-height: 1.55; margin: 0;
  border-top: 1px solid var(--line); padding-top: .9rem; max-width: 100ch;
}
.footer-bottom {
  max-width: var(--maxw); margin: 0 auto;
  padding: .9rem clamp(.9rem, 2vw, 1.4rem) 1.6rem;
  display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; justify-content: space-between;
}
.footer-bottom p { margin: 0; font-size: .8rem; color: var(--ink-3); }
.copyright { font-weight: 600; }

/* ---------- Back to top ---------- */
.to-top {
  position: fixed; right: 14px; bottom: 14px; z-index: 55;
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font-size: 1.1rem; box-shadow: var(--shadow); display: grid; place-items: center;
}
.to-top:hover { color: var(--brand); border-color: var(--brand); }
.to-top[hidden] { display: none; }

/* ---------- Consent bar (Google Consent Mode / analytics preferences) ---------- */
.consent-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 120;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 32px rgba(16,24,40,.14);
  padding: .8rem clamp(.8rem, 2.4vw, 1.4rem) calc(.8rem + env(safe-area-inset-bottom, 0));
}
.consent-bar[hidden] { display: none; }
.consent-bar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: .7rem 1rem; flex-wrap: wrap;
}
.consent-text { flex: 1 1 300px; margin: 0; font-size: .86rem; line-height: 1.5; color: var(--ink-2); }
.consent-text strong { color: var(--ink); }
.consent-text a { font-weight: 600; }
.consent-actions { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
/* Both choices look the same: neither is pushed visually (EDPB guidance). */
.consent-btn {
  font-size: .86rem; padding: .5rem 1rem; min-width: 9.5rem;
  border-color: var(--ink-3); background: var(--surface); color: var(--ink);
}
.consent-btn:hover { background: var(--surface-3); color: var(--ink); }
.link-button {
  font: inherit; font-size: inherit; cursor: pointer; padding: 0; border: 0; background: none;
  color: var(--brand); text-decoration: underline; text-underline-offset: 2px;
}
.link-button:hover { color: var(--brand-dark); }
.footer-links .link-button { font-size: .86rem; color: var(--ink-2); text-decoration: none; }
.footer-links .link-button:hover { color: var(--brand); text-decoration: underline; }
#privacy { scroll-margin-top: 80px; }
.consent-change {
  font: inherit; font-size: .82rem; font-weight: 650; cursor: pointer;
  background: none; border: 0; padding: .4rem .25rem; color: var(--brand);
  text-decoration: underline; text-underline-offset: 2px;
}
.consent-change:hover { color: var(--brand-dark); }
/* Keep the back-to-top button clear of the bar while it is showing. */
body.has-consent-bar .to-top { bottom: 84px; }

/* =========================================================================
   Print
   ========================================================================= */
@media print {
  .site-header, .sidebar, .ad-rail, .ad-slot, .to-top, .nav-scrim, .consent-bar,
  .table-actions, .hero-badges { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .calc-body { display: block; }
  .calc-inputs, .result-block, .metric { break-inside: avoid; box-shadow: none; }
  .explain { break-before: page; }
  .explain[open] .prose, .explain .prose { display: block !important; }
  a[href^="#"]::after { content: ""; }
}
