/**
 * Arbor (K5) — Reviewer Console Styles
 *
 * All colour and type comes from ../shared/brand.css (Brandbook §3/§4).
 * No hard-coded hex lives in this file; the archived CohortTrials teal
 * (#1F6F6B / #155551 / #E2F0EF) has been removed entirely.
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

/* `hidden` must win over the layout rules below (.login-container is flex). */
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  background: var(--chalk);
  color: var(--bark);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Native dialogs (focus trap + ESC come for free) ---- */
dialog {
  border: none; border-radius: 12px;
  padding: 24px; max-width: 560px; width: calc(100% - 32px);
  background: var(--paper); color: var(--bark);
  font-family: var(--font-body);
  box-shadow: 0 12px 32px rgba(42, 42, 42, 0.25);
}
dialog::backdrop { background: rgba(26, 75, 58, 0.45); }
dialog h2 { margin-bottom: 12px; font-size: var(--fs-h3); }
dialog p { margin-bottom: 8px; }
dialog .dialog-note { color: var(--stone); font-size: var(--fs-small); }
dialog .dialog-actions {
  display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px;
}
dialog .dialog-actions .btn { min-height: 44px; }

/* ---- Topbar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--grove); color: var(--paper);
  padding: 0 24px; min-height: 56px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-family: var(--font-heading); font-size: 1.125rem; font-weight: 600; }
/* Mist at full opacity: 8.9:1 on Grove. White at 75% measured 4.11:1. */
.topbar-subtitle { font-size: var(--fs-small); color: var(--mist); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-user { font-size: var(--fs-small); color: var(--mist); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--fs-small); font-weight: 600; padding: 10px 20px;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--grove); color: var(--paper); }
.btn-primary:hover:not(:disabled) { background: var(--canopy); }
.btn-outline { background: transparent; color: var(--paper); border: 1.5px solid var(--mist); }
.btn-outline:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.btn-outline-dark { background: transparent; color: var(--grove); border: 1.5px solid var(--border-input); }
.btn-outline-dark:hover:not(:disabled) { background: var(--mist); }
.btn-sm { padding: 6px 14px; font-size: var(--fs-micro); }
.btn-full { width: 100%; }

.btn-link {
  background: none; border: none; padding: 4px 0;
  color: var(--grove); font-family: var(--font-body);
  font-size: var(--fs-small); font-weight: 600;
  text-decoration: underline; cursor: pointer;
}
.btn-link:hover { color: var(--canopy); }

.btn-action { padding: 10px 18px; font-size: var(--fs-small); border-radius: 8px; }
.btn-green { background: var(--ok); color: var(--paper); }
.btn-green:hover:not(:disabled) { background: var(--canopy); }
.btn-amber { background: var(--flint-text); color: var(--paper); }
.btn-amber:hover:not(:disabled) { filter: brightness(0.88); }
.btn-blue { background: var(--slate-fern); color: var(--paper); }
.btn-blue:hover:not(:disabled) { background: var(--grove); }
.btn-teal { background: var(--canopy); color: var(--paper); }
.btn-teal:hover:not(:disabled) { background: var(--grove); }

/* ---- Login / MFA ---- */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  padding: 24px;
}
.login-card {
  background: var(--paper); border-radius: 12px;
  padding: 40px 36px; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.login-card h1 { font-size: var(--fs-h2); margin-bottom: 4px; }
.login-subtitle { color: var(--stone); margin-bottom: 24px; font-size: var(--fs-small); }
.login-links { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; align-items: flex-start; }

.session-notice {
  background: var(--flint-surface); color: var(--flint-text);
  border: 1px solid var(--flint);
  border-radius: var(--radius); padding: 10px 14px;
  font-size: var(--fs-small); margin-bottom: 16px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: var(--fs-small); font-weight: 600;
  color: var(--bark); margin-bottom: 6px;
}
.field input, .field textarea, .select {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border-input); border-radius: var(--radius);
  font-family: var(--font-body); font-size: var(--fs-body);
  color: var(--bark); background: var(--paper);
  transition: border-color 0.15s;
}
.field textarea { resize: vertical; }
.field input:hover, .field textarea:hover, .select:hover { border-color: var(--canopy); }
.select-sm { width: auto; min-width: 160px; padding: 8px 12px; font-size: var(--fs-small); }
.error-msg { color: var(--danger); font-size: var(--fs-small); min-height: 20px; margin-bottom: 8px; }
.muted { color: var(--stone); font-size: var(--fs-small); }

/* ---- Protocol Bar ---- */
.protocol-bar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--paper);
  border-bottom: 1px solid var(--border);
}
.app-h1 { font-size: var(--fs-h3); margin-right: auto; }
.app-h1:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 4px; }
.protocol-bar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.protocol-bar label {
  font-weight: 600; color: var(--bark); font-size: var(--fs-small);
}
.protocol-bar .select { width: auto; min-width: 260px; }

/* ---- Loading ---- */
.loading-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-small); color: var(--stone);
}
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--lichen); border-top-color: var(--canopy);
  animation: arbor-spin 0.7s linear infinite;
}
@keyframes arbor-spin { to { transform: rotate(360deg); } }
.queue-loading, .detail-loading { padding: 16px 20px; color: var(--stone); font-size: var(--fs-small); }

/* ---- Guardrail / regulatory banner ----
   --flint-text on --flint-surface measures 6.05:1 (the previous
   #9A6B00 on #FBF0D6 pairing measured 4.14:1). */
.guardrail-banner {
  background: var(--flint-surface); color: var(--flint-text);
  border-bottom: 1px solid var(--flint);
  padding: 10px 24px; font-size: var(--fs-small);
  font-weight: 600; text-align: center;
}

/* ---- Split Layout ---- */
.reviewer {
  display: flex; flex-direction: column;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
}
.split-layout { display: flex; flex: 1; min-height: 0; }

@media (min-width: 901px) {
  /* Desktop keeps independent scrolling panes inside the viewport. */
  .reviewer { height: calc(100vh - 56px); height: calc(100dvh - 56px); }
  .split-layout { overflow: hidden; }
}

/* ---- Queue Panel ---- */
.queue-panel {
  width: 360px; min-width: 320px;
  background: var(--paper); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.queue-header {
  padding: 16px 20px; font-size: var(--fs-h3);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.queue-count {
  background: var(--grove); color: var(--paper); font-size: var(--fs-micro);
  font-family: var(--font-body); font-weight: 600;
  padding: 2px 10px; border-radius: 10px;
}
.queue-error {
  margin: 12px 16px; padding: 10px 12px;
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--radius);
  font-size: var(--fs-small);
}
.queue-list { flex: 1; overflow-y: auto; }
.queue-item {
  display: block; width: 100%; text-align: left;
  padding: 14px 20px; border: none; border-bottom: 1px solid var(--mist);
  border-left: 3px solid transparent;
  background: var(--paper); font-family: var(--font-body);
  cursor: pointer; transition: background 0.1s;
}
.queue-item:hover { background: var(--chalk); }
.queue-item.active { background: var(--mist); border-left-color: var(--grove); }
.queue-item-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.queue-id { font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-small); color: var(--bark); }
.queue-score { font-size: var(--fs-micro); font-weight: 700; color: var(--grove); }
.queue-confidence { font-size: var(--fs-micro); color: var(--stone-on-mist); }
.queue-criterion { display: block; font-size: var(--fs-small); color: var(--stone-on-mist); margin-top: 2px; }
.queue-pagination {
  padding: 12px 20px; display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
}
.page-info { font-size: var(--fs-small); color: var(--stone); }

/* Status chips */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: var(--fs-micro); font-weight: 700; text-transform: uppercase;
}
.chip-eligible { background: var(--ok-bg); color: var(--ok); }
.chip-needs-review { background: var(--warn-bg); color: var(--warn); }
.chip-flagged { background: var(--warn-bg); color: var(--warn); }
.chip-screened { background: var(--mist); color: var(--grove); }
.chip-consented { background: var(--ok-bg); color: var(--ok); }
.chip-inclusion { background: var(--ok-bg); color: var(--ok); }
.chip-exclusion { background: var(--danger-bg); color: var(--danger); }

/* ---- Detail Panel ---- */
.detail-panel { flex: 1; overflow-y: auto; padding: 24px; min-width: 0; }
.empty-detail { text-align: center; color: var(--stone); margin-top: 96px; font-size: var(--fs-body); }
.detail-error {
  margin: 24px auto; max-width: 640px;
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger); border-radius: 8px;
  padding: 16px 20px; font-size: var(--fs-small); font-weight: 600;
}

/* Candidate Header */
.candidate-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.candidate-header h2 { font-size: var(--fs-h3); }
.meta { font-size: var(--fs-small); color: var(--stone); margin-top: 2px; }
.classification-chip {
  padding: 6px 16px; border-radius: 8px; font-weight: 700;
  font-size: var(--fs-small); text-transform: uppercase; white-space: nowrap;
}
.classification-eligible { background: var(--ok-bg); color: var(--ok); }
.classification-needs-review { background: var(--warn-bg); color: var(--warn); }
.classification-excluded { background: var(--danger-bg); color: var(--danger); }

/* Criteria Table */
.criteria-section { margin-bottom: 24px; }
.criteria-section h3, .extractions-section h3, .audit-section h3 {
  font-size: var(--fs-h3); margin-bottom: 12px;
}
.table-wrap { overflow-x: auto; }
.criteria-table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: var(--fs-small); }
.criteria-table thead th {
  text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border);
  color: var(--stone); font-weight: 700; text-transform: uppercase;
  font-size: var(--fs-micro); letter-spacing: 0.04em;
}
.criteria-table tbody td { padding: 10px; border-bottom: 1px solid var(--mist); vertical-align: top; }
.criteria-table tbody tr:hover { background: var(--chalk); }
.table-empty { color: var(--stone); font-style: italic; }

.verdict-pass { color: var(--ok); font-weight: 700; }
.verdict-fail { color: var(--danger); font-weight: 700; }
.verdict-unknown { color: var(--warn); font-weight: 700; }

/* The Brandbook requires the full triggering sentence be shown — no clamp. */
.evidence-quote {
  background: var(--mist); padding: 6px 10px; border-radius: 4px;
  font-size: var(--fs-small); color: var(--bark); line-height: 1.5;
  display: block; min-width: 240px;
}
/* Bark on Lichen measures 8.4:1; the previous grey pill measured 3.73:1. */
.redacted-token {
  display: inline-block; background: var(--lichen); color: var(--bark);
  padding: 1px 8px; border-radius: 10px; font-size: var(--fs-micro);
  font-weight: 600; font-family: var(--font-mono);
}

/* Extractions */
.extractions-section { margin-bottom: 24px; }
.extractions-list { display: flex; flex-wrap: wrap; gap: 8px; }
.extraction-tag {
  background: var(--mist); color: var(--grove); padding: 6px 12px;
  border-radius: var(--radius); font-size: var(--fs-small); font-weight: 600;
}

/* Action Bar */
.action-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 8px; padding: 16px 0; border-top: 1px solid var(--border);
}
.action-status { min-height: 20px; font-size: var(--fs-small); margin-bottom: 12px; }
.action-status-ok { color: var(--ok); font-weight: 600; }
.action-status-error { color: var(--danger); font-weight: 600; }

/* Audit Trail */
.audit-section { margin-top: 24px; }
.audit-trail { display: flex; flex-direction: column; gap: 8px; }
.audit-entry {
  padding: 10px 14px; background: var(--chalk); border-radius: var(--radius);
  font-size: var(--fs-small); border-left: 3px solid var(--canopy);
}
.audit-entry .audit-action { font-weight: 700; color: var(--bark); }
.audit-entry .audit-meta { color: var(--stone); font-size: var(--fs-micro); margin-top: 2px; }
.audit-entry .audit-reason { color: var(--bark); margin-top: 4px; font-style: italic; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .split-layout { flex-direction: column; }
  .queue-panel {
    width: 100%; min-width: 0;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .queue-list { max-height: 320px; }
  .detail-panel { overflow: visible; }
  .protocol-bar .select { min-width: 0; width: 100%; }
  .protocol-bar-controls { width: 100%; }
  .app-h1 { width: 100%; }
}
