:root {
  --bg: #fafaf7; --surface: #ffffff; --fg: #1d1d1b; --muted: #5b5b57; --line: #e3e2dc;
  --accent: #1f5f8b; --accent-fg: #ffffff; --down: #a33a2a; --up: #2f6f3e; --flag: #fff4d6; --flag-line: #e7c766;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161615; --surface: #1f1f1d; --fg: #ececea; --muted: #a3a39e; --line: #34342f;
    --accent: #7fb6dc; --accent-fg: #10232f; --down: #f08f7c; --up: #8fd19e; --flag: #3a3219; --flag-line: #7a6624;
  }
}
:root[data-theme="dark"] {
  --bg: #161615; --surface: #1f1f1d; --fg: #ececea; --muted: #a3a39e; --line: #34342f;
  --accent: #7fb6dc; --accent-fg: #10232f; --down: #f08f7c; --up: #8fd19e; --flag: #3a3219; --flag-line: #7a6624;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
header.site, main, footer.site { max-width: 68rem; margin: 0 auto; padding: 0 16px; }
header.site { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; align-items: baseline; padding-top: 1.25rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
header.site .brand { font-weight: 700; color: var(--fg); text-decoration: none; margin-right: auto; }
header.site nav a { color: var(--muted); text-decoration: none; margin-left: 1rem; white-space: nowrap; display: inline-block; }
header.site nav a[aria-current="page"] { color: var(--fg); font-weight: 600; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 1.5rem 0 .5rem; }
.lede { color: var(--muted); max-width: 46rem; margin: 0 0 1.25rem; }
.picker { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; }
.picker label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: .25rem; }
.picker input, .picker select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; }
.picker input { width: 8rem; }
.picker select { max-width: 100%; min-width: 16rem; }
.picker .vs { display: flex; flex-wrap: wrap; gap: .25rem 1rem; border: 1px solid var(--line); border-radius: 6px; margin: 0; padding: .3rem .7rem .45rem; }
.picker .vs legend { font-size: .85rem; color: var(--muted); padding: 0 .25rem; }
.picker .vs label { flex-direction: row; align-items: center; gap: .35rem; font-size: .9rem; color: var(--fg); }
.picker .vs input { width: auto; margin: 0; padding: 0; }
.picker-note { flex-basis: 100%; margin: 0; font-size: .9rem; color: var(--muted); min-height: 1.4em; }
button.primary { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-fg); border: 0; border-radius: 6px; padding: .55rem 1rem; cursor: pointer; }
button.primary:disabled { opacity: .45; cursor: default; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .75rem; margin: 1.25rem 0; }
.summary div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; }
.summary b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.summary span { font-size: .8rem; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
@media (max-width: 960px) { th, td { padding: .4rem .45rem; } }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .45rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { white-space: normal; }
tr.group th { text-align: center; border-bottom: 1px solid var(--line); }
tr.group th[rowspan] { text-align: left; vertical-align: bottom; }
tr.group th + th:not([rowspan]) { border-left: 1px solid var(--line); }
.howto { color: var(--muted); font-size: .9rem; max-width: 60rem; margin: 1rem 0 .5rem; }
.cut-key { background: var(--flag); font-weight: 600; padding: 0 .25rem; border-radius: 3px; }
tr.cat td { background: var(--bg); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.down { color: var(--down); }
.up { color: var(--up); }
tr.flag td { background: var(--flag); }
td.cut { background: var(--flag); font-weight: 600; }
a { color: var(--accent); }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); margin: .25rem 0; }
.builder { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-top: .75rem; }
.proc { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.proc .code { font-weight: 600; font-variant-numeric: tabular-nums; }
.proc .desc { flex: 1 1 14rem; color: var(--muted); font-size: .9rem; }
.proc input { width: 4.5rem; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .5rem; }
button.link { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: .2rem; }
.add-row { margin: .75rem 0; }
.add-row select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; width: 100%; max-width: 40rem; }
.modes { border: 1px solid var(--line); border-radius: 8px; margin: .5rem 0 0; padding: .5rem .9rem .75rem; }
.modes legend { font-size: .85rem; color: var(--muted); padding: 0 .25rem; }
.modes label { display: block; font-size: .9rem; margin: .6rem 0; }
.modes .mode-desc { display: block; margin-left: 1.6rem; color: var(--muted); font-size: .85rem; }
tfoot td { font-weight: 700; border-bottom: 0; }
.notes { color: var(--muted); font-size: .85rem; max-width: 50rem; }
.notes li { margin: .3rem 0; }
footer.site { color: var(--muted); font-size: .8rem; padding-top: 2rem; padding-bottom: 2rem; }
.explainer > * { max-width: 46rem; }
.explainer h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
.explainer li { margin: .35rem 0; }
.callout { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: .75rem 1.1rem; margin: 1rem 0 1.5rem; }
.callout h2 { margin: .25rem 0 .25rem; }
.callout ul { padding-left: 1.2rem; margin: .25rem 0; }
.formula { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .75rem 0; font-size: .9rem; }
.formula .term { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .55rem; }
.formula .term.hl { background: var(--flag); border-color: var(--flag-line); font-weight: 600; }
.formula .op { color: var(--muted); font-weight: 700; }
.timeline { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; }
.timeline li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .75rem 1rem; margin: 0; }
.timeline b { display: block; margin-bottom: .25rem; }
.timeline span { font-size: .9rem; color: var(--muted); }
blockquote { margin: 1rem 0; padding: .5rem 1rem; border-left: 4px solid var(--line); color: var(--fg); background: var(--surface); border-radius: 0 10px 10px 0; }
blockquote cite { display: block; margin-top: .4rem; font-size: .8rem; font-style: normal; color: var(--muted); }
[hidden] { display: none !important; }
@media (max-width: 960px) {
  .rates th:nth-child(3), .rates td:nth-child(3), .rates th:nth-child(7), .rates td:nth-child(7),
  .rates th:nth-child(8), .rates td:nth-child(8),
  .rates.fac th:nth-child(6), .rates.fac td:nth-child(6),
  .mod25 .c-alone { display: none; }
  /* Office vs facility view: column 7 is ASC total, so keep it and drop the two % columns (6 and 8). */
  .rates.fac th:nth-child(7), .rates.fac td:nth-child(7) { display: table-cell; }
}
@media (max-width: 600px) {
  .picker select { min-width: 0; width: 100%; }
  .mod25 .c-desc { display: none; }
  .calc th:nth-child(2), .calc td:nth-child(2), .calc th:nth-child(3), .calc td:nth-child(3) { display: none; }
}
