/* Colours follow the ADS "Decision Navy" colour standard (adopted 2026-09-30).
   Brand: navy #0B2545, teal #13A89E, slate #8DA9C4, mist #EEF4ED, amber #F2A541.
   Teal and amber are never used as text on light backgrounds; amber is a fill
   with navy text. Charts use the categorical slots: 1 blue (range), 2 amber
   (true/false). Status colours always come with an icon and a label. */
:root {
  --navy: #0B2545;
  --teal: #13A89E;
  --amber: #F2A541;
  --bg: #EEF4ED;            /* mist */
  --surface: #FFFFFF;
  --text: #0B2545;          /* text-primary */
  --muted: #4A5D75;         /* text-secondary */
  --border: #8DA9C4;        /* slate */
  --line: #d3dee9;          /* hairlines: slate at low strength */
  --link: #0E7C74;          /* teal-text */
  --tint: #e6edf4;          /* slate wash for table headers and hovers */
  --stripe: #f6f9fb;
  --header-bg: #0B2545;
  --on-navy: #EEF4ED;
  --series-1: #1F5FA8;      /* blue: range questions */
  --series-2: #E89A2C;      /* amber: true/false questions */
  --series-1-soft: #e7eef7;
  --series-2-soft: #fdf2e2;
  --good: #0CA30C;
  --warning: #FAB219;
  --serious: #EC835A;
  --critical: #D03B3B;
  --shadow: 0 2px 10px rgba(11, 37, 69, .08);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B2545;
    --surface: #12305A;
    --text: #EEF4ED;
    --muted: #B8C7D9;
    --border: #2B4566;
    --line: #2B4566;
    --link: #1FB5AA;
    --tint: #1a3a66;
    --stripe: #153660;
    --header-bg: #071a33;
    --series-1: #3A80E0;
    --series-2: #C47F14;
    --series-1-soft: #173a6a;
    --series-2-soft: #3a3324;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); }

/* header: navy band with a teal divider */
header.top {
  background: var(--header-bg);
  color: var(--on-navy);
  padding: 16px;
  border-bottom: 4px solid var(--teal);
}
header.top .inner, main { max-width: 1180px; margin: 0 auto; }
header.top .inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
header.top h1 { font-size: 24px; margin: 0; flex: 1; letter-spacing: .2px; }
header.top .muted, header.top .savestate { color: #8DA9C4; }
header.top button.secondary, header.top .btn.secondary { color: var(--on-navy); border-color: #8DA9C4; }
header.top button.secondary:hover, header.top .btn.secondary:hover { background: rgba(238, 244, 237, .12); }
header.top button.link { color: var(--teal); }
header.top select { background: var(--on-navy); color: var(--navy); border-color: transparent; }

main { padding: 24px 16px 64px; }
main.narrow { max-width: 820px; }
h2 { font-size: 26px; margin: 30px 0 14px; }
h3 { font-size: 20px; margin: 22px 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
label { display: block; font-weight: 600; font-size: 16px; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], input[type=email], input:not([type]), select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, button:focus-visible { outline: 3px solid var(--teal); outline-offset: 1px; }

/* buttons: primary is amber with navy text, secondary is a navy outline */
button, .btn {
  font: inherit;
  font-weight: 650;
  border: 1.5px solid var(--amber);
  background: var(--amber);
  color: var(--navy);
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: filter .15s, background .15s;
}
button:hover, .btn:hover { filter: brightness(1.05); }
button.secondary, .btn.secondary { background: transparent; color: var(--text); border-color: var(--text); }
button.secondary:hover, .btn.secondary:hover { background: var(--tint); }
button.danger { background: transparent; color: var(--text); border-color: var(--critical); }
button.danger::before { content: "⚠ "; color: var(--critical); }
button.link { background: none; border: none; color: var(--link); padding: 0; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1; min-width: 180px; }
.error { color: var(--text); font-weight: 600; min-height: 1.5em; margin-top: 8px; }
.error:not(:empty)::before { content: "⚠ "; color: var(--critical); }
.hidden { display: none !important; }

/* tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--text); background: var(--tint); font-weight: 700; font-size: 15px; }
thead th:first-child { border-top-left-radius: 8px; }
thead th:last-child { border-top-right-radius: 8px; }
tbody tr:nth-child(even) td { background: var(--stripe); }
tbody tr:hover td { background: var(--tint); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.you td { background: var(--tint); font-weight: 600; }

/* status badges: text stays in text colours; the status colour is the icon and edge */
.badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--tint);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.badge::before { margin-right: 5px; }
.badge.good { border-color: var(--good); }
.badge.good::before { content: "✓"; color: var(--good); }
.badge.warn { border-color: var(--warning); }
.badge.warn::before { content: "●"; color: var(--warning); }
.badge.bad { border-color: var(--critical); }
.badge.bad::before { content: "▼"; color: var(--critical); }
.badge.under { border-color: var(--serious); }
.badge.under::before { content: "▲"; color: var(--serious); }
.badge.plain { background: transparent; color: var(--muted); border-color: var(--line); }

/* stat tiles: series colour marks the edge; numbers use text colour */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.stat { background: var(--series-1-soft); border-left: 6px solid var(--series-1); border-radius: 12px; padding: 16px 18px; }
.stat.binary { background: var(--series-2-soft); border-left-color: var(--series-2); }
.stat .k { font-size: 16px; color: var(--muted); font-weight: 650; }
.stat .v { font-size: 38px; font-weight: 800; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .s { font-size: 16px; color: var(--muted); }

.code-box {
  font: 800 34px/1 ui-monospace, Consolas, monospace;
  letter-spacing: 4px;
  background: var(--navy);
  color: var(--on-navy);
  border-bottom: 4px solid var(--teal);
  padding: 12px 18px;
  border-radius: 12px;
  display: inline-block;
}

/* test taking */
.progress { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--link); width: 0; transition: width .2s; }
.q { border-top: 1px solid var(--line); padding: 18px 0; }
.q:first-child { border-top: none; padding-top: 0; }
.q .qtext { font-weight: 650; font-size: 19px; margin-bottom: 12px; }
.q .qnum { color: var(--muted); font-weight: 800; margin-right: 8px; }
.q .inputs { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.q .inputs > div { min-width: 150px; flex: 1; max-width: 240px; }
.tf { display: inline-flex; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; }
.tf button { background: var(--surface); color: var(--text); border: none; border-radius: 0; padding: 10px 22px; }
.tf button + button { border-left: 1.5px solid var(--border); }
.tf button.on { background: var(--navy); color: var(--on-navy); }
.q.result.right { border-left: 6px solid var(--good); padding-left: 14px; }
.q.result.wrong { border-left: 6px solid var(--critical); padding-left: 14px; }
#rangeBlock, #rangeResults { border-top-color: var(--series-1); }
#binaryBlock, #binaryResults { border-top-color: var(--series-2); }
.section-title { margin-top: 0; }
.savestate { font-size: 15px; color: var(--muted); }

/* charts */
.chart svg { width: 100%; height: auto; max-width: 460px; display: block; }
.chart .axis { stroke: var(--line); }
.chart .diag { stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1.5; }
.chart text { fill: var(--muted); font-size: 12.5px; }
.chart .dot-range { fill: var(--series-1); }
.chart .dot-binary { fill: var(--series-2); }
.legend { display: flex; gap: 18px; font-size: 15px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend .lr::before { background: var(--series-1); }
.legend .lb::before { background: var(--series-2); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }

/* tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); }
.tabs button { background: none; color: var(--text); border: none; border-radius: 10px; padding: 11px 22px; font-size: 18px; }
.tabs button:hover { background: var(--tint); filter: none; }
.tabs button.on { background: var(--navy); color: var(--on-navy); box-shadow: inset 0 -3px 0 var(--teal); }

@media (prefers-color-scheme: dark) {
  .tabs button.on { background: var(--on-navy); color: var(--navy); }
  .tf button.on { background: var(--on-navy); color: var(--navy); }
}

@media (max-width: 600px) {
  body { font-size: 17px; }
  header.top h1 { font-size: 20px; }
  .q .inputs > div { max-width: none; }
  .stat .v { font-size: 30px; }
  .tabs button { padding: 9px 14px; font-size: 16px; }
}
.badge.wrong { border-color: var(--critical); }
.badge.wrong::before { content: "✗"; color: var(--critical); }

/* ADS logo: reversed mark on the navy header, colour lockup on sign-in cards */
header.top .brand { display: flex; align-items: center; line-height: 0; margin-right: 4px; }
header.top .brand img { height: 40px; width: auto; display: block; }
.lockup img { display: block; width: 240px; max-width: 70%; height: auto; margin: -12px 0 8px -14px; }
@media (max-width: 600px) { header.top .brand img { height: 32px; } }

/* compact class header */
.class-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; padding: 16px 20px; }
.class-head-main { flex: 1; min-width: 280px; display: grid; gap: 4px; }
.class-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.class-title h2 { margin: 0; }
.class-controls { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 16px; margin: 0; }
.class-head-side { display: grid; justify-items: end; gap: 6px; }
.class-head .code-box { font-size: 26px; padding: 8px 14px; }
.class-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.class-actions button, .class-actions .btn { padding: 8px 14px; font-size: 16px; }

/* overview: totals and both charts side by side */
.overview-grid { display: grid; grid-template-columns: minmax(230px, 0.9fr) 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.overview-grid > .panel { margin: 0; padding: 16px 18px; }
.overview-grid h3 { font-size: 18px; margin: 0 0 8px; }
.overview-grid .chart svg { max-width: 100%; max-height: 240px; margin: 0 auto; }
.overview-grid .note { margin: 4px 0 0; font-size: 14px; }
.stats-stack .stats { grid-template-columns: 1fr; gap: 10px; }
.stats-stack .stat { padding: 12px 14px; }
.stats-stack .stat .v { font-size: 32px; }
#studentTable td { white-space: normal; }
#studentTable td:first-child { white-space: nowrap; font-weight: 600; }
.fig { font-weight: 800; font-variant-numeric: tabular-nums; }
@media (max-width: 1000px) {
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .overview-grid > .panel:first-child { grid-column: 1 / -1; }
  .stats-stack .stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}
@media (max-width: 640px) {
  .overview-grid { grid-template-columns: 1fr; }
  .class-head-side { justify-items: start; }
}

/* tighter chrome so the overview fits a laptop screen */
header.top { padding: 10px 16px; }
header.top .brand img { height: 34px; }
header.top h1 { font-size: 22px; }
main { padding-top: 16px; }
.class-head { padding: 12px 18px; margin-bottom: 12px; }
.class-head h2 { font-size: 24px; }
.tabs { padding: 6px; margin-bottom: 12px; }
.tabs button { padding: 8px 18px; }
.overview-grid { gap: 12px; margin-bottom: 12px; }
.overview-grid > .panel { padding: 12px 16px; }
.overview-grid .chart svg { max-height: 200px; }
.stats-stack .stat { padding: 8px 12px; border-left-width: 5px; }
.stats-stack .stat .k { font-size: 14px; }
.stats-stack .stat .v { font-size: 26px; }
.stats-stack .stat .s { font-size: 14px; }
.stats-stack .badge { font-size: 13px; padding: 1px 9px; }
.table-panel { padding: 10px 14px; }
.table-wrap.fit { overflow: auto; }
table.sticky thead th { position: sticky; top: 0; z-index: 1; }
table.sticky th, table.sticky td { padding: 8px 10px; }

/* fit the overview into a laptop-height window */
.class-head { align-items: center; }
.class-head-main { gap: 2px; }
.class-controls { margin-top: 2px; }
.class-head-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.class-head-side > .small { display: none; }
.class-head .code-box { font-size: 22px; padding: 6px 12px; border-bottom-width: 3px; }
.stats-stack .stat .v { display: inline-block; margin-right: 8px; vertical-align: middle; }
.stats-stack .stat .v + .s { display: inline; }
.stats-stack .stat > div:last-child { display: inline-block; margin-top: 2px !important; }
.overview-grid .chart svg { max-height: 170px; }
.overview-grid .note { font-size: 13px; }
main { padding-bottom: 20px; }
.class-head h2 { font-size: 22px; }
.class-head-main { gap: 0; }
.overview-grid .chart svg { max-height: 160px; }
.overview-grid h3 { margin-bottom: 4px; }
.overview-grid .note { margin-top: 2px; }
.overview-grid .chart svg { max-height: 175px; }
.overview-grid .chart text { font-size: 15px; }
.stats-stack .stat { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; }
.stats-stack .stat .k { flex-basis: 100%; }
.stats-stack .stat .v { order: 1; margin: 0; }
.stats-stack .stat > div:last-child { order: 2; margin: 0 !important; }
.stats-stack .stat .s { order: 3; flex-basis: 100%; display: block; }

/* class totals: number on the left, label, detail and status stacked beside it */
.stats-stack .stat {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; row-gap: 0;
  align-items: center; padding: 8px 12px;
}
.stats-stack .stat .v { grid-row: 1 / span 3; grid-column: 1; order: 0; font-size: 30px; line-height: 1; }
.stats-stack .stat .k { grid-column: 2; font-size: 14px; line-height: 1.3; }
.stats-stack .stat .s { grid-column: 2; order: 0; font-size: 13px; line-height: 1.3; }
.stats-stack .stat > div:last-child { grid-column: 2; order: 0; margin: 2px 0 0 !important; }
.stats-stack .stats { gap: 8px; }
.overview-grid { align-items: start; }
.overview-grid .chart svg { max-height: 300px; }
