:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f0f2f7;
  --line: #e3e6ee;
  --line-2: #d3d8e4;
  --text: #1c2333;
  --text-2: #3d4659;
  --muted: #5d6579;
  --gold: #a87c2a;
  --gold-bright: #d4af6a;
  --gold-dim: rgba(212, 175, 106, 0.16);
  --gold-line: rgba(212, 175, 106, 0.45);
  --gold-text: #85601e;
  --green: #1d9a5b;
  --green-dim: rgba(29, 154, 91, 0.10);
  --green-line: rgba(79, 209, 139, 0.4);
  --green-text: #127043;
  --red: #cf3a51;
  --red-dim: rgba(207, 58, 81, 0.09);
  --red-line: rgba(224, 71, 94, 0.45);
  --red-text: #b52a40;
  --amber: #b9780f;
  --amber-dim: rgba(230, 162, 60, 0.14);
  --amber-line: rgba(230, 162, 60, 0.4);
  --amber-text: #8c5a08;
  --grey: #9aa2b6;
  --grey-dim: rgba(120, 128, 150, 0.12);
  --grey-line: rgba(107, 116, 147, 0.35);
  --blue: #2f63c9;
  --blue-dim: rgba(47, 99, 201, 0.09);
  --blue-line: rgba(111, 156, 240, 0.4);
  --blue-text: #2f63c9;
  --navy: #0f1730;
  --primary-bg: #0f1730;
  --primary-bg-hover: #1f2a4d;
  --primary-fg: #ffffff;
  --active-text: #0f1730;
  --brand-1: #e6c88a;
  --brand-mid: #a87c2a;
  --brand-2: #a7843f;
  --s3-1: #e7792b;
  --s3-2: #c7511f;
  --code-bg: #f7f8fb;
  --j-key: #2f55b3;
  --j-str: #1b7a49;
  --j-bool: #b4366b;
  --overlay: rgba(15, 23, 48, 0.28);
  --login-glow: #e9ecf5;
  --login-glow-fade: rgba(245, 246, 250, 0);
  --shadow: 0 1px 2px rgba(16, 24, 48, 0.05), 0 2px 8px rgba(16, 24, 48, 0.04);
  --shadow-drawer: -20px 0 50px rgba(15, 23, 48, 0.14);
  --shadow-pop: 0 20px 60px rgba(15, 23, 48, 0.12);
  --shadow-toast: 0 10px 30px rgba(15, 23, 48, 0.15);
  --radius: 10px;
  --focus: #2f63c9;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme: explicit choice, or the OS preference when the user left the toggle on Auto. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1220;
  --bg-2: #131a2a;
  --panel: #172033;
  --panel-2: #1f2940;
  --line: #273250;
  --line-2: #36425f;
  --text: #e6eaf3;
  --text-2: #c3cad9;
  --muted: #9aa4ba;
  --gold: #e0bb6f;
  --gold-bright: #e8c785;
  --gold-dim: rgba(224, 187, 111, 0.14);
  --gold-line: rgba(224, 187, 111, 0.45);
  --gold-text: #e6c57f;
  --green: #4cc98a;
  --green-dim: rgba(76, 201, 138, 0.14);
  --green-line: rgba(76, 201, 138, 0.42);
  --green-text: #63d89b;
  --red: #ff7b8e;
  --red-dim: rgba(255, 123, 142, 0.13);
  --red-line: rgba(255, 123, 142, 0.45);
  --red-text: #ff8d9d;
  --amber: #f2b453;
  --amber-dim: rgba(242, 180, 83, 0.14);
  --amber-line: rgba(242, 180, 83, 0.42);
  --amber-text: #f5c069;
  --grey: #6f7a94;
  --grey-dim: rgba(152, 162, 184, 0.14);
  --grey-line: rgba(152, 162, 184, 0.35);
  --blue: #8db0ff;
  --blue-dim: rgba(141, 176, 255, 0.12);
  --blue-line: rgba(141, 176, 255, 0.42);
  --blue-text: #9dbbff;
  --navy: #0f1730;
  --primary-bg: #e0bb6f;
  --primary-bg-hover: #ecc982;
  --primary-fg: #141a2b;
  --active-text: #ffffff;
  --code-bg: #0f1524;
  --j-key: #9dbbff;
  --j-str: #7adba5;
  --j-bool: #f59ac0;
  --overlay: rgba(0, 0, 0, 0.55);
  --login-glow: #1b2542;
  --login-glow-fade: rgba(13, 18, 32, 0);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-drawer: -20px 0 50px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-toast: 0 10px 30px rgba(0, 0, 0, 0.5);
  --focus: #9dbbff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1220;
    --bg-2: #131a2a;
    --panel: #172033;
    --panel-2: #1f2940;
    --line: #273250;
    --line-2: #36425f;
    --text: #e6eaf3;
    --text-2: #c3cad9;
    --muted: #9aa4ba;
    --gold: #e0bb6f;
    --gold-bright: #e8c785;
    --gold-dim: rgba(224, 187, 111, 0.14);
    --gold-line: rgba(224, 187, 111, 0.45);
    --gold-text: #e6c57f;
    --green: #4cc98a;
    --green-dim: rgba(76, 201, 138, 0.14);
    --green-line: rgba(76, 201, 138, 0.42);
    --green-text: #63d89b;
    --red: #ff7b8e;
    --red-dim: rgba(255, 123, 142, 0.13);
    --red-line: rgba(255, 123, 142, 0.45);
    --red-text: #ff8d9d;
    --amber: #f2b453;
    --amber-dim: rgba(242, 180, 83, 0.14);
    --amber-line: rgba(242, 180, 83, 0.42);
    --amber-text: #f5c069;
    --grey: #6f7a94;
    --grey-dim: rgba(152, 162, 184, 0.14);
    --grey-line: rgba(152, 162, 184, 0.35);
    --blue: #8db0ff;
    --blue-dim: rgba(141, 176, 255, 0.12);
    --blue-line: rgba(141, 176, 255, 0.42);
    --blue-text: #9dbbff;
    --navy: #0f1730;
    --primary-bg: #e0bb6f;
    --primary-bg-hover: #ecc982;
    --primary-fg: #141a2b;
    --active-text: #ffffff;
    --code-bg: #0f1524;
    --j-key: #9dbbff;
    --j-str: #7adba5;
    --j-bool: #f59ac0;
    --overlay: rgba(0, 0, 0, 0.55);
    --login-glow: #1b2542;
    --login-glow-fade: rgba(13, 18, 32, 0);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-drawer: -20px 0 50px rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 20px 60px rgba(0, 0, 0, 0.5);
    --shadow-toast: 0 10px 30px rgba(0, 0, 0, 0.5);
    --focus: #9dbbff;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* The scrollbar's room is kept on every page, so a long page and a short one put the content in the same place. */
html { scrollbar-gutter: stable; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold-text); text-decoration: none; }
a:hover { text-decoration: underline; }
/* A link inside running text is underlined, so it is told apart by more than its color (WCAG 1.4.1). */
p a:not(.btn), dd a:not(.btn):not(.chip), .small > a, .stack-sm > a, .advice a, .card-foot a, .muted a:not(.btn) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
code, .hash { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.break { word-break: break-all; }
.fail-text { color: var(--red-text); }
.error-text { color: var(--red-text); min-height: 1.2em; margin: 6px 0; }
.row-gap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }

/* Keyboard focus: one visible ring everywhere (WCAG 2.4.7 / 2.4.11), never removed without a replacement. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ksi:focus-visible, .sys:focus-visible, .stat:focus-visible { outline-offset: 3px; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--primary-bg); color: var(--primary-fg); border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.skip:focus { top: 10px; }
/* Loading: a thin bar at the top while the next view loads; the view being left stays in place (no jump). */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 70; pointer-events: none; opacity: 0; background: linear-gradient(90deg, transparent, var(--gold-bright), transparent); background-size: 40% 100%; background-repeat: no-repeat; }
.is-loading .loadbar { opacity: 1; animation: mini-slide 1.1s ease-in-out infinite; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--gold-text); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }
.row-link { color: inherit; display: block; text-decoration: none; }
a.row-link:hover, .row-link.linklike:hover { text-decoration: none; }
.row-link.linklike { width: 100%; }
.cell-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; position: relative; }
/* The menu's column, the whole height of the page (the menu itself stays in view while the page scrolls). */
.shell::before { content: ""; position: absolute; top: 56px; bottom: 0; left: 0; width: 220px; background: var(--bg-2); border-right: 1px solid var(--line); }
.shell > .sidebar { border-right: 0; background: transparent; z-index: 1; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.2px; white-space: nowrap; }
.brand em { font-style: normal; color: var(--muted); font-weight: 500; }
.brand-mark { width: 28px; height: 28px; flex: none; fill: currentColor; }
/* The Commandry wordmark: an alpha mask, so it takes the text color in light and dark themes. */
.brand-text { display: flex; align-items: center; gap: 10px; }
.brand-word { display: block; width: 118px; height: 24px; background: currentColor;
  -webkit-mask: url(brand/commandry-wordmark.png) left center / contain no-repeat; mask: url(brand/commandry-wordmark.png) left center / contain no-repeat; }
.brand-lg .brand-mark { width: 34px; height: 34px; }
.brand-lg .brand-word { width: 126px; height: 26px; }
.brand-lg { font-size: 16px; margin-bottom: 8px; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line-2); color: var(--text); border-radius: 6px; padding: 4px 9px; font-size: 16px; cursor: pointer; }
.pill { border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.pill:empty { display: none; }
.pill-running { color: var(--gold-text); border-color: var(--gold); animation: pulse 1.6s ease-in-out infinite; font-family: var(--sans); }
@keyframes pulse { 50% { opacity: 0.55; } }

.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 56px; height: calc(100vh - 56px); align-self: start; overflow-y: auto; }
.nav-label { display: block; padding: 10px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.nav-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar a { display: block; color: var(--muted); padding: 8px 12px; border-radius: 7px; font-weight: 500; border-left: 2px solid transparent; }
.sidebar a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.sidebar a.active { color: var(--active-text); background: var(--panel-2); border-left-color: var(--gold-bright); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 8px 12px; font-family: var(--mono); }

.main { padding: 24px 28px 48px; min-width: 0; }
.view { max-width: 1400px; margin: 0 auto; }
.loading { padding: 40px 0; text-align: center; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { min-width: 0; }
.page-head h1 { margin: 0 0 2px; font-size: 22px; font-weight: 650; letter-spacing: -0.2px; }
.page-head h1:focus { outline: none; }
.page-head h1:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: 10px; align-items: center; flex: none; }

/* ---------- theme toggle ---------- */
.theme-toggle { gap: 6px; }
.theme-toggle svg { width: 15px; height: 15px; flex: none; }
.theme-toggle-float { position: absolute; top: 16px; right: 16px; background: var(--panel); }

/* ---------- buttons, inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); }
.btn-primary:hover { background: var(--primary-bg-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-text); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-xs { padding: 1px 8px; font-size: 11.5px; border-radius: 6px; }
.btn.disabled { pointer-events: none; color: var(--muted); border-color: var(--line); background: transparent; }
.btn[aria-busy="true"] { cursor: progress; }
input, select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 10px; font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
input[aria-invalid="true"] { border-color: var(--red); }

/* ---------- cards ---------- */
.card { background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 600; }
.card > h2 { margin-bottom: 10px; }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--line); font-size: 13px; }
.pad { padding: 14px 18px; margin: 0; }
.error-card { border-color: var(--red); color: var(--text); background: var(--red-dim); }
.card h2.error-title { margin: 0 0 6px; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.error-card p { margin: 0 0 12px; }
.card-ok { border-color: var(--green-line); }
.card-bad { border-color: var(--red-line); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 6px; }
.empty .empty-title { color: var(--text); font-weight: 600; font-size: 15px; }
.empty .btn { margin-top: 6px; }

.big { font-size: 28px; font-weight: 700; font-family: var(--mono); color: var(--gold-text); line-height: 1.2; }
.big-sm { font-size: 17px; font-weight: 600; }
.meta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 18px 0 16px; }
.meta-grid .card { margin: 0; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; text-align: left; font: inherit; cursor: pointer; box-shadow: var(--shadow); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 12px; border-top: 3px solid var(--grey); color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--line-2); }
.stat[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--gold-bright), var(--shadow); }
.stat-num { font-size: 32px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-2); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; margin-top: 4px; }
.stat-meaning { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.35; }
.stat[aria-pressed="true"] .stat-label::after { content: " · shown"; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.stat-pass { border-top-color: var(--green); } .stat-pass .stat-num { color: var(--green-text); }
.stat-insufficient { border-top-color: var(--gold); } .stat-insufficient .stat-num { color: var(--gold-text); }
.stat-fail { border-top-color: var(--red); } .stat-fail .stat-num { color: var(--red-text); }
.stat-unknown { border-top-color: var(--grey); } .stat-unknown .stat-num { color: var(--muted); }

.stackbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--panel-2); margin: 16px 0 8px; }
.seg { display: block; height: 100%; }
.seg-pass { background: var(--green); } .seg-insufficient { background: var(--gold-bright); } .seg-fail { background: var(--red); } .seg-unknown { background: var(--grey); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--grey); flex: none; }
.dot-pass { background: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }
.dot-insufficient { background: var(--gold-bright); box-shadow: 0 0 0 3px var(--gold-dim); }
.dot-fail { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
.dot-unknown { background: var(--grey); }

/* ---------- KSI grid ---------- */
.ksi-card .card-head { margin: 0; }
.filter-count { margin: 0; }
.ksi-groups { padding: 16px 18px 18px; display: flex; flex-wrap: wrap; gap: 18px 22px; align-items: flex-start; }
.ksi-group { min-width: 0; }
.ksi-group-head { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 13px; font-weight: 400; }
.fam { font-family: var(--mono); font-weight: 700; color: var(--gold-text); font-size: 12.5px; letter-spacing: 0.6px; }
.ksi-grid { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; margin: 0; padding: 0; }
.ksi-item { width: 212px; display: flex; }
.ksi {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 8px; color: var(--text); width: 100%;
  background: var(--bg-2); border: 1px solid var(--line); border-left: 3px solid var(--grey); min-height: 96px; transition: transform .08s, border-color .08s;
}
.ksi:hover { text-decoration: none; transform: translateY(-1px); border-color: var(--line-2); }
.ksi .badge { font-size: 11px; padding: 1px 7px; }
.ksi-pass { border-left-color: var(--green); background: linear-gradient(90deg, var(--green-dim), var(--bg-2) 60%); }
.ksi-insufficient { border-left-color: var(--gold-bright); background: linear-gradient(90deg, var(--gold-dim), var(--bg-2) 60%); }
.ksi-fail { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-dim), var(--bg-2) 60%); }
.ksi-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ksi-id { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.ksi-name { font-size: 12.5px; color: var(--text-2); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ksi-foot { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; white-space: nowrap; font-size: 11.5px; color: var(--muted); }
.card .toolbar.filters { padding: 12px 18px; margin: 0; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.card-flush > .toolbar.filters + .ksi-groups { padding-top: 14px; }
.ksi-card .filters select { width: 240px; min-width: 0; }
.filters input[type=search] { min-width: 200px; }

/* ---------- badges, chips ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.2px; white-space: nowrap; border: 1px solid transparent; }
.badge-pass, .badge-success { color: var(--green-text); background: var(--green-dim); border-color: var(--green-line); }
.badge-fail, .badge-error, .badge-failed { color: var(--red-text); background: var(--red-dim); border-color: var(--red-line); }
.badge-insufficient { color: var(--gold-text); background: var(--gold-dim); border-color: var(--gold-line); }
.badge-warn { color: var(--amber-text); background: var(--amber-dim); border-color: var(--amber-line); }
.badge-unknown, .badge-na { color: var(--muted); background: var(--grey-dim); border-color: var(--grey-line); }
.badge-running { color: var(--gold-text); background: var(--gold-dim); border-color: var(--gold-line); }
.badge-lg { font-size: 14px; padding: 4px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; font-family: var(--mono); font-size: 11.5px; padding: 1px 7px; border-radius: 5px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; margin: 1px 2px 1px 0; }
a.chip:hover { border-color: var(--gold); color: var(--gold-text); text-decoration: none; }
.ksi-ref { font-family: var(--mono); font-weight: 600; font-size: 12.5px; }
.chip-commandry { color: var(--gold-text); border-color: var(--gold-line); }
.chip-fetchers { color: var(--blue-text); border-color: var(--blue-line); }
.chip-type-checkpoint { color: var(--gold-text); border-color: var(--gold-line); }
.chip-type-run_started, .chip-type-run_finished { color: var(--blue-text); border-color: var(--blue-line); }
.chip-type-ksi_snapshot { color: var(--green-text); border-color: var(--green-line); }
.chip-type-plugin_health, .chip-type-notice { color: var(--amber-text); border-color: var(--amber-line); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table caption { text-align: left; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.table tr.clickable:focus-within td { background: var(--panel-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.table .col-wide { min-width: 220px; max-width: 420px; }
.table code.muted { display: inline-block; margin-top: 1px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--text-2); }
.err-msg { color: var(--red-text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.missing { margin-top: 5px; color: var(--gold-text); }
.missing code { margin-right: 6px; }
.errlist { margin: 6px 0 0; padding-left: 18px; color: var(--red-text); font-size: 12.5px; }
details summary { cursor: pointer; }
.hash { color: var(--muted); }

.filters { display: flex; gap: 8px 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.field + .field, .field + .seg-tabs, .seg-tabs + .field { margin-left: 8px; }
.filters select { min-width: 170px; max-width: 100%; }
.filter-count { margin-left: auto; }
.pub-docs summary { color: var(--muted); }
.pub-docs[open] summary { margin-bottom: 4px; }
.compare-pick select { min-width: 0; width: min(440px, 100%); }

.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--line-2); background: var(--panel); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner-warn, .banner-insufficient { border-color: var(--gold-line); background: var(--gold-dim); }
.banner-fail { border-color: var(--red-line); background: var(--red-dim); }
.banner-pass { border-color: var(--green-line); background: var(--green-dim); }
.banner-unknown { border-color: var(--grey-line); background: var(--grey-dim); }
.banner-text { flex: 1 1 320px; min-width: 0; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--bg-2); }

.verify-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.verify-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-size: 20px; font-weight: 700; }
.verify-ok .verify-icon { background: var(--green-dim); color: var(--green-text); }
.verify-bad .verify-icon { background: var(--red-dim); color: var(--red-text); }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; justify-content: flex-end; }
.drawer-panel { width: min(760px, 100%); height: 100%; background: var(--bg-2); border-left: 1px solid var(--line-2); display: flex; flex-direction: column; box-shadow: var(--shadow-drawer); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { padding: 16px 20px 32px; overflow: auto; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0 0 16px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; }
.kv-tight { grid-template-columns: 92px 1fr; gap: 4px 10px; margin: 8px 0 10px; font-size: 13px; }
.kv-tight dt { font-size: 12px; }
.section-label { margin: 8px 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); }
.json { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px; font: 12.5px/1.55 var(--mono); overflow: auto; color: var(--text-2); white-space: pre; margin: 0; }
.j-key { color: var(--j-key); }
.j-str { color: var(--j-str); }
.j-num { color: var(--gold-text); }
.j-bool, .j-null { color: var(--j-bool); }
a.j-link { color: var(--gold-text); text-decoration: underline dotted; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; overflow: auto; background-color: var(--bg); display: grid; place-items: center; padding: 16px; background: var(--bg) radial-gradient(1100px 600px at 50% 0%, var(--login-glow), var(--login-glow-fade) 70%) no-repeat; }
.login-card { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-pop); }
.login-card label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.login-card .btn { justify-content: center; margin-top: 4px; }
.login-section { display: flex; flex-direction: column; gap: 8px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.login-divider::before, .login-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.login-card h2 { margin: 8px 0 0; font-size: 18px; }
.login-title { margin: 8px 0 0; font-size: 18px; font-weight: 650; }
.login-notice { margin: 0; padding: 9px 12px; border-radius: 8px; background: var(--gold-dim); border: 1px solid var(--gold-line); color: var(--text); font-size: 13.5px; }
.brand-lg .brand-text { flex-wrap: wrap; row-gap: 2px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 8px; z-index: 60; box-shadow: var(--shadow-toast); color: var(--text); }
.toast-ok { border-color: var(--green); }
.toast-error { border-color: var(--red); }
.toast-info { border-color: var(--blue-line); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .meta-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .ksi-groups { display: block; }
  .ksi-group { margin-bottom: 14px; }
  .ksi-item { width: calc(50% - 5px); }
  .shell { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-block; }
  .sidebar { position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 20; transform: translateX(-100%); visibility: hidden; transition: transform .15s, visibility 0s linear .15s; box-shadow: var(--shadow-drawer); overflow-y: auto; }
  .sidebar.open { transform: none; visibility: visible; transition: transform .15s; }
  .shell::before { display: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 56px 0 0 0; background: var(--overlay); z-index: 15; }
  .shell > .sidebar { background: var(--bg-2); border-right: 1px solid var(--line); z-index: 20; height: auto; }
  .main { padding: 18px 16px 40px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; gap: 10px; }
  .topbar .brand em, #user-name, #collector-name { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}

/* ---------- run detail & connectors ---------- */
.back { display: inline-block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.lede { color: var(--text-2); font-size: 14.5px; max-width: 860px; margin: 4px 0 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-num { font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tile-sub { font-size: 12px; color: var(--text-2); margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.tile-sub b { font-weight: 600; }
.t-green { color: var(--green-text); } .t-red { color: var(--red-text); } .t-gold { color: var(--gold-text); } .t-grey { color: var(--muted); } .t-blue { color: var(--blue-text); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 4px 0 18px; counter-reset: step; }
.step { position: relative; padding: 12px 14px 12px 44px; border: 1px solid var(--line); background: var(--panel); margin-right: -1px; font-size: 13px; color: var(--text-2); }
.step:first-child { border-radius: var(--radius) 0 0 var(--radius); } .step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 14px; top: 12px; width: 20px; height: 20px; border-radius: 50%; background: var(--primary-bg); color: var(--primary-fg); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.step b { display: block; color: var(--text); font-size: 13.5px; }
.srcs { display: flex; flex-direction: column; }
.src { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 170px); gap: 4px 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.src:last-child { border-bottom: none; }
.src-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; margin-top: 1px; }
.src-ok .src-icon { background: var(--green-dim); color: var(--green-text); }
.src-bad .src-icon { background: var(--red-dim); color: var(--red-text); }
.src-title { font-weight: 600; font-size: 14.5px; margin: 0; }
.src-title small { font-weight: 500; color: var(--muted); margin-left: 6px; font-size: 12px; }
.src-about { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.src-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); align-items: center; }
.src-facts b { color: var(--text); font-weight: 600; }
.src-side { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.src-err { margin-top: 8px; font-size: 12.5px; color: var(--red-text); background: var(--red-dim); border-radius: 6px; padding: 6px 10px; }
.link-s3 { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--blue-text); }
.link-s3::before { content: ''; width: 14px; height: 14px; border-radius: 3px; background: linear-gradient(135deg, var(--s3-1), var(--s3-2)); display: inline-block; }
.storage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.storage-item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.storage-item .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.storage-item code { display: block; margin-top: 3px; color: var(--text-2); word-break: break-all; }
.note { font-size: 12.5px; color: var(--text-2); background: var(--blue-dim); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.ksi-rows { display: flex; flex-direction: column; }
.ksi-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.ksi-row:last-child { border-bottom: none; }
.ksi-row .ksi-name-l { font-weight: 600; font-size: 13.5px; }
.checks { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--text-2); }
.checks li { padding: 2px 0; display: flex; gap: 8px; align-items: baseline; }
.checks li .badge { flex: none; }
.cov { display: flex; align-items: center; gap: 10px; }
.cov-bar { width: 100%; height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; display: flex; }
.cov-bar span { display: block; height: 100%; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { min-width: 260px; }
.seg-tabs { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg-tabs button { border: 0; background: none; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); border-right: 1px solid var(--line); }
.seg-tabs button:last-child { border-right: 0; }
.seg-tabs button[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); }
.cat { margin-bottom: 22px; }
.cat-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 10px; }
.cat-head h2 { margin: 0; font-size: 16px; }
.cat-head p { margin: 0; color: var(--muted); font-size: 13px; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.sys { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.sys:hover { border-color: var(--gold-bright); }
.sys-connected { border-left: 3px solid var(--green); } .sys-error { border-left: 3px solid var(--red); } .sys-incomplete { border-left: 3px solid var(--gold-bright); }
.sys-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sys-name { font-weight: 650; font-size: 15px; }
.sys-meta { font-size: 12.5px; color: var(--muted); }
.sys-ksis { display: flex; flex-wrap: wrap; gap: 4px; }
.badge-connected { color: var(--green-text); background: var(--green-dim); border-color: var(--green-line); }
.badge-available { color: var(--muted); background: var(--panel-2); border-color: var(--line-2); }
.badge-incomplete { color: var(--amber-text); background: var(--amber-dim); border-color: var(--amber-line); }
.method { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
.method-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.method-name { font-weight: 600; margin: 0; font-size: 14px; }
.method p { margin: 6px 0; color: var(--text-2); font-size: 13px; }
.snippet { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font: 12px/1.5 var(--mono); white-space: pre; overflow: auto; margin: 6px 0 0; color: var(--text); }
.fieldlist { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
@media (max-width: 1100px) { .tiles, .steps { grid-template-columns: 1fr 1fr; } .step { margin: 0 0 -1px; border-radius: 0 !important; } }
@media (max-width: 860px) { .tiles, .steps, .storage-grid { grid-template-columns: 1fr; } .src { grid-template-columns: 28px minmax(0, 1fr); } .src-side { grid-column: 2; align-items: flex-start; text-align: left; } .ksi-row { grid-template-columns: 1fr; } }
.runid { margin: 6px 0 16px; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .my6 { margin: 6px 0; }

/* published card and KSI history strip */
.pubgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 24px; align-items: start; }
.meta-grid .card { display: flex; flex-direction: column; }
.meta-grid .card .empty { padding: 6px 0; text-align: left; }
.pubgrid > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.ksi-hist { display: flex; gap: 2px; margin: 4px 0 2px; }
.ksi-hist .kh { width: 4px; height: 10px; border-radius: 1px; background: var(--grey); display: inline-block; }
.ksi-hist .kh-pass { background: var(--green); } .ksi-hist .kh-fail { background: var(--red); } .ksi-hist .kh-insufficient { background: var(--gold); }
@media (max-width: 860px) { .pubgrid { grid-template-columns: 1fr; } }

/* results counted for a KSI by configuration (also_ksis) */
.chip-mapped { border-style: dashed; }
.mapnote { margin-top: 4px; font-style: italic; }

/* ---------- scan in progress (live progress of the current run) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.scan { position: relative; overflow: hidden; border-color: var(--gold-line); padding: 18px 20px 16px;
  background: linear-gradient(135deg, var(--gold-dim), var(--panel) 45%); }
.scan.scan-finished { border-color: var(--green-line); background: linear-gradient(135deg, var(--green-dim), var(--panel) 45%); }
.scan-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.scan-head-text { min-width: 0; }
.scan-kicker { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--gold-text); }
.scan-finished .scan-kicker { color: var(--green-text); }
.scan-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-bright); box-shadow: 0 0 0 0 var(--gold-line); animation: scan-ping 1.6s ease-out infinite; }
.scan-finished .scan-pulse { background: var(--green); animation: none; }
@keyframes scan-ping { 0% { box-shadow: 0 0 0 0 var(--gold-line); } 80%, 100% { box-shadow: 0 0 0 8px rgba(212, 175, 106, 0); } }
.card h2.scan-title { margin: 4px 0 2px; font-size: 20px; font-weight: 650; letter-spacing: -0.2px; text-transform: none; color: var(--text); }
.scan-sub { margin: 0; overflow-wrap: anywhere; }
.scan-pct { font: 700 30px/1 var(--mono); color: var(--gold-text); font-variant-numeric: tabular-nums; flex: none; }
.scan-finished .scan-pct { color: var(--green-text); }
.pbar { position: relative; height: 10px; margin: 16px 0 10px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.pbar-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-2), var(--gold-bright) 70%, var(--brand-1)); transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.pbar-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: translateX(-100%); animation: pbar-sheen 2.2s ease-in-out infinite; }
.pbar-done .pbar-fill { background: var(--green); }
.pbar-done .pbar-fill::after { animation: none; display: none; }
.pbar-bad .pbar-fill { background: var(--amber); }
@keyframes pbar-sheen { 60%, 100% { transform: translateX(100%); } }
.scan-status { margin: 0 0 12px; font-weight: 600; color: var(--text-2); }
.scan-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.scan-step { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font-size: 12.5px; font-weight: 600; min-width: 0; }
.scan-step-icon { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-2); font: 700 11px/1 var(--mono); }
.scan-step-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-step-current { color: var(--text); border-color: var(--gold-line); background: var(--gold-dim); }
.scan-step-current .scan-step-icon { border-color: var(--gold); color: var(--gold-text); animation: pulse 1.6s ease-in-out infinite; }
.scan-step-done { color: var(--green-text); }
.scan-step-done .scan-step-icon { border-color: var(--green); background: var(--green); color: var(--bg-2); }

.scan-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 16px; align-items: start; }
.scan-grid .card { margin: 0; }
.psrc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.psrc { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.psrc:first-child { border-top: none; padding-top: 2px; }
.psrc-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font: 700 12px/1 var(--mono); border: 1.5px solid var(--grey-line); color: var(--muted); margin-top: 1px; }
.psrc-collecting .psrc-icon { border-color: var(--gold-dim); border-top-color: var(--gold); animation: spin .9s linear infinite; }
.psrc-done .psrc-icon { border-color: var(--green); background: var(--green-dim); color: var(--green-text); }
.psrc-error .psrc-icon { border-color: var(--red); background: var(--red-dim); color: var(--red-text); }
.psrc-skipped .psrc-icon { border-style: dashed; }
@keyframes spin { to { transform: rotate(360deg); } }
.psrc-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.psrc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.psrc-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.psrc-top .chip { margin: 0; }
.psrc-state { margin-left: auto; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.psrc-collecting .psrc-state { color: var(--gold-text); }
.psrc-done .psrc-state { color: var(--green-text); }
.psrc-error .psrc-state { color: var(--red-text); }
.psrc-counts:empty { display: none; }
.mini { position: relative; display: block; height: 4px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.mini-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; background: var(--grey); transition: width .4s ease; }
.psrc-done .mini-fill { background: var(--green); }
.psrc-error .mini-fill { background: var(--red); }
.psrc-skipped .mini-fill { background: var(--grey-line); }
.mini-fill.mini-busy { background: linear-gradient(90deg, transparent, var(--gold-bright), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: mini-slide 1.3s ease-in-out infinite; }
@keyframes mini-slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.pk-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); margin-bottom: 12px; }
.pk-key { display: inline-flex; align-items: center; gap: 6px; }
.pk-swatch { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; font: 700 10px/1 var(--mono); }
.pk-groups { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.pk-group { min-width: 0; }
.pk-group-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.pk-grid { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pk { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 50px; height: 44px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); transition: background-color .35s ease, border-color .35s ease, color .35s ease; }
.pk-id { font: 700 10.5px/1 var(--mono); letter-spacing: 0.3px; }
.pk-glyph { font: 700 13px/1 var(--mono); }
.pk-pending { border-style: dashed; border-color: var(--line-2); }
.pk-pending .pk-glyph { opacity: 0.6; }
.pk-pass, .pk-swatch.pk-pass { background: var(--green-dim); border-color: var(--green-line); color: var(--green-text); }
.pk-fail, .pk-swatch.pk-fail { background: var(--red-dim); border-color: var(--red-line); color: var(--red-text); }
.pk-insufficient, .pk-swatch.pk-insufficient { background: var(--gold-dim); border-color: var(--gold-line); color: var(--gold-text); }
.pk-unknown, .pk-swatch.pk-unknown { background: var(--grey-dim); border-color: var(--grey-line); color: var(--muted); }
.pk-in { animation: pk-pop .45s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pk-pop { 0% { transform: scale(.7); opacity: .3; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }

@media (max-width: 1100px) { .scan-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .scan { padding: 16px 14px 14px; }
  .scan-steps { grid-template-columns: 1fr 1fr; }
  .card h2.scan-title { font-size: 18px; }
  .scan-pct { font-size: 24px; }
}
@media (max-width: 420px) {
  .pk-groups { display: block; }
  .pk-group { margin-bottom: 12px; }
  .pk { width: calc((100% - 30px) / 6); min-width: 44px; }
  .pk-grid { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .scan-pulse, .scan-step-current .scan-step-icon, .psrc-collecting .psrc-icon, .pk-in, .pill-running { animation: none; }
  .pbar-fill, .mini-fill, .pk { transition: none; }
  .pbar-fill::after { animation: none; display: none; }
  .mini-fill.mini-busy { animation: none; background: var(--gold-bright); opacity: 0.6; }
}
/* Phone width: the top bar must not widen the page (the scan panel says a run is in progress). */
@media (max-width: 480px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .topbar { min-width: 0; gap: 8px; }
  .topbar-meta { gap: 6px; min-width: 0; }
  #run-indicator { display: none; }
  .theme-toggle span { display: none; }
  .brand-word { width: 96px; }
}

/* ---------- signatures ---------- */
.sigline { display: flex; gap: 6px; align-items: baseline; font-size: 12.5px; color: var(--text-2); margin-bottom: 12px; }
.meta-grid .sigline { margin: 0; }
.sig-mark { font-weight: 700; }
.sig-ok .sig-mark, .sig-ok > .sig-mark { color: var(--green-text); }
.sig-ok { color: var(--text-2); }
.sig-bad, .sig-bad .sig-mark { color: var(--red-text); }
.sig-none { color: var(--muted); }

/* ---------- one KSI ---------- */
.eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: 0.7px; text-transform: uppercase; color: var(--gold-text); }
.ksi-h-id { font-family: var(--mono); font-size: 0.86em; font-weight: 700; margin-right: 4px; }
.statement { margin: 0 0 16px; padding: 10px 16px; border-left: 3px solid var(--gold-line); background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0; max-width: 980px; }
.statement p { margin: 0 0 4px; font-size: 15px; color: var(--text); }
.statement footer { overflow-wrap: anywhere; }
.verdict-card { border-left: 4px solid var(--grey); }
.verdict-pass { border-left-color: var(--green); }
.verdict-fail { border-left-color: var(--red); }
.verdict-insufficient { border-left-color: var(--gold-bright); }
.verdict-text { margin: 0 0 6px; font-size: 15.5px; font-weight: 550; }
.verdict-card p { overflow-wrap: anywhere; }
.advice { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.advice li::marker { font-weight: 700; color: var(--muted); }
.advice p { margin: 0 0 3px; }
.advice-title { font-weight: 600; }
.advice-where { font-weight: 400; color: var(--muted); font-size: 13px; }
.advice-fix .advice-title, .advice-error .advice-title { color: var(--red-text); }
.advice-warn .advice-title { color: var(--amber-text); }
.advice-ok .advice-title { color: var(--green-text); }
.cand-list { margin: 4px 0; padding-left: 18px; font-size: 13px; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; }
.section-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 600; }
.section-head p { margin: 0; }
.methods-section { margin-bottom: 16px; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 14px; align-items: start; }
.method-col { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--grey); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.method-pass { border-top-color: var(--green); }
.method-fail { border-top-color: var(--red); }
.method-error, .method-warn { border-top-color: var(--amber); }
.method-col-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.method-col-head > div { min-width: 0; }
.method-col-head code { overflow-wrap: anywhere; }
.method-title { margin: 0 0 2px; font-size: 15px; font-weight: 650; }
.method-role { margin: 8px 0 4px; font-size: 13px; }
.method-col .section-label { margin-top: 14px; }
.check-list, .ev-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.check { padding: 8px 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); }
.check-fail { border-color: var(--red-line); background: var(--red-dim); }
.check-error, .check-warn { border-color: var(--amber-line); background: var(--amber-dim); }
.check-head { display: flex; gap: 8px; align-items: baseline; }
.check-head .badge { flex: none; }
.check-title { font-weight: 600; font-size: 13.5px; }
.check p { margin: 4px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.check-detail { color: var(--text-2); }
.check-fix { color: var(--text); }
.check-meta code { font-size: 11.5px; }
.ev { padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 8px; }
.ev-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; }
.ev-name code { font-size: 12px; }
.hashline { display: flex; gap: 6px; align-items: flex-start; }
.hash-full { font-size: 12px; word-break: break-all; color: var(--text-2); }
.copy { flex: none; }

/* ---------- compare, changes ---------- */
.changes { display: inline-flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; font-weight: 600; }
.count-diff { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 12px 0 16px; }
.count-cell { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--grey); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; }
.count-cell.stat-pass { border-top-color: var(--green); } .count-cell.stat-fail { border-top-color: var(--red); } .count-cell.stat-insufficient { border-top-color: var(--gold); }
.count-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.count-nums { font: 700 20px/1.3 var(--mono); }
.flips { list-style: none; margin: 0; padding: 0; }
.flip { display: grid; grid-template-columns: minmax(0, 1fr) 236px minmax(0, 2fr); gap: 6px 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); align-items: start; }
.flip:last-child { border-bottom: 0; }
.flip-ksi { display: flex; flex-direction: column; min-width: 0; }
.flip-verdicts { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.flip-verdicts .arrow { color: var(--muted); }
.flip-why { color: var(--text-2); overflow-wrap: anywhere; }
.flip-why code { font-size: 11.5px; }
.flip-worse { box-shadow: inset 3px 0 0 var(--red); }
.flip-better { box-shadow: inset 3px 0 0 var(--green); }

/* ---------- phones: tables become cards, the KSI list one column ---------- */
@media (max-width: 700px) {
  .table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; padding: 3px 0; border: 0; text-align: left; max-width: none; min-width: 0; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding-top: 2px; }
  .table.stack td.num { text-align: left; }
  .table .col-wide { min-width: 0; max-width: none; }
  .table-wrap { overflow-x: visible; }
  .stats { gap: 10px; }
  .stat { padding: 12px 14px 10px; }
  .stat-num { font-size: 26px; }
  .stat-meaning { display: none; }
  /* The KSI list as rows: id and verdict, then the name on one line. */
  .ksi-groups { padding: 4px 0 6px; }
  .ksi-group { margin: 0; }
  .ksi-group-head { padding: 12px 14px 6px; margin: 0; }
  .ksi-grid { gap: 0; border-top: 1px solid var(--line); }
  .ksi-item { width: 100%; }
  .ksi { min-height: 0; border-radius: 0; border-width: 0 0 1px 3px; padding: 8px 14px; gap: 1px; }
  .ksi:hover { transform: none; }
  .ksi-name { -webkit-line-clamp: 1; line-clamp: 1; }
  .ksi-foot { display: none; }
  .card .toolbar.filters { padding: 12px 14px; }
  .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
  .field { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
  .field + .field, .field + .seg-tabs, .seg-tabs + .field { margin-left: 0; }
  .field-search, .filters .seg-tabs, .filters > .btn, .filter-count { grid-column: 1 / -1; }
  .filter-count { margin: 0; }
  .filters select, .filters input[type=search], .ksi-card .filters select { width: 100%; min-width: 0; }
  .filters > .btn { justify-self: start; }
  .meta-grid .hash { display: none; }
  .count-diff { grid-template-columns: 1fr 1fr; }
  .flip { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 14px; }
  .flip-why { grid-column: 1 / -1; }
  .hashline { flex-direction: column; gap: 4px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px; }
  .tile-num { font-size: 22px; }
  .cat-head { flex-direction: column; gap: 2px; }
  .kv-tight { grid-template-columns: 1fr; }
  .statement p { font-size: 14px; }
}
@media (max-width: 860px) {
  .ksi-groups { padding: 14px; }
}
