/* AgentHub admin console — dense ops-console styling, light/dark via CSS variables. */

:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f0f2f6;
  --panel-3: #e6e9ef;
  --border: #d9dee6;
  --border-strong: #c3cad5;
  --text: #18202b;
  --muted: #5a6575;
  --accent: #2357d6;
  --accent-hover: #1b46b0;
  --accent-fg: #ffffff;
  --accent-soft: #e5edfd;
  --ok: #157a3b;
  --ok-bg: #e3f5e9;
  --warn: #935400;
  --warn-bg: #fff1d6;
  --crit: #b3261e;
  --crit-bg: #fde7e5;
  --info: #1d5bb8;
  --info-bg: #e4eefc;
  --off: #556070;
  --off-bg: #eaedf1;
  --run: #6534c9;
  --run-bg: #efe8fd;
  --focus: #2f6bff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 8px;
  --radius-sm: 5px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 196px;
  --topbar-h: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --panel: #151b23;
    --panel-2: #1b222c;
    --panel-3: #232c38;
    --border: #2a3441;
    --border-strong: #3a4656;
    --text: #e2e8f0;
    --muted: #9aa6b6;
    --accent: #5b9bff;
    --accent-hover: #7fb0ff;
    --accent-fg: #07111f;
    --accent-soft: #16294a;
    --ok: #56d98a;
    --ok-bg: #10301f;
    --warn: #f5bd4f;
    --warn-bg: #352708;
    --crit: #ff7b72;
    --crit-bg: #3b1513;
    --info: #79b0ff;
    --info-bg: #132a4c;
    --off: #a3adbb;
    --off-bg: #232a34;
    --run: #b99bff;
    --run-bg: #2a1f4b;
    --focus: #7fb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1b222c;
  --panel-3: #232c38;
  --border: #2a3441;
  --border-strong: #3a4656;
  --text: #e2e8f0;
  --muted: #9aa6b6;
  --accent: #5b9bff;
  --accent-hover: #7fb0ff;
  --accent-fg: #07111f;
  --accent-soft: #16294a;
  --ok: #56d98a;
  --ok-bg: #10301f;
  --warn: #f5bd4f;
  --warn-bg: #352708;
  --crit: #ff7b72;
  --crit-bg: #3b1513;
  --info: #79b0ff;
  --info-bg: #132a4c;
  --off: #a3adbb;
  --off-bg: #232a34;
  --run: #b99bff;
  --run-bg: #2a1f4b;
  --focus: #7fb0ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
/* The UA's [hidden] rule loses to any author `display` (e.g. .field, .btn): make `hidden` always win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 var(--font);
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
code { background: var(--panel-2); border-radius: 4px; padding: 0 4px; overflow-wrap: anywhere; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.3; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; margin-top: 14px; color: var(--muted); text-transform: none; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
summary { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent-soft); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; margin: 12px 0; }
.lead { font-size: 14px; }
.pre-line { white-space: pre-line; overflow-wrap: anywhere; }
.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; }
.t-ok { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-crit { color: var(--crit); }
.inline-h { display: inline; margin: 0; }
.count:not(:empty) { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 12px; text-align: center; vertical-align: 2px; }
.id { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

.skip { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--accent); color: var(--accent-fg); padding: 8px 12px; }
.skip:focus { left: 8px; top: 8px; }

/* ---------------------------------------------------------------- shell */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 22px; margin-bottom: 4px; }
.brand-sub { font-weight: 500; font-size: 13px; }
.logo { color: var(--accent); }
.top-badges { display: flex; gap: 6px; align-items: center; min-width: 0; overflow: hidden; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.whoami { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; border: 1px solid transparent; flex-shrink: 0; }
.pill:hover { text-decoration: none; filter: brightness(.97); }
.p-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.p-crit { background: var(--crit-bg); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 30%, transparent); }
.p-ok { background: var(--ok-bg); color: var(--ok); }

.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 10px 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.sidebar a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500;
}
.sidebar a:hover { background: var(--panel-2); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav-count:empty { display: none; }
.nav-count { min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; text-align: center; font-weight: 600; }
.c-crit { background: var(--crit); color: #fff; }
.c-warn { background: var(--warn-bg); color: var(--warn); }
.nav-foot { margin-top: auto; padding: 8px 10px 0; }
.scrim { display: none; }

.view { padding: 18px 22px 48px; min-width: 0; outline: none; }
.view > * { max-width: 1500px; }

/* ---------------------------------------------------------------- login / boot */

.boot, .loading { display: flex; align-items: center; gap: 8px; padding: 32px; color: var(--muted); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(420px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login .field { margin: 0; }
.hint { font-size: 12px; color: var(--muted); }
.hint summary { color: var(--accent); }

/* ---------------------------------------------------------------- page structure */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head > div:first-child { min-width: 0; flex: 1 1 320px; }
.page-head h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.page-head p { margin: 2px 0 0; }
.head-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 8px; overflow-wrap: anywhere; }
.section { margin-bottom: 16px; min-width: 0; }
.section > h2 { margin-bottom: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h2 { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .section { margin-bottom: 16px; }
.toc { margin: -4px 0 14px; color: var(--muted); }
.field-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.attention { border-left: 3px solid var(--warn); padding-left: 12px; }
.card.attention { border-left-width: 3px; border-left-color: var(--warn); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 7px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-height: 30px; padding: 4px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
:root[data-theme="dark"] .btn.danger { color: #1a0605; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { color: #1a0605; } }
.btn.danger:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger.ghost { background: transparent; color: var(--crit); border-color: transparent; }
.btn.danger.ghost:hover { background: var(--crit-bg); }
.btn.icon { width: 32px; padding: 0; font-size: 16px; }
.btn.small { min-height: 26px; padding: 2px 9px; font-size: 12px; }
.btn.tiny { min-height: 22px; padding: 0 7px; font-size: 11px; }
.btn.block { width: 100%; min-height: 36px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
/* After .btn (same specificity, so order decides) and before the 860px media query that shows it. */
.menu-btn { display: none; }
.linklike:hover { text-decoration: underline; }

.switch { position: relative; width: 34px; height: 20px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--panel-3); cursor: pointer; padding: 0; }
.switch span { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); transition: left .15s; }
.switch.on { background: var(--ok); border-color: var(--ok); }
.switch.on span { left: 16px; }

/* ---------------------------------------------------------------- forms */

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 5px 8px; min-height: 30px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; line-height: 1.45; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent); outline-offset: 0; border-color: var(--focus); }
input.invalid, textarea.invalid { border-color: var(--crit); background: color-mix(in srgb, var(--crit-bg) 45%, var(--panel)); }
input[type="checkbox"] { min-height: 0; width: 15px; height: 15px; accent-color: var(--accent); vertical-align: -2px; }
input[type="file"] { padding: 4px; }
.field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; min-width: 0; }
.field > span:first-child { font-size: 12px; color: var(--muted); font-weight: 550; }
.field input, .field select { width: 100%; }
.field.inline { margin-bottom: 0; }
.field.inline input, .field.inline select { width: auto; min-width: 120px; }
.field.grow { flex: 1 1 260px; }
.field.grow input { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.json-hint { font-size: 11.5px; min-height: 16px; }
.json-hint.ok { color: var(--ok); }
.json-hint.bad { color: var(--crit); }
.filters {
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
}
.filters .check { padding-bottom: 6px; }
.filters fieldset.cats { flex: 1 1 100%; border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.filters fieldset.cats legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 4px; float: left; width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: start; }
.form-grid .span-2, .form-grid details { grid-column: 1 / -1; }
.form-grid .check { margin-bottom: 10px; }
.form-grid details { margin-bottom: 10px; }
.form-grid details > summary { color: var(--accent); font-size: 12px; margin-bottom: 8px; }
.note-form { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin-top: 10px; }
.note-form .field { width: 100%; margin: 0; }

/* ---------------------------------------------------------------- badges, chips, dots */

.badge {
  display: inline-block; padding: 0 7px; border-radius: 4px;
  font-size: 11.5px; font-weight: 600; line-height: 19px; white-space: nowrap;
  font-family: var(--mono); letter-spacing: -.1px; vertical-align: middle;
}
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-crit { background: var(--crit-bg); color: var(--crit); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-off { background: var(--off-bg); color: var(--off); }
.b-run { background: var(--run-bg); color: var(--run); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.d-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.d-warn { background: var(--warn); }
.d-crit { background: var(--crit); }
.d-off { background: var(--off); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 6px; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--border);
  font-size: 11.5px; line-height: 19px; max-width: 100%; white-space: nowrap;
}
a.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.more { color: var(--muted); }
.checks { font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* ---------------------------------------------------------------- tables */

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.card .table-wrap { border-radius: var(--radius-sm); }
.table-wrap.scroll-y { max-height: 420px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  background: var(--panel-2); padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
/* break-word (not anywhere): long tokens still wrap when the column is wide enough, but they no longer
   shrink a column's min-content to one character; .table-wrap scrolls instead. */
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: break-word; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.tbl.compact td { padding: 5px 8px; }
.tbl.compact th { padding: 5px 8px; }
.tbl td:first-child { min-width: 140px; }
.row-warn td { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.row-crit td { background: color-mix(in srgb, var(--crit-bg) 55%, transparent); }
.row-crit td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
.row-muted td { opacity: .62; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 2px; flex-wrap: wrap; }

.load { display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.bar { display: inline-block; height: 5px; width: 80px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.progress { display: inline-flex; align-items: center; gap: 6px; }

/* logs */
.logs td.msg { min-width: 260px; }
/* category/action: api actions are full request paths; let them break anywhere so one long path
   cannot widen the column and push the message off-screen. */
.logs td.act { min-width: 120px; overflow-wrap: anywhere; }
.filters fieldset.cats .chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.log-row { cursor: pointer; }
.log-row.lv-error td { background: color-mix(in srgb, var(--crit-bg) 50%, transparent); }
.log-row.lv-warn td { background: color-mix(in srgb, var(--warn-bg) 40%, transparent); }
.log-row.lv-debug { color: var(--muted); }
.log-detail td { background: var(--panel-2); }
.log-wrap { max-height: calc(100vh - 300px); min-height: 240px; overflow-y: auto; }
.cat { font-family: var(--mono); font-weight: 600; }

/* ---------------------------------------------------------------- callouts, kv, json, empty */

.callout { padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid; margin: 0 0 10px; overflow-wrap: anywhere; }
.callout.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.callout.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout.crit { background: var(--crit-bg); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 25%, transparent); }
.callout.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.callout a { color: inherit; text-decoration: underline; }

.kv { display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); gap: 5px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.json-wrap { position: relative; margin: 4px 0 8px; }
.json-wrap .copy-btn { position: absolute; top: 4px; right: 4px; opacity: .65; }
.json-wrap:hover .copy-btn, .json-wrap .copy-btn:focus { opacity: 1; }
pre.json, pre.code, pre.md-code {
  margin: 0; padding: 10px 12px; max-height: 420px; overflow: auto;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
pre.code { margin: 4px 0 10px; }
.j-key { color: var(--info); }
.j-str { color: var(--ok); }
.j-num { color: var(--run); }
.j-lit { color: var(--warn); }
.code-block { position: relative; }
.code-block .copy-btn { position: absolute; top: 6px; right: 6px; }

.empty { padding: 26px 16px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: color-mix(in srgb, var(--panel) 70%, transparent); }
.empty-title { font-weight: 600; margin-bottom: 4px; }
.empty-hint { color: var(--muted); font-size: 12.5px; max-width: 560px; margin: 0 auto; }

ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
ol.notes { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 10px; }
ol.notes li { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 10px; }

/* ---------------------------------------------------------------- overview */

.approvals { display: flex; flex-direction: column; gap: 10px; }
.approval { padding: 12px 14px; border-left: 4px solid var(--warn); }
.approval.r-high { border-left-color: var(--crit); }
.approval.r-low { border-left-color: var(--info); }
.approval.done { opacity: .5; }
.approval-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; margin-bottom: 4px; }
.approval-title { font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.approval-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.approval-summary { margin: 4px 0 6px; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.approval-actions input { flex: 1 1 240px; min-width: 0; }

.alert-group { margin-bottom: 10px; }
.group-title { font-size: 12.5px; margin: 0 0 6px; }
.group-title.t-crit { color: var(--crit); }
.group-title.t-warn { color: var(--warn); }
details.alert-group > summary { color: var(--muted); font-weight: 600; }
.alert-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.alert-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.alert-row:last-child { border-bottom: 0; }
.alert-title { font-weight: 550; overflow-wrap: anywhere; }
.alert-side { text-align: right; white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; }
.tile { display: block; padding: 11px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); border-top: 3px solid var(--border-strong); }
a.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile.t-ok { border-top-color: var(--ok); color: var(--text); }
.tile.t-warn { border-top-color: var(--warn); color: var(--text); }
.tile.t-crit { border-top-color: var(--crit); color: var(--text); }
.tile-label { font-size: 12px; color: var(--muted); font-weight: 550; }
.tile-value { font-size: 24px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.tile-of { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.tile-sub { font-size: 11.5px; color: var(--muted); }

.report { border-bottom: 1px solid var(--border); padding: 6px 0 10px; }
.report:last-of-type { border-bottom: 0; }
.report > summary { font-weight: 600; padding: 4px 0; }
.report-summary { margin-top: 6px; }

ol.timeline { list-style: none; margin: 0 0 8px; padding: 0; position: relative; }
ol.timeline li { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
ol.timeline li:last-child { border-bottom: 0; }
.tl-time { padding-top: 2px; white-space: nowrap; }
.tl-body { min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- markdown */

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 8px; }
.md .md-h { margin: 14px 0 6px; color: var(--text); }
.md h3.md-h { font-size: 15px; }
.md h4.md-h { font-size: 13.5px; }
.md h5.md-h, .md h6.md-h { font-size: 13px; color: var(--muted); }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md blockquote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md pre.md-code { margin: 0 0 8px; }
.md .table-wrap { margin-bottom: 8px; }
.md table.md-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md table.md-table th, .md table.md-table td { border-bottom: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.md table.md-table th { background: var(--panel-2); }
.md-box { font-size: 14px; }
.md-box.done { color: var(--ok); }
.preview { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 420px; overflow: auto; background: var(--panel-2); }

/* ---------------------------------------------------------------- modal */

dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  padding: 0; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal.wide { width: min(860px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(10, 14, 22, .5); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--panel-2); border-radius: 0 0 10px 10px; }
.modal-error { margin-top: 8px; }
.secret-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret { flex: 1 1 260px; padding: 8px 10px; font-size: 13px; user-select: all; word-break: break-all; }

/* ---------------------------------------------------------------- toasts */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius); box-shadow: var(--shadow-lg);
  background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--info);
  animation: toast-in .18s ease-out; overflow-wrap: anywhere;
}
.toast.t-error { border-left-color: var(--crit); }
.toast.t-ok { border-left-color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); transition: all .2s; }
.toast-msg { flex: 1; }
.toast-x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 40;
    width: 240px; height: auto;
    transform: translateX(-100%); transition: transform .18s ease-out;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 35; background: rgba(10, 14, 22, .4); }
  .view { padding: 14px 16px 40px; }
  .brand-sub, .whoami, .conn-label { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
}

@media (max-width: 600px) {
  body { font-size: 14px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  /* Two columns instead of one full-width row per filter, so data starts above the fold. */
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; padding: 8px 10px; }
  .filters > .field.grow, .filters > fieldset.cats, .filters > .span-2 { grid-column: 1 / -1; }
  .filters .field > span:first-child { font-size: 11.5px; }
  /* Category chips: one horizontally scrollable row (the legend shows how many are selected). */
  .filters fieldset.cats { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; min-width: 0; min-inline-size: 0; }
  .filters fieldset.cats legend { float: none; margin-bottom: 2px; }
  .filters fieldset.cats .chip { flex: 0 0 auto; }
  .field.inline input, .field.inline select { width: 100%; min-width: 0; }
  /* Logs: one stacked row per event (time · level · category/action, then the message full-width),
     so the message is readable without scrolling sideways. */
  .log-wrap { overflow-x: hidden; }
  .logs, .logs tbody, .logs tr, .logs td { display: block; }
  .logs thead { display: none; }
  .logs tr { border-bottom: 1px solid var(--border); }
  .logs tbody tr:last-child { border-bottom: 0; }
  .logs td, .logs td:first-child, .logs td.msg, .logs td.act { min-width: 0; border-bottom: 0; }
  .logs tr.log-row { display: grid; grid-template-columns: max-content max-content minmax(0, 1fr); }
  .logs tr.log-row td { padding: 5px 8px 0; }
  .logs tr.log-row td.msg { grid-column: 1 / -1; padding-top: 2px; }
  .logs tr.log-row td.actor { grid-column: 1 / -1; padding: 0 8px 5px; }
  .logs tr.log-row td.actor:empty { padding: 0 0 3px; }
  .alert-row { grid-template-columns: auto minmax(0, 1fr); }
  .alert-side { grid-column: 2; text-align: left; white-space: normal; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 20px; }
  ol.timeline li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  .kv dt { margin-top: 6px; }
  .page-head h1 { font-size: 18px; }
  .top-badges .pill { padding: 2px 7px; }
  .top-badges .pill-label { display: none; } /* colour + count only; full text in title/aria-label */
  .log-wrap { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Link to the public docs site at the bottom of the sidebar. */
.sidebar .nav-docs { margin-top: 8px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 10px; }
.login-docs { margin: 12px 0 0; text-align: center; }
