/* ============================================================================
   Admin dashboard — "Chalkboard" theme.
   Warm paper, deep-green academic accent. Consumes design tokens from theme.css.
   The admin's own token names below are REMAPPED onto the shared Chalkboard
   palette, so every existing rule and inline style restyles without renaming a
   single class — preserving all admin-*.js DOM hooks.
   ============================================================================ */

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: radial-gradient(120% 70% at 50% 0%, var(--sidebar) 0%, var(--bg) 45%);
  background-attachment: fixed;
}
button { font-family: inherit; cursor: pointer; }
input  { font-family: inherit; }
a      { color: inherit; text-decoration: none; }

/* ── Legacy admin tokens remapped onto the Chalkboard system (theme.css) ──
   theme.css defines the source palette (--green, --bg, --ink, --ok/--warn/--bad …).
   These aliases translate the admin's original dark-theme token names to it.  */
:root {
  --ink:       var(--text);        /* strong body text  */
  --ink-dim:   var(--muted);       /* labels, meta      */
  --ink-faint: var(--muted-2);     /* placeholders      */
  --surface:   var(--card);        /* panels, cards     */
  --surface-2: var(--panel-warm);  /* insets, hover     */
  --surface-3: var(--sidebar);     /* pills, tracks     */
  --border-hi: var(--border-input);
  --accent:    var(--green);
  --accent-hi: var(--green);
  --accent-bg: var(--green-soft);
  --green-bg:  var(--ok-bg);
  --red:       var(--bad);
  --red-bg:    var(--bad-bg);
  --amber:     var(--warn);
}

/* ── Layout shell ── */
.shell { display: flex; flex: 1; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.logo-mark {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font: 700 15px/1 var(--font-serif); color: #faf8f4; flex-shrink: 0;
}
.logo-text { font: 600 15px var(--font-serif); color: var(--ink); letter-spacing: -.01em; }
.logo-sub  { font-size: 11px; color: var(--ink-dim); margin-top: 1px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 1.25rem;
  font-size: 13.5px; color: var(--ink-dim);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
  user-select: none;
}
.nav-item:hover { color: var(--ink); background: var(--accent-bg); }
.nav-item.active { color: var(--ink); border-left-color: var(--accent); background: var(--accent-bg); }
.nav-icon { width: 16px; text-align: center; flex-shrink: 0; font-size: 15px; }

.nav-count {
  margin-left: auto;
  background: var(--surface-3);
  color: var(--ink-dim);
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 99px;
}
.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
}
.api-url-label { font-size: 11px; color: var(--ink-dim); margin-bottom: 4px; }
.api-url-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ink-dim);
  outline: none;
  transition: border-color .15s;
}
.api-url-input:focus { border-color: var(--accent); color: var(--ink); }

/* ── Main content ── */
.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center;
  padding: 0 2rem;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font: 600 17px var(--font-serif); color: var(--ink); }
.topbar-sub   { font-size: 13px; color: var(--ink-dim); margin-left: 10px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── Panels ── */
.panel { display: none; flex: 1; padding: 2rem; }
.panel.active { display: flex; flex-direction: column; gap: 1.5rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border-input);
  background: var(--card);
  color: var(--text-2);
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover  { background: var(--bg); border-color: var(--muted-2); color: var(--ink); }
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--green); border-color: var(--green); color: #faf8f4;
}
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-hover); color: #faf8f4; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--card); border-color: var(--border); color: var(--ink); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── Upload zone ── */
.upload-zone {
  border: 1.5px dashed var(--border-hi);
  border-radius: 12px;
  background: var(--surface);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.upload-headline { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.upload-sub { font-size: 13px; color: var(--ink-dim); }
.upload-sub strong { color: var(--accent); }

/* ── Format hint ── */
.format-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.25rem;
}
.format-card h4 { font-size: 12px; font-weight: 600; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.format-card pre { font-family: "SF Mono", "Fira Code", Consolas, monospace; font-size: 12px; color: var(--ink-dim); line-height: 1.9; }
.format-card pre span { color: var(--accent-hi); }

/* ── File ready state ── */
.file-ready {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  align-items: center; gap: 12px;
}
.file-ready.show { display: flex; }
.file-icon { font-size: 1.75rem; }
.file-name { font-size: 14px; font-weight: 500; }
.file-meta { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.file-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── Preview panel ── */
.preview-header {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.preview-header h2 { font-size: 16px; font-weight: 600; flex: 1; min-width: 200px; }
.title-input {
  flex: 1; min-width: 180px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 14px; color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.title-input:focus { border-color: var(--accent); }
.title-input::placeholder { color: var(--ink-faint); }

.q-list { display: flex; flex-direction: column; gap: 10px; }
.q-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}
.q-item-num { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-dim); margin-bottom: 6px; }
.q-item-text { font-size: 14px; color: var(--ink); margin-bottom: 10px; line-height: 1.5; }
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.q-opt {
  font-size: 12.5px; padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--ink-dim);
  background: var(--surface-2);
}
.q-opt.correct { border-color: var(--green); color: var(--green); background: var(--green-bg); }

/* ── Library table ── */
.lib-empty {
  text-align: center; padding: 4rem 1rem;
  color: var(--ink-dim); font-size: 14px;
}
.lib-empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }

.quiz-table { width: 100%; border-collapse: collapse; }
.quiz-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.quiz-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.quiz-table tr:last-child td { border-bottom: none; }
.quiz-table tr:hover td { background: var(--surface-2); }
.td-title { font-weight: 500; color: var(--ink); }
.td-meta  { color: var(--ink-dim); font-size: 12.5px; }
.td-badge {
  display: inline-block;
  background: var(--accent-bg); color: var(--accent-hi);
  font-size: 11.5px; font-weight: 600;
  padding: 2px 10px; border-radius: 99px;
}
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Snippet drawer ── */
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 50;
  animation: fadeIn .2s ease;
}
.drawer-overlay.open { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed;
  top: 0; right: -520px; bottom: 0;
  width: 480px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 51;
  display: flex; flex-direction: column;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  padding: 1.5rem;
}
.drawer.open { right: 0; }

.drawer-head {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 1.5rem;
}
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-sub   { font-size: 13px; color: var(--ink-dim); margin-top: 3px; }
.drawer-close {
  margin-left: auto; font-size: 18px;
  background: none; border: none; color: var(--ink-dim);
  cursor: pointer; padding: 2px 6px;
  line-height: 1; border-radius: 4px;
  transition: color .15s, background .15s;
}
.drawer-close:hover { color: var(--ink); background: var(--surface-2); }

.snippet-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-dim); margin-bottom: 8px;
}
.snippet-block {
  background: #23271f;                /* dark code block reads well on warm paper */
  border: 1px solid #33372d;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.8;
  color: #d8dccb;
  white-space: pre;
  overflow-x: auto;
  margin-bottom: .75rem;
  position: relative;
}
.snippet-block .s-cm  { color: #565f89; }
.snippet-block .s-tag { color: #7aa2f7; }
.snippet-block .s-attr{ color: #9ece6a; }
.snippet-block .s-val { color: #e0af68; }
.snippet-copy {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; padding: 3px 10px;
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #d8dccb;
}
.snippet-copy:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); color: #fff; }

.drawer-divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.steps-label { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.step {
  display: flex; gap: 12px;
  margin-bottom: 14px;
}
.step-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-bg); color: var(--accent-hi);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.step-text { font-size: 13px; color: var(--ink-dim); line-height: 1.6; }
.step-text strong { color: var(--ink); }

/* ── Toast ── */
.toast-wrap {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13.5px;
  color: #faf8f4;
  box-shadow: 0 8px 28px rgba(47,45,35,.22);
  animation: toastIn .22s ease forwards;
  pointer-events: auto;
}
.toast.ok   { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok), 0 8px 28px rgba(47,45,35,.22); }
.toast.err  { border-color: var(--bad); color: #f4c9be; box-shadow: 0 0 0 1px var(--bad), 0 8px 28px rgba(47,45,35,.22); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ── Stat row (library header) ── */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1.25rem;
  min-width: 130px;
  box-shadow: var(--shadow-card);
}
.stat-val   { font: 700 24px/1 var(--font-serif); color: var(--ink); }
.stat-label { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }

/* ── Section card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.card-body { padding: 1.25rem 1.5rem; }

.section-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-dim); margin-bottom: 1rem;
}

/* scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 99px; }

/* ── Confirm / remove-from-quiz modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 60;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.75rem 1.5rem;
  width: 100%; max-width: 480px;
  max-height: 90vh;
  display: flex; flex-direction: column; gap: 1rem;
}
.modal-title { font-size: 15px; font-weight: 600; flex-shrink: 0; }
.modal-body  { font-size: 13px; color: var(--ink-dim); line-height: 1.6; overflow-y: auto; flex: 1; min-height: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: .25rem; flex-shrink: 0; }
.quiz-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.quiz-check-item:hover { border-color: var(--border-hi); background: var(--surface-2); }
.quiz-check-item.checked { border-color: var(--accent); background: var(--accent-bg); }
.quiz-check-item input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ── Question bank ── */
.bank-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.bank-row:hover { border-color: var(--border-hi); background: var(--surface-2); }
.bank-row.selected { border-color: var(--accent); background: var(--accent-bg); }
.bank-row-topic {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--accent-hi); margin-bottom: 4px;
}
.bank-row-text { font-size: 13.5px; color: var(--ink); line-height: 1.4; }
.bank-row-opts { font-size: 12px; color: var(--ink-dim); margin-top: 4px; }
.bank-topic-header {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-dim);
  padding: .5rem 0 .25rem; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

/* ── Assignments panel ── */
.assign-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.assign-row:last-child { border-bottom: none; }
.assign-class {
  font-size: 13px; font-weight: 700;
  background: var(--accent-bg); color: var(--accent-hi);
  padding: 2px 10px; border-radius: 99px; display: inline-block;
}
.assign-meta { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.results-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: var(--surface-2); }
.pct-badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
}
.pct-high { background: var(--ok-bg);   color: var(--ok); }
.pct-mid  { background: var(--warn-bg); color: var(--warn); }
.pct-low  { background: var(--bad-bg);  color: var(--bad); }

/* ── Team panel ── */
.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) { .team-grid { grid-template-columns: 1fr; } }
.team-section-title {
  font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: .75rem; display: flex; align-items: center; gap: 8px;
}
.subject-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1rem;
  margin-bottom: 8px;
}
.subject-card-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.subject-name { font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; }
.subject-pill {
  font-size: 11px; padding: 2px 9px; border-radius: 99px;
  background: var(--accent-bg); color: var(--accent-hi); font-weight: 500;
}
.subject-topics {
  display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px;
}
.topic-tag {
  font-size: 11.5px; padding: 3px 10px; border-radius: 99px;
  background: var(--surface-3); color: var(--ink-dim);
  border: 1px solid var(--border);
}
.subject-teachers { font-size: 12px; color: var(--ink-dim); }
.teacher-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 6px;
}
.teacher-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-bg); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent-hi);
  flex-shrink: 0;
}
.teacher-email { font-size: 13px; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.teacher-role  { font-size: 11px; color: var(--ink-dim); }
.inline-form { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.inline-input {
  flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 13px; color: var(--ink);
  outline: none; font-family: inherit;
}
.inline-input:focus { border-color: var(--accent); }

/* ── Results panel ── */
.ra-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px; cursor: pointer;
  transition: background .15s;
}
.ra-row:last-child { border-bottom: none; }
.ra-row:hover { background: var(--surface-2); }
.ra-title { font-weight: 600; color: var(--ink); }
.ra-meta  { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }

.sr-row {
  border-bottom: 1px solid var(--border);
}
.sr-row:last-child { border-bottom: none; }
.sr-head {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 80px 28px;
  align-items: center; gap: 10px;
  padding: 11px 16px;
  cursor: pointer; transition: background .15s;
  font-size: 13px;
}
.sr-head:hover { background: var(--surface-2); }
.sr-expand-icon { color: var(--ink-dim); font-size: 11px; text-align:center; transition: transform .2s; }
.sr-expand-icon.open { transform: rotate(90deg); }
.sr-detail {
  display: none;
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.sr-detail.open { display: block; }

.topic-bar-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px; font-size: 12px;
}
.topic-bar-label { width: 160px; flex-shrink: 0; color: var(--ink-dim); }
.topic-bar-track {
  flex: 1; height: 6px; border-radius: 99px;
  background: var(--surface-3); overflow: hidden;
}
.topic-bar-fill  { height: 100%; border-radius: 99px; background: var(--accent); }
.topic-bar-pct   { width: 36px; text-align: right; color: var(--ink); font-weight: 600; }

/* ── Analytics tabs ── */
.tab-bar {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: 9px 18px; font-size: 13px; font-weight: 500;
  color: var(--ink-dim); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

/* analytics grid */
.an-stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 1.25rem;
}
@media (max-width: 800px) { .an-stat-strip { grid-template-columns: repeat(2,1fr); } }

.an-section { margin-bottom: 1.5rem; }
.an-section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-dim);
  margin-bottom: .75rem;
}

/* distribution bars */
.dist-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 7px; font-size: 12.5px;
}
.dist-label { width: 60px; flex-shrink: 0; color: var(--ink-dim); font-size: 12px; }
.dist-track {
  flex: 1; height: 20px; border-radius: 5px;
  background: var(--surface-3); overflow: hidden; position: relative;
}
.dist-fill {
  height: 100%; border-radius: 5px;
  background: var(--accent); opacity: .85;
  transition: width .4s ease;
}
.dist-count {
  width: 24px; flex-shrink: 0;
  color: var(--ink); font-weight: 600; text-align: right;
}

/* topic table */
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.an-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}
.an-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.an-table tr:last-child td { border-bottom: none; }
.an-table tr:hover td { background: var(--surface-2); }

.mini-bar-track {
  width: 90px; height: 6px; border-radius: 99px;
  background: var(--surface-3); overflow: hidden; display: inline-block;
  vertical-align: middle;
}
.mini-bar-fill { height: 100%; border-radius: 99px; }

/* question difficulty rows */
.qd-row {
  border-bottom: 1px solid var(--border);
}
.qd-row:last-child { border-bottom: none; }
.qd-head {
  display: grid;
  grid-template-columns: 36px 1fr 90px 60px 28px;
  align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  transition: background .15s; font-size: 13px;
}
.qd-head:hover { background: var(--surface-2); }
.qd-num { font-size: 11px; font-weight: 700; color: var(--ink-dim); }
.qd-text { color: var(--ink); line-height: 1.4; }
.qd-pct  { font-weight: 700; text-align: right; }
.qd-wrong { font-size: 12px; color: var(--red); text-align: right; }
.qd-chevron { color: var(--ink-dim); font-size: 11px; text-align: center; transition: transform .2s; }
.qd-chevron.open { transform: rotate(90deg); }
.qd-detail {
  display: none; padding: 0 14px 12px 50px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.qd-detail.open { display: block; }
.opt-bar-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--border);
}
.opt-bar-row:last-child { border-bottom: none; }
.opt-letter-sm {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  background: var(--surface-3); color: var(--ink-dim);
}
.opt-letter-sm.correct { background: var(--ok-bg); color: var(--ok); }
.opt-bar-text { flex: 1; color: var(--ink); min-width: 0; }
.opt-bar-track {
  width: 80px; height: 5px; border-radius: 99px;
  background: var(--surface-3); overflow: hidden; flex-shrink: 0;
}
.opt-bar-fill { height: 100%; border-radius: 99px; background: var(--accent); opacity: .75; }
.opt-bar-count { width: 24px; text-align: right; color: var(--ink-dim); font-weight: 600; flex-shrink: 0; }

/* ── Class report ── */
.cr-class-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
  font-size: 13.5px;
}
.cr-class-btn:last-child { border-bottom: none; }
.cr-class-btn:hover { background: var(--surface-2); }
.cr-class-label { font-weight: 700; color: var(--accent-hi); font-size: 13px; }
.cr-class-meta  { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }

/* Student matrix table */
.cr-matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cr-matrix th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-dim); padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.cr-matrix th.cr-assign-th { text-align: center; max-width: 80px; }
.cr-matrix td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cr-matrix tr:last-child td { border-bottom: none; }
.cr-matrix tr:hover td { background: var(--surface-2); }
.cr-avg-cell { text-align: center; font-weight: 700; }
.cr-score-cell { text-align: center; }

/* Trend bars */
.cr-trend-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; font-size: 12.5px;
}
.cr-trend-label { width: 160px; flex-shrink: 0; color: var(--ink); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-trend-track {
  flex: 1; height: 20px; border-radius: 5px;
  background: var(--surface-3); overflow: hidden; position: relative;
}
.cr-trend-fill { height: 100%; border-radius: 5px; background: var(--accent); opacity: .85; transition: width .4s ease; }
.cr-trend-pct { width: 40px; flex-shrink: 0; text-align: right; font-weight: 700; }
.cr-trend-n { width: 70px; flex-shrink: 0; color: var(--ink-dim); font-size: 11px; }

/* ── Auth screen ── */
.auth-screen {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg);
  background-image: radial-gradient(120% 80% at 50% 0%, var(--sidebar) 0%, var(--bg) 55%);
  z-index: 200;
  align-items: center; justify-content: center;
}
.auth-screen.visible { display: flex; }
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  display: flex; flex-direction: column; gap: 1.25rem;
  box-shadow: 0 18px 50px rgba(47,45,35,.12);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: .25rem;
}
.auth-logo-mark {
  width: 34px; height: 34px;
  background: var(--accent); border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font: 700 17px/1 var(--font-serif); color: #faf8f4;
}
.auth-logo-text { font: 700 17px var(--font-serif); color: var(--ink); }
.auth-tagline { font-size: 13px; color: var(--ink-dim); }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: 12px; font-weight: 500; color: var(--ink-dim); }
.auth-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 14px; color: var(--ink);
  outline: none; width: 100%;
  transition: border-color .15s;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--ink-faint); }
.auth-error {
  font-size: 13px; color: var(--red);
  background: var(--red-bg);
  border: 1px solid var(--red);
  border-radius: 7px; padding: 8px 12px;
  display: none;
}
.auth-error.visible { display: block; }
.auth-submit {
  width: 100%; justify-content: center;
  padding: 10px; font-size: 14px;
}
.auth-switch { font-size: 12.5px; color: var(--ink-dim); text-align: center; }
.auth-switch span { color: var(--accent); cursor: pointer; }
.auth-switch span:hover { color: var(--accent-hi); }

/* ── User chip in sidebar footer ── */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: .75rem 1.25rem;
  margin-bottom: .5rem;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-bg); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent-hi);
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-email { font-size: 11.5px; color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 10.5px; color: var(--ink-dim); }
.logout-btn {
  background: none; border: none;
  color: var(--ink-dim); font-size: 15px;
  cursor: pointer; padding: 2px 4px; border-radius: 4px;
  transition: color .15s;
}
.logout-btn:hover { color: var(--red); }
