/* ============================================================
   Correção ONIA — design system
   ============================================================ */

:root {
  /* Paleta */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #e4e6eb;
  --border-strong: #d0d3da;

  --fg: #1a1a1d;
  --fg-soft: #3d3d44;
  --muted: #6c6c75;
  --muted-soft: #9a9aa3;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;

  --good: #16803a;
  --good-bg: #dcfce7;
  --good-border: #86efac;

  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --bad-border: #fca5a5;

  --mid: #b45309;
  --mid-bg: #fef3c7;
  --mid-border: #fcd34d;

  --neutral-soft: #f1f2f4;
  --neutral: #98989f;

  --override: #7c3aed;
  --override-bg: #f3eaff;
  --override-border: #c4b5fd;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);

  /* Espaçamento (base 4px) */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

/* Layout */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
}
header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
header h1 a {
  color: var(--fg);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
header h1 a::before {
  content: "📋";
  font-size: 1.1em;
}
header small {
  color: var(--muted);
  font-size: 0.82rem;
}
header .back {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}
header .back:hover { text-decoration: underline; }

.student-nav { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.82rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.1s;
}
.nav-btn:hover { background: var(--accent-soft); }
.nav-btn.skip { background: var(--mid-bg); border-color: var(--mid-border); color: var(--mid); }
.nav-btn.skip:hover { background: #fde68a; }
.nav-btn.disabled { color: var(--muted-soft); background: var(--surface-alt); cursor: not-allowed; pointer-events: none; }
.nav-pos { font-family: ui-monospace, monospace; font-size: 0.78rem; color: var(--muted); padding: 0 6px; font-variant-numeric: tabular-nums; }

main {
  padding: 24px 28px 48px;
  max-width: 1700px;
  margin: 0 auto;
}

/* Headings */
h1, h2, h3, h4 { color: var(--fg); letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; margin: 0 0 10px; font-weight: 700; }
h3 { font-size: 1.05rem; margin: 0 0 14px; font-weight: 600; }
h4 { font-size: 0.95rem; margin: 0 0 8px; font-weight: 600; }

p { margin: 0 0 8px; }
.hint { color: var(--muted); font-size: 0.85rem; }
.muted { color: var(--muted); }

/* ============================================================
   Dashboard
   ============================================================ */

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.controls input, .controls select, .controls button {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s;
}
.controls input:focus, .controls select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.controls input { min-width: 220px; }
.controls .preset {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}
.controls .preset:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.controls .counter { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.controls .counter strong { color: var(--fg); }

/* Tabela */
table {
  border-collapse: collapse;
  background: var(--surface);
  width: 100%;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--fg-soft);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
th[data-sort]:hover { background: #eef0f3; }
th.sorted-asc::after { content: " ↑"; color: var(--accent); }
th.sorted-desc::after { content: " ↓"; color: var(--accent); }
tbody tr:hover td { background: #f8f9fb; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nome-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.nome-link:hover { text-decoration: underline; }
.polo { color: var(--muted); font-size: 0.82rem; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn { color: var(--mid); margin-left: 4px; cursor: help; font-weight: 600; }

/* Gap / status cores em células */
.gap-bad { background: var(--bad-bg) !important; color: var(--bad); font-weight: 700; }
.gap-mid { background: var(--mid-bg) !important; color: var(--mid); font-weight: 600; }
.gap-good { color: var(--good); font-weight: 600; }
.pair-warn { background: var(--bad-bg) !important; color: var(--bad); font-weight: 600; }
tr.row-bad td { background: rgba(220, 38, 38, 0.06); }
tr.row-mid td { background: rgba(217, 119, 6, 0.06); }

/* ============================================================
   Student detail — hero + scores
   ============================================================ */

.hero {
  background: var(--surface);
  padding: 18px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.hero h2 { margin: 0 0 6px; }
.hero-meta {
  display: flex;
  gap: 18px;
  color: var(--muted);
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.hero-meta strong { color: var(--fg-soft); }

.scores { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.card {
  background: var(--surface-alt);
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  min-width: 110px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card .lbl {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.card .val {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.card.gap-card.gap-bad { background: var(--bad-bg); border-color: var(--bad-border); }
.card.gap-card.gap-mid { background: var(--mid-bg); border-color: var(--mid-border); }
.card.gap-card.gap-good { background: var(--good-bg); border-color: var(--good-border); }
.card.gap-card small { font-size: 0.72rem; color: var(--fg-soft); margin-top: 2px; }

/* ============================================================
   Review (veredito do avaliador)
   ============================================================ */

.review-wrap {
  background: var(--surface);
  padding: 18px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.review-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}
.review-header h3 { margin: 0; }
.review-meta { font-size: 0.82rem; color: var(--accent); font-family: ui-monospace, monospace; }
.review-meta.muted { color: var(--muted); }

.review-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 800px) {
  .review-options { grid-template-columns: 1fr; }
}
.review-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.review-opt:hover { background: var(--neutral-soft); border-color: var(--border-strong); }
.review-opt input[type="radio"] { display: none; }
.review-opt .opt-icon {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.review-opt .opt-label { font-weight: 700; font-size: 1.05rem; }
.review-opt .opt-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }
.review-opt.opt-passa .opt-icon { color: var(--good); }
.review-opt.opt-nao_passa .opt-icon { color: var(--bad); }
.review-opt.opt-neutra .opt-icon { color: var(--muted); }
.review-opt.opt-passa.selected { background: var(--good-bg); border-color: var(--good); }
.review-opt.opt-nao_passa.selected { background: var(--bad-bg); border-color: var(--bad); }
.review-opt.opt-neutra.selected { background: var(--neutral-soft); border-color: var(--neutral); }
.review-opt.opt-passa:has(input:checked) { background: var(--good-bg); border-color: var(--good); }
.review-opt.opt-nao_passa:has(input:checked) { background: var(--bad-bg); border-color: var(--bad); }
.review-opt.opt-neutra:has(input:checked) { background: var(--neutral-soft); border-color: var(--neutral); }

.review-notes { margin-bottom: 14px; }
.review-notes label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--fg-soft);
}
.review-notes textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  resize: vertical;
  line-height: 1.5;
}
.review-notes textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.review-actions { display: flex; gap: 8px; justify-content: flex-end; }
.review-actions button {
  font: inherit;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
}
.review-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.review-actions button.primary:hover { background: var(--accent-hover); }
.review-actions button.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.review-actions button.danger:hover { background: #fecaca; }

/* badge da decisão na dashboard */
.decision-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.decision-pill.passa { background: var(--good-bg); color: var(--good); }
.decision-pill.nao_passa { background: var(--bad-bg); color: var(--bad); }
.decision-pill.neutra { background: var(--neutral-soft); color: var(--fg-soft); }
.decision-pill.conflito { background: var(--mid-bg); color: var(--mid); }

.agg-passa { color: var(--good); }
.agg-nao_passa { color: var(--bad); }
.agg-neutra { color: var(--muted); }
.agg-conflito { color: var(--mid); }
.agg-sem_decisao { color: var(--muted-soft); }

/* user header nav */
.user-nav { margin-left: auto; display: inline-flex; align-items: center; gap: 12px; font-size: 0.82rem; }
.user-nav .nav-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.user-nav .nav-link:hover { text-decoration: underline; }
.user-nav .nav-link.admin { color: var(--override); font-weight: 600; }
.user-tag { color: var(--muted); padding: 2px 8px; background: var(--neutral-soft); border-radius: 12px; }
.flash-messages { padding: 8px 28px; }
.flash { background: var(--accent-soft); color: var(--accent); padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: 4px; }

/* Login page */
.login-body { background: linear-gradient(180deg, #eef2f9, #f6f7f9); height: 100vh; display: flex; align-items: center; justify-content: center; margin: 0; }
.login-box { background: #fff; padding: 32px 36px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.08); width: min(380px, 92vw); }
.login-box h1 { margin: 0 0 4px; }
.login-box p.muted { margin-bottom: 18px; }
.login-box label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--fg-soft); margin-bottom: 12px; }
.login-box input { display: block; width: 100%; padding: 8px 10px; margin-top: 4px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font-size: 1rem; font-family: inherit; }
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-box button.primary { width: 100%; padding: 10px; background: var(--accent); color: #fff; border: none; border-radius: var(--r-md); font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 6px; }
.login-box button.primary:hover { background: var(--accent-hover); }
.login-error { background: var(--bad-bg); color: var(--bad); padding: 8px 12px; border-radius: var(--r-sm); margin-bottom: 12px; font-size: 0.85rem; border: 1px solid var(--bad-border); }

/* Admin */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.admin-card { background: var(--surface); padding: 16px 18px; border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 4px; }
.admin-card-title { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.admin-card-val { font-size: 1.8rem; font-weight: 700; }
.admin-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; font-weight: 500; margin-top: auto; }
.admin-link:hover { text-decoration: underline; }
.stats-pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stats-pill { padding: 6px 12px; border-radius: 18px; background: var(--surface-alt); border: 1px solid var(--border); font-size: 0.85rem; }
.stats-pill.passa { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.stats-pill.nao_passa { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.stats-pill.neutra { background: var(--neutral-soft); color: var(--fg-soft); }
.stats-pill.conflito { background: var(--mid-bg); color: var(--mid); border-color: var(--mid-border); }
.stats-pill.sem { background: var(--surface-alt); color: var(--muted); }

.user-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.user-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--fg-soft); font-weight: 600; }
.user-form input, .user-form select { padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font: inherit; }
.user-form button { padding: 7px 16px; }
.small-btn { font: inherit; font-size: 0.78rem; padding: 3px 8px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; }
.small-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.small-btn.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }

.assign-form fieldset { border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 12px; }
.assign-form legend { font-weight: 600; padding: 0 6px; color: var(--fg-soft); font-size: 0.85rem; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 6px; }
.checkbox-grid label { font-weight: 400; font-size: 0.88rem; }
.assign-form input[type="number"] { padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font: inherit; width: 100px; }
.mode-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.mode-row label { font-weight: 500; }
#threshold-counter { color: var(--accent); font-family: ui-monospace, monospace; }

/* Outras decisões no detalhe */
.other-reviews { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.other-reviews-list { list-style: none; padding: 0; margin: 0; }
.other-review { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 12px; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.other-who { font-weight: 600; }
.other-notes { width: 100%; color: var(--muted); font-size: 0.82rem; margin-top: 4px; padding-left: 12px; border-left: 2px solid var(--border); }

/* admin assignment panel no detalhe do aluno */
.admin-assign-aluno { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--override-border); }
.assigned-list { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.assigned-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; background: var(--override-bg); border: 1px solid var(--override-border); color: var(--override); border-radius: 14px; font-size: 0.82rem; font-weight: 600; }
.chip-remove { background: transparent; border: none; color: var(--override); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 6px; border-radius: 50%; opacity: 0.65; }
.chip-remove:hover { opacity: 1; background: var(--bad-bg); color: var(--bad); }
.add-assign-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.add-assign-form label { font-size: 0.82rem; color: var(--fg-soft); font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.add-assign-form select { padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); font: inherit; min-width: 240px; }

/* ============================================================
   Matriz Q1-Q20
   ============================================================ */

.matrix-wrap, .viewer-wrap, .pairs-wrap, .diffs {
  background: var(--surface);
  padding: 18px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.matrix-row { display: flex; align-items: stretch; gap: 12px; margin-bottom: 8px; }
.matrix-label {
  width: 110px;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
}
.cells {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  flex: 1;
}
.cell {
  background: var(--neutral-soft);
  padding: 8px 6px;
  border-radius: var(--r-md);
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  user-select: none;
  transition: transform 0.08s, border-color 0.08s, box-shadow 0.12s;
}
.cell:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}
.cell.correto { background: var(--good-bg); color: var(--good); border-color: var(--good-border); }
.cell.errado { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
.cell.branco { background: var(--neutral-soft); color: var(--neutral); border-color: var(--border); }
.cell .qn { font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.cell .marc { font-weight: 700; font-size: 1.05rem; margin-top: 2px; }
.cell .extra { font-size: 0.62rem; color: var(--muted); }
.cell .status-icon { font-size: 1.45rem; font-weight: 700; line-height: 1.1; margin-top: 2px; }
.cell.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  transform: translateY(-1px);
}
.cell.has-override { box-shadow: inset 0 0 0 2px var(--override); }
.hand { color: var(--override); font-size: 0.85rem; cursor: help; }
.cartao-tag {
  font-size: 0.62rem;
  margin-top: 4px;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.02em;
}
.cartao-tag strong { font-size: 0.8rem; }
.cartao-tag.cartao-ok { background: rgba(22, 128, 58, .15); color: var(--good); }
.cartao-tag.cartao-fail { background: rgba(185, 28, 28, .12); color: var(--bad); }
.cartao-tag.cartao-none { background: var(--neutral-soft); color: var(--muted); }
.legend { color: var(--muted); font-size: 0.78rem; margin: 14px 0 0; }
.legend strong { color: var(--fg-soft); }

/* ============================================================
   Visualizador de imagens
   ============================================================ */

.viewer {
  display: grid;
  grid-template-columns: 220px 1fr 320px;
  gap: 14px;
  min-height: 520px;
}
.sheet-list {
  background: var(--surface-alt);
  padding: 8px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  overflow: auto;
  max-height: 720px;
}
.sheet-list ul { list-style: none; padding: 0; margin: 0; }
.sheet-list li { margin-bottom: 4px; }
.sheet-btn {
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.sheet-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.sheet-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.viewer-main { display: flex; flex-direction: column; min-width: 0; }
.viewer-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  margin-bottom: 6px;
  padding: 6px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.viewer-toolbar button {
  font: inherit;
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.1s;
}
.viewer-toolbar button:hover { background: var(--accent-soft); }
.current-sheet { color: var(--muted); margin-left: auto; font-size: 0.82rem; font-family: ui-monospace, monospace; }

.img-pane {
  background: #1a1a1d;
  border-radius: var(--r-md);
  height: 720px;
  overflow: auto;
  padding: 0;
  position: relative;
}
.img-pane-inner { min-width: 100%; min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 8px; }
#viewer-img {
  display: block;
  max-width: 100%;
  max-height: 700px;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.15s;
  background: #fff;
  border-radius: var(--r-sm);
}
#viewer-img[src=''] { display: none; }

.qdetail {
  background: var(--surface-alt);
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  max-height: 720px;
  overflow: auto;
}
.qdetail h4 { margin: 0 0 8px; color: var(--fg); }
.qdetail .field { margin-bottom: 10px; }
.qdetail .field .label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
  font-weight: 600;
}
.qdetail .field .value {
  background: var(--surface);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 0.84rem;
  line-height: 1.5;
}
.section-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin: 12px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.section-label.override-label { color: var(--override); border-bottom-color: var(--override-border); }
.section-label.override-label small { font-weight: 400; opacity: 0.65; margin-left: 6px; font-size: 0.7rem; }
.section-label.gabarito-label { color: var(--accent); border-bottom-color: #c5d5fa; }
.gabarito-field .value { background: var(--accent-soft); border-color: #c5d5fa; color: var(--fg); font-size: 0.85rem; line-height: 1.55; }

.section-label.enunciado-label { color: #555; border-bottom-color: #d8d8d8; }
.enunciado-field .value { background: #fafafa; border-color: #e2e2e2; padding: 8px 10px; }
.enun-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--fg);
}
.enun-alts {
  list-style: none;
  padding: 0;
  margin: 6px 0 14px;
  font-size: 0.82rem;
  line-height: 1.45;
}
.enun-alt {
  padding: 5px 8px;
  border: 1px solid #e2e2e2;
  border-radius: var(--r-sm);
  margin-bottom: 4px;
  background: #fff;
}
.enun-alt.alt-correta { background: #e8f5ea; border-color: #b8dfc0; }
.enun-alt.alt-marcada-errada { background: #fdecec; border-color: #f5bcbc; }
.enun-alt.alt-marcada-certa { background: #d8efdd; border-color: #88c597; font-weight: 500; }
.enun-alt .alt-tag { color: #666; font-size: 0.75rem; margin-left: 4px; }

/* ============================================================
   Override (correção manual)
   ============================================================ */

.override-note {
  background: var(--override-bg);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--override);
}
.btn-edit {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 8px 12px;
  background: var(--override-bg);
  color: var(--override);
  border: 1px solid var(--override-border);
  border-radius: var(--r-md);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: background 0.12s;
}
.btn-edit:hover { background: #e5d4ff; }

dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  width: min(620px, 90vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px); }
dialog h3 { margin: 0 0 6px; }
dialog .hint { font-size: 0.85rem; margin-bottom: 12px; }
dialog .field { margin-top: 14px; }
dialog .field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--fg-soft);
}
dialog textarea, dialog input[type="text"] {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  resize: vertical;
  line-height: 1.5;
}
dialog textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
dialog .radios { display: flex; gap: 14px; flex-wrap: wrap; }
dialog .radios label {
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
}
dialog .radios label:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
dialog .dialog-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }
dialog button {
  font: inherit;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s;
}
dialog button:hover { background: var(--surface-alt); }
dialog button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
dialog button.primary:hover { background: var(--accent-hover); }
dialog button.danger { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-border); }
dialog button.danger:hover { background: #fecaca; }

/* ============================================================
   Pares e colegas
   ============================================================ */

.pairs-tbl td { font-size: 0.85rem; vertical-align: top; padding: 8px 12px; }
.qchip {
  display: inline-block;
  padding: 2px 6px;
  background: var(--neutral-soft);
  border-radius: var(--r-sm);
  margin: 1px;
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  color: var(--fg-soft);
}
.qchip.susp { background: var(--bad-bg); color: var(--bad); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.mid { background: var(--mid-bg); color: var(--mid); }
.badge.good { background: var(--good-bg); color: var(--good); }

.method-info {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: 0.88rem;
  color: var(--fg-soft);
}
.method-info summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  color: var(--accent);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.method-info summary::-webkit-details-marker { display: none; }
.method-info summary::before {
  content: "ⓘ";
  font-size: 1.1em;
  display: inline-block;
  width: 18px;
  height: 18px;
  text-align: center;
  line-height: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  font-weight: 700;
}
.method-info[open] summary::before { content: "−"; }
.method-info .method-body { margin-top: 14px; }
.method-info code {
  background: var(--neutral-soft);
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 0.82rem;
  color: var(--fg);
  font-family: ui-monospace, monospace;
  font-weight: 600;
}
.method-intro {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--fg-soft);
  margin: 0 0 12px;
}
.method-card-body {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--fg-soft);
  margin: 0 0 10px;
}
.method-card-example {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.method-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 900px) {
  .method-grid { grid-template-columns: 1fr; }
}
.method-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.method-card-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.metric-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.metric-row:last-child { border-bottom: none; }
.metric-name {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-weight: 700;
  text-align: center;
  font-family: ui-monospace, monospace;
}
.metric-desc { color: var(--fg-soft); line-height: 1.5; font-size: 0.85rem; }
.threshold-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.threshold-pill {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 5px 12px;
  border-radius: 18px;
  font-family: ui-monospace, monospace;
  font-weight: 700;
  border: 1px solid var(--bad-border);
  font-size: 0.85rem;
}
.threshold-op {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.85rem;
}
.threshold-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}
.method-footnote {
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin: 0;
  line-height: 1.55;
}
.method-footnote strong { color: var(--accent); }
.method-footnote code {
  background: rgba(37, 99, 235, 0.15);
  color: var(--accent);
}

/* ============================================================
   Compare page
   ============================================================ */

.compare-headers {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin: 8px 0;
}
.compare-headers h3 { margin: 0; font-size: 1.1rem; }
.compare-headers h3 a { color: var(--accent); text-decoration: none; }
.compare-headers h3 a:hover { text-decoration: underline; }
.compare-headers .col-vs { font-size: 1.8rem; color: var(--muted); text-align: center; }
.compare-headers .meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.pair-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--surface-alt);
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  margin-top: 10px;
}
.pair-stats strong { color: var(--fg-soft); margin-right: 4px; }

.diff-q {
  background: var(--surface-alt);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.diff-q summary {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 14px;
  list-style: none;
}
.diff-q summary::-webkit-details-marker { display: none; }
.diff-q summary::before {
  content: "▶";
  display: inline-block;
  transition: transform 0.15s;
  color: var(--muted);
  font-size: 0.7rem;
}
.diff-q[open] summary::before { transform: rotate(90deg); }
.diff-q .q-label { font-weight: 700; min-width: 3em; }
.status-pair { display: inline-flex; gap: 4px; align-items: center; }
.status-tag {
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.status-tag.correto { background: var(--good-bg); color: var(--good); }
.status-tag.errado { background: var(--bad-bg); color: var(--bad); }
.status-tag.branco { background: var(--neutral-soft); color: var(--neutral); }
.diff-stats {
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: auto;
  font-family: ui-monospace, monospace;
}
.diff-stats strong { color: var(--bad); }
.diff-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.diff-col { background: var(--surface); padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md); }
.diff-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.diff-text { line-height: 1.75; font-size: 0.92rem; word-wrap: break-word; }
.diff-text .word { color: var(--fg); }
.diff-text .shared {
  background: #fef3a0;
  padding: 1px 3px;
  border-radius: 2px;
  font-weight: 600;
  transition: outline 0.1s, background 0.1s;
}
.diff-text .shared.hover { outline: 2px solid var(--mid); background: #fcd34d; }
.diff-justif {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.diff-justif em { font-style: normal; color: var(--fg-soft); }
.sheet-link {
  display: inline-block;
  margin: 6px 6px 0 0;
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--accent-soft);
  border: 1px solid #c5d5fa;
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--accent);
}
.sheet-link:hover { background: var(--accent); color: #fff; }
.chunks-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.chunk-chip {
  display: inline-block;
  margin: 3px 4px;
  padding: 2px 8px;
  background: #fef3a0;
  border-radius: var(--r-sm);
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: outline 0.1s, background 0.1s;
}
.chunk-chip:hover { outline: 2px solid var(--mid); background: #fcd34d; }

/* Empty states / fallbacks */
.warn { color: var(--mid); font-weight: 600; }

/* Manual */
.manual { background: var(--surface); padding: 24px 32px; border-radius: var(--r-lg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); max-width: 920px; line-height: 1.65; }
.manual h2 { margin-top: 0; }
.manual h3 { margin-top: 32px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
.manual h4 { margin-top: 18px; color: var(--fg-soft); }
.manual p { margin: 10px 0; }
.manual ul, .manual ol { margin: 8px 0 12px 24px; }
.manual li { margin-bottom: 4px; }
.manual .manual-section { margin-bottom: 12px; }
.manual-toc { background: var(--accent-soft); border: 1px solid #c5d5fa; border-radius: var(--r-md); padding: 12px 16px; margin: 18px 0; font-size: 0.88rem; line-height: 1.9; }
.manual-toc strong { color: var(--accent); }
.manual-toc a { color: var(--accent); text-decoration: none; font-weight: 500; }
.manual-toc a:hover { text-decoration: underline; }
.manual-table { width: 100%; border-collapse: collapse; margin: 12px 0 18px; font-size: 0.9rem; box-shadow: none; border: 1px solid var(--border); }
.manual-table th { background: var(--surface-alt); padding: 8px 12px; text-align: left; font-weight: 600; }
.manual-table td { padding: 8px 12px; vertical-align: top; border-top: 1px solid var(--border); }
.manual-dl dt { font-weight: 600; margin-top: 12px; color: var(--accent); }
.manual-dl dd { margin: 4px 0 8px 0; color: var(--fg-soft); }
.manual kbd { background: var(--surface-alt); border: 1px solid var(--border-strong); padding: 2px 8px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 0.85em; box-shadow: 0 1px 0 rgba(0,0,0,0.05); }

/* Responsivo básico */
@media (max-width: 1200px) {
  .viewer { grid-template-columns: 1fr; }
  .diff-body { grid-template-columns: 1fr; }
  .compare-headers { grid-template-columns: 1fr; text-align: center; }
}
