:root {
  --bg: #f5f7fa; --panel: #ffffff; --panel-2: #f0f3f7; --border: #dde3ea; --text: #17212b; --muted: #5c6b7a;
  --accent: #1f5fae; --accent-text: #ffffff; --accent-soft: #e3eefb;
  --ok: #17803d; --ok-soft: #e1f5e8; --warn: #a35f00; --warn-soft: #fdf1dc; --bad: #c0262d; --bad-soft: #fde5e6;
  --crit: #8f1239; --info: #4b5b6b;
  --claude: #c4673a; --codex: #2c7a6b; --human: #6b5fb5; --unknown: #8a96a3;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --panel: #161d25; --panel-2: #1c252f; --border: #2a3542; --text: #e4e9ee; --muted: #94a3b3;
    --accent: #5b9be6; --accent-text: #0b1520; --accent-soft: #1b2c42;
    --ok: #4cc27a; --ok-soft: #15301f; --warn: #e0a243; --warn-soft: #33270f; --bad: #f0686e; --bad-soft: #3a1b1d;
    --crit: #ff7aa2; --info: #9fb0c0; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --panel: #161d25; --panel-2: #1c252f; --border: #2a3542; --text: #e4e9ee; --muted: #94a3b3;
  --accent: #5b9be6; --accent-text: #0b1520; --accent-soft: #1b2c42;
  --ok: #4cc27a; --ok-soft: #15301f; --warn: #e0a243; --warn-soft: #33270f; --bad: #f0686e; --bad-soft: #3a1b1d;
  --crit: #ff7aa2; --info: #9fb0c0; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 650; margin: 0 6px 18px; }
.brand img { width: 26px; height: 26px; }
.nav a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .sect { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 10px 4px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .sub { color: var(--muted); }
.userbox { margin-top: 18px; padding: 10px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: none; }
  .side.open { display: block; }
  .menu-toggle { display: inline-flex; margin: 12px 16px 0; }
  .main { padding: 16px; }
}

/* panels */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .g2, .g4 { grid-template-columns: 1fr; } }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.stat .hint { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.stack > * + * { margin-top: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.hr { border-top: 1px solid var(--border); margin: 14px 0; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }

/* forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=email], input[type=time], input[type=search], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); font: inherit;
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { margin: 0; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--panel-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small, .btn.small { padding: 3px 9px; font-size: 12.5px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.badge.pass, .badge.success, .badge.ok, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.queued, .badge.running, .badge.expired { background: var(--warn-soft); color: var(--warn); }
.badge.fail, .badge.failure, .badge.error, .badge.revoked { background: var(--bad-soft); color: var(--bad); }
.sev { display: inline-block; min-width: 64px; text-align: center; padding: 1px 6px; border-radius: 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.sev.critical { background: var(--crit); color: #fff; }
.sev.high { background: var(--bad-soft); color: var(--bad); }
.sev.medium { background: var(--warn-soft); color: var(--warn); }
.sev.low { background: var(--panel-2); color: var(--muted); }
.sev.info { background: var(--panel-2); color: var(--info); }
.agent { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12.5px; }
.agent::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); }
.agent.claude::before { background: var(--claude); } .agent.codex::before { background: var(--codex); }
.agent.human::before { background: var(--human); } .agent.mixed::before { background: linear-gradient(90deg, var(--claude) 50%, var(--codex) 50%); }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.good { color: var(--ok); } .score.mid { color: var(--warn); } .score.bad { color: var(--bad); }

/* verdict banner */
.verdict { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }
.verdict.pass { background: var(--ok-soft); border-color: var(--ok); }
.verdict.fail { background: var(--bad-soft); border-color: var(--bad); }
.verdict.warn { background: var(--warn-soft); border-color: var(--warn); }
.verdict .big { font-size: 22px; font-weight: 750; text-transform: uppercase; }
.verdict ul { margin: 4px 0 0; padding-left: 18px; }

/* bars and charts */
.bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* diff viewer */
.diff { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.diff .fh { background: var(--panel-2); padding: 6px 10px; font-family: var(--mono); font-size: 12.5px; display: flex; gap: 10px; align-items: center; }
.diff table { font-family: var(--mono); font-size: 12px; }
.diff td { border: 0; padding: 0 8px; white-space: pre-wrap; word-break: break-all; }
.diff td.ln { width: 1%; color: var(--muted); text-align: right; user-select: none; white-space: nowrap; }
.diff tr.add td.code { background: var(--ok-soft); }
.diff tr.del td.code { background: var(--bad-soft); }
.diff tr.hunk td { background: var(--accent-soft); color: var(--muted); }
.diff tr.note td { background: var(--panel); padding: 6px 10px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); white-space: normal; font-family: system-ui, sans-serif; font-size: 13px; }

/* finding list */
.finding { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; background: var(--panel); }
.finding.suppressed { opacity: .6; }
.finding .meta { color: var(--muted); font-size: 12px; }
.finding .detail { margin-top: 6px; }
.finding pre { background: var(--panel-2); padding: 6px 8px; border-radius: 4px; margin-top: 6px; }

/* misc */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); }
.notice { padding: 10px 12px; border-radius: 6px; background: var(--accent-soft); margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); } .notice.bad { background: var(--bad-soft); } .notice.ok { background: var(--ok-soft); }
.secret { font-family: var(--mono); background: var(--panel-2); padding: 10px; border-radius: 6px; word-break: break-all; user-select: all; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.toast.error { border-left-color: var(--bad); } .toast.ok { border-left-color: var(--ok); }
.modal-bg { position: fixed; inset: 0; background: rgba(10,15,20,.5); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
