/* ISEA Guardian admin: calm, light, thin lines, one accent. No inline styles anywhere (CSP style-src 'self'). */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --text: #1a1f27;
  --muted: #6a7282;
  --accent: #1f3a8a;
  --accent-hover: #172d6e;
  --accent-soft: #eef2fb;
  --bad: #b42318;
  --bad-soft: #fdf1f0;
  --ok: #1d7a3a;
  --ok-soft: #eef8f1;
  --warn-soft: #fff8ea;
  --warn-line: #f0dcae;
  --mark: #e7ecfb;
  --real: #fff1c2;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a.plain { color: inherit; }
h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 28px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; letter-spacing: 0.01em; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 20px; margin-bottom: 8px; }
.who { display: flex; align-items: center; gap: 8px; }
.who .me { color: var(--text); padding: 4px 8px; border-radius: var(--radius); }
.who .me.on, .who .me:hover { background: var(--accent-soft); text-decoration: none; }
.nav { display: flex; gap: 2px; overflow-x: auto; }
.nav a { color: var(--muted); padding: 9px 12px 10px; border-bottom: 2px solid transparent; white-space: nowrap; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.on { color: var(--accent); border-bottom-color: var(--accent); }
main.wrap { padding-top: 28px; padding-bottom: 40px; }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 28px; }

/* page head */
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; }
.head p { margin: 0; }
.crumbs { color: var(--muted); font-size: 12px; margin-bottom: 6px; }

/* buttons, forms */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--accent); border-color: var(--line); }
.btn.small { height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
form.inline { display: inline; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text); }
label.check { flex-direction: row; align-items: center; gap: 6px; }
input[type=text], input[type=email], input[type=password], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 6px 9px; min-height: 32px;
}
textarea { resize: vertical; font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.grid-form { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 12px; align-items: end; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 10px; margin: 0; display: flex; gap: 18px; flex-wrap: wrap; }
legend { font-size: 13px; padding: 0 4px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filters select { min-width: 160px; }

/* notices */
.notice, .error { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--accent-soft); margin-bottom: 16px; }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.error { background: var(--bad-soft); border-color: #f3c9c4; color: var(--bad); }
.empty { color: var(--muted); padding: 28px 0; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); }

/* cards, columns */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.card.narrow { max-width: 760px; margin-top: 24px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.cols > .card { min-width: 0; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--text); }
.stat:nth-child(4n) { border-right: 0; }
.stat:nth-last-child(-n+4) { border-bottom: 0; }
a.stat:hover { background: var(--accent-soft); text-decoration: none; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 26px; font-weight: 300; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat.warn .v { color: var(--bad); }

/* segmented period selector, tabs */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg a { padding: 5px 12px; color: var(--muted); border-right: 1px solid var(--line); }
.seg a:last-child { border-right: 0; }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; color: var(--accent); }
.seg a.on:hover { color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .count { font-size: 11.5px; color: var(--muted); margin-left: 4px; }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card table { border: 0; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.dim td { color: var(--muted); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn, td.actions form { margin-left: 4px; }
.journal td.q { max-width: 420px; }
.findings td.value { font-weight: 500; }
.findings td.context { max-width: 360px; color: var(--muted); font-size: 12.5px; }
.audit td.details { max-width: 560px; word-break: break-word; }
.pager { display: flex; justify-content: space-between; margin-top: 14px; }

/* pills */
.pill { display: inline-block; padding: 0 7px; margin: 1px 4px 1px 0; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 11.5px; line-height: 18px; color: var(--muted); background: var(--surface); white-space: nowrap; }
.pill.ok, .pill.st-masked { color: var(--ok); border-color: #bfe0c9; background: var(--ok-soft); }
.pill.bad, .pill.st-open { color: var(--bad); border-color: #f3c9c4; background: var(--bad-soft); }
.pill.off, .pill.st-ignored { color: var(--muted); background: #f3f4f6; }
.pill[class*="kind-"] { color: var(--accent); border-color: #c9d3ee; background: var(--accent-soft); }

/* facts */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts.inline { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0 18px; }
.facts.inline dd { margin-right: 14px; }
.facts.inline dt::after { content: ":"; }

/* client profiles */
.profile { padding: 10px 0; border-top: 1px solid var(--line); }
.profile:first-of-type { border-top: 0; padding-top: 0; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 4px 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
ul.tree { margin: 2px 0; padding-left: 16px; }
ul.tree > li { margin: 2px 0; }
ul.tree > li > dl.kv { padding: 4px 0 6px; border-bottom: 1px dotted var(--line); }

/* journal items */
.item-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 10px; }
.part { margin-top: 10px; }
.part-label { color: var(--muted); margin-bottom: 4px; }
pre {
  margin: 0; padding: 10px 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: var(--radius);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto;
}
pre.clip { max-height: 140px; max-width: 460px; padding: 6px 8px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
mark { border-radius: 3px; padding: 0 2px; color: inherit; }
mark.ph { background: var(--mark); color: var(--accent); }
mark.real { background: var(--real); }

/* chart */
.chart { display: flex; flex-direction: column; gap: 10px; }
.chart-row { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: end; }
.chart-label { display: flex; flex-direction: column; }
svg.bars { width: 100%; height: 56px; display: block; }
svg.bars rect { fill: var(--accent); opacity: 0.85; }
svg.bars rect:hover { opacity: 1; }
svg.bars.s-placeholders rect { fill: #4f6fc2; }
svg.bars.s-findings rect { fill: var(--bad); opacity: 0.75; }
svg.bars.s-mcp_calls rect { fill: #7d8fb8; }
svg.bars line.base { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ticks { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }

/* key box */
.keybox { display: flex; gap: 10px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); margin-bottom: 16px; }
.keybox code { flex: 1; word-break: break-all; font-size: 14px; user-select: all; }

/* login / error */
body.center { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login { width: 380px; max-width: calc(100% - 32px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 28px 20px; }
.login .stack { max-width: none; margin-top: 18px; }
.login h1 { margin-top: 12px; }

/* toast */
.toast { position: fixed; right: 20px; bottom: 20px; padding: 10px 14px; background: var(--text); color: #fff; border-radius: var(--radius); font-size: 13px; max-width: 360px; }
.toast[hidden] { display: none; }

@media (max-width: 1000px) {
  .cols, .pair { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(n) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .grid-form { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; gap: 4px; }
  .head { flex-direction: column; }
  table { display: block; overflow-x: auto; }
}
