/* PSB Budget Builder: court black + gold, calm and friendly for non-finance folks. */
:root {
  --ink: #17150f;
  --ink-soft: #5b5646;
  --paper: #faf7f0;
  --card: #ffffff;
  --line: #e7e1d2;
  --gold: #FFD329;        /* PSB brand gold: fills, primary actions */
  --gold-bright: #FFD329; /* gold on black */
  --gold-edge: #f0c419;   /* gold as a border/edge on light backgrounds */
  --gold-soft: #fff8df;   /* soft gold wash */
  --gold-hover: #f6c714;
  --gold-deep: #a9820a;   /* legible warm gold for icons on gold-soft */
  --gold-text: #8a6d00;   /* the only gold legal as TEXT on white (4.9:1) */
  --black: #000000;       /* PSB brand black */
  --green: #1e7a3c;
  --red: #d3392c;         /* PSB accent red: sparingly */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 21, 15, .06), 0 8px 24px -12px rgba(23, 21, 15, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--ink); }

/* ---------- Header ---------- */
header.topbar {
  background: var(--black); color: #fff;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; position: sticky; top: 0; z-index: 40;
}
.wordmark { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.wordmark .psb { font-weight: 800; letter-spacing: .5px; color: var(--gold-bright); font-size: 18px; }
.wordmark .app { font-weight: 600; font-size: 15px; color: #fff; }
.topbar .spacer { flex: 1; }
.topbar select {
  background: #1d1b15; color: #fff; border: 1px solid #3a3628; border-radius: 8px; padding: 6px 10px;
  max-width: 220px;
}
.topbar .ghost {
  background: transparent; color: #d8d3c4; border: 1px solid #3a3628; border-radius: 8px; padding: 6px 12px;
}
.topbar .ghost:hover { color: #fff; border-color: var(--gold-edge); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 26px; max-width: 1520px; margin: 0 auto; padding: 22px 24px 80px; }
@media (max-width: 900px) { .shell { grid-template-columns: 1fr; } .rail { position: static !important; order: -1; } }
main { min-width: 0; }

/* ---------- Progress ---------- */
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.steps button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
}
.steps button.active { background: var(--black); border-color: var(--black); color: var(--gold-bright); }
.steps button.done { border-color: var(--gold-edge); color: var(--gold-text); }
.steps button.done::before { content: "✓ "; }

/* ---------- Cards & typography ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 0 0 4px; letter-spacing: -.2px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p.lead { margin: 0 0 14px; color: var(--ink-soft); max-width: 62ch; }
.hint {
  background: #fdf6e0; border: 1px solid #f0e2b0; border-radius: 10px;
  padding: 10px 14px; font-size: 13.5px; color: #5f5325; margin: 12px 0;
}
.hint b { color: var(--gold-text); }
.formula-note { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }
.formula-note code { background: #f3efe4; border-radius: 6px; padding: 1px 6px; font-size: 12px; }

/* ---------- Item blocks (tier / program / gym rows) ---------- */
.item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 12px 0; background: #fffdf8; }
.item-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fff; min-width: 0;
}
.field input:focus { outline: 2px solid var(--gold-edge); outline-offset: 0; border-color: var(--gold-edge); }
.field.grow { flex: 1 1 160px; }
.field.w-90 input { width: 90px; }
.field.w-70 input { width: 70px; }
.item-total { margin-left: auto; text-align: right; }
.item-total .amt { font-weight: 800; font-size: 16px; }
.item-total .sub { font-size: 11.5px; color: var(--ink-soft); }
.remove-btn { background: none; border: none; color: #6d675a; font-size: 13px; padding: 4px; }
.remove-btn:hover { color: var(--red); }

/* ---------- Month grid ---------- */
.mgrid { display: grid; grid-template-columns: repeat(15, minmax(46px, 1fr)); gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.mgrid .mcell { display: flex; flex-direction: column; gap: 2px; }
.mgrid .mlabel { font-size: 10px; font-weight: 700; color: var(--ink-soft); text-align: center; white-space: nowrap; }
.mgrid .mlabel.tail { color: #b09a4e; }
.mgrid input {
  width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 4px;
  text-align: center; font-size: 12.5px; background: #fff;
}
.mgrid input:focus { outline: 2px solid var(--gold-edge); border-color: var(--gold-edge); }
.mgrid input.nonzero { background: #fdf3d0; border-color: #e8d48a; font-weight: 600; }
.quickfill { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.quickfill input, .quickfill select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12.5px; width: 70px; }
.quickfill select { width: auto; }
.quickfill button { border: 1px solid var(--gold-edge); color: var(--gold-text); background: var(--gold-soft); border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 700; }

/* pair grid (teams+hours) */
.mgrid.pair { grid-template-columns: repeat(15, minmax(58px, 1fr)); }
.mgrid .pair-cell input + input { margin-top: 3px; }
.pair-legend { font-size: 11px; color: var(--ink-soft); margin: 4px 0 0; }

/* ---------- Buttons ---------- */
.btn-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.primary {
  background: var(--gold); color: #1a1a1a; font-weight: 800; border: none;
  border-radius: 10px; padding: 10px 22px; letter-spacing: .01em;
}
.primary:hover { background: var(--gold-hover); }
.secondary { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; font-weight: 600; color: var(--ink); }
.secondary:hover { border-color: var(--gold-edge); }
.add-btn { background: none; border: 1px dashed var(--gold-edge); color: var(--gold-text); border-radius: 10px; padding: 8px 16px; font-weight: 700; font-size: 13.5px; }
.add-btn:hover { background: #fffbe8; }

/* ---------- Live rail ---------- */
.rail { position: sticky; top: 74px; align-self: start; }
.scoreboard { background: var(--black); color: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.scoreboard .sb-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.scoreboard .sb-label, .scoreboard .muted { color: #a49d87; }
.cd-headline { margin: 2px 0 14px; }
.cd-headline .amt { font-size: 30px; font-weight: 800; color: var(--gold-bright); letter-spacing: -.5px; }
.cd-headline .amt.negative { color: #ff9d8a; }
.cd-headline .sub { font-size: 12px; color: #a49d87; margin-top: 2px; }
.sb-rows { border-top: 1px solid #2c2920; padding-top: 12px; display: grid; gap: 8px; }
.sb-row { display: flex; justify-content: space-between; font-size: 13.5px; }
.sb-row .v { font-weight: 700; }
.sb-row.net .v { color: var(--gold-bright); }
.sb-chart { margin-top: 14px; }
.sb-chart svg { width: 100%; height: 54px; display: block; }
.sb-note { font-size: 11.5px; color: #8d8671; margin-top: 10px; line-height: 1.45; }

/* ---------- Review table ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.pnl { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 1100px; }
.pnl th, .pnl td { padding: 5px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid #f0ece0; }
.pnl th { background: #f6f2e7; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); position: sticky; top: 0; }
.pnl td:first-child, .pnl th:first-child { text-align: left; position: sticky; left: 0; background: #fff; max-width: 220px; }
.pnl th:first-child { background: #f6f2e7; }
.pnl tr.section td { font-weight: 800; background: #faf7ec; }
.pnl tr.subtotal td { font-weight: 700; border-top: 1px solid var(--line); }
.pnl tr.grand td { font-weight: 800; background: var(--black); color: #fff; border-bottom: none; }
.pnl tr.grand td:first-child { background: var(--black); }
.pnl td.neg { color: var(--red); }
.pnl td.auto-tag::after { content: " ⚙︎"; color: var(--gold-text); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 4px 0 16px; }
.kpi { background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.kpi .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.kpi .v.gold { color: var(--gold-text); }

/* national table */
table.natl { border-collapse: collapse; width: 100%; font-size: 13px; }
.natl th, .natl td { padding: 7px 10px; text-align: right; border-bottom: 1px solid #f0ece0; white-space: nowrap; }
.natl th { background: #f6f2e7; font-size: 11px; text-transform: uppercase; color: var(--ink-soft); }
.natl td:first-child, .natl th:first-child { text-align: left; }
.natl tr.grand td { font-weight: 800; background: #faf7ec; }
.natl-scroll { overflow-x: auto; margin-top: 12px; }
.natl.pl td, .natl.pl th { font-variant-numeric: tabular-nums; }
.natl.pl td.lbl { max-width: 300px; white-space: normal; }
.natl.pl tr.sec td { background: var(--black); color: #f3efe4; font-size: 11px; letter-spacing: .08em; text-align: left; font-weight: 700; }
.natl.pl td.tot { font-weight: 700; background: #faf7ec; }
.natl.pl tr.noi td { color: #6b5400; }
.natl.pl tr.pct td { color: var(--ink-soft); font-size: 12px; }

.empty-note { color: var(--ink-soft); font-size: 14px; padding: 8px 0; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.chip.draft { background: #eee7d7; color: #5b5646; }
.chip.submitted { background: #fdf6e0; color: #8a6d00; }
.chip.ops_reviewed { background: #e4eefc; color: #23538f; }
.chip.hq_approved { background: #eaf6ee; color: #1e7a3c; }
.chip.locked { background: var(--black); color: var(--gold); }
.group-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid #f0ece0; flex-wrap: wrap; }
.group-row:last-child { border-bottom: none; }
.group-row .season { font-weight: 800; font-size: 14px; min-width: 120px; }
.group-row .meta { color: var(--ink-soft); font-size: 12.5px; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar input, .filter-bar select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
details.acc summary .chips { display: flex; gap: 5px; margin-left: 10px; flex-wrap: wrap; }
details.acc { border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; background: #fffdf8; }
details.acc summary { padding: 12px 16px; font-weight: 700; cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.acc summary::after { content: "▸"; margin-left: auto; color: var(--gold-text); transition: transform .15s; }
details.acc[open] summary::after { transform: rotate(90deg); }
details.acc .acc-body { padding: 0 16px 14px; }
details.acc summary .sumt { margin-left: auto; font-weight: 800; }
details.acc summary::after { margin-left: 8px; }
.welcome-hero { background: linear-gradient(135deg, #000000, #24200f); color: #fff; border-radius: var(--radius); padding: 28px; margin-bottom: 16px; }
.welcome-hero h1 { color: #fff; }
.welcome-hero .gold { color: var(--gold-bright); }
.welcome-hero p { color: #cfc9b6; max-width: 64ch; }
.city-list { display: grid; gap: 10px; margin-top: 12px; }
.city-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 16px; }
.city-row .nm { font-weight: 800; font-size: 15px; }
.city-row .meta { color: var(--ink-soft); font-size: 12.5px; }
.city-row .spacer { flex: 1; }
@media print {
  header.topbar, .rail, .steps, .btn-row, .no-print { display: none !important; }
  .shell { display: block; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; }
  body { background: #fff; }
}

/* ---------- UI/UX pass: per-view shells + welcome board ---------- */
.shell--single { grid-template-columns: minmax(0, 1fr); max-width: 860px; }
.shell--wide { grid-template-columns: minmax(0, 1fr); max-width: 1520px; }
.budget-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 0 22px; align-items: start; }
/* min() lets the column shrink below 320px on a phone. A bare minmax(320px,1fr)
   cannot shrink, so the board pushed the whole page sideways at 375px. */

/* ---------- UI/UX pass wave 2: dialogs, toasts, focus, tables, mobile ---------- */
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--gold-bright); outline-offset: 2px;
}
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 14, 11, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 3px solid var(--gold-edge); padding: 20px 22px; width: 100%; max-width: 440px;
}
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.modal input, .modal textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; margin-bottom: 12px; resize: vertical;
}
.modal input:focus, .modal textarea:focus { outline: 2px solid var(--gold-edge); border-color: var(--gold-edge); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.primary.danger { background: var(--red); color: #fff; }
.primary.danger:hover { background: #cf3b23; }
#toastRoot { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 110; display: grid; gap: 8px; justify-items: center; }
.toast {
  background: var(--black); color: #f3efe4; border-radius: 10px; padding: 10px 18px;
  font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px);
  transition: opacity .25s, transform .25s; max-width: min(90vw, 480px);
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: #5c1509; color: #ffe0d8; }
/* national tables: sticky labels + real min-widths (mirrors .pnl) */
table.natl { min-width: 720px; }
table.natl.pl { min-width: 1150px; }
.natl td:first-child, .natl th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
.natl th:first-child { background: #f6f2e7; }
.natl tr.grand td:first-child { background: #faf7ec; }
.natl.pl tr.sec td { position: sticky; left: 0; }
/* scroll affordance on horizontally scrolling containers */
.tablewrap, .natl-scroll {
  background:
    linear-gradient(90deg, #fff 30%, rgba(255,255,255,0)) left / 48px 100%,
    linear-gradient(270deg, #fff 30%, rgba(255,255,255,0)) right / 48px 100%,
    radial-gradient(farthest-side at 0 50%, rgba(23,21,15,.16), transparent) left / 18px 100%,
    radial-gradient(farthest-side at 100% 50%, rgba(23,21,15,.16), transparent) right / 18px 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
}
/* workflow steps read as status pages, not build steps */
.steps button.wf { border-style: dashed; opacity: .78; }
.steps button.wf.active { opacity: 1; border-style: solid; }
.steps-sep { color: var(--line); align-self: center; margin: 0 2px; user-select: none; }
/* topbar on small screens */
@media (max-width: 720px) {
  header.topbar { flex-wrap: wrap; row-gap: 6px; padding: 10px 12px; }
  .topbar select { max-width: 150px; }
  .topbar .username { display: none; }
}

/* ---------- Step hints (money finder) ---------- */
.step-hints { display: grid; gap: 8px; margin: 0 0 14px; }
.step-hint {
  border-left: 3px solid var(--gold-edge); background: var(--gold-soft); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; line-height: 1.5;
}
.step-hint b { font-size: 13.5px; }
.step-hint > div { color: var(--ink-soft); margin-top: 2px; }
.hint-chip {
  background: var(--black); color: var(--gold); border-radius: 999px;
  padding: 1px 9px; font-size: 11px; font-weight: 800; margin-left: 6px; white-space: nowrap;
}

/* ---------- AI surfaces: bubbles, AI cards, Ask dock ---------- */
.bubble { border-radius: 12px; padding: 8px 12px; max-width: 88%; font-size: 13.5px; line-height: 1.5; }
.bubble.you { justify-self: end; background: var(--black); color: #fff; border-bottom-right-radius: 2px; }
.bubble.ai { justify-self: start; background: #f3efe4; border-bottom-left-radius: 2px; white-space: pre-wrap; font-variant-numeric: tabular-nums; }
.card--ai { border-left: 3px solid var(--gold-edge); }
.dock-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  background: var(--black); color: var(--gold-bright); border: 1px solid #3a3628;
  border-radius: 999px; padding: 11px 20px; font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow); letter-spacing: .02em;
}
.dock-fab:hover { border-color: var(--gold-edge); transform: translateY(-1px); }
.dock-panel[hidden] { display: none; }
.dock-panel {
  position: fixed; right: 20px; bottom: 74px; z-index: 60; width: 390px; max-height: 70vh;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 40px -8px rgba(23, 21, 15, .35); display: flex; flex-direction: column;
}
.dock-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--black); color: var(--gold-bright); border-radius: var(--radius) var(--radius) 0 0;
  padding: 10px 14px; font-size: 12.5px; font-weight: 700;
}
.dock-head button { background: none; border: none; color: #a49d87; font-size: 14px; padding: 2px 4px; }
.dock-head button:hover { color: #fff; }
.dock-log { flex: 1; overflow-y: auto; display: grid; gap: 8px; padding: 12px; min-height: 60px; align-content: start; }
.dock-log:empty::before { content: "Ask about your numbers, peer comparisons, or how any step works."; color: var(--ink-soft); font-size: 12.5px; }
.dock-row { display: flex; gap: 8px; padding: 0 12px 10px; }
.dock-row input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.dock-row .primary { padding: 8px 16px; }
@media (max-width: 600px) {
  .dock-panel { left: 12px; right: 12px; width: auto; bottom: 68px; }
  .dock-fab { right: 12px; bottom: 14px; }
}
@media print { .dock-fab, .dock-panel { display: none !important; } }

/* ---------- Sticky rail recap (Chris: reference it without scrolling up) ---------- */
.rail { max-height: calc(100vh - 88px); overflow-y: auto; scrollbar-width: thin; }
.rail-recap { margin-top: 12px; padding: 0; }
.rail-recap summary {
  cursor: pointer; font-weight: 700; font-size: 12.5px; padding: 10px 14px;
  list-style: none;
}
.rail-recap summary::-webkit-details-marker { display: none; }
.rail-recap .rr-body {
  padding: 0 14px 12px; font-size: 12px; line-height: 1.75; color: var(--ink);
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
@media (max-width: 900px) { .rail { max-height: none; overflow: visible; } .rail-recap { display: none; } }

/* prior-year salary comparison on Salaries lines */
.sal-prior { white-space: nowrap; font-size: 11.5px; }

/* ---------- Season-first budget board ---------- */
.season-group { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; background: #fffdf8; }
.season-group > summary {
  cursor: pointer; list-style: none; padding: 12px 16px; display: flex; align-items: baseline;
  gap: 12px; border-radius: 12px;
}
.season-group > summary::-webkit-details-marker { display: none; }
.season-group > summary::before { content: "▸"; color: var(--gold-text); font-size: 12px; }
.season-group[open] > summary::before { content: "▾"; }
.season-group[open] > summary { border-bottom: 1px solid var(--line); border-radius: 12px 12px 0 0; }
.season-group .season-name { font-weight: 800; font-size: 16px; }
.season-group .season-meta { color: var(--ink-soft); font-size: 12.5px; }
.season-group .budget-board { padding: 4px 16px 14px; }

/* values still identical to last season's budget (copy-forward awareness) */
input.prev-same { color: #979078; font-style: italic; }
.mgrid input.nonzero.prev-same { color: #979078; }

/* ---- UI/UX pass (budget-ui-ux branch) ---- */
.steps-meter { height: 5px; background: #eee8d8; border-radius: 99px; margin: 0 0 8px; overflow: hidden; }
.steps-meter-fill { height: 100%; background: var(--gold); border-radius: 99px; transition: width .3s ease; }
.steps button .step-tick { color: #2e7d32; font-weight: 800; }
.steps button.active .step-tick { color: inherit; }

/* People: the access cell can hold a home chip + several names; let it wrap and cap it
   so a wide scope never stretches the row (8/12). */
.natl td.acccell { white-space: normal; max-width: 340px; overflow-wrap: anywhere; }
