/* ══════════════════════════════════════════
   DESIGN SYSTEM — Dark Enterprise SaaS
   ══════════════════════════════════════════ */
:root {
  /* ── Layout ── */
  --bg:           #0D0D0D;
  --bg-2:         #14121f;
  --surface:      #1a1730;
  --surface-2:    #221e3d;
  --border:       #2e2a52;
  --border-2:     #3d3868;

  /* ── Brandable tokens (overridden at runtime by Admin Branding panel) ── */
  --brand:        #1B78F2;
  --brand-dark:   #1560C8;
  --brand-glow:   rgba(27,120,242,0.15);
  --shadow-brand: 0 0 0 3px rgba(27,120,242,0.2);
  --brand-secondary:      #241C59;
  --brand-secondary-dark: #1A1442;
  --brand-secondary-glow: rgba(36,28,89,0.10);
  --brand-accent:         #D9631E;
  --brand-accent-dark:    #B84F14;
  --brand-accent-glow:    rgba(217,99,30,0.12);

  /* ── Status ── */
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --muted:        #64748b;
  /* Status alpha variants — token the rgba values so they survive migration */
  --pass-lt:      rgba(16,185,129,0.10);
  --pass-dim:     rgba(16,185,129,0.05);
  --pass-bg:      rgba(16,185,129,0.08);
  --pass-border:  rgba(16,185,129,0.20);
  --fail-lt:      rgba(239,68,68,0.10);
  --fail-dim:     rgba(239,68,68,0.05);
  --fail-bg:      rgba(239,68,68,0.08);
  --fail-border-lt: rgba(239,68,68,0.15);
  --fail-border:  rgba(239,68,68,0.20);
  --warn-lt:      rgba(245,158,11,0.10);
  --warn-border:  rgba(245,158,11,0.20);

  /* ── Text ── */
  --ink-1:        #f1f5f9;
  --ink-2:        #94a3b8;
  --ink-3:        #64748b;
  --ink-4:        #475569;

  /* ── Typography ── */
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  /* ── Type scale (mobile-ready: 12pt minimum) ── */
  --text-xs:   12px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  30px;

  /* ── Spacing ── */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* ── Radius ── */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* ── Shadows ── */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);

  /* ── Elevation surfaces ── (depth ladder: bg < bg-2 < surface < surface-raised) */
  --surface-raised: var(--surface-2);

  /* ── Scrim (modal/overlay backdrops) ── */
  --scrim:        rgba(0,0,0,0.7);
  --scrim-strong: rgba(0,0,0,0.85);

  /* ── Legacy aliases — keep these so existing HTML/JS that references old names doesn't break ── */
  --white:      #1c2333;
  --r:          var(--radius-md);
  --r-lg:       var(--radius-lg);
  --r-full:     50%;
  --rule:       var(--border);
  --rule-2:     var(--border-2);
  --pass:       var(--success);
  --fail:       var(--danger);
  --warn:       var(--warning);
  --accent-lt:  var(--brand-glow);
  --brand-1:    var(--brand);
  --brand-2:    var(--brand-dark);
  --s-1: 4px; --s-2: 8px; --s-4: 16px; --s-6: 24px;
  --ink-meta:   var(--ink-4);
  --shadow-xs:  var(--shadow-sm);
}

/* ── LIGHT MODE ── */
[data-theme="light"] {
  --bg:           #F2F2F2;
  --bg-2:         #E8E8EC;
  --surface:      #ffffff;
  --surface-2:    #f1f5f9;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;

  --ink-1:        #0D0D0D;
  --ink-2:        #2b2a3a;
  --ink-3:        #64748b;
  --ink-4:        #94a3b8;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.14);

  /* Legacy aliases */
  --white: #ffffff;
}

/* ── Theme toggle button ── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-3);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--ink-1);
  border-color: var(--border-2);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--ink-2);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; outline: none; }
input, select, textarea { font-family: inherit; }

/* ── UTIL ── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
/* Aligned figures for any column/metric of numbers */
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 50%; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ══════════════════ BUTTONS ══════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary:focus { outline: none; box-shadow: var(--shadow-brand); }
.btn-outline {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border-2);
}
.btn-outline:hover { background: var(--surface-2); color: var(--ink-1); }
.btn-ghost {
  background: transparent;
  color: var(--ink-3);
  border: none;
}
.btn-ghost:hover { color: var(--ink-1); background: var(--surface); }
.btn-danger {
  background: var(--fail-lt);
  color: var(--danger);
  border: 1px solid var(--fail-border);
}
.btn-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: var(--text-xs); }
.btn-lg { min-height: 48px; padding: 12px 22px; font-size: var(--text-md); }
.btn-xl { min-height: 52px; padding: 14px 28px; font-size: var(--text-lg); }
.btn-icon { min-height: 0; padding: 10px; border-radius: var(--radius-sm); }
.w-full { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ══════════════════ INPUTS ══════════════════ */
.field { margin-bottom: var(--space-4); }
.field label, label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
input[type=text],
input[type=password],
input[type=email],
input[type=number],
input[type=url],
input[type=search],
input[type=tel],
input[type=date],
input[type=color],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-size: var(--text-md);
  padding: 8px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
select option { background: var(--surface); color: var(--ink-1); }
input[type=color] { padding: 4px 6px; height: 38px; cursor: pointer; }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* ══════════════════ CHIPS / BADGES ══════════════════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.5;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--ink-3);
  white-space: nowrap;
}
.chip-green  { background: var(--pass-lt);  color: var(--success); border-color: var(--pass-border); }
.chip-red    { background: var(--fail-lt);  color: var(--danger);  border-color: var(--fail-border); }
.chip-amber  { background: var(--warn-lt);  color: var(--warning); border-color: var(--warn-border); }
.chip-blue   { background: var(--brand-glow);    color: var(--brand);   border-color: var(--brand-glow); }
.chip-brand-accent    { background: var(--brand-accent-glow);    color: var(--brand-accent);    border-color: var(--brand-accent-glow); }
.chip-brand-secondary { background: var(--brand-secondary-glow); color: var(--brand-secondary); border-color: var(--brand-secondary-glow); }

/* ══════════════════ PROGRESS ══════════════════ */
.progress-track { background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress-fill { background: var(--brand); border-radius: 2px; transition: width 0.3s ease; height: 100%; }

/* ══════════════════ APP SHELL ══════════════════ */
#app { min-height: 100vh; display: flex; flex-direction: column; }
.screen {
  display: none;
  width: 100vw;
  min-height: 100vh;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ══════════════════ TOP HEADER ══════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-1);
}
.brand::before {
  content: '';
  display: block;
  width: 10px;
  height: 10px;
  background: var(--brand);
  transform: rotate(45deg);
  border-radius: 2px;
  flex-shrink: 0;
}
.brand.has-logo::before { display: none; }
.brand-logo { height: 28px; width: auto; border-radius: var(--radius-sm); object-fit: contain; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.user-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ══════════════════ APP LAYOUT ══════════════════ */
.app-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ══════════════════ SIDEBAR NAV ══════════════════ */
.sidenav {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sidenav-section { margin-top: var(--space-5); }
.sidenav-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 10px;
  margin-bottom: 4px;
  margin-top: 2px;
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
}
.nav-btn:hover {
  color: var(--ink-2);
  background: var(--surface);
}
.nav-btn.active {
  color: var(--ink-1);
  background: var(--brand-glow);
  border-left: 2px solid var(--brand);
  font-weight: 700;
}
.nav-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-btn.active .nav-icon,
.nav-btn:hover .nav-icon { opacity: 1; }
.nav-sub {
  padding-left: 20px;
  font-size: calc(var(--text-sm) - 1px);
  opacity: 0.85;
}

/* ══════════════════ MAIN CONTENT ══════════════════ */
.main {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-8) 40px;
  background: var(--bg);
  min-width: 0;
}
@media (max-width: 900px) { .main { padding: var(--space-6); } }

/* ══════════════════ PAGE STRUCTURE ══════════════════ */
.page { display: none; }
.page.active { display: block; animation: fadeUp 0.25s ease forwards; }

.page-head { margin-bottom: var(--space-6); }
.page-head-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-4); }
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 6px;
}
.page-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--ink-1);
  line-height: 1.2;
}
.page-sub {
  font-size: var(--text-sm);
  color: var(--ink-3);
  margin-top: var(--space-2);
}

/* ══════════════════ DIVIDER ══════════════════ */
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }

/* ══════════════════ CARDS ══════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-sm { padding: var(--space-4); border-radius: var(--radius-md); }
.card + .card { margin-top: var(--space-4); }
.card-title { font-size: var(--text-md); font-weight: 600; color: var(--ink-1); margin-bottom: var(--space-2); }
.card-sub { font-size: var(--text-sm); color: var(--ink-3); margin-bottom: var(--space-4); }

/* ══════════════════ STATS ══════════════════ */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
@media (max-width: 900px) { .stats-row { grid-template-columns: 1fr 1fr; } }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--brand-glow);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand);
  margin-bottom: var(--space-3);
}
.stat-value { font-size: 28px; font-weight: 600; color: var(--ink-1); line-height: 1; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.stat-label { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

/* ══════════════════ DASHBOARD LAYOUT ══════════════════ */
.dash-mid {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  align-items: start;
}
@media (max-width: 960px) { .dash-mid { grid-template-columns: 1fr; } }

.dash-section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: var(--space-3);
}

/* Quick actions panel */
.dash-quick {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4);
}
.quick-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  cursor: pointer;
  text-align: left;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background 0.1s, border-color 0.1s;
  margin-bottom: var(--space-2);
}
.quick-action-btn:last-child { margin-bottom: 0; }
.quick-action-btn:hover { background: var(--brand-glow); border-color: var(--brand); color: var(--ink-1); }
.quick-action-icon {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--brand-glow);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--brand);
}
.quick-action-sub { font-size: var(--text-xs); color: var(--ink-4); margin-top: 2px; }

/* Activity feed */
.activity-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  gap: var(--space-3);
}
.activity-item:last-child { border-bottom: none; }
.activity-info { flex: 1; min-width: 0; }
.activity-name { font-size: var(--text-sm); font-weight: 500; color: var(--ink-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-course { font-size: var(--text-xs); color: var(--ink-4); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-meta { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.activity-date { font-size: var(--text-xs); color: var(--ink-4); }

/* Misc */
.link-cell { color: var(--brand); cursor: pointer; font-weight: 500; }
.link-cell:hover { text-decoration: underline; }
.empty-state-sm {
  padding: var(--space-6);
  color: var(--ink-4);
  font-size: var(--text-sm);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* ══════════════════ COURSE GRID ══════════════════ */
.courses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-5); align-items: stretch; }
.courses-grid .card + .card { margin-top: 0; }

/* ══════════════════ TEAMS LAYOUT ══════════════════ */
.teams-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 480px;
  height: calc(100vh - 200px);
  max-height: 820px;
  background: var(--surface);
}
.teams-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg-2);
  padding: var(--space-2);
}
.team-list-item {
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
  margin-bottom: 2px;
}
.team-list-item:hover { background: var(--surface); }
.team-list-item.active { background: var(--brand-glow); border-left: 2px solid var(--brand); }
.team-list-name { font-size: var(--text-sm); font-weight: 500; color: var(--ink-2); }
.team-list-item.active .team-list-name { color: var(--ink-1); font-weight: 700; }
.team-list-meta { font-size: var(--text-xs); color: var(--ink-4); margin-top: 2px; }
.team-detail {
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
}
.team-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--ink-4);
  font-size: var(--text-sm);
}
.team-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}
.team-detail-name { font-size: var(--text-xl); font-weight: 700; color: var(--ink-1); }
.team-detail-meta { font-size: var(--text-sm); color: var(--ink-4); margin-top: 4px; }
.team-detail-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-start; }
.section-header {
  grid-column: 1 / -1;
  margin-top: var(--space-6);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--brand-secondary);
  font-weight: 600;
  font-size: var(--text-md);
  color: var(--ink-1);
}
.section-header:first-child { margin-top: 0; }
@media (max-width: 600px) { .courses-grid { grid-template-columns: 1fr; } }
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.course-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-md);
}
.course-card:active { transform: scale(0.985); }
.course-icon { font-size: 28px; margin-bottom: var(--space-4); }
.course-name { font-size: var(--text-md); font-weight: 600; color: var(--ink-1); margin-bottom: 6px; line-height: 1.3; }
.course-desc { font-size: var(--text-sm); color: var(--ink-3); margin-bottom: var(--space-5); line-height: 1.6; }
.course-meta { display: flex; gap: var(--space-4); align-items: center; font-size: var(--text-xs); color: var(--ink-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.course-meta-item { display: flex; align-items: center; gap: 4px; }

/* ══════════════════ TABLE ══════════════════ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
thead th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 10px 16px;
  text-align: left;
  background: var(--surface);
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface); }

/* ══════════════════ MODAL ══════════════════ */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
}
.overlay.hidden { display: none; }
.overlay:not(.hidden) { animation: fadeIn 0.15s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.overlay:not(.hidden) .modal { animation: modalIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal {
  background: var(--surface-raised);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-wide { max-width: 820px; }
.modal-sm { max-width: 360px; }
.modal-lg { max-width: 640px; }
.modal-head { margin-bottom: var(--space-5); }
.modal-title { font-size: var(--text-lg); font-weight: 600; color: var(--ink-1); }
.modal-sub { font-size: var(--text-sm); color: var(--ink-3); margin-top: var(--space-2); }
.modal-body { margin-bottom: var(--space-5); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-3); }

/* ══════════════════ UPLOAD ZONE ══════════════════ */
.upload-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}
.upload-zone:hover, .upload-zone.drag-active {
  border-color: var(--brand);
  background: var(--brand-glow);
}
.upload-icon { font-size: 32px; margin-bottom: var(--space-3); color: var(--ink-3); }
.upload-text { font-size: var(--text-md); font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.upload-hint { font-size: var(--text-xs); color: var(--ink-4); }

/* ══════════════════ EMPTY STATE ══════════════════ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--ink-3);
  font-size: var(--text-sm);
  padding: var(--space-12) var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.empty-icon { font-size: 40px; margin-bottom: var(--space-4); opacity: 0.45; }
.empty-title { font-size: var(--text-lg); font-weight: 600; color: var(--ink-1); margin-bottom: var(--space-2); }
.empty-hint { font-size: var(--text-sm); color: var(--ink-3); max-width: 42ch; line-height: 1.6; }
.empty-action { margin-top: var(--space-5); }

/* ══════════════════ TOAST ══════════════════ */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: var(--space-2); max-width: 320px; pointer-events: none; }
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 10px 16px;
  font-size: var(--text-sm);
  color: var(--ink-1);
  animation: slideIn 0.2s ease;
  pointer-events: auto;
}
.toast.t-success, .toast.toast-ok { border-left-color: var(--success); }
.toast.t-error, .toast.toast-err  { border-left-color: var(--danger); }
.toast.t-info                      { border-left-color: var(--brand); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════ LANDING ══════════════════ */
#screen-landing {
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-10);
  min-height: 100vh;
}
#screen-landing.active { display: flex; }
#screen-landing {
  padding: var(--space-8) var(--space-4);
  background:
    radial-gradient(900px 420px at 50% -10%, var(--brand-glow), transparent 70%),
    var(--bg);
}
.landing-wrap {
  width: 100%; max-width: 760px;
  text-align: center;
}
.ldg-logo { text-align: center; }
.ldg-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink-1);
  margin-bottom: var(--space-3);
}
.ldg-wordmark::before {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  background: var(--brand);
  transform: rotate(45deg);
  border-radius: 2px;
  flex-shrink: 0;
}
.ldg-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ldg-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}
.ldg-logo-img {
  max-height: 120px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
  border-radius: var(--radius-md);
}
.landing-logo {
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink-1);
  line-height: 1.1;
  margin: 0 0 var(--space-3);
}
.ldg-head { margin-bottom: var(--space-10); }
.ldg-org {
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--brand); margin-bottom: var(--space-2);
}
.ldg-org:empty { display: none; }
.landing-sub {
  font-size: var(--text-md); color: var(--ink-3); font-weight: 400;
  line-height: 1.5; max-width: 480px; margin: 0 auto;
}
.role-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
@media (max-width: 720px) { .role-grid { grid-template-columns: 1fr; } }
.role-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  font: inherit; text-align: left; color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.role-tile:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.role-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.role-tile:active { transform: scale(0.98); }
.role-tile-icon {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--brand-glow); color: var(--brand);
  margin-bottom: var(--space-2);
}
.role-tile-icon svg { width: 22px; height: 22px; }
.role-tile-primary .role-tile-icon { background: var(--brand); color: #fff; }
.role-tile-title { font-size: var(--text-md); font-weight: 600; color: var(--ink-1); }
.role-tile-desc { font-size: var(--text-sm); color: var(--ink-3); line-height: 1.45; flex: 1; }
.role-tile-cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: var(--space-3);
  font-size: var(--text-sm); font-weight: 600; color: var(--brand);
}
.role-tile-cta svg { width: 16px; height: 16px; transition: transform 0.15s ease; }
.role-tile:hover .role-tile-cta svg { transform: translateX(3px); }
.ldg-demo {
  background: none; border: 0; padding: var(--space-2) var(--space-3);
  font: inherit; font-size: var(--text-sm); font-weight: 500; color: var(--ink-3);
  cursor: pointer; border-radius: var(--radius-md);
  margin-bottom: var(--space-8);
  transition: color 0.15s ease;
}
.ldg-demo:hover { color: var(--brand); }
.ldg-demo:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.landing-foot { font-size: var(--text-xs); color: var(--ink-3); line-height: 1.7; }
.landing-foot strong { color: var(--ink-2); font-weight: 600; }

/* ══════════════════ LOGIN ══════════════════ */
#screen-login, #screen-manager-login, #screen-join {
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  min-height: 100vh;
}
#screen-login.active, #screen-manager-login.active, #screen-join.active { display: flex; }
.login-wrap { width: 100%; max-width: 400px; }
.login-header { margin-bottom: var(--space-8); }
.login-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: var(--space-2);
}
.login-sub { font-size: var(--text-sm); color: var(--ink-3); margin-bottom: var(--space-6); }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
}

/* ══════════════════ LEARNER NAME ══════════════════ */
.name-wrap {
  max-width: 380px;
  margin: 0 auto;
  padding: var(--space-10);
}
.name-greeting {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--ink-1);
  margin-bottom: var(--space-2);
}
.name-hint { font-size: var(--text-sm); color: var(--ink-3); margin-bottom: var(--space-6); }

/* ══════════════════ COURSE VIEWER ══════════════════ */
#screen-course { background: var(--bg); }
.course-layout { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.course-header {
  padding: var(--space-4) var(--space-6);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.ch-back-btn { color: var(--ink-3); }
.ch-meta { font-size: var(--text-sm); font-weight: 500; color: var(--ink-2); flex: 1; }
.ch-prog-wrap { display: flex; align-items: center; gap: var(--space-3); }
.ch-label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-3); white-space: nowrap; }
.ch-prog-bar { width: 120px; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.focus-mode .module-nav { width: 0; padding: 0; border: none; opacity: 0; overflow: hidden; }
.focus-mode .module-prose { max-width: 800px; }
.module-nav { transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.course-header-title { font-weight: 600; font-size: var(--text-base); color: var(--ink-1); }
.course-header-progress { flex: 1; max-width: 320px; }
.course-header-meta { font-size: var(--text-xs); color: var(--ink-4); margin-bottom: 5px; }
.course-body { display: flex; flex: 1; overflow: hidden; }
.mod-sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.module-nav {
  width: 260px; flex-shrink: 0;
  background: var(--bg-2); border-right: 1px solid var(--border);
  overflow-y: auto; padding: var(--space-5);
}
.module-nav-title { font-size: var(--text-xs); font-weight: 700; color: var(--ink-4); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: var(--space-4); }
.mod-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 2px;
  transition: background 0.12s; color: var(--ink-3);
  font-size: var(--text-sm);
}
.mod-item:hover { background: var(--surface); color: var(--ink-2); }
.mod-item.active { background: var(--brand-glow); color: var(--ink-1); }
.mod-item-body { flex: 1; min-width: 0; }
.mod-item-title { font-weight: 500; line-height: 1.3; }
.mod-item-summary { font-size: var(--text-xs); color: var(--ink-4); margin-top: 2px; line-height: 1.4; white-space: normal; }
.mod-bullet {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; color: var(--ink-4); flex-shrink: 0;
}
.mod-item.active .mod-bullet { border-color: var(--brand); color: var(--brand); }
.mod-item.done-pass .mod-bullet { border-color: var(--success); background: var(--success); color: white; }
.mod-item.done-fail .mod-bullet { border-color: var(--danger); background: var(--danger); color: white; }

.module-main, .mod-main { flex: 1; overflow-y: auto; padding: var(--space-8) 40px; background: var(--bg); }
.module-prose {
  max-width: 720px; margin: 0 auto;
}
.module-prose h2 {
  font-size: var(--text-2xl); font-weight: 600; color: var(--ink-1);
  margin-bottom: var(--space-6);
}
.module-prose h3 { font-size: var(--text-lg); font-weight: 600; color: var(--ink-1); margin: var(--space-6) 0 var(--space-3); }
.module-prose p { color: var(--ink-2); line-height: 1.7; margin-bottom: var(--space-4); }
.module-prose ul, .module-prose ol { color: var(--ink-2); padding-left: var(--space-6); margin-bottom: var(--space-4); line-height: 1.8; }
.module-prose li { margin-bottom: 4px; }

/* Reference material notice */
.ref-material-notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-8);
  padding: var(--space-4) var(--space-5);
  background: var(--brand-glow);
  border: 1px solid var(--brand);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.ref-material-notice .ref-icon { font-size: 16px; flex-shrink: 0; }
.ref-material-notice span { flex: 1; min-width: 180px; }
.ref-link {
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.ref-link:hover { background: var(--brand-glow); }

/* ── Source banner ── */
.source-banner {
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--brand-glow); border: 1px solid var(--brand);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-md); margin-bottom: var(--space-6);
}
.source-banner-icon { font-size: 1.4rem; flex-shrink: 0; margin-top: 2px; }
.source-banner-body { flex: 1; min-width: 0; }
.source-banner-label { font-weight: 700; font-size: var(--text-sm); color: var(--ink-1); margin-bottom: 2px; }
.source-banner-text { font-size: var(--text-sm); color: var(--ink-2); line-height: 1.5; }
.source-banner-link {
  flex-shrink: 0; align-self: center;
  font-size: var(--text-sm); font-weight: 600; color: var(--brand);
  text-decoration: none; white-space: nowrap;
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--brand); border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.source-banner-link:hover { background: var(--brand-glow); }

/* ── Module overview card ── */
.mod-overview-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-5);
  margin-bottom: var(--space-6);
}
.mod-summary-text { font-size: var(--text-sm); color: var(--ink-2); line-height: 1.7; margin: 0 0 var(--space-4); font-style: italic; }
.mod-objectives { margin-top: var(--space-2); }
.mod-objectives-label { font-size: var(--text-xs); font-weight: 700; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--space-2); }
.mod-objectives ul { margin: 0; padding-left: var(--space-5); }
.mod-objectives li { font-size: var(--text-sm); color: var(--ink-2); margin-bottom: 4px; line-height: 1.5; }
.mod-meta-row { display: flex; gap: var(--space-3); margin-top: var(--space-4); flex-wrap: wrap; }
.mod-meta-chip {
  font-size: var(--text-xs); font-weight: 600; color: var(--ink-3);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 99px; padding: 2px 10px;
}

/* ── Prose content (markdown rendered) ── */
.prose-content { color: var(--ink-2); line-height: 1.7; }
.prose-content h1, .prose-content h2 { font-size: var(--text-lg); font-weight: 600; color: var(--ink-1); margin: var(--space-6) 0 var(--space-3); }
.prose-content h3, .prose-content h4 { font-size: var(--text-md); font-weight: 600; color: var(--ink-1); margin: var(--space-5) 0 var(--space-2); }
.prose-content p { margin-bottom: var(--space-4); }
.prose-content ul, .prose-content ol { padding-left: var(--space-6); margin-bottom: var(--space-4); }
.prose-content li { margin-bottom: 4px; }
.prose-content a { color: var(--brand); text-decoration: underline; }
.prose-content a:hover { opacity: 0.8; }
.prose-content code { font-family: var(--font-mono); font-size: 0.875em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; color: var(--ink-1); }
.prose-content pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); overflow-x: auto; margin-bottom: var(--space-4); }
.prose-content pre code { background: none; padding: 0; font-size: 0.8em; }
.prose-content blockquote { border-left: 3px solid var(--brand); padding-left: var(--space-4); color: var(--ink-3); margin: 0 0 var(--space-4); font-style: italic; }
.prose-content table { width: 100%; border-collapse: collapse; margin-bottom: var(--space-4); font-size: var(--text-sm); }
.prose-content th { background: var(--surface-2); font-weight: 600; color: var(--ink-1); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); text-align: left; }
.prose-content td { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); color: var(--ink-2); }
.prose-content tr:nth-child(even) td { background: var(--surface); }
.prose-content strong { font-weight: 600; color: var(--ink-1); }
.prose-content hr { border: none; border-top: 1px solid var(--border); margin: var(--space-6) 0; }

/* ── Quiz question review ── */
.qr-review { text-align: left; margin-top: var(--space-8); }
.qr-review-title { font-size: var(--text-sm); font-weight: 700; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: var(--space-4); }
.qr-review-item {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-3);
  border: 1px solid var(--border);
}
.qr-item-pass { background: var(--pass-dim);  border-color: var(--pass-border); }
.qr-item-fail { background: var(--fail-dim);  border-color: var(--fail-border-lt); }
.qr-review-status { font-size: 14px; font-weight: 700; flex-shrink: 0; width: 20px; margin-top: 1px; }
.qr-item-pass .qr-review-status { color: var(--success); }
.qr-item-fail .qr-review-status { color: var(--danger); }
.qr-review-body { flex: 1; min-width: 0; }
.qr-review-q { font-size: var(--text-sm); font-weight: 500; color: var(--ink-1); line-height: 1.4; }
.qr-review-correct { font-size: 12px; color: var(--success); margin-top: 4px; }
.qr-review-exp { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }

.quiz-wrap { max-width: 640px; margin: 0 auto; }
.quiz-header { margin-bottom: var(--space-6); }
.quiz-step { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: var(--space-3); }
.quiz-q { font-size: var(--text-lg); font-weight: 600; color: var(--ink-1); line-height: 1.4; }
.quiz-options { display: flex; flex-direction: column; gap: var(--space-3); }
.quiz-opt {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  color: var(--ink-2);
  font-size: var(--text-md);
  transition: all 0.12s;
  width: 100%;
}
.quiz-opt:hover { border-color: var(--border-2); color: var(--ink-1); background: var(--surface-2); }
.quiz-opt:active:not(:disabled) { transform: scale(0.99); }
.quiz-opt:disabled { cursor: default; opacity: 0.85; }
.quiz-opt.correct { border-color: var(--success) !important; background: var(--pass-bg) !important; color: var(--success) !important; }
.quiz-opt.wrong   { border-color: var(--danger) !important;  background: var(--fail-bg) !important;  color: var(--danger) !important; }
.opt-letter {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; color: var(--ink-3);
}
.quiz-opt.correct .opt-letter { background: var(--success); color: white; }
.quiz-opt.wrong   .opt-letter { background: var(--danger);  color: white; }
.quiz-feedback {
  display: flex; align-items: flex-start; gap: var(--space-4);
  padding: var(--space-5); border-radius: var(--radius-md);
  margin-top: var(--space-5); border: 1px solid transparent;
}
.quiz-feedback.fb-pass { background: var(--pass-bg); color: var(--success); border-color: var(--pass-border); }
.quiz-feedback.fb-fail { background: var(--fail-bg); color: var(--danger);  border-color: var(--fail-border); }
.fb-icon { font-size: 1.4rem; font-weight: 700; flex-shrink: 0; line-height: 1; }
.fb-body { flex: 1; }
.fb-verdict { font-weight: 700; font-size: var(--text-md); }
.fb-exp { margin-top: var(--space-2); font-size: var(--text-sm); opacity: .85; font-weight: 400; }
.fb-next { flex-shrink: 0; align-self: center; }

/* Module results screen */
.quiz-results { max-width: 480px; margin: 0 auto; padding: var(--space-12) var(--space-6); text-align: center; }
.qr-score { font-size: 4rem; font-weight: 800; line-height: 1; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.qr-score.qr-pass { color: var(--success); }
.qr-score.qr-fail { color: var(--danger); }
.qr-label { font-size: var(--text-lg); color: var(--ink-3); margin-top: var(--space-2); }
.qr-verdict { font-size: var(--text-md); font-weight: 600; margin-top: var(--space-4); color: var(--ink-1); }

.results-wrap { max-width: 540px; margin: 0 auto; padding: var(--space-16) var(--space-8); text-align: center; }
.score-ring-wrap { position: relative; width: 140px; height: 140px; margin: 0 auto var(--space-6); }
.score-ring-wrap svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.score-ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.score-big { font-family: var(--font-mono); font-size: 40px; font-weight: 700; line-height: 1; color: var(--ink-1); font-variant-numeric: tabular-nums; }
.score-lbl { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-4); }
.results-title { font-size: var(--text-2xl); font-weight: 600; color: var(--ink-1); margin-bottom: var(--space-2); }
.results-sub { color: var(--ink-3); margin-bottom: var(--space-8); }

/* ══════════════════ BRANDING PAGE ══════════════════ */
.brand-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); margin-bottom: var(--space-6); }
.brand-preview-bar { height: 6px; border-radius: 2px; margin-top: var(--space-3); }
.color-row { display: flex; gap: var(--space-3); align-items: center; }
.swatch { width: 36px; height: 36px; border-radius: var(--radius-md); border: 1px solid var(--border); overflow: hidden; flex-shrink: 0; cursor: pointer; }
.swatch input[type=color] { width: 200%; height: 200%; margin: -25%; border: none; cursor: pointer; padding: 0; }

/* ══════════════════ MODULE BUILDER ══════════════════ */
.mod-builder {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); margin-bottom: var(--space-4); overflow: hidden;
}
.mod-builder-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); cursor: pointer;
  background: var(--surface-2);
}
.mod-builder-head:hover { background: var(--surface); }
.mod-builder-body { padding: var(--space-5); border-top: 1px solid var(--border); }

/* ══════════════════ STEP INDICATOR ══════════════════ */
.step-row { display: flex; gap: var(--space-3); margin-bottom: var(--space-8); align-items: center; }
.step { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; color: var(--ink-4); }
.step.active { color: var(--brand); }
.step.done { color: var(--success); }
.step-num { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); font-weight: 700; flex-shrink: 0; }
.step-sep { flex: 1; height: 1px; background: var(--border); max-width: 40px; }

.q-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-4); margin-bottom: var(--space-3);
}
.q-opts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: var(--space-3) 0; }
.q-opt-row { display: flex; align-items: center; gap: var(--space-2); }
.opt-ltr { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; color: var(--ink-4); width: 14px; }

/* ══════════════════ CERTIFICATE TEMPLATE ══════════════════ */
.cert-overlay-wrap, #cert-overlay {
  position: fixed; inset: 0; background: var(--scrim-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 200; padding: var(--space-6);
  backdrop-filter: blur(4px);
}
.cert-controls { display: flex; gap: var(--space-3); margin-bottom: var(--space-5); justify-content: center; }
.cert-sheet, #cert-sheet {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 60px 80px;
  max-width: 760px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
}
.cert-accent-bar { height: 6px; background: linear-gradient(to right, var(--brand), var(--brand-secondary)); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.course-header-logo { height: 32px; width: auto; max-width: 100px; object-fit: contain; flex-shrink: 0; }
.cert-body { padding: 52px 64px 48px; text-align: center; }
.cert-org-name {
  font-family: var(--font-mono);
  font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 32px;
}
.cert-heading {
  font-size: 52px; font-weight: 600;
  color: var(--ink-1); line-height: 1; margin-bottom: 28px;
}
.cert-of { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 28px; }
.cert-presents { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.cert-name {
  font-size: 42px; font-weight: 700; color: var(--ink-1);
  letter-spacing: -0.02em; margin-bottom: 28px;
  display: inline-block;
}
.cert-completed { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.cert-course { font-size: 20px; font-weight: 700; color: var(--ink-1); margin-bottom: 36px; }
.cert-rule { width: 60px; height: 1px; background: var(--border); margin: 0 auto 32px; }
.cert-meta-row { display: flex; justify-content: center; gap: 64px; margin-bottom: 36px; }
.cert-meta-item { text-align: center; }
.cert-meta-label { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-3); margin-bottom: 4px; }
.cert-meta-val { font-size: 14px; font-weight: 700; color: var(--ink-1); }
.cert-sig-row { display: flex; justify-content: center; gap: 80px; padding-top: 28px; border-top: 1px solid var(--border); }
.cert-sig-item { text-align: center; }
.cert-sig-line { width: 120px; height: 1px; background: var(--border-2); margin: 0 auto 6px; }
.cert-sig-label { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); }

/* ══════════════════ CODE / FORMAT ══════════════════ */
code {
  font-family: var(--font-mono);
  font-size: 12px; background: var(--surface-2);
  padding: 2px 6px; border-radius: var(--radius-sm); color: var(--ink-2);
}
pre code { display: block; padding: var(--space-4); line-height: 1.7; }

/* ══════════════════ ANIMATIONS ══════════════════ */
@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp   { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes shake    { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse    { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* List entrance: fade + 8px rise, 150ms, staggered */
@keyframes listIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.stagger > * { opacity: 0; animation: listIn 0.15s ease-out forwards; }
.stagger > *:nth-child(1) { animation-delay: 0.03s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.09s; }
.stagger > *:nth-child(4) { animation-delay: 0.12s; }
.stagger > *:nth-child(5) { animation-delay: 0.15s; }
.stagger > *:nth-child(6) { animation-delay: 0.18s; }
.stagger > *:nth-child(7) { animation-delay: 0.21s; }
.stagger > *:nth-child(8) { animation-delay: 0.24s; }

.shake { animation: shake 0.2s ease-in-out 0s 2; }
.pulse { animation: pulse 0.3s ease-in-out; }

/* ── SPINNER ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════ REDUCED MOTION ══════════════════ */
/* Respect the OS "Reduce Motion" setting — degrade to instant state changes.
   The spinner keeps a minimal rotation so loading state stays legible. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .stagger > * { opacity: 1 !important; }
  .page.active { animation: none !important; }
  .btn:active,
  .course-card:active,
  .role-tile:active,
  .quiz-opt:active,
  .role-tile:hover { transform: none !important; }
  .spinner { animation-duration: 0.8s !important; animation-iteration-count: infinite !important; }
}

/* ══════════════════ PRINT ══════════════════ */
@media print {
  body > *:not(#cert-overlay) { display: none !important; }
  #cert-overlay {
    position: static; background: none;
    display: block !important; padding: 0;
  }
  .cert-controls { display: none !important; }
  #cert-sheet { box-shadow: none; max-width: none; border-radius: 0; }
}

/* ══════════════════ ENTERPRISE POLISH ══════════════════
   App shell (topbar, sidebar, page header) + course library. Presentation only. */
.topbar {
  height: 56px;
  background: var(--surface);
  padding: 0 var(--space-6);
  justify-content: flex-start;
  gap: var(--space-2);
}
.topbar-right { margin-left: auto; }
.brand { font-weight: 700; font-size: var(--text-md); letter-spacing: -0.01em; }

.sidenav {
  width: 248px;
  background: var(--surface);
  padding: var(--space-4) var(--space-3);
  gap: 2px;
}
.sidenav-section { margin-top: var(--space-6); }
.sidenav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}
.nav-btn {
  gap: var(--space-3);
  min-height: 40px;
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  border-left: none;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink-2);
}
.nav-btn:hover { background: var(--bg-2); color: var(--ink-1); }
.nav-btn.active { background: var(--brand-glow); color: var(--brand); font-weight: 600; border-left: none; }
.nav-btn .nav-icon { width: 18px; height: 18px; opacity: 0.8; }
.nav-btn .nav-icon svg { width: 18px; height: 18px; }
.nav-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.nav-sub { padding-left: 38px; font-size: var(--text-sm); opacity: 1; }
.nav-sub .nav-icon { display: none; }

.main { padding: var(--space-8) var(--space-10); }
.main > .page { max-width: 1240px; margin: 0 auto; }
.page-head { margin-bottom: var(--space-8); }
.page-eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-1);
}
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }

/* Course library */
.courses-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--space-5); }
.sec-chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 4px 4px 4px var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-1);
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; padding: 0;
  background: none; border: 0; border-radius: 50%;
  color: var(--ink-3); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink-1); }
.icon-btn.danger:hover { background: var(--fail-lt); color: var(--danger); }
.icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.icon-btn svg { width: 14px; height: 14px; }
.btn-sm.icon-btn { width: 36px; height: 36px; border-radius: var(--radius-md); }
.btn-sm.icon-btn svg { width: 16px; height: 16px; }

.sec-head {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: var(--space-3);
  margin-top: var(--space-8); padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.sec-head:first-child { margin-top: 0; }
.sec-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; color: var(--ink-1); }
.sec-count { font-size: var(--text-xs); font-weight: 500; color: var(--ink-3); }
.sec-empty {
  grid-column: 1 / -1;
  padding: var(--space-5); text-align: center;
  border: 1px dashed var(--border-2); border-radius: var(--radius-lg);
  font-size: var(--text-sm); color: var(--ink-3);
}

.cc {
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-5);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.cc:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cc-top { display: flex; align-items: flex-start; gap: var(--space-3); }
.cc-icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: var(--radius-lg);
  background: var(--brand-glow); font-size: 22px;
}
.cc-body { min-width: 0; flex: 1; }
.cc-title { font-size: var(--text-md); font-weight: 600; line-height: 1.35; color: var(--ink-1); }
.cc-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-2); flex-wrap: wrap; }
.cc-select {
  width: auto; max-width: 100%; min-height: 32px;
  padding: 4px 28px 4px 10px;
  font-size: var(--text-xs); font-weight: 500;
  border-radius: var(--radius-md);
}
.cc-actions {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: auto; padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}
.cc-actions .btn-primary { flex: 1; }
.cc-actions .btn svg { width: 16px; height: 16px; }
.btn-danger-ghost { color: var(--ink-3); }
.btn-danger-ghost:hover { background: var(--fail-lt); color: var(--danger); }
@media (max-width: 900px) { .main { padding: var(--space-6) var(--space-4); } }


/* ══════════════════ ENTERPRISE POLISH II — data, learner, course player ══════════════════ */
/* Type: retire terminal-style mono labels */
.stat-label { font-family: var(--font-body); font-size: var(--text-sm); font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stat-icon { width: 40px; height: 40px; border-radius: var(--radius-md); }
.stat-tile { padding: var(--space-5) var(--space-6); }
.dash-section-label { font-family: var(--font-body); font-size: var(--text-base); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-1); margin-bottom: var(--space-3); }
.ch-label, .quiz-step { font-family: var(--font-body); }
.quiz-step { font-weight: 600; letter-spacing: 0.06em; }

/* Tables */
thead th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  padding: 12px 16px;
  background: var(--bg-2);
}
tbody td { padding: 14px 16px; vertical-align: middle; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--bg-2); }
.table-wrap { box-shadow: var(--shadow-sm); background: var(--surface); }
.table-wrap .btn-ghost { color: var(--ink-2); }
.table-wrap .icon-btn { color: var(--ink-3); }

/* Quick actions + activity */
.dash-quick { padding: var(--space-5); box-shadow: var(--shadow-sm); }
.quick-action-btn { background: var(--surface); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.quick-action-btn:hover { background: var(--bg-2); border-color: var(--border-2); }
.quick-action-icon { width: 36px; height: 36px; border-radius: var(--radius-md); }
.activity-list { box-shadow: var(--shadow-sm); }

/* Teams */
.teams-sidebar { background: var(--surface); padding: var(--space-3); }
.team-list-item { border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin-bottom: 4px; }
.team-list-item:hover { background: var(--bg-2); }
.team-list-item.active { background: var(--brand-glow); border-left: none; }
.team-list-item.active .team-list-name { color: var(--brand); }
.team-list-name { font-size: var(--text-base); }
.team-list-meta { color: var(--ink-3); }
.team-detail-name { font-size: var(--text-xl); letter-spacing: -0.01em; }

/* Forms / branding */
.page [style*="display:grid"] > .card + .card { margin-top: 0; }
input[type=file]::file-selector-button {
  font: inherit; font-size: var(--text-sm); font-weight: 500;
  padding: 6px 12px; margin-right: var(--space-3);
  border: 1px solid var(--border-2); border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink-1); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--bg-2); }

/* Learner course cards */
.section-header {
  font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  margin-top: var(--space-8); padding-bottom: var(--space-3);
}
.lc { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); }
.lc:hover { transform: translateY(-1px); }
.lc:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.lc-top { display: flex; align-items: flex-start; gap: var(--space-3); }
.lc-icon {
  display: grid; place-items: center; flex-shrink: 0;
  width: 44px; height: 44px; border-radius: var(--radius-lg);
  background: var(--brand-glow); font-size: 22px;
}
.lc-body { min-width: 0; flex: 1; }
.lc-title { font-size: var(--text-md); font-weight: 600; line-height: 1.35; color: var(--ink-1); }
.lc-meta { font-size: var(--text-xs); color: var(--ink-3); margin-top: 2px; }
.lc-desc {
  font-size: var(--text-sm); color: var(--ink-3); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lc-progress { height: 4px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.lc-progress span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.lc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin-top: auto; padding-top: var(--space-3); border-top: 1px solid var(--border);
}
.lc-cta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--brand); }
.lc-cta svg { width: 16px; height: 16px; transition: transform 0.15s ease; }
.lc:hover .lc-cta svg { transform: translateX(3px); }

/* Course player */
.course-header { background: var(--surface); }
.mod-sidebar, .module-nav { background: var(--surface); }
.module-nav-title { color: var(--ink-3); letter-spacing: 0.06em; }
.mod-item { border-radius: var(--radius-md); padding: var(--space-3); }
.mod-item.active { background: var(--brand-glow); }
.mod-item.active .mod-item-title { color: var(--brand); font-weight: 600; }
.mod-bullet { font-family: var(--font-body); }
.module-main, .mod-main { padding: var(--space-10) var(--space-10); }
.module-prose h2 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }
.mod-overview-card { box-shadow: var(--shadow-sm); }
.mod-meta-chip { font-family: var(--font-body); }
.quiz-opt { border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-sm); }
.quiz-opt:hover { border-color: var(--brand); background: var(--surface); }

/* Danger zone + auth screens */
.danger-zone { border-color: var(--fail-border); background: var(--surface); }
.danger-zone .card-title { color: var(--danger); }
#screen-login, #screen-manager-login {
  background:
    radial-gradient(900px 420px at 50% -10%, var(--brand-glow), transparent 70%),
    var(--bg);
}

/* ══════════════════ RESPONSIVE SHELL ══════════════════
   Sidebar collapses to a horizontally scrolling tab strip on tablets/phones. */
@media (max-width: 860px) {
  .app-layout { flex-direction: column; overflow: visible; }
  .screen.active { min-height: 100vh; }
  .sidenav {
    width: 100%; flex-direction: row; align-items: center;
    overflow-x: auto; overflow-y: hidden;
    padding: var(--space-2) var(--space-3);
    border-right: none; border-bottom: 1px solid var(--border);
    gap: var(--space-1);
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .sidenav::-webkit-scrollbar { display: none; }
  .sidenav-section { display: contents; margin: 0; }
  .sidenav-label { display: none; }
  .nav-btn, .nav-sub {
    width: auto; flex-shrink: 0; white-space: nowrap;
    padding: 8px var(--space-3); min-height: 40px;
  }
  .nav-sub .nav-icon { display: flex; }
  .main { padding: var(--space-6) var(--space-4); overflow: visible; }
  .topbar { padding: 0 var(--space-4); }
  .page-title { font-size: 24px; }
  .courses-grid { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
  .cc-actions { flex-wrap: wrap; }
  .cc-actions .btn-primary { flex: 1 1 100%; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .teams-layout { grid-template-columns: 1fr; height: auto; max-height: none; }
  .teams-sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 220px; }
  .module-main, .mod-main { padding: var(--space-6) var(--space-4); }
  .course-body { flex-direction: column; }
  .module-nav, .mod-sidebar { width: 100%; max-height: 180px; border-right: none; border-bottom: 1px solid var(--border); }
}
@media (max-width: 520px) {
  .topbar-right .btn { padding-left: var(--space-2); padding-right: var(--space-2); }
  .page-head-row > div:last-child { width: 100%; }
}

/* Modals on small screens */
@media (max-width: 600px) {
  .modal { max-width: calc(100vw - 24px); }
  .modal-foot { flex-wrap: wrap; }
}

/* ══════════════════ ENTERPRISE POLISH III — icons, empty states, global interaction ══════════════════ */
.theme-toggle svg, .upload-icon svg, .empty-icon svg, .source-banner-icon svg { display: block; }
.theme-toggle { width: 40px; height: 40px; border-radius: 999px; background: var(--surface); border-color: var(--border); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle:hover { color: var(--ink-1); border-color: var(--border-2); }

/* Empty states */
.empty { border-style: dashed; border-color: var(--border-2); background: var(--surface); }
.empty-icon {
  display: grid; place-items: center;
  width: 56px; height: 56px; margin: 0 auto var(--space-4);
  border-radius: 50%; background: var(--brand-glow); color: var(--brand);
  font-size: 0; opacity: 1;
}
.empty-icon svg { width: 26px; height: 26px; }
.empty-title { letter-spacing: -0.01em; }

/* Upload zone */
.upload-zone { border-radius: var(--radius-lg); background: var(--surface); }
.upload-icon {
  display: grid; place-items: center;
  width: 48px; height: 48px; margin: 0 auto var(--space-3);
  border-radius: 50%; background: var(--brand-glow); color: var(--brand); font-size: 0;
}
.upload-icon svg { width: 22px; height: 22px; }

/* Source banner in the course player */
.source-banner-icon {
  display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; margin-top: 0;
  border-radius: var(--radius-md); background: var(--brand-glow); color: var(--brand); font-size: 0;
}
.source-banner-icon svg { width: 18px; height: 18px; }

/* Toasts */
.toast { background: var(--surface); border-color: var(--border); border-radius: var(--radius-lg); padding: 12px 16px; box-shadow: var(--shadow-lg); font-weight: 500; }

/* Global interaction polish */
::selection { background: var(--brand-glow); color: var(--ink-1); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; cursor: pointer; }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
.btn { font-weight: 600; }
.btn-outline { background: var(--surface); }
.btn-outline:hover { border-color: var(--ink-4); }
.page-sub + .upload-zone, .page-sub + .card { margin-top: var(--space-4); }
.qr-score { font-family: var(--font-body); font-weight: 700; letter-spacing: -0.03em; }

/* ══════════════════ PREGAME ACADEMY SKIN ══════════════════
   Matches the Pregame site (pregame.vickerydigital.com): brand black + electric blue,
   aurora hero, uppercase tracked labels, 6px buttons, 16px cards, system font stack. */
:root {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --btn-radius: 6px;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 16px; --radius-xl: 20px;

  /* dark surfaces */
  --bg: #05060a; --bg-2: #0a0c13; --surface: #0e1118; --surface-2: #151a24; --surface-raised: #151a24;
  --border: #1f2531; --border-2: #2b3342;
  --ink-1: #f2f5fb; --ink-2: #c4cad8; --ink-3: #8e97a9; --ink-4: #6b7488;

  /* brand (runtime-overridden by Admin → Branding) */
  --brand: #1565ff; --brand-dark: #0f48c4; --brand-glow: rgba(21,101,255,0.16);
  --shadow-brand: 0 0 0 3px rgba(21,101,255,0.28);
  --brand-secondary: #1b1a5c; --brand-secondary-dark: #12113f; --brand-secondary-glow: rgba(27,26,92,0.35);
  --brand-accent: #d99100; --brand-accent-dark: #b07400; --brand-accent-glow: rgba(217,145,0,0.16);
  --brand-hi: #6aa2ff;                        /* kicker / highlight on black */

  /* text-safe accent (WCAG AA on each surface) */
  --accent: #4d8dff; --accent-strong: #8db6ff; --why-bg: #0f1d3d; --why-text: #c3d6ff;

  --shadow-sm: none; --shadow-md: 0 10px 40px rgba(0,0,0,.5); --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
  --hero: radial-gradient(700px 320px at 12% 118%, rgba(91,61,245,.55), transparent 70%),
          radial-gradient(760px 300px at 52% 125%, rgba(21,101,255,.6), transparent 70%),
          radial-gradient(520px 240px at 96% 122%, rgba(70,150,90,.28), transparent 70%),
          radial-gradient(420px 200px at 82% 130%, rgba(190,140,30,.22), transparent 70%),
          linear-gradient(180deg, #000 0%, #000 38%, #070626 80%, #0d0b3a 100%);
}
[data-theme="light"] {
  --bg: #f3f5fa; --bg-2: #eceff6; --surface: #ffffff; --surface-2: #f7f8fc; --surface-raised: #ffffff;
  --border: #e3e8f2; --border-2: #cdd5e4;
  --ink-1: #0b1220; --ink-2: #3b4559; --ink-3: #667086; --ink-4: #8a93a7;
  --accent: #1260f0; --accent-strong: #0f48c4; --why-bg: #eaf0ff; --why-text: #17368f;
  --brand-glow: rgba(21,101,255,0.12);
  --shadow-sm: 0 1px 2px rgba(11,18,32,.05), 0 6px 18px rgba(11,18,32,.05);
  --shadow-md: 0 4px 16px rgba(11,18,32,.10); --shadow-lg: 0 10px 40px rgba(11,18,32,.18);
}
body { font-family: var(--font-body); }

/* ── Topbar: brand black, tracked wordmark, outlined actions ── */
.topbar { background: #000; border-bottom: 1px solid #1f2531; height: 60px; }
.brand { color: #fff; font-size: 17px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.brand::before { content: ''; width: 28px; height: 28px; border-radius: 8px; transform: none; background: url('../assets/pregame-icon-192.png') center / cover; }
.brand-logo { height: 28px; width: auto; border-radius: 8px; }
.topbar .user-pill { color: rgba(255,255,255,.85); }
.topbar .btn-ghost {
  min-height: 36px; padding: 0 14px; border-radius: var(--btn-radius);
  border: 1px solid rgba(255,255,255,.28); background: transparent; color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.topbar .btn-ghost:hover { background: rgba(255,255,255,.18); color: #fff; }
.topbar .chip { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.2); color: rgba(255,255,255,.92); border-radius: 4px; }
.topbar .chip-amber { background: rgba(255,190,40,.18); border-color: rgba(255,200,80,.4); color: #ffe5a8; }

/* ── Sidebar ── */
.sidenav { background: var(--surface); }
.sidenav-label { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.nav-btn { font-weight: 550; border-radius: 10px; color: var(--ink-2); }
.nav-btn:hover { background: var(--bg-2); color: var(--ink-1); }
.nav-btn.active { background: var(--why-bg); color: var(--accent-strong); font-weight: 600; }

/* ── Page header = aurora hero (continues the black topbar) ── */
.main { padding-top: 0; }
.main > .page { max-width: none; margin: 0; }
.page > :not(.page-head) { max-width: 1240px; margin-left: auto; margin-right: auto; }
.page-head {
  --edge: max(var(--space-10), calc((100% - 1240px) / 2 + var(--space-10)));
  margin: 0 calc(-1 * var(--space-10)) var(--space-8);
  padding: var(--space-8) var(--edge) var(--space-10);
  background: var(--hero); color: #fff;
}
.page-head .page-eyebrow { color: var(--brand-hi); font-weight: 700; letter-spacing: .16em; }
.page-head .page-title { color: #fff; font-size: clamp(30px, 4vw, 44px); font-weight: 560; letter-spacing: -.03em; line-height: 1.04; }
.page-head .page-sub { color: rgba(255,255,255,.8); }
.page-head .btn-outline, .page-head .btn-ghost {
  background: transparent; color: #fff; border-color: rgba(255,255,255,.28);
}
.page-head .btn-outline:hover, .page-head .btn-ghost:hover { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.4); }
.page-head select, .page-head input[type=date], .page-head input[type=search], .page-head input[type=text] {
  background-color: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); color: #fff; color-scheme: dark;
}
.page-head select option { background: #0e1118; color: #f2f5fb; }
.page-head select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23c4cad8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.page-head #comp-pass-rate { color: rgba(255,255,255,.85) !important; }
@media (max-width: 860px) {
  .main { padding-top: 0; }
  .page-head { margin: 0 calc(-1 * var(--space-4)) var(--space-6); padding: var(--space-6) var(--space-4) var(--space-8); }
}

/* ── Surfaces, buttons, chips ── */
.card, .stat-tile, .table-wrap, .dash-quick, .activity-list, .modal { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.btn { border-radius: var(--btn-radius); font-weight: 600; letter-spacing: 0; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.chip { border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; }
.chip-blue { background: var(--why-bg); color: var(--accent-strong); border-color: transparent; }
.chip-amber { background: rgba(217,145,0,.14); color: #d99100; border-color: rgba(217,145,0,.3); }
[data-theme="light"] .chip-amber { background: #fff2d1; color: #7a5200; border-color: transparent; }
.chip-green { text-transform: uppercase; }

/* text-safe accent for links and active states */
.link-cell, .lc-cta, .role-tile-cta, .ldg-demo:hover, .page-eyebrow { color: var(--accent); }
.mod-item.active .mod-item-title, .team-list-item.active .team-list-name { color: var(--accent-strong); }
.team-list-item.active, .mod-item.active { background: var(--why-bg); }
.icon-btn:hover { color: var(--ink-1); }
a { color: var(--accent); }

/* ── Landing: black aurora hero, tiles overlap the edge ── */
#screen-landing { position: relative; justify-content: flex-start; padding: 0 var(--space-4) var(--space-12); background: var(--bg); }
#screen-landing::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 460px; background: var(--hero); z-index: 0; }
#screen-landing .landing-wrap { position: relative; z-index: 1; max-width: 960px; padding-top: 72px; }
.ldg-head { margin-bottom: var(--space-10); min-height: 300px; text-align: left; }
.ldg-logo-wrap { justify-content: flex-start; margin-bottom: var(--space-5); }
.ldg-logo-img { max-height: 56px; border-radius: 12px; }
.ldg-kicker { font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--brand-hi); margin-bottom: var(--space-2); }
.landing-logo { color: #fff !important; font-size: clamp(36px, 6vw, 64px); font-weight: 560; letter-spacing: -.03em; line-height: 1.02; }
.landing-sub { color: rgba(255,255,255,.88); font-size: clamp(16px, 1.9vw, 19px); line-height: 1.5; margin: var(--space-4) 0 0; max-width: 60ch; }
.ldg-org { color: var(--brand-hi); }
.role-tile { border-radius: var(--radius-lg); }
.role-tile-primary .role-tile-icon { background: var(--brand); color: #fff; }
.role-tile-icon { background: var(--why-bg); color: var(--accent); }
.landing-foot { text-align: left; }
.ldg-demo { margin-left: calc(-1 * var(--space-3)); }

/* ── Login screens: same hero band ── */
#screen-login, #screen-manager-login { position: relative; background: var(--bg); }
#screen-login::before, #screen-manager-login::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 340px; background: var(--hero); }
#screen-login .login-wrap, #screen-manager-login .login-wrap { position: relative; z-index: 1; }
.login-title { color: #fff; font-weight: 560; letter-spacing: -.03em; }
.login-sub { color: rgba(255,255,255,.8); }

/* ── Course player header ── */
.course-header { background: #000; border-bottom: 1px solid #1f2531; color: #fff; }
.course-header .ch-meta, .course-header-meta, .course-header #ch-label { color: rgba(255,255,255,.8); }
.course-header .btn-outline, .course-header .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.28); }
.course-header .btn-outline:hover, .course-header .btn-ghost:hover { background: rgba(255,255,255,.18); }
.course-header .progress-track { background: rgba(255,255,255,.18); }
.qr-score.qr-pass { color: var(--success); }

/* ── Quiz / modules pick up the accent ── */
.quiz-opt:hover { border-color: var(--accent); }
.mod-item.active .mod-bullet { border-color: var(--accent); color: var(--accent); }
#screen-landing .landing-wrap { text-align: left; }

#screen-join { position: relative; background: var(--bg); }
#screen-join::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 340px; background: var(--hero); }
#screen-join .login-wrap { position: relative; z-index: 1; }

/* ══════════════════ POLISH IV — loading, sorting, landing, a11y, certificate ══════════════════ */
/* Skeleton loaders */
.skeleton {
  display: block; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--border) 37%, var(--bg-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.courses-grid > .card[aria-hidden], .stats-row > .stat-tile[aria-hidden] { box-shadow: none; }

/* Sortable table headers */
.table-wrap thead th { cursor: pointer; user-select: none; white-space: nowrap; }
.table-wrap thead th:hover { color: var(--ink-1); }
.table-wrap thead th[aria-sort]::after { content: ' ↑'; color: var(--accent); }
.table-wrap thead th[aria-sort="descending"]::after { content: ' ↓'; }
.table-wrap thead th:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table-wrap thead th:empty, .table-wrap thead th:has(input) { cursor: default; }

/* Accessibility: muted text meets 4.5:1 on its surface */
[data-theme="light"] { --ink-3: #5a6478; --ink-4: #667086; }
:root:not([data-theme="light"]) { --ink-4: #7d869a; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Landing: value strip + footer anchored to the bottom */
#screen-landing { min-height: 100vh; }
#screen-landing .landing-wrap { flex: 1; display: flex; flex-direction: column; }
.ldg-features {
  list-style: none; margin: var(--space-10) 0 var(--space-6); padding: var(--space-6) 0 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-6);
  border-top: 1px solid var(--border);
}
.ldg-features li { display: flex; gap: var(--space-3); text-align: left; }
.ldg-features strong { display: block; color: var(--ink-1); font-size: var(--text-md); font-weight: 600; margin-bottom: 2px; }
.ldg-features span:not(.ldg-feat-icon) { color: var(--ink-3); font-size: var(--text-sm); line-height: 1.5; }
.ldg-feat-icon {
  flex-shrink: 0; display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--radius-md); background: var(--why-bg); color: var(--accent);
}
.ldg-feat-icon svg { width: 20px; height: 20px; }
.landing-foot { margin-top: auto; padding-top: var(--space-8); max-width: 62ch; }
@media (max-width: 720px) { .ldg-features { grid-template-columns: 1fr; gap: var(--space-4); } }

/* Certificate: always a light sheet (so PDFs are consistent in dark mode), Pregame typography */
#cert-sheet {
  --surface: #ffffff; --ink-1: #0b1220; --ink-2: #3b4559; --ink-3: #5a6478;
  --border: #e3e8f2; --border-2: #cdd5e4;
  background: #fff; color: #0b1220;
}
#cert-sheet .cert-accent-bar { height: 10px; background: var(--hero); }
.cert-org-name { letter-spacing: .16em; font-weight: 800; }
.cert-heading { font-weight: 560; letter-spacing: -.03em; }
.cert-of, .cert-meta-label { font-family: var(--font-body); font-weight: 700; letter-spacing: .14em; }
.ldg-links { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin-bottom: var(--space-2); }
.ldg-links .ldg-demo { margin: 0 0 0 calc(-1 * var(--space-3)); padding: var(--space-2) var(--space-3); }
#c-name { color: var(--ink-1) !important; }
#c-org { color: var(--brand) !important; }
#cert-sheet { padding: 0; overflow: hidden; }
#cert-sheet .cert-accent-bar { border-radius: 0; }
.cert-org-name, .cert-sig-label { font-family: var(--font-body); }
