/* Official, restrained look with a side menu. Every colour is a token: the light set is the
   default, the dark set applies when the system prefers dark (unless the user chose light)
   or when the user chose dark. theme.js sets data-theme on <html> from the saved choice. */
:root {
  color-scheme: light;
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #fafbfd; --text: #1a2233; --heading: #0b2a66; --muted: #566175;
  --line: #d5dbe5; --line-strong: #b9c2d0; --head: #e9eef8; --hover: #e9eef8;
  --primary: #0b2a66; --primary-hover: #081f4d; --primary-text: #ffffff; --link: #0b2a66; --focus: #2f8fcb;
  --green: #2e9e5b; --card-top: #0b2a66; --input: #ffffff; --chip: #e8ebf0; --chip-text: #3c4658;
  --good: #1c6e42; --good-bg: #e2f3e9; --good-line: #b9dfc8; --warn: #855400; --warn-bg: #fcefd2; --warn-line: #ecd49a;
  --bad: #a3221b; --bad-bg: #fbe5e3; --bad-line: #efc1bd; --info: #4338a0; --info-bg: #eef0fa; --info-line: #cfd3ef;
  --note-text: #5f3d00; --action-bg: #fbfefc;
  --side: #0b2a66; --side-text: #d3def3; --side-strong: #ffffff; --side-muted: #a9bbdd; --side-line: #27458a;
  --side-active: #1d3f86; --side-hover: rgba(255, 255, 255, .08);
  --radius: 6px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141c; --surface: #171e29; --surface-2: #1a2230; --text: #e6eaf1; --heading: #f2f5fa; --muted: #9aa6b8;
  --line: #2a3443; --line-strong: #3a4658; --head: #1c2532; --hover: #212c3c;
  --primary: #7fb0f5; --primary-hover: #9cc2f8; --primary-text: #0b1220; --link: #9cc2f8; --focus: #7fb0f5;
  --green: #4fc084; --card-top: #33558f; --input: #111823; --chip: #263142; --chip-text: #c3ccda;
  --good: #7fd6a4; --good-bg: #143524; --good-line: #1f5237; --warn: #f0c466; --warn-bg: #3a2e10; --warn-line: #5a4716;
  --bad: #f4a09a; --bad-bg: #3d1b19; --bad-line: #632a26; --info: #b3bcf5; --info-bg: #232a4a; --info-line: #36407a;
  --note-text: #f0cf7a; --action-bg: #14231c;
  --side: #0b1220; --side-text: #b9c4d6; --side-strong: #f2f5fa; --side-muted: #8b97ab; --side-line: #222c3b;
  --side-active: #1b2a47; --side-hover: rgba(255, 255, 255, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f141c; --surface: #171e29; --surface-2: #1a2230; --text: #e6eaf1; --heading: #f2f5fa; --muted: #9aa6b8;
    --line: #2a3443; --line-strong: #3a4658; --head: #1c2532; --hover: #212c3c;
    --primary: #7fb0f5; --primary-hover: #9cc2f8; --primary-text: #0b1220; --link: #9cc2f8; --focus: #7fb0f5;
    --green: #4fc084; --card-top: #33558f; --input: #111823; --chip: #263142; --chip-text: #c3ccda;
    --good: #7fd6a4; --good-bg: #143524; --good-line: #1f5237; --warn: #f0c466; --warn-bg: #3a2e10; --warn-line: #5a4716;
    --bad: #f4a09a; --bad-bg: #3d1b19; --bad-line: #632a26; --info: #b3bcf5; --info-bg: #232a4a; --info-line: #36407a;
    --note-text: #f0cf7a; --action-bg: #14231c;
    --side: #0b1220; --side-text: #b9c4d6; --side-strong: #f2f5fa; --side-muted: #8b97ab; --side-line: #222c3b;
    --side-active: #1b2a47; --side-hover: rgba(255, 255, 255, .06);
  }
}

* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ---- shell: side menu + content ---- */
.shell { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 28px 28px 48px; flex: 1; }
main.wide { max-width: 1320px; }
.side { width: 264px; flex: none; background: var(--side); color: var(--side-text); border-right: 1px solid var(--side-line);
  display: flex; flex-direction: column; gap: 20px; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side:empty { display: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px; color: var(--side-strong); text-decoration: none; }
.brand-logo { height: 44px; width: 44px; display: block; background: #fff; border-radius: 50%; padding: 4px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-org { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--side-muted); }
.brand-name { font-size: 17px; font-weight: 700; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius);
  color: var(--side-text); text-decoration: none; font-weight: 600; }
.side nav a:hover { background: var(--side-hover); color: var(--side-strong); }
.side nav a.active { background: var(--side-active); color: var(--side-strong); box-shadow: inset 3px 0 0 var(--green); }
.side nav svg { width: 20px; height: 20px; flex: none; }
.side nav .label { flex: 1; }
.side nav .count { font-size: 12.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--green); color: #06170d; }
.side-sep { border-top: 1px solid var(--side-line); margin: 4px 8px; }
.side-grow { flex: 1; }
.side-foot { display: flex; flex-direction: column; gap: 12px; padding: 14px 8px 2px; border-top: 1px solid var(--side-line); }
.side-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--side-muted); margin: 0 0 5px; font-weight: 600; display: block; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--side-line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 36px; padding: 0 4px; font-size: 13px; background: transparent; color: var(--side-text); }
.seg button:hover { background: var(--side-hover); color: var(--side-strong); }
.seg button.on { background: var(--side-active); color: var(--side-strong); }
.side select { width: 100%; min-height: 36px; padding: 0 8px; background: transparent; color: var(--side-strong); border-color: var(--side-line); }
.side select option { color: #1a2233; background: #fff; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--side-active); color: var(--side-strong); display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }
.who-text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.who-text strong { color: var(--side-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { font-size: 13px; color: var(--side-muted); }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-actions .button, .side-actions button { background: transparent; color: var(--side-text); border-color: var(--side-line); text-align: center;
  padding: 7px 6px; font-size: 13px; }
.side-actions .button:hover, .side-actions button:hover { background: var(--side-hover); color: var(--side-strong); }
.footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; padding: 14px 28px;
  display: flex; flex-wrap: wrap; gap: 6px 24px; justify-content: space-between; }

/* ---- headings and panels ---- */
h1 { font-size: 24px; margin: 0 0 6px; color: var(--heading); font-weight: 700; }
h2 { font-size: 16.5px; margin: 0 0 14px; padding-bottom: 8px; color: var(--heading); border-bottom: 1px solid var(--line); }
h2.section { margin: 28px 0 12px; border-bottom: 2px solid var(--card-top); }
h3 { font-size: 15px; margin: 18px 0 6px; color: var(--heading); }
.sub { color: var(--muted); margin: 0 0 16px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--card-top); }
.page-head h1 { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--card-top); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; }
.card.action { border: 2px solid var(--green); border-top-width: 4px; background: var(--action-bg); }
.card.empty { border-top-color: var(--line-strong); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 14px; }
.cards .card { margin-bottom: 0; }
.narrow { max-width: 480px; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.doc { max-height: 480px; overflow-y: auto; margin-top: 8px; padding: 12px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; }

/* ---- buttons and forms ---- */
.button, button { font: inherit; font-weight: 600; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--heading); cursor: pointer; text-decoration: none; display: inline-block; }
.button:hover, button:hover { background: var(--hover); }
.button.primary, button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button.primary:hover, button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.danger { color: var(--bad); border-color: var(--bad-line); }
button.danger:hover { background: var(--bad-bg); }
button:disabled { opacity: .55; cursor: default; }
.small, button.small { padding: 5px 10px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.top0 { margin-top: 0; }
label { display: block; font-weight: 600; margin: 14px 0 4px; }
input[type=text], input[type=password], textarea, select { font: inherit; padding: 9px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--input); color: var(--text); max-width: 100%; }
input[type=text], input[type=password], textarea { width: 100%; }
input[type=file] { color: var(--text); max-width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { min-height: 130px; resize: vertical; }
.short { min-height: 80px; }
form select, .card > select { width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 18px; }
.checks, .choices { display: grid; gap: 6px; margin-top: 4px; }
.choices { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 6px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
label.check:has(input:checked) { border-color: var(--primary); background: var(--hover); }
label.check input { margin-top: 4px; accent-color: var(--primary); }
label.check.inline { border: 0; padding: 0; align-items: center; background: none; }
.card > label.check { margin-bottom: 6px; }
.select-all { margin: 0 0 8px; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-form input { min-width: 130px; }
td .inline-form { flex-wrap: wrap; }
td input[type=text], td input[type=password] { min-width: 150px; padding: 6px 8px; }
td select { padding: 6px 8px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--head);
  border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even) td { background: var(--surface-2); }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--hover); }
td.err { color: var(--bad); font-size: 13px; max-width: 280px; overflow-wrap: anywhere; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---- status marks ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  background: var(--chip); color: var(--chip-text); border: 1px solid transparent; }
.badge.good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; overflow-wrap: anywhere; }
.note { background: var(--warn-bg); color: var(--note-text); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.note a { color: inherit; font-weight: 600; }
.ok { background: var(--good-bg); color: var(--good); border: 1px solid var(--good-line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; }
.pos { display: inline-block; min-width: 26px; padding: 1px 6px; margin-right: 6px; background: var(--primary); color: var(--primary-text);
  text-align: center; font-weight: 700; font-size: 13px; border-radius: 4px; }

/* ---- report ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-size: 30px; font-weight: 700; line-height: 1.1; color: var(--heading); }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.bar { height: 10px; background: var(--chip); overflow: hidden; margin: 10px 0 6px; border-radius: 999px; }
.bar > div { height: 100%; background: var(--green); width: 0; transition: width .3s; }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.steps li { padding: 4px 12px; font-size: 13px; background: var(--chip); color: var(--muted); border-radius: 999px; }
.steps li.now { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.steps li.past { background: var(--good-bg); color: var(--good); }
.quote { border-left: 3px solid var(--line-strong); padding: 2px 0 2px 10px; margin: 6px 0; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.item-title { font-weight: 600; }
.event { padding: 10px 0; border-bottom: 1px solid var(--line); }
.event:last-child { border-bottom: 0; padding-bottom: 0; }
.list { margin: 4px 0; padding-left: 20px; }
.list li { margin: 4px 0; }
details > summary { cursor: pointer; margin: 6px 0; }
.transcript { max-height: 560px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 10px; }
.turn { display: grid; grid-template-columns: 62px 96px 1fr; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.turn.student { background: var(--info-bg); }
.turn .role { font-weight: 600; font-size: 13px; color: var(--heading); }
.turn.student .role { color: var(--info); }
.turn .text { overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: break-word; }
.tabs { display: flex; gap: 0; margin-bottom: 14px; border-bottom: 1px solid var(--line-strong); }
.tabs a { padding: 8px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--heading); border-bottom-color: var(--primary); }

/* ---- sign-in ---- */
.login { max-width: 430px; margin: 6vh auto 0; padding: 0; border-top-width: 5px; overflow: hidden; }
/* The logo's lettering is dark blue, so it always sits on white, in the dark theme too. */
.login-logo { padding: 22px 26px 16px; border-bottom: 1px solid var(--line); text-align: center; background: #ffffff; }
.login-logo img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.login-body { padding: 18px 26px 24px; }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.login-top h1 { margin: 0; font-size: 20px; }
.login-top select { width: auto; }
.login .actions button { width: 100%; padding: 10px; }
.login-prefs { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.login-prefs .seg { border-color: var(--line-strong); flex: 1; }
.login-prefs .seg button { color: var(--muted); min-height: 32px; }
.login-prefs .seg button:hover { background: var(--hover); color: var(--text); }
.login-prefs .seg button.on { background: var(--primary); color: var(--primary-text); }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--side-line); gap: 12px; padding: 12px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side nav a { min-height: 40px; }
  .side nav .label { flex: none; }
  .side-grow { display: none; }
  .side-foot { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding-top: 12px; }
  .side-foot > * { flex: 1 1 200px; }
  main { padding: 18px 14px 40px; }
  .turn { grid-template-columns: 54px 1fr; }
  .turn .text { grid-column: 1 / -1; }
}
@media print {
  .no-print, .side, .footer { display: none !important; }
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) { color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --heading: #000; --muted: #333; --line: #888; --line-strong: #666;
    --head: #eee; --chip: #eee; --chip-text: #000; --card-top: #000; --primary: #000; --primary-text: #fff;
    --good: #0b4d2a; --good-bg: #fff; --warn: #5c3a00; --warn-bg: #fff; --bad: #7a120d; --bad-bg: #fff; --info: #2a2370; --info-bg: #fff; --action-bg: #fff; }
  .shell { display: block; }
  main, main.wide { max-width: none; padding: 0; }
  .card, .stat { break-inside: avoid; }
  .transcript, .doc { max-height: none; overflow: visible; }
}

/* demo version marker */
.demo-flag { margin: 0 8px 12px; padding: 6px 10px; border-radius: var(--radius); background: #f5c542; color: #3a2a00; font-weight: 700; font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; text-align: center; }
