/* ── Admin Dashboard SPA Styles ──
 * @file admin.css
 * @description Admin dashboard (operator tooling) styles, .adm-* scoped. Keeps
 *   its distinct indigo accent and a permanently-dark sidebar, but all content
 *   surfaces map to global theme.css tokens so they flip with dark/light mode.
 * @version-history
 *   v1.11.0 — 2026-08-15 — Organism ownership tab: .adm-oo-row / .adm-oo-card. The panel first
 *     shipped with the profile's .detail-card/.form-row classes, which admin.css does not define, so
 *     label and value rendered with no gap ("Ownershappyadmin") and the button dropped under the
 *     input. Caught by driving the browser, not by any gate.
 *   v1.10.0 — 2026-07-21 — App-shell scroll model (theme.css v1.24.0): .adm-sidebar height 100vh →
 *     calc(100dvh − nav-height) so the sticky sidebar fills the .page-content scroll region instead of
 *     overflowing the frame by the header's height.
 *   v1.9.0 — 2026-07-16 — Drop the dead .adm-nav-item .icon rule (nav is label-only now).
 *   v1.8.0 — 2026-06-25 — Applications tab: .adm-apps-rowactions (Hide/Restore + Delete row).
 *   v1.7.0 — 2026-06-24 — Applications moderation tab: .adm-apps-* (filters row,
 *     hidden-only toggle, dimmed hidden rows, modal actions).
 *   v1.6.0 — 2026-06-12 — Subdomains tab: .adm-subdomain-form create-form grid
 *     + .adm-subdomain-modal-actions (right-aligned type-to-confirm buttons).
 *   v1.5.0 — 2026-06-02 — Component unification (#13 tables): strip the dead
 *     `, #E5E7EB` hardcoded fallback from `.adm-breakdown-table th` border
 *     (.adm always maps --glass-border → --border, so the fallback was dead
 *     light-frozen code). No visual change. The .adm table look is unchanged
 *     (scoped .adm table still wins over the new generic .data-table).
 *   v1.1.0 — 2026-06-02 — Tokenize all surfaces/text/borders/badges for dark mode (Phase 2).
 *   v1.2.0 — 2026-06-02 — Component unification (#3): remove .adm-modal-overlay
 *     duplicate; msm-tab now uses canonical theme.css .modal-overlay.
 *   v1.3.0 — 2026-06-02 — Component unification (#16): add tokenized
 *     .tag--status-* classes (replace agent-tasks-tab inline hex status colors).
 *   v1.4.0 — 2026-06-02 — Component unification (#21 key/value rows): strip the
 *     dead `, #6366F1` hardcoded hex fallbacks from every `var(--accent, #6366F1)`
 *     (10 sites incl. .adm-hval) — .adm always defines --accent (indigo light /
 *     #818CF8 dark), so the fallback was light-mode-frozen dead code. No visual
 *     change; removes hardcoded hex per Rule 7.3. .adm-erow/.adm-hrow markup left
 *     in place (mono/bordered look differs from canonical .kv-row).
 */

/* Admin-scoped variables: indigo accent identity + surfaces mapped to global
   (flipping) tokens. Text tiers inherit the global tokens so they flip too. */
.adm {
  --accent: #6366F1;
  --accent-light: rgba(99, 102, 241, 0.12);
  --glass-border: var(--border);
  --glass-bg: var(--bg-card);
  --bg-deep: var(--bg);
  --sidebar-bg: #1E293B;            /* dark slate — sidebar stays dark in both themes (by design) */
  --sidebar-text: #CBD5E1;
  --sidebar-border: rgba(255, 255, 255, 0.08);
}
/* Brighten the indigo accent for contrast on dark surfaces */
[data-theme="dark"] .adm { --accent: #818CF8; }

/* Layout */
.adm { display: flex; min-height: 100vh; position: relative; z-index: 1; background: var(--bg-deep); color: var(--text); }

/* Sidebar — stays dark per mockup (its colors are intentionally fixed) */
.adm-sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  border-right: none;
  padding: 16px 0;
  flex-shrink: 0;
  /* App-shell: sticks to the top of the .page-content scroll region; height caps
     at that region (viewport minus the fixed header) so the sidebar's own nav
     scrolls instead of overflowing past the frame by the header's height. */
  position: sticky;
  top: 0;
  height: calc(100dvh - var(--nav-height, 56px));
  box-sizing: border-box; /* fold the 16px vertical padding into the height so it fits the scroll region */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.adm-sidebar .node-id {
  padding: 0 18px;
  padding-top: 4px;
  color: #475569;
  font-size: .69rem;
  font-family: var(--font-mono);
  margin-bottom: 16px;
  word-break: break-all;
}
.adm-nav-group {
  font-size: .625rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #475569;
  padding: 0 18px;
  margin-top: 16px;
  margin-bottom: 4px;
  font-weight: 700;
}
.adm-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 18px;
  color: var(--sidebar-text, #CBD5E1);
  font-size: .84rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-weight: 400;
  transition: all .1s;
  border-left: 3px solid transparent;
}
.adm-nav-item:hover { background: rgba(255,255,255,0.04); color: #F1F5F9; }
.adm-nav-item.active {
  color: #FFFFFF;
  background: rgba(99,102,241,0.18);
  border-left-color: var(--accent);
  font-weight: 500;
}
.adm-nav-item .label { flex: 1; }
.adm-nav-item .cnt {
  background: rgba(255,255,255,0.08);
  color: #94A3B8;
  font-size: .69rem;
  padding: 1px 7px;
  border-radius: 9999px;
  font-weight: 600;
}
.adm-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 8px 16px; }

/* Main area */
.adm-main { flex: 1; padding: 24px 32px; overflow-y: auto; background: var(--bg-deep); }
.adm-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.adm-topbar-right { display: flex; align-items: center; gap: 12px; }
.adm-page-title {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Cards */
.adm-grid { display: grid; gap: 16px; margin-bottom: 20px; }
.adm-grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.adm-grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.adm-grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.adm-card {
  background: var(--glass-bg, #FFFFFF);
  border: 1px solid var(--glass-border, #E5E7EB);
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}
.adm-card h2 {
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 700;
}
.adm-subhead {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 700;
  margin: 10px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.adm-stat { font-size: 1.625rem; font-weight: 800; line-height: 1.1; color: var(--text); }
.adm-stat.indigo { color: var(--accent); }
.adm-stat.mint,
.adm-stat.green  { color: var(--mint); }
.adm-stat.cyan   { color: var(--teal); }
.adm-stat.amber  { color: var(--warn); }
.adm-stat.purple { color: var(--purple); }
.adm-stat.blue   { color: var(--blue); }
.adm-stat.orange { color: var(--orange); }
.adm-stat.red    { color: var(--danger); }
.adm-stat-label { color: var(--text-muted); font-size: .69rem; margin-top: 2px; }

/* Storage/Database tab — per-table growth deltas + the counts table. */
.adm-delta-up   { color: var(--success); }
.adm-delta-down { color: var(--danger); }
.adm-delta-zero { color: var(--text-muted); }
.adm-db-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.adm-db-table th, .adm-db-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.adm-db-table th { color: var(--text-muted); font-weight: 600; }
.adm-db-table td.num, .adm-db-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.adm-db-bar { height: 6px; border-radius: 3px; background: var(--blue); min-width: 2px; }
.adm-db-bar-track { background: var(--bg-dim); border-radius: 3px; width: 100%; }

/* Badges */
.adm-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
}
/* Badge semantic colors */
.adm-badge--success { background: var(--success-bg); color: var(--success-fg); }
.adm-badge--warning { background: var(--warn-bg); color: var(--warn-fg); }
.adm-badge--danger  { background: var(--danger-bg); color: var(--danger-fg); }
.adm-badge--info    { background: var(--info-bg); color: var(--info-fg); }
.adm-badge--accent  { background: var(--purple-bg); color: var(--purple-fg); }
.adm-badge--muted   { background: var(--bg-surface); color: var(--text-dim); }
/* Single-dash aliases — the <Badge> component emits adm-badge-${type}, so these
   semantic tones need the single-dash form too (were undefined → badges rendered
   with no background in cortex/capabilities/federation tabs). neutral = muted. */
.adm-badge-success { background: var(--success-bg); color: var(--success-fg); }
.adm-badge-warning { background: var(--warn-bg); color: var(--warn-fg); }
.adm-badge-muted,
.adm-badge-neutral { background: var(--bg-surface); color: var(--text-dim); }

/* Badge name aliases → semantic colors */
.adm-badge-healthy,
.adm-badge-public,
.adm-badge-delivered,
.adm-badge-settled,
.adm-badge-owner      { background: var(--success-bg); color: var(--success-fg); }

.adm-badge-watch,
.adm-badge-pending    { background: var(--warn-bg); color: var(--warn-fg); }

.adm-badge-danger,
.adm-badge-critical,
.adm-badge-cancelled,
.adm-badge-expired,
.adm-badge-disputed,
.adm-badge-error      { background: var(--danger-bg); color: var(--danger-fg); }

.adm-badge-info,
.adm-badge-accepted,
.adm-badge-in_progress,
.adm-badge-operator,
.adm-badge-syncing    { background: var(--info-bg); color: var(--info-fg); }

.adm-badge-private,
.adm-badge-agent      { background: var(--purple-bg); color: var(--purple-fg); }

.adm-badge-idle,
.adm-badge-general    { background: var(--bg-surface); color: var(--text-dim); }

/* Error / success toast */
.adm-toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .85rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: adm-toast-in .2s ease;
}
.adm-toast-error   { background: var(--danger-bg); color: var(--danger-fg); border: 1px solid var(--danger-border); }
.adm-toast-success { background: var(--success-bg); color: var(--success-fg); border: 1px solid var(--success-border); }
.adm-toast-dismiss {
  margin-left: auto;
  cursor: pointer;
  opacity: .6;
  background: none;
  border: none;
  color: inherit;
  font-size: 1rem;
}
.adm-toast-dismiss:hover { opacity: 1; }
@keyframes adm-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Economy rows */
.adm-erow { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border-subtle); }
.adm-erow:last-child { border-bottom: none; }
.adm-elabel { color: var(--text-dim); font-size: .84rem; }
.adm-eval { font-family: var(--font-mono); font-size: .81rem; font-weight: 600; color: var(--text); }

/* Health rows */
.adm-hrow { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); }
.adm-hrow:last-child { border-bottom: none; }
.adm-hmetric { font-size: .84rem; color: var(--text-dim); }
.adm-hval { font-family: var(--font-mono); font-size: .84rem; color: var(--accent); }

/* Tables */
.adm table { width: 100%; border-collapse: collapse; font-size: .81rem; }
.adm th { text-align: left; color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: .69rem; text-transform: uppercase; letter-spacing: .3px; }
.adm td { padding: 8px 10px; border-bottom: 1px solid var(--border-subtle); color: var(--text-dim); }
.adm tr:hover td { background: var(--bg-surface); }

/* Misc */
.adm .mono { font-family: var(--font-mono); font-size: .78rem; }
.adm .scrollable { max-height: 600px; overflow-y: auto; }
.adm .empty { color: var(--text-muted); text-align: center; padding: 24px; font-size: .85rem; }
.adm .error-box { background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: 8px; padding: 16px; color: var(--danger-fg); margin: 20px 0; }
.adm .tag { display: inline-block; background: var(--bg-surface); color: var(--text-dim); padding: 1px 6px; border-radius: 4px; font-size: .7rem; margin: 1px; }
/* Status-colored task tags — tokenized (were inline hex colors). Color only;
   base .adm .tag has no border so border-color stays inert as before. */
.adm .tag--status-active  { color: var(--accent); }
.adm .tag--status-done    { color: var(--success); }
.adm .tag--status-failed  { color: var(--danger); }
.adm .tag--status-stalled { color: var(--warn); }
.adm .tag--status-queued  { color: var(--purple); }
.adm .tag--status-draft   { color: var(--text-dim); }

/* Buttons */
.adm-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: .81rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .15s;
}
.adm-btn:hover { filter: brightness(0.92); }
.adm-btn:disabled { opacity: .5; cursor: not-allowed; }
.adm-btn-sm {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .75rem;
  font-family: inherit;
}
.adm-btn-sm:hover { background: var(--bg-surface); }
.adm-btn-action {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .78rem;
  font-family: inherit;
}
.adm-btn-action:hover { background: var(--bg-surface); }

/* Sub-panels */
.adm-sub-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
  font-size: .8rem;
}

/* Inputs */
.adm input[type="text"],
.adm input[type="number"],
.adm input[type="email"],
.adm input[type="password"],
.adm textarea,
.adm select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}
.adm input:focus,
.adm textarea:focus,
.adm select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
  outline: none;
}

/* Login overlay */
.adm-login {
  max-width: 420px;
  margin: 60px auto;
  text-align: center;
}
.adm-login h2 {
  font-size: 1.2rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 4px;
}
.adm-login p { color: var(--text-dim); font-size: .85rem; margin-bottom: 16px; }
.adm-login input { width: 100%; margin-bottom: 8px; }
.adm-login-err {
  margin-top: 10px;
  padding: 8px;
  border-radius: 6px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-fg);
  font-size: .85rem;
}

/* Config editor */
.adm-config-changes {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 8px;
}
/* The pending bar follows the viewport, because the thing it reports — work that is not saved yet —
   happens wherever you are on a page that is many screens long.
   FIXED rather than sticky, and that was measured: the admin content sits inside `.adm-main`, which
   has `overflow: auto` and is as tall as its content, so it is the nearest scrollport while the
   actual scrolling happens in `.page-content` above it. A sticky bar therefore sticks to the top of
   a box that itself scrolls away — measured at top: -1274px after one screen of scrolling, which is
   the exact failure this bar exists to prevent. */
.adm-cfg-pending {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  margin-bottom: 0;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.18);
}
.adm-cfg-pending-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.adm-cfg-pending-hint { font-size: .8rem; opacity: .85; }
.adm-cfg-pending-actions { margin-left: auto; }
.adm-cfg-pending-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: .8rem;
  max-height: 30vh;
  overflow-y: auto;
}
.adm-cfg-pending-list li { margin: 2px 0; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.adm-cfg-pending-was { text-decoration: line-through; opacity: .7; margin: 0 4px; }

/* An edited row stays findable after you have scrolled past it. */
.adm-cfg-row-edited { background: var(--warn-bg); border-radius: 6px; }
.adm-cfg-edited-dot { color: var(--warn-fg, #eab308); font-size: .8rem; }

/* Contents block */
.adm-cfg-toc-summary { cursor: pointer; font-weight: 600; font-size: .95rem; padding: 8px 0; }
.adm-cfg-toc-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  padding: 8px 0;
}
.adm-cfg-toc-domain-name {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.adm-cfg-toc-links { display: flex; flex-wrap: wrap; gap: 4px; }
.adm-cfg-toc-link {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: .78rem;
  cursor: pointer;
  color: inherit;
}
.adm-cfg-toc-link:hover { border-color: var(--accent-border); }
.adm-cfg-toc-count { color: var(--text-muted); font-size: .7rem; }

.adm-cfg-domain-head {
  margin: 20px 0 8px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}

.adm-config-array-edit {
  width: 360px;
  max-width: 100%;
  min-height: 4.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  padding: 6px 8px;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 6px;
  resize: vertical;
  box-sizing: border-box;
}
.adm-config-readonly { opacity: 0.85; pointer-events: none; }
.adm-config-readonly input,
.adm-config-readonly select { background: var(--bg-surface); cursor: not-allowed; }
.adm-config-readonly-banner {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 8px;
  color: var(--info-fg);
  font-size: .85rem;
}
.adm-config-result-ok {
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
}

/* Expandable help sections */
.adm-help {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
}
.adm-help-summary {
  cursor: pointer;
  padding: 10px 14px;
  color: var(--accent);
  font-size: .85rem;
  font-weight: 600;
  user-select: none;
}
.adm-help-summary:hover { color: var(--text); }
.adm-help-body {
  padding: 0 14px 12px;
  color: var(--text-dim);
  font-size: .82rem;
  line-height: 1.6;
}
.adm-help-body p { margin: 0 0 8px; }
.adm-help-body ul { margin: 4px 0 8px; padding-left: 20px; }
.adm-help-body li { margin-bottom: 4px; }
.adm-help-body code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: .78rem;
  color: var(--accent);
}
.adm-help-body strong { color: var(--text); }

/* Card grid for card-based layouts */
.adm-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }

/* Responsive */
@media (max-width: 768px) {
  .adm-sidebar { display: none; }
  .adm-main { padding: 12px; }
}

/* ── System Prompts ── */
.adm-prompt-editor { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.adm-prompt-textarea {
  width: 100%; min-height: 300px; max-height: 600px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.5;
  background: var(--bg-input); border: 1.5px solid var(--border);
  color: var(--text); padding: 12px; border-radius: 8px;
  resize: vertical; box-sizing: border-box; tab-size: 2;
}
.adm-prompt-textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.adm-prompt-vars { font-size: .8rem; color: var(--text-dim); padding: 8px 12px; background: var(--bg-surface); border-radius: 6px; margin: 4px 0; }
.adm-prompt-vars code { color: var(--accent); }
.adm-prompt-version-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle); font-size: .85rem;
}
.adm-prompt-version-row:last-child { border-bottom: none; }
.adm-prompt-used-tag {
  display: inline-block; font-size: .7rem; padding: 2px 6px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-dim); margin: 1px;
}
.adm-prompt-group-header {
  cursor: pointer; padding: 8px 0; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Form Controls ── */
.adm-input {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .85rem;
  font-family: inherit;
}
.adm-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.adm-input-full { width: 100%; }

.adm-textarea {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .8rem;
  resize: vertical;
  line-height: 1.5;
  tab-size: 2;
}

/* ── Flex Utilities ── */
.adm-flex       { display: flex; gap: 8px; }
.adm-flex-col   { display: flex; flex-direction: column; gap: 8px; }
.adm-flex-between { display: flex; justify-content: space-between; align-items: center; }
.adm-flex-center  { display: flex; align-items: center; gap: 8px; }
.adm-flex-wrap    { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Text Utilities ── */
.adm-text-xs  { font-size: .7rem; }
.adm-text-sm  { font-size: .8rem; }
.adm-text-base { font-size: .85rem; }
.adm-text-dim  { color: var(--text-dim); }
.adm-text-bright { color: var(--text); }
.adm-text-accent { color: var(--accent); }
.adm-text-error  { color: var(--danger-fg); }
.adm-text-success { color: var(--success-fg); }
.adm-text-mono { font-family: var(--font-mono); font-size: .8rem; }

/* ── Spacing Utilities ── */
.adm-gap-xs { gap: 4px; }
.adm-gap-sm { gap: 8px; }
.adm-gap-md { gap: 12px; }
.adm-gap-lg { gap: 16px; }

.adm-mb-xs { margin-bottom: 4px; }
.adm-mb-sm { margin-bottom: 8px; }
.adm-mb-md { margin-bottom: 12px; }
.adm-mb-lg { margin-bottom: 16px; }

.adm-mt-sm { margin-top: 8px; }
.adm-mt-md { margin-top: 12px; }
.adm-mt-lg { margin-top: 16px; }

/* ── Modal ── canonical overlay/box live in theme.css (.modal-overlay / .modal).
   msm-tab uses .modal-overlay directly; no admin-specific override needed. */

/* ── Memory Tab ──
   (the bespoke .adm-mem-stat summary cards were removed — memory/agent-tasks/
   sharing-groups now use the canonical <StatsGrid>/.adm-stat pattern.) */
.adm-mem-filters {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.adm-mem-filters .adm-input {
  padding: 6px 10px; border: 1px solid var(--glass-border); border-radius: 6px;
  font-size: .85rem; background: var(--glass-bg); color: inherit; min-width: 160px;
}
.adm-mem-value-label { font-size: .8rem; color: var(--text-dim); margin-bottom: 4px; }
.adm-mem-value {
  background: var(--bg-surface); border: 1px solid var(--glass-border); border-radius: 6px;
  padding: 10px; font-size: .8rem; max-height: 300px; overflow: auto;
  white-space: pre-wrap; word-break: break-all; font-family: 'JetBrains Mono', monospace;
}
.adm-mem-pagination {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--glass-border); margin-top: 8px;
}
.adm-mem-page-info { font-size: .85rem; color: var(--text-dim); }
/* Semantic button modifiers — combine with .adm-btn-sm / .adm-btn-action
   (which supply padding/radius). Theme-aware via tokens, never hardcoded hex.
   These replace the ad-hoc inline style="color:#ef4444…" overrides that were
   scattered across the tabs. */
.adm-btn-danger {
  color: var(--danger-fg); border-color: var(--danger-border);
}
.adm-btn-danger:hover { background: var(--danger-bg); }
.adm-btn-success {
  color: var(--success-fg); border-color: var(--success-border);
}
.adm-btn-success:hover { background: var(--success-bg); }
/* Solid danger — combine with .adm-btn (which supplies layout); the bg override
   below wins on source order. For destructive primary actions (e.g. delete). */
.adm-btn-danger-solid {
  background: var(--danger); color: #fff; border-color: transparent;
}
.adm-btn-danger-solid:hover { background: var(--danger); filter: brightness(0.92); }
/* Info / ghost button modifiers (combine with .adm-btn-sm like -danger/-success). */
.adm-btn-info { color: var(--info-fg); border-color: var(--info-border); }
.adm-btn-info:hover { background: var(--info-bg); }
.adm-btn-ghost { color: var(--text-dim); border-color: var(--border); }
.adm-btn-ghost:hover { background: var(--bg-surface); }

/* Previously-undefined classes used by cortex/database/skills/feedback tabs
   (they rendered unstyled). Defined to the admin design language — no markup
   change needed. */
.adm-section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.adm-meta-row { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; color: var(--text-dim); font-size: 0.85rem; margin: 0.5rem 0; }
.adm-actions-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.adm-row { padding: 0.35rem 0; border-bottom: 1px solid var(--border-subtle); }
.adm-row:last-child { border-bottom: none; }
.adm-table-wrap { overflow-x: auto; }
.adm-link { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
.adm-link:hover { text-decoration: underline; }
.adm-desc, .adm-help-text { color: var(--text-dim); font-size: 0.85rem; }
.adm-muted { color: var(--text-dim); }

/* Subtabs row */
.adm-subtabs { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }

/* Subdomains tab — create-form row: subdomain | kind | target (grows) | button */
.adm-subdomain-form {
  display: grid;
  grid-template-columns: minmax(120px, 200px) minmax(100px, 140px) 1fr auto;
  gap: 8px;
  align-items: center;
}
.adm-subdomain-form .adm-text-error { grid-column: 1 / -1; }
.adm-subdomain-modal-actions { justify-content: flex-end; }

/* Applications (moderation) tab */
.adm-apps-filters { gap: 12px; align-items: center; }
.adm-apps-toggle { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.adm-apps-row-hidden { opacity: 0.6; }
.adm-apps-modal-actions { justify-content: flex-end; }
.adm-apps-rowactions { gap: 6px; flex-wrap: wrap; }

/* Active subtab button */
.adm-btn-active,
.adm-btn-active:hover { background: var(--accent); color: #fff; }

/* Packages tab seed card */
.adm-pkg-seed-card { margin-bottom: 16px; text-align: center; padding: 24px; }
.adm-pkg-seed-text { margin-bottom: 12px; }
.adm-pkg-seed-msg { margin-top: 8px; font-size: .85rem; color: var(--mint); }

/* Template moderation */
.adm-mod-section { margin-bottom: 16px; }
.adm-mod-review { margin-top: 8px; }
.adm-mod-review-title { font-size: 1rem; font-weight: 700; margin-bottom: 8px; color: var(--text-bright, #1A1A2E); }
.adm-mod-desc { font-size: .85rem; color: var(--text-dim, #6B7280); margin-bottom: 8px; }
.adm-mod-meta-grid { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; font-size: .84rem; }
.adm-mod-meta-item { color: var(--text-dim, #6B7280); }
.adm-mod-meta-item strong { color: var(--text-bright, #1A1A2E); }
.adm-mod-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.adm-mod-pre { font-size: .78rem; white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow: auto; font-family: var(--font-mono); background: var(--bg-deep, #F8FAFC); border: 1px solid var(--glass-border, #E5E7EB); border-radius: 6px; padding: 10px; }
.adm-mod-components { margin-bottom: 12px; }
.adm-mod-components h5 { font-size: .84rem; margin-bottom: 6px; }
.adm-mod-actions { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }
.adm-mod-action-group { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.adm-mod-action-label { font-size: .78rem; font-weight: 600; color: var(--text-dim, #6B7280); }
.adm-mod-input { padding: 6px 10px; border: 1px solid var(--glass-border, #E5E7EB); border-radius: 6px; font-size: .85rem; background: var(--glass-bg, #fff); color: inherit; }
.adm-mod-suspend-panel { margin-top: 8px; }
.adm-mod-suspend-row { display: flex; gap: 8px; align-items: center; }
.adm-mod-suspend-row .adm-mod-input { flex: 1; }

/* Badge aliases for moderation statuses */
.adm-badge-approved  { background: var(--success-bg); color: var(--success-fg); }
.adm-badge-rejected  { background: var(--danger-bg); color: var(--danger-fg); }
.adm-badge-suspended { background: var(--warn-bg); color: var(--warn-fg); }
.adm-badge-published { background: var(--success-bg); color: var(--success-fg); }
.adm-badge-active    { background: var(--success-bg); color: var(--success-fg); }
.adm-badge-installed { background: var(--success-bg); color: var(--success-fg); }

/* ── Board Members ── */
.adm-board-detail { border-top: 1px solid var(--card-border, var(--glass-border)); padding-top: 8px; }
.adm-board-post { margin-bottom: 6px; padding: 6px; background: var(--bg-card, var(--glass-bg)); border-radius: 6px; }
.adm-board-members { border-top: 1px solid var(--card-border, var(--glass-border)); padding-top: 8px; }
.adm-member-tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: 4px; padding: 2px 8px; font-size: .8rem;
}
.adm-member-tag code { font-size: .78rem; }
.adm-member-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0 2px;
}
.adm-member-remove:hover { color: var(--danger, #E8564A); }
.adm-member-add { display: flex; gap: 8px; align-items: center; }
.adm-member-add .adm-input { flex: 1; font-size: .85rem; }
.adm-font-mono { font-family: 'JetBrains Mono', monospace; }

/* ── Stats Time Range Selector ── */
.adm-time-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--glass-bg, #FFFFFF);
  border: 1px solid var(--glass-border, #E5E7EB);
  border-radius: 8px;
}
.adm-time-range-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-right: 4px;
}
.adm-time-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  border: 1px solid var(--glass-border, #E5E7EB);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.adm-time-btn:hover { border-color: var(--accent); color: var(--accent); }
.adm-time-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.adm-time-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.adm-time-custom input[type="date"] {
  padding: 3px 8px;
  font-size: 0.75rem;
  border: 1px solid var(--glass-border, #E5E7EB);
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text);
  font-family: inherit;
}

/* ── Stats Breakdown Table ── */
.adm-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 8px;
}
.adm-breakdown-table th {
  text-align: left;
  padding: 6px 10px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.adm-breakdown-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.adm-breakdown-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Stats Section Header Colors ── */
.adm-section-purple  { color: var(--purple); }
.adm-section-cyan    { color: var(--teal); }
.adm-section-violet  { color: var(--purple); }
.adm-section-amber   { color: var(--warn); }
.adm-section-red     { color: var(--danger); }

/* ── Breakdown Table ── */
.adm-breakdown-table th.num { text-align: right; }

/* ── Stats Inline Breakdown ── */
.adm-date-separator { color: var(--text-dim); }
.adm-mailbox-inline { padding: 10px 16px; }
.adm-blocked-reasons { margin-bottom: 6px; color: var(--text-dim); }
.adm-channels-summary { color: var(--text-dim); }

.adm-badge-live {
  display: inline-block;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  vertical-align: middle;
  margin-left: 6px;
}

/* Security tab — incident list */
.adm-sec-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 0.3rem; }
.adm-sec-desc { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.75rem; }
.adm-sec-empty { color: var(--muted); padding: 0.75rem 0; }
.adm-sec-list { display: flex; flex-direction: column; gap: 0.5rem; }
.adm-sec-row { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.75rem; background: var(--card); }
.adm-sec-row.open { border-color: var(--danger); border-left-width: 3px; }
.adm-sec-main { min-width: 0; flex: 1; }
.adm-sec-line1 { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.adm-sec-type { font-weight: 600; color: var(--text); }
.adm-sec-code { font-size: 0.78rem; background: var(--bg-dim); padding: 0.05rem 0.35rem; border-radius: 4px; }
.adm-sec-when { font-size: 0.74rem; color: var(--muted); margin-left: auto; }
.adm-sec-line2 { font-size: 0.82rem; color: var(--text); margin: 0.25rem 0; word-break: break-word; }
.adm-sec-line3 { font-size: 0.76rem; color: var(--muted); }
.adm-sec-actions { display: flex; gap: 0.35rem; flex-shrink: 0; flex-wrap: wrap; }

/* ── Skills admin tab (adm-skills) — node registry Phase 2b ── */
.adm-skills-row { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 0.55rem 0.75rem; margin-bottom: 0.5rem; }
.adm-skills-row-main { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.adm-skills-version { font-size: 0.74rem; color: var(--muted); }
.adm-skills-actions { margin-left: auto; display: flex; gap: 0.3rem; }
.adm-skills-desc { font-size: 0.82rem; color: var(--muted); margin-top: 0.25rem; }
.adm-skills-body { background: var(--bg-dim); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem; font-size: 0.78rem; max-height: 24rem; overflow: auto; white-space: pre-wrap; margin-top: 0.5rem; }
.adm-skills-editor { margin: 0.5rem 0 0.75rem; }
.adm-skills-editor-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.adm-skills-editor-md { width: 100%; min-height: 24rem; font-family: var(--mono); font-size: 0.82rem; resize: vertical; }
.adm-skills-detail { margin-top: 0.5rem; }
.adm-skills-frontmatter { background: var(--bg-dim); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.6rem; font-size: 0.74rem; color: var(--muted); white-space: pre-wrap; margin-bottom: 0.5rem; }
.adm-skills-body-md { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.86rem; max-height: 32rem; overflow: auto; }

/* ── Feedback tab (Node Feedback Channel operator inbox) ── */
.adm-fb-filters { display: flex; gap: 0.5rem; margin: 0.75rem 0; flex-wrap: wrap; }
.adm-fb-row { cursor: pointer; }
.adm-fb-row:hover td { background: var(--bg-dim); }
.adm-fb-thread-head { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.75rem; flex-wrap: wrap; }
.adm-fb-status { margin-left: auto; }
.adm-fb-msg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 0.6rem 0.8rem; margin-top: 0.5rem; white-space: pre-wrap; font-size: 0.88rem; }
.adm-fb-msg-operator { background: var(--bg-dim); margin-left: 2rem; }
.adm-fb-msg-sender { margin-right: 2rem; }
.adm-fb-context { font-size: 0.76rem; color: var(--muted); margin-top: 0.4rem; }
.adm-fb-replybox { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.adm-fb-replybox textarea { width: 100%; resize: vertical; }

/* ── Organism ownership tab (operator break-glass) ── */
/* The lookup and add-owner rows: one input that takes the width, one button beside it. Without
   this the button dropped under a full-width input and the pair stopped reading as one action. */
.adm-oo-row { display: flex; gap: 0.5rem; align-items: center; margin: 0.75rem 0; flex-wrap: wrap; }
.adm-oo-row .input-field { flex: 1 1 20rem; }
.adm-oo-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.4rem 0.9rem; margin: 0.75rem 0; }

/* ── Metrics tab ── */
/* Session sparkline inside a stat card: recessive line in the tab accent, endpoint dot filled. */
.adm-metrics-spark { display: block; margin-top: 0.4rem; }
.adm-metrics-spark polyline { stroke: var(--blue); opacity: 0.8; }
.adm-metrics-spark circle { fill: var(--blue); }
.adm-metrics-poll-note { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.adm-metrics-off p { margin: 0.4rem 0; }
.adm-metrics-off-hint { color: var(--muted); font-size: 0.85rem; }
.adm-metrics-filter { max-width: 16rem; }
.adm-metrics-route { font-family: var(--font-mono, monospace); font-size: 0.82rem; word-break: break-all; }
.adm-metrics-labels { font-family: var(--font-mono, monospace); font-size: 0.76rem; color: var(--muted); word-break: break-all; }
.adm-metrics-all td { vertical-align: top; }
/* The memory ledger: prose explanations, not monospace — these rows are read as sentences. */
.adm-metrics-ledger-intro { color: var(--muted); font-size: 0.85rem; margin: 0.3rem 0 0.8rem; max-width: 62rem; }
.adm-metrics-ledger-hint { color: var(--muted); font-size: 0.82rem; }
.adm-metrics-ledger tr:last-child td { border-top: 2px solid var(--border); font-weight: 600; }
.adm-metrics-ledger tr:last-child .adm-metrics-ledger-hint { font-weight: 400; }
