:root {
  --navy-deep: #002247;
  --navy: #003872;
  --blue: #426991;
  --gold: #c79b55;
  --gold-deep: #a87f3c;
  --ink: #16223a;
  --muted: #5a6678;
  --soft: #7e8aa0;
  --line: #dde4ee;
  --line-strong: #c6d1e0;
  --wash: #f1f4fa;
  --paper: #ffffff;
  --sage: #7a8c73;
  --red: #9b3b32;
  --r: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --lift: 0 1px 2px rgba(0, 34, 71, .06), 0 8px 24px -12px rgba(0, 34, 71, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--wash); color: var(--ink);
  font: 400 15px/1.6 "Geist", system-ui, sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, .big, .fig { font-family: "Albert Sans", sans-serif; }
a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--gold-deep); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--navy-deep) 232px, transparent 232px); }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s6);
  padding: var(--s6) var(--s5);
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(199, 155, 85, .16), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgba(66, 105, 145, .35), transparent 70%),
    var(--navy-deep);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: var(--s3); color: #fff; text-decoration: none;
  font: 700 13px/1.25 "Albert Sans", sans-serif; letter-spacing: .01em; }
.brand img { width: 36px; height: auto; }
.brand:hover { color: #fff; opacity: .9; }
.rail nav { display: flex; flex-direction: column; gap: var(--s1); flex: 1; }
.rail nav a {
  padding: 10px var(--s3); border-radius: var(--r); color: rgba(255, 255, 255, .72);
  text-decoration: none; font-weight: 500; transition: background-color .2s var(--ease), color .2s var(--ease);
}
.rail nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.rail nav a:active { background: rgba(255, 255, 255, .14); }
.rail nav a[aria-current="page"] { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 0 0 0 1px rgba(199, 155, 85, .55); }
button.quiet {
  width: 100%; padding: 10px var(--s3); border: 1px solid rgba(255, 255, 255, .2); border-radius: var(--r);
  background: transparent; color: rgba(255, 255, 255, .72); font: inherit; cursor: pointer; text-align: left;
}
button.quiet:hover { color: #fff; border-color: rgba(255, 255, 255, .4); }
button.quiet:active { background: rgba(255, 255, 255, .08); }

main { padding: var(--s6) var(--s7) var(--s8); width: 100%; min-width: 0; animation: rise .5s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- type ---------- */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s5); margin-bottom: var(--s6); }
.kicker a { color: inherit; }
.kicker { margin: 0 0 var(--s1); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-deep); }
h1 { margin: 0; font-size: 40px; line-height: 1.05; font-weight: 800; letter-spacing: -.03em; color: var(--navy-deep); }
h2 { margin: 0 0 var(--s3); font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--navy-deep); }
.note, .sub { color: var(--muted); max-width: 62ch; }
.note { margin: calc(var(--s5) * -1) 0 var(--s5); font-size: 14px; }
.meta { display: block; font-size: 13px; color: var(--soft); }
.empty { color: var(--muted); padding: var(--s5); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.more { margin: var(--s3) 0 0; font-size: 14px; }

/* ---------- figures ---------- */
.hero-figure { margin-bottom: var(--s6); }
.big {
  margin: 0; font-size: clamp(44px, 6vw, 72px); line-height: 1; font-weight: 800; letter-spacing: -.035em;
  color: var(--navy-deep);
}
.hero-figure .sub { margin: var(--s3) 0 0; }
.hero-figure strong { color: var(--gold-deep); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); margin-bottom: var(--s7); }
.stats > div { padding: var(--s5); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--lift); }
.label { margin: 0 0 var(--s1); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.fig { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--s6); align-items: start; }

/* ---------- tables ---------- */
.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--lift); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px var(--s4); text-align: left; vertical-align: top; }
thead th { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); background: var(--wash); white-space: nowrap; }
tbody tr + tr td, tbody tr + tr th { box-shadow: inset 0 1px 0 var(--line); }
tbody tr:hover td { background: #fafbfd; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pending { color: var(--soft); font-style: italic; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--wash); color: var(--muted); }
.s-approved { background: rgba(199, 155, 85, .16); color: var(--gold-deep); }
.s-paid { background: rgba(122, 140, 115, .18); color: #4e6049; }
.s-denied { background: rgba(155, 59, 50, .10); color: var(--red); }
.s-countered { background: rgba(66, 105, 145, .14); color: var(--blue); }

.years { display: flex; flex-wrap: wrap; gap: var(--s1); }
.years a { padding: 6px var(--s3); border-radius: var(--r); text-decoration: none; font-weight: 500; color: var(--muted); border: 1px solid transparent; }
.years a:hover { border-color: var(--line-strong); color: var(--ink); }
.years a[aria-current] { background: var(--navy); color: #fff; }

/* P&L */
.pnl { font-size: 12.5px; table-layout: fixed; min-width: 1040px; }
.pnl th:first-child { width: 190px; }
.pnl th, .pnl td { padding: 9px 8px; }
.pnl th:first-child, .pnl td:first-child { padding-left: var(--s4); }
.pnl th[scope="row"] { font-weight: 500; white-space: nowrap; position: sticky; left: 0; background: var(--paper); }
.pnl .group th { padding-top: var(--s4); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gold-deep); }
.pnl .total { font-weight: 600; background: var(--wash); }
.pnl .net td, .pnl .net th { font-weight: 700; color: var(--navy-deep); box-shadow: inset 0 2px 0 var(--navy-deep) !important; }
.dash { color: var(--line-strong); }

/* ---------- login ---------- */
body.login {
  min-height: 100vh; display: grid; place-items: center; padding: var(--s4);
  background:
    radial-gradient(90% 60% at 10% 0%, rgba(199, 155, 85, .22), transparent 60%),
    radial-gradient(70% 60% at 100% 100%, rgba(66, 105, 145, .45), transparent 70%),
    var(--navy-deep);
}
.login main { max-width: 380px; padding: 0; color: #fff; text-align: center; }
.login .mark { width: 64px; margin-bottom: var(--s4); }
.login h1 { color: #fff; font-size: 26px; }
.login .sub { margin: var(--s1) 0 var(--s6); color: rgba(255, 255, 255, .65); }
.login form { display: grid; gap: var(--s4); padding: var(--s6); text-align: left; background: var(--paper); color: var(--ink); border-radius: var(--r); box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .5); }
.login label { display: grid; gap: var(--s1); font-size: 13px; font-weight: 600; color: var(--muted); }
.login input { padding: 12px var(--s3); font: inherit; font-size: 16px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r); background: #fff; }
.login input:focus-visible { outline-offset: 0; border-color: var(--gold); }
.login button {
  margin-top: var(--s2); padding: 13px; border: 0; border-radius: var(--r); background: var(--navy); color: #fff;
  font: 600 15px "Albert Sans", sans-serif; cursor: pointer; transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.login button:hover { background: var(--navy-deep); }
.login button:active { transform: translateY(1px); }
.error { margin: 0; padding: var(--s3); border-radius: var(--r); background: rgba(155, 59, 50, .08); color: var(--red); font-size: 14px; }

/* ---------- small screens ---------- */
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: none; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s4); }
  .rail nav { flex-direction: row; flex-wrap: wrap; flex-basis: 100%; order: 3; }
  .rail nav a { padding: 8px 10px; }
  .rail form { margin-left: auto; }
  button.quiet { width: auto; }
  main { padding: var(--s5) var(--s4) var(--s7); }
  h1 { font-size: 32px; }
  .split, .hero-row { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { main { animation: none; } * { transition: none !important; } }

/* ---------- overview ---------- */
.hero-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s6); align-items: end; margin-bottom: var(--s6); }
.hero-row .hero-figure { margin: 0; }
.by-year { display: flex; flex-wrap: wrap; gap: var(--s2); }
.by-year a {
  display: grid; gap: 2px; min-width: 150px; padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper); text-decoration: none; color: var(--ink); transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.by-year a:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.by-year a:active { transform: none; }
.by-year a[aria-current] { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.by-year .fig { font-size: 20px; }
.fig.neg { color: var(--red); }
.stats.four { margin-bottom: var(--s6); }
.panel { margin-bottom: var(--s6); padding: var(--s5); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--lift); }
h2.gap { margin-top: var(--s6); }

/* chart */
:root { --c-in: #3a75c4; --c-out: #a8752a; --c-bal: #6a4fb0; }
.chart { margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin-bottom: var(--s3); font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: var(--s2); }
.legend .unit { margin-left: auto; color: var(--soft); }
.k { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.k.in { background: var(--c-in); } .k.out { background: var(--c-out); }
.k.bal { height: 2px; width: 16px; border-radius: 0; background: var(--c-bal); }
.plot { position: relative; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot .grid { stroke: var(--line); stroke-width: 1; }
.plot .grid.faint { stroke: #eef2f7; }
.plot .zero { stroke: var(--soft); stroke-width: 1; }
.plot .tick { font: 12px "Geist", sans-serif; fill: var(--soft); font-variant-numeric: tabular-nums; }
.plot .b-in { fill: var(--c-in); } .plot .b-out { fill: var(--c-out); }
.plot .bal { fill: none; stroke: var(--c-bal); stroke-width: 2; stroke-linejoin: round; }
.plot .cross { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; }
.plot .hit { fill: transparent; cursor: crosshair; }
.tip {
  position: absolute; top: 12px; min-width: 190px; padding: var(--s3); pointer-events: none; font-size: 13px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--lift);
}
.tip p { margin: 0 0 var(--s2); font-weight: 600; color: var(--muted); }
.tip div { display: flex; align-items: center; gap: var(--s2); }
.tip b { font-variant-numeric: tabular-nums; color: var(--ink); }
.tip span { color: var(--soft); }

/* metrics */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.metric { padding: var(--s4); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.metric .fig { font-size: 22px; }
.bench { margin: var(--s2) 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* P&L rows */
.pnl .balance th, .pnl .balance td { font-weight: 600; color: var(--navy-deep); background: var(--wash); }
.pnl .subtotal th, .pnl .subtotal td { font-weight: 600; }
.pnl .running th, .pnl .running td { color: var(--c-bal); font-weight: 500; }
.note.after { margin: var(--s3) 0 0; }

/* grants and articles */
.rowlink { text-decoration: none; }
.rowlink:hover strong { text-decoration: underline; }
.answers { display: grid; gap: 1px; margin: 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.answers div { display: grid; grid-template-columns: minmax(160px, 38%) 1fr; gap: var(--s4); padding: var(--s3) var(--s4); background: var(--paper); }
.answers dt { font-size: 13px; color: var(--muted); }
.answers dd { margin: 0; white-space: pre-wrap; }
.answers.compact div { grid-template-columns: 140px 1fr; }
.button {
  display: inline-block; padding: 10px var(--s4); border-radius: var(--r); background: var(--navy); color: #fff; text-decoration: none; font-weight: 600;
  transition: background-color .2s var(--ease);
}
.button:hover { background: var(--navy-deep); color: #fff; }
.button:active { transform: translateY(1px); }
.article-title { font-size: 34px; max-width: 28ch; }
.reading { max-width: 70ch; padding: var(--s6); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.reading .lede { font-size: 18px; color: var(--muted); margin-top: 0; }
.reading h2 { margin-top: var(--s6); }
.reading p, .reading li { line-height: 1.75; }
@media (max-width: 860px) { .answers div, .answers.compact div { grid-template-columns: 1fr; gap: var(--s1); } .legend .unit { margin-left: 0; } }

/* ---------- collapsible rail ---------- */
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail nav a, button.quiet, button.fold { display: flex; align-items: center; gap: var(--s3); }
button.fold {
  width: 100%; padding: 10px var(--s3); border: 0; border-radius: var(--r); background: transparent; color: rgba(255, 255, 255, .55);
  font: inherit; font-size: 14px; cursor: pointer; transition: color .2s var(--ease), background-color .2s var(--ease);
}
button.fold:hover { color: #fff; background: rgba(255, 255, 255, .06); }
button.fold:active { background: rgba(255, 255, 255, .12); }
.rail-min .shell { grid-template-columns: 76px 1fr; background: linear-gradient(to right, var(--navy-deep) 76px, transparent 76px); }
.rail-min .rail { padding: var(--s5) var(--s3); align-items: center; }
.rail-min .rail span { display: none; }
.rail-min .brand img { width: 40px; }
.rail-min .rail nav a, .rail-min button.quiet, .rail-min button.fold { justify-content: center; padding: 11px; }
.rail-min button.fold .ico { transform: rotate(180deg); }
.rail-min .rail form, .rail-min .rail nav { width: 100%; }

/* ---------- range controls ---------- */
.rangebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.custom { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-size: 13px; color: var(--muted); }
.custom label { display: inline-flex; align-items: center; gap: var(--s2); }
.custom input { padding: 7px var(--s2); font: inherit; font-size: 14px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--paper); }
.custom button {
  padding: 8px var(--s4); border: 1px solid var(--navy); border-radius: var(--r); background: var(--paper); color: var(--navy);
  font: 600 14px "Geist", sans-serif; cursor: pointer; transition: background-color .2s var(--ease), color .2s var(--ease);
}
.custom button:hover, .custom button.on { background: var(--navy); color: #fff; }
.custom button:active { transform: translateY(1px); }
.period { margin: 0 0 var(--s4); font-size: 14px; color: var(--muted); }
@media (max-width: 860px) { .rail-min .shell { grid-template-columns: 1fr; background: none; } .rail-min .rail span { display: inline; } button.fold { display: none; } }
