/* Mis-sell review — an evidence desk. Red and yellow are highlighter marks, used only for flags. */
:root {
  --paper: #f4f5f2;
  --surface: #ffffff;
  --ink: #1d2733;
  --ink-2: #4a5663;
  --ink-3: #737e8a;
  --rule: #dde1e4;
  --rule-strong: #bcc4cb;
  --hover: #eef0ec;

  --red: #b42233;
  --red-mark: #ffd9dd;
  --red-mark-active: #ffb0ba;
  --yellow: #7d5a00;
  --yellow-mark: #fff1a8;
  --yellow-mark-active: #ffe05a;
  --ok: #1f6b45;
  --ok-soft: #e1f1e7;

  --action: #14595a;
  --action-hover: #0e4546;
  --focus: #2b63d9;

  --ui: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --read: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 var(--ui);
  font-variant-numeric: tabular-nums;
}
a { color: var(--action); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s3) var(--s5);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.brand { font-weight: 700; font-size: 15px; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.topbar-user { display: flex; align-items: center; gap: var(--s3); color: var(--ink-2); }
.role-label { color: var(--ink-3); }

main { padding: var(--s5); max-width: 1480px; margin: 0 auto; }
main:focus { outline: none; }
.state-message { color: var(--ink-2); padding: var(--s6) 0; }
.error-message { color: var(--red); background: var(--surface); border: 1px solid var(--red-mark-active); border-radius: var(--radius); padding: var(--s3) var(--s4); }

/* ---------- Buttons and fields ---------- */
.button {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.button:hover { background: var(--hover); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button-primary { background: var(--action); border-color: var(--action); color: #fff; font-weight: 700; }
.button-primary:hover { background: var(--action-hover); }
.button-quiet { border-color: transparent; background: transparent; color: var(--action); padding-inline: 6px; }
.button-quiet:hover { background: var(--hover); }
.field { display: inline-flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); }
.input, .select, .textarea {
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); padding: 6px 8px; min-width: 0;
}
.textarea { width: 100%; resize: vertical; min-height: 60px; }

/* ---------- Sign in ---------- */
.signin { max-width: 420px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s6); }
.signin h1 { margin: 0 0 var(--s2); font-size: 22px; }
.signin p { color: var(--ink-2); margin: 0 0 var(--s5); }

/* ---------- Queue ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); }
.page-title { margin: 0; font-size: 22px; font-weight: 700; }
.page-sub { margin: 2px 0 0; color: var(--ink-2); }
.window-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2); }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 0; }
.tab {
  border: 0; background: transparent; padding: 10px 14px; cursor: pointer;
  color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
.tab-count { color: var(--ink-3); font-weight: 400; margin-left: 4px; }
.tab-note { padding: var(--s3) 0; color: var(--ink-2); margin: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.queue-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.queue-table th {
  text-align: left; font-weight: 700; font-size: 13px; color: var(--ink-2);
  padding: 10px 12px; border-bottom: 1px solid var(--rule); background: var(--surface);
  position: sticky; top: 0;
}
.queue-table td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.queue-table tbody tr { cursor: pointer; }
.queue-table tbody tr:hover { background: var(--hover); }
.queue-table tbody tr:last-child td { border-bottom: 0; }
.rank { color: var(--ink-3); width: 36px; }
.seller-name { font-weight: 700; color: var(--ink); text-decoration: none; }
.seller-name:hover { text-decoration: underline; }
.seller-company { color: var(--ink-2); }
.muted { color: var(--ink-3); }
.num, .queue-table .num { text-align: right; }

.flag-count { display: inline-flex; align-items: center; gap: 5px; margin-right: 10px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch-red { background: var(--red); }
.swatch-yellow { background: #e8b400; }
.sev { font-weight: 700; }
.sev-Critical, .sev-High { color: var(--red); }
.sev-Medium { color: var(--yellow); }
.sev-Low { color: var(--ink-2); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--rule-strong); color: var(--ink-2); background: var(--surface); white-space: nowrap; }
.badge-carry { border-color: #d9a400; color: var(--yellow); background: #fff8d6; }
.badge-review { border-color: var(--action); color: var(--action); }
.badge-done { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }

.score-cell { position: relative; }
.score-button { border: 0; background: transparent; padding: 0; cursor: pointer; font-weight: 700; text-decoration: underline dotted var(--ink-3); text-underline-offset: 3px; }
.score-why {
  position: absolute; z-index: 5; right: 0; top: 100%; width: 320px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(29, 39, 51, 0.14); padding: var(--s3); font-size: 13px; cursor: default;
}
.score-why ol { margin: 0; padding-left: 18px; }
.score-why li { margin: 2px 0; }
.score-why p { margin: 0 0 6px; color: var(--ink-2); }

/* ---------- Case ---------- */
.case-head { margin-bottom: var(--s4); }
.case-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s4); }
.back { display: inline-block; margin-bottom: var(--s2); }
.case-title { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.25; }
.case-title .seller-company { font-weight: 400; }
.facts { display: flex; flex-wrap: wrap; gap: 4px var(--s5); margin: var(--s2) 0 0; padding: 0; list-style: none; color: var(--ink-2); }
.facts strong { color: var(--ink); font-weight: 700; }
.case-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.banner { background: var(--surface); border: 1px solid var(--rule-strong); border-left: 4px solid var(--ink-2); border-radius: var(--radius); padding: var(--s3) var(--s4); margin: var(--s3) 0; }
.banner-warn { border-left-color: #d9a400; }
.banner-done { border-left-color: var(--ok); }

.stage-tabs { margin-top: var(--s4); }

.workspace { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (max-width: 1080px) { .workspace { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.panel-tabs { padding: 0 var(--s3); }
.panel-body { padding: var(--s3); }
.left-panel { position: sticky; top: var(--s3); max-height: calc(100vh - 140px); display: flex; flex-direction: column; }
.left-panel .panel-body { overflow-y: auto; }
@media (max-width: 1080px) { .left-panel { position: static; max-height: none; } }

.section-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: var(--s3) 0 var(--s2); }
.section-title:first-child { margin-top: 0; }

/* Flag cards: the left edge carries the tier. */
.flag-card {
  border: 1px solid var(--rule); border-left: 4px solid var(--rule-strong); border-radius: var(--radius);
  padding: var(--s3); margin-bottom: var(--s2); background: var(--surface);
}
.flag-card.tier-Red { border-left-color: var(--red); }
.flag-card.tier-Yellow { border-left-color: #e8b400; }
.flag-card.is-selected { box-shadow: 0 0 0 2px var(--ink); }
.flag-card.is-corrected { background: #fafbf9; }
.flag-head { display: flex; justify-content: space-between; gap: var(--s2); align-items: baseline; }
.flag-name { font-weight: 700; }
.flag-meta { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.flag-quote {
  display: block; width: 100%; text-align: left; margin: var(--s2) 0; padding: 6px 8px;
  font: 400 15px/1.55 var(--read); border: 0; border-radius: 4px; cursor: pointer; color: var(--ink);
}
.tier-Red .flag-quote { background: var(--red-mark); }
.tier-Yellow .flag-quote { background: var(--yellow-mark); }
.flag-quote:hover { filter: saturate(1.4); }
.flag-rule { font-size: 13px; color: var(--ink-2); margin: 0 0 var(--s2); }
.flag-rule strong { color: var(--ink); }
.flag-warning { font-size: 13px; color: var(--red); margin: 0 0 var(--s2); }
.flag-correction { font-size: 13px; background: var(--ok-soft); border-radius: 4px; padding: 6px 8px; margin: 0 0 var(--s2); }
.flag-correction q { font-family: var(--read); }

.verdict { border-top: 1px solid var(--rule); padding-top: var(--s2); display: grid; gap: var(--s2); }
.verdict-options { display: flex; flex-wrap: wrap; gap: 4px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: inline-block; padding: 4px 10px; border: 1px solid var(--rule-strong); border-radius: 999px; font-size: 13px; }
.choice input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.verdict-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); }
.verdict-saved { font-size: 13px; color: var(--ink-2); }

.gap-list { list-style: none; padding: 0; margin: 0 0 var(--s3); }
.gap-list li { padding: 6px 0 6px 10px; border-left: 4px solid var(--red); margin-bottom: 4px; background: #fdf3f4; border-radius: 0 4px 4px 0; }

.concerns summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.concerns ul { margin: var(--s2) 0 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }

.checklist { width: 100%; border-collapse: collapse; font-size: 13px; }
.checklist td { padding: 6px 4px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.checklist tr.group-row td { font-weight: 700; color: var(--ink-2); padding-top: var(--s3); border-bottom-color: var(--rule-strong); }
.cov-Covered { color: var(--ok); }
.cov-Partial { color: var(--yellow); }
.cov-Missed { color: var(--red); }
.cov-NotApplicable, .cov-Unknown { color: var(--ink-3); }

.add-flag { border: 1px dashed var(--rule-strong); border-radius: var(--radius); padding: var(--s3); margin-top: var(--s3); display: grid; gap: var(--s2); }
.add-flag .verdict-row .field { flex: 1 1 140px; }
.added-list { list-style: none; padding: 0; margin: var(--s2) 0 0; font-size: 13px; }
.added-list li { padding: 6px 8px; background: var(--hover); border-radius: 4px; margin-bottom: 4px; display: flex; justify-content: space-between; gap: var(--s2); }

/* Reader: the transcript, with the flag rail alongside. */
.reader-head { padding: var(--s3); border-bottom: 1px solid var(--rule); display: grid; gap: var(--s2); }
.call-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.call-tab { border: 1px solid var(--rule-strong); background: var(--surface); border-radius: var(--radius); padding: 5px 10px; cursor: pointer; font-size: 13px; }
.call-tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.call-tab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.dot-red { background: var(--red); }
.dot-yellow { background: #e8b400; }
.call-info { color: var(--ink-2); font-size: 13px; }
.player { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.player audio { flex: 1 1 280px; height: 36px; }
.selection-bar { display: flex; align-items: center; gap: var(--s2); font-size: 13px; background: #eef3fb; border-radius: 4px; padding: 6px 8px; }
.selection-bar q { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--read); }

.reader { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 14px; }
.transcript {
  font: 400 17px/1.75 var(--read); padding: var(--s5) var(--s5) var(--s6);
  max-width: 78ch; white-space: pre-wrap; word-wrap: break-word;
  max-height: calc(100vh - 290px); overflow-y: auto;
}
@media (max-width: 1080px) { .transcript { max-height: none; } }
.transcript mark { color: inherit; border-radius: 2px; padding: 1px 0; cursor: pointer; scroll-margin: 40vh; }
.transcript mark.m-Red { background: var(--red-mark); }
.transcript mark.m-Yellow { background: var(--yellow-mark); }
.transcript mark.m-Red.is-active { background: var(--red-mark-active); box-shadow: 0 0 0 2px var(--red); }
.transcript mark.m-Yellow.is-active { background: var(--yellow-mark-active); box-shadow: 0 0 0 2px #c79a00; }
.transcript mark.is-corrected { background: transparent; text-decoration: underline 2px; text-underline-offset: 4px; }
.transcript mark.m-Red.is-corrected { text-decoration-color: var(--red-mark-active); }
.transcript mark.m-Yellow.is-corrected { text-decoration-color: var(--yellow-mark-active); }
.transcript .added-mark { background: #dfe8fb; border-radius: 2px; }

.rail { position: relative; border-left: 1px solid var(--rule); background: var(--paper); }
.rail-tick { position: absolute; left: 2px; right: 2px; height: 6px; border: 0; padding: 0; border-radius: 2px; cursor: pointer; }
.rail-tick.t-Red { background: var(--red); }
.rail-tick.t-Yellow { background: #e8b400; }
.rail-tick.is-active { left: 0; right: 0; height: 10px; }

.empty-reader { padding: var(--s6); color: var(--ink-2); }

/* Review bar */
.review-dock { position: sticky; bottom: 0; z-index: 4; margin-top: var(--s4); padding-bottom: var(--s3); }
.review-bar {
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: 0 -4px 18px rgba(29, 39, 51, 0.08);
  padding: var(--s3) var(--s4); display: grid; grid-template-columns: auto 1fr auto; gap: var(--s4); align-items: center;
}
@media (max-width: 900px) { .review-bar { grid-template-columns: 1fr; } }
.review-bar fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px var(--s3); align-items: center; }
.review-bar legend { float: left; font-weight: 700; margin-right: var(--s2); padding: 0; }
.review-submit { display: flex; align-items: center; gap: var(--s3); }
.progress { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 20; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Narrow screens: wrap instead of overflowing. Only the queue table scrolls sideways. */
.topbar { flex-wrap: wrap; }
.topbar-user { flex-wrap: wrap; min-width: 0; }
.page-head > div { min-width: 0; flex: 1 1 320px; }
.table-wrap { max-width: 100%; }
@media (max-width: 600px) {
  main { padding: var(--s4); }
  .topbar { padding: var(--s3) var(--s4); }
  .window-form { width: 100%; }
  .window-form .field { flex: 1 1 140px; }
  .window-form .input { width: 100%; }
  .case-title { font-size: 20px; }
  .transcript { padding: var(--s4); font-size: 16px; }
}
.flag-kind { display: inline-block; font-weight: 700; color: var(--red); margin-right: 4px; }
.flag-finding { font-size: 13px; margin: var(--s2) 0; color: var(--ink); }

/* ---------- Navigation ---------- */
.topbar-left { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.topnav { display: flex; gap: var(--s1); }
.topnav a { color: var(--ink-2); text-decoration: none; padding: 4px 10px; border-radius: var(--radius); }
.topnav a:hover { background: var(--hover); color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 700; background: var(--hover); }

/* ---------- Overview ---------- */
.toggle-unasked { margin: 0 0 var(--s4); }
.kpis {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  margin-bottom: var(--s5);
}
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: var(--s4); border-left: 1px solid var(--rule); }
.kpi:first-child { border-left: 0; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi-label { margin-top: 4px; color: var(--ink); }
.kpi-sub { color: var(--ink-3); font-size: 13px; }

.report-section { margin-bottom: var(--s6); min-width: 0; }
.report-title { font-size: 17px; margin: 0 0 var(--s2); }
.report-note { color: var(--ink-2); margin: 0 0 var(--s3); max-width: 80ch; }
.report-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); }
@media (max-width: 1080px) { .report-columns { grid-template-columns: 1fr; } }
.report-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.report-table th, .report-table td { padding: 8px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.report-table thead th { font-size: 13px; color: var(--ink-2); }
.report-table tbody th { font-weight: 400; }
.report-table .num { text-align: right; }
.report-table tr.is-sub th { padding-left: 32px; color: var(--ink-2); }
.report-table tr.is-divider th, .report-table tr.is-divider td { border-top: 2px solid var(--rule-strong); }
.report-section .table-wrap { border-top: 1px solid var(--rule); border-radius: var(--radius); }
.table-view { margin-top: var(--s2); }
.table-view summary { cursor: pointer; color: var(--action); }

.legend { display: flex; flex-wrap: wrap; gap: var(--s4); margin-bottom: var(--s2); color: var(--ink-2); font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend-item .legend-swatch { margin-right: 0; }
.chart-wrap { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: var(--s3); }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--rule); stroke-width: 1; }
.chart-axis { fill: var(--ink-3); font: 11px var(--ui); }
.chart-hit { fill: transparent; cursor: default; }
.chart-hit.is-hover { fill: rgba(29, 39, 51, 0.05); }
.chart-tip {
  position: absolute; top: 8px; transform: translateX(-50%); pointer-events: none; z-index: 3;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(29, 39, 51, 0.14); padding: 8px 10px; font-size: 13px; white-space: nowrap;
}
.section-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; margin: var(--s4) 0 var(--s2); }
.section-row .section-title { margin: 0; }
