/* Keel admin console. Cool steel palette; verdict colors carry meaning (blocked, warned, redacted, allowed). */
:root {
  --bg: #e9edf1;
  --surface: #f7f9fb;
  --sunk: #dfe5ea;
  --ink: #17212b;
  --muted: #56636f;
  --line: #c9d2da;
  --steel: #2f4a5e;
  --steel-ink: #f7f9fb;
  --block: #a8322a;
  --warn: #9a6516;
  --redact: #6b4fa0;
  --allow: #2e6b4f;
  --log: #6b7a87;
  --focus: #e3a948;
  --rail-bg: #2f4a5e;
  --rail-ink: #f7f9fb;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121a21; --surface: #1a242d; --sunk: #222e38; --ink: #e3e9ee; --muted: #9aa9b6; --line: #2f3d48;
    --steel: #8db3cf; --steel-ink: #10171d; --block: #e0705f; --warn: #e08a4f; --rail-bg: #0c1217; --rail-ink: #dfe6ec; --redact: #a994d8; --allow: #6fbf95; --log: #8d9aa6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--steel); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100%; }
.rail { background: var(--rail-bg); color: var(--rail-ink); padding: 22px 0; display: flex; flex-direction: column; }
.mark { display: flex; align-items: center; gap: 10px; padding: 0 22px 26px; font-weight: 800; font-size: 19px; letter-spacing: .01em; }
.mark svg { width: 26px; height: 26px; }
.rail nav a {
  display: block; padding: 9px 22px; color: inherit; text-decoration: none; opacity: .78; border-left: 4px solid transparent;
}
.rail nav a:hover { opacity: 1; }
.rail nav a[aria-current="page"] { opacity: 1; font-weight: 700; border-left-color: var(--focus); background: rgba(255,255,255,.07); }
.rail .foot { margin-top: auto; padding: 0 22px; font-size: 13px; opacity: .8; }
.rail .foot button { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
main { padding: 30px 36px 60px; max-width: 1240px; width: 100%; }

/* Type */
h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; font-weight: 800; }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 700; }
.lede { color: var(--muted); margin: 0 0 24px; max-width: 70ch; }
.muted { color: var(--muted); }
small { font-size: 13px; }

/* Overview headline: the sentence is the hero */
.headline { font-size: clamp(24px, 3.1vw, 36px); line-height: 1.25; font-weight: 300; margin: 4px 0 6px; max-width: 30ch; }
.headline b { font-weight: 800; }
.headline .stopped { font-weight: 800; color: var(--block); }
.mode-note { margin: 0 0 26px; color: var(--muted); }
.mode-note b { color: var(--ink); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }

/* Chart */
.chart svg { width: 100%; height: 190px; display: block; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* Tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }
tr.event { cursor: pointer; }
tr.event:hover td { background: var(--sunk); }
tr.event td:first-child { border-left: 4px solid var(--rail, var(--log)); white-space: nowrap; }
tr.detail td { background: var(--sunk); }
.empty { padding: 26px 10px; color: var(--muted); }

/* Verdicts and statuses */
.verdict { font-weight: 700; color: var(--tone); white-space: nowrap; }
.v-blocked { --tone: var(--block); } .v-overridden, .v-warn { --tone: var(--warn); } .v-redacted { --tone: var(--redact); }
.v-cancelled { --tone: var(--allow); } .v-sent { --tone: var(--log); }
.status { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 13px; border: 1px solid currentColor; white-space: nowrap; }
.s-sanctioned { color: var(--allow); } .s-unsanctioned { color: var(--warn); } .s-blocked { color: var(--block); } .s-unlisted { color: var(--muted); }
.sev-high { color: var(--block); font-weight: 600; } .sev-medium { color: var(--warn); } .sev-low { color: var(--muted); }

/* Detail block */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.snippet { font: inherit; white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; margin: 8px 0 0; max-height: 260px; overflow: auto; }

/* Forms */
input[type="text"], input[type="password"], input[type="search"], input[type="email"], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px;
}
textarea { width: 100%; min-height: 80px; resize: vertical; }
label.field { display: block; font-weight: 600; margin: 16px 0 6px; }
.hint { font-size: 13px; color: var(--muted); margin: 4px 0 0; }
.btn { border: 1px solid var(--steel); background: var(--steel); color: var(--steel-ink); border-radius: 4px; padding: 8px 15px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--steel); }
.btn.danger { background: transparent; color: var(--block); border-color: var(--block); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--steel); text-decoration: underline; cursor: pointer; }

.segmented { display: inline-flex; border: 1px solid var(--steel); border-radius: 4px; overflow: hidden; }
.segmented button { border: 0; background: transparent; padding: 7px 16px; cursor: pointer; color: var(--steel); font-weight: 600; }
.segmented button[aria-pressed="true"] { background: var(--steel); color: var(--steel-ink); }

.section { margin-top: 28px; }
.section > h2 { padding-bottom: 8px; border-bottom: 2px solid var(--ink); }
.matrix select { min-width: 120px; }

.savebar { position: sticky; bottom: 0; margin-top: 30px; padding: 14px 0; background: var(--bg); border-top: 1px solid var(--line); display: flex; gap: 14px; align-items: center; }
.errors { color: var(--block); margin: 0; padding-left: 18px; }
.notice { padding: 12px 14px; border-left: 4px solid var(--warn); background: var(--surface); margin: 12px 0; }
.secret { font-size: 16px; padding: 10px 12px; background: var(--sunk); border-radius: 4px; overflow-wrap: anywhere; user-select: all; }
pre.code { background: var(--sunk); padding: 12px 14px; border-radius: 4px; overflow-x: auto; font-size: 13px; }

/* Sign-in */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.signin form { width: min(380px, 100%); background: var(--surface); border-top: 6px solid var(--steel); border-radius: 6px; padding: 26px 26px 22px; box-shadow: 0 10px 40px rgba(10,20,30,.12); }
.signin h1 { font-size: 22px; }
.signin input { width: 100%; }
.signin .btn { width: 100%; margin-top: 18px; }
.err { color: var(--block); min-height: 1.5em; margin: 10px 0 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 0; }
  .rail .mark { padding: 0 16px; }
  .rail nav { display: flex; flex-wrap: wrap; }
  .rail nav a { padding: 6px 12px; border-left: 0; border-bottom: 3px solid transparent; }
  .rail nav a[aria-current="page"] { border-bottom-color: var(--focus); }
  .rail .foot { margin: 0 0 0 auto; padding: 0 16px; }
  main { padding: 20px 16px 50px; }
  .grid2 { grid-template-columns: 1fr; }
}
tr.detail input[type="text"] { width: min(520px, 100%); }

/* Layer-by-layer report */
h3 { font-size: 15px; margin: 18px 0 8px; }
.report-head h1 { font-size: 30px; }
.stack { list-style: none; margin: 18px 0 8px; padding: 0; display: grid; gap: 6px; }
.stack-row { display: grid; grid-template-columns: 34px 150px 1fr auto; gap: 14px; align-items: center; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; color: inherit; text-decoration: none; }
.stack li:nth-child(1) .stack-row { margin-right: 0; }
.stack li:nth-child(2) .stack-row { margin-left: 14px; }
.stack li:nth-child(3) .stack-row { margin-left: 28px; }
.stack li:nth-child(4) .stack-row { margin-left: 42px; }
.stack li:nth-child(5) .stack-row { margin-left: 56px; }
.stack-row:hover { border-color: var(--steel); }
.stack-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--steel); color: var(--steel-ink); font-weight: 800; }
.stack-name { font-weight: 700; }
.stack-sum { color: var(--muted); }
.layer { margin-top: 34px; padding-top: 18px; border-top: 2px solid var(--ink); }
.layer-head { display: flex; gap: 14px; align-items: flex-start; }
.layer-head h2 { margin: 2px 0 2px; font-size: 20px; }
.layer-head p { margin: 0; }
.layer-sum { font-size: 17px; margin: 14px 0; }
.gaps { margin-top: 16px; padding: 12px 16px; border-left: 4px solid var(--warn); background: var(--surface); }
.gaps h3 { margin-top: 0; }
.gaps ul { margin: 0; padding-left: 18px; }
.practice { font-size: 13px; color: var(--muted); margin-top: 12px; }
.grid2.tight { margin-top: 0; }
.report-foot { margin-top: 40px; font-size: 13px; }
@media (max-width: 860px) { .stack-row { grid-template-columns: 34px 1fr; } .stack-sum, .stack-row .status { grid-column: 2; } .stack li .stack-row { margin-left: 0 !important; } }

@page { margin: 14mm; }
@media print {
  :root, :root:not([data-theme="light"]) {
    --bg: #fff; --surface: #fff; --sunk: #f2f4f6; --ink: #111; --muted: #4b5763; --line: #c9d2da; --steel: #2f4a5e; --steel-ink: #fff;
    --block: #a8322a; --warn: #9a6516; --redact: #6b4fa0; --allow: #2e6b4f; color-scheme: light;
  }
  body { background: #fff; font-size: 11pt; }
  .rail, .noprint, .savebar { display: none !important; }
  .shell { display: block; }
  main { padding: 0; max-width: none; }
  .layer { break-before: page; border-top: 0; padding-top: 0; }
  .layer-head, .gaps, tr, .stack-row { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.layer-head .grow { flex: 1; }

.signin form { width: min(460px, 100%); }
.banner { font-size: 13px; margin: 14px 0 4px; border-radius: 0; }
.banner p { margin: 0 0 8px; }
.banner label { font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.signin .banner input { width: auto; margin-top: 3px; }
