/* Layout: a sticky input column on the left and a payslip-style results column on the right; one column on phones. */
:root {
  --paper: #eef1f5;
  --sheet: #ffffff;
  --sheet-2: #f6f8fa;
  --ink: #101828;
  --ink-2: #475069;
  --muted: #737c90;
  --line: #dde2ea;
  --line-strong: #c3cad6;
  --accent: #1d5bb0;
  --accent-hover: #174a91;
  --accent-ink: #ffffff;
  --accent-soft: #e5edf9;
  --focus: #2a78d6;

  --good: #0b6b33;
  --good-soft: #e3f3e8;
  --warn: #8a4b00;
  --warn-soft: #fcefd9;
  --tip: #1d5bb0;
  --tip-soft: #e5edf9;
  --info-soft: #eef0f4;

  /* Chart series: fixed categorical order, validated for colour-blind separation. */
  --s-takehome: #2a78d6;
  --s-tax: #eb6834;
  --s-ni: #1baf7a;
  --s-pension: #eda100;
  --s-loan: #e87ba4;
  --s-other: #a3a8b4;
  --s-line: #6250d6;
  --grid: #e3e6ec;
  --axis: #c3c7d0;
  --band-0: #d9dde5;
  --band-1: #86b6ef;
  --band-2: #5598e7;
  --band-3: #2a78d6;
  --band-4: #256abf;
  --band-5: #1c5cab;
  --band-6: #184f95;

  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c111b;
    --sheet: #151b28;
    --sheet-2: #1a2132;
    --ink: #eef1f7;
    --ink-2: #b7bfd0;
    --muted: #8a93a7;
    --line: #262e40;
    --line-strong: #35405a;
    --accent: #5a9bf0;
    --accent-hover: #78aef4;
    --accent-ink: #0a1220;
    --accent-soft: #1b2a45;
    --focus: #78aef4;
    --good: #4cc27a;
    --good-soft: #13281d;
    --warn: #f0b259;
    --warn-soft: #2e2213;
    --tip: #78aef4;
    --tip-soft: #182540;
    --info-soft: #1c2333;
    --s-takehome: #3987e5;
    --s-tax: #d95926;
    --s-ni: #199e70;
    --s-pension: #c98500;
    --s-loan: #d55181;
    --s-other: #6b7286;
    --s-line: #9085e9;
    --grid: #232a3a;
    --axis: #3a4358;
    --band-0: #2c3446;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0c111b;
  --sheet: #151b28;
  --sheet-2: #1a2132;
  --ink: #eef1f7;
  --ink-2: #b7bfd0;
  --muted: #8a93a7;
  --line: #262e40;
  --line-strong: #35405a;
  --accent: #5a9bf0;
  --accent-hover: #78aef4;
  --accent-ink: #0a1220;
  --accent-soft: #1b2a45;
  --focus: #78aef4;
  --good: #4cc27a;
  --good-soft: #13281d;
  --warn: #f0b259;
  --warn-soft: #2e2213;
  --tip: #78aef4;
  --tip-soft: #182540;
  --info-soft: #1c2333;
  --s-takehome: #3987e5;
  --s-tax: #d95926;
  --s-ni: #199e70;
  --s-pension: #c98500;
  --s-loan: #d55181;
  --s-other: #6b7286;
  --s-line: #9085e9;
  --grid: #232a3a;
  --axis: #3a4358;
  --band-0: #2c3446;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--body);
}
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ---------- top bar ---------- */
.topbar {
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding-block: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { width: 38px; height: 38px; display: block; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font: 750 1.2rem/1.1 var(--display); letter-spacing: -0.02em; }
.brand-sub { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.02em; }
.topbar-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.field-inline { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--ink-2); }

/* ---------- layout ---------- */
.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding-block: 20px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.inputs {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
  scrollbar-width: thin;
}
.results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.card-note { font-size: 0.8rem; color: var(--muted); }
.grid-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field-label { font-size: 0.82rem; font-weight: 550; color: var(--ink-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }

input[type="text"], input:not([type]), input[inputmode], input[type="number"], select {
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 40px;
  width: 100%;
  min-width: 0;
}
select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.field-inline select { width: auto; min-height: 36px; padding-block: 6px; }
input:hover, select:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }

.money-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--sheet);
  padding: 0 10px;
  min-height: 40px;
  min-width: 0;
}
.money-input:focus-within { outline: 2px solid var(--focus); border-color: var(--focus); }
.money-input:hover { border-color: var(--muted); }
.money-input > span { color: var(--muted); font-family: var(--mono); font-size: 0.95em; }
.money-input input {
  border: 0; outline: 0; background: transparent;
  padding: 8px 6px; min-height: 0;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.money-input input:focus-visible { outline: 0; }
.money-input-lg { min-height: 54px; }
.money-input-lg > span { font-size: 1.35rem; }
.money-input-lg input { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }

.salary-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.salary-row select { width: auto; min-height: 54px; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  margin: 2px 0 0;
  cursor: pointer;
}
.range-scale { display: flex; justify-content: space-between; font: 0.72rem var(--mono); color: var(--muted); margin-top: -6px; }

.input-with-toggle { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }

/* segmented control (radio group) */
.seg {
  display: inline-flex;
  background: var(--sheet-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.seg label:hover { color: var(--ink); }
.seg input:checked + label { background: var(--sheet); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong), 0 1px 2px rgba(16, 24, 40, 0.08); }
.seg input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 1px; }
.seg-sm label { padding: 5px 9px; font-size: 0.8rem; font-family: var(--mono); }
.seg-sm { align-self: stretch; align-items: center; }

.check { display: flex; align-items: center; gap: 9px; font-size: 0.9rem; cursor: pointer; color: var(--ink); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.check-boxed { border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 0 10px; min-height: 40px; }
.checks { display: flex; flex-direction: column; gap: 10px; }

.hint { font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
.help {
  font-size: 0.85rem;
  color: var(--ink-2);
  background: var(--sheet-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.help ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.help-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink-2);
  font: 600 0.8rem var(--body);
  cursor: pointer;
}
.help-btn:hover, .help-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.more-label { font: 600 0.75rem var(--body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 6px 4px 0; }
.more-label span { text-transform: none; letter-spacing: 0; font-weight: 400; }
details.more { padding: 0; gap: 0; }
details.more summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 18px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
  font-size: 0.93rem;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after {
  content: "";
  margin-left: auto;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}
details.more[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
details.more summary:hover { color: var(--accent); }
.more-body { padding: 0 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.badge {
  font: 600 0.72rem var(--mono);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 1px 7px;
}

/* ---------- buttons ---------- */
.btn {
  font: 600 0.88rem var(--body);
  border: 1px solid var(--line-strong);
  background: var(--sheet);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sheet-2); border-color: var(--line); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* ---------- payslip hero ---------- */
.slip {
  position: relative;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px 22px;
  display: flex; flex-direction: column; gap: 18px;
  min-width: 0;
}
/* perforated tear line along the top, like a printed payslip */
.slip::before {
  content: "";
  position: absolute;
  left: 18px; right: 18px; top: 52px;
  height: 0;
  border-top: 2px dashed var(--line);
}
.slip-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }
.slip-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font: 0.75rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.slip-meta b { color: var(--ink-2); font-weight: 600; }
.hero { padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.hero-label { font-size: 0.9rem; color: var(--ink-2); font-weight: 550; }
.hero-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
#heroValue {
  font: 750 clamp(2.4rem, 6vw, 3.6rem)/1 var(--display);
  letter-spacing: -0.035em;
  color: var(--ink);
}
/* The display face draws a script-style £; headings wrap it in .cur to use the body face's plainer one. */
.cur { font-family: var(--body); }
#heroValue .cur { font-weight: 700; margin-right: 0.02em; }
.hero-per { font: 500 1.1rem var(--display); color: var(--muted); }
.hero-sub { color: var(--ink-2); font-size: 0.92rem; }
.pills { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font-size: 0.8rem;
  border: 1px solid var(--line);
  background: var(--sheet-2);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--ink-2);
}
.pill b { font-family: var(--mono); color: var(--ink); font-weight: 600; }

.flow { display: flex; flex-direction: column; gap: 12px; }
.flow-bar {
  display: flex;
  gap: 2px;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
}
.flow-seg { height: 100%; min-width: 3px; cursor: default; transition: filter 0.1s; }
.flow-seg:first-child { border-radius: 6px 0 0 6px; }
.flow-seg:last-child { border-radius: 0 6px 6px 0; }
.flow-seg:only-child { border-radius: 6px; }
.flow-seg:hover { filter: brightness(1.08) saturate(1.1); }
.flow-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.flow-legend li { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; align-items: baseline; }
.flow-legend .chip { width: 10px; height: 10px; border-radius: 3px; transform: translateY(1px); }
.flow-legend .lg-name { font-size: 0.82rem; color: var(--ink-2); }
.flow-legend .lg-val { grid-column: 2; font: 600 0.98rem var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.flow-legend .lg-pct { font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-left: 4px; }

/* ---------- breakdown table ---------- */
.table-card { padding-bottom: 8px; }
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.summary { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 560px; }
.summary th, .summary td { padding: 8px 10px; text-align: right; white-space: nowrap; }
.summary th:first-child, .summary td:first-child { text-align: left; padding-left: 0; white-space: normal; }
.summary thead th { font: 600 0.72rem var(--body); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); border-bottom: 1px solid var(--line-strong); }
.summary thead th.is-active { color: var(--accent); }
.summary td { font-family: var(--mono); font-size: 0.88rem; border-bottom: 1px solid var(--line); }
.summary td:first-child { font-family: var(--body); font-size: 0.9rem; }
.summary td.is-active { background: var(--accent-soft); }
.summary tr.sub td { color: var(--muted); font-size: 0.82rem; }
.summary tr.sub td:first-child { padding-left: 14px; }
.summary tr.deduct td:not(:first-child) { color: var(--ink-2); }
.summary tr.total td { font-weight: 700; font-size: 0.98rem; border-bottom: 0; border-top: 2px solid var(--ink); color: var(--ink); }
.summary tr.section td { font: 600 0.72rem var(--body); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); padding-top: 18px; border-bottom: 1px solid var(--line-strong); background: transparent; }
.summary tr.info td { color: var(--ink-2); }
.summary .row-chip { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; transform: translateY(-1px); }

/* ---------- small stat lists ---------- */
.kv { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.kv li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.kv li:last-child { border-bottom: 0; }
.kv li span:last-child { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv li.kv-total { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.kv-lead { font-size: 0.9rem; color: var(--ink-2); }
.kv-lead b { font: 700 1.3rem var(--display); color: var(--ink); }

/* ---------- band chart ---------- */
.band-bar { display: flex; gap: 2px; height: 30px; border-radius: 6px; overflow: hidden; }
.band-bar div { min-width: 3px; height: 100%; }
.band-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: 4px; }
.band-table th, .band-table td { padding: 7px 8px; text-align: right; font-size: 0.86rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.band-table th:first-child, .band-table td:first-child { text-align: left; padding-left: 0; white-space: normal; }
.band-table th { font: 600 0.72rem var(--body); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); border-bottom-color: var(--line-strong); }
.band-table td { font-family: var(--mono); }
.band-table td:first-child { font-family: var(--body); }
.band-table tr:last-child td { border-bottom: 0; font-weight: 700; }
.band-chip { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; transform: translateY(1px); }

/* ---------- insights ---------- */
.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.insight {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
}
.insight .tag {
  grid-row: span 2;
  font: 600 0.68rem var(--body);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-radius: 6px;
  padding: 3px 7px;
  align-self: start;
  margin-top: 1px;
  background: var(--sheet);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.insight strong { font-size: 0.92rem; }
.insight p { font-size: 0.86rem; color: var(--ink-2); }
.insight.tip { background: var(--tip-soft); }
.insight.tip .tag { color: var(--tip); border-color: currentColor; }
.insight.warn { background: var(--warn-soft); }
.insight.warn .tag { color: var(--warn); border-color: currentColor; }
.insight.good { background: var(--good-soft); }
.insight.good .tag { color: var(--good); border-color: currentColor; }

/* ---------- rate chart ---------- */
.rate-chart { position: relative; }
.rate-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.rate-chart text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.rate-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.82rem; color: var(--ink-2); margin-bottom: 6px; }
.rate-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rate-legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--s-line); }
.rate-legend i.dash { border-top: 2px dashed var(--muted); }
.rate-legend i.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--s-line); border: 2px solid var(--sheet); box-shadow: 0 0 0 1px var(--s-line); }

/* ---------- compare ---------- */
.compare-row { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); gap: 16px; align-items: start; }
.compare-out { min-width: 0; }
.compare-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.compare-grid div { background: var(--sheet-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.compare-grid span { display: block; font-size: 0.78rem; color: var(--muted); }
.compare-grid b { font: 700 1.1rem var(--mono); font-variant-numeric: tabular-nums; }
.compare-grid b.up { color: var(--good); }
.compare-note { font-size: 0.84rem; color: var(--ink-2); margin-top: 8px; }

/* ---------- workings ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.88rem; font-weight: 550; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--sheet); transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
#workings { display: flex; flex-direction: column; gap: 18px; }
.wk-step h3 { font-size: 0.95rem; font-weight: 650; margin-bottom: 4px; display: flex; gap: 8px; align-items: baseline; }
.wk-step h3 span { font: 600 0.75rem var(--mono); color: var(--muted); }
.wk-table { width: 100%; border-collapse: collapse; }
.wk-table td { padding: 6px 0; border-bottom: 1px dotted var(--line-strong); vertical-align: top; font-size: 0.86rem; }
.wk-table td:nth-child(2) { color: var(--muted); font: 0.8rem var(--mono); padding: 7px 12px; }
.wk-table td:last-child { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-table tr:last-child td { border-bottom: 0; font-weight: 650; }

/* ---------- export ---------- */
.export-row { display: flex; flex-wrap: wrap; gap: 8px; }
.status { font-size: 0.85rem; color: var(--good); min-height: 1.3em; }

.foot { font-size: 0.8rem; color: var(--muted); padding: 4px 4px 0; line-height: 1.55; max-width: 80ch; display: flex; flex-direction: column; gap: 10px; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-nav a { color: var(--ink-2); font-weight: 550; text-decoration: none; }
.foot-nav a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- FAQ ---------- */
.faq-list { display: flex; flex-direction: column; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-item:last-child { border-bottom: 0; }
.faq-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 2px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "";
  margin-left: auto;
  flex: none;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}
.faq-item[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.faq-item summary:hover h3 { color: var(--accent); }
.faq h3 { font-size: 0.95rem; font-weight: 650; }
.faq-item p { font-size: 0.9rem; color: var(--ink-2); line-height: 1.6; padding: 0 28px 14px 2px; max-width: 75ch; }

/* ---------- ad spaces ---------- */
/* Space is reserved so the page doesn't jump when an ad loads. */
.ad-slot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 130px;
  min-width: 0;
}
.ad-slot .adsbygoogle { min-height: 100px; }
.ad-label { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-align: center; }
@media (max-width: 640px) { .ad-slot { min-height: 280px; } }
/* Extra room between calculator ads and the cards (and controls) around them. */
.results > .ad-slot { margin-block: 8px; }
/* Short banner under the header on desktop; on phones the same ad sits between inputs and results. */
.ad-top {
  max-width: 1320px;
  margin: 16px auto 0;
  min-height: 110px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.ad-top .adsbygoogle { min-height: 90px; }
@media (max-width: 1080px) { .ad-desktop-only { display: none !important; } }
@media (min-width: 1081px) { .ad-mobile-only { display: none !important; } }

/* ---------- content pages (guides, about, privacy) ---------- */
.site-nav { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.site-nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}
.site-nav a:hover { background: var(--sheet-2); color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.page-main {
  max-width: 1320px;
  margin: 0 auto;
  padding-block: 28px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.prose {
  width: 100%;
  max-width: 72ch;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 44px);
  font-size: 1rem;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.prose h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 750; line-height: 1.15; letter-spacing: -0.025em; }
.prose h2 { font-size: 1.3rem; margin-top: 14px; }
.prose h3 { font-size: 1.05rem; margin-top: 6px; }
.prose p, .prose li { color: var(--ink-2); }
.prose strong { color: var(--ink); }
.prose ul, .prose ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.prose .lede { font-size: 1.1rem; color: var(--ink); }
.prose .meta { font: 0.78rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.prose table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { font: 600 0.72rem var(--body); text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); border-bottom-color: var(--line-strong); }
.prose td.num, .prose th.num { text-align: right; font-family: var(--mono); }
.prose .table-scroll { margin: 0; padding: 0; }
.prose .callout { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 14px 16px; color: var(--ink); }
.prose .callout p { color: var(--ink); }
.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--sheet-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.cta p { color: var(--ink); font-weight: 550; }
.guide-list { list-style: none; padding: 0 !important; gap: 12px !important; }
.guide-list a { display: block; text-decoration: none; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.guide-list a:hover { border-color: var(--accent); background: var(--accent-soft); }
.guide-list b { display: block; color: var(--ink); font-family: var(--display); font-size: 1.05rem; }
.guide-list span { display: block; color: var(--ink-2); font-size: 0.9rem; }
.page-main > .ad-slot, .page-main > .foot { width: 100%; max-width: 72ch; }
/* End-of-article ads sit clear of the links and buttons above them. */
.prose .ad-end { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.prose tr.total td { font-weight: 700; color: var(--ink); border-top: 2px solid var(--ink); }

/* ---------- salary pages ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--sheet-2); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat span { font-size: 0.78rem; color: var(--muted); line-height: 1.3; }
.stat b { font: 700 1.15rem var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
.stat.is-main { background: var(--accent-soft); }
.stat.is-main b { color: var(--accent); }
@media (max-width: 640px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.prose ul.salary-links { list-style: none; padding: 0; flex-direction: row; flex-wrap: wrap; gap: 8px; }
.salary-links a {
  display: inline-block;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font: 500 0.88rem var(--mono);
  color: var(--ink);
  text-decoration: none;
}
.salary-links a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.salary-links a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  max-width: 260px;
}
.tooltip b { font-family: var(--mono); }

/* ---------- mobile bar ---------- */
.mobile-bar { display: none; }

@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .inputs { position: static; max-height: none; overflow: visible; padding-right: 0; }
  .mobile-bar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--sheet);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.08);
    padding-top: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .mobile-bar > div { display: flex; flex-direction: column; line-height: 1.2; }
  .mobile-label { font-size: 0.75rem; color: var(--muted); }
  .mobile-value { font: 700 1.05rem var(--mono); white-space: nowrap; }
  .mobile-bar .btn { white-space: nowrap; }
  body { padding-bottom: 72px; }
  .mobile-bar.is-hidden { display: none; }
}
@media (max-width: 640px) {
  .grid-cards { grid-template-columns: minmax(0, 1fr); }
  .compare-row { grid-template-columns: minmax(0, 1fr); }
  .compare-grid { grid-template-columns: minmax(0, 1fr); }
  .slip { padding: 16px; }
  .slip::before { top: 96px; }
  .seg label { padding: 6px 9px; }
  .topbar-controls { width: 100%; justify-content: space-between; }
  .topbar-controls .seg { order: 3; width: 100%; }
  .topbar-controls .seg label { flex: 1; text-align: center; }
}
@media (max-width: 420px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .money-input-lg input { font-size: 1.25rem; padding-inline: 4px; }
  .salary-row { grid-template-columns: minmax(0, 1fr) 100px; }
  .salary-row select { padding-right: 24px; font-size: 0.9rem; }
  .seg-period label { padding: 6px 8px; }
}

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

/* ---------- print ---------- */
@media print {
  :root { --paper: #fff; --sheet: #fff; --shadow: none; }
  body { background: #fff; font-size: 11pt; padding: 0; }
  .ad-slot, .faq, .foot-nav,
  .topbar, .inputs, .mobile-bar, .export-card, .tooltip, .seg-period, .compare-row input, #workingsHint, .switch { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .results { gap: 10px; }
  .card, .slip { break-inside: avoid; border-color: #ccc; box-shadow: none; }
  .table-scroll { overflow: visible; margin: 0; padding: 0; }
  table.summary { min-width: 0; }
  .flow-bar, .band-bar, .flow-legend .chip, .band-chip, .row-chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #workings[hidden] { display: none !important; }
}
