:root {
  color-scheme: dark;
  --bg: #0f151b;
  --panel: #151d25;
  --panel-2: #1b2530;
  --line: #2a3744;
  --line-2: #3a4a5a;
  --text: #dde6ee;
  --muted: #8fa1b1;
  --accent: #6cb8ff;
  --critical: #ff5d6c;
  --punitive: #ff9d4d;
  --house: #e3c65b;
  --ok: #5fd08e;
  --info: #7aa8d8;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
[hidden] {
  display: none !important;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 6px 10px;
}
button {
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: #1f4c7a;
  border-color: #2d6aa6;
}
button.danger {
  border-color: #8a3a44;
}
button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  text-align: left;
}
button.link:hover {
  text-decoration: underline;
}
textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
}
pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0b1116;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  max-height: 420px;
  overflow: auto;
}
details > summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
img.evidence {
  max-width: 100%;
  max-height: 600px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* Lock screen */
#lock-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
#login {
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}
#login h1 {
  margin: 0;
  font-size: 20px;
}
#login p {
  margin: 0;
  color: var(--muted);
}
#login-error {
  color: var(--critical);
  min-height: 1em;
}

/* Top bar */
#topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
#agents,
#views {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--muted);
}
.tab[aria-current="true"] {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--line-2);
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ok);
  vertical-align: middle;
}
.dot.warn {
  background: var(--punitive);
}
.dot.bad {
  background: var(--critical);
}
.dot.off {
  background: var(--line-2);
}
#health {
  flex: 1;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
#health .warn {
  color: var(--punitive);
}
#topbar-actions {
  display: flex;
  gap: 6px;
}

/* Reviews workspace */
.workspace {
  display: grid;
  grid-template-columns: 250px minmax(340px, 1fr) minmax(420px, 1.35fr);
  height: calc(100vh - 51px);
}
.workspace > * {
  overflow: auto;
  min-width: 0;
}
.filters {
  border-right: 1px solid var(--line);
  padding: 12px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.filters input[type="search"] {
  width: 100%;
}
.filter-group h3 {
  margin: 0 0 6px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  font-size: 12.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.chip[aria-pressed="true"] {
  background: #1f4c7a;
  border-color: #3b82c4;
}
.chip .count {
  color: var(--muted);
  margin-left: 5px;
  font-variant-numeric: tabular-nums;
}
.chip[aria-pressed="true"] .count {
  color: #c4ddf5;
}
.presets {
  display: grid;
  gap: 4px;
}
.preset {
  text-align: left;
  font-size: 13px;
}
.preset small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}
.note {
  color: var(--muted);
  font-size: 12px;
}
.note.warn {
  color: var(--house);
}

/* Result list */
.results {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.results-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}
.results-head .line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.results-head strong {
  font-size: 15px;
}
.progress {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  background: var(--accent);
}
ol.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.row {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  gap: 0 10px;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: none;
  padding: 8px 12px 8px 0;
}
.row:hover {
  background: #131c24;
}
.row[aria-selected="true"] {
  background: #17283a;
}
.row .bar {
  border-radius: 0 3px 3px 0;
  background: transparent;
}
.impact-3 .bar {
  background: var(--critical);
}
.impact-2 .bar {
  background: var(--punitive);
}
.impact-1 .bar {
  background: var(--house);
}
.row .top {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
}
.row .ident {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.row .when {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.row .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 3px 0;
}
.row .summary {
  color: var(--muted);
  font-size: 12.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid var(--line-2);
  color: var(--text);
  white-space: nowrap;
}
.badge.v-punitive,
.badge.v-ban {
  border-color: var(--punitive);
  color: #ffc491;
}
.badge.critical {
  border-color: var(--critical);
  color: #ff9aa3;
}
.badge.v-housekeeping,
.badge.v-watch,
.badge.v-already_banned {
  border-color: #8a7a35;
  color: #eadb95;
}
.badge.v-no_change,
.badge.v-no_action {
  color: var(--muted);
}
.badge.agree {
  border-color: var(--ok);
  color: var(--ok);
}
.badge.disagree {
  border-color: var(--critical);
  color: var(--critical);
}
.badge.unsure {
  border-color: var(--info);
  color: var(--info);
}
.badge.shadow {
  color: var(--muted);
  border-style: dashed;
}
.badge.state-pending {
  border-color: var(--accent);
  color: var(--accent);
}
.badge.state-applied {
  border-color: var(--ok);
  color: var(--ok);
}
.empty {
  padding: 24px 14px;
  color: var(--muted);
}
.more {
  margin: 10px 12px 24px;
}

/* Detail */
.detail {
  padding: 0 18px 40px;
}
.detail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
}
.detail-head h2 {
  margin: 0;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.detail-head .meta {
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.detail-head .buttons,
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.section {
  margin-top: 16px;
}
.section > h3 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.prose {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.summary-text {
  font-size: 15px;
}
.assess {
  display: grid;
  gap: 6px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.assess .buttons button[aria-pressed="true"].agree {
  background: #1d4a33;
  border-color: var(--ok);
}
.assess .buttons button[aria-pressed="true"].disagree {
  background: #4d2027;
  border-color: var(--critical);
}
.assess .buttons button[aria-pressed="true"].unsure {
  background: #1f3550;
  border-color: var(--info);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}
.card .title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  font-weight: 600;
}
.card.critical {
  border-left: 3px solid var(--critical);
}
.callout {
  border-left: 3px solid var(--house);
  background: #1f1d12;
  padding: 8px 10px;
  border-radius: 4px;
  color: #ecdca0;
}
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  font-size: 12.5px;
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.artifact {
  display: grid;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.artifact .name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
.artifact.cited .name::after {
  content: " · cited";
  color: var(--accent);
}
.history-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.placeholder {
  color: var(--muted);
  padding: 40px 10px;
  text-align: center;
}

/* Tables (queue, rules) */
.page {
  padding: 14px;
  max-width: 1300px;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
  overflow-wrap: anywhere;
}
th {
  color: var(--muted);
  font-weight: 500;
}
.table-wrap {
  overflow-x: auto;
}

/* Modal and toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(3, 7, 10, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 18px;
  display: grid;
  gap: 10px;
}
.modal h2 {
  margin: 0;
  font-size: 17px;
}
#toast {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  max-width: min(640px, 92vw);
  background: #243444;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#toast:empty {
  display: none;
}
kbd {
  font: 12px ui-monospace, monospace;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
}

/* Narrow screens: detail becomes an overlay. */
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 220px 1fr;
  }
  .detail {
    position: fixed;
    inset: 51px 0 0 0;
    z-index: 10;
    background: var(--bg);
  }
  .detail.closed {
    display: none;
  }
}
@media (max-width: 700px) {
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }
  .filters {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.row > span:last-child {
  min-width: 0;
}
.row .note,
.row .summary {
  display: block;
  overflow-wrap: anywhere;
}
.row .summary {
  display: -webkit-box;
}
.detail-head .url {
  color: var(--accent, #7cb7ff);
  font-size: 13px;
  margin: 2px 0 6px;
}

/* Loading states */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes slide {
  from {
    background-position: -60% 0;
  }
  to {
    background-position: 160% 0;
  }
}
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  padding: 18px 4px;
}
.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
button.busy {
  cursor: progress;
  opacity: 0.7;
}
button.busy::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  vertical-align: -1px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.results,
.detail {
  position: relative;
}
.results.busy ol.rows {
  opacity: 0.45;
  transition: opacity 0.15s 0.1s;
}
.results.busy::before,
.detail.refreshing::before {
  content: "";
  position: sticky;
  top: 0;
  display: block;
  height: 3px;
  margin-bottom: -3px;
  z-index: 2;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: slide 1s linear infinite;
}
.callout.error {
  border-color: var(--critical);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
@media (prefers-reduced-motion: reduce) {
  .spinner,
  button.busy::after,
  .results.busy::before,
  .detail.refreshing::before {
    animation-duration: 3s;
  }
}
.nav-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  align-self: center;
  margin-right: 4px;
}
.preset[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--text);
}
