:root {
  --bg: #0e1013;
  --surface: #15181d;
  --surface-2: #1a1e25;
  --border: #262c36;
  --border-strong: #333b47;
  --text: #e6e9ee;
  --muted: #9aa3af;
  --faint: #6b7481;
  --accent: #5b8cff;
  --green: #4cc38a;
  --amber: #e0a84e;
  --red: #e15454;
  --purple: #a68bff;
  --slate: #8ea0b4;

  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
.link { color: var(--text); text-decoration: none; }
.link:hover { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.spacer { flex: 1; }
.warn-text { color: var(--amber); }

/* ---- layout ------------------------------------------------------------ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 14px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark {
  width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--accent);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-name { font-weight: 650; font-size: 14px; letter-spacing: .2px; }
.brand-sub { color: var(--faint); font-size: 11.5px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .12s ease, color .12s ease;
}
.nav-item svg { width: 16px; height: 16px; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); border-color: var(--border); font-weight: 600; }
.nav-item.active svg { opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meta-label { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.meta-link { color: var(--muted); font-size: 12px; text-decoration: none; }
.meta-link:hover { color: var(--accent); }

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 13px 26px;
  background: rgba(14, 16, 19, .9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar-title h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .1px; }
.topbar-title .case-heading { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.topbar-sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.content { padding: 22px 26px 60px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---- cards / panels ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card-sub { margin: 2px 0 0; font-size: 12px; color: var(--faint); }

.h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }

.empty { color: var(--faint); }
.empty-state { text-align: center; padding: 34px 20px; }
.empty-title { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.empty-state .empty { margin: 0; }

/* ---- KPI / stats ------------------------------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
@media (max-width: 980px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }

.kpi { padding: 16px 18px; margin-bottom: 0; }
.kpi-value { font-size: 28px; font-weight: 650; letter-spacing: -.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { margin-top: 6px; font-size: 13px; font-weight: 600; }
.kpi-caption { color: var(--faint); font-size: 12px; margin-top: 1px; }

.stat-strip {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex; align-items: baseline; gap: 9px;
}
.stat-value { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12px; }

/* ---- charts ------------------------------------------------------------ */
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar { display: grid; grid-template-columns: 86px 1fr 30px; align-items: center; gap: 10px; }
.bar-label { color: var(--muted); font-size: 12.5px; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); }

.bar-track, .legend-track { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; height: 7px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; }
.sev-critical { background: var(--red); }
.sev-high { background: var(--amber); }
.sev-medium { background: var(--accent); }
.sev-low, .sev-info { background: var(--slate); }

.legend-list { display: flex; flex-direction: column; gap: 12px; }
.legend-row { display: grid; grid-template-columns: 150px 28px 1fr; align-items: center; gap: 10px; }
.legend-count { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.disp-true_positive { background: var(--red); }
.disp-false_positive { background: var(--green); }
.disp-suspicious { background: var(--amber); }
.disp-investigate { background: var(--purple); }

/* ---- badges ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge.sev { border: 1px solid transparent; }
.sev-critical { color: var(--red); background: rgba(225, 84, 84, .12); }
.sev-high { color: var(--amber); background: rgba(224, 168, 78, .12); }
.sev-medium { color: var(--accent); background: rgba(91, 140, 255, .12); }
.sev-low, .sev-info { color: var(--slate); background: rgba(142, 160, 180, .1); }

.badge.status { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.status-open { color: var(--accent); background: rgba(91, 140, 255, .08); }
.status-triaging { color: var(--amber); }
.status-resolved { color: var(--green); }
.status-auto_resolved { color: var(--slate); }

.badge.disp { border: 1px solid transparent; }
.disp-true_positive { color: #ff8080; }
.disp-false_positive { color: var(--green); }
.disp-suspicious { color: var(--amber); }
.disp-investigate { color: var(--purple); }

.pill {
  display: inline-block;
  border-radius: 20px;
  padding: 2px 11px;
  font-size: 11.5px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  text-transform: lowercase;
}
.pill.ok { color: var(--green); border-color: rgba(76, 195, 138, .5); background: rgba(76, 195, 138, .08); }
.pill.warn { color: var(--amber); border-color: rgba(224, 168, 78, .5); background: rgba(224, 168, 78, .08); }
.pill.amber { color: var(--amber); border-color: rgba(224, 168, 78, .5); }
.pill.blue { color: var(--accent); border-color: rgba(91, 140, 255, .5); }

.chip {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 5px;
  padding: 1px 8px;
  font-size: 11px;
  margin: 2px;
  white-space: nowrap;
}
.chip-group { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-tech { color: var(--accent); border-color: rgba(91, 140, 255, .3); font-family: var(--mono); }
.chip-user { color: var(--green); border-color: rgba(76, 195, 138, .3); }
.chip-ip { color: var(--purple); border-color: rgba(166, 139, 255, .3); font-family: var(--mono); }
.chip-bad { color: var(--red); border-color: rgba(225, 84, 84, .4); }
.chip-neutral { color: var(--slate); }

/* ---- buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--accent);
  color: #0b1220;
  border: 1px solid rgba(91, 140, 255, .4);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: #6d9aff; }
.btn:focus-visible { outline: 2px solid rgba(91, 140, 255, .5); outline-offset: 1px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn .spinner { width: 12px; height: 12px; }

.spinner {
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-text, .btn.is-loading:empty ~ .btn-text { visibility: hidden; }

/* ---- filter bar -------------------------------------------------------- */
.filterbar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.filter-field { display: flex; flex-direction: column; gap: 5px; }
.filter-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.filter-field input, .filter-field select {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}
.filter-field input:focus, .filter-field select:focus { outline: none; border-color: var(--accent); }
.filter-field.grow { flex: 1; min-width: 190px; }
.filter-actions { display: flex; gap: 8px; }

/* ---- tables ------------------------------------------------------------ */
.table-skin { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }

table.registry { width: 100%; border-collapse: collapse; font-size: 13px; }
table.registry th {
  text-align: left; color: var(--faint); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 14px; white-space: nowrap;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
table.registry td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.registry tbody tr:last-child td { border-bottom: 0; }
table.registry tbody tr:hover td { background: var(--surface-2); }
.align-right { text-align: right; }
.entities-cell { max-width: 210px; }

.confidence { width: 74px; height: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; display: inline-block; margin-right: 7px; vertical-align: middle; }
.confidence.wide { width: 180px; }
.confidence-fill { height: 100%; background: var(--accent); border-radius: 20px; }

.timeline-tbl td { font-size: 12px; }

/* ---- alerts / entities / actions --------------------------------------- */
.alert-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.alert-row:last-child { border-bottom: 0; }
.alert-body { min-width: 0; }
.alert-title { font-weight: 600; margin-bottom: 2px; }

.entity-list { display: flex; flex-direction: column; gap: 7px; }
.entity-chip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
.k {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  font-size: 9.5px; font-weight: 700; color: var(--accent);
  padding: 0 5px;
  letter-spacing: .04em;
}

.action { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.action:last-child { border-bottom: 0; }
.action-title { font-weight: 600; margin-bottom: 2px; }
.gate { font-size: 11px; border-radius: 5px; padding: 2px 8px; white-space: nowrap; flex-shrink: 0; margin-top: 1px; }
.gate-warn { color: var(--amber); border: 1px solid rgba(224, 168, 78, .5); background: rgba(224, 168, 78, .08); }
.gate-ok { color: var(--green); border: 1px solid rgba(76, 195, 138, .5); background: rgba(76, 195, 138, .08); }

/* ---- verdict ----------------------------------------------------------- */
.verdict-card { border-left: 3px solid var(--border-strong); }
.verdict-main { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 12px; }
.verdict-disc { display: flex; flex-direction: column; gap: 4px; }
.verdict-meta { display: flex; align-items: center; gap: 8px; }
.summary { margin: 0; font-size: 14px; }

/* ---- collapsibles / trace ---------------------------------------------- */
.collapsible { border-top: 1px solid var(--border); padding-top: 10px; }
.collapsible summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.collapsible summary:hover { color: var(--accent); }

.trace { border: 1px solid var(--border); border-radius: 6px; margin: 6px 0; background: var(--surface-2); }
.trace summary { cursor: pointer; padding: 8px 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.trace code { font-size: 12px; font-family: var(--mono); }
.trace-in { color: var(--faint); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trace summary:hover { background: var(--bg); border-radius: 6px 6px 0 0; }
.step {
  display: inline-block; min-width: 24px; text-align: center;
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 4px; font-weight: 700; color: var(--accent);
  padding: 1px 4px; font-size: 11px;
}

/* ---- code blocks ------------------------------------------------------- */
pre.code {
  margin: 10px 0 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow: auto;
  font-size: 11px;
  font-family: var(--mono);
  color: #b8c2ce;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- columns ----------------------------------------------------------- */
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .cols, .cols-detail { grid-template-columns: 1fr; } }
.cols > .stack, .stack { display: flex; flex-direction: column; }
.stack .card { margin-bottom: 16px; }
.stack .card:last-child { margin-bottom: 0; }

/* ---- toasts ------------------------------------------------------------ */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  padding: 10px 13px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  animation: toast-in .18s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.toast-msg { line-height: 1.45; }

/* ---- responsive -------------------------------------------------------- */
@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 14px; }
  .brand { padding: 0 8px 0 0; }
  .sidebar-foot { display: none; }
  .nav { flex-direction: row; margin: 0; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .filterbar { align-items: stretch; flex-direction: column; }
}