:root {
  --bg: #eef2f5;
  --paper: #ffffff;
  --ink: #1b2836;
  --muted: #5c6b7c;
  --line: #d5dee7;
  --navy: #1e3a5f;
  --navy-soft: #e7eef6;
  --healthy: #0f6b3c;
  --healthy-bg: #e7f5ee;
  --pressure: #6e5608;
  --pressure-bg: #fbf4dc;
  --critical: #8c2f2f;
  --critical-bg: #f8eaea;
  --income: #0f6b3c;
  --cost: #8c2f2f;
  --shadow: 0 1px 2px rgba(27, 40, 54, 0.05), 0 10px 28px rgba(27, 40, 54, 0.05);
  --sans: "Segoe UI", "Source Sans 3", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(1.0625rem, 0.98rem + 0.4vw, 1.125rem);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.site-header,
main,
footer {
  width: min(1120px, calc(100% - clamp(1rem, 4vw, 2.5rem) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  margin-left: auto;
  margin-right: auto;
}

.site-header {
  padding: 1.75rem 0 0.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.55rem, 1.15rem + 1.6vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2,
legend,
.effects-title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

#health-heading { scroll-margin-top: 0.75rem; }

.back-top { margin: 1rem 0 0.15rem; }
.back-top a { color: var(--navy); font-weight: 700; }
#summary-example { margin: 0.15rem 0; text-align: center; }
#summary-example a { color: var(--navy); font-weight: 700; }
#summary-review + hr.section-rule,
#summary-example + hr.section-rule { margin: 0.55rem 0; }

.mode-flag {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.12rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--navy-soft);
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.3;
  vertical-align: 0.28rem;
}

.mode-flag[data-state="simulation"] {
  background: var(--pressure-bg);
  border-color: #e4d3a8;
  color: var(--pressure);
}

.employer-note {
  display: none;
  grid-column: 1 / -1;
  justify-self: start;
  max-width: 100%;
  margin-top: 0.15rem;
  padding: 0.22rem 0.7rem;
  border: 1px solid #e4d3a8;
  border-radius: 999px;
  background: var(--pressure-bg);
  color: var(--pressure);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.employer-note.is-on {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.85rem;
}

.employer-note.is-on + .range { margin-top: 0.2rem; }

h3 { margin: 0; font-size: clamp(1.15rem, 1.05rem + 0.45vw, 1.3rem); line-height: 1.25; }

.lede, .section-head p, .fine, .hint, .prose p, .prose li, footer p {
  color: var(--muted);
}

.lede { margin: 0; max-width: 48rem; }
.teaching-note { color: #c62828; font-weight: 700; }
.lede + .lede { margin-top: 0.75rem; }
.lede a { color: var(--navy); font-weight: 650; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  margin: clamp(0.75rem, 0.5rem + 1vw, 1rem) 0;
  padding: clamp(0.85rem, 0.7rem + 1vw, 1.25rem);
  container-type: inline-size;
  container-name: panel;
}

.section-head { margin-bottom: 1rem; }
.section-head p { margin: 0.25rem 0 0; }
.section-head.row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  align-items: flex-start;
}
.section-head.row > div { flex: 1 1 28rem; min-width: min(100%, 28rem); }

.summary-report > h3 {
  margin: 1.15rem 0 0.45rem;
}

.summary-params {
  display: grid;
  grid-template-columns: minmax(11rem, 16rem) 1fr;
  gap: 0.55rem 1rem;
  margin: 0 0 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
}

.summary-params div { display: contents; }

.summary-params dt {
  margin: 0;
  font-weight: 700;
}

.summary-params dd {
  margin: 0;
}

@media (max-width: 640px) {
  .summary-params { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .summary-params dd { margin-bottom: 0.55rem; }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.5rem), 1fr));
  gap: clamp(0.65rem, 1.5vw, 0.8rem);
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 0.95rem 1rem;
  background: #fbfcfd;
}

.card header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.35rem;
}

.card-about {
  margin: 0.15rem 0 0.2rem;
  color: var(--ink);
}

.card-about a {
  color: var(--navy);
  font-weight: 650;
}

.fund-code {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status {
  margin: 0;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.card[data-status="critical"] .status { background: var(--critical-bg); color: var(--critical); }
.card[data-status="pressure"] .status { background: var(--pressure-bg); color: var(--pressure); }
.card[data-status="healthy"] .status { background: var(--healthy-bg); color: var(--healthy); }
.card[data-status="critical"] .metric { color: var(--critical); }
.card[data-status="pressure"] .metric { color: var(--pressure); }
.card[data-status="healthy"] .metric { color: var(--healthy); }

.metric-label {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.metric {
  margin: 0.1rem 0 0;
  font-size: clamp(1.35rem, 1.15rem + 1vw, 1.7rem);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.metric-sub { margin: 0.15rem 0 0; font-weight: 650; }
.law, .note { margin: 0.15rem 0 0; color: var(--muted); }
.fine { margin: 0.9rem 0 0; }

fieldset { border: 0; margin: 0 0 1.1rem; padding: 0; }
fieldset.ruled {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 1.15rem 0;
  padding: 0.85rem 0 0.35rem;
}
hr.section-rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.4rem 0 1rem;
}
legend { display: block; width: 100%; padding: 0; font-family: inherit; }

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.upper-payer {
  margin: 0.35rem 0 1rem;
}

.segmented label {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  background: #fff;
  font-weight: 650;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label:has(input:checked) {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.option-title {
  margin: 0.15rem 0 0.15rem;
  font-weight: 700;
  color: var(--navy);
}
.option-title + .option-check { margin-top: 0.45rem; }

.option-check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  margin: 1rem 0 0.35rem;
  font-weight: 650;
  cursor: pointer;
}

.option-check input { margin-top: 0.2rem; accent-color: var(--navy); }

.control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  margin: 0.85rem 0 0.2rem;
}

.control label { font-weight: 650; }
.range { grid-column: 1 / -1; width: 100%; accent-color: var(--navy); height: 1.6rem; }

input[type="number"] {
  width: 7.2rem;
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

input[type="number"]:disabled,
input[type="range"]:disabled { opacity: 0.45; }

.hint { margin: 0.35rem 0 0.6rem; }
#recommendations { color: #c62828; font-weight: 650; }
#solve-next { color: #c62828; font-weight: 700; }
.check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin: 0.45rem 0;
  font-weight: 650;
}
.check input { margin-top: 0.25rem; accent-color: var(--navy); width: 1.05rem; height: 1.05rem; }

button, .presets button, #reset {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--navy);
  background: #fff;
  color: var(--navy);
  padding: 0.5rem 0.9rem;
}

#reset { flex: 0 0 auto; }
button:hover, .presets button:hover, #reset:hover { background: var(--navy-soft); }

.run-simulator {
  display: flex;
  justify-content: center;
  margin: 1rem 0 0.35rem;
}
hr.section-rule + .run-simulator { margin-top: 0.15rem; }

#find-taxes {
  width: auto;
  font-size: 1.35rem;
  line-height: 1.2;
  padding: 0.95rem 1.8rem;
  background: var(--navy);
  color: #fff;
}

#find-taxes:hover { background: #16304f; color: #fff; }

.tier {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem 0.4rem;
  margin: 0.55rem 0;
  background: #fbfcfd;
}

.tier h3 { margin-bottom: 0.2rem; }

.rate-formula { margin: 0.85rem 0 0.35rem; }
.rate-formula { container-type: inline-size; container-name: formula; }
.formula-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 0.4rem 0.55rem;
  margin: 0 0 0.85rem;
}
.formula-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-weight: 650;
  line-height: 1.25;
}
.formula-field output {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
}
.formula-total output {
  background: var(--navy-soft);
  font-weight: 700;
}
.formula-op {
  flex: 0 0 auto;
  padding-bottom: 0.35rem;
  color: var(--navy);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}
.rate-formula .hint { margin: 0; }
.law-ref { margin: 0.15rem 0 0.65rem; }
.law-ref[hidden] { display: none; }

details {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
  margin-bottom: 0.6rem;
}
summary { cursor: pointer; font-weight: 750; }

.effects-title { margin: 0.4rem 0 0.3rem; }
#effects { margin: 0; padding-left: 1.15rem; }
#effects li { margin: 0.35rem 0; }
#effects li.quiet { color: var(--muted); list-style: none; margin-left: -1.15rem; }

figure { margin: 1.1rem 0 0; }
figcaption h3 { margin-bottom: 0.15rem; }
figcaption p { margin: 0 0 0.45rem; color: var(--muted); }

.chart-host {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfd;
  min-height: 0;
}

.chart-host svg { display: block; width: 100%; height: auto; touch-action: manipulation; }

.tooltip {
  position: absolute;
  z-index: 2;
  max-width: min(16rem, 100%);
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: none;
}

.tooltip strong { display: block; margin-bottom: 0.2rem; }
.tooltip p { margin: 0.12rem 0; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
}

.swatch {
  display: inline-block;
  width: 1.3rem;
  height: 0;
  border-top-width: 3px;
  border-top-style: solid;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.swatch.dashed { border-top-style: dashed; }

.share-wrap { overflow-x: auto; margin-top: 0.15rem; }
.share-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.share-table th,
.share-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.share-table th { font-size: 0.78rem; font-weight: 650; color: var(--muted); }
.share-table tbody th { color: var(--ink); font-size: 0.86rem; font-weight: 650; }
.share-dollars { display: block; font-weight: 700; color: var(--ink); }
.share-pct { display: block; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
#tier-share-heading { margin: 0.95rem 0 0.15rem; }

.prose h3 { margin: 1rem 0 0.3rem; }
.prose ul { margin: 0.2rem 0 0.4rem; padding-left: 1.15rem; }
.prose a { color: var(--navy); }
code { font-size: 0.92em; }

footer { padding: 0.2rem 0 1.6rem; }
footer > hr.section-rule { margin: 1.15rem 0 1rem; }
footer p { margin: 0; font-size: 0.88rem; }
footer p + p { margin-top: 0.45rem; }
footer a { color: var(--navy); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

@container panel (max-width: 36rem) {
  .control { grid-template-columns: minmax(0, 1fr); }
  .control input[type="number"] { width: 100%; }
}

@container formula (max-width: 40rem) {
  .formula-line { grid-template-columns: minmax(0, 1fr); }
  .formula-op { justify-self: center; padding: 0.1rem 0; }
}

@media (max-width: 680px) {
  .control { grid-template-columns: minmax(0, 1fr); }
  .control input[type="number"] { width: 100%; }
  .formula-line { grid-template-columns: minmax(0, 1fr); }
  .formula-op { justify-self: center; padding: 0.1rem 0; }
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  margin-top: 0.75rem;
}
.summary-report .report-actions {
  justify-content: center;
  margin-top: 0;
  margin-bottom: 0.15rem;
}
.report-actions .hint { margin: 0; flex: 1 1 16rem; }
.report-actions-end { justify-content: center; margin: 1.25rem 0 0.5rem; }

.pdf-report { display: none; }
.pdf-running { position: running(reportHead); }

@page simulation-report {
  size: letter portrait;
  margin: 0.82in 0.68in 0.72in;
  @top-left {
    content: element(reportHead);
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    color: #5c6b7c;
  }
  @bottom-left {
    content: "Educational use only. Not an official projection.";
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    color: #5c6b7c;
  }
  @bottom-right {
    content: "Page " counter(page);
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 9pt;
    color: #5c6b7c;
  }
}

@media print {
  body.report-print {
    background: #fff !important;
  }
  body.report-print .site-header,
  body.report-print main,
  body.report-print > footer,
  body.report-print #narrative-live {
    display: none !important;
  }
  body.report-print .pdf-report[hidden] {
    display: block !important;
  }
  body.report-print .pdf-report {
    page: simulation-report;
    width: auto;
    margin: 0;
    color: #1b2836;
    font-size: 11pt;
    line-height: 1.4;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

.pdf-sheet + .pdf-sheet > h2 {
  break-before: page;
  page-break-before: always;
}
.pdf-report h1,
.pdf-report h2,
.pdf-report h3,
.pdf-report h4 {
  break-inside: avoid;
  page-break-inside: avoid;
  break-after: avoid;
  page-break-after: avoid;
}
.pdf-report h1 + *,
.pdf-report h2 + *,
.pdf-report h3 + *,
.pdf-report h4 + * {
  break-before: avoid;
  page-break-before: avoid;
}
.pdf-report p,
.pdf-report li {
  orphans: 3;
  widows: 3;
}
.pdf-kicker {
  margin: 0 0 0.15rem;
  color: #5c6b7c;
  font-size: 9pt;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.pdf-report h2 {
  margin: 0 0 0.45rem;
  color: #1e3a5f;
  font-size: 16pt;
  line-height: 1.2;
}
.pdf-report h3 { margin: 0.7rem 0 0.2rem; font-size: 12pt; color: #1e3a5f; }
.pdf-report p { margin: 0.3rem 0; }
.pdf-report .pdf-lead { font-size: 12pt; color: #1b2836; }
.pdf-report .pdf-rec { color: #c62828; font-weight: 650; }
.pdf-report .pdf-muted, .pdf-report .pdf-law { color: #5c6b7c; }
.pdf-report .teaching-note { color: #c62828; font-weight: 700; }
.pdf-report h2 .mode-flag,
.pdf-report h3 .mode-flag {
  margin-left: 0.4rem;
  padding: 0.05rem 0.45rem;
  font-size: 10pt;
  vertical-align: middle;
}
.pdf-report .summary-params {
  display: block;
  margin: 0.35rem 0 0.6rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid #d5dee7;
  border-radius: 8px;
  background: #fbfcfd;
}
.pdf-report .summary-params div {
  display: grid;
  grid-template-columns: 12.5rem 1fr;
  gap: 0.15rem 0.7rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid #e6edf3;
  break-inside: avoid;
  page-break-inside: avoid;
}
.pdf-report .summary-params div:last-child { border-bottom: 0; }
.pdf-report .summary-params dt,
.pdf-report .summary-params dd { margin: 0; }
.pdf-report .pdf-back {
  margin-top: 0.85rem;
  color: #1e3a5f;
  font-weight: 700;
}
.pdf-fund {
  border: 1px solid #d5dee7;
  border-radius: 8px;
  padding: 0.4rem 0.55rem 0.5rem;
  margin: 0 0 0.4rem;
  break-inside: avoid;
  page-break-inside: avoid;
}
.pdf-fund h3 { margin: 0 0 0.25rem; }
.pdf-status { font-weight: 700; }
.pdf-status[data-state="critical"] { color: #8c2f2f; }
.pdf-status[data-state="pressure"] { color: #6e5608; }
.pdf-status[data-state="healthy"] { color: #0f6b3c; }
.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.35rem 0 0.7rem;
  break-inside: avoid;
  page-break-inside: avoid;
}
.pdf-table th, .pdf-table td {
  padding: 0.28rem 0.4rem;
  border-bottom: 1px solid #d5dee7;
  text-align: left;
  vertical-align: top;
}
.pdf-table th { font-weight: 650; color: #1e3a5f; }
.pdf-table thead th { font-size: 9pt; }
.pdf-chart, .pdf-report li, .pdf-report .pdf-disclaimer p {
  break-inside: avoid;
  page-break-inside: avoid;
}
.pdf-chart { margin: 0.35rem 0 0.55rem; }
.pdf-chart .chart-host {
  min-height: 0;
  border: 0;
  background: transparent;
}
.pdf-chart svg { display: block; width: 100%; height: auto; }
.pdf-chart .tooltip { display: none !important; }
.pdf-report .legend { margin-top: 0.2rem; }
.pdf-report .share-wrap { overflow: visible; }
.pdf-disclaimer { margin-top: 0.8rem; }
.pdf-disclaimer p { font-size: 9pt; color: #5c6b7c; }

@media (max-width: 560px) {
  .segmented label, button, #reset { width: 100%; text-align: center; }
  .report-actions-end button, #create-pdf { width: auto; max-width: 100%; }
}
