/* ═══════════════════════════════════════════════════════════════════
   ASP Exec Dashboard — design system
   "The fund ledger meets the morning lake."
   Serif display (Charter stack) for titles; quiet system sans for UI;
   tabular numerals wherever data lives. One interactive accent
   (sea-green). Chart series colors come from the validated dataviz
   reference palette — do not improvise hues; re-run the validator.
   Light + dark are both SELECTED (not a flip): media query covers OS,
   [data-theme] override wins both ways.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;
  /* surfaces */
  --bg: #f7f8f7;            /* morning-haze white, cool green cast */
  --surface: #ffffff;
  --surface-2: #f1f4f3;     /* inset wells, table header */
  --line: #e3e8e6;          /* hairlines */
  --line-strong: #cfd7d4;
  /* ink */
  --ink: #16211f;           /* harbor ink */
  --ink-2: #5a6b67;
  --muted: #6b7a76;
  /* interactive accent (UI only — charts use series tokens) */
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-wash: #0f766e14;
  /* status (text-grade, AA on this bg) */
  --good: #0e6b31;
  --bad: #b42318;
  --warn: #9a6700;
  --warn-wash: #9a670014;
  --bad-wash: #b4231810;
  --good-wash: #0e6b3112;
  /* chart chrome */
  --chart-grid: #e7ebe9;
  --chart-axis: #c3cdc9;
  /* series: actual / budget / prior-year (style + color encode identity) */
  --s-actual: #0f766e;
  --s-budget: #898781;
  --s-py: #2a78d6;
  /* categorical slots (validated reference palette, fixed order) */
  --c1: #2a78d6; --c2: #008300; --c3: #e87ba4; --c4: #eda100;
  --c5: #1baf7a; --c6: #eb6834; --c7: #4a3aa7; --c8: #e34948;
  --c-other: #898781;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(22 33 31 / 0.05), 0 4px 16px rgb(22 33 31 / 0.05);
  --shadow-lift: 0 2px 6px rgb(22 33 31 / 0.08), 0 12px 32px rgb(22 33 31 / 0.10);
  --font-ui: system-ui, "Segoe UI", -apple-system, sans-serif;
  --font-display: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101514;
    --surface: #171d1c;
    --surface-2: #1d2524;
    --line: #26302e;
    --line-strong: #35413e;
    --ink: #ecf1ef;
    --ink-2: #a9b6b2;
    --muted: #8a9793;
    --accent: #2aa48b;
    --accent-ink: #08110f;
    --accent-wash: #2aa48b1f;
    --good: #46c776;
    --bad: #f97066;
    --warn: #e5b454;
    --warn-wash: #e5b45418;
    --bad-wash: #f9706614;
    --good-wash: #46c77614;
    --chart-grid: #232c2a;
    --chart-axis: #3a4643;
    --s-actual: #2aa48b;
    --s-budget: #898781;
    --s-py: #3987e5;
    --c1: #3987e5; --c2: #008300; --c3: #d55181; --c4: #c98500;
    --c5: #199e70; --c6: #d95926; --c7: #9085e9; --c8: #e66767;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.3);
    --shadow-lift: 0 2px 6px rgb(0 0 0 / 0.5), 0 16px 40px rgb(0 0 0 / 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101514; --surface: #171d1c; --surface-2: #1d2524;
  --line: #26302e; --line-strong: #35413e;
  --ink: #ecf1ef; --ink-2: #a9b6b2; --muted: #8a9793;
  --accent: #2aa48b; --accent-ink: #08110f; --accent-wash: #2aa48b1f;
  --good: #46c776; --bad: #f97066; --warn: #e5b454;
  --warn-wash: #e5b45418; --bad-wash: #f9706614; --good-wash: #46c77614;
  --chart-grid: #232c2a; --chart-axis: #3a4643;
  --s-actual: #2aa48b; --s-budget: #898781; --s-py: #3987e5;
  --c1: #3987e5; --c2: #008300; --c3: #d55181; --c4: #c98500;
  --c5: #199e70; --c6: #d95926; --c7: #9085e9; --c8: #e66767;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.3);
  --shadow-lift: 0 2px 6px rgb(0 0 0 / 0.5), 0 16px 40px rgb(0 0 0 / 0.45);
}

/* ── base ── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
::selection { background: var(--accent-wash); }

h1, h2, h3 { margin: 0; font-weight: 600; }
.display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.num, .value, td.n, .delta { font-variant-numeric: tabular-nums; }

button {
  font: inherit; color: inherit; background: none; border: none;
  cursor: pointer; padding: 0;
}
button:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  button { transition: transform 140ms var(--ease-out), background 140ms ease; }
}

/* ── app shell ── */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }

.rail {
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--surface);
}
.brand {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  padding: 4px 10px 14px;
}
.brand small { display: block; font-family: var(--font-ui); font-size: 10.5px; font-weight: 500; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }
.rail-group {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 4px;
}
.rail a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.rail a:hover { background: var(--surface-2); color: var(--ink); }
.rail a.active { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.rail a svg { width: 15px; height: 15px; flex: none; opacity: 0.85; }
.rail .planned-dot { margin-left: auto; font-size: 9px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 5px; }

.main { min-width: 0; display: flex; flex-direction: column; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 22px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); backdrop-filter: none; }
}
.page-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin-right: auto; }

select.prop-select {
  font: 500 13.5px var(--font-ui); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 6px 28px 6px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7a76' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}

.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px;
}
.seg button {
  padding: 4.5px 11px; border-radius: 5px; font-size: 12.5px; font-weight: 550;
  color: var(--ink-2);
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: var(--radius-sm); color: var(--ink-2); border: 1px solid transparent;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ── content grid ── */
.content { padding: 20px 22px 48px; display: flex; flex-direction: column; gap: 18px; }
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; } .col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }
@media (max-width: 1100px) {
  .col-3 { grid-column: span 6; } .col-4 { grid-column: span 6; } .col-8 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%); transition: transform 220ms var(--ease-out); width: 230px; }
  .rail.open { transform: translateX(0); box-shadow: var(--shadow-lift); }
  .col-3, .col-4, .col-6 { grid-column: span 12; }
}

.section-h {
  font-family: var(--font-display); font-size: 15.5px; font-weight: 700;
  color: var(--ink); letter-spacing: -0.005em;
  display: flex; align-items: baseline; gap: 8px;
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.section-h small { font-family: var(--font-ui); font-weight: 450; font-size: 12px; color: var(--muted); }

/* ── metric card ── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 12px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0;
}
.card.clickable { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .card.clickable { transition: border-color 140ms ease, box-shadow 140ms ease; }
  .card.clickable:hover { border-color: var(--line-strong); box-shadow: var(--shadow-lift); }
}
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-label { font-size: 12px; font-weight: 550; color: var(--ink-2); letter-spacing: 0.01em; }
.card-badges { margin-left: auto; display: flex; gap: 4px; flex: none; }
.card .value {
  font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1;
  color: var(--ink);
}
.card .value small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.deltas { display: flex; gap: 6px; flex-wrap: wrap; }
.delta {
  font-size: 11.5px; font-weight: 600; border-radius: 99px; padding: 1.5px 8px;
  display: inline-flex; align-items: center; gap: 3px;
}
.delta.up { color: var(--good); background: var(--good-wash); }
.delta.down { color: var(--bad); background: var(--bad-wash); }
.delta.flat { color: var(--ink-2); background: var(--surface-2); }
.delta .k { font-weight: 450; opacity: 0.8; }
.card-foot {
  display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px;
  font-size: 10.5px; color: var(--muted);
}
.card-foot .dot { opacity: 0.5; }
.spark { margin: 2px -4px 0; }

/* badges */
.badge {
  font-size: 9.5px; font-weight: 650; letter-spacing: 0.05em; text-transform: uppercase;
  border-radius: 4px; padding: 1.5px 5px; white-space: nowrap;
}
.badge.mock { background: var(--c7); color: #fff; }
.badge.stale { background: var(--warn-wash); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.caveat { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); cursor: help; }
.badge.await { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); }

.awaiting {
  border-style: dashed; box-shadow: none; background: transparent;
}
.awaiting .value { color: var(--muted); font-size: 15px; font-weight: 500; }

/* ── dock strip (signature) ── */
.dock { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; }
.dock::after { content: ""; }
.berth {
  flex: 1 0 118px; min-width: 118px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 11px 9px; text-align: left;
  display: flex; flex-direction: column; gap: 7px;
  border-bottom: 3px solid var(--line-strong);
}
.berth:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.berth.on { border-color: var(--accent); border-bottom-color: var(--accent); background: var(--accent-wash); }
.berth .b-name { font-size: 11.5px; font-weight: 650; color: var(--ink); line-height: 1.2; }
.berth .b-sub { font-size: 10px; color: var(--muted); }
.berth .b-row { display: flex; align-items: flex-end; gap: 8px; }
.gauge { width: 14px; height: 34px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); position: relative; overflow: hidden; flex: none; }
.gauge > i {
  position: absolute; inset: auto 0 0 0; display: block;
  background: var(--s-actual); opacity: 0.85;
  border-radius: 0 0 3px 3px;
}
.berth .b-num { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.berth .b-num small { display: block; font-size: 9.5px; font-weight: 500; color: var(--muted); letter-spacing: 0.03em; }

/* ── charts ── */
.chart-wrap { position: relative; }
.chart-wrap svg {
  display: block; width: 100%; height: auto; font-family: var(--font-ui);
  max-height: 280px; margin-inline: auto; /* wide cards must not become towers */
}
.chart-tip {
  position: absolute; pointer-events: none; z-index: 20;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
  padding: 7px 10px; font-size: 11.5px; line-height: 1.45;
  min-width: 120px; opacity: 0; transition: opacity 100ms ease;
  font-variant-numeric: tabular-nums;
}
.chart-tip.show { opacity: 1; }
.chart-tip .t-month { font-weight: 650; margin-bottom: 2px; }
.chart-tip .t-row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.chart-tip .t-row b { color: var(--ink); font-weight: 600; }
.chart-tip .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--ink-2); padding-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px); height: 2px; }

/* ── tables ── */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-size: 10.5px; font-weight: 650; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
  padding: 7px 10px; border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.tbl th:first-child { border-radius: 6px 0 0 0; }
.tbl th:last-child { border-radius: 0 6px 0 0; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.n { text-align: right; }
.tbl th.n { text-align: right; }
.tbl tbody tr:hover td { background: var(--surface-2); }

/* ── drawer ── */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 60; background: rgb(10 15 14 / 0.32);
  opacity: 0; transition: opacity 200ms ease; pointer-events: none;
}
.drawer-scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(560px, 94vw);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-h {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-h h2 { font-family: var(--font-display); font-size: 17px; }
.drawer-body { padding: 16px 20px 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

/* ── forms (admin) ── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 7px 10px;
}
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-wash); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); }

.note { font-size: 12px; color: var(--muted); }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── weather strip ── */
.wx { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wx .d {
  text-align: center; padding: 8px 4px 7px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.wx .d b { font-size: 13px; font-variant-numeric: tabular-nums; }
.wx .d span { font-size: 10px; color: var(--muted); }
.wx .glyph { font-size: 14px; line-height: 1; }

/* ── login ── */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-wash), transparent 60%),
    var(--bg);
  margin: 0; font-family: var(--font-ui); color: var(--ink);
}
.login-card {
  width: min(360px, 92vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lift); padding: 30px 28px 26px;
}
.login-card h1 { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.01em; }
.login-sub { color: var(--muted); font-size: 12px; margin: 4px 0 20px; }
.login-card label { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }
.login-card input {
  width: 100%; font: inherit; padding: 9px 11px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.login-card button {
  width: 100%; margin-top: 18px; padding: 10px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; font-weight: 650; font-size: 14px;
}
.login-err { color: var(--bad); font-size: 12.5px; margin: 10px 0 0; }

/* ── skeleton / empty ── */
.skeleton { border-radius: var(--radius); background: linear-gradient(100deg, var(--surface-2) 40%, var(--line) 50%, var(--surface-2) 60%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; min-height: 96px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .drawer { transition: opacity 150ms ease; transform: none; opacity: 0; pointer-events: none; }
  .drawer.show { opacity: 1; pointer-events: auto; }
}

@media print {
  .rail, .topbar, .drawer, .drawer-scrim { display: none !important; }
  .content { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}
