/* Roanoke Signal Desk — moderation console.
   Dense, queue-first layout on generous surfaces. Light and dark themes follow
   the operating system unless the operator picks one from the top bar, in which
   case `data-theme` on <html> wins in both directions. */

:root {
  color-scheme: light;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eceff4;
  --sidebar: #ffffff;
  --border: #e0e5ec;
  --border-strong: #c6cfda;
  --text: #141c28;
  --text-2: #55616f;
  --text-3: #838f9d;
  --accent: #1f5fd0;
  --accent-solid: #1f5fd0;
  --accent-hover: #1a51b4;
  --accent-weak: #e9f0fd;
  --on-accent: #ffffff;
  --danger: #bf3227;
  --danger-solid: #c0392b;
  --danger-weak: #fcecea;
  --on-danger: #ffffff;
  --warn: #96600a;
  --warn-weak: #fbf2e0;
  --ok: #157048;
  --ok-weak: #e6f4ec;
  --info: #5943bd;
  --info-weak: #eeebfb;
  --focus: #1f5fd0;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 6px 22px rgba(16, 24, 40, .1);
  --shadow-lg: -16px 0 48px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --surface: #141922;
  --surface-2: #1a202a;
  --surface-3: #222a36;
  --sidebar: #0f131b;
  --border: #232b38;
  --border-strong: #38434f;
  --text: #e6ecf3;
  --text-2: #9aa7b6;
  --text-3: #6d7a89;
  --accent: #6b9df9;
  --accent-solid: #2f6fed;
  --accent-hover: #3f7cf0;
  --accent-weak: #16243c;
  --on-accent: #ffffff;
  --danger: #f0837a;
  --danger-solid: #c9372e;
  --danger-weak: #331d1b;
  --on-danger: #ffffff;
  --warn: #dfab61;
  --warn-weak: #2e2517;
  --ok: #5dc490;
  --ok-weak: #132a20;
  --info: #a794f5;
  --info-weak: #201c36;
  --focus: #6b9df9;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 8px 26px rgba(0, 0, 0, .4);
  --shadow-lg: -18px 0 54px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0e14;
    --surface: #141922;
    --surface-2: #1a202a;
    --surface-3: #222a36;
    --sidebar: #0f131b;
    --border: #232b38;
    --border-strong: #38434f;
    --text: #e6ecf3;
    --text-2: #9aa7b6;
    --text-3: #6d7a89;
    --accent: #6b9df9;
    --accent-solid: #2f6fed;
    --accent-hover: #3f7cf0;
    --accent-weak: #16243c;
    --on-accent: #ffffff;
    --danger: #f0837a;
    --danger-solid: #c9372e;
    --danger-weak: #331d1b;
    --on-danger: #ffffff;
    --warn: #dfab61;
    --warn-weak: #2e2517;
    --ok: #5dc490;
    --ok-weak: #132a20;
    --info: #a794f5;
    --info-weak: #201c36;
    --focus: #6b9df9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 26px rgba(0, 0, 0, .4);
    --shadow-lg: -18px 0 54px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* Icons are drawn as strokes so they inherit the surrounding text colour. */
svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-radius: var(--radius-sm);
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 500 11px/1.5 var(--mono);
  text-align: center;
}

code { font-family: var(--mono); }

/* --- Controls ---------------------------------------------------------- */

input, select, textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { min-height: 74px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
  outline: none;
}
input[type="checkbox"], input[type="radio"] {
  width: 15px;
  height: 15px;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent-solid);
  cursor: pointer;
}
select { padding-right: 8px; cursor: pointer; }

.field { display: grid; gap: 5px; }
.field-label { color: var(--text-2); font-size: 12px; font-weight: 600; }
.field-label em { color: var(--text-3); font-style: normal; font-weight: 400; }
.field-label code { padding: 2px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-affix { position: relative; display: block; }
.input-affix input { padding-right: 58px; }
.affix-button {
  position: absolute;
  top: 50%;
  right: 5px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  transform: translateY(-50%);
}
.affix-button:hover { background: var(--surface-3); color: var(--text); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.button:hover { background: var(--surface-3); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button:disabled:hover { background: var(--surface); }
.button-icon { width: 14px; height: 14px; }
.button-primary { border-color: var(--accent-solid); background: var(--accent-solid); color: var(--on-accent); }
.button-primary:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
.button-primary:disabled:hover { background: var(--accent-solid); }
.button-danger { border-color: var(--danger-solid); background: var(--danger-solid); color: var(--on-danger); }
.button-danger:hover { filter: brightness(1.08); }
.button-danger:disabled:hover { filter: none; }
.button-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.button-ghost:hover { background: var(--surface-3); color: var(--text); }
.button-block { width: 100%; min-height: 38px; }
.button-small { min-height: 28px; padding: 0 10px; font-size: 11px; }
.button-danger-ghost { border-color: var(--danger); background: transparent; color: var(--danger); }
.button-danger-ghost:hover { background: var(--danger-weak); }
.button-danger-ghost:disabled:hover { background: transparent; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  transition: background .12s ease, color .12s ease;
}
.icon-button:hover { background: var(--surface-3); color: var(--text); }
.icon-button:disabled { opacity: .35; cursor: not-allowed; }
.icon-button:disabled:hover { background: transparent; color: var(--text-2); }

.form-status { min-height: 16px; color: var(--danger); font-size: 12px; }
.form-status.is-ok { color: var(--ok); }
.form-status-inset { padding: 0 18px; }

/* --- Sign in ----------------------------------------------------------- */

.login-screen { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--bg); }
.login-card {
  display: grid;
  gap: 16px;
  width: min(380px, 100%);
  padding: 30px 30px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-head strong, .sidebar-brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.login-head small, .sidebar-brand small { display: block; color: var(--text-3); font-size: 11px; }
.login-footnote { color: var(--text-3); font-size: 11px; line-height: 1.55; }

.brand-glyph {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent-solid);
  color: var(--on-accent);
  font-size: 15px;
  font-weight: 700;
}
.brand-glyph-small { width: 20px; height: 20px; border-radius: 6px; font-size: 11px; }

/* --- Shell ------------------------------------------------------------- */

.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 18px 12px 14px;
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }

.primary-nav { display: grid; gap: 2px; }
.nav-item {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.is-active { background: var(--accent-solid); color: var(--on-accent); font-weight: 600; }
.nav-icon { width: 16px; height: 16px; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count {
  min-width: 22px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-2);
  font: 600 11px/18px var(--sans);
  text-align: center;
}
.nav-item.is-active .nav-count { background: rgba(255, 255, 255, .24); color: var(--on-accent); }
.nav-count:empty { display: none; }

.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.user-card { display: grid; grid-template-columns: 30px minmax(0, 1fr) 32px; align-items: center; gap: 10px; padding: 5px 6px; }
.user-identity { min-width: 0; }
.user-card strong, .user-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card strong { font-size: 12px; font-weight: 600; }
.user-card small { color: var(--text-3); font-size: 11px; }
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font: 600 11px var(--sans);
}

.main-content { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  z-index: 15;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-heading { min-width: 0; }
.topbar-title { font-size: 21px; font-weight: 650; letter-spacing: -.02em; white-space: nowrap; }
.topbar-subtitle { margin-top: 1px; overflow: hidden; color: var(--text-2); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.nav-toggle { display: none; }
.topbar-clock { color: var(--text-3); font: 11px var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sync-state { color: var(--text-3); font-size: 11px; white-space: nowrap; }
.sync-state.is-busy { color: var(--accent); }
.sync-state.is-error { color: var(--danger); }

/* The live badge mirrors the SSE stream state rather than fetch activity. */
.live-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--ok);
  border-radius: var(--radius-pill);
  background: var(--ok-weak);
  color: var(--ok);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: live-pulse 2.4s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.icon-dark { display: none; }
:root[data-theme="dark"] .icon-light { display: none; }
:root[data-theme="dark"] .icon-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-light { display: none; }
  :root:not([data-theme="light"]) .icon-dark { display: block; }
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.chip-quiet { background: var(--surface-3); color: var(--text-2); }
.chip-role { background: var(--accent-weak); border-color: transparent; color: var(--accent); }

.app-status {
  margin: 16px 24px 0;
  padding: 11px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-weak);
  color: var(--danger);
  font-size: 12px;
}

.view { display: none; max-width: 1560px; width: 100%; padding: 24px; }
.view.is-visible { display: block; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.section-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.utc-note { color: var(--text-3); font-size: 11px; }

/* --- Stat tiles -------------------------------------------------------- */

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-strip-three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stat-label { display: block; color: var(--text-2); font-size: 12px; font-weight: 600; }
.stat strong {
  display: block;
  margin-top: 8px;
  font: 650 30px/1.1 var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
}
.stat .stat-text { font-size: 18px; }
.stat-note { display: block; margin-top: 7px; color: var(--text-3); font-size: 11px; }
.stat-note.is-up { color: var(--ok); }
.stat-note.is-down { color: var(--danger); }
.stat-note.is-flat { color: var(--text-3); }

/* --- Panels ------------------------------------------------------------ */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.panel-subtitle { margin-top: 2px; color: var(--text-2); font-size: 12px; }
.panel-subtitle code { padding: 1px 5px; border-radius: 5px; background: var(--surface-3); font-size: 11px; }
.panel-caption { color: var(--text-3); font-size: 11px; white-space: nowrap; }

.panel-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.foot-label { color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.foot-controls { display: flex; align-items: center; gap: 16px; }
.inline-field { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12px; }
.inline-field select { width: auto; min-height: 30px; font-size: 12px; }
.pager { display: flex; gap: 4px; }

/* --- Queue toolbar ----------------------------------------------------- */

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2.2fr) repeat(5, minmax(110px, 1fr)) auto;
  gap: 8px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.toolbar select { font-size: 12px; }
.search-field { position: relative; display: block; }
.search-field input { padding-left: 32px; padding-right: 30px; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-icon {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-3);
  transform: translateY(-50%);
  pointer-events: none;
}
.search-hint { position: absolute; top: 50%; right: 7px; transform: translateY(-50%); pointer-events: none; }
.search-field input:focus ~ .search-hint, .search-field input:not(:placeholder-shown) ~ .search-hint { display: none; }

/* --- Audit filter ------------------------------------------------------- */

.audit-toolbar { padding: 12px 18px 0; max-width: 360px; }
.audit-toolbar .search-field input { min-height: 30px; font-size: 12px; }

/* Pill filters mirror the console convention of one-click source switching. */
.pill-row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.pill-row-label { color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-row-spacer { margin-left: 18px; padding-left: 18px; border-left: 1px solid var(--border); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.pill:hover { background: var(--surface-3); color: var(--text); }
.pill.is-active { border-color: var(--accent-solid); background: var(--accent-solid); color: var(--on-accent); }

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 6px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 11px;
}
.filter-chip strong { color: var(--text); font-weight: 600; }
.filter-chip button {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1;
}
.filter-chip button:hover { background: var(--surface-3); color: var(--text); }
.chip-clear-all { border-style: dashed; padding: 0 11px; color: var(--accent); font-weight: 600; }

/* --- Tables ------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; min-width: 900px; border-collapse: collapse; }
/* The header sticks to the top of `.table-wrap`, which is the scroll container
   the horizontal overflow creates — not to the viewport. */
.data-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.data-table th:not(.select-column) { padding: 10px 14px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 18px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 18px; }
.data-table th:has(.sort-button) { padding: 0; }
.sort-button {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}
.sort-button:hover { color: var(--text); background: var(--surface-3); }
.sort-arrow::after { content: ""; color: var(--text-3); }
.sort-button.is-sorted { color: var(--text); }
.sort-button.is-sorted.is-desc .sort-arrow::after { content: "▼"; font-size: 8px; }
.sort-button.is-sorted.is-asc .sort-arrow::after { content: "▲"; font-size: 8px; }

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr.is-clickable { cursor: pointer; }
.data-table tbody tr.is-clickable:hover td { background: var(--surface-2); }
.data-table tbody tr.is-cursor td { background: var(--accent-weak); }
.data-table tbody tr.is-selected td { background: var(--surface-3); }
/* Row-state stripes go on the first cell only - an inset shadow on every td
   would paint a stripe at each cell edge and read as column borders. */
.data-table tbody tr.is-open td:first-child { box-shadow: inset 2px 0 var(--accent-solid); }
.data-table tbody tr:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.select-column { width: 38px; padding: 10px 0 10px 18px; }
.data-table td.select-column { padding: 12px 0 12px 18px; }
.evidence-column { width: 30%; }

.cell-primary { display: block; color: var(--text); font-weight: 600; }
.cell-secondary { display: block; margin-top: 2px; color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.cell-mono { font-family: var(--mono); font-size: 11.5px; }
.cell-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-detail {
  display: -webkit-box;
  overflow: hidden;
  max-width: 44ch;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.cell-truncate { display: block; overflow: hidden; max-width: 22ch; text-overflow: ellipsis; white-space: nowrap; }

/* Severity reads as a single glanceable token rather than a bar chart. */
.sev {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 7px;
  font: 700 12px var(--sans);
  font-variant-numeric: tabular-nums;
}
.sev-0, .sev-1, .sev-2 { background: var(--surface-3); color: var(--text-2); }
.sev-3 { background: var(--warn-weak); border-color: var(--warn); color: var(--warn); }
.sev-4 { background: var(--danger-weak); border-color: var(--danger); color: var(--danger); }
.sev-5 { background: var(--danger-solid); border-color: var(--danger-solid); color: var(--on-danger); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-open { background: var(--accent-weak); color: var(--accent); }
.status-approved { background: var(--ok-weak); color: var(--ok); }
.status-dismissed { background: var(--surface-3); color: var(--text-2); }
.status-escalated { background: var(--info-weak); color: var(--info); }
.status-false_positive { background: var(--warn-weak); color: var(--warn); }

.claim-note { display: block; margin-top: 2px; color: var(--text-3); font-size: 10px; font-weight: 500; }

/* SLA aging reads on the row border and the first-seen stamp; the exact age
   stays on hover so the default view stays calm. */
.data-table tbody tr.is-sla-breach td:first-child { box-shadow: inset 2px 0 var(--danger); }
.data-table tbody tr.is-sla-breach.is-open td:first-child { box-shadow: inset 2px 0 var(--danger); }
.data-table tbody tr.is-sla-warn td:first-child { box-shadow: inset 2px 0 var(--warn); }
td.cell-time.is-sla-warn { color: var(--warn); font-weight: 600; }
td.cell-time.is-sla-breach { color: var(--danger); font-weight: 700; }

/* Grouped (by-player) queue rows sit between the header and their cases. */
tr.is-group-row td { background: var(--surface-2); font-weight: 600; }
tr.is-group-row:hover td { background: var(--surface-3); }
tr.is-group-detail td { padding-top: 6px; padding-bottom: 6px; }
.group-toggle { display: flex; align-items: center; }
.group-chevron {
  display: inline-block;
  color: var(--text-3);
  font-size: 12px;
  transition: transform .12s ease;
}
.group-chevron.is-open { transform: rotate(90deg); }

.empty-state { display: grid; justify-items: center; gap: 7px; padding: 56px 20px; text-align: center; }
.empty-state h3 { font-size: 14px; font-weight: 650; }
.empty-state p { max-width: 46ch; color: var(--text-2); font-size: 12px; }
.empty-state .button { margin-top: 8px; }

.skeleton-cell { display: block; height: 11px; border-radius: 6px; background: var(--surface-3); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* --- Bulk action bar --------------------------------------------------- */

.bulk-bar {
  position: fixed;
  z-index: 30;
  bottom: 22px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}
.bulk-count { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.bulk-count strong { color: var(--text); font-variant-numeric: tabular-nums; }
.bulk-actions { display: flex; gap: 7px; padding: 0 8px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.bulk-actions .button { min-height: 30px; font-size: 11px; }

/* --- Analytics --------------------------------------------------------- */

.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-2); }
.range-button {
  min-width: 60px;
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.range-button:hover { background: var(--surface-3); color: var(--text); }
.range-button.is-active { background: var(--accent-solid); color: var(--on-accent); }

.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-wide { grid-column: 1 / -1; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--text-2); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.legend-signals { background: var(--accent-solid); }
.legend-reviewed { background: var(--ok); }
.legend-fp { background: var(--warn); }

.flow-chart { display: flex; align-items: end; gap: clamp(3px, 1vw, 14px); height: 200px; padding: 22px 18px 12px; }
.flow-chart-weeks { height: 150px; }
.flow-chart-weeks .flow-day { min-width: 34px; }
.flow-day { display: grid; grid-template-rows: 1fr 14px; flex: 1; gap: 8px; height: 100%; min-width: 16px; }
.flow-bars { display: flex; align-items: end; justify-content: center; gap: 3px; min-height: 0; }
.flow-bar { width: min(11px, 28%); min-height: 2px; border-radius: 3px 3px 0 0; }
.flow-bar-signals { background: var(--accent-solid); }
.flow-bar-reviewed { background: var(--ok); }
.flow-bar-fp { background: var(--warn); }
.flow-label { overflow: hidden; color: var(--text-3); font-size: 10px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.bar-list, .rank-list { display: grid; padding: 16px 18px; }
.bar-list { gap: 14px; }
.bar-item { display: grid; gap: 6px; }
.bar-item-head { display: flex; justify-content: space-between; gap: 14px; }
.bar-item-label { overflow: hidden; color: var(--text); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.bar-item-value { color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { height: 6px; overflow: hidden; border-radius: 3px; background: var(--surface-3); }
.bar-fill { height: 100%; border-radius: 3px; background: var(--accent-solid); }
.bar-fill.bad { background: var(--warn); }

.rank-list { gap: 0; padding-top: 4px; padding-bottom: 4px; }
.rank-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.rank-item:last-child { border-bottom: 0; }
.rank-item.is-clickable { cursor: pointer; }
.rank-item.is-clickable:hover .rank-name { color: var(--accent); }
.rank-index { width: 18px; color: var(--text-3); font: 11px var(--mono); }
.rank-name { flex: 1; min-width: 0; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { display: block; color: var(--text-3); font-size: 11px; font-weight: 400; }
.rank-value { color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list-empty { padding: 16px 18px; color: var(--text-3); font-size: 12px; }

/* Per-moderator decision mix: one thin stacked strip per reviewer. */
.decisions-strip {
  display: flex;
  overflow: hidden;
  width: 110px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
}
.decisions-strip i { display: block; height: 100%; }
.ds-approved { background: var(--ok); }
.ds-dismissed { background: var(--border-strong); }
.ds-escalated { background: var(--info); }
.ds-fp { background: var(--warn); }

/* --- Settings ---------------------------------------------------------- */

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.settings-wide { grid-column: 1 / -1; }

.detail-list { padding: 6px 18px 12px; }
.detail-list div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--text-2); font-size: 12px; }
.detail-list dd { color: var(--text); font-size: 12px; font-weight: 500; text-align: right; }

.integration-list { padding: 6px 18px 12px; }
.integration-item { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.integration-item:last-child { border-bottom: 0; }
.integration-item span { color: var(--text); font-size: 12px; font-weight: 500; }
.integration-item small { display: block; margin-top: 2px; color: var(--text-3); font-size: 11px; font-weight: 400; }
.health-state { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.health-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.health-ok { color: var(--ok); }
.health-off { color: var(--text-3); }

.capability-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 16px 18px; }
.capability {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 500;
}
.capability small { color: var(--ok); font-size: 11px; font-weight: 600; }
.capability.is-off { color: var(--text-3); }
.capability.is-off small { color: var(--text-3); }

.moderator-form { display: grid; grid-template-columns: 1.2fr 1fr .8fr 1.3fr auto; gap: 8px; padding: 16px 18px 0; }
.moderator-list { padding: 8px 18px 12px; }
.moderator-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto auto auto auto; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.moderator-row:last-child { border-bottom: 0; }
.moderator-identity { min-width: 0; }
.moderator-row strong, .moderator-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moderator-row strong { font-size: 12px; font-weight: 600; }
.moderator-row small { color: var(--text-3); font-size: 11px; }
.moderator-status { font-size: 11px; font-weight: 600; }
.moderator-status.is-active { color: var(--ok); }
.moderator-status.is-off { color: var(--text-3); }
.moderator-self { color: var(--text-3); font-size: 11px; }

/* --- Footer ------------------------------------------------------------ */

.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: auto;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
}
.footer-brand { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 600; }
.footer-meta { color: var(--text-3); }

/* --- Case drawer ------------------------------------------------------- */

.drawer-scrim { position: fixed; z-index: 24; inset: 0; background: rgba(8, 12, 18, .45); }
.case-drawer {
  position: fixed;
  z-index: 25;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(660px, 100vw);
  height: 100vh;
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(101%);
  transition: transform .18s ease;
  visibility: hidden;
}
.case-drawer.is-open { transform: translateX(0); visibility: visible; }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 20px;
  border-bottom: 1px solid var(--border);
}
.drawer-head-id { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.drawer-eyebrow { color: var(--text-3); font-size: 11px; font-weight: 600; }
.copy-id {
  overflow: hidden;
  max-width: 32ch;
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: 11px var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-id:hover { background: var(--surface-3); color: var(--text); }
.drawer-head-controls { display: flex; gap: 4px; }

.drawer-content { overflow-y: auto; padding: 0 20px 36px; }
.drawer-section { padding: 18px 0; border-bottom: 1px solid var(--border); }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section-title { margin-bottom: 12px; color: var(--text-2); font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }

.drawer-hero { display: flex; justify-content: space-between; align-items: start; gap: 14px; }
.drawer-hero h2 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.drawer-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 5px; color: var(--text-3); font-size: 11px; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 11px; font-weight: 600; }
.link-button:hover { text-decoration: underline; }

.drawer-detail {
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-solid);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  line-height: 1.65;
}

.fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 10px; margin-top: 14px; }
.fact { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.fact dt { color: var(--text-3); font-size: 11px; }
.fact dd { margin-top: 3px; color: var(--text); font-size: 12px; font-weight: 600; }
.fact dd.is-mono { font-family: var(--mono); font-size: 11.5px; font-weight: 500; overflow-wrap: anywhere; }

.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.drawer-actions .button { flex: 1; min-width: 130px; }

.timeline { display: grid; }
.timeline-item { position: relative; padding: 0 0 16px 16px; border-left: 1px solid var(--border); }
.timeline-item:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline-item::before {
  position: absolute;
  top: 5px;
  left: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  content: "";
}
.timeline-item strong { display: block; color: var(--text); font-size: 12px; font-weight: 600; }
.timeline-item p { margin-top: 3px; color: var(--text-2); font-size: 12px; }
.timeline-item time { display: block; margin-top: 4px; color: var(--text-3); font-size: 11px; }

.note-card { padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.note-card + .note-card { margin-top: 9px; }
.note-card strong { font-size: 12px; font-weight: 600; }
.note-card p { margin-top: 4px; color: var(--text-2); font-size: 12px; white-space: pre-wrap; }
.note-card time { display: block; margin-top: 5px; color: var(--text-3); font-size: 11px; }
.drawer-note-form { display: grid; gap: 8px; margin-top: 12px; }
.drawer-note-form .button { justify-self: end; }

.mini-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.mini-row:last-child { border-bottom: 0; }
.mini-row span { color: var(--text-2); }
.mini-row strong { color: var(--text); font-weight: 600; }

.profile-details summary { cursor: pointer; color: var(--text-2); font-size: 12px; }
.profile-details pre {
  overflow-x: auto;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font: 11px/1.55 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}
.drawer-muted { color: var(--text-3); font-size: 12px; }

/* --- Modals ------------------------------------------------------------ */

.modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 18, .55); }
.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(540px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px 22px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.modal-card-narrow { width: min(450px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.modal-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.modal-intro { margin-top: -8px; color: var(--text-2); font-size: 12px; }
.modal-card form { display: grid; gap: 14px; }
.modal-card fieldset { margin: 0; padding: 0; border: 0; }
.modal-card legend { margin-bottom: 8px; color: var(--text-2); font-size: 12px; font-weight: 600; }

.decision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.decision-option {
  display: flex;
  align-items: start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.decision-option:hover { background: var(--surface-2); }
.decision-option:has(input:checked) { border-color: var(--accent-solid); background: var(--accent-weak); }
.decision-option input { margin-top: 2px; }
.decision-option strong { display: block; font-size: 12px; font-weight: 600; }
.decision-option small { display: block; color: var(--text-2); font-size: 11px; }

.checkbox-label { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 12px; cursor: pointer; }
.checkbox-label input { flex: none; }
.modal-actions { display: flex; justify-content: end; gap: 9px; }

.shortcut-list { display: grid; gap: 2px; }
.shortcut-list div { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.shortcut-list div:last-child { border-bottom: 0; }
.shortcut-list dt { display: flex; gap: 4px; }
.shortcut-list dd { color: var(--text-2); font-size: 12px; }

/* --- Toasts ------------------------------------------------------------ */

.toast-stack { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 9px; width: min(360px, calc(100vw - 40px)); }
.toast {
  display: flex;
  align-items: start;
  gap: 10px;
  padding: 12px 12px 12px 15px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 12px;
  animation: toast-in .14s ease both;
}
.toast.is-error { border-left-color: var(--danger); }
.toast.is-warn { border-left-color: var(--warn); }
.toast p { flex: 1; }
.toast button { flex: none; padding: 0 2px; border: 0; background: transparent; color: var(--text-3); font-size: 15px; line-height: 1; }
.toast button:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* --- Responsive -------------------------------------------------------- */

@media (min-width: 1800px) {
  /* Ultra-wide displays: the 1560px cap would leave a large dead margin on
     the right, so let every view use the available width. */
  .view { max-width: none; }
}

@media (max-width: 1400px) {
  /* First seen duplicates what the case drawer always shows. */
  .case-table th:nth-child(8), .case-table td:nth-child(8) { display: none; }
  .data-table { min-width: 820px; }
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 208px minmax(0, 1fr); }
  .toolbar { grid-template-columns: minmax(200px, 1.6fr) repeat(3, minmax(110px, 1fr)); }
  .capability-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case-table th:nth-child(6), .case-table td:nth-child(6) { display: none; }
  .data-table { min-width: 760px; }
  .topbar-subtitle { display: none; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    width: 248px;
    box-shadow: var(--shadow-md);
    transform: translateX(-101%);
    transition: transform .18s ease;
  }
  .app-shell.nav-open .sidebar { transform: translateX(0); }
  .nav-toggle { display: inline-grid; }
  .settings-grid, .analytics-grid { grid-template-columns: minmax(0, 1fr); }
  .chart-wide { grid-column: auto; }
  .moderator-form { grid-template-columns: 1fr 1fr; }
  .moderator-form input:first-child, .moderator-form .button { grid-column: 1 / -1; }
  .section-head { flex-direction: column; align-items: stretch; }
}

@media (max-width: 720px) {
  .view { padding: 16px 14px; }
  .stat-strip, .stat-strip-three { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px 16px; }
  .stat strong { font-size: 25px; }
  .toolbar { grid-template-columns: 1fr 1fr; padding: 14px; }
  .toolbar .search-field { grid-column: 1 / -1; }
  .pill-row { flex-direction: column; align-items: stretch; gap: 8px; padding: 14px; }
  .topbar { min-height: 60px; padding: 10px 14px; }
  .topbar-right .button span { display: none; }
  .topbar-clock, .sync-state { display: none; }
  .topbar-title { font-size: 18px; }
  .field-row { grid-template-columns: 1fr; }
  .decision-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
  .bulk-bar { left: 14px; right: 14px; flex-wrap: wrap; justify-content: center; transform: none; }
  .bulk-actions { border: 0; padding: 0; }
  .capability-grid { grid-template-columns: 1fr; }
  .drawer-actions .button { flex: 1 1 100%; }
  .app-footer { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
