/* Ink & Brass — the same tokens as the planning documents, so the product and
   the thinking behind it read as one thing. Semantic colour (go/warn/stop) is
   kept separate from the brass accent: status must never compete with emphasis. */

:root {
  --ink: #152A38;
  --paper: #F4F5F2;
  --brass: #A87C2E;
  --go: #2F6B4F;
  --warn: #9A6410;
  --stop: #96382C;

  --surface: #FFFFFF;
  --surface-sunk: #ECEDE8;
  --line: #D8DAD3;
  --line-soft: #E6E7E1;
  --muted: #5D6B75;
  --faint: #8A959D;

  --display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --data: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --rail: 232px;
  --r: 6px;
  --shadow: 0 1px 2px rgba(21, 42, 56, .06), 0 8px 24px rgba(21, 42, 56, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E8EAE4;
    --paper: #101A21;
    --brass: #D2A253;
    --go: #6FB08C;
    --warn: #D3A055;
    --stop: #D97F70;
    --surface: #17242D;
    --surface-sunk: #0C151B;
    --line: #2A3B47;
    --line-soft: #21313B;
    --muted: #9AA9B3;
    --faint: #6D7E89;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --ink: #E8EAE4; --paper: #101A21; --brass: #D2A253;
  --go: #6FB08C; --warn: #D3A055; --stop: #D97F70;
  --surface: #17242D; --surface-sunk: #0C151B;
  --line: #2A3B47; --line-soft: #21313B; --muted: #9AA9B3; --faint: #6D7E89;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  --ink: #152A38; --paper: #F4F5F2; --brass: #A87C2E;
  --go: #2F6B4F; --warn: #9A6410; --stop: #96382C;
  --surface: #FFFFFF; --surface-sunk: #ECEDE8;
  --line: #D8DAD3; --line-soft: #E6E7E1; --muted: #5D6B75; --faint: #8A959D;
  --shadow: 0 1px 2px rgba(21, 42, 56, .06), 0 8px 24px rgba(21, 42, 56, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; text-wrap: balance; margin: 0; }

button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 3px; }

/* ---------- shell ---------- */

.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }

/* The rail is a constant dark field in both themes — it anchors the page and
   keeps navigation out of the content's contrast budget. Deliberately literal
   rather than token-driven: routing it through --ink/--paper makes the tokens
   invert underneath it and collides with the theme overrides. */
.rail {
  background: #152A38;
  color: #F4F5F2;
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
@media (prefers-color-scheme: dark) { .rail { background: #0A1218; color: #E8EAE4; } }
:root[data-theme="dark"] .rail { background: #0A1218; color: #E8EAE4; }
:root[data-theme="light"] .rail { background: #152A38; color: #F4F5F2; }

.brand { padding: 0 10px 20px; }
.brand strong { font-family: var(--display); font-size: 17px; display: block; letter-spacing: .01em; }
.brand span { font-size: 11px; letter-spacing: .13em; text-transform: uppercase; opacity: .55; }
.demo-chip {
  display: inline-block; margin-top: 6px;
  font-size: 10px !important; letter-spacing: .12em; text-transform: uppercase;
  color: #10222F; background: var(--brass); opacity: 1 !important;
  border-radius: 999px; padding: 2px 8px; font-weight: 700;
}

.nav-item {
  display: flex; align-items: baseline; gap: 9px;
  padding: 8px 10px; border: 0; border-radius: var(--r);
  background: transparent; color: inherit;
  text-align: left; cursor: pointer; width: 100%;
  opacity: .72; transition: opacity .12s, background .12s;
}
.nav-item:hover { opacity: 1; background: rgba(255, 255, 255, .07); }
.nav-item[aria-current="page"] { opacity: 1; background: rgba(255, 255, 255, .11); box-shadow: inset 2px 0 0 var(--brass); }
.nav-item small { font-family: var(--data); font-size: 11px; opacity: .6; margin-left: auto; font-variant-numeric: tabular-nums; }

.rail-foot { margin-top: auto; padding: 0 10px; font-size: 12px; opacity: .5; }
.rail-link { display: block; color: var(--brass); text-decoration: none; margin: 8px 0; }
.rail-link:hover { text-decoration: underline; }
.whoami { margin-bottom: 8px; }
.whoami button {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: var(--brass); text-decoration: underline;
}
.rail-foot button {
  background: none; border: 1px solid rgba(255, 255, 255, .2); color: inherit;
  border-radius: var(--r); padding: 5px 9px; cursor: pointer; font-size: 12px; margin-bottom: 10px;
}

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 26px; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 21px; }
.topbar .spacer { flex: 1; }

.content { padding: 24px 26px 64px; }

/* ---------- controls ---------- */

.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 6px 12px; border-radius: var(--r); cursor: pointer;
  transition: border-color .12s, background .12s;
  font-size: 14px;
}
.btn:hover { border-color: var(--brass); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.danger { border-color: color-mix(in srgb, var(--stop) 45%, var(--line)); color: var(--stop); }
.btn.danger:hover { border-color: var(--stop); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.sm { padding: 3px 9px; font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

select, input[type="text"], input[type="date"], input[type="datetime-local"], textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 6px 9px;
}

/* ---------- summary numbers ---------- */

.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }

.figure {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 17px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.figure::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line); }
.figure.go::before { background: var(--go); }
.figure.warn::before { background: var(--warn); }
.figure.stop::before { background: var(--stop); }
.figure.brass::before { background: var(--brass); }

.figure .label { font-size: 11px; letter-spacing: .11em; text-transform: uppercase; color: var(--muted); }
.figure .value {
  font-family: var(--display); font-size: 30px; line-height: 1.15; margin: 5px 0 2px;
  font-variant-numeric: tabular-nums;
}
.figure .value.sm { font-size: 22px; }
.figure .foot { font-size: 12.5px; color: var(--muted); }

/* ---------- panels & tables ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden;
}
.panel > header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft); background: var(--surface-sunk);
}
.panel > header h2 { font-size: 15.5px; }
.panel > header .spacer { flex: 1; }
.panel > header small { color: var(--muted); font-size: 12.5px; }
.panel-body { padding: 14px 16px; }

.scroll-x { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-sunk); }
.num { font-family: var(--data); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- chips ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.go { color: var(--go); border-color: color-mix(in srgb, var(--go) 40%, transparent); background: color-mix(in srgb, var(--go) 8%, transparent); }
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.chip.stop { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 40%, transparent); background: color-mix(in srgb, var(--stop) 8%, transparent); }
.chip.brass { color: var(--brass); border-color: color-mix(in srgb, var(--brass) 45%, transparent); background: color-mix(in srgb, var(--brass) 9%, transparent); }

/* ---------- week grid ---------- */

.week { display: grid; grid-template-columns: repeat(7, minmax(148px, 1fr)); gap: 10px; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; min-height: 130px; }
.day.today { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.day > header {
  padding: 8px 10px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: baseline; gap: 6px; background: var(--surface-sunk);
  border-radius: var(--r) var(--r) 0 0;
}
.day > header b { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; }
.day > header span { font-family: var(--data); font-size: 12px; color: var(--muted); margin-left: auto; }
.day .slots { padding: 7px; display: flex; flex-direction: column; gap: 6px; }
.day .empty { padding: 14px 10px; color: var(--faint); font-size: 12.5px; }

.slot {
  border: 1px solid var(--line-soft); border-left: 3px solid var(--line);
  border-radius: 4px; padding: 6px 8px; background: var(--surface);
  cursor: pointer; text-align: left; width: 100%; display: block;
  transition: border-color .1s, transform .1s;
}
.slot:hover { border-color: var(--brass); transform: translateX(1px); }
.slot .t { font-family: var(--data); font-size: 11.5px; color: var(--muted); }
.slot .who { font-size: 13.5px; font-weight: 500; }
.slot .sub { font-size: 11.5px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ---------- the action queue ---------- */

.acase {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brass);
  border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 18px; margin-bottom: 14px; max-width: 860px;
}
.acase.stop { border-left-color: var(--stop); }
.acase.warn { border-left-color: var(--warn); }
.acase.muted { opacity: .65; border-left-color: var(--line); padding: 8px 18px; }
.acase header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.acase header strong { font-family: var(--display); font-size: 16.5px; }
.acase .worth { margin-left: auto; font-family: var(--data); font-size: 13px; color: var(--muted); }
.acase .rec { font-size: 13.5px; margin: 4px 0 10px; color: var(--muted); }
.acase .rec b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.acase-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.acase-actions .spacer { flex: 1; }
.snoozed-group { max-width: 860px; margin-top: 20px; color: var(--muted); }
.snoozed-group summary { cursor: pointer; font-size: 13px; margin-bottom: 8px; }
.foot-note { color: var(--faint); font-size: 12.5px; max-width: 860px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 10px; }
.legend-item {
  border: 0; background: none; padding: 2px 0; cursor: pointer;
  font: inherit; font-size: 12px; color: var(--muted);
}
.legend-item:hover { color: var(--text); }
.slot.attended { border-left-color: var(--go); }
.slot.absent { border-left-color: var(--warn); }
.slot.cancelled { border-left-color: var(--stop); opacity: .62; }
.slot.cancelled .who { text-decoration: line-through; }
.slot.makeup { border-left-color: var(--brass); border-left-style: double; border-left-width: 4px; }

/* ---------- today ---------- */

.spark { width: 100%; height: auto; display: block; }
.spark .bar { fill: color-mix(in srgb, var(--brass) 38%, transparent); }
.spark .bar.current { fill: var(--brass); }
.spark .bar:hover { fill: color-mix(in srgb, var(--brass) 70%, transparent); }
.spark text { font: 10px var(--data); fill: var(--muted); }
.spark line { stroke: var(--line-soft); stroke-width: 1; }

.attention { display: grid; gap: 10px; margin: 0; padding: 0; }
.attention li {
  list-style: none; display: flex; gap: 10px; align-items: baseline;
  padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r);
  background: var(--surface); font-size: 13.5px; cursor: pointer;
  border-left: 3px solid var(--warn);
}
.attention li:hover { border-color: var(--brass); border-left-color: var(--warn); }
.attention li.stop { border-left-color: var(--stop); }
.attention li .go-to { margin-left: auto; color: var(--brass); font-size: 12px; white-space: nowrap; }

/* ---------- assistant ---------- */

.chat { display: grid; gap: 12px; max-width: 780px; }
.msg { padding: 12px 15px; border-radius: var(--r); font-size: 14px; line-height: 1.55; }
.msg.user {
  background: var(--ink); color: var(--paper);
  justify-self: end; max-width: 85%; border-bottom-right-radius: 2px;
}
.msg.assistant {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--brass); max-width: 95%; border-bottom-left-radius: 2px;
  white-space: pre-wrap;
}
.msg.assistant .meta { font-size: 11px; color: var(--faint); font-family: var(--data); margin-top: 8px; }
.msg.pending { color: var(--muted); font-style: italic; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; cursor: pointer; color: var(--ink);
}
.chips button:hover { border-color: var(--brass); color: var(--brass); }

.ask-bar { display: flex; gap: 8px; max-width: 780px; }
.ask-bar textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 130px;
  font: 14px/1.4 var(--body); color: var(--ink);
}

/* ---------- retention ---------- */

/* A risk score on its own is astrology. The card is laid out so the evidence is
   the body of it and the score is a footnote — what the school acts on is the
   sentence "four no-shows in sixty days", never the number 36. */
.risk { display: grid; gap: 12px; }

.risk-card {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--stop); border-radius: var(--r);
  padding: 13px 16px; display: grid; gap: 9px;
  cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit;
  transition: border-color .12s, transform .1s;
}
.risk-card:hover { border-color: var(--brass); border-left-color: var(--stop); transform: translateX(1px); }
.risk-card.watch { border-left-color: var(--warn); }
.risk-card.watch:hover { border-left-color: var(--warn); }
.risk-card > header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.risk-card .who { font-family: var(--display); font-size: 16.5px; }
.risk-card .kin { font-size: 12.5px; color: var(--muted); }
.risk-card .worth {
  margin-left: auto; font-family: var(--data); font-variant-numeric: tabular-nums;
  font-size: 13.5px; text-align: right;
}
.risk-card .worth b { display: block; font-size: 15px; font-weight: 600; }
.risk-card .worth span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.risk-card .risk-actions { display: flex; justify-content: flex-end; }

/* ---------- AI surfaces ---------- */

.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 20px; }

/* A draft is a document, not chat: monospace body, generous padding, and the
   copy button right under it. pre-wrap because emails have paragraphs. */
.draft {
  font: 13px/1.6 var(--data); color: var(--ink);
  background: var(--surface-sunk); border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; margin: 0 0 10px;
  white-space: pre-wrap; word-wrap: break-word; max-width: 100%;
}

.proposal {
  margin-top: 12px; padding: 12px 14px;
  background: var(--surface-sunk); border: 1px solid var(--line);
  border-left: 3px solid var(--brass); border-radius: var(--r);
  font-size: 14px; line-height: 1.5;
}
.proposal-actions { display: flex; gap: 8px; margin-top: 10px; }

.practice-spark { display: block; max-width: 100%; }

.evidence { display: grid; gap: 6px; margin: 0; padding: 0; }
.evidence li {
  list-style: none; font-size: 13.5px; line-height: 1.45;
  padding-left: 17px; position: relative;
}
.evidence li::before { content: "→"; position: absolute; left: 0; color: var(--brass); }

/* Cohort grid. Retention is read across a row, so the row label stays put and
   only the months scroll. */
.cohort { font-size: 13px; }
.cohort th, .cohort td { padding: 5px 6px; border: 0; }
.cohort th { font-size: 10.5px; letter-spacing: .06em; }
.cohort tbody td { border-bottom: 0; }
.cohort .who { white-space: nowrap; font-family: var(--data); font-size: 12px; }
.cohort .size { color: var(--faint); font-family: var(--data); font-size: 11.5px; text-align: right; }
.cohort .heat { padding: 3px; }
.cohort .heat > span {
  display: block; border-radius: 3px; padding: 5px 7px; min-width: 40px; text-align: center;
  font-family: var(--data); font-variant-numeric: tabular-nums; font-size: 12px;
}
.cohort tr.blended td { border-top: 1px solid var(--line); padding-top: 9px; font-weight: 600; }

/* ---------- drawer ---------- */

.scrim { position: fixed; inset: 0; background: rgba(10, 18, 24, .35); z-index: 40; }
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(460px, 100vw); z-index: 50;
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(10, 18, 24, .18);
}
.drawer > header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.drawer > header h2 { font-size: 18px; }
.drawer > header .close { margin-left: auto; background: none; border: 0; cursor: pointer; font-size: 20px; color: var(--muted); line-height: 1; }
.drawer .body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.drawer .actions { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; background: var(--surface-sunk); }

.kv { display: grid; grid-template-columns: 116px 1fr; gap: 5px 12px; font-size: 14px; margin-bottom: 18px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; }

/* The reasoning trace. This is the differentiator, so it gets real design:
   an ordered list a parent could be read down the phone, verbatim. */
.reasoning { border-left: 2px solid var(--brass); padding: 2px 0 2px 14px; margin: 4px 0 16px; display: grid; gap: 9px; }
.reasoning li { list-style: none; font-size: 13.5px; line-height: 1.45; }
.reasoning li code { font-family: var(--data); font-size: 11px; color: var(--faint); display: block; letter-spacing: .04em; }
.reasoning ol { margin: 0; padding: 0; }

.notice { border: 1px solid; border-radius: var(--r); padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); color: var(--warn); }
.notice.stop { border-color: color-mix(in srgb, var(--stop) 45%, transparent); background: color-mix(in srgb, var(--stop) 8%, transparent); color: var(--stop); }
.notice.go { border-color: color-mix(in srgb, var(--go) 45%, transparent); background: color-mix(in srgb, var(--go) 8%, transparent); color: var(--go); }

.section-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line-soft);
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: var(--r);
  z-index: 90; box-shadow: var(--shadow); font-size: 14px; max-width: 90vw;
}

.empty-state { padding: 40px 20px; text-align: center; color: var(--faint); }

.bar { height: 6px; background: var(--surface-sunk); border-radius: 999px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media (max-width: 940px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .brand { padding: 0 10px 0 4px; }
  .nav-item { width: auto; }
  .rail-foot { margin: 0 0 0 auto; }
  .week { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 14px; padding-right: 14px; }
}
