/* Design tokens and components.
 *
 * Hand-rolled rather than a framework: the page must stay small, the CSP
 * allows nothing from a CDN, and a tax product needs about a dozen
 * components, not a design system.
 *
 * The palette is deliberately sober. This page asks people for their income
 * and their property and then charges them; it should look like a document,
 * not a campaign.
 */

:root {
  /* Ink and paper */
  --c-ink: #17222e;
  --c-ink-soft: #4a5866;
  --c-ink-faint: #74818e;
  --c-paper: #ffffff;
  --c-surface: #f6f8fa;
  --c-surface-sunk: #eef1f5;
  --c-border: #d9dfe6;
  --c-border-strong: #b9c3ce;

  /* Brand: deep slate blue, one accent */
  --c-brand: #1d3f5e;
  --c-brand-dark: #142c43;
  --c-brand-tint: #eaf1f7;
  --c-accent: #b4762a;
  --c-accent-tint: #fbf3e6;

  /* Status */
  --c-ok: #1f6b45;
  --c-ok-tint: #eaf5ef;
  --c-warn: #8a5a12;
  --c-warn-tint: #fdf4e4;
  --c-stop: #9a2b2b;
  --c-stop-tint: #fbecec;

  /* Type scale — 1.25 ratio from 16px */
  --t-xs: 0.75rem;
  --t-sm: 0.875rem;
  --t-base: 1rem;
  --t-md: 1.125rem;
  --t-lg: 1.375rem;
  --t-xl: 1.75rem;
  --t-2xl: 2.25rem;

  /* Spacing — 4px base */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;
  --s-8: 4rem;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 2px rgb(23 34 46 / 6%), 0 4px 12px rgb(23 34 46 / 5%);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-num: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 68ch;
  --page: 62rem;
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.6;
  color: var(--c-ink);
  background: var(--c-surface);
}

h1, h2, h3 {
  line-height: 1.25;
  letter-spacing: -0.011em;
  margin: 0 0 var(--s-3);
  font-weight: 650;
}

h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); margin-top: var(--s-6); }
h3 { font-size: var(--t-md); margin-top: var(--s-5); }

p { margin: 0 0 var(--s-4); max-width: var(--measure); }

a { color: var(--c-brand); text-underline-offset: 2px; }
a:hover { color: var(--c-brand-dark); }

small { font-size: var(--t-sm); color: var(--c-ink-soft); }

/* ------------------------------------------------------------- layout */

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--s-4);
}

.page--narrow { max-width: 46rem; }

.site-header {
  background: var(--c-paper);
  border-bottom: 1px solid var(--c-border);
}

.site-header__inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--s-3) var(--s-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
}

.brand {
  font-weight: 680;
  font-size: var(--t-md);
  color: var(--c-brand);
  text-decoration: none;
  letter-spacing: -0.015em;
}

.brand span { color: var(--c-accent); }

.nav { display: flex; gap: var(--s-4); font-size: var(--t-sm); flex-wrap: wrap; }
.nav a { color: var(--c-ink-soft); text-decoration: none; }
.nav a:hover { color: var(--c-brand); text-decoration: underline; }

main { padding: var(--s-6) 0 var(--s-8); }

.site-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-paper);
  padding: var(--s-6) 0;
  font-size: var(--t-sm);
  color: var(--c-ink-soft);
}

.site-footer .nav { margin-bottom: var(--s-3); }

.stack > * + * { margin-top: var(--s-4); }
.stack-lg > * + * { margin-top: var(--s-6); }

/* --------------------------------------------------------------- card */

.card {
  background: var(--c-paper);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow);
}

.card__title { margin-top: 0; }

/* -------------------------------------------------------------- forms */

fieldset { border: 0; margin: 0 0 var(--s-5); padding: 0; }

legend {
  font-weight: 640;
  font-size: var(--t-md);
  padding: 0;
  margin-bottom: var(--s-2);
}

.field { margin-bottom: var(--s-4); }

.field__label {
  display: block;
  font-weight: 560;
  font-size: var(--t-sm);
  margin-bottom: var(--s-1);
}

.field__hint {
  display: block;
  font-size: var(--t-sm);
  color: var(--c-ink-soft);
  margin-bottom: var(--s-2);
  max-width: var(--measure);
}

.field__error {
  display: block;
  font-size: var(--t-sm);
  color: var(--c-stop);
  margin-top: var(--s-1);
  font-weight: 560;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  font: inherit;
  color: var(--c-ink);
  background: var(--c-paper);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
}

input[type="number"] { font-family: var(--font-num); }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
}

.field--invalid input,
.field--invalid select { border-color: var(--c-stop); }

.field__suffix {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.field__suffix span {
  color: var(--c-ink-faint);
  font-size: var(--t-sm);
  white-space: nowrap;
}

.checkbox {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  font-size: var(--t-sm);
  max-width: var(--measure);
}

.checkbox input { margin-top: 0.25rem; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--s-4);
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-block;
  padding: var(--s-3) var(--s-5);
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn--primary { background: var(--c-brand); color: #fff; }
.btn--primary:hover { background: var(--c-brand-dark); color: #fff; }

.btn--secondary {
  background: var(--c-paper);
  color: var(--c-brand);
  border-color: var(--c-border-strong);
}
.btn--secondary:hover { background: var(--c-surface-sunk); }

.btn--ghost {
  background: none;
  border: 0;
  color: var(--c-ink-soft);
  padding: var(--s-2);
  text-decoration: underline;
}

.btn-row {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--s-5);
}

.btn-row--split { justify-content: space-between; }

/* ----------------------------------------------------------- progress */

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  list-style: none;
  margin: 0 0 var(--s-5);
  padding: 0;
  font-size: var(--t-sm);
  counter-reset: step;
}

.steps li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius);
  color: var(--c-ink-faint);
  background: var(--c-surface-sunk);
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--c-border);
  color: var(--c-paper);
  font-size: var(--t-xs);
  font-weight: 700;
  flex: none;
}

.steps li[data-state="done"] { color: var(--c-brand); background: var(--c-brand-tint); }
.steps li[data-state="done"]::before { background: var(--c-brand); }

.steps li[data-state="current"] {
  color: var(--c-paper);
  background: var(--c-brand);
  font-weight: 600;
}
.steps li[data-state="current"]::before { background: var(--c-accent); }

/* ----------------------------------------------------------- callouts */

.callout {
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-border-strong);
  border-radius: var(--radius);
  padding: var(--s-4);
  background: var(--c-surface);
  margin-bottom: var(--s-4);
}

.callout__title { font-weight: 640; margin: 0 0 var(--s-2); }
.callout p:last-child { margin-bottom: 0; }

.callout__citation {
  display: block;
  margin-top: var(--s-2);
  font-size: var(--t-xs);
  color: var(--c-ink-faint);
  font-variant: small-caps;
  letter-spacing: 0.03em;
}

.callout--blocker { border-left-color: var(--c-stop); background: var(--c-stop-tint); }
.callout--blocker .callout__title { color: var(--c-stop); }

.callout--warning { border-left-color: var(--c-warn); background: var(--c-warn-tint); }
.callout--warning .callout__title { color: var(--c-warn); }

.callout--note { border-left-color: var(--c-brand); background: var(--c-brand-tint); }
.callout--note .callout__title { color: var(--c-brand); }

.callout--ok { border-left-color: var(--c-ok); background: var(--c-ok-tint); }
.callout--ok .callout__title { color: var(--c-ok); }

/* ------------------------------------------------------- disclaimer */

.disclaimer {
  font-size: var(--t-sm);
  color: var(--c-ink-soft);
  background: var(--c-surface-sunk);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  max-width: var(--measure);
}

.disclaimer strong { color: var(--c-ink); }

/* ------------------------------------------------------------ tables */

.table-scroll { overflow-x: auto; margin-bottom: var(--s-4); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}

th, td {
  text-align: left;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}

th {
  font-weight: 620;
  color: var(--c-ink-soft);
  background: var(--c-surface);
  white-space: nowrap;
}

td.num, th.num { text-align: right; font-family: var(--font-num); white-space: nowrap; }

tr.is-total td { font-weight: 680; border-top: 2px solid var(--c-border-strong); }

.line-ref {
  font-family: var(--font-num);
  font-size: var(--t-xs);
  color: var(--c-brand);
  background: var(--c-brand-tint);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
}

.line-ref--missing { color: var(--c-warn); background: var(--c-warn-tint); }

/* ------------------------------------------------------------ prices */

.prices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--s-4);
}

.price {
  background: var(--c-paper);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
}

.price[data-selected="true"] {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 2px var(--c-brand-tint);
}

.price__amount {
  font-size: var(--t-2xl);
  font-weight: 680;
  letter-spacing: -0.02em;
}

.price__name { font-weight: 620; margin-bottom: var(--s-1); }
.price__note { font-size: var(--t-sm); color: var(--c-ink-soft); }

/* ------------------------------------------------------ trust badges */

.trust {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  list-style: none;
  margin: var(--s-4) 0 0;
  padding: 0;
  font-size: var(--t-sm);
  color: var(--c-ink-soft);
}

.trust li {
  background: var(--c-paper);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: var(--s-1) var(--s-3);
}

/* --------------------------------------------------------- result kpi */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.kpi {
  background: var(--c-paper);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
}

.kpi__label {
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-ink-faint);
  margin-bottom: var(--s-1);
}

.kpi__value { font-size: var(--t-lg); font-weight: 680; font-family: var(--font-num); }
.kpi__value[data-sign="negative"] { color: var(--c-stop); }

.repeat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: end;
  padding: var(--s-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  margin-bottom: var(--s-3);
  background: var(--c-surface);
}

.htmx-request .btn--primary { opacity: 0.6; pointer-events: none; }

/* ------------------------------------------------------- utilities
 *
 * A deliberately tiny set, existing so templates never need an inline
 * style="" attribute. That keeps the Content Security Policy at
 * style-src 'self' with no 'unsafe-inline', which is the whole point.
 */
.flush-top { margin-top: 0; }
.spaced-top { margin-top: var(--s-4); }
.spaced-top-lg { margin-top: var(--s-5); }
.spaced-bottom { margin-bottom: var(--s-4); }
.lede { font-size: var(--t-md); max-width: 62ch; }
.input--short { max-width: 6rem; }

/* A hint rendered after its input (see the field macro): the spacing flips to
 * the top, and fields in a grid stay aligned because the input is no longer
 * pushed down by a hint of unpredictable height. */
.field__hint--below {
  margin-top: var(--s-1);
  margin-bottom: 0;
}

/* Align grid items to the top so a taller hint in one column does not
 * vertically centre its neighbour. */
.grid-2 { align-items: start; }

/* Values held back until purchase. Rendered as visible placeholders rather
 * than blurred real text: a CSS blur still ships the number to the browser,
 * and anyone who opens the dev tools reads it. */
.locked-value {
  color: var(--c-ink-faint);
  letter-spacing: 0.15em;
  font-family: var(--font-num);
}

.line-ref--locked {
  color: var(--c-ink-faint);
  background: var(--c-surface-sunk);
}
