:root {
  color-scheme: light;
  --primary: #2f6fed;
  --primary-dark: #1d4fbf;
  --primary-light: #eaf1ff;
  --success: #1a9c6d;
  --success-bg: #e6f7f0;
  --warn: #c98a02;
  --warn-bg: #fdf3e0;
  --error: #d64545;
  --error-bg: #fbe9e9;
  --surface: #ffffff;
  --bg: #f4f6fb;
  --border: #e1e5ee;
  --text: #1e2430;
  --text-muted: #6b7280;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- Login ----------
   Was a flat two-stop blue gradient. Now a richer multi-tone gradient with
   two soft blurred "aurora" blobs and a faint dot-grid texture, all behind
   the card. #login-screen and #terms-gate-screen intentionally share the
   exact same treatment (see JS.enterApp(), which shows one or the other). */
#login-screen, #terms-gate-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 16px;
  background:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0) 38%),
    radial-gradient(circle at 82% 12%, rgba(147,197,253,0.55) 0%, rgba(147,197,253,0) 45%),
    radial-gradient(circle at 78% 88%, rgba(13,37,99,0.65) 0%, rgba(13,37,99,0) 55%),
    linear-gradient(135deg, #4c8bf5 0%, #2f6fed 38%, #1d4fbf 70%, #122d70 100%);
}
/* Faint dot-grid texture for a bit of depth, sitting behind the card. */
#login-screen::before, #terms-gate-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.16) 1px, transparent 1.5px);
  background-size: 26px 26px;
  opacity: 0.55;
  pointer-events: none;
}
/* Two soft blurred "aurora" blobs, one per corner-ish. */
#login-screen::after, #terms-gate-screen::after {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  top: -140px;
  right: -120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
  filter: blur(30px);
  pointer-events: none;
}
.login-blob-2 {
  position: absolute;
  width: 380px;
  height: 380px;
  left: -110px;
  bottom: -140px;
  border-radius: 50%;
  background: rgba(29,79,191,0.55);
  filter: blur(40px);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--primary-dark);
}
.login-card .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 24px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.field .hint.ok { color: var(--success); }
.field .hint.err { color: var(--error); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: #f0f2f7; }
.btn.danger { background: var(--error); }
.btn.danger:hover { background: #b93636; }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 11px; }
.btn.icon { padding: 6px 8px; }

.login-error {
  background: var(--error-bg);
  color: var(--error);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 14px;
}

/* ---------- Shell ---------- */
#app-shell { display: none; min-height: 100vh; }
#app-shell.active { display: flex; }

.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: #182233;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  /* Pinned to the window, so the menu — and Log Out at its foot — stays in
     view however far down a long page (like the timetable) is scrolled. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 10px;
}
.sidebar .brand h2 { color: #fff; font-size: 17px; margin: 0; }
.sidebar .brand .inst { font-size: 11px; color: #8fa1bd; margin-top: 3px; }
.sidebar .brand h2:hover, #sb-home-link:hover { text-decoration: underline; color: #fff; }
#login-brand-title:hover { text-decoration: underline; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.05); }
.nav-item.active {
  background: rgba(47,111,237,0.18);
  color: #fff;
  border-left-color: var(--primary);
}
.nav-spacer { flex: 1; }
.nav-item.logout { color: #f2a5a5; }
/* Which build of the website this browser is actually running, printed
   under the institution name. Deliberately quiet — it is only looked at
   when something that should be there isn't, and then it answers in one
   glance whether the deploy landed. */
.nav-build {
  font-size: 10px;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 8px;
  cursor: help;
}

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .who { font-size: 12px; color: var(--text-muted); }
.topbar .who b { color: var(--text); }

.content { flex: 1; padding: 22px 26px; overflow-y: auto; }

.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: #182233;
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  max-width: 340px;
  animation: toast-in 0.15s ease-out;
}
.toast.error { background: var(--error); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Cards / grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 14px; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-box .num { font-size: 24px; font-weight: 700; }
.stat-box .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }
.stat-box.primary .num { color: var(--primary); }
.stat-box.success .num { color: var(--success); }
.stat-box.error .num { color: var(--error); }
.stat-box.warn .num { color: var(--warn); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar .filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="text"], .toolbar input[type="date"], .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12px;
}
.chip {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th {
  text-align: left;
  padding: 9px 10px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 50px;
  font-size: 10px;
  font-weight: 700;
}
.badge.role-ADMIN { background: #ecdff9; color: #7b3fb5; }
.badge.role-HOD { background: #dff3ff; color: #1479bd; }
.badge.role-IQA { background: #e0f8ec; color: #1a9c6d; }
.badge.role-TRAINER { background: #f0f1f5; color: #4b5568; }
.badge.role-DEVELOPER { background: #fdeccf; color: #9a5b00; }
.badge.status-present, .badge.status-PRESENT, .badge.status-ON_TIME { background: var(--success-bg); color: var(--success); }
.badge.status-late, .badge.status-LATE { background: var(--warn-bg); color: var(--warn); }
.badge.status-absent, .badge.status-ABSENT { background: var(--error-bg); color: var(--error); }
.badge.status-pending, .badge.status-PENDING, .badge.status-unmarked { background: #eceff3; color: var(--text-muted); }
.badge.status-APPROVED { background: var(--success-bg); color: var(--success); }
.badge.status-REJECTED { background: var(--error-bg); color: var(--error); }

.row-actions { display: flex; gap: 6px; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,20,30,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
}
.modal h2 { font-size: 17px; margin: 0 0 4px; }
.modal .modal-sub { font-size: 12px; color: var(--text-muted); margin: 0 0 16px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.checkbox-field { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.checkbox-field input { margin-top: 3px; }
.checkbox-field .txt { font-size: 12px; }
.checkbox-field .txt b { display: block; font-size: 13px; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row { text-align: center; padding: 30px; color: var(--text-muted); }

/* ---------- Phone layout ----------
 * The sidebar used to be hidden outright below 760px, which left no menu
 * at all on a phone. It's now a drawer: the ☰ button in the top bar slides
 * it in over the page, and tapping a page (or the dimmed area) closes it. */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  padding: 6px 10px;
  margin-right: 10px;
  cursor: pointer;
  color: var(--text);
}
.sidebar-backdrop { display: none; }

@media (max-width: 760px) {
  .menu-toggle { display: inline-block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 60;
    box-shadow: 0 0 30px rgba(0,0,0,.35);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55; }
  .sidebar-backdrop[hidden] { display: none; }
  .nav-item { padding: 14px 18px; font-size: 14px; }
  .content { padding: 14px; }
  .topbar { padding: 10px 12px; position: sticky; top: 0; z-index: 30; }
  .topbar h1 { font-size: 16px; }
  .topbar-right { gap: 6px; }
  .toolbar { gap: 8px; }
  .toolbar .filters { width: 100%; }
  .toolbar .filters > * { flex: 1 1 140px; min-width: 0; }
  .toolbar input[type="text"], .toolbar input[type="date"], .toolbar select, .toolbar .btn { font-size: 13px; padding: 9px 10px; }
  .btn { padding: 9px 12px; }
  .card { padding: 14px; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 8px; }
  .modal { width: 94vw; max-height: 88vh; overflow-y: auto; }
  .rc-btn { width: 38px; height: 36px; }
  .lesson-cards, .rating-grid, .pg-summary { grid-template-columns: 1fr; }
}

/* ---------- Bar chart (Reports) ---------- */
.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.bar-chart-row:last-child { margin-bottom: 0; }
.bar-chart-label {
  width: 170px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-chart-track {
  flex: 1;
  background: var(--bg);
  border-radius: 50px;
  height: 14px;
  overflow: hidden;
}
.bar-chart-fill {
  height: 100%;
  border-radius: 50px;
  background: var(--primary);
  transition: width 0.25s ease-out;
}
.bar-chart-fill.success { background: var(--success); }
.bar-chart-fill.warn { background: var(--warn); }
.bar-chart-fill.error { background: var(--error); }
.bar-chart-value {
  width: 46px;
  flex-shrink: 0;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* The institution-wide total, closing the chart. Set off by a rule and a
   heavier bar so it reads as a different kind of number from the rows above
   it — a summary of them, not another one of them. */
.bar-chart-row.total {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
}
.bar-chart-row.total .bar-chart-label { font-weight: 800; letter-spacing: .02em; }
.bar-chart-row.total .bar-chart-track { height: 18px; }
.bar-chart-row.total .bar-chart-value { font-size: 14px; color: var(--text); }
.bar-chart-note {
  margin-top: 6px;
  margin-left: 180px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
@media (max-width: 760px) {
  .bar-chart-note { margin-left: 0; }
}

/* ---------- Absentee lists (Daily report) ---------- */
.absentee-list { list-style: none; margin: 6px 0 0; padding: 0; }
.absentee-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.absentee-list li:last-child { border-bottom: none; }
.absentee-list .name { font-weight: 600; }
.absentee-list .meta { color: var(--text-muted); }
.dept-report-card .dept-report-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dept-report-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.dept-report-col-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ---------- Timetable: multi-trainer / combined-class inputs, generator, reports ---------- */
.modal.wide { max-width: 640px; }
.field .hint, .hint-block { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.45; }
.hint-block { margin: 0 0 12px; }
.mv-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.mv-row input { flex: 1; min-width: 0; }
.mv-tag { width: 74px; flex-shrink: 0; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.mv-remove {
  width: 32px; height: 34px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--error);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.mv-remove:hover { background: var(--error-bg); }
.mv-add { margin-top: 2px; }
.pill {
  display: inline-block; padding: 2px 8px; margin: 1px 3px 1px 0;
  border-radius: 50px; background: var(--primary-light); color: var(--primary-dark);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.pill.muted { background: #eef0f4; color: var(--text-muted); }
.co-trainer { font-size: 12px; color: var(--text-muted); }
.sub-note { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.table-foot { font-size: 11px; color: var(--text-muted); padding: 10px 10px 0; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.live-indicator .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.notice { border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px; line-height: 1.5; margin-bottom: 14px; }
.notice.info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #cfdcfb; }
.notice.warn { background: var(--warn-bg); color: #6f4b00; border: 1px solid #f0d9a6; }
/* "Nothing is wrong here" — the Unallocated tab's empty state, where an
   empty list is the good outcome rather than a dead end. Built from the same
   success tokens the status badges use, so it follows dark mode without
   needing its own override. */
.notice.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
/* A short, read-only block of exact values — the class-name rewrites a
   merge is about to make. Monospace because the point is comparing two
   strings character by character. */
.code-block { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 0; overflow-x: auto; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; line-height: 1.6; white-space: pre; }
.check-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.check-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 12px; cursor: pointer; font-weight: 500 !important; text-transform: none !important; }
.check-pill span { color: var(--text-muted); font-size: 11px; }
.check-pill input { width: auto !important; margin: 0; }
tr.locked td { background: #f3f7ff; }
tr.row-clash td { background: var(--error-bg); }
.lock-toggle { width: 16px; height: 16px; cursor: pointer; }

.tt-grid { border-collapse: collapse; min-width: 640px; table-layout: fixed; }
.tt-grid th, .tt-grid td { border: 1px solid var(--border); padding: 6px; vertical-align: top; font-size: 11.5px; }
.tt-grid thead th { background: var(--bg); text-align: center; color: var(--text); }
.tt-grid thead th .pt { font-weight: 500; color: var(--text-muted); text-transform: none; font-size: 10.5px; }
.tt-grid th.day { width: 56px; background: var(--bg); color: var(--text); text-align: center; vertical-align: middle; }
.tt-grid tr:hover td { background: transparent; }
.tt-cell { min-width: 96px; }
.tt-cell-entry { background: var(--primary-light); border-radius: 6px; padding: 4px 6px; margin-bottom: 3px; }
.tt-cell-entry:last-child { margin-bottom: 0; }
.tt-cell-entry b { display: block; font-size: 12px; color: var(--text); }
.tt-cell-entry .sub { display: block; font-size: 10.5px; color: var(--text-muted); line-height: 1.35; }
.tt-cell.clash { background: var(--error-bg) !important; }
.tt-cell.clash .tt-cell-entry { background: #f7d2d2; }
.tt-grid-foot { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.tt-grid-foot .clash-note { color: var(--error); font-weight: 600; }

/* ---------- Master timetable (the whole college on one sheet) ----------
   Everyone down the left, the week across the top. Dense on purpose: this
   sheet gets printed and pinned to a staffroom wall, so it is built to
   survive being printed small — a hairline rule on every cell so the eye can
   follow one person's row across five days, and three sizes of type inside a
   cell so unit, class and room separate at a glance without needing labels. */
/* min-width buys roughly 70px a period, which is what a class code and a
   two-word unit name need before they start breaking mid-word. Below that
   the sheet technically fits and is unreadable, so it scrolls sideways on
   screen instead and the browser scales it down for print. */
.tt-master { border-collapse: collapse; width: 100%; table-layout: fixed; min-width: 1680px; }
.tt-master th,
.tt-master td {
  border: 1px solid var(--border); padding: 3px 4px; vertical-align: top;
  /* break-word, not anywhere: a long code with no spaces may break inside
     rather than spill into the next day, but ordinary words still break at
     their spaces instead of being chopped into "AGRON OMY". */
  overflow-wrap: break-word;
  /* Undoes the site-wide `table th { white-space: nowrap }`, which is right
     for a list of short headings and wrong for a grid where every column is
     50px and everything has to wrap. */
  white-space: normal;
}
/* Three stacked header rows can't all stick to the top of the scroller —
   they would pile up on each other. The master sheet is read whole, on
   paper as often as on screen, so its header simply scrolls with it. */
.tt-master thead th { position: static !important; box-shadow: none !important; }
.tt-master thead th { background: var(--bg); color: var(--text); text-align: center; font-size: 11px; }
.tt-master .mg-day { font-size: 13px; font-weight: 700; letter-spacing: .02em; border-bottom-width: 2px; }
.tt-master .mg-time { font-weight: 500; font-size: 9.5px; color: var(--text-muted); line-height: 1.25; text-transform: none; }
.tt-master .mg-num { font-weight: 600; font-size: 10px; color: var(--text-muted); }
.tt-master th.mg-name {
  width: 128px; background: var(--bg); color: var(--text); text-transform: none;
  text-align: left; vertical-align: middle; font-size: 12px; font-weight: 700;
}
.tt-master .mg-name .mg-full {
  display: block; font-size: 9.5px; font-weight: 500; color: var(--text-muted);
  text-transform: none; line-height: 1.25; margin-top: 1px;
}
.tt-master .mg-cell { height: 44px; }
.tt-master tr:hover td { background: transparent; }

/* The key under the sheet: what every class code on it stands for. */
.mg-key {
  display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: baseline;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}
.mg-key-title { font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.mg-key-item b { color: var(--text); }

/* The lunch band: one cell per day spanning every row, so a reader finds the
   middle of the day without reading a single time. */
.tt-master .mg-lunch-head,
.tt-master .mg-lunch { width: 24px; background: var(--bg); padding: 0; text-align: center; }
.tt-master .mg-lunch span {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 10px; font-weight: 700; letter-spacing: .14em;
  color: var(--text-muted); white-space: nowrap;
}

.mg-entry { background: var(--primary-light); border-radius: 4px; padding: 2px 4px; margin-bottom: 2px; line-height: 1.25; }
.mg-entry:last-child { margin-bottom: 0; }
.mg-unit { display: block; font-size: 8.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .02em; }
.mg-mid { display: block; font-size: 11px; color: var(--text); }
.mg-plus { padding: 0 3px; color: var(--text-muted); }
.mg-mid .mg-full { display: block; font-size: 8.5px; font-weight: 500; color: var(--text-muted); text-transform: none; }
.mg-venue { display: block; font-size: 8.5px; color: var(--text-muted); }
.tt-master .mg-cell.clash { background: var(--error-bg); }
.tt-master .mg-cell.clash .mg-entry { background: #f7d2d2; }

/* ---------- Print header and footer (hidden on screen, shown only when printing) ---------- */
.print-header { display: none; }
.print-footer { display: none; }

/* ---------- Print / Save as PDF ---------- */
@media print {
  .sidebar, .topbar, .toast-host, .no-print { display: none !important; }
  /* min-height: 100vh is right on screen and wrong on paper, where vh is
     the SHEET: a report shorter than one page still stretched the shell
     to a full page, pushing the credit line onto a second sheet that
     carried nothing else. Every short report was quietly printing a
     blank back page. */
  #app-shell { display: block !important; min-height: 0 !important; height: auto !important; }
  .main-area { display: block !important; min-height: 0 !important; height: auto !important; }
  .content { padding: 0 !important; overflow: visible !important; }
  body { background: #fff !important; }
  /* A card taller than a sheet CANNOT be kept whole, and asking a browser
     to avoid breaking one anyway makes it overflow and print on top of
     whatever follows — which is exactly what a 66-row register table did.
     Cards break where they must; the small things inside them are what
     stay whole (see the break-inside rules further down). */
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: auto; }
  .stat-box, .dept-report-card, .bar-chart-row, .rf-sign { break-inside: avoid; }
  tr, li { break-inside: avoid; }
  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }

  /* The filter bars are controls, not content — a date picker and a Run
     button mean nothing on paper. */
  .toolbar { display: none !important; }
  .print-header {
    display: flex !important;
    align-items: center;
    gap: 12mm;
    width: 100%;
    margin-bottom: 16px;
    border-bottom: 2px solid #182233;
    padding-bottom: 10px;
  }
  /* Sized against the sheet rather than in pixels, so the crest is a
     letterhead across the top of the page instead of a thumbnail
     floating above the name. */
  .print-header .ph-logo {
    max-height: 22mm;
    max-width: 38mm;
    width: auto;
    margin: 0;
    flex: 0 0 auto;
    object-fit: contain;
  }
  .print-header .ph-text { flex: 1 1 auto; min-width: 0; }
  .print-header .ph-inst { font-size: 19px; font-weight: 700; color: #182233; letter-spacing: .01em; }
  .print-header .ph-report { font-size: 14px; font-weight: 600; margin-top: 3px; }
  .print-header .ph-meta { font-size: 12px; color: #555; margin-top: 2px; }
  /* The credit, once at the end of the document.
     It used to be position: fixed so it repeated on every sheet, with
     body padding meant to keep the last row off it. That padding does
     not work: a fixed element sits at the bottom of each page's content
     area, which is exactly where the rows end too, so on a long report
     table rows printed straight through the credit line. Reserving room
     with a page margin does not fix it either — tested at 20mm, 30mm
     and 40mm, and whether a row lands on the footer just depends on
     where the rows happen to fall, which is not something to ship.
     Printed once at the end, it can never cover a row. */
  .print-footer {
    display: block !important;
    position: static;
    margin-top: 10mm;
    padding: 3mm 0 1mm;
    border-top: 1px solid #999;
    background: #fff;
    font-size: 8.5pt;
    color: #555;
    text-align: center;
    letter-spacing: .02em;
    break-inside: avoid;
  }
  /* Timetable reports: one trainer/class per printed page, grid kept readable in black & white. */
  /* A bar chart whose bars are missing is not a chart — it is a list of
     numbers with a lot of white space. Chrome leaves "Background graphics"
     UNTICKED by default, which drops every background colour, and the bar
     and its track are both background colours: printed with the default
     settings, every bar vanished and only the percentage was left.
     print-color-adjust: exact tells the browser these particular colours
     carry meaning and must be printed whatever that setting says. It is
     applied to the bars alone, deliberately — forcing it everywhere would
     print each card's fill and tint too, and waste ink on decoration that
     carries nothing. */
  .bar-chart-track,
  .bar-chart-fill {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  /* The track needs an edge of its own: on a mono printer or a photocopy
     the fill and the track reduce to similar greys, and without it you
     cannot see where the bar ends. */
  .bar-chart-track { border: 1px solid #b9c0cc; }

  .notice, .live-indicator { display: none !important; }
  .tt-page { break-after: page; break-inside: auto; border: none !important; padding: 0 !important; }
  .tt-page:last-child { break-after: auto; }
  .tt-page .section-title { display: none; }
  .tt-grid { min-width: 0; width: 100%; }
  .tt-grid th, .tt-grid td { border: 1px solid #888 !important; font-size: 9.5px; padding: 4px; }
  .tt-cell-entry { background: none !important; border: 1px solid #bbb; }
  .tt-cell.clash { background: #eee !important; }
  /* THE one that made long tables print on top of what followed.
     .table-wrap is capped at 70vh on screen so a long table scrolls
     inside its card. On paper vh is the PAGE, so any table taller than
     70% of a sheet was clipped to that height: its rows overflowed the
     box, and the next department was laid out immediately after the
     box rather than after the rows. Hence a heading printed across the
     middle of the previous table.
     The sticky header goes for the same reason — there is nothing to
     stick to on a sheet of paper, and a sticky cell inside a fragmented
     table is positioned against a scroll container that no longer
     exists. */
  .table-wrap {
    overflow: visible !important;
    max-height: none !important;
  }
  .table-wrap thead th {
    position: static !important;
    box-shadow: none !important;
  }

  /* The master sheet is one wide table, not one page per person, so it must
     NOT inherit .tt-page's page break — and it wants landscape. The browser
     scales it to the sheet; everything here is about staying legible once it
     has. Colour fills are dropped because this gets photocopied. */
  .tt-master-page { break-after: auto !important; }
  .tt-master { min-width: 0; width: 100%; }
  .tt-master th,
  .tt-master td { border: 1px solid #888 !important; }
  .tt-master .mg-cell { height: auto; }
  .tt-master th.mg-name { width: 92px; font-size: 9.5px; }
  .tt-master .mg-day { font-size: 10.5px; }
  .tt-master .mg-time,
  .tt-master .mg-num { font-size: 7.5px; }
  .mg-entry { background: none !important; padding: 1px 2px; }
  .mg-unit, .mg-venue, .mg-name .mg-full { font-size: 6.5px; }
  .mg-mid { font-size: 8.5px; }
  .mg-key { font-size: 7.5px; gap: 2px 12px; border-top: 1px solid #888; }
  .mg-key-title { font-size: 7px; }
  .tt-master .mg-cell.clash { background: #eee !important; }
  .tt-master .mg-cell.clash .mg-entry { background: none !important; }
}
/* A master sheet is landscape by nature — five days across the page. Scoped
   to the page that holds one, so printing a personal timetable stays
   portrait. */
@page { size: auto; }
.tt-master-page { break-inside: auto; }

/* ---------- Legal pages (terms / privacy / disclaimer) ---------- */
.legal-body {
  background: var(--bg);
}
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  color: var(--text);
  line-height: 1.55;
}
.legal-back {
  display: inline-block;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--primary);
}
.legal-page h1 {
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--primary-dark);
}
.legal-updated {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0 0 24px;
}
.legal-page h2 {
  font-size: 16px;
  margin: 26px 0 8px;
  color: var(--text);
}
.legal-page p, .legal-page li {
  font-size: 14px;
  color: var(--text);
}
.legal-page ul {
  padding-left: 20px;
  margin: 8px 0;
}
.legal-footer-links {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Login-screen footer (Terms / Privacy / Disclaimer) ---------- */
.login-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}
.login-footer a {
  color: #fff;
  text-decoration: underline;
}
.login-footer .login-copyright {
  margin-top: 6px;
  color: rgba(255,255,255,0.65);
}

/* "New institution? Register it here" / "Back to Sign In" link under the
   login/register cards — see #login-screen / #register-screen in index.html. */
.login-alt-link {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 16px 0 0;
}
.login-alt-link a { font-weight: 600; }

/* Success banner shown on the register form after a request is submitted
   (and especially after an instant auto-approval, which includes the new
   institution code) — same shape as .login-error but green. */
.login-success {
  background: var(--success-bg);
  color: var(--success);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.login-success b { font-size: 15px; }

/* ---------- Login: "Saved codes" picker for the institution code ---------- */
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; min-width: 0; }
.input-with-btn .btn { white-space: nowrap; padding-left: 12px; padding-right: 12px; font-size: 12px; }
.saved-codes-panel {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(20, 30, 60, 0.12);
  max-height: 240px;
  overflow-y: auto;
}
.saved-code-row { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.saved-code-row:last-child { border-bottom: none; }
.saved-code-row:hover, .saved-code-row:focus { background: var(--primary-light); outline: none; }
.saved-code-main { flex: 1; min-width: 0; }
.saved-code-main b { display: block; font-size: 13px; color: var(--text); }
.saved-code-main span { display: block; font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-code-remove { border: none; background: none; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.saved-code-remove:hover { background: var(--error-bg); color: var(--error); }
.saved-code-empty { padding: 12px; font-size: 12px; color: var(--text-muted); line-height: 1.45; }

/* ---------- Top bar: always-visible Log Out ---------- */
.topbar { position: sticky; top: 0; z-index: 50; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-logout { color: var(--error) !important; border-color: #f1c9c9 !important; }
.topbar-logout:hover { background: var(--error-bg) !important; }
.nav-item.logout { position: sticky; bottom: 0; background: #182233; border-top: 1px solid rgba(255,255,255,0.08); }
@media (max-width: 760px) {
  .topbar-right .who { display: none; }
}
/* Friendly (non-error) notices on the sign-in card, e.g. "You have signed out." */
.login-error.info { background: var(--primary-light); color: var(--primary-dark); border-color: #cfdcfb; }

/* ---------- Timetable Excel import ---------- */
.import-steps .steps { margin: 0; padding-left: 20px; }
.import-steps .steps li { margin-bottom: 14px; line-height: 1.6; }
.import-steps .steps li .btn { margin-left: 8px; vertical-align: middle; }
.file-pick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.file-pick input[type="file"] { font-size: 12px; }
.replace-warning { font-size: 13.5px; border-width: 2px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Trainer: My Schedule / Roll Call / Ratings ---------- */
.lesson-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lesson-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid #94a3b8; border-radius: var(--radius); padding: 14px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.lesson-card:hover, .lesson-card:focus { box-shadow: 0 6px 18px rgba(30,36,48,.10); transform: translateY(-1px); outline: none; }
.lesson-card.live { border-left-color: var(--success); background: linear-gradient(0deg, var(--surface), var(--success-bg)); }
.lesson-card.upcoming { border-left-color: var(--primary); }
.lesson-card.past { opacity: .85; }
.lc-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.lesson-card.live .lc-state { color: var(--success); }
.lc-unit { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin: 6px 0; }
.lc-meta { margin-bottom: 4px; }
.lc-foot { margin-top: 8px; display: flex; gap: 6px; align-items: center; }
.action-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.action-row { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; font: inherit; color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.action-row:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.action-row span { font-size: 12px; color: var(--text-muted); }
.action-row:disabled { cursor: not-allowed; opacity: .6; }
.big-code { font-size: 44px; font-weight: 800; letter-spacing: 8px; text-align: center; color: var(--primary-dark); margin: 14px 0; }
.rc-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.rc-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.rc-toggle { display: inline-flex; gap: 4px; }
.rc-btn { width: 32px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; cursor: pointer; color: var(--text-muted); }
.rc-btn:disabled { cursor: not-allowed; opacity: .55; }
.rc-btn.on.p { background: var(--success); color: #fff; border-color: var(--success); }
.rc-btn.on.l { background: var(--warn); color: #fff; border-color: var(--warn); }
.rc-btn.on.a { background: var(--error); color: #fff; border-color: var(--error); }
.rc-btn.on.e { background: #2563eb; color: #fff; border-color: #2563eb; }
.rating-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.rating-top { display: flex; justify-content: space-between; gap: 8px; }
.stars { color: #f5a524; letter-spacing: 1px; }
.stars .off { color: #d7dbe3; }
.rating-comments { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.rating-comment { font-size: 12.5px; background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.star-pick { display: inline-flex; gap: 4px; }
.star-pick button { font-size: 28px; line-height: 1; background: none; border: 0; cursor: pointer; color: #d7dbe3; padding: 0 2px; }
.star-pick button.on { color: #f5a524; }

/* ---------- Trainee portal ---------- */
#trainee-portal { min-height: 100vh; }
.tp-login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 82% 12%, rgba(147,197,253,0.55) 0%, rgba(147,197,253,0) 45%), linear-gradient(135deg, #4c8bf5 0%, #2f6fed 38%, #1d4fbf 70%, #122d70 100%); }
.tp-shell { min-height: 100vh; background: var(--bg); }
.tp-top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; background: #1d2536; color: #fff; }
.tp-top .sub-note { color: rgba(255,255,255,.7); }
.tp-who { display: flex; gap: 10px; align-items: center; font-size: 12.5px; flex-wrap: wrap; }
.tp-tabs { display: flex; gap: 6px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; position: sticky; top: 52px; z-index: 4; }
.tp-tab { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.tp-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tp-body { max-width: 1100px; margin: 0 auto; padding: 18px 20px 40px; }
.tp-checkin h3 { margin: 0 0 4px; }
.tp-ci-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tp-ci-row input { font-size: 22px; letter-spacing: 6px; width: 220px; text-align: center; }
@media (max-width: 600px) {
  .tp-top { padding: 10px 14px; }
  .tp-tabs { padding: 8px 14px; top: 84px; }
  .tp-body { padding: 14px; }
}
.rating-grid > .card, .lesson-cards > .card { margin: 0; }
.cls-card-head { display: flex; justify-content: space-between; align-items: flex-start; cursor: pointer; border-radius: 8px; margin: -4px; padding: 4px; }
.cls-card-head:hover, .cls-card-head:focus { background: var(--primary-light); outline: none; }
.cls-trainees { margin: 6px 0 10px; border-top: 1px dashed var(--border); padding-top: 4px; }
.pg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pg-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 12px 0; }
.pg-summary .card { margin: 0; }
.pg-big { font-size: 24px; font-weight: 800; color: var(--primary-dark); }
.pg-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .pg-form { grid-template-columns: 1fr; } }
.pg-dept { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; }
.pg-dept > summary { cursor: pointer; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; list-style: none; }
.pg-dept > summary::-webkit-details-marker { display: none; }
.pg-dept > summary::before { content: '▸'; color: var(--primary); margin-right: 8px; transition: transform .15s; }
.pg-dept[open] > summary::before { transform: rotate(90deg); }
.pg-dept-name { font-weight: 700; font-size: 15px; color: var(--primary-dark); flex: 1; }
.pg-dept[open] > summary { border-bottom: 1px solid var(--border); }
.pg-class { padding: 12px 16px 4px; }
.pg-class + .pg-class { border-top: 1px dashed var(--border); }
.pg-class-head { margin-bottom: 8px; font-size: 13.5px; }
.pg-class .lesson-cards { margin-bottom: 12px; }
.topbar-live.paused { background: var(--warn-bg); border-color: #f0d9a6; color: #6f4b00; }
@media (max-width: 700px) { .topbar-live { display: none; } }


/* ================= Dark mode =================
 * Set by the ☾ button in the top bar and remembered per browser
 * (data-theme="dark" on <html>). Everything on the site is drawn from the
 * variables at the top of this file, so only the values change. */
html[data-theme="dark"] {
  color-scheme: dark;
  --primary: #6f9bff;
  --primary-dark: #a8c3ff;
  --primary-light: #1b2740;
  --success: #37c48d;
  --success-bg: #123026;
  --warn: #e0a83a;
  --warn-bg: #33270c;
  --error: #f07070;
  --error-bg: #3a1a1a;
  --surface: #151b26;
  --bg: #0e131c;
  --border: #29313f;
  --text: #e6eaf2;
  --text-muted: #9aa4b6;
}
html[data-theme="dark"] .sidebar { background: #0b1017; }
html[data-theme="dark"] .tp-top { background: #0b1017; }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea {
  background: #0f1622; color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] .btn.secondary { background: #1b2331; color: var(--text); }
html[data-theme="dark"] .rating-comment, html[data-theme="dark"] .badge { background: #1b2331; }
html[data-theme="dark"] .modal { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .toast { background: #0b1017; }
html[data-theme="dark"] .stars .off { color: #3a4455; }
html[data-theme="dark"] img.logo-mark { filter: brightness(1.1); }

/* ================= Reading and navigation helpers ================= */
/* Scroll progress bar across the very top of the page. */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: var(--primary); z-index: 200; transition: width .1s linear;
}
/* "Skip to content" — invisible until a keyboard user tabs to it. */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 300;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
/* Back to top */
.to-top {
  position: fixed; right: 18px; bottom: 18px; z-index: 120;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 18px; cursor: pointer; display: none;
  box-shadow: 0 4px 14px rgba(15,23,42,.18);
}
.to-top.show { display: block; }
/* Sticky table headers inside a scrolling card */
.table-wrap { max-height: 70vh; }
.table-wrap thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}
tbody tr:hover { background: var(--primary-light); }
.card:hover { box-shadow: 0 2px 10px rgba(15,23,42,.06); }
.btn, .nav-item, .chip, .rc-btn, .tp-tab { transition: background .15s, color .15s, border-color .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
/* Password show/hide */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 62px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; font-size: 11px; font-weight: 700;
  color: var(--primary); cursor: pointer; padding: 6px;
}
/* Copy button */
.copy-btn { font-size: 11px; }
/* Global search results */
.gs-wrap { position: relative; }
.gs-results {
  position: absolute; right: 0; top: 110%; width: min(360px, 86vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(15,23,42,.18); z-index: 140; max-height: 60vh; overflow-y: auto;
}
.gs-results .gs-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 13px; }
.gs-results .gs-item:last-child { border-bottom: 0; }
.gs-results .gs-item:hover { background: var(--primary-light); }
.gs-results .gs-group { padding: 8px 12px; font-size: 10px; font-weight: 800; letter-spacing: .06em; color: var(--text-muted); background: var(--bg); }
.topbar-search { width: 190px; }
@media (max-width: 900px) { .topbar-search { width: 130px; } }
@media (max-width: 700px) { .topbar-search { display: none; } }
.updated-stamp { font-size: 11px; color: var(--text-muted); }

/* ---------- Attendance location check (Institution Settings) ----------
 * The address panel is the first thing the eye should land on, because
 * reading it off and pressing Add is the entire setup. It turns green
 * once the address you are on is allowed, so "is this set up right?" is
 * answered at a glance instead of by reading the list.
 * Uses the existing --warn / --success tokens so it follows the theme
 * into dark mode rather than carrying its own colours.
 */
.al-you {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius);
  background: var(--bg);
}
.al-you.ok { border-left-color: var(--success); }
.al-warn {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  border-left-width: 4px;
  background: var(--warn-bg);
  font-size: 13px;
  line-height: 1.5;
}
.al-warn b { display: block; margin-bottom: 2px; }
@media (max-width: 560px) {
  .al-you { flex-direction: column; align-items: flex-start; }
}

/* The scope checkboxes sit outside .field on purpose: .field input has
   width:100%, which stretches a checkbox across the card and shoves its
   label to the far edge, and .field label upper-cases sentence text. */
.al-legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.al-scopes { display: flex; flex-direction: column; gap: 8px; }
.al-scope-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
}
.al-scope-row input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin: 2px 0 0 0;
  flex: 0 0 auto;
}
.al-sub { font-size: 11px; color: var(--text-muted); }

/* ---------- Unit marks: written/oral and practical evidence ----------
 * The two sides are tinted so a trainer reading across a wide row can
 * see at a glance which half they are in — the same split the printed
 * assessment sheet uses, which is what people are used to.
 */
.ev-wrap { margin-top: 10px; }
table.ev-grid { width: 100%; border-collapse: collapse; }
table.ev-grid th, table.ev-grid td {
  border: 1px solid var(--border);
  padding: 6px 4px;
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
}
th.ev-side { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
th.ev-theory, td.ev-theory { background: rgba(201, 138, 2, 0.10); }
th.ev-prac, td.ev-prac { background: rgba(26, 156, 109, 0.10); }
.ev-avg { font-weight: 700; background: var(--bg); }
table.ev-grid input.ev-in {
  width: 100%;
  min-width: 58px;
  text-align: center;
  padding: 6px 4px;
  font-size: 13px;
}
.ev-total { margin-top: 12px; font-size: 14px; }
.ev-note { color: var(--text-muted); font-size: 11px; margin-left: 6px; }
@media (max-width: 640px) {
  table.ev-grid input.ev-in { min-width: 46px; font-size: 12px; }
  table.ev-grid th, table.ev-grid td { padding: 4px 2px; font-size: 11px; }
}

/* ---------- Trainee report form / transcript / class marksheet -------
 * These are documents, not pages. They are sized and ruled for A4 and
 * carry their own letterhead and signature block, so what is on screen
 * is a preview of what leaves the printer.
 */
.report-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.rf-bio { width: 100%; border-collapse: collapse; margin: 14px 0 10px; }
.rf-bio td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  font-size: 13px;
  vertical-align: top;
}
.rf-label {
  display: block;
  font-size: 10px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
table.rf-marks { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
table.rf-marks th, table.rf-marks td {
  border: 1px solid var(--border);
  padding: 5px 6px;
  text-align: center;
  font-size: 12px;
}
table.rf-marks th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; }
table.rf-marks td.rf-unit, table.rf-marks th.rf-unit { text-align: left; white-space: normal; }
.rf-total { background: var(--bg); }
.rf-blank { color: var(--text-muted); }
tr.rf-provisional { background: var(--warn-bg); }
.rf-flag { font-size: 10px; color: var(--warn); white-space: nowrap; }
.rf-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 12px;
}
.rf-summary b { font-size: 16px; }
.rf-remarks { font-size: 12.5px; margin-bottom: 12px; }
.rf-remarks ul { margin: 4px 0 0; padding-left: 18px; }
.rf-warning {
  font-size: 12px;
  border-left: 4px solid var(--warn);
  background: var(--warn-bg);
  padding: 8px 10px;
  border-radius: 6px;
}
.rf-signs { display: flex; gap: 28px; margin-top: 26px; flex-wrap: wrap; }
.rf-sign { flex: 1 1 160px; }
.rf-sign-line { border-bottom: 1px solid var(--text); height: 26px; }
.rf-date { font-size: 10px; color: var(--text-muted); }
.rf-foot {
  margin-top: 16px;
  font-size: 10.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 6px;
}
/* The marksheet gets one column per unit, so unit names stand upright. */
.rf-sheet th.rf-vert { height: 110px; vertical-align: bottom; padding: 4px 2px; }
.rf-sheet th.rf-vert span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  font-size: 10px;
}

/* ---------- Institution logo ---------- */
.sb-logo { margin: 6px 0 4px; }
.sb-logo-img { max-width: 108px; max-height: 54px; object-fit: contain; }
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo-img { max-width: 140px; max-height: 70px; object-fit: contain; }
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.logo-preview {
  min-width: 150px;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 8px;
}
.logo-preview-img { max-width: 200px; max-height: 70px; object-fit: contain; }
.logo-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ph-logo { max-height: 56px; max-width: 170px; object-fit: contain; display: block; margin: 0 auto 6px; }

@media print {
  .report-doc {
    border: none;
    padding: 0;
    margin: 0 0 12mm;
    /* One trainee per sheet — a report form handed over should not have
       the next trainee's marks on the back of it. */
    page-break-after: always;
    break-after: page;
  }
  .report-doc:last-child { page-break-after: auto; break-after: auto; }
  table.rf-marks { page-break-inside: avoid; }
  .rf-signs { page-break-inside: avoid; }
}

/* ---------- Configurable assessments (migration_v33.sql) -------------
 * The marks grid no longer has a fixed number of columns, so anything
 * that assumed three a side is sized by content here instead.
 */

/* "/30" after a column heading, where an assessment isn't out of 100. */
.ev-max { font-weight: 400; opacity: .7; font-size: .85em; }

/* The key under a report table: what the abbreviated headings mean and
   how the unit mark was arrived at. Small, because it is a footnote on
   a document, not a paragraph. */
.rf-key {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.rf-weight { font-size: 10px; color: var(--text-muted); font-weight: 400; }

/* ---- The Assessments editor in Institution Settings ---- */
.at-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
@media (max-width: 820px) { .at-sides { grid-template-columns: 1fr; } }

.at-side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.at-side-head .badge { font-size: 11px; }

table.at-table { width: 100%; border-collapse: collapse; }
table.at-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  vertical-align: middle;
  font-size: 13px;
}
table.at-table tr:last-child td { border-bottom: none; }
td.at-name { text-align: left; }
td.at-actions { text-align: right; white-space: nowrap; width: 1%; }
td.at-w { white-space: nowrap; }
td.at-w .sub-note { display: inline; margin-left: 4px; }

/* A module folds away: a college has dozens of units and an Admin is
   usually here to change one of them. */
.at-module, .at-hidden {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-top: 10px;
}
.at-module > summary, .at-hidden > summary { cursor: pointer; padding: 4px 0; }
.at-module-bulk {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: 12px;
}
.at-module-bulk label { font-weight: 600; }

@media print {
  /* The key prints with the document — it is how a parent reads the
     abbreviated column headings. */
  .rf-key { font-size: 8.5px; }
}

/* ---- Entering marks: one labelled box per assessment ----
 * These used to be cells in a single wide table row, which stopped
 * fitting the dialog once a college had more than four assessments on
 * a side. Boxes that wrap hold any number and stack cleanly on a
 * phone, which is where most marks get typed.
 */
.ev-block { margin-top: 12px; }
.ev-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.ev-block-avg { font-weight: 600; text-transform: none; letter-spacing: 0; }
.ev-block-avg b { font-size: 14px; }
.ev-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}
.ev-field { display: flex; flex-direction: column; gap: 3px; }
.ev-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ev-fields input.ev-in {
  width: 100%;
  text-align: center;
  padding: 7px 4px;
  font-size: 14px;
}
@media (max-width: 480px) {
  .ev-fields { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
}

/* ---------- Registers not taken (daily report) ----------
 * Sits above the charts because it is the part of the report somebody
 * has to act on the same evening. The two states are coloured apart:
 * a class with no register at all is a different conversation from one
 * the trainer started and was pulled away from.
 */
.mr-card { border-left: 3px solid var(--danger, #c0392b); }

.mr-trainers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}
.mr-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12px;
  white-space: nowrap;
}
.mr-chip b {
  background: var(--danger, #c0392b);
  color: #fff;
  border-radius: 999px;
  min-width: 17px;
  text-align: center;
  padding: 0 5px;
  font-size: 11px;
}

tr.mr-none td { background: rgba(192, 57, 43, 0.06); }
tr.mr-partial td { background: rgba(201, 138, 2, 0.07); }

/* ---- Grouped by department ---- */
.mr-dept { margin-top: 14px; }
.mr-dept:first-of-type { margin-top: 10px; }
.mr-dept-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 2px;
}
.mr-dept-name {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--primary-dark);
}
.mr-dept-count { font-size: 11.5px; color: var(--text-muted); }

@media print {
  /* Keep a department's heading with at least the start of its table —
     a heading alone at the foot of a sheet is worse than a clean break.
     The block itself is allowed to break, because one department can
     easily run past a page and forcing it whole is what made the old
     version print on top of the charts. */
  .mr-dept { break-inside: auto; }
  .mr-dept-head { break-after: avoid; break-inside: avoid; }
  .mr-chip { border: 1px solid #999; }
  .mr-table { font-size: 9.5pt; }
  .mr-table th, .mr-table td { padding: 3px 5px; }
  /* Photocopies lose the tint, so the status column has to carry it. */
  tr.mr-none td, tr.mr-partial td { background: none !important; }
  .mr-table .badge { border: 1px solid #777; background: none !important; color: #000 !important; }
}

/* ---- "Not marked" is not the same as "nobody was absent" ----
 * Amber rather than green or red: an unmarked register is neither good
 * news nor bad news, it is missing information, and it should not be
 * mistaken for either at a glance.
 */
.dr-pending {
  font-size: 12px;
  color: var(--warn-text, #6f4b00);
  background: var(--warn-bg, #fdf4e0);
  border: 1px solid #f0d9a6;
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 6px;
}
.dr-pending-all { margin-top: 0; font-weight: 600; }

.badge.dr-badge { background: var(--primary-light); color: var(--primary-dark); }
.badge.dr-badge-pending {
  background: var(--warn-bg, #fdf4e0);
  color: var(--warn-text, #6f4b00);
  border: 1px solid #f0d9a6;
}

@media print {
  /* Same reasoning as the bars: this panel's colour is the signal that
     the figure beside it is missing rather than zero. */
  .dr-pending, .badge.dr-badge-pending {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* ---------- General Class Register (per unit, per class) ----------
 * A copy of the college's printed form. Ruled rather than styled: this
 * is filed beside hand-written ones and signed, so it should look like
 * the same document, not like a web page that happened to be printed.
 */
.cr-doc { font-size: 12px; }

.cr-head { display: flex; align-items: flex-start; gap: 14px; }
.cr-logo {
  width: 22mm; height: 22mm;
  object-fit: contain;
  flex: 0 0 auto;
}
.cr-head-text { flex: 1 1 auto; min-width: 0; }
.cr-inst {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--primary-dark);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.cr-fields { width: 100%; border-collapse: collapse; }
.cr-fields td { padding: 3px 4px; font-size: 11.5px; vertical-align: bottom; }
.cr-fields .cr-lbl { white-space: nowrap; font-weight: 600; width: 1%; letter-spacing: .02em; }
/* The underline is the point: an empty one is a line to write on, a
   filled one is the same line with the answer already on it. */
.cr-rule {
  display: block;
  border-bottom: 1px solid var(--text);
  min-height: 15px;
  padding: 0 4px 1px;
  font-weight: 600;
}

.cr-title {
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .03em;
  margin-top: 10px;
}
.cr-filter {
  text-align: center;
  font-style: italic;
  font-size: 11px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

table.cr-table { width: 100%; border-collapse: collapse; table-layout: auto; }
table.cr-table th,
table.cr-table td {
  border: 1px solid #8a8a8a;
  padding: 3px 4px;
  font-size: 11px;
  text-align: center;
}
table.cr-table th { font-weight: 700; background: var(--bg); }
/* The app's screen tables drop the last row's bottom border on purpose —
   a list reads better without a rule under the final item. A ruled form
   is the opposite: the box has to close, or the last row reads as the
   page having run out rather than the table having ended. This is a
   form, so the rule goes back. */
table.cr-table tr:last-child td,
table.cr-table tr:last-child th { border-bottom: 1px solid #8a8a8a; }
.cr-table .cr-no { width: 64px; white-space: nowrap; }
.cr-table .cr-name { text-align: left; white-space: nowrap; }
.cr-table .cr-tot { width: 54px; }
.cr-table th.cr-wk { font-size: 11px; letter-spacing: .04em; }
.cr-wk-date { display: block; font-weight: 400; font-size: 9px; color: var(--text-muted); }
.cr-table th.cr-day { font-size: 9.5px; font-weight: 600; padding: 2px 1px; min-width: 17px; }
.cr-table th.cr-day.cr-future { color: var(--text-muted); font-weight: 400; }
/* A session nobody registered is marked in the heading, so an empty
   column reads as "not taken" rather than "everyone was away". */
.cr-table th.cr-day.cr-unreg::after { content: "*"; color: var(--warn); }

.cr-mark { font-weight: 700; padding: 3px 1px; }
.cr-mark.cr-p { color: var(--success); }
.cr-mark.cr-l { color: var(--warn); }
.cr-mark.cr-a { color: var(--error); }
.cr-mark.cr-e { color: var(--text-muted); }
.cr-mark.cr-none { background: repeating-linear-gradient(135deg, transparent, transparent 3px, rgba(0,0,0,.05) 3px, rgba(0,0,0,.05) 4px); }
.cr-pct { font-weight: 700; }

.cr-table tr.cr-comment td {
  text-align: left;
  font-weight: 700;
  height: 34px;
  font-size: 11.5px;
}

/* Names the register that the signatures below belong to, because on a
   class big enough to need a second sheet they are all that sheet has. */
.cr-signcap {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.cr-key {
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.6;
  color: var(--text-muted);
}
.cr-key .cr-warn { color: var(--error); }

@media print {
  /* The marks are the document. They must not depend on whether the
     person printing ticked "Background graphics". */
  .cr-mark, .cr-table th, .cr-table th.cr-day.cr-unreg::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .cr-doc { font-size: 10.5px; }
  table.cr-table th, table.cr-table td { padding: 2px 3px; font-size: 9.5pt; }
  .cr-table th.cr-day { font-size: 8pt; }
  /* A register is read across the page — the columns are the point. */
  .cr-doc { break-inside: auto; }
  .cr-head, .cr-title, .cr-filter { break-after: avoid; }
  /* .report-doc forces a page break after itself so that each trainee's
     report form gets its own sheet. A register is one document, not a
     stack of them, and inheriting that rule cost a blank second page
     with nothing on it but the credit line. */
  .cr-doc { break-after: auto !important; page-break-after: auto !important; }

  /* A register with a long roster filled the sheet to within a few
     points, and the credit line underneath took a whole page of its own
     — three such pages in one department run. break-before: avoid and
     break-after: avoid were both tried on it and Chrome honoured
     neither; the only thing that works is for the tail to need less
     room. The signatures keep their full writing height: it is the
     slack around them that goes. */
  .cr-doc .rf-signs { margin-top: 8px; }
  .cr-doc .rf-foot { margin-top: 6px; padding-top: 3px; font-size: 7.5pt; }
  /* The caption, the signatures it names and the credit line are one
     block and move as one. Left as siblings, the credit line alone
     spilled onto a sheet of its own twice in a 47-page department run.
     The block is about 25mm, so it always fits wherever it lands. */
  .cr-tail { break-inside: avoid; page-break-inside: avoid; }
}

/* A lesson still to come: left plain. Only a lesson that was HELD and
   never registered gets the hatch, so the shading means one thing. */
.cr-mark.cr-later { background: none; }

/* The class heading in a bulk run. A department's registers are read
   class by class, so each class announces itself rather than the sheets
   running together and leaving the reader to spot where one class ends. */
.cr-class-divider {
  margin: 18px 0 10px;
  padding: 6px 10px;
  background: var(--bg);
  border-left: 4px solid var(--primary-dark);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .03em;
}

@media print {
  /* One register per sheet in a bulk run. The single-register case has
     nothing to break against, so this costs it nothing. */
  .cr-doc:not(.ca-doc) + .cr-doc:not(.ca-doc) { break-before: page; page-break-before: always; }
  .cr-class-divider {
    break-before: page; page-break-before: always; break-after: avoid;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    font-size: 12pt;
  }
  /* The first divider in the run has nothing above it worth a blank
     sheet of its own. */
  #ur-out > .cr-class-divider:first-child { break-before: auto; page-break-before: auto; }
}

/* ---------- Trainee Class Attendance Analysis ----------
 * The college's two-page form. It reuses the register's rules and
 * ruled-line conventions on purpose: the two sheets are filed together
 * and should read as one pair of documents.
 */
.ca-doc { font-size: 12px; }
.ca-doc .cr-title { margin-top: 2px; }
.ca-fields { margin-top: 10px; }
.ca-fields .cr-lbl { font-size: 10.5px; }
/* A date that wraps is a date that gets misread. */
.ca-fields tr.ca-when .cr-rule { white-space: nowrap; }

.ca-section {
  margin: 14px 0 6px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--text);
  padding-bottom: 3px;
}

table.ca-grid { table-layout: auto; }
.ca-grid .ca-unit { text-align: left; white-space: normal; min-width: 90px; }
.ca-grid th.ca-sub { font-size: 8.5px; font-weight: 600; line-height: 1.15; padding: 2px 1px; }
.ca-num { width: 34px; font-variant-numeric: tabular-nums; }
.ca-num.ca-rowtot { font-weight: 700; }
/* Expected is the denominator of every percentage on the sheet, so it is
   set apart from the two recorded counts rather than sitting in the row
   as though it were a third tally. */
.ca-exp { width: 46px; background: rgba(0, 0, 0, .035); }
.ca-grid th.ca-exp { background: var(--bg); }
/* A week in which a session was held and never registered. Both numbers
   in the pair are zero because nothing was marked, and without the
   shading that is indistinguishable from a week nobody attended. */
.ca-cell-unreg {
  background: repeating-linear-gradient(135deg, transparent, transparent 3px, rgba(0,0,0,.06) 3px, rgba(0,0,0,.06) 4px);
}
.ca-grid tr.ca-total-row td { font-weight: 700; background: var(--bg); }

/* The Met / Not Met box. Drawn, not typed: a ballot character depends on
   a font the printer may not have, and a blank square where the tick
   should be is the worst possible failure on a compliance form. */
.ca-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 4px;
  font-size: 11.5px;
}
.ca-status-lbl { font-weight: 700; letter-spacing: .03em; margin-right: 4px; }
.ca-box {
  display: inline-block;
  width: 13px; height: 13px;
  border: 1.5px solid var(--text);
  position: relative;
  flex: 0 0 auto;
}
.ca-box-on::after {
  content: "";
  position: absolute;
  left: 3px; top: -1px;
  width: 4px; height: 9px;
  border: solid var(--text);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.ca-box-lbl { font-weight: 600; margin-right: 14px; }
.ca-status-note { color: var(--text-muted); font-style: italic; }

.ca-irreg .ca-sn { width: 62px; }
.ca-irreg .ca-tname { text-align: left; white-space: nowrap; }
.ca-irreg .ca-adm { width: 90px; }
.ca-irreg .ca-remark { text-align: left; }
.ca-irreg .ca-action { width: 30%; }
.ca-irreg tr td { height: 22px; }
/* Blank rows exist to be written on, so they are ruled the same as the
   filled ones and given the same height. */
.ca-irreg tr.ca-blank td { color: var(--text-muted); }

.ca-ruled { margin-bottom: 4px; }
.ca-ruled-line {
  border-bottom: 1px solid #9a9a9a;
  height: 20px;
}
.ca-prepared { margin-top: 16px; }

/* What a bulk run could not produce. It prints: a pack that silently
   drops four classes is a pack nobody can check. */
.ca-skipped { font-size: 11.5px; line-height: 1.6; }
.ca-skipped ul { margin: 6px 0 0; padding-left: 20px; }
.ca-skipped li { margin-bottom: 2px; }

@media print {
  .ca-doc { font-size: 10.5px; }
  .ca-doc .ca-section { font-size: 10.5pt; }
  table.ca-grid th, table.ca-grid td { padding: 2px 3px; font-size: 9pt; }
  .ca-grid th.ca-sub { font-size: 7pt; }
  .ca-irreg th, .ca-irreg td { font-size: 9.5pt; }
  /* The shading and the tick are the findings. They must survive a
     printer with "Background graphics" left off, which is the default. */
  .ca-cell-unreg, .ca-box, .ca-box-on::after, .ca-grid tr.ca-total-row td, .ca-grid th, .ca-exp {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  /* Two sheets, one document: the break between them is deliberate, and
     neither half may break after itself and leave a third blank page. */
  .ca-doc { break-inside: auto; break-after: auto !important; page-break-after: auto !important; }
  .ca-page2 { break-before: page; page-break-before: always; }
  /* A department run is a stack of two-sheet forms. The sheet after a
     second page is the next class's first page, so it starts fresh —
     otherwise class two's grid prints under class one's signature. */
  .ca-page2 + .ca-doc { break-before: page; page-break-before: always; }
  .ca-skipped { break-before: page; page-break-before: always; }
  .ca-section { break-after: avoid; }
  /* The written half — narrative, recommendations, signature — is one
     thing and moves as one. Under a short irregular list it sits on the
     same sheet; under a long one it takes the next sheet whole rather
     than stranding the signature away from what it signs off.
     It is roughly half a page, so keeping it together can never make it
     taller than the sheet it lands on. */
  .ca-writing { break-inside: avoid; page-break-inside: avoid; }
  .ca-prepared { break-before: avoid; page-break-before: avoid; break-inside: avoid; }
  /* 6mm, not 7: at 7 the second sheet ended 13pt short of the bottom and
     pushed the site credit line onto a third page with nothing else on
     it. Fourteen writing lines at 6mm are still comfortable to write on
     by hand, and they leave the footer room to land where it belongs. */
  .ca-ruled-line { height: 6mm; }
  .ca-prepared { margin-top: 10px; }
  /* Landscape paper is 85mm shorter. Everything on the second sheet that
     exists to be written on gives some of that back, so the signature
     block still lands on the same page as what it signs off. */
  .ca-wide .ca-ruled-line { height: 5.5mm; }
  .ca-wide .ca-section { margin: 8px 0 4px; }
  .ca-wide .ca-irreg tr td { height: 18px; }
  .ca-wide .ca-prepared { margin-top: 6px; }
}

/* ---------- Missed Registers (completing a register after the fact) ----------
 * Styled to feel deliberately heavier than the Roll Call screen. Writing a
 * register weeks late is a more serious act than taking one in the room,
 * and the screen should not pretend otherwise.
 */
.bf-summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bf-stat {
  flex: 0 0 auto; min-width: 118px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px; text-align: center;
}
.bf-stat-n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.bf-stat-l { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.bf-stat-warn { border-color: var(--warn); }
.bf-stat-warn .bf-stat-n { color: var(--warn); }
.bf-stat-ok .bf-stat-n { color: var(--success); }

.bf-table td, .bf-table th { vertical-align: middle; }
.bf-table .bf-date { white-space: nowrap; font-weight: 600; }
/* A register more than a month old is the one most likely to be filled in
   from imagination rather than memory. It is marked, not blocked. */
.bf-table .bf-old { color: var(--warn); font-weight: 700; }
.bf-table tr.bf-open { background: var(--bg); }

.bf-marker { border: 2px solid var(--warn); }
.bf-marker-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }

/* The warning is part of the control, not decoration around it: it is the
   only thing on screen that says what the trainer is about to assert. */
.bf-warn {
  background: #fff8e6;
  border: 1px solid var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) {
  .bf-warn { background: rgba(245, 165, 36, .12); }
}

/* An unmarked trainee is visibly unfinished, so a half-done register
   cannot be mistaken for a complete one at a glance. */
.bf-unset td { background: rgba(0, 0, 0, .03); }
.bf-unset td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

.bf-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 14px; flex-wrap: wrap;
}

/* A register column that was completed after the lesson. Distinct from
   cr-unreg (never taken at all): this one HAS marks, they are simply
   not contemporaneous, and the dagger says so without crowding the
   grid. Kept legible in black and white, like the rest of the form. */
.cr-table th.cr-day.cr-late::after { content: "\2020"; color: var(--text-muted); }
@media print {
  .cr-table th.cr-day.cr-late::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
