/* Post Budget Evaluator — tokens carried over from the v29 prototype (samples/prototype). */
:root {
  --bg: #f3f4f6; --surface: #ffffff; --surface-2: #eceef2; --line: #d9dce3; --fg: #171a21; --muted: #5d6472;
  --rebate: #2bd600; --series: #ff4fa3; --series-soft: rgba(255, 79, 163, .35); --funding: #ff0202;
  --target: #f2c023; --target-ink: #1d1700; --target-soft: rgba(242, 192, 35, .20);
  --accent: #1f8a64; --accent-soft: #dff2ea; --input: #fbfbfd; --warn: #9a5b00; --warn-soft: #fff3dc;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif; --body: "Public Sans", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #121419; --surface: #1a1d24; --surface-2: #22262f; --line: #2e333d; --fg: #e9ebf0; --muted: #9aa1ae;
  --accent: #4fc08f; --accent-soft: #183328; --target-soft: rgba(242, 192, 35, .13); --input: #15181e; --warn: #f0b252; --warn-soft: #34290f; color-scheme: dark } }
* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 14px }
.wrap { max-width: 1560px; margin: 0 auto; padding-block: 24px 48px; padding-inline: 16px; display: grid; gap: 16px }
h1 { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 0 }
h2 { font-family: var(--display); font-weight: 700; font-size: 18px; margin: 0 }
.muted { color: var(--muted) }
.top { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center }
.top .who { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center }   /* controls sit left, beside the title */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); min-height: 40px; align-items: flex-end }
button { font: inherit; font-weight: 600; font-size: 13px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 6px 12px; cursor: pointer }
button:hover { border-color: var(--muted) }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg) }
button.fixed { width: 140px }
input { font: inherit; color: var(--fg); background: var(--input); border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 24px; display: grid; gap: 12px; max-width: 420px }
.field { display: grid; gap: 4px }
.field label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted) }
.error { color: var(--funding); font-weight: 600; min-height: 1.2em }
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; max-width: 640px }
table { border-collapse: collapse; width: 100% }
th, td { padding: 6px 12px; border-bottom: 1px solid var(--line); text-align: left }
th { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2) }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums }
tr.tot td { font-weight: 700; border-top: 2px solid var(--fg) }

/* ── Slice 3: page tabs, status, Settings page ── */
.top .save { font-size: 12px; color: var(--muted) }
.top .save.error { color: var(--funding); font-weight: 600 }
.tabs a { font-family: var(--display); font-weight: 600; font-size: 14px; padding: 8px 16px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent) }
a { color: var(--accent) }
.empty { display: grid; gap: 8px; padding: 32px 0; max-width: 72ch }
.bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-block: 12px }
.vars { display: flex; flex-wrap: wrap; gap: 16px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px }
.vgroup { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end }
.vgroup h3 { width: 100%; margin: 0; font-family: var(--display); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg) }
input.num { text-align: right; font-variant-numeric: tabular-nums }
select { font: inherit; font-size: 13px; color: var(--fg); background: var(--input); border: 1px solid var(--line); border-radius: 4px; padding: 5px 6px; width: 100% }
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
.scroll.wide { max-width: none }
table.rc { table-layout: fixed; min-width: 1360px }
table.rc td { vertical-align: middle; padding: 5px 8px }
table.rc td input:not([type=checkbox]) { width: 100%; padding: 5px 8px }
table.rc td.c, table.rc th.c { text-align: center }
table.rc tr.grp td { background: var(--surface-2); font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 13px }
table.rc tr.grp .chev { cursor: pointer; display: inline-flex; vertical-align: -3px; margin-right: 6px; transition: transform .15s }
table.rc tr.grp.open .chev { transform: rotate(90deg) }
table.rc tr.grp input.secname { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; font-size: 13px; width: 320px; background: transparent; border-color: transparent }
table.rc tr.grp input.secname:hover, table.rc tr.grp input.secname:focus { background: var(--input); border-color: var(--line) }
table.rc tr.grp .n { color: var(--muted); font-weight: 600 }
.det { display: inline-flex; gap: 6px; align-items: center }
.det label { font-size: 11px; color: var(--muted); white-space: nowrap }
.det input { width: 64px !important }
.small { font-size: 11px }
select.wide { max-width: 260px }
@media (prefers-reduced-motion: reduce) { table.rc tr.grp .chev { transition: none } }

/* ── Slice 4: fixed header, budget tabs, variables + totals bar, budget sheet (ported from prototype v31) ── */
.wrap { gap: 0 }
.head { position: sticky; top: 0; z-index: 5; background: var(--bg); display: grid; gap: 12px; padding-block: 12px }
.head .top { gap: 12px 16px }
.head .who { margin-left: auto }
.pages { display: flex; gap: 2px; background: var(--surface-2); border-radius: 6px; padding: 2px }
.pages a { padding: 5px 12px; border-radius: 4px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px }
.pages a[aria-current="page"] { background: var(--surface); color: var(--fg) }
.head .bar { margin: 0 }
#varsbar:empty { display: none }
.tabs { align-items: flex-end; flex-wrap: wrap; gap: 4px }
.tabs[hidden] { display: none }
.tabs a { display: inline-flex; gap: 8px; align-items: baseline; cursor: pointer }
.tabs a .type { font-family: var(--body); font-weight: 500; font-size: 11px; color: var(--muted) }
.tabs a.t-series { border-bottom-color: var(--series-soft) }
.tabs a.t-series[aria-current="page"] { border-bottom-color: var(--series) }
.tabs .tabbtn { margin: 0 0 6px 8px; width: 120px; display: inline-flex; gap: 6px; align-items: center; justify-content: center }
.tabs .tabbtn:first-child { margin-left: 0 }
button { display: inline-flex; gap: 6px; align-items: center; justify-content: center }
.panel { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; background: var(--surface); border: 1px solid var(--accent); border-radius: 6px; padding: 12px 16px; margin-block: 12px }
.vars { align-items: flex-end }
.vars .field input { width: 96px }
.ro { min-width: 96px; padding: 6px 8px; border: 1px dashed var(--line); border-radius: 4px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted) }
.kpis { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-left: auto; font-variant-numeric: tabular-nums }
.kpi { display: grid; gap: 2px; text-align: right }
.kpi span { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted) }
.kpi b { font-family: var(--display); font-size: 17px; font-weight: 700 }
.kpi.hi b { color: var(--rebate) }
.kpi.fund b { color: var(--funding) }
.confirm { display: inline-flex; gap: 8px; align-items: center; font-size: 13px }
.warn-msg { color: var(--funding); font-weight: 600 }
.scroll.sheet { max-width: none; margin-top: 12px }
table.sheet { table-layout: fixed; width: 100%; min-width: 960px }
table.sheet th { position: sticky; top: var(--head-h, 0px); z-index: 2 }
table.sheet td { padding: 6px 8px; vertical-align: middle }
table.sheet td.qtyc { padding-inline: 4px }
table.sheet td input:not([type=checkbox]), table.sheet td select, table.sheet td textarea { width: 100% }
table.sheet td.li { white-space: normal; line-height: 1.35 }
table.sheet tr.grp td { background: var(--surface-2); font-family: var(--display); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; font-size: 13px }
table.sheet tr.grp td[data-grp] { cursor: pointer }
table.sheet tr.grp svg { transition: transform .15s; vertical-align: -3px; margin-right: 6px }
table.sheet tr.grp.open svg { transform: rotate(90deg) }
table.sheet tr.grp .n { color: var(--muted); font-weight: 600; margin-left: 8px }
table.sheet tr.off td:not(:first-child) { opacity: .45 }
table.sheet tr.tot td { font-family: var(--display); font-weight: 700; border-top: 2px solid var(--fg) }
table.sheet tr.muted td { color: var(--muted) }
input.over, select.over { background: var(--warn-soft); border-color: var(--warn) }
.ic { width: 28px; height: 28px; padding: 0; border: none; background: none; color: var(--muted) }
.ic:hover { color: var(--fg) }
textarea { font: inherit; color: var(--fg); background: var(--input); border: 1px solid var(--line); border-radius: 4px; padding: 5px 8px; resize: none; overflow: hidden; line-height: 1.35; display: block; min-height: 30px }
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
@media (prefers-reduced-motion: reduce) { table.sheet tr.grp svg { transition: none } }
/* Column headings stick under the fixed header: the sheet's box only scrolls sideways on narrow screens. */
@media (min-width: 1000px) { .scroll.sheet { overflow: visible } }

/* ── Slice 5: Target + Comment columns ── */
:root { --target-ink: #1d1700 }
table.sheet { min-width: 1250px }
table.sheet th.workcol { background: var(--target); color: var(--target-ink) }
table.sheet td.workcol { background: var(--target-soft) }
table.sheet tr.grp td.workcol { background: var(--target-soft); font-family: var(--body); font-weight: 600; text-transform: none; letter-spacing: 0 }
table.sheet tr.off td.workcol, table.sheet tr.off td.notecol { opacity: 1 }
table.sheet td.notecol { white-space: normal }
table.sheet td.notecol textarea { font-size: 13px; font-family: var(--body); text-transform: none; letter-spacing: 0; font-weight: 400 }
table.sheet td.notecol textarea:placeholder-shown { border-color: transparent; background: transparent }
table.sheet td.notecol textarea:placeholder-shown:hover, table.sheet td.notecol textarea:focus { border-color: var(--line); background: var(--input) }
@media (min-width: 1000px) { .scroll.sheet { overflow: visible } }
@media (max-width: 1283px) { .scroll.sheet { overflow-x: auto } }

/* ── Slice 6: change log panel ── */
.logpanel { margin-top: 12px }
.logpanel .scroll { max-width: none; max-height: 320px; overflow: auto }
table.log { table-layout: fixed; width: 100%; font-size: 13px }
table.log td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
table.log td.chg { font-variant-numeric: tabular-nums }
button[aria-pressed="true"] { border-color: var(--accent) }
