/* ==========================================================================
   SGF Quiz - admin panel
   Plain CSS, no build step. Light by default, dark via [data-theme="dark"]
   (set from the toggle, falling back to the OS setting).
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --ink: #14161f;
  --ink-2: #565d70;
  --ink-3: #868ca0;
  --line: #e7e9f0;
  --line-strong: #d3d7e2;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --good: #006c10;
  --good-soft: #e6f6e8;
  --warn: #8a5400;
  --warn-soft: #fff3d6;
  --bad: #b3261e;
  --bad-soft: #fdeceb;
  --info: #1757ac;
  --info-soft: #e8f1fd;
  /* chart tokens (series-1 = blue, validated reference palette) */
  --series-1: #257de0;
  --grid: #e7e7e7;
  --baseline: #c2c2c2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 22, 31, .04), 0 8px 24px -12px rgba(20, 22, 31, .10);
  --sidebar-w: 236px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1016;
  --surface: #161922;
  --surface-2: #1b1f2a;
  --ink: #eceef6;
  --ink-2: #a3a9bc;
  --ink-3: #747b90;
  --line: #262a37;
  --line-strong: #353a4b;
  --accent: #8189ff;
  --accent-hover: #9aa0ff;
  --accent-ink: #0e1016;
  --accent-soft: rgba(129, 137, 255, .14);
  --good: #53c556;
  --good-soft: rgba(83, 197, 86, .13);
  --warn: #fbb315;
  --warn-soft: rgba(251, 179, 21, .13);
  --bad: #ff8a84;
  --bad-soft: rgba(255, 138, 132, .13);
  --info: #84b9f3;
  --info-soft: rgba(132, 185, 243, .13);
  --series-1: #338ced;
  --grid: #303030;
  --baseline: #474747;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .5);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--ink); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
  transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #4338ca); color: #fff; font-weight: 700; letter-spacing: -.02em;
}
.brand b { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { color: var(--ink-3); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; overflow-y: auto; }
.nav-label { padding: 14px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; text-transform: uppercase; }
.me b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: var(--ink-3); font-size: 12px; }
.foot-actions { display: flex; gap: 8px; }
.foot-actions form { flex: 1; margin: 0; }
.foot-actions form .btn { width: 100%; white-space: nowrap; }
.foot-actions .btn-icon { flex: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 16px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid transparent;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 22px; letter-spacing: -.02em; }
.topbar p { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .menu-btn { display: none; }
.content { padding: 8px 28px 56px; max-width: 1280px; }
.scrim { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 12, 20, .5); z-index: 35; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .topbar { flex-wrap: wrap; row-gap: 12px; }
  .topbar-title { flex: 1 1 0; }
  .topbar-actions { flex: 1 1 100%; justify-content: flex-start; }
  .topbar-actions:empty { display: none; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; line-height: 1.2; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 8px; }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head h2 { font-size: 16px; letter-spacing: -.01em; }
.card-head p { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.card-body { padding: 18px 20px 20px; }
.card-flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 18px; }
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }   /* minmax: a wide table inside must scroll, not stretch the page */
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 10px; line-height: 1.1; }
.stat-note { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table td:first-child { min-width: 170px; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; }
.row-actions { display: inline-flex; gap: 4px; }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty .i { width: 34px; height: 34px; color: var(--ink-3); margin: 0 auto 10px; }
.empty h3 { font-size: 16px; margin-bottom: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-live { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-upcoming { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-ended { background: var(--surface-2); color: var(--ink-2); }
.badge-draft, .badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge-good { background: var(--good-soft); color: var(--good); border-color: transparent; }

/* ---------- filters (one row above content) ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .control, .filters .select { width: auto; min-width: 150px; padding: 8px 12px; }
.search { position: relative; flex: 1 1 220px; max-width: 340px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.search .control { padding-left: 36px; width: 100%; }

/* ---------- forms ---------- */
.control, .select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.control::placeholder { color: var(--ink-3); }
.control:hover, .select:hover { border-color: var(--ink-3); }
.control:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.control { resize: vertical; min-height: 84px; }
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 13.5px; }
.help { color: var(--ink-3); font-size: 12.5px; }
.errors { color: var(--bad); font-size: 13px; font-weight: 500; }
.field.has-error .control, .field.has-error .select { border-color: var(--bad); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 6px; }
.form-actions .push { margin-left: auto; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.narrow { max-width: 760px; }

/* answer options with a "correct" radio */
.options { display: grid; gap: 10px; }
.option-row { display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: start; }
.option-pick { position: relative; }
.option-pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.option-pick span {
  width: 38px; height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); display: grid; place-items: center;
  font-weight: 700; color: var(--ink-3); background: var(--surface); transition: all .15s;
}
.option-pick input:checked + span { background: var(--good); border-color: var(--good); color: #fff; }
:root[data-theme="dark"] .option-pick input:checked + span { color: #0e1016; }
.option-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.option-row.is-correct .control { border-color: var(--good); }

/* image upload */
.dropzone-hint { display: grid; gap: 8px; justify-items: center; }
.dropzone {
  position: relative; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2);
  padding: 18px; display: grid; gap: 12px; justify-items: center; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .i { width: 28px; height: 28px; color: var(--ink-3); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preview { position: relative; width: 100%; max-width: 420px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.preview img { width: 100%; max-height: 280px; object-fit: contain; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px; }
.preview[hidden], .dropzone-hint[hidden] { display: none; }
.preview-meta { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 12.5px; color: var(--ink-2); border-top: 1px solid var(--line); background: var(--surface); }
.bypass-box { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); display: grid; gap: 6px; }
.bypass-box.is-on { border-color: var(--good); background: var(--good-soft); }
.bypass-target { transition: opacity .15s; }
.bypass-target.is-bypassed { opacity: .5; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.check-danger input { accent-color: var(--bad); }
.preview-round { max-width: 220px; border: 0; background: transparent; overflow: visible; }
.preview-round img { display: block; width: 150px; height: 150px; max-height: none; margin: 0 auto; object-fit: cover; border-radius: 50%; border: 1px solid var(--line); }
.preview-round .preview-meta { border-top: 0; background: transparent; justify-content: center; gap: 12px; padding: 10px 0 0; }

/* ---------- site manager ---------- */
.save-bar {
  position: sticky; bottom: 0; z-index: 5; margin-top: 4px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.banner-preview {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 11px; border: 1px solid transparent;
  font-size: 14px; font-weight: 500; transition: opacity .15s;
}
.banner-preview .i { flex: none; }
.banner-preview.info { background: var(--info-soft); color: var(--info); }
.banner-preview.success { background: var(--good-soft); color: var(--good); }
.banner-preview.warning { background: var(--warn-soft); color: var(--warn); }
.banner-preview.is-empty span { opacity: .65; font-style: italic; }
.banner-preview.is-off { opacity: .5; }
.banner-preview.is-off::after { content: "Hidden on the site"; margin-left: auto; font-size: 12px; font-weight: 600; white-space: nowrap; }

.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.member-card { padding: 22px 20px 16px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.member-card h2 { font-size: 16px; letter-spacing: -.01em; margin-top: 12px; overflow-wrap: anywhere; }
.member-role { color: var(--ink-2); font-size: 13.5px; margin: 2px 0 6px; }
.member-photo { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }
.member-initial { display: grid; place-items: center; font-size: 30px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-color: transparent; text-transform: uppercase; }
.member-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.member-card .cell-sub { min-height: 1.3em; margin-bottom: 14px; overflow-wrap: anywhere; }

/* thumbnails */
.thumb { width: 52px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); background: var(--surface-2); }
.thumb-empty { width: 52px; height: 40px; border-radius: 8px; border: 1px dashed var(--line-strong); display: grid; place-items: center; color: var(--ink-3); }
.q-cell { display: flex; gap: 12px; align-items: center; min-width: 260px; }
.q-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- messages ---------- */
.toasts { display: grid; gap: 8px; margin: 4px 0 16px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 11px; font-weight: 500; font-size: 14px; background: var(--info-soft); color: var(--info); }
.toast.success { background: var(--good-soft); color: var(--good); }
.toast.error { background: var(--bad-soft); color: var(--bad); }
.toast.warning { background: var(--warn-soft); color: var(--warn); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; border-radius: 6px; opacity: .7; }
.toast button:hover { opacity: 1; }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; }
.pager-links { display: flex; gap: 6px; }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* ---------- charts ---------- */
.chart { position: relative; }
.col-chart { display: grid; grid-template-columns: 34px 1fr; margin-top: 14px; }
.col-axis { position: relative; height: 190px; }
.col-axis span { position: absolute; right: 8px; transform: translateY(50%); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; line-height: 1; }
.col-plot { position: relative; height: 190px; }
.col-plot .grid-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--grid); }
.col-plot .grid-line.base { background: var(--baseline); }
.col-bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(14, 1fr); }
.col-slot { position: relative; display: flex; align-items: flex-end; justify-content: center; height: 100%; cursor: default; }
.col-slot::before { content: ""; position: absolute; inset: 0; border-radius: 6px; }
.col-slot:hover::before, .col-slot:focus-visible::before { background: var(--surface-2); }
.col-slot:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }
.col-bar {
  position: relative; width: min(24px, 62%); background: var(--series-1);
  border-radius: 4px 4px 0 0; /* rounded data end, square at the baseline */
  min-height: 0; transition: filter .15s;
}
.col-slot:hover .col-bar, .col-slot:focus-visible .col-bar { filter: brightness(1.12); }
.col-val { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-x { display: grid; grid-template-columns: 34px repeat(14, 1fr); margin-top: 8px; }
.col-x span { text-align: center; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.col-x span:first-child { visibility: hidden; }

.hbars { display: grid; gap: 14px; margin-top: 14px; }
.hbar-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 5px; }
.hbar-head b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-head span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hbar-track { height: 10px; border-radius: 0 5px 5px 0; position: relative; }
.hbar-track::before { content: ""; position: absolute; inset: 0; border-left: 1px solid var(--baseline); }
.hbar-fill { height: 100%; background: var(--series-1); border-radius: 0 5px 5px 0; min-width: 4px; }
.hbar-row { cursor: default; }
.hbar-row:hover .hbar-fill, .hbar-row:focus-visible .hbar-fill { filter: brightness(1.12); }

.tip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 11px; box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .35);
  font-size: 13px; opacity: 0; transition: opacity .1s; min-width: 120px;
}
.tip.on { opacity: 1; }
.tip b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.tip span { color: var(--ink-2); }
.tip i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; background: var(--series-1); margin-right: 6px; vertical-align: middle; }
details.table-view { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
details.table-view summary { cursor: pointer; font-size: 13px; color: var(--ink-2); font-weight: 600; }
details.table-view table { width: 100%; font-size: 13px; margin-top: 8px; border-collapse: collapse; }
details.table-view td, details.table-view th { padding: 5px 0; border-bottom: 1px solid var(--line); text-align: left; }
details.table-view td:last-child, details.table-view th:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- lists ---------- */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item small { color: var(--ink-3); }
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); margin-bottom: 18px; font-size: 14px; align-items: flex-start; }
.alert b { color: inherit; }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }

/* score meter */
.meter { display: inline-flex; align-items: center; gap: 10px; min-width: 120px; }
.meter-track { flex: 1; height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; min-width: 60px; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter-fill.good { background: var(--good); }
.meter-fill.mid { background: #d28e05; }
.meter-fill.low { background: var(--bad); }

/* result detail */
.score-hero { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; padding: 22px; }
.ring { --p: 0; width: 104px; height: 104px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--accent-soft) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.ring b { position: relative; font-size: 24px; letter-spacing: -.03em; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 26px; flex: 1; min-width: 260px; }
.kv dt { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 2px 0 0; font-weight: 600; }
.qa { padding: 18px 20px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 34px 1fr; gap: 14px; }
.qa-n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.qa.ok .qa-n { background: var(--good-soft); color: var(--good); }
.qa.bad .qa-n { background: var(--bad-soft); color: var(--bad); }
.qa-img { max-width: 340px; max-height: 220px; border-radius: 10px; border: 1px solid var(--line); margin: 10px 0 4px; object-fit: contain; background: var(--surface-2); }
.qa-answers { display: grid; gap: 4px; margin-top: 10px; font-size: 14px; }
.qa-answers div { display: flex; gap: 8px; }
.qa-answers dt, .qa-answers span.k { color: var(--ink-3); min-width: 108px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
  radial-gradient(700px 420px at 100% 100%, var(--info-soft), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 410px; padding: 30px; }
.login-card .brand { padding: 0 0 18px; }
.login-card h1 { font-size: 24px; letter-spacing: -.02em; }
.login-card p.muted { margin: 6px 0 22px; }
.login-card form { display: grid; gap: 16px; }

/* confirm */
.confirm { max-width: 520px; margin: 40px auto; padding: 28px; text-align: center; }
.confirm .stat-icon { width: 48px; height: 48px; margin: 0 auto 14px; background: var(--bad-soft); color: var(--bad); border-radius: 14px; }
.confirm h1 { font-size: 20px; margin-bottom: 6px; }
.confirm ul { text-align: left; margin: 16px auto 22px; padding: 14px 16px 14px 34px; border-radius: 12px; background: var(--surface-2); font-size: 14px; color: var(--ink-2); }
.confirm .form-actions { justify-content: center; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* ---------- mandals + quiz codes ---------- */
.mandal-grid, .side-grid { grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 1100px) { .mandal-grid, .side-grid { grid-template-columns: minmax(0, 1fr); } }
/* the open/close registration control in a page's top bar */
.reg-toggle { display: inline-flex; align-items: center; gap: 10px; margin: 0; flex-wrap: wrap; }
/* announcements: a list with the add form beside it */
.inline-form { display: inline; margin: 0; }
.ann-text { display: block; overflow-wrap: anywhere; }
.table tr.is-hidden-row .ann-text { color: var(--ink-3); font-weight: 500; }
.ann-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 6px; }
@media (max-width: 640px) {
  .ann-table .col-actions { white-space: normal; }
  .ann-table .row-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 130px; }
}
.code-cell { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
table.table.table-narrow { min-width: 340px; }

/* ---------- topics: each topic's questions, folded under its row ---------- */
.filters-end { margin-left: auto; display: inline-flex; gap: 4px; }
.filters-end[hidden] { display: none; }
.q-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.q-toggle:hover { background: var(--surface-2); border-color: var(--line-strong); }
.q-toggle .i { transition: transform .15s ease; color: var(--ink-3); }
.q-toggle[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.q-toggle[aria-expanded="true"] .i { transform: rotate(90deg); color: inherit; }
@media (prefers-reduced-motion: reduce) { .q-toggle .i { transition: none; } }
.table tr.topic-row.is-open td { border-bottom-color: transparent; }
.table tr.tq-row > td { padding: 2px 16px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.table tbody tr.tq-row:hover td { background: var(--surface-2); }
.tq-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tq-item { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.tq-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; }
.tq-item .thumb { flex: none; }
.tq-main { flex: 1 1 auto; min-width: 0; }
.tq-main .cell-title { display: block; overflow-wrap: anywhere; }
.tq-opts { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; font-size: 13.5px; color: var(--ink-2); }
.tq-opts li { display: flex; gap: 8px; align-items: baseline; padding: 4px 9px; border-radius: 8px; overflow-wrap: anywhere; }
.tq-opts li b { flex: none; color: var(--ink-3); }
.tq-opts li.is-answer { background: var(--good-soft); color: var(--good); font-weight: 600; }
.tq-opts li.is-answer b { color: inherit; }
.tq-opts li .i { flex: none; align-self: center; width: 14px; height: 14px; margin-left: auto; }
.tq-fix { margin-top: 8px; }
.tq-item .row-actions { flex: none; }
.tq-foot { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 14px 0 0; font-size: 13px; font-weight: 600; }
.tq-foot a { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 640px) {
  .tq-opts { grid-template-columns: 1fr; }
  .tq-item { flex-wrap: wrap; }
  .tq-main { flex-basis: calc(100% - 50px); }
}
/* On a phone the table scrolls sideways; keep the questions panel as wide as the screen and pinned in view. */
.table-wrap-q { container-type: inline-size; }
.tq-panel { position: sticky; left: 16px; width: calc(100cqw - 32px); }
/* ---------- overview: results by topic (the fold-out reuses the topics page's .q-toggle / .tq-row) ---------- */
.topic-results { margin-bottom: 18px; }
.topic-results .card-head { flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.top-item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.top-who { flex: 1 1 auto; min-width: 0; }
.top-who .cell-title { overflow-wrap: anywhere; }
.top-score { flex: none; }
.top-when { flex: none; font-size: 12.5px; }
.topic-results-foot { padding: 12px 20px 16px; }
@media (max-width: 640px) { .top-item { flex-wrap: wrap; } .top-when { flex-basis: 100%; padding-left: 38px; } }
/* ---------- import questions from Excel ---------- */
.import-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .import-grid { grid-template-columns: minmax(0, 1fr); } }
.import-cols code { font-size: 12.5px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); }
.import-report .card-head p { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.import-preview td { vertical-align: top; }
.import-preview th:first-child, .import-preview td.num { width: 1%; min-width: 0; white-space: nowrap; }   /* the row number needs no room */
.import-preview td:nth-child(2) { min-width: 220px; }                                        /* the question gets the room */.import-preview .q-text { -webkit-line-clamp: 3; }
.import-preview tr.is-skipped td { color: var(--ink-3); }
.import-preview-names td:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }   /* mandal names are short: let them wrap on a phone */
.import-errors { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; color: var(--bad); font-size: 13.5px; font-weight: 500; }
.form-actions .help { margin-left: 4px; }
.import-sample { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px 20px; margin-bottom: 20px; }
.import-sample-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.import-sample-text { flex: 1 1 300px; min-width: 0; }
.import-sample-text h2 { font-size: 16px; letter-spacing: -.01em; }
.import-sample-text p { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.import-notices { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 8px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 500; }
.import-notices li { display: flex; gap: 8px; align-items: flex-start; }
.import-notices .i { flex: none; margin-top: 2px; }