:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-alt: #1c222b;
  --text: #e6edf3;
  --muted: #8b949e;
  --gold: #d4a72c;
  --border: #30363d;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login Overlay */
#loginOverlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 25%, #161b22 0%, #090c10 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 6px;
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0 0 6px;
  color: var(--text);
}
.login-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.login-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
}
.err-line {
  color: #f87171;
  font-size: 12px;
  min-height: 18px;
  margin-top: 8px;
}
.login-note {
  max-width: 420px;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 14px;
}

/* Buttons & Inputs */
.btn {
  background: #21262d;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #30363d; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-gold {
  background: var(--gold);
  color: #0d1117;
  border-color: #e3b341;
}
.btn-gold:hover { background: #e3b341; }
.link-btn {
  background: none;
  border: none;
  color: #ffd866;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}

/* Header & Top Strip */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}
.brand {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .06em;
  color: var(--text);
}
.q-chip {
  background: #451a03;
  color: #fbbf24;
  border: 1px solid #f59e0b;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .04em;
}
.head-strip {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.hs-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  min-width: 125px;
}
.hs-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.hs-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
}

/* Eval Banner */
.eval-banner {
  background: #3b2300;
  border-bottom: 1px solid #9a6700;
  color: #ffd866;
  padding: 7px 18px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#evalState {
  font-weight: 800;
  text-decoration: underline;
}

/* Nav Tabs & Filter Bar */
.nav-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.tab-list {
  display: flex;
  gap: 2px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.filter-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 18px;
  background: #12161c;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.filter-bar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.filter-bar select, .filter-bar input[type="text"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}
.search-lbl { flex: 1; min-width: 200px; }
.search-lbl input { width: 100%; }
.chk-lbl { cursor: pointer; color: var(--text) !important; }

/* Main & Panels */
.main-wrap {
  padding: 16px 18px 40px;
  max-width: 1680px;
  margin: 0 auto;
}
.tabpage { display: none; }
.tabpage.active { display: block; }
.row-note {
  margin-bottom: 10px;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--panel);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 10px 12px;
}
.stat-card .sc-lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-card .sc-val {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 2px;
  color: var(--text);
}
.stat-card .sc-sub {
  font-size: 11px;
  color: var(--gold);
}
.ov-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 14px;
  overflow: hidden;
}
.p-head {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel-alt);
}
.p-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.p-sub {
  font-size: 11.5px;
  color: var(--gold);
  font-weight: 600;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  max-height: 620px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
th, td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #21262d;
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: #1c222b;
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
tbody tr:nth-child(even) { background: rgba(255,255,255,.018); }
tbody tr:hover { background: rgba(212,167,44,.08); cursor: pointer; }
tr.ghost { opacity: .55; }

/* Badges (unmissable) */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.3;
  white-space: nowrap;
}
.g-full { background: #0f5132; color: #7ee2a8; border: 1px solid #2ea043; }
.g-abstract { background: #4d3800; color: #ffd866; border: 1px solid #d4a72c; }
.s-verified { background: #14532d; color: #4ade80; border: 1px solid #22c55e; }
.s-unverified { background: #451a03; color: #fbbf24; border: 1px solid #f59e0b; }
.s-rejected { background: #450a0a; color: #f87171; border: 1px solid #ef4444; }
.t-flag { background: #312e81; color: #a5b4fc; border: 1px solid #6366f1; }

/* Spend Bars */
.spend-summary {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.spend-bars { padding: 10px 12px; }
.sbar-row {
  display: grid;
  grid-template-columns: 120px 1fr 90px;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
}
.sbar-track {
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.sbar-fill {
  height: 100%;
  background: linear-gradient(90deg, #9a6700, var(--gold));
}
.spend-note { padding: 0 12px 10px; margin: 0; font-size: 11.5px; }

/* Pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel-alt);
  font-size: 12px;
}

/* Analytics & Charts */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 14px;
}
.chart {
  width: 100%;
  height: 320px;
  padding: 6px;
}
.pending {
  border: 1px dashed var(--border);
  border-radius: 5px;
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: 10px;
}

/* Agent Chat */
.agent-panel { display: flex; flex-direction: column; }
.agent-log {
  min-height: 300px;
  max-height: 480px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.msg-user {
  align-self: flex-end;
  background: #1f2937;
  border-color: #374151;
}
.msg-agent {
  align-self: flex-start;
  background: var(--bg);
}
.cite {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  margin: 2px;
  font-size: 11px;
  cursor: pointer;
}
.cite .badge {
  padding: 1px 5px;
  font-size: 9.5px;
}
.agent-compose {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel-alt);
}
.agent-compose textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: inherit;
  font-size: 12.5px;
  resize: vertical;
}
.agent-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

/* Drill Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 560px;
  max-width: 100vw;
  height: 100vh;
  background: var(--panel);
  border-left: 2px solid var(--gold);
  box-shadow: -8px 0 28px rgba(0,0,0,.7);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  padding: 12px 14px;
  background: var(--panel-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-head h2 {
  font-family: var(--serif);
  font-size: 15px;
  margin: 0;
}
.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: #12161c;
}
.d-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 8px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.d-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Toast & Footer */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #1f2937;
  color: var(--text);
  border: 1px solid var(--gold);
  padding: 8px 14px;
  border-radius: 5px;
  font-size: 12px;
  z-index: 2000;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
.footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  background: var(--panel);
}
.muted { color: var(--muted); }

@media (max-width: 900px) {
  .ov-grid, .analytics-grid { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .topbar, .eval-banner { flex-direction: column; align-items: flex-start; }
}

/* REFEREE bucket = MACHINE TRIAGE (ISA ratification 2026-10-22) */
.chip.m-triage {background:#312e81; color:#a5b4fc; border:1px solid #6366f1; font-weight:700; letter-spacing:.04em}
tr.machine-triage {background:rgba(49,46,129,.18)}
tr.machine-triage td {border-top:1px dashed #3730a3; border-bottom:1px dashed #3730a3}
#queueSummary {margin:0 0 10px; padding:8px 10px; border:1px solid #3730a3; background:rgba(49,46,129,.15); border-radius:6px; font-size:12.5px; color:#c7d2fe}
