/* Budget 2027 prototype. Quiet ledger look: ink blue on paper, tabular figures, one accent per meaning. */
:root {
  --ink: #17212d;
  --ink-2: #44515f;
  --muted: #687584;
  --navy: #16324f;
  --navy-2: #24496f;
  --line: #d9dfe6;
  --line-2: #eceff3;
  --paper: #ffffff;
  --bg: #f3f5f7;
  --ref: #f0f2f5;
  --ref-series: #8a99ab;
  --scen: #0f766e;
  --scen-bg: #e9f5f3;
  --warn-ink: #9a5b00;
  --warn-bg: #fff3dc;
  --bad: #b42318;
  --good: #1e6b3a;
  --focus: #2f6fb3;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: 1.35rem; color: var(--navy); }
h2 { font-size: 1.02rem; color: var(--navy); margin-bottom: .6rem; }
h3 { font-size: .92rem; margin: 1rem 0 .4rem; color: var(--ink-2); }
p { margin: .25rem 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.error { color: var(--bad); margin: 0; }
.empty { color: var(--muted); padding: .8rem; text-align: center; }
.pad { padding: 1rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

.proto-banner {
  background: #ffe8a3; color: #4f3a00; text-align: center; font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-bottom: 1px solid #e3c771; position: sticky; top: 0; z-index: 50;
}

/* login */
.login { display: flex; justify-content: center; padding: 12vh 1rem; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: .85rem; background: var(--paper);
  border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: 4px; padding: 1.6rem 1.5rem; }
.login-card .field { font-size: 13px; }
.login-card input { padding: .5rem .6rem; }
.login-card .btn { padding: .55rem; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1.6rem; padding: 0 1.2rem; height: 50px; background: var(--navy);
  color: #fff; position: sticky; top: 22px; z-index: 40; }
.brand { font-weight: 700; font-size: 15px; }
.nav { display: flex; gap: .15rem; flex: 1; height: 100%; }
.nav a { color: #cfdbe8; text-decoration: none; padding: 0 .85rem; display: flex; align-items: center;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent; }
.nav a:hover { color: #fff; background: var(--navy-2); }
.nav a.active { color: #fff; border-bottom-color: #8fc1e8; font-weight: 600; }
.user { display: flex; align-items: center; gap: .9rem; font-size: 12.5px; }
.who { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.who span { color: #b9c9da; font-size: 11.5px; }
.user .btn.ghost { color: #e3ecf5; border-color: #4d6c8f; background: transparent; }
.user .btn.ghost:hover { background: var(--navy-2); }

main { padding: 1rem 1.2rem 2.5rem; max-width: 1680px; margin: 0 auto; display: flex; flex-direction: column; gap: .9rem; }

/* page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.page-head > div:first-child { max-width: 70ch; }
.page-head p { font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; }
.version-status { align-self: center; }
.save-state { align-self: center; font-size: 12px; min-width: 9em; }

/* generic */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: .9rem 1rem; }
.card.tight { padding: .6rem; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.section-head h2 { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.field { display: flex; flex-direction: column; gap: .2rem; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 600; }
.field small { color: var(--warn-ink); font-size: 11px; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #b7c1cc; border-radius: 3px;
  padding: .36rem .5rem; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0ea; outline-offset: 0; border-color: var(--focus); }
textarea { width: 100%; resize: vertical; min-height: 64px; font-size: 15px; line-height: 1.45; }
.btn { font: inherit; font-size: 13px; border: 1px solid #a9b5c2; background: #fff; color: var(--ink); border-radius: 3px;
  padding: .38rem .8rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #eef2f6; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--navy-2); }
.btn.ghost:hover { background: #eef2f6; border-color: var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: .18rem .5rem; font-size: 12px; }

.pill { display: inline-block; padding: .08rem .5rem; border-radius: 9px; font-size: 11.5px; font-weight: 600;
  background: #e6ebf1; color: var(--navy); vertical-align: 1px; }
.pill.submitted { background: #e0ecfb; color: #1d4f91; }
.pill.validated { background: #def2e5; color: var(--good); }
.pill.abandoned { background: #f6e1df; color: var(--bad); }
.badge-warn { color: var(--warn-ink); background: var(--warn-bg); border-radius: 2px; padding: 0 .35rem; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 600; border-radius: 2px; padding: 0 .3rem; vertical-align: 1px; }
.tag.rule, .tag.scen { background: var(--scen-bg); color: var(--scen); border: 1px solid #b8dcd6; }
.count-badge { display: inline-block; min-width: 1.6em; text-align: center; font-size: 12px; padding: 0 .4rem; border-radius: 9px;
  background: var(--warn-bg); color: var(--warn-ink); vertical-align: 2px; }
.count-badge.zero { background: #def2e5; color: var(--good); }
.notice { background: var(--warn-bg); border-left: 3px solid #d99a2b; padding: .55rem .8rem; border-radius: 2px; margin: .5rem 0; }
.notice ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.info { background: #edf3fa; border-left: 3px solid #6f9bd1; padding: .5rem .8rem; border-radius: 2px; margin: 0; }
.dirty { color: var(--warn-ink); font-size: 12px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.scroll-x { overflow-x: auto; }
.scroll-y { max-height: 62vh; overflow-y: auto; }
.hint { font-size: 12px; color: var(--scen); align-self: center; max-width: 34ch; }

.legend { display: flex; gap: 1.2rem; font-size: 12px; color: var(--muted); margin-top: .5rem; flex-wrap: wrap; padding: 0 .2rem; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--line); vertical-align: -2px; margin-right: 5px; }
.sw.ref { background: var(--ref); }
.sw.rule { background: var(--scen-bg); border-color: #b8dcd6; }
.sw.warn { background: #fff; box-shadow: inset 3px 0 0 #d99a2b; }

/* plain tables */
table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { border-bottom: 1px solid var(--line-2); padding: .32rem .45rem; text-align: left; vertical-align: top; }
table.data th { background: #f1f4f7; font-weight: 600; color: #34465a; white-space: nowrap; }
.scroll-y table.data th { position: sticky; top: 0; z-index: 1; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.strong { font-weight: 600; }
table.data tr.section td { background: #e9eef4; font-weight: 600; color: var(--navy); }
table.data tr.subtotal td { background: #f5f7f9; font-weight: 600; border-top: 1px solid #c3ccd6; }
table.data tr.result td { font-weight: 700; border-top: 2px solid #7d8da0; }
table.data tr.delta td { color: var(--scen); font-weight: 600; }
table.data tr.first td { border-top: 1px solid #c9d2dc; }
table.data tr.result-fam td { font-weight: 700; }
table.data tr.result-fam.first td { border-top: 2px solid #7d8da0; }
table.data tr.muted-row td { color: var(--warn-ink); font-style: italic; }
table.data tbody tr:hover td { background: #f7f9fb; }
table.data td.label-col { min-width: 230px; }
table.data td { white-space: nowrap; }
table.data td.label-col, .preview table.data td:first-child, table.data.journal-table td { white-space: normal; }
.mono-num { font-variant-numeric: tabular-nums; }

/* totals band: the ledger foot of the grid */
.ledger { background: var(--paper); border: 1px solid var(--line); border-top: 3px solid var(--navy); border-radius: 0 0 4px 4px; }
.ledger table.data th { background: #fff; color: var(--muted); font-weight: 600; }
.ledger table.data td:first-child { font-weight: 600; white-space: nowrap; }
.ledger table.data tr.result td { background: #f4f7fa; font-size: 13px; }

/* grid */
.grid-actions { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; padding: .2rem .2rem .6rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
#new-label { width: 290px; }
#new-nature { max-width: 210px; }
#new-cc { max-width: 260px; }
.tabulator { font-size: 12.5px; border: 1px solid var(--line); background: #fff; }
.tabulator .tabulator-header { border-bottom: 1px solid #c3ccd6; }
.tabulator .tabulator-header .tabulator-col { background: #f1f4f7; }
.tabulator .tabulator-cell.num, .tabulator-cell.num { font-variant-numeric: tabular-nums; }
.tabulator-row .tabulator-cell { border-right-color: var(--line-2); }
.tabulator-row.tabulator-row-even { background: #fbfcfd; }
.tabulator-row.row-ref, .tabulator-row.row-ref.tabulator-row-even { background: var(--ref); color: #5a6876; }
.tabulator-row.row-rule, .tabulator-row.row-rule.tabulator-row-even { background: var(--scen-bg); }
.tabulator-row.row-warn .tabulator-cell[tabulator-field="label"] { box-shadow: inset 3px 0 0 #d99a2b; }
.tabulator-row.row-new { animation: newrow 1.6s ease-out; }
@keyframes newrow { from { background: #fff3c4; } }
.tabulator-cell.total-col { font-weight: 600; background: #f6f8fa; }
.tabulator-cell.cell-active { outline: 2px solid var(--focus); outline-offset: -2px; }
.tabulator-cell.neg { color: var(--bad); }
.row-del { border: none; background: none; color: #97a3b0; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.row-del:hover { color: var(--bad); }
.tip { max-width: 420px; white-space: pre-line; font-size: 12px; }
.tabulator-edit-list .tabulator-edit-list-item { font-size: 12.5px; }

/* scenarios */
.scen-form { display: flex; flex-direction: column; gap: .4rem; }
.row-end { display: flex; justify-content: flex-end; }
.examples { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { border: 1px solid #c6d1dd; background: #f7f9fb; border-radius: 12px; padding: .15rem .6rem; font-size: 12px;
  cursor: pointer; color: var(--navy-2); max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { background: #e9f0f8; }
.scen-result { border-top: 1px solid var(--line); margin-top: .9rem; padding-top: .2rem; }
.items { display: flex; flex-direction: column; gap: .5rem; }
.item-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; padding: .6rem .7rem; border: 1px solid var(--line);
  border-left: 3px solid var(--scen); border-radius: 3px; background: #fbfcfd; }
.item-row .kind { font-weight: 600; color: var(--navy); min-width: 150px; align-self: center; }
.item-row input.count { width: 70px; }
.item-row input.pct { width: 80px; text-align: right; }
.item-row input.amount { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.assumption-field input { border-color: #d9b56a; background: #fffaf0; }
.preview table.data td:first-child { min-width: 320px; }
.assumption { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.create-bar { display: flex; justify-content: flex-end; align-items: flex-end; gap: .7rem; margin-top: .8rem; }
#scen-name { width: 320px; }

.compare-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.delta-figure { display: flex; flex-direction: column; align-items: flex-end; }
.delta-figure strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.chart-head { display: flex; justify-content: flex-end; margin: .8rem 0 .3rem; }
.chart-box { position: relative; height: 280px; }

/* journal */
.journal-table { table-layout: fixed; }
.journal-table td { font-size: 12px; overflow-wrap: anywhere; }
.journal-table th:nth-child(1) { width: 112px; }
.journal-table th:nth-child(2) { width: 96px; }
.journal-table th:nth-child(3) { width: 160px; }
.journal-table th:nth-child(4) { width: 20%; }
.journal-table td.before { color: #6b4a3a; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 1px .6rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.kv-list { margin: 0; padding-left: 1rem; }
.act { font-weight: 600; }
.act-delete { color: var(--bad); }
.act-create { color: var(--good); }

/* toasts */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #22364d; color: #fff; padding: .6rem .9rem; border-radius: 3px; max-width: 440px;
  box-shadow: 0 4px 14px rgba(20, 30, 45, .2); font-size: 13px; }
.toast.error { background: var(--bad); }
.toast.warn { background: #8a5a00; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: .4rem .8rem; gap: .6rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .nav a { padding: .4rem .6rem; }
  main { padding: .8rem; }
}
