:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1c2230; --muted: #667085; --line: #e4e7ec;
  --accent: #3b5bdb; --ok: #2b8a3e; --warn: #b26b00; --bad: #c92a2a;
  --ok-bg: #e6f4ea; --warn-bg: #fff4e0; --bad-bg: #fdecec; --chip: #eef1f6;
  --a: #2b8a3e; --b: #1c7ed6; --c: #b26b00; --d: #c92a2a;
  /* charts — categorical order validated (dataviz validator) on this surface */
  --viz-1: #2a78d6; --viz-2: #eb6834; --viz-3: #1baf7a; --viz-4: #eda100;
  --viz-5: #e87ba4; --viz-6: #008300; --viz-7: #4a3aa7; --viz-8: #e34948;
  --viz-pos: #2a78d6; --viz-neg: #e34948;
  --viz-grid: #ecebe6; --viz-axis: #c3c2b7; --viz-tick: #898781;
  --up: #006300; --down: #c92a2a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141a; --surface: #1a1f28; --text: #e6e9ef; --muted: #98a2b3; --line: #2a313d;
    --accent: #7c9cff; --ok: #69db7c; --warn: #ffc078; --bad: #ff8787;
    --ok-bg: #1c3324; --warn-bg: #3a2c14; --bad-bg: #3d1f1f; --chip: #242b36;
    --a: #69db7c; --b: #74c0fc; --c: #ffc078; --d: #ff8787;
    --viz-1: #3987e5; --viz-2: #d95926; --viz-3: #199e70; --viz-4: #c98500;
    --viz-5: #d55181; --viz-6: #008300; --viz-7: #9085e9; --viz-8: #e66767;
    --viz-pos: #3987e5; --viz-neg: #e66767;
    --viz-grid: #2a313d; --viz-axis: #3a4250; --viz-tick: #8b93a1;
    --up: #0ca30c; --down: #ff8787;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { margin: 0; font-size: 1.25rem; }
.card > h2 { margin-bottom: .75rem; }
h3 { margin: 1.1rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
button { font: inherit; padding: .35rem .8rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding: .75rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.top nav { display: flex; gap: 1rem; }
.top nav a { color: var(--muted); }
.top nav a[aria-current] { color: var(--text); font-weight: 600; }
.poll { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.poll form { margin: 0; }

main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
footer { text-align: center; padding: 1rem; font-size: .85rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card > header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; margin-bottom: .75rem; }
.students { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.students .card { margin: 0; }
.empty { text-align: center; padding: 2rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badges { display: flex; gap: .5rem; margin-bottom: .75rem; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.badge.small { font-size: .72rem; padding: 0 .4rem; margin-left: .3rem; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; }
th, td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.courses td { padding: .3rem 0; }
.courses td:first-child a { color: var(--text); }
.grade { text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.band-a { color: var(--a); } .band-b { color: var(--b); } .band-c { color: var(--c); }
.band-d { color: var(--d); } .band-none { color: var(--muted); font-weight: 400; }

.items { list-style: none; margin: 0; padding: 0; }
.items li { padding: .25rem 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.item { font-weight: 500; }

.tag, .status { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem;
  border-radius: 4px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.t-assignment_missing, .t-grade_drop, .status.s-missing { background: var(--bad-bg); color: var(--bad); }
.t-due_soon, .t-past_due_ungraded, .status.s-due, .status.s-ungraded_past_due { background: var(--warn-bg); color: var(--warn); }
.t-assignment_graded, .status.s-graded { background: var(--ok-bg); color: var(--ok); }
tr.s-missing td:first-child { box-shadow: inset 3px 0 var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips a { padding: .25rem .6rem; border-radius: 999px; background: var(--chip); color: var(--text); font-size: .9rem; }
.chips a[aria-current] { outline: 2px solid var(--accent); }
.chips .grade { margin-left: .25rem; font-size: .85rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--bad-bg); color: var(--bad); }

/* buttons + forms */
.button { display: inline-block; font: inherit; padding: .35rem .8rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.button:hover { border-color: var(--accent); text-decoration: none; }
button.small, .button.small { font-size: .85rem; padding: .15rem .55rem; }
button.danger { color: var(--bad); border-color: var(--bad); }
.actions { text-align: right; }
.actions form { display: inline; margin: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .9rem; }
.form { display: flex; flex-direction: column; gap: .9rem; max-width: 640px; }
.form > label, fieldset > label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
.form small { font-weight: 400; color: var(--muted); font-size: .82rem; }
.form input:not([type=checkbox]):not([type=radio]) { font: inherit; padding: .4rem .55rem; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.form input[type=number] { width: 6rem; }
.form input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-weight: 400; }
.inline.grow input { flex: 1; min-width: 12rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem .8rem; margin: 0;
  display: flex; flex-direction: column; gap: .35rem; }
legend { font-weight: 600; padding: 0 .3rem; display: flex; align-items: center; gap: .6rem; }
label.check { flex-direction: row !important; align-items: baseline; gap: .5rem !important; font-weight: 400 !important; }
.indent { padding-left: 1.5rem; display: flex; flex-direction: column; gap: .3rem; }
.presets { display: inline-flex; gap: .3rem; font-weight: 400; }
.form > button, aside button { align-self: flex-start; }
.two-col { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; align-items: start; }
.two-col.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.two-col .card { margin: 0; }
aside { display: flex; flex-direction: column; gap: 1rem; }
aside .card { margin: 0; }
.qr svg { display: block; width: 100%; max-width: 220px; height: auto; background: #fff; padding: 8px; border-radius: 8px; }
.qr + p { word-break: break-all; }

details.help { margin: .75rem 0; }
details.help summary { cursor: pointer; color: var(--accent); }
.steps li { margin: .35rem 0; }
code { font-size: .85em; background: var(--chip); padding: 0 .3rem; border-radius: 4px; }
.form.compact { max-width: 480px; margin-top: .75rem; }
.form select { font: inherit; padding: .4rem .55rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); }
.colors { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-right: .35rem;
  vertical-align: -1px; }

/* ── dashboard ─────────────────────────────────────────────────── */
.swatch.big { width: .7rem; height: .7rem; margin-right: .45rem; vertical-align: 1px; }
.legend { display: inline-flex; gap: .9rem; font-size: .9rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; }
.up { color: var(--up); white-space: nowrap; }
.down { color: var(--down); white-space: nowrap; }

.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.day { border: 1px solid var(--line); border-radius: 8px; padding: .5rem; min-height: 5.5rem;
  display: flex; flex-direction: column; gap: .35rem; }
.day.today { border-color: var(--accent); }
.day-head { font-size: .85rem; }
.due-chip { display: flex; gap: .4rem; align-items: baseline; color: var(--text); font-size: .85rem;
  line-height: 1.25; padding: .25rem .3rem; border-radius: 6px; background: var(--chip); }
.due-chip:hover { text-decoration: none; outline: 1px solid var(--accent); }
.due-chip .swatch { flex: none; width: .55rem; height: .55rem; margin: 0; }
.due-chip small { display: block; }
.due-name { display: block; font-weight: 500; overflow-wrap: anywhere; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin-bottom: .9rem; }
.kpi { background: var(--chip); border-radius: 8px; padding: .5rem .65rem; display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: .75rem; color: var(--muted); }
.kpi-value { font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
.kpi-value.small-value { font-size: 1.05rem; }
.kpi small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.is-bad .kpi-value { color: var(--bad); }

.courses th { font-weight: 600; }
.courses td { vertical-align: middle; }
.spark-col { width: 38%; }
.spark { width: 100%; height: 30px; }
.delta { white-space: nowrap; font-size: .9rem; }
.chart-note { margin: .5rem 0 0; }
.chart-note p { margin: .25rem 0 0; }
.line-key { display: inline-block; width: 14px; height: 2px; border-radius: 1px; margin-right: .4rem; vertical-align: middle; }
.line-legend { gap: 1rem; }
.ranges { display: inline-flex; gap: .3rem; margin: .1rem 0 .5rem; flex-wrap: wrap; }
.ranges button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.table-pair { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.table-pair caption { text-align: left; font-weight: 600; color: var(--muted); padding-bottom: .25rem; }

/* class page */
.class-chips { margin-bottom: 1rem; }
.class-top { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 3fr); gap: 1rem; margin-bottom: 1rem; }
.class-top .card { margin: 0; }
.hero h2 { margin: .15rem 0 .25rem; }
.hero-value { font-size: 3.25rem; font-weight: 650; line-height: 1.1; margin: .25rem 0; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin: 1rem 0; }
.hero-stats div { background: var(--chip); border-radius: 8px; padding: .4rem .55rem; }
.hero-stats dt { font-size: .72rem; color: var(--muted); }
.hero-stats dd { margin: 0; font-size: 1.2rem; font-weight: 600; }
.hero-stats .is-bad dd { color: var(--bad); }
.chart-card > header { margin-bottom: .25rem; }
.line-chart { width: 100%; height: 240px; }
.table-view { margin-top: .5rem; font-size: .85rem; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view table { max-width: 420px; }
.breakdown { margin-top: .75rem; }
.breakdown .swatch { width: .6rem; height: .6rem; }
.breakdown tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }

/* chart marks */
.viz-svg { display: block; overflow: visible; }
.viz-line { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-area { fill: var(--viz-1); opacity: .1; stroke: none; }
.viz-end, .viz-dot { fill: var(--viz-1); stroke: var(--surface); stroke-width: 2; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-axis { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-cross { stroke: var(--viz-tick); stroke-width: 1; shape-rendering: crispEdges; }
.viz-tick { fill: var(--viz-tick); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-band { fill: var(--viz-tick); font-size: 11px; font-weight: 600; }
[data-viz] rect:focus { outline: none; }
[data-viz] svg:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.viz-stack { display: flex; gap: 2px; height: 24px; }
.viz-seg { position: relative; background: color-mix(in srgb, var(--c) 18%, transparent); cursor: default; min-width: 3px; }
.viz-seg:last-child { border-radius: 0 4px 4px 0; overflow: hidden; }
.viz-seg-fill { height: 100%; background: var(--c); }
.viz-seg:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.viz-scale { display: flex; justify-content: space-between; font-size: .75rem; color: var(--viz-tick); margin-top: .2rem; }

.viz-diverge { display: flex; flex-direction: column; gap: .35rem; }
.viz-div-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: .75rem; align-items: center; }
.viz-div-row:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.viz-div-name { display: flex; flex-direction: column; min-width: 0; font-size: .88rem; line-height: 1.2; }
.viz-div-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-div-track { display: grid; grid-template-columns: 1fr 1fr; position: relative; height: 22px; }
.viz-div-track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--viz-axis); }
.viz-div-neg { grid-column: 1; display: flex; flex-direction: row-reverse; align-items: center; gap: .3rem; }
.viz-div-pos { grid-column: 2; display: flex; align-items: center; gap: .3rem; }
.viz-div-bar { height: 14px; min-width: 2px; max-width: calc(100% - 2.6rem); }
.viz-div-neg .viz-div-bar { background: var(--viz-neg); border-radius: 4px 0 0 4px; }
.viz-div-pos .viz-div-bar { background: var(--viz-pos); border-radius: 0 4px 4px 0; }
.viz-div-val { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.viz-tip { position: absolute; z-index: 10; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem; font-size: .85rem;
  box-shadow: 0 4px 16px rgb(0 0 0 / .12); max-width: 280px; }
.viz-tip-row { display: flex; align-items: center; gap: .45rem; }
.viz-tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.viz-tip-label { color: var(--muted); }

@media (max-width: 900px) {
  .week-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .class-top { grid-template-columns: 1fr; }
}

pre.log { max-height: 28rem; overflow: auto; margin: 0; padding: .75rem; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); font-size: .78rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 600px) {
  .students, .two-col, .two-col.wide-left { grid-template-columns: 1fr; }
  .week-grid { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spark-col { width: 30%; }
  .poll { margin-left: 0; width: 100%; justify-content: space-between; }
}
