:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #eceef8;
  --field-bg: #ffffff;
  --text: #1a1c2e;
  --muted: #4b5069;
  --line: #d5d8ea;
  --field-line: #6b7090; /* control borders keep at least 3:1 against their background */
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #e9eafc;
  --focus: #4338ca;
  --warn: #8a4b08;
  --warn-soft: #fdf3e0;
  --error: #b42318;
  --ok: #146c43;
  --radius: 12px;
  --tap: 44px;
  --shadow: 0 1px 2px rgb(20 20 60 / 0.06), 0 2px 8px rgb(20 20 60 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11121c;
    --surface: #1a1b2b;
    --surface-2: #242639;
    --field-bg: #242639;
    --text: #e9ebf8;
    --muted: #a9aecb;
    --line: #34374f;
    --field-line: #8087ab;
    --accent: #a5b4fc;
    --accent-ink: #11121c;
    --accent-soft: #272a52;
    --focus: #c7d2fe;
    --warn: #fbbf24;
    --warn-soft: #2b2416;
    --error: #ff8a80;
    --ok: #6ee7b7;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: break-word;
}

h1, h2, h3 { text-wrap: balance; }
.lead { text-wrap: pretty; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1080px; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 20; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 8px; }
main:focus { outline: none; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header > .wrap { display: flex; align-items: center; min-height: 56px; max-width: 1080px; }
.logo { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.01em; }
.logo svg { color: var(--accent); flex: none; }
.logo-arrow { stroke: var(--accent-ink); }
.site-nav { border-top: 1px solid var(--line); }
.site-nav .wrap { display: flex; flex-wrap: wrap; gap: 0 4px; padding-top: 2px; padding-bottom: 2px; max-width: 1080px; }
.site-nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 0.92rem; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* Text */
main { padding-bottom: 56px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; margin-top: 4px; font-size: 0.88rem; color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; min-height: var(--tap); min-width: var(--tap); color: var(--muted); }
h1 { font-size: 1.85rem; line-height: 1.25; margin: 20px 0 8px; letter-spacing: -0.01em; }
.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 20px; }
h2 { font-size: 1.3rem; line-height: 1.35; margin: 44px 0 12px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
h3 { font-size: 1.07rem; line-height: 1.4; margin: 28px 0 8px; }
p, ul, ol { margin: 0 0 14px; }
li { margin-bottom: 6px; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
strong { font-weight: 700; }
.note { font-size: 0.9rem; color: var(--muted); }
.hint { font-size: 0.86rem; color: var(--muted); margin: 0; line-height: 1.5; }
.hint:empty { display: none; }
.meta { font-size: 0.88rem; color: var(--muted); margin-top: 36px; }
.callout { background: var(--warn-soft); border-left: 4px solid var(--warn); padding: 10px 14px; border-radius: 6px; font-size: 0.95rem; margin: 16px 0; }
.estimate-note { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; font-size: 0.9rem; margin: 14px 0 0; }
.sources ul { font-size: 0.95rem; }
.contact-mail { font-size: 1.25rem; font-weight: 700; }
.tool-intro { color: var(--muted); }

/* Focus */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: 0; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
caption { text-align: left; font-weight: 700; padding: 0 0 6px; color: var(--text); }
th, td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
thead th { background: var(--surface-2); font-weight: 700; }
tbody th { font-weight: 500; background: var(--surface); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; margin: 0 0 20px; border-radius: 6px; }
.table-scroll:focus-visible { outline-offset: 0; }
.table-scroll table { min-width: 100%; }
.nw { white-space: nowrap; }
@media (min-width: 600px) { .date { white-space: nowrap; } }
.cell-note { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); line-height: 1.4; }
.above { color: var(--ok); font-weight: 600; }
.below { color: var(--muted); }
.indent { padding-left: 18px; color: var(--muted); }

/* Cards */
.tool { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 20px; }
.tool > h2:first-child { margin-top: 0; font-size: 1.15rem; border: 0; padding: 0; }
.tool .table-scroll:last-child { margin-bottom: 0; }

/* Form controls */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset[hidden] { display: none; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 16px; margin: 0 0 16px; display: flex; flex-direction: column; gap: 14px; }
.group > legend { float: left; width: 100%; padding: 0; margin: 0 0 2px; font-size: 1.1rem; font-weight: 700; line-height: 1.35; }
.group > legend + * { clear: both; }
.radios > legend { float: none; padding: 0; font-size: 0.95rem; font-weight: 600; margin-bottom: 2px; }
.radios { display: flex; flex-direction: column; gap: 2px; }
label { font-size: 0.95rem; font-weight: 600; }
input[type="text"], select {
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid var(--field-line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: var(--tap);
  width: 100%;
  font-variant-numeric: tabular-nums;
}
select { padding-right: 6px; text-overflow: ellipsis; }
input::placeholder { color: var(--muted); opacity: 0.85; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-meta { display: flex; flex-direction: column-reverse; gap: 1px; }
.lvl { font-size: 0.88rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.field-error { margin: 0; font-size: 0.88rem; font-weight: 600; color: var(--error); }
.field-error[hidden] { display: none; }
.scores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.scores[hidden] { display: none; }
#clb-form { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 560px) { .scores { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.radio, .check { display: flex; align-items: flex-start; gap: 10px; min-height: var(--tap); padding: 8px 0; font-weight: 400; font-size: 1rem; cursor: pointer; line-height: 1.4; }
.radio input, .check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.check-field { display: flex; flex-direction: column; }
.check-field .hint { margin: -6px 0 6px 32px; }
.btn { font: inherit; font-size: 0.95rem; font-weight: 600; border-radius: 8px; border: 1px solid var(--field-line); background: var(--surface); color: var(--text); padding: 8px 14px; min-height: var(--tap); cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* Result */
.result { margin-top: 12px; background: var(--accent-soft); border-radius: 10px; padding: 14px 16px; }
.result:empty { min-height: 72px; }
.result-main { font-size: 2.8rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--text); }
.result-main small { display: block; font-size: 0.95rem; font-weight: 500; color: var(--muted); margin-top: 2px; }
.result dl { display: grid; grid-template-columns: fit-content(55%) minmax(0, 1fr); gap: 6px 14px; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); font-size: 0.95rem; }
.result dt { color: var(--muted); }
.result dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 0; }
.result dd small { display: block; font-weight: 400; font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.result .err { margin: 0; color: var(--error); font-weight: 700; }
.result-empty { margin: 0; color: var(--muted); }
.result-note { margin: 12px 0 0; font-size: 0.9rem; line-height: 1.5; }
.result-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* Calculator layout */
.calc-layout { display: block; }
.calc-form { margin-bottom: 4px; }
.calc-side { margin-bottom: 8px; }
.calc-side .tool { margin-bottom: 0; }
.score-bar { display: flex; align-items: center; gap: 10px; position: sticky; bottom: 8px; z-index: 5; min-height: 56px; padding: 6px 16px; margin: 8px 0 20px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); text-decoration: none; box-shadow: 0 4px 16px rgb(0 0 0 / 0.25); }
.score-bar strong { font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.score-bar-link { margin-left: auto; font-weight: 700; text-decoration: underline; }
.score-bar:focus-visible { outline-color: var(--text); }
.score-bar.is-empty strong { opacity: 0.85; }
@media (min-width: 960px) {
  .calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
  .calc-side { position: sticky; top: 16px; margin-bottom: 0; }
  .score-bar { display: none; }
  /* the side card is only 360px wide, so stack the breakdown like on a phone */
  .calc-side .result dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .calc-side .result dt { margin-top: 10px; }
  .calc-side .result dd { font-size: 1.05rem; }
}

/* Next step: a quiet card after a tool, with one button-style link */
.next-step { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 16px 14px; margin: 0 0 20px; }
.next-step p { margin: 0; }
.next-step-label { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.next-step-title { margin-top: 2px; font-weight: 700; }
.next-step-text { margin: 2px 0 10px; font-size: 0.95rem; }
.next-step-cta { display: inline-flex; align-items: center; justify-content: center; text-align: center; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.next-step-cta:hover { background: var(--accent); filter: brightness(1.12); }

/* Lists, FAQ */
.tool-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tool-list li { margin: 0; }
.tool-list a { display: block; height: 100%; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); }
.tool-list a:hover { border-color: var(--accent); }
.tool-list strong { display: block; color: var(--accent); }
.tool-list span { display: block; font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
.faq details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 8px; }
.faq summary { cursor: pointer; padding: 10px 14px; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; }
.faq details > div { padding: 0 14px 4px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 20px 0 28px; font-size: 0.9rem; color: var(--muted); }
.site-footer .wrap { max-width: 1080px; }
.site-footer p { margin: 0 0 6px; }
.site-footer a { color: var(--muted); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 14px; }
.footer-links a { display: inline-flex; align-items: center; min-height: var(--tap); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 480px) {
  h1 { font-size: 1.55rem; }
  .result-main { font-size: 2.4rem; }
  .result dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .result dt { margin-top: 10px; }
  .result dd { font-size: 1.05rem; }
  th, td { padding: 6px 8px; }
  .next-step-cta { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .tool-list a, .site-nav a { transition: background-color 0.15s, border-color 0.15s; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .site-nav, .related, .site-footer, .btn-row, .result-actions, .skip-link, .score-bar, .next-step { display: none !important; }
  body { background: #fff; color: #000; }
  .group, .tool { box-shadow: none; }
}
