/* ============================================================================
   Two selectable visual themes, same markup/behavior throughout:
   - "controlcenter" (default) — matches dashboards/1.html's dark Exam Control
     Center look (slate/navy palette, Segoe UI, 12px card radius).
   - "wallboard" — the original design this app shipped with (light blue-grey,
     Oswald/Work Sans/JetBrains Mono, 3px radius). Selected via the theme
     switcher in the header; persisted in localStorage by wwwroot/app-theme.js.
   Every rule below reads colors/fonts from these tokens — never hardcode a
   color or font-family outside this block.
   ============================================================================ */

:root {
  /* Control Center (default) */
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #243246;
  --surface-3: #334155;
  --border: #334155;
  --border-strong: #475569;
  --ink: #e2e8f0;
  --ink-muted: #94a3b8;
  --ink-faint: #64748b;

  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: #1d3a63;

  --good: #22c55e;
  --good-soft: #143a24;
  --warn: #f59e0b;
  --warn-soft: #3a2c0f;
  --critical: #ef4444;
  --critical-soft: #3a1c1c;

  --header-bg: #111827;
  --header-ink: #e2e8f0;
  --header-muted: #94a3b8;
  --header-border: #1f2937;

  --font-heading: "Segoe UI", Arial, sans-serif;
  --font-body: "Segoe UI", Arial, sans-serif;
  --font-mono: "Segoe UI", Consolas, monospace;
  --heading-transform: none;
  --heading-tracking: normal;

  /* Fixed seat/candidate status colors — the same in every theme, per spec. */
  --status-completed: #16a34a;
  --status-inprogress: #2563eb;
  --status-notstarted: #64748b;
  --status-expired: #dc2626;
  --status-absent: #d97706;
  --status-vacant: #94a3b8;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3);
  --radius: 12px;
}

html[data-app-theme="wallboard"] {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #e2e8ed;
  --surface-3: #d3dce2;
  --border: #c3ccd3;
  --border-strong: #a7b2ba;
  --ink: #10161c;
  --ink-muted: #57626b;
  --ink-faint: #808c94;

  --accent: #1467a6;
  --accent-strong: #0d4a79;
  --accent-soft: #dbeaf5;

  --good: #1f9d63;
  --good-soft: #dff2e8;
  --warn: #c07a12;
  --warn-soft: #f7ead2;
  --critical: #d13a3a;
  --critical-soft: #fae0df;

  --header-bg: #0b1620;
  --header-ink: #eef4f8;
  --header-muted: #93a4b2;
  --header-border: #1f2e3a;

  --font-heading: "Oswald", "Work Sans", sans-serif;
  --font-body: "Work Sans", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;
  --heading-transform: uppercase;
  --heading-tracking: 0.04em;

  --shadow: 0 1px 2px rgba(9, 15, 20, 0.06), 0 6px 18px rgba(9, 15, 20, 0.06);
  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

h1, h2 {
  font-family: var(--font-heading);
  text-transform: var(--heading-transform);
  letter-spacing: var(--heading-tracking);
  text-wrap: balance;
  margin: 0;
}

/* ---------- Theme switcher ---------- */

.theme-switch { display: flex; gap: 2px; background: rgba(148, 163, 184, 0.16); padding: 2px; border-radius: 6px; }
.theme-switch button {
  border: none; background: transparent; color: var(--header-muted);
  font-family: var(--font-heading); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 500;
  padding: 5px 10px; border-radius: 4px;
}
.theme-switch button.active { background: var(--surface); color: var(--header-ink); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

button { font-family: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Wallboard header ---------- */

.wallboard { background: var(--header-bg); color: var(--header-ink); border-bottom: 1px solid var(--header-border); padding: 18px 28px 0; }
.wall-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-bottom: 16px; }

.live-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-heading); font-weight: 600; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: #0b1620; background: var(--good); padding: 3px 9px 3px 7px; border-radius: 100px;
}
.live-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #0b1620; animation: blink 1.6s step-start infinite; }
@media (prefers-reduced-motion: reduce) { .live-chip::before { animation: none; } }
@keyframes blink { 50% { opacity: 0.25; } }

.wall-title { font-size: 24px; font-weight: 600; letter-spacing: 0.01em; margin-top: 8px; }
.wall-meta { color: var(--header-muted); font-size: 12px; margin-top: 4px; display: flex; gap: 16px; flex-wrap: wrap; text-transform: none; font-family: var(--font-body); }
.wall-meta b { color: var(--header-ink); font-weight: 600; }

.wall-clock { text-align: right; }
.wall-clock-time { font-size: 34px; font-weight: 600; letter-spacing: 0.02em; color: var(--header-ink); }
.wall-clock-sub { font-size: 11px; color: var(--header-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.session-select {
  margin-top: 8px; background: var(--header-bg); color: var(--header-ink); border: 1px solid var(--header-border);
  border-radius: 4px; padding: 5px 8px; font-family: var(--font-body); font-size: 12px;
}

.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--header-border); }
.kpi { padding: 16px 14px 18px; border-right: 1px solid var(--header-border); }
.kpi:last-child { border-right: none; }
.kpi-value { font-size: 38px; font-weight: 700; line-height: 1; letter-spacing: -0.01em; }
.kpi-label { font-family: var(--font-heading); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--header-muted); margin-top: 6px; }
.kpi--accent .kpi-value { color: var(--accent-strong, var(--accent)); }
.kpi--good .kpi-value { color: var(--good); }
.kpi--warn .kpi-value { color: var(--warn); }
.kpi--critical .kpi-value { color: var(--critical); }

/* ---------- Body ---------- */

.shell { max-width: 1520px; margin: 0 auto; padding: 20px 28px 0; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar h2 { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; }
.toolbar .count { color: var(--ink-muted); font-family: var(--font-body); text-transform: none; font-weight: 400; font-size: 12px; }

.seg { display: flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: 5px; }
.seg button { border: none; background: transparent; color: var(--ink-muted); font-family: var(--font-heading); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 500; padding: 6px 12px; border-radius: 4px; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* ---------- Lab table ---------- */

.lab-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 22px; }
table.labs { width: 100%; border-collapse: collapse; min-width: 900px; }
table.labs thead th { text-align: left; font-family: var(--font-heading); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
table.labs td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.labs tbody tr:last-child td { border-bottom: none; }
table.labs tbody tr:hover { background: var(--surface-2); }

.row-flag { width: 4px; padding: 0 !important; }
.row-flag span { display: block; height: 100%; min-height: 40px; }
tr.status-normal .row-flag span { background: var(--good); }
tr.status-attention .row-flag span { background: var(--warn); }
tr.status-critical .row-flag span { background: var(--critical); }

.lab-cell-name { font-weight: 600; }
.lab-cell-room { color: var(--ink-muted); font-size: 11.5px; margin-top: 1px; }

.status-tag { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-heading); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; padding: 3px 8px; border-radius: 3px; }
.status-tag--normal { background: var(--good-soft); color: var(--good); }
.status-tag--attention { background: var(--warn-soft); color: var(--warn); }
.status-tag--critical { background: var(--critical-soft); color: var(--critical); }

.bar-cell { min-width: 140px; }
.bar-track { height: 6px; border-radius: 100px; background: var(--surface-3); display: flex; overflow: hidden; }
.bar-seg-done { height: 100%; background: var(--accent); }
.bar-seg-prog { height: 100%; background: var(--ink-faint); opacity: 0.55; }
.bar-caption { font-size: 10.5px; color: var(--ink-muted); margin-top: 4px; }

.num { text-align: right; }
.issue-note { font-size: 11px; color: var(--ink-muted); margin-top: 2px; max-width: 220px; }
tr.status-critical .issue-note { color: var(--critical); }
tr.status-attention .issue-note { color: var(--warn); }

.row-actions { display: flex; gap: 6px; white-space: nowrap; }
.btn-link { border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); font-size: 11px; font-weight: 600; padding: 5px 9px; border-radius: 3px; }
.btn-link:hover { background: var(--surface-2); }
.btn-link--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-link--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

/* ---------- Lab detail (seat grid) ---------- */

.detail-panel { margin-bottom: 22px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; gap: 10px; }
.detail-head-left { display: flex; align-items: center; gap: 12px; }
.detail-head h2 { font-size: 16px; }
.detail-sub { color: var(--ink-muted); font-size: 11.5px; text-transform: none; font-family: var(--font-body); margin-top: 2px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 9px 16px; border-bottom: 1px solid var(--border); font-size: 10.5px; color: var(--ink-muted); }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

.seat-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.seat { aspect-ratio: 1; border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; }
.seat small { font-size: 8px; font-weight: 500; opacity: 0.9; margin-top: 1px; }

.seat.completed { background: var(--status-completed); }
.seat.inprogress { background: var(--status-inprogress); }
.seat.notstarted { background: var(--status-notstarted); }
.seat.expired { background: var(--status-expired); }
.seat.absent { background: var(--status-absent); }
.seat.vacant { background: transparent; border: 1px dashed var(--status-vacant); color: var(--status-vacant); font-weight: 500; }

.flagged-list { padding: 0 16px 16px; }
.flagged-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 3px; margin-top: 6px; font-size: 12px; }
.flagged-row.warn { background: var(--warn-soft); }
.flagged-row.critical { background: var(--critical-soft); }
.flagged-empty { padding: 4px 0 2px; color: var(--ink-faint); font-size: 12px; }

/* ---------- Bottom split ---------- */

.bottom-split { display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 16px; padding-bottom: 28px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.panel-head h2 { font-size: 12.5px; letter-spacing: 0.06em; }
.panel-head .count { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); text-transform: none; }

.queue { max-height: 260px; overflow-y: auto; }
.queue-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.queue-row:last-child { border-bottom: none; }
.queue-row:hover { background: var(--surface-2); }
.queue-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.queue-row.critical .queue-dot { background: var(--critical); }
.queue-row.warn .queue-dot { background: var(--warn); }
.queue-title { font-size: 12px; font-weight: 600; }
.queue-sub { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }

.ticker { max-height: 260px; overflow-y: auto; }
.ticker-row { display: flex; gap: 10px; padding: 7px 16px; font-size: 11.5px; border-bottom: 1px dotted var(--border); }
.ticker-row:last-child { border-bottom: none; }
.ticker-time { color: var(--ink-faint); flex-shrink: 0; }
.ticker-row strong { font-weight: 600; }
.ticker-text { color: var(--ink-muted); }

.empty-note { padding: 14px 16px; color: var(--ink-faint); font-size: 12px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.footnote { text-align: center; font-size: 11px; color: var(--ink-faint); padding-bottom: 20px; }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .bottom-split { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}
