/* RevCircle Medical Billing Academy
   W3Schools-style reader: fixed top bar, left topic sidebar, one topic per page.
   Blue theme. Typography tuned for long-form reading by ESL learners. */

:root {
  --brand: #7850A0;
  --brand-dark: #201858;
  --brand-darker: #101038;
  --brand-light: #EFEAF6;
  --brand-tint: #F5F3FA;
  --accent: #9B72C4;
  --ok: #2E7D32;
  --ok-light: #E8F5E9;
  --warn: #EF6C00;
  --err-light: #FDECEA;
  --err: #C62828;

  --ink: #1E1B33;
  --muted: #5B6B7C;
  --line: #DFE6EE;
  --page: #FBFAFE;
  --card: #FFFFFF;

  --topbar-h: 56px;
  --sidebar-w: 300px;

  /* Weak-concept heatmap: one hue, light -> dark, so more-is-darker reads
     without a key. Steps chosen off the brand purple and checked for monotone
     lightness, visible gaps between steps, and a light end that still stands
     off white (the palest step clears 2:1 on the card). Colour is never the
     only channel here — every filled cell also carries its number. */
  --heat-1: #BFA8DC;
  --heat-2: #9670BE;
  --heat-3: #6B4595;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.75;
}

p { margin: 0 0 18px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.lead { color: var(--muted); font-size: 16px; }

/* ---------- Global: all table/column headers centered ---------- */
th { text-align: center; }
/* First column in body rows stays left-aligned (names, labels) */
tbody th, td:first-child { text-align: left; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  background: var(--brand-dark);
  color: #fff;
  box-shadow: 0 1px 6px rgba(8, 48, 107, .25);
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand span { font-weight: 400; opacity: .85; }
.topbar-spacer { flex: 1; }
.topbar-link {
  color: #fff; text-decoration: none; font-size: 14px;
  padding: 6px 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,.35);
}
.topbar-link:hover { background: rgba(255,255,255,.15); }

/* ---------- Navbar: Account dropdown ---------- */
.topbar-account { position: relative; }
.topbar-account-btn {
  color: #fff; font-size: 14px; font-family: inherit;
  padding: 6px 12px; border-radius: 6px; border: 1px solid rgba(255,255,255,.35);
  background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.topbar-account-btn:hover { background: rgba(255,255,255,.15); }
.topbar-account-btn::after {
  content: "▾"; font-size: 11px; opacity: .8;
}
.topbar-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.12);
  min-width: 180px; z-index: 200; overflow: hidden;
}
.topbar-dropdown.open { display: block; }
.topbar-dropdown-item {
  display: block; padding: 11px 16px; font-size: 14px; color: var(--ink);
  text-decoration: none; border: none; background: none; width: 100%;
  text-align: left; cursor: pointer; font-family: inherit;
}
.topbar-dropdown-item:hover { background: var(--brand-tint); color: var(--brand-dark); }
.topbar-dropdown-divider { height: 1px; background: var(--line); margin: 4px 0; }
.menu-toggle {
  display: none;
  background: transparent; border: 1px solid rgba(255,255,255,.4);
  color: #fff; font-size: 18px; line-height: 1;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
}

/* ---------- Journey (course home) ---------- */
.container { max-width: 1800px; margin: 0 auto; padding: 32px 20px 80px; }
.course-title { color: var(--brand-dark); margin: 0 0 6px; font-size: 32px; line-height: 1.25; }
.course-sub { color: var(--muted); font-size: 16px; margin-bottom: 22px; }

.overall-progress { margin-bottom: 34px; }
.progress-track { height: 10px; background: #E3EAF2; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--brand); border-radius: 999px; transition: width .3s ease; }
.progress-text { margin-top: 8px; font-size: 14px; color: var(--muted); }

.phase { margin-top: 34px; }
.phase-title {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  color: var(--brand-dark); font-size: 20px;
  border-bottom: 2px solid var(--brand); padding-bottom: 8px;
}
.phase-num {
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700;
  letter-spacing: .6px; text-transform: uppercase; padding: 3px 9px; border-radius: 4px;
}
.phase-count { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 400; }

.chapter-list { list-style: none; padding: 0; margin: 14px 0 0; }
.chapter-row { margin: 9px 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.chapter-row a {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; text-decoration: none; color: var(--ink);
}
.chapter-row:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(21, 101, 192, .12); }
.ch-id { font-weight: 700; color: var(--brand); min-width: 46px; }
.ch-title { flex: 1; }
.ch-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ch-status { min-width: 22px; text-align: right; font-weight: 700; color: var(--ok); }
.chapter-row.complete { background: var(--ok-light); border-color: #A5D6A7; }
.chapter-row.complete .ch-status::after { content: "\2713"; }
.ch-bar { height: 3px; background: transparent; }
.ch-bar-fill { height: 100%; width: 0; background: var(--brand); transition: width .3s ease; }

.badge {
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px; letter-spacing: .5px;
}

/* ---------- Reader layout ---------- */
.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--topbar-h);
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 20px 0 30px;
}
.sidebar-head { padding: 0 18px 14px; border-bottom: 1px solid var(--line); }
.sidebar-eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.sidebar-title { font-weight: 700; color: var(--brand-dark); font-size: 16px; line-height: 1.4; margin: 4px 0 12px; }
.sidebar-progress { height: 7px; }
.sidebar-progress-text { font-size: 12px; color: var(--muted); margin-top: 6px; }

.toc ol { list-style: none; margin: 0; padding: 10px 0; counter-reset: toc; }
.toc-item { counter-increment: toc; }
.toc-item a {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 18px; text-decoration: none; color: var(--ink);
  font-size: 15px; line-height: 1.45;
  border-left: 3px solid transparent;
}
.toc-item a:hover { background: var(--brand-tint); }
.toc-item.current a { background: var(--brand-light); border-left-color: var(--brand); font-weight: 600; color: var(--brand-dark); }
.toc-tick {
  flex: 0 0 18px; width: 18px; height: 18px; margin-top: 3px;
  border: 1.5px solid #C3CFDB; border-radius: 50%;
  font-size: 11px; line-height: 15px; text-align: center; color: transparent;
}
.toc-item.done .toc-tick { background: var(--ok); border-color: var(--ok); color: #fff; }
.toc-item.done .toc-tick::after { content: "\2713"; }
.toc-text { flex: 1; }
.sidebar-back { display: block; padding: 12px 18px 0; font-size: 14px; text-decoration: none; }

/* ---------- Content column ---------- */
.content {
  flex: 1 1 auto; min-width: 0;
  max-width: none;
  padding: 26px 40px 90px;
}
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.step-count {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--brand);
  background: var(--brand-light); padding: 3px 10px; border-radius: 999px;
  margin-bottom: 14px;
}
.content h1 { color: var(--brand-dark); font-size: 28px; line-height: 1.3; margin: 0 0 14px; }
.content h2 { color: var(--brand-dark); font-size: 21px; line-height: 1.35; margin: 30px 0 12px; }
.ch-time-main { color: var(--muted); font-style: italic; font-size: 14px; margin-bottom: 16px; }

.label {
  color: var(--accent); font-weight: 700; font-size: 12px;
  letter-spacing: 1px; text-transform: uppercase; margin: 0 0 10px;
}

/* Panels */
.orientation {
  background: var(--brand-light); border-left: 4px solid var(--brand);
  padding: 16px 18px 2px; border-radius: 8px; margin: 0 0 24px;
}
.field-exercise {
  background: #FFF8E9; border-left: 4px solid var(--warn);
  padding: 16px 18px 2px; border-radius: 8px;
}
.closing { background: var(--brand-tint); border-radius: 8px; padding: 16px 18px 2px; margin-top: 26px; }

/* Diagrams */
.diagram { margin: 26px 0; text-align: center; }
.diagram img {
  max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 6px;
}
.diagram figcaption { color: var(--muted); font-style: italic; font-size: 14px; margin-top: 10px; }

/* Glossary cards */
.term-card {
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px; padding: 14px 18px 4px; margin-bottom: 14px;
}
.term-card h2 { margin: 0 0 8px; font-size: 18px; color: var(--brand-dark); }
.term-card p { margin: 0 0 10px; font-size: 16px; }
.term-label { color: var(--accent); font-weight: 600; }

/* Resources */
.res-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; margin-bottom: 12px; }
.res-title { font-weight: 600; text-decoration: none; }
.res-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.res-card p { margin: 8px 0 0; font-size: 16px; }
.deeper { padding-left: 20px; }

/* Practice */
.practice { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.practice-q { font-weight: 700; font-size: 19px; }
.options { list-style: none; margin: 0; padding: 0; }
.options > li { margin-bottom: 10px; }
.option {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 13px 16px; font: inherit; font-size: 17px; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: 8px;
  transition: border-color .15s, background .15s;
}
.option:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-tint); }
.option:disabled { cursor: default; }
.option.picked-correct { border-color: var(--ok); background: var(--ok-light); }
.option.picked-wrong { border-color: var(--err); background: var(--err-light); }
.option.reveal-correct { border-color: var(--ok); }
.why { font-size: 16px; padding: 10px 16px 2px; }
.why.correct { color: var(--ok); }
.why.incorrect { color: var(--muted); }
.btn-reset {
  margin-top: 6px; background: var(--brand); color: #fff; border: none;
  padding: 10px 18px; border-radius: 8px; font: inherit; font-size: 15px; cursor: pointer;
}
.btn-reset:hover { background: var(--brand-dark); }

/* Summary table */
.summary-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.summary-table td { padding: 12px 14px; vertical-align: top; border-bottom: 1px solid var(--line); }
.summary-table tr:last-child td { border-bottom: none; }
.row-key { font-weight: 700; color: var(--brand-dark); width: 32%; background: var(--brand-tint); }

/* Pager */
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; }
.btn {
  display: flex; flex-direction: column; gap: 2px;
  max-width: 47%; padding: 12px 20px;
  background: var(--brand); color: #fff; text-decoration: none;
  border-radius: 8px; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn-next { margin-left: auto; text-align: right; }
.btn-dir { font-weight: 700; font-size: 15px; }
.btn-label { font-size: 13px; opacity: .9; line-height: 1.35; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  body { font-size: 17px; }
  .menu-toggle { display: block; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 40;
    width: 86%; max-width: 340px; height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 2px 0 14px rgba(8, 48, 107, .18);
  }
  .sidebar.open { transform: translateX(0); }
  .content { max-width: none; padding: 22px 18px 80px; }
  .btn { max-width: 48%; }
}

/* Dim the page behind the mobile drawer */
.scrim {
  position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 39;
  background: rgba(11, 32, 55, .45); border: 0; padding: 0; margin: 0;
}
@media (min-width: 901px) { .scrim { display: none; } }

@media print {
  .topbar, .sidebar, .pager, .crumb { display: none; }
  .content { max-width: none; padding: 0; }
}

/* ---------- Who's logged in (top bar) ---------- */
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-name { font-size: 14px; font-weight: 600; }
.role-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.18);
}
.role-trainer { background: var(--accent); }
.role-manager { background: var(--warn); }
.role-admin   { background: #6d3fc0; color: #fff; }
.logout-form { margin: 0; display: flex; }
.logout-form .topbar-link { font: inherit; font-size: 14px; cursor: pointer; background: transparent; }

/* ---------- Login / password pages ---------- */
.auth-wrap {
  display: flex; align-items: flex-start; justify-content: center;
  min-height: calc(100vh - var(--topbar-h)); padding: 8vh 20px 60px;
}
.auth-card {
  width: 100%; max-width: 420px; padding: 32px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(32, 24, 88, .10);
}
.auth-title { color: var(--brand-dark); margin: 0 0 6px; font-size: 26px; line-height: 1.25; }
.auth-sub { color: var(--muted); font-size: 15px; margin: 0 0 24px; }
.auth-label {
  display: block; margin-bottom: 6px;
  font-size: 14px; font-weight: 600; color: var(--brand-dark);
}
.auth-input {
  width: 100%; margin-bottom: 18px; padding: 11px 13px;
  font-size: 16px; font-family: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
.auth-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.auth-button {
  display: inline-block; width: 100%; margin-top: 6px; padding: 12px 20px;
  font-size: 16px; font-weight: 700; font-family: inherit; text-align: center;
  color: #fff; background: var(--brand); text-decoration: none;
  border: 0; border-radius: 8px; cursor: pointer; transition: background .15s;
}
.auth-button:hover { background: var(--brand-dark); }
.auth-error {
  margin-bottom: 20px; padding: 12px 14px;
  font-size: 15px; color: var(--err); background: var(--err-light);
  border: 1px solid rgba(198, 40, 40, .25); border-radius: 8px;
}
.auth-error ul { margin: 0; padding-left: 18px; }
.auth-note {
  margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 14px; line-height: 1.6; color: var(--muted);
}

/* ---------- Locked chapters + flash notes ---------- */
.flash {
  margin: 0 0 22px; padding: 14px 18px;
  font-size: 15px; font-weight: 600; color: var(--brand-dark);
  background: var(--brand-light); border-left: 4px solid var(--brand);
  border-radius: 6px;
}
.flash--error {
  color: var(--err); background: #FDECEA; border-left-color: var(--err);
  border-radius: 6px;
}

/* A locked row keeps the layout of a linked one but isn't clickable. */
.ch-locked {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; color: var(--muted); cursor: not-allowed;
}
.chapter-row.locked { opacity: .62; }
.chapter-row.locked .ch-title { color: var(--muted); }
.chapter-row.locked .ch-status { font-weight: 600; }
.chapter-row.locked .ch-status::before { content: "\1F512\00a0"; }

.journey-note {
  margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}

/* ---------- Trainer / manager dashboard ---------- */
.dash-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 34px; }
.dash-btn {
  padding: 10px 18px; border-radius: 8px;
  font-size: 15px; font-weight: 600; text-decoration: none;
  background: var(--brand); color: #fff; transition: background .15s;
}
.dash-btn:hover { background: var(--brand-dark); }
.dash-btn-quiet { background: var(--card); color: var(--brand-dark); border: 1px solid var(--line); }
.dash-btn-quiet:hover { background: var(--brand-light); }

.dash-section { margin-bottom: 34px; }
.dash-heading, .heat-heading {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 12px; font-size: 19px; color: var(--brand-dark);
  text-transform: capitalize;
}
.dash-count {
  font-size: 13px; font-weight: 700; color: var(--muted);
  background: var(--brand-tint); border: 1px solid var(--line);
  padding: 2px 9px; border-radius: 999px;
}

/* Wide rosters scroll inside the card, never the page. */
.dash-table-wrap {
  overflow-x: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.dash-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.dash-table th, .dash-table td { padding: 12px 16px; text-align: left; white-space: nowrap; }
.dash-table thead th {
  font-size: 12px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--muted); background: var(--brand-tint); border-bottom: 1px solid var(--line);
}
.dash-table tbody tr + tr td { border-top: 1px solid var(--line); }
.dash-table tbody tr:hover { background: var(--brand-tint); }
.dash-row-actions { display: flex; gap: 14px; font-size: 14px; }

.pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.pill-ok { background: var(--ok-light); color: var(--ok); }
.pill-off { background: var(--err-light); color: var(--err); }

.dash-empty {
  padding: 18px; font-size: 15px; color: var(--muted);
  background: var(--card); border: 1px dashed var(--line); border-radius: 10px;
}
.dash-note {
  margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (max-width: 900px) {
  /* Keep the bar to essentials so it never overflows: the logo already links
     home, and the name and role are not worth the width on a phone. */
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar-link--home, .topbar-name, .topbar .role-badge { display: none; }
  .auth-wrap { padding: 5vh 16px 60px; }
  .auth-card { padding: 24px 20px; }
  /* The roster keeps its own horizontal scroll rather than squashing. */
  .dash-table { font-size: 14px; }
  .dash-table th, .dash-table td { padding: 10px 12px; }
}

/* === UI Overhaul === */
@media (min-width: 901px) { .content { padding: 32px 64px 90px; } }
.section-heading { padding-left: 18px; border-left: 5px solid var(--brand); font-size: 28px; line-height: 1.3; margin: 0 0 20px; }
.section-body p:first-child { background: var(--brand-tint); border-left: 4px solid var(--brand); border-radius: 0 8px 8px 0; padding: 14px 20px; font-size: 17px; font-weight: 500; color: var(--brand-dark); line-height: 1.75; margin-bottom: 20px; }
.section-body p { font-size: 17px; line-height: 1.85; }
.hook-section { margin: 8px 0 4px; }
.hook-body p:first-child { font-size: 18px; font-weight: 500; color: var(--brand-dark); line-height: 1.75; }
.orientation-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 10px 0 28px; }
.orient-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px 18px 14px; position: relative; overflow: hidden; box-shadow: 0 2px 8px rgba(32,24,88,.06); }
.orient-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 10px 10px 0 0; }
.orient-card--info::before { background: var(--brand); }
.orient-card--unlock::before { background: var(--ok); }
.orient-card--connect::before { background: var(--accent); }
.orient-label { font-size: 11px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.orient-body { font-size: 15px; line-height: 1.6; color: var(--ink); margin: 0; }
.diagram { margin: 32px 0; background: var(--brand-tint); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.diagram img { max-width: 100%; height: auto; border-radius: 8px; border: none; padding: 0; box-shadow: 0 4px 18px rgba(32,24,88,.13); }
.diagram figcaption { color: var(--muted); font-style: italic; font-size: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
@media (max-width: 900px) { .orientation-cards { grid-template-columns: 1fr; } .section-heading { padding-left: 12px; border-left-width: 4px; } }

/* ---------- Gates (Milestone D) ---------- */

/* The gate sits at the foot of its phase on the journey map, deliberately
   heavier than a chapter row: it is the thing the phase has been leading to. */
.gate-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 10px; padding: 14px 18px;
  border: 1px solid var(--brand, #2c2a6b); border-radius: 10px;
  background: rgba(44, 42, 107, 0.04);
  text-decoration: none; color: inherit;
}
.gate-row:hover { background: rgba(44, 42, 107, 0.09); }
.gate-row-name { font-weight: 700; }
.gate-row-meta { color: var(--muted); font-size: 14px; }
.gate-row-status { margin-left: auto; font-size: 14px; font-weight: 700; }
.gate-row.passed { border-color: #1c7c4a; background: rgba(28, 124, 74, 0.07); }
.gate-row.passed .gate-row-status { color: #1c7c4a; }
.gate-row.locked { border-color: var(--line); background: transparent; color: var(--muted); }

.gate-page { max-width: 760px; }
.gate-status { margin-top: 26px; }
.gate-blocked { padding: 14px 16px; border-radius: 8px; background: #f4f4f7; }
.gate-cooldown, .gate-attempts { color: var(--muted); font-size: 14px; }
.gate-back { margin-top: 34px; }

.gate-result { margin-top: 24px; padding: 18px 20px; border-radius: 10px; }
.gate-result--pass { background: rgba(28, 124, 74, 0.08); border: 1px solid #1c7c4a; }
.gate-result--fail { background: rgba(176, 58, 46, 0.06); border: 1px solid #b03a2e; }
.gate-result h2 { margin: 0 0 6px; }
.gate-score { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
.gate-reasoning { margin: 0; font-size: 15px; }

.gate-revise { margin-top: 22px; }
.revise-list { list-style: none; padding: 0; }
.revise-list li {
  padding: 12px 0; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.revise-concept { font-weight: 700; }
.revise-note { color: var(--muted); font-size: 14px; }

/* ---------- The exam paper ---------- */

.exam { max-width: 820px; }
.exam-head {
  display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 5;
}
.exam-title { margin: 0; font-size: 24px; }
.exam-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* The clocks stay on screen while the paper scrolls. */
.exam-timers { margin-left: auto; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.exam-timer, .exam-q-timer {
  text-align: right; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px; min-width: 110px;
}
.exam-q-timer { border-color: var(--brand-light); background: var(--brand-tint); }
.exam-timer-value { display: block; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.exam-timer-label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.exam-timer--warn  { border-color: #c77700; color: #c77700; }
.exam-timer--urgent { border-color: #b03a2e; color: #b03a2e; }
.exam-q-timer.exam-timer--warn  { border-color: #c77700; }
.exam-q-timer.exam-timer--urgent { border-color: #b03a2e; background: #FDECEA; }

/* Question navigation dots */
.exam-nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 0 6px; }
.exam-nav-dot {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--card); font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.exam-nav-dot.active  { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }
.exam-nav-dot.answered { border-color: var(--ok); color: var(--ok); background: var(--ok-light); }
.exam-nav-dot.timed-out { border-color: var(--muted); color: var(--muted); background: var(--line); }
.exam-nav-dot.locked { border-color: var(--line); color: var(--line); background: var(--card); cursor: not-allowed; opacity: 0.45; }

/* Per-question navigation buttons */
.exam-q-nav { display: flex; gap: 12px; padding: 20px 0 8px; }

.exam-q { padding: 26px 0; border-bottom: 1px solid var(--line); }
.exam-q-num { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.exam-scenario {
  background: #f6f7fb; border-left: 3px solid var(--brand, #2c2a6b);
  padding: 12px 16px; border-radius: 0 8px 8px 0; margin: 0 0 12px;
}
.exam-question { font-weight: 700; margin: 0 0 14px; }
.exam-options { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.exam-option {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.exam-option:hover { background: #f6f7fb; }
.exam-option input { margin-top: 3px; }
/* No correct/incorrect styling exists for the exam on purpose — the browser
   is never told, so there would be nothing to style it from. */
.exam-q.answered .exam-option input:checked + .exam-option-text { font-weight: 600; }

.exam-submit { padding: 28px 0 60px; }
.exam-submit-note { color: var(--muted); font-size: 14px; max-width: 60ch; }

@media (max-width: 900px) {
  .exam-head { position: static; }
  .exam-timer { margin-left: 0; }
}

/* ---------- Pre-exam warning screen ---------- */
.preexam-rules { background: var(--brand-tint); border: 1px solid var(--brand-light); border-radius: 12px; padding: 28px 32px; max-width: 680px; }
.preexam-list { margin: 0; padding: 0 0 0 20px; }
.preexam-list li { margin-bottom: 16px; line-height: 1.6; }
.preexam-list li:last-child { margin-bottom: 0; }

/* Timed-out questions in supervisor review */
.item-timed-out { background: #F5F5F5; opacity: 0.7; }
.badge-timeout { background: var(--muted); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; }

/* ---------- Escalation review (Milestone D4) ---------- */

/* Deliberately the first thing on the roster: a locked exam is a person
   waiting on a conversation, not a row in a report. */
.review-queue {
  margin: 22px 0 8px; padding: 18px 20px;
  border: 1px solid #c77700; border-radius: 10px;
  background: rgba(199, 119, 0, 0.06);
}
.review-queue-title { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.review-queue-count {
  background: #c77700; color: #fff; border-radius: 999px;
  padding: 1px 10px; font-size: 13px;
}
.review-queue-list { list-style: none; padding: 0; margin: 12px 0 0; }
.review-queue-list a {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline;
  padding: 10px 0; border-top: 1px solid rgba(199, 119, 0, 0.25);
  text-decoration: none; color: inherit;
}
.review-queue-list a:hover { background: rgba(199, 119, 0, 0.07); }
.review-who { font-weight: 700; }
.review-what { color: var(--muted); }
.review-when { margin-left: auto; color: var(--muted); font-size: 14px; }

/* Authorization queue items (not links, so styled separately from escalation rows) */
.auth-item {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  padding: 10px 0; border-top: 1px solid rgba(199, 119, 0, 0.25);
}
.auth-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.dash-btn--small { padding: 5px 12px; font-size: 13px; }
.quick-release-panel { background: #FFFBEA; border: 1px solid #F0D050; border-radius: 12px; padding: 18px 20px; }
.quick-release-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.linkish--danger { color: #c0392b; }
.linkish--danger:hover { color: #96281b; }
.inline-select {
  font: inherit; font-size: 13px;
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  cursor: pointer;
}

/* Gate page authorization and reveal states */
.gate-auth-note { color: var(--muted); font-size: 14px; margin-top: 10px; }
.gate-review-note { font-size: 14px; margin-top: 10px; }
.gate-reveal-note {
  margin-top: 18px; padding: 12px 16px; border-radius: 8px;
  background: rgba(39, 174, 96, 0.08); border: 1px solid rgba(39, 174, 96, 0.3);
  font-size: 14px;
}
.gate-reveal-note a { font-weight: 600; }
.gate-reveal-note--pending {
  background: rgba(199, 119, 0, 0.06); border-color: rgba(199, 119, 0, 0.35);
  color: var(--muted);
}

.review-attempts { margin-top: 26px; }
.review-decide { margin-top: 30px; }
.review-note-label { display: block; font-weight: 700; margin-bottom: 6px; }
.review-note {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; margin-bottom: 14px;
}
.gate-review-note {
  margin-top: 12px; padding: 14px 16px; border-radius: 8px;
  background: rgba(44, 42, 107, 0.05); max-width: 62ch;
}

/* ---------- Phase locking (Milestone D5) ---------- */

/* A closed phase is dimmed but never hidden: seeing what is coming is part of
   the motivation, and a phase that vanished would look like a bug. */
.phase--locked .chapter-list { opacity: 0.55; }
.phase-locked-note {
  margin: 8px 0 14px; padding: 12px 16px;
  border-left: 3px solid var(--brand, #2c2a6b);
  background: rgba(44, 42, 107, 0.05); border-radius: 0 8px 8px 0;
  max-width: 62ch;
}

/* ---------- Cohort reporting (Milestone E) ---------- */

.stat-row {
  display: flex; flex-wrap: wrap; gap: 24px; margin: 0 0 56px;
  justify-content: center;
}
.stat {
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); flex: 0 0 auto; min-width: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
/* Coloured card variants */
.stat--purple { background: #F3EEFF; border-color: #C9AAEE; }
.stat--green  { background: #EAF7EE; border-color: #A3D9B0; }
.stat--red    { background: #FDECEA; border-color: #F5C6C0; }

.stat-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stat-value { display: block; font-size: 30px; font-weight: 700; line-height: 1.25; color: var(--ink); }
.stat-foot  { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Card 1: "Students" heading above two sub-columns split by a vertical divider */
.stat--split {
  flex-direction: column; align-items: stretch; gap: 0; padding: 0; justify-content: flex-start;
}
.stat-split-top {
  width: 100%; text-align: center; padding: 14px 20px 6px;
  font-size: 13px; color: var(--muted);
}
.stat-split-row {
  display: flex; flex-direction: row; flex: 1; align-items: stretch;
}
.stat-half {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px 20px 18px; text-align: center; flex: 1;
}
.stat-divider {
  width: 1px; background: var(--line); align-self: stretch; margin: 12px 0;
}

/* Needs review attention state */
.stat--attention { border-color: #F5C6C0; background: #FDECEA; }
.stat--attention .stat-value { color: var(--err); }

/* Red badge (!) for needs-review > 0 */
.stat-alert {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--err); color: #fff; font-size: 13px; font-weight: 900;
  margin-left: 8px; vertical-align: middle; line-height: 1;
}

/* Horseshoe gauge (SVG) for avg completion */
.stat-gauge { display: block; margin: 4px auto 0; }

/* Clickable stat cards */
a.stat, a.stat--split {
  text-decoration: none; transition: box-shadow .15s, transform .15s;
  cursor: pointer;
}
a.stat:hover, a.stat--split:hover {
  box-shadow: 0 4px 16px rgba(120,80,160,.15);
  transform: translateY(-2px);
}

/* ---------- Responsive dashboard grid ---------- */
/* Content below the stat cards: 1 → 2 → 3 columns by screen width.
   Each column scrolls independently so a wide table in one column doesn't
   break the layout of the others. */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  align-items: start;
}
.dash-grid > * { min-width: 0; }
@media (min-width: 1400px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 2000px) {
  .dash-grid { grid-template-columns: 1fr 1fr 1fr; }
}
/* Sections that should span all columns (review queues, etc.) */
.dash-grid-full { grid-column: 1 / -1; }

/* Prevent wide tables from overflowing their column */
.dash-table-wrap { overflow-x: auto; max-width: 100%; }

/* ---------- Completion: meter ---------- */
.dash-progress-cell { min-width: 160px; }
.meter {
  display: block; width: 110px; height: 8px; border-radius: 999px;
  background: var(--brand-light); overflow: hidden;
}
.meter-fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.meter-text {
  display: block; font-size: 13px; margin-top: 6px; /* breathing room */
}
.meter-text .muted { font-size: 12px; }

.dash-student { font-weight: 600; text-decoration: none; }
.dash-student:hover { text-decoration: underline; }
.dash-username { display: block; font-size: 12px; color: var(--muted); }

/* The exam matrix. Status colour is reserved for state and always carries a
   word or a score with it, so the grid is readable without relying on hue. */
.matrix-head { text-align: center; }
.matrix-head abbr { text-decoration: none; border-bottom: 1px dotted var(--muted); }
.matrix-cell { text-align: center; }
.cell {
  display: inline-block; min-width: 54px; padding: 3px 8px;
  border-radius: 6px; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
/* A first-attempt pass is the strongest signal the system produces, so it is
   the only solid green square; a later pass is the same green, outlined. */
.cell--passed { background: var(--card); color: var(--ok); border-color: var(--ok); }
.cell--passed.cell--first { background: var(--ok); color: #fff; border-color: var(--ok); }
.cell--failed { background: var(--err-light); color: var(--err); border-color: #F5C6C0; }
.cell--locked { background: rgba(199, 119, 0, 0.12); color: #8a5300; border-color: var(--warn); }
.cell--sitting { background: var(--brand-light); color: var(--brand-dark); border-color: var(--accent); }
.cell--ready { background: var(--card); color: var(--muted); border-color: var(--line); }
.cell--reading { background: transparent; color: var(--line); font-weight: 400; }
/* Closed by a manager — not a state the student got themselves into, so it is
   neutral rather than red. */
.cell--closed { background: var(--brand-tint); color: var(--muted); border-color: var(--line); }
.cell-flag { margin-left: 4px; font-size: 13px; color: var(--muted); }

/* Heatmap: rows are concepts, columns are students, and the number in the cell
   says how many attempts that person missed it in. */
.heat-table th, .heat-table td { padding: 8px 10px; }
.dash-table th.heat-concept { min-width: 220px; white-space: normal; }
.heat-concept-name { display: block; font-weight: 700; }
.heat-concept-meta { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.heat-count-head, .heat-count { white-space: nowrap; font-size: 13px; text-align: center; }
/* Full student name in column headers — allow wrapping so wide names don't blow the table */
.heat-col { text-align: center; font-size: 11px; min-width: 56px; white-space: normal; line-height: 1.3; }
.heat-col abbr { text-decoration: none; }
/* Breathing room between "1 of 8" and the percentage */
.heat-count-sep { display: block; height: 4px; }
.heat-cell {
  text-align: center; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  /* A 2px surface gap does the separating between neighbouring cells; no
     borders, which would add ink that isn't data. */
  border: 2px solid var(--card); border-radius: 4px; min-width: 34px;
}
.heat-table tbody tr:hover .heat-cell { border-color: var(--brand-tint); }
.heat-0 { background: transparent; }
.heat-1 { background: var(--heat-1); color: var(--ink); }
.heat-2 { background: var(--heat-2); color: #fff; }
.heat-3 { background: var(--heat-3); color: #fff; }
.heat-key { margin-top: 12px; font-size: 13px; color: var(--muted); }
.heat-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  vertical-align: -2px; margin: 0 2px 0 10px;
}
.badge-warn { background: var(--warn); }

/* ---------- The candidate one-pager ---------- */

.candidate { max-width: 1400px; }
.candidate-head { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.candidate-head .course-title { margin-bottom: 2px; }
.candidate-actions { margin-left: auto; display: flex; gap: 10px; }
.candidate-block { margin-top: 30px; }
.candidate-block h2 { font-size: 19px; color: var(--brand-dark); margin: 0 0 10px; }
.candidate-block .dash-table {
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.candidate-block .dash-table-wrap { border: 0; background: transparent; }
/* Rows in these tables have cells of very different heights (a wrapped concept
   list beside a one-line link), so align them to the top rather than centring
   the short ones against the tall one. */
.candidate-block .dash-table td, .candidate-block .dash-table th { vertical-align: top; }
.dash-table th.candidate-exam-name { font-weight: 600; white-space: normal; min-width: 200px; }
/* A list of missed concepts is the one genuinely long cell on the page. It
   wraps rather than running on, and the column that follows it keeps its own
   width — the link must never end up sitting on top of the text. */
.dash-table td.missed-cell {
  white-space: normal; overflow-wrap: break-word;
  min-width: 30ch; max-width: 40ch; font-size: 13px;
}
.candidate-note { margin-top: 12px; font-size: 14px; color: var(--muted); max-width: 72ch; }
.candidate-flag { border-left: 3px solid var(--warn); padding-left: 12px; }

/* What actually comes out of the printer: the summary, on one page, with no
   navigation, no buttons and no link underlining to read around. */
@media print {
  body { background: #fff; font-size: 12px; line-height: 1.45; }
  .topbar, .candidate-actions, .gate-back, .flash { display: none !important; }
  .container.candidate { max-width: none; padding: 0; margin: 0; }
  .candidate-block { margin-top: 16px; page-break-inside: avoid; }
  .course-title { font-size: 22px; }
  .stat-row { gap: 8px; margin-bottom: 14px; }
  .stat { padding: 8px 10px; }
  .stat-value { font-size: 20px; }
  .dash-table { font-size: 11px; }
  .dash-table th, .dash-table td { padding: 5px 8px; }
  .dash-table-wrap, .candidate-block .dash-table { border-color: #999; }
  a { color: inherit; text-decoration: none; }
  .revise-list li { padding: 5px 0; }
}

/* ---------- Assign / release + the attempt drill-down (Milestone E) ---------- */

.pill-warn { background: rgba(199, 119, 0, 0.14); color: #8a5300; }
.pill-chosen { background: var(--brand-light); color: var(--brand-dark); }

/* A submit button that reads as the link it behaves like, so the exam table's
   last column doesn't sprout a row of heavy buttons. */
.linkish {
  border: 0; background: none; padding: 0; font: inherit; font-size: 14px;
  color: var(--brand); cursor: pointer; text-decoration: underline;
}
.linkish:hover { color: var(--brand-dark); }

.candidate-release select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 12px; display: block;
}
.dash-table td.drill-cell { font-size: 13px; white-space: nowrap; vertical-align: top; }

/* One question, as the trainer reviews it. Right answers collapse; wrong ones
   open, because the paper is read for what went wrong. */
.qreview {
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  margin-bottom: 12px; padding: 4px 16px;
}
.qreview--wrong { border-color: #F0B8B2; background: rgba(198, 40, 40, 0.03); }
.qreview summary { cursor: pointer; padding: 12px 0; }
.qreview summary::marker { color: var(--muted); }
.qreview-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.qreview-num { font-weight: 700; font-size: 13px; color: var(--muted); min-width: 34px; }
.qreview-title { flex: 1 1 320px; font-size: 15px; }
.qreview-tags { font-size: 12px; color: var(--muted); text-transform: lowercase; }
.qreview-time { font-size: 12px; color: var(--muted); margin-left: auto; }
.qreview-retired { color: var(--muted); font-size: 14px; }

.qreview-options { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.qreview-option {
  display: flex; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 15px;
}
/* The correct answer and the one they picked are different facts about an
   option, so they are different marks — an option can carry both. */
.qreview-option.is-correct { border-color: var(--ok); background: var(--ok-light); }
.qreview-option.is-chosen { box-shadow: inset 3px 0 0 var(--brand); }
.qreview-option.is-chosen:not(.is-correct) { border-color: var(--err); background: var(--err-light); }
.qreview-key { font-weight: 700; color: var(--muted); }
.qreview-option-body { display: flex; flex-direction: column; gap: 6px; }
.qreview-marks { display: flex; gap: 6px; flex-wrap: wrap; }
.qreview-why { font-size: 14px; color: var(--muted); }
/* The instructor annotation — the most useful line on the page, and the one
   that must never reach a student. */
.qreview-catches {
  font-size: 14px; padding: 8px 12px; border-radius: 6px;
  background: rgba(199, 119, 0, 0.08); border-left: 3px solid var(--warn);
}
.qreview-foot { font-size: 13px; color: var(--muted); margin: 0 0 14px; }

@media print {
  /* Reviewing a paper away from a desk is the same job as the one-pager. */
  .qreview { break-inside: avoid; }
  .qreview details { display: block; }
  .qreview summary { list-style: none; }
}

/* --- Dashboard tabs (Active / Graduated / Disabled) ----------------------- */
.dash-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 2px solid var(--line);
}
.dash-tab {
  padding: 8px 18px; font-size: 14px; font-weight: 600;
  color: var(--muted); text-decoration: none; border-radius: 6px 6px 0 0;
  border: 1px solid transparent; border-bottom: none;
  transition: color .15s;
}
.dash-tab:hover { color: var(--brand); background: var(--brand-tint); }
.dash-tab--active {
  color: var(--brand-dark); background: var(--card);
  border-color: var(--line); border-bottom: 2px solid var(--card);
  margin-bottom: -2px;
}
.dash-tab-count {
  display: inline-block; min-width: 20px; padding: 1px 6px;
  background: var(--brand-light); color: var(--brand-dark);
  border-radius: 999px; font-size: 11px; font-weight: 700;
  margin-left: 6px; text-align: center;
}
.dash-tab--active .dash-tab-count { background: var(--brand); color: #fff; }

/* --- Graduated pill and badge --------------------------------------------- */
.pill-graduated { background: #FFF8E1; color: #8B6800; }
.pill-warn { background: #FFF3CD; color: #7C5200; }

.dash-btn--danger {
  background: var(--card); color: var(--err);
  border: 1px solid var(--err); border-radius: 8px;
}
.dash-btn--danger:hover { background: var(--err-light); }
.dash-btn--graduate {
  background: var(--ok-light); color: var(--ok);
  border: 1px solid var(--ok); border-radius: 8px; font-weight: 700;
}
.dash-btn--graduate:hover { background: #c8e6c9; }

.linkish--graduate { color: var(--ok); }
.linkish--graduate:hover { color: #1b5e20; }

/* --- Graduates page -------------------------------------------------------- */
.graduates-table td, .graduates-table th { vertical-align: middle; }
.grad-row--champion { background: #FFFDE7; }
.grad-badge {
  display: inline-block; font-size: 14px; margin-left: 4px;
  color: #B8860B; vertical-align: middle;
}
.grad-badge--reason { color: var(--brand); }

/* --- User management page ------------------------------------------------- */
.users-table td { vertical-align: middle; }

/* --- Exam integrity flags -------------------------------------------------- */
.exam-flags { margin: 28px 0; }
.flag-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--err-light); color: var(--err);
  vertical-align: middle; margin-left: 8px;
}
.flag-count--warn { background: #FFF3E0; color: #E65100; }
.flag-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.flag-item {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px;
  background: #FFF3E0; font-size: 14px;
}
.flag-label { color: #E65100; font-weight: 600; }
.flag-n { color: #BF360C; font-weight: 700; }

/* Flag badge on the candidate attempt table */
.flag-badge {
  display: inline-block; margin-left: 8px;
  font-size: 12px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px;
  background: #FFF3E0; color: #E65100;
  vertical-align: middle; white-space: nowrap;
}

/* ---------- Dashboard: clickable student rows ---------- */
.dash-table tbody tr[data-href] { cursor: pointer; }
.dash-table tbody tr[data-href]:hover { background: var(--brand-light); }

/* ---------- Dashboard: attempt timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.timeline-dot--pass { background: var(--ok); }
.timeline-dot--fail { background: var(--err); }
.timeline-body { flex: 1; }
.timeline-who { font-weight: 600; }
.timeline-what { color: var(--muted); }
.timeline-when { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Dashboard: student pace board ---------- */
.pace-board { display: flex; flex-direction: column; gap: 0; }
.pace-row {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.pace-row:last-child { border-bottom: none; }
.pace-name { font-weight: 600; }
.pace-bar-wrap { width: 120px; }
.pace-bar { height: 6px; background: var(--brand-light); border-radius: 3px; overflow: hidden; }
.pace-bar-fill { height: 100%; background: var(--brand); border-radius: 3px; }
.pace-days { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }

/* ---------- Dashboard: student progress cards ---------- */
.student-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 28px;
}
@media (min-width: 600px) {
  .student-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 900px) {
  .student-cards { grid-template-columns: repeat(4, 1fr); }
}

/* Exams table: columns 2-5 centered */
.dash-section.exams td { text-align: center; }
.student-card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  padding: 14px 12px; display: flex; flex-direction: column; align-items: center;
  text-align: center; text-decoration: none; color: inherit;
  transition: box-shadow .15s, transform .15s;
}
.student-card:hover {
  box-shadow: 0 4px 16px rgba(120,80,160,.12); transform: translateY(-2px);
}
.student-card-name { font-weight: 700; font-size: 13px; margin-bottom: 10px; color: var(--ink); }
.student-card-ring { display: block; margin: 0 auto; }

/* Action buttons in table rows */
.dash-row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 0; }

/* ---------- Dashboard: stat mini-bars ------------------------------------ */
/* A thin bar beneath each stat value gives ratio context without replacing
   the number. The brand colour for neutral metrics; green for first-try rate
   (the strongest positive signal); orange for anything requiring attention. */
.stat-bar {
  display: block; height: 5px; border-radius: 3px;
  background: var(--line); margin-top: 10px; overflow: hidden;
}
.stat-bar-fill {
  display: block; height: 100%; border-radius: 3px;
  background: var(--brand); transition: width .4s ease;
}
.stat-bar-fill--ok   { background: var(--ok); }
.stat-bar-fill--warn { background: var(--warn); }

/* ---------- Dashboard: exam pipeline chart -------------------------------- */
/* One horizontal stacked bar per exam. Segments are coloured by status so a
   glance answers "which exam is the bottleneck?" without reading the table. */
.pipeline { margin-bottom: 34px; }
.pipeline-rows { display: flex; flex-direction: column; gap: 10px; }
.pipeline-row {
  display: grid;
  grid-template-columns: 180px 1fr 48px;
  align-items: center; gap: 12px;
}
.pipeline-name {
  font-size: 14px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pipeline-bar {
  height: 22px; background: var(--brand-tint); border-radius: 5px;
  display: flex; overflow: hidden; border: 1px solid var(--line);
}
.pipeline-seg {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; overflow: hidden;
  transition: flex-basis .4s ease;
}
/* Colours match the cell colours on the roster matrix for consistency */
.pipeline-seg--passed  { background: var(--ok); }
.pipeline-seg--sitting { background: var(--accent); }
.pipeline-seg--waiting { background: var(--warn); }
.pipeline-seg--locked  { background: var(--err); }
.pipeline-total { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.pipeline-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--muted);
}
.pipeline-key { display: flex; align-items: center; gap: 5px; }
.pipeline-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }

/* ---------- Student journey: phase progress track ------------------------- */
/* A row of numbered bubbles giving the student a one-glance view of where
   they stand across the whole course, complementing the chapter list below. */
.phase-track {
  display: flex; align-items: center; gap: 0; margin: 0 0 28px; flex-wrap: wrap;
}
.phase-pip {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  border: 2px solid transparent;
  position: relative;
}
.phase-pip-label {
  font-size: 11px; color: var(--muted); text-align: center;
  margin: 0 2px; display: flex; flex-direction: column; align-items: center;
}
.phase-track-connector {
  flex: 1; height: 2px; background: var(--line); min-width: 16px; max-width: 40px;
}
/* States */
.phase-pip--passed  { background: var(--ok); color: #fff; border-color: var(--ok); }
.phase-pip--sitting { background: var(--brand-light); color: var(--brand-dark); border-color: var(--accent); }
.phase-pip--reading { background: var(--brand-light); color: var(--brand-dark); border-color: var(--brand); }
.phase-pip--locked  { background: var(--card); color: var(--muted); border-color: var(--line); }
.phase-track-connector--passed { background: var(--ok); }

/* An attempt an admin set aside so the exam could be re-sat. It stays on the
   record deliberately, so it is dimmed and struck rather than hidden — a
   hiring page that silently drops results is worse than one that shows a
   crossed-out one. */
.attempt-superseded > td,
.attempt-superseded > th { opacity: .55; }
.attempt-superseded > td:nth-child(3) { text-decoration: line-through; }
.attempt-superseded-note > td {
  padding-top: 0;
  border-top: 0;
  font-size: 12px;
  color: var(--muted);
}

/* Wide centered orientation pills (opt-in per chapter) */
.orient-wide { display: flex; flex-direction: column; gap: 14px; margin: 10px 0 28px; }
.orient-wide .orient-card { width: 100%; text-align: center; }
.orient-wide .orient-card--info .orient-label { color: var(--brand); }
.orient-wide .orient-card--unlock .orient-label { color: var(--ok); }
.orient-wide .orient-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-top: 14px; }
.orient-wide .orient-cell { text-align: center; font-size: 15px; line-height: 1.6; color: var(--ink); }
.orient-wide .orient-label { font-size: 15px; }
.concept-body p { font-size: 17px; line-height: 1.85; }
.concept-card { background: var(--brand-tint); border: 2px solid var(--brand); border-radius: 12px; padding: 20px 24px; margin: 24px 0; font-size: 18px; line-height: 1.7; color: var(--brand-dark); }
.concept-card strong { color: var(--brand); }
.concept-tri { display: block; width: 100%; max-width: 560px; margin: 8px auto 24px; }
.tri-node circle { fill: var(--brand-tint); stroke: var(--brand); stroke-width: 3; }
.tri-node text { fill: var(--brand-dark); font-size: 17px; font-weight: 700; text-anchor: middle; }
.tri-arrow { stroke: var(--brand); stroke-width: 3; fill: none; marker-start: url(#triHead); marker-end: url(#triHead); }
.tri-head { fill: var(--brand); }
.video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; margin: 20px 0 12px; }
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 10px; }

.cyc{display:block;width:100%;max-width:1560px;margin:16px auto 8px}
.cyc-node circle{fill:var(--brand-tint);stroke:var(--brand);stroke-width:3}
.cyc-node text{fill:var(--brand-dark);font-size:18px;font-weight:700;text-anchor:middle;dominant-baseline:central}
.cyc-ok circle{fill:#e6f4ea;stroke:var(--ok)}
.cyc-bad circle{fill:#fdecea;stroke:#c0392b}
.cyc-arr{stroke:var(--brand);stroke-width:2.5;fill:none;marker-end:url(#cycHead)}
.cyc-head{fill:var(--brand)}
.cyc-lab{fill:var(--ink);font-size:14px;text-anchor:middle;paint-order:stroke;stroke:#fff;stroke-width:5px}

.lad{margin:16px 0}
.lad-rung{display:flex;gap:16px;margin-bottom:18px;position:relative}
.lad-rung:not(:last-child)::before{content:"";position:absolute;left:19px;top:40px;bottom:-18px;width:3px;background:var(--brand)}
.lad-num{flex:none;width:40px;height:40px;border-radius:50%;background:var(--brand);color:#fff;font-weight:700;display:flex;align-items:center;justify-content:center;z-index:1}
.lad-body{flex:1;background:var(--brand-tint);border-left:4px solid var(--brand);border-radius:10px;padding:14px 18px}
.lad-body h3{margin:0 0 6px;color:var(--brand-dark);font-size:20px}
.lad-body p{margin:0 0 6px;font-size:16px}
.lad-body ul{margin:0;padding-left:20px}
.lad-body li{margin:4px 0;font-size:16px;line-height:1.6}

.scope-wrap{display:grid;grid-template-columns:2fr 1fr;gap:20px;margin:20px 0;align-items:start}
.scope-block{background:var(--brand-tint);border:2px solid var(--brand);border-radius:12px;padding:20px 24px}
.scope-block h3{margin:0 0 12px;color:var(--brand-dark);font-size:20px}
.scope-item{margin:0 0 14px}
.scope-item p{margin:4px 0 0;font-size:16px;line-height:1.7}
.aside-note{background:#fff8e6;border:1px solid #f0d58c;border-radius:10px;padding:14px 16px;font-size:14px;line-height:1.6}
.aside-note h4{margin:0 0 6px;font-size:15px;color:#7a5a00}
.aside-note p{margin:0}
@media(max-width:800px){.scope-wrap{grid-template-columns:1fr}}

.pnl-list{display:flex;flex-direction:column;gap:16px;margin:20px 0}
.pnl{background:var(--brand-tint);border-left:5px solid var(--brand);border-radius:10px;padding:18px 22px}
.pnl h3{margin:0 0 6px;color:var(--brand-dark);font-size:20px}
.pnl-rule{font-weight:700;margin:0 0 10px}
.pnl-wr{display:flex;gap:14px;margin:8px 0 12px;flex-wrap:wrap}
.pnl-w,.pnl-r{flex:1;min-width:200px;padding:10px 14px;border-radius:8px;font-weight:700}
.pnl-w{background:#fdecea;border:1px solid #c0392b}
.pnl-r{background:#e6f4ea;border:1px solid var(--ok)}
.pnl-w span,.pnl-r span{display:block;font-size:12px;text-transform:uppercase;letter-spacing:.6px;font-weight:600;margin-bottom:2px}
.pnl p{margin:6px 0;font-size:16px;line-height:1.7}
.pnl ol{margin:6px 0 0;padding-left:22px}
.pnl li{margin:6px 0;line-height:1.7}
.tbl-wrap{overflow-x:auto;margin:14px 0}
.tbl{width:100%;border-collapse:collapse;font-size:15px;line-height:1.5}
.tbl th{background:#f1ebf8;color:#4a2c7a;text-align:left;padding:10px 12px;border:1px solid #ddd3ec}
.tbl td{padding:10px 12px;border:1px solid #e6e0ef;vertical-align:top}
.tbl td:first-child{font-weight:600}
.tbl tr:nth-child(even) td{background:#faf8fd}
