:root {
  --bg: #0b0f17;
  --panel: #131a26;
  --panel-2: #0f1520;
  --line: #223047;
  --text: #e6edf6;
  --muted: #8fa1bb;
  --accent: #2b9246;
  --accent-2: #3b82f6;
  --crit: #ef4444;
  --high: #f97316;
  --med: #eab308;
  --low: #38bdf8;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #16233a 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column;
}
code { background: #0c1420; padding: 1px 6px; border-radius: 6px; color: #cbd5e1; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(12,18,28,.7); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { font-size: 30px; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.brand .sub { margin: 0; color: var(--muted); font-size: 12px; }
.status {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; background: var(--panel-2);
}
.status.ok { color: #8ff0a4; border-color: #1f7a3a; }

.layout { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.sidebar {
  border-right: 1px solid var(--line); padding: 16px; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel-2), transparent 220px);
}
.side-head { display: flex; align-items: center; justify-content: space-between; }
.sidebar h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 8px 0; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; padding: 4px 8px; }
.ghost:hover { color: var(--text); }

.run-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.run-item {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  cursor: pointer; background: var(--panel); transition: border-color .15s, transform .05s;
}
.run-item:hover { border-color: #33507a; }
.run-item.active { border-color: var(--accent-2); box-shadow: 0 0 0 1px var(--accent-2) inset; }
.run-item .rname { font-weight: 600; word-break: break-all; }
.run-item .rmeta { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-all; }
.badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.pill.crit { background: rgba(239,68,68,.15); color: var(--crit); }
.pill.high { background: rgba(249,115,22,.15); color: var(--high); }
.pill.med { background: rgba(234,179,8,.15); color: var(--med); }
.pill.low { background: rgba(56,189,248,.15); color: var(--low); }
.state-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.state-completed { background: #22c55e; } .state-running { background: #eab308; }
.state-failed { background: #ef4444; } .state-stopped, .state-interrupted { background: #eab308; }

.launch { border-top: 1px solid var(--line); padding-top: 12px; }
.gate { font-size: 12px; border: 1px dashed var(--line); border-radius: 8px; padding: 10px; }
form label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
form input, form select {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit;
}
.primary { margin-top: 12px; width: 100%; background: var(--accent); color: #04140a; border: 0; padding: 10px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.primary:hover { filter: brightness(1.08); }
.scan-msg { font-size: 12px; margin: 8px 0 0; min-height: 16px; }

.content { overflow-y: auto; padding: 22px; min-width: 0; }
.empty { height: 100%; display: grid; place-items: center; }
.empty-state { text-align: center; color: var(--muted); }
.empty-state .big { font-size: 46px; display: block; margin-bottom: 10px; }

.detail-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-size: 22px; word-break: break-all; }
.detail-head .target { color: var(--muted); }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 18px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card .n { font-size: 26px; font-weight: 800; }
.card .l { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.card.crit .n { color: var(--crit); } .card.high .n { color: var(--high); }
.card.med .n { color: var(--med); } .card.low .n { color: var(--low); }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.tab { background: transparent; border: 0; color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; font: inherit; }
.tab.active { color: var(--text); border-bottom-color: var(--accent-2); }

.finding { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; background: var(--panel); overflow: hidden; }
.finding > summary { cursor: pointer; list-style: none; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.finding > summary::-webkit-details-marker { display: none; }
.finding .sev-tag { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 6px; text-transform: uppercase; }
.sev-critical { background: rgba(239,68,68,.16); color: var(--crit); }
.sev-high { background: rgba(249,115,22,.16); color: var(--high); }
.sev-medium { background: rgba(234,179,8,.16); color: var(--med); }
.sev-low { background: rgba(56,189,248,.16); color: var(--low); }
.finding .ftitle { font-weight: 600; flex: 1; }
.finding .cvss { color: var(--muted); font-size: 12px; white-space: nowrap; }
.finding .body { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.finding .body h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.finding .body p { margin: 0; white-space: pre-wrap; }
.finding pre { background: #0a1018; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 12.5px; }
.kv { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.kv span { font-size: 11px; color: var(--muted); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }

.report { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.report h1 { font-size: 20px; } .report h2 { font-size: 16px; margin-top: 20px; }
.report h3 { font-size: 14px; } .report table { border-collapse: collapse; }
.report th, .report td { border: 1px solid var(--line); padding: 6px 12px; text-align: left; }
.report blockquote { border-left: 3px solid var(--accent-2); margin: 12px 0; padding: 6px 14px; color: var(--muted); background: var(--panel-2); border-radius: 0 8px 8px 0; }
.report code { font-size: 12.5px; }

/* Activity: agent graph + event timeline */
.agent-graph { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.agent-graph h4, .timeline h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.agent-tree { display: flex; flex-direction: column; gap: 6px; }
.agent-node { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.agent-name { font-weight: 600; }
.agent-status { margin-left: auto; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.timeline { display: flex; flex-direction: column; gap: 8px; }
.ev { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.ev-meta { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; }
.ev-agent { font-size: 11px; color: var(--accent-2); font-weight: 700; }
.ev-role { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.ev-content { padding: 4px 12px 12px; white-space: pre-wrap; }
.ev-chat.ev-user { border-left: 3px solid var(--accent-2); }
.ev-chat.ev-assistant { border-left: 3px solid #64748b; }
.ev-tool { border-left: 3px solid var(--accent); }
.ev-tool > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.ev-tool > summary::-webkit-details-marker { display: none; }
.tool-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: #a7f3d0; }
.tool-status { margin-left: auto; font-size: 11px; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.status-completed { background: rgba(34,197,94,.15); color: #34d399; }
.status-running { background: rgba(234,179,8,.15); color: var(--med); }
.status-failed, .status-error { background: rgba(239,68,68,.15); color: var(--crit); }
.ev-tool-body { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.tool-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 10px 0 4px; }
.ev-tool-body pre { background: #0a1018; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12.5px; margin: 0; }

.muted { color: var(--muted); }
.footer { border-top: 1px solid var(--line); padding: 10px 20px; color: var(--muted); font-size: 12px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 42vh; }
}
