:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1420;
  --panel: #111d2b;
  --panel-2: #182739;
  --border: #294055;
  --text: #fffaf0;
  --muted: #9caaba;
  --accent: #14b8a6;
  --accent-strong: #0d9488;
  --ok: #a3e635;
  --warn: #f59e0b;
  --bad: #fb7185;
  --btn: #0f766e;
  --btn-hover: #115e59;
  --focus: #5eead4;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-2: #eaf3f0;
  --border: #cadbd5;
  --text: #172033;
  --muted: #5f6c78;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --ok: #3f6212;
  --warn: #b45309;
  --bad: #be123c;
  --btn: #0f766e;
  --btn-hover: #115e59;
  --focus: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  transition: background-color 160ms ease, color 160ms ease;
}

header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: -.01em;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: auto;
  max-width: 100%;
}

.brand-logo-light {
  display: none;
}

:root[data-theme="light"] .brand-logo-dark {
  display: none;
}

:root[data-theme="light"] .brand-logo-light {
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 9px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 600 12px/1 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--panel-2);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  color: var(--warn);
  font-size: 15px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 5px 8px;
  cursor: pointer;
}

.tab.active {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel-2);
}

/* Socket state, styled to match the collector pill beside it. The dot is a
   ::before so the JS can keep setting plain text. */
header .conn {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

.conn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
  flex: none;
}

.conn.live::before {
  background: var(--ok);
}

.conn.down {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
}

.conn.down::before {
  background: var(--bad);
}

main {
  padding: 20px 24px;
  display: grid;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 10px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.tile .name {
  font-weight: 600;
  font-size: 13px;
  word-break: break-all;
}

.tile .type {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.tile .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.ok {
  background: var(--ok);
}

.dot.warn {
  background: var(--warn);
}

.dot.unknown {
  background: var(--muted);
}

.tile .detail {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.lane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  min-height: 140px;
}

.lane h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.lane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mode {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode.rules {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
}

.mode.ai {
  color: #bd9cff;
  background: #bd9cff22;
}

.pipeline-note {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.pipeline-note strong {
  color: var(--text);
}

.lane .model {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 10px;
}

.lane .activity {
  font-size: 13px;
  min-height: 36px;
}

.lane.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.lane .cost {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.cols {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 20px;
  align-items: start;
}

.incidents {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 400px;
  overflow: auto;
}

.incident-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.incident-row:hover {
  background: var(--panel-2);
}

.incident-id {
  color: var(--accent);
  font: 600 11px ui-monospace, monospace;
  margin-right: 7px;
}

.incident-time {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}

.sev {
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
}

.sev-P1 {
  background: var(--bad);
  color: #fff;
}

.sev-P2 {
  background: var(--warn);
  color: #241a00;
}

.sev-P3,
/* --- platform grouping ---------------------------------------------- */
.platform-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.ptab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 13px;
}

.ptab:hover {
  color: var(--text);
  border-color: var(--accent);
}

.ptab.on {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--accent);
}

.ptab-count {
  font: 600 11px ui-monospace, monospace;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
}

.ptab.on .ptab-count {
  background: var(--bg);
}

.platform-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 4px 0 2px;
  font-size: 15px;
}

/* Marks are original functional glyphs, not vendor trademarks; each keeps a
   distinct hue so platforms stay tellable apart at a glance. */
.platform-mark {
  flex: none;
  vertical-align: -3px;
}

.platform-ibm_mq { color: #5b8cff; }
.platform-ibm_ace { color: #38bdf8; }
.platform-apigee { color: #a78bfa; }
.platform-datapower { color: #fb923c; }
.platform-java { color: #f472b6; }
.platform-common,
.platform-other { color: var(--muted); }

/* --- lifecycle ------------------------------------------------------ */
.status-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: capitalize;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  margin-right: 6px;
}

.status-open {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
}

.status-acknowledged {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

.status-resolved,
.status-closed {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.lifecycle {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.lifecycle .draft-field {
  margin: 0;
  width: auto;
  flex: 1 1 150px;
  min-width: 120px;
}

.lifecycle .lifecycle-note {
  flex: 2 1 220px;
}

.chip-sep {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
  vertical-align: middle;
}

.audit-list {
  display: grid;
  gap: 6px;
}

.audit-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.audit-actor {
  font-weight: 600;
}

.audit-time {
  color: var(--muted);
  margin-left: auto;
}

.audit-note {
  width: 100%;
  color: var(--muted);
  font-style: italic;
}

.sev-P4 {
  background: var(--panel-2);
  color: var(--muted);
}

.trigger-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.trigger-poll {
  background: var(--panel-2);
  color: var(--muted);
}

.trigger-event {
  background: var(--accent);
  color: #fff;
}

.detail-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  min-height: 200px;
}

.detail-panel pre {
  white-space: pre-wrap;
  font: 13px/1.5 ui-monospace, monospace;
}

.incident-summary {
  color: var(--muted);
  margin: 5px 0 16px;
}

.stage {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 12px 0;
  overflow: hidden;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--panel-2);
  padding: 10px 12px;
}

.stage-title {
  font-size: 14px;
  font-weight: 700;
}

.stage-subtitle {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.stage-body {
  padding: 12px;
}

.facts {
  display: grid;
  grid-template-columns: minmax(130px, .35fr) 1fr;
  gap: 8px 14px;
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
}

.facts dd {
  margin: 0;
  word-break: break-word;
}

.facts ul {
  margin: 0;
  padding-left: 18px;
}

.facts .facts {
  grid-template-columns: 110px 1fr;
}

.mode.failed {
  color: var(--bad);
  background: #ff5c5c22;
}

.kb-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.kb-section h4 {
  margin: 0 0 8px;
}

.kb-actions {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
}

.button {
  background: var(--btn);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  padding: 8px 12px;
  min-height: 36px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.button:hover:not(:disabled) {
  background: var(--btn-hover);
}

.button:disabled { opacity: .55; cursor: default; }

.button.danger {
  background: var(--bad);
}

.kb-library {
  display: grid;
  gap: 10px;
}

.kb-library-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.kb-library-row h3 {
  margin: 0;
  font-size: 14px;
}

.kb-library-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 7px;
}

.row-actions .button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}

.hidden {
  display: none;
}

.kb-list {
  display: grid;
  gap: 7px;
}

.kb-article {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

.kb-article:hover {
  border-color: var(--accent);
}

.kb-score {
  color: var(--muted);
  font-size: 11px;
}

dialog {
  max-width: min(800px, calc(100vw - 32px));
  max-height: 80vh;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

dialog::backdrop {
  background: #0009;
}

dialog h3 {
  margin-top: 0;
}

dialog pre {
  white-space: pre-wrap;
  font: 13px/1.5 ui-monospace, monospace;
}

.kb-rendered {
  line-height: 1.65;
}

.kb-rendered h1,
.kb-rendered h2,
.kb-rendered h3 {
  margin: 20px 0 8px;
}

.kb-rendered h1 {
  font-size: 20px;
}

.kb-rendered h2 {
  font-size: 16px;
}

.kb-rendered h3 {
  font-size: 14px;
}

.kb-rendered p {
  margin: 8px 0;
}

.kb-rendered ul,
.kb-rendered ol {
  padding-left: 22px;
}

.kb-rendered code,
.kb-rendered pre {
  background: var(--panel-2);
  border-radius: 4px;
}

.kb-rendered code {
  padding: 2px 4px;
}

.kb-rendered pre {
  padding: 10px;
  overflow: auto;
}

.dialog-close {
  float: right;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
}

.draft-editor {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  font: 13px/1.5 ui-monospace, monospace;
}

.draft-field {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px;
  margin: 6px 0 10px;
}

.dialog-note {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.list-note {
  color: var(--muted);
  font-size: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

/* --- health cluster ----------------------------------------------- */
.health {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Both header indicators read as the same object: a state dot plus the
   word for it. No unlabelled dots. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

button.status-pill {
  cursor: pointer;
}

button.status-pill:hover {
  color: var(--text);
  border-color: var(--accent);
}

.status-pill.failing {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 45%, transparent);
}

.status-pill.degraded {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

.health-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  cursor: default;
}

.health-dot.ok { background: var(--ok); }
.health-dot.degraded { background: var(--warn); }
.health-dot.failing { background: var(--bad); }
.health-dot.starting { background: var(--muted); }

/* --- pipeline strip ------------------------------------------------ */
.strip {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 150px;
  cursor: pointer;
}

.stage-chip.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.stage-chip .stage-name {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.stage-chip .stage-state {
  font-size: 11px;
  color: var(--muted);
}

.stage-chip .stage-cost {
  font-size: 11px;
  color: var(--muted);
  display: none;
}

.strip.expanded .stage-chip .stage-cost {
  display: block;
}

/* --- tiles: anomalies must not look like furniture ------------------ */
.tile.anomaly {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--border));
  background: color-mix(in srgb, var(--warn) 9%, var(--panel));
}

/* --- severity summary + filters ------------------------------------ */
.list-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.summary {
  display: flex;
  gap: 6px;
  font-size: 11px;
}

.summary .pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.summary .pill.p1 { color: var(--bad); }
.summary .pill.p2 { color: var(--warn); }

.filters {
  display: flex;
  gap: 4px;
}

.filters .chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.filters .chip.on {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--accent);
}

.incident-row.filtered {
  display: none;
}

@keyframes rowflash {
  0% { background: color-mix(in srgb, var(--warn) 30%, var(--panel)); }
  100% { background: transparent; }
}

.incident-row.flash {
  animation: rowflash 2.5s ease-out 1;
}

/* --- agent workflow ------------------------------------------------- */
.workflow {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.agent-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.agent-card.running {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.agent-card.disabled {
  opacity: .65;
}

.agent-card h3 {
  margin: 0;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.agent-card .agent-model {
  font: 600 11px ui-monospace, monospace;
  color: var(--accent);
}

.agent-card .agent-role {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}

.agent-card .agent-state {
  font-size: 12px;
  border-top: 1px solid var(--border);
  padding-top: 7px;
}

.agent-card .agent-cost {
  font-size: 11px;
  color: var(--muted);
}

.flow-arrow {
  align-self: center;
  color: var(--muted);
  font-size: 22px;
  user-select: none;
}

.gate-card {
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  width: 230px;
  font-size: 12px;
  color: var(--muted);
}

.gate-card h4 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.gate-card ul {
  margin: 0;
  padding-left: 16px;
}

.gate-card .gate-on { color: var(--ok); }
.gate-card .gate-off { color: var(--bad); }

.pipeline-note .dismiss {
  float: right;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

/* ============================================================
   v2 shell — login gate and sidebar layout
   ============================================================ */

.hidden { display: none !important; }

/* --- login gate --- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  background:
    radial-gradient(circle at 18% 12%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 34%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}

.login-brand {
  justify-content: center;
  margin-bottom: 20px;
  overflow: hidden;
}

.login-brand .brand-logo {
  width: auto;
  max-width: min(100%, 320px);
  height: auto;
  max-height: 96px;
  object-fit: contain;
}

.login-theme-toggle {
  position: absolute;
  top: 18px;
  right: 20px;
}

/* The weakest part of the system says so, prominently and in the user's path. */
.login-warning {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 20px;
}

.login-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.login-card .draft-field { margin: 0 0 14px; }

/* --- app shell --- */
.app {
  display: grid;
  grid-template-columns: 224px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-brand {
  height: 62px;
  padding: 0 2px;
  overflow: hidden;
}

.sidebar-brand .brand-logo {
  width: 100%;
  max-width: 196px;
  height: 62px;
  object-fit: cover;
  object-position: center;
}

.nav-group + .nav-group { margin-top: 18px; }

.nav-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 0 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
}

.nav-item:hover { color: var(--text); background: var(--panel-2); }

.nav-item.on {
  color: var(--text);
  background: var(--panel-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: grid;
  gap: 9px;
}

.who-name { font-size: 13px; font-weight: 600; }
.who-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }

.who-unverified {
  font-size: 10px;
  color: var(--warn);
  margin-top: 3px;
}

.button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.button.ghost:hover { color: var(--text); border-color: var(--accent); filter: none; }

.content { display: flex; flex-direction: column; min-width: 0; }

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.content-head h2 {
  margin: 0;
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}

.content main { padding: 20px 24px; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-brand,
  .sidebar-brand .brand-logo { height: 56px; }
  .sidebar-brand .brand-logo { max-width: 180px; }
}

@media (max-width: 520px) {
  .theme-toggle [data-theme-label] { display: none; }
  .theme-toggle { padding: 6px 8px; }
}

/* --- agent catalogue --- */
.agent-grid { display: grid; gap: 12px; }

.agent-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px 16px;
}

.agent-top {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
}

.agent-item h3 { margin: 0; font-size: 14px; }
.agent-purpose { color: var(--muted); font-size: 12px; margin: 5px 0 0; }

.agent-explain {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  margin: 10px 0 0;
  opacity: .85;
}

.agent-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}

.agent-meta code {
  background: var(--panel-2);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
}

/* Tier is the most safety-relevant fact about an agent, so it reads loudest. */
.tier-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tier-read { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.tier-write_external,
.tier-write_code {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 50%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}

.locked-note {
  font-size: 11px;
  color: var(--muted);
  border-left: 2px solid var(--border);
  padding-left: 9px;
  margin-top: 12px;
}

/* --- edit form controls --- */
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  margin: 0;
}

.switch input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Consequences are stated next to the control that causes them, not buried in
   a tooltip. */
.field-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin: 4px 0 12px;
  line-height: 1.5;
}

.field-hint code {
  background: var(--panel-2);
  border-radius: 3px;
  padding: 1px 4px;
}

#app-dialog label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

#app-dialog .draft-field { margin: 0; }

/* --- toast --- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(14px);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 60;
}

#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
#toast.err {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 14%, var(--panel-2));
}

/* Role picker in the sidebar — the dummy login means role is a UI control,
   not an identity claim, so it belongs where you can reach it. */
.who-role-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 8px 0 3px;
}

.who-role-select {
  margin: 0;
  padding: 5px 7px;
  font-size: 12px;
  text-transform: capitalize;
}

.button[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.button[disabled]:hover {
  filter: none;
  border-color: var(--border);
  color: var(--muted);
}

/* --- runs, approvals and workflow cards ----------------------------------- */

/* Run status reuses the tier-badge shape; only the colour differs. */
.tier-badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.tier-badge.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.tier-badge.bad {
  color: var(--danger, #ff6b6b);
  border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent);
}

/* The plan is the thing being approved, so it gets room to be read rather than
   being squeezed into a summary line. */
.plan-steps {
  margin: 10px 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.plan-steps li { line-height: 1.5; }

.prompt-view {
  margin: 6px 0 12px;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  background: var(--panel-2, rgba(255, 255, 255, .03));
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- onboarding wizard ---------------------------------------------------- */

.wizard {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel, rgba(255, 255, 255, .02));
}

.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  border-bottom: 1px solid var(--border);
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.wizard-step.on {
  color: var(--text, #e8ecf3);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.wizard-step.done { color: var(--ok); }

.wizard-num {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 10px;
}

.wizard-body { padding: 16px 18px; }
.wizard-body h3 { margin: 0 0 10px; font-size: 15px; }

/* The template card is the one place a user decides what they are signing up
   for, so it gets more room than a list row. */
.template-card {
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.template-facts {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* A template card is a choice, so it reads as one. */
.template-card { display: block; cursor: pointer; }
.template-card input[type="radio"] { margin-right: 8px; }
.template-card.chosen {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}
.template-card + .template-card { margin-top: 10px; }

/* An email address is a literal, not a label: title-casing it renders
   Ajit@Example.Com, which looks like a different address. */
.who-role { text-transform: none; }
.who-role-label { text-transform: uppercase; }

/* --- data tables (Users, and reusable elsewhere) -------------------------- */

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 10px;
}

.table-count { font-size: 12px; color: var(--muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.data-table .row-inactive td { opacity: .55; }
.data-table code { font-size: 12px; }
.data-table .muted { color: var(--muted); }

.col-status { width: 1%; white-space: nowrap; }
.col-action { width: 1%; text-align: right; white-space: nowrap; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.status-dot.off { background: var(--muted); }

.role-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  text-transform: capitalize;
  color: var(--muted);
}
.role-pill.admin {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}

.row-flag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border: 1px solid var(--border);
  color: var(--muted);
}
.row-flag.bad {
  color: var(--danger, #ff6b6b);
  border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent);
}

.button.small { padding: 4px 12px; font-size: 12px; }

/* On narrow screens the table scrolls inside itself rather than the page. */
@media (max-width: 720px) {
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* --- connections (compact list + add dropdown + in-dialog test) ----------- */

.conn-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 10px;
}
.conn-bar-title { font-size: 14px; font-weight: 600; }

.menu-wrap { position: relative; }
.caret { font-style: normal; font-size: 11px; opacity: .7; }

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 170px;
  background: var(--panel, #14181f);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 5px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.menu-item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.connector-logo {
  width: 22px; height: 22px; flex: none; vertical-align: middle;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.16));
}
.menu-item .connector-logo { width: 24px; height: 24px; }

.conn-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.conn-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  cursor: pointer;
}
.conn-row + .conn-row { border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent); }
.conn-row:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }

.conn-logo {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px;
}
.conn-logo .connector-logo { width: 26px; height: 26px; }

.conn-status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.conn-status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.conn-status-dot.off { background: var(--danger, #ff6b6b); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger, #ff6b6b) 20%, transparent); }
.conn-status-dot.unknown { background: var(--muted); }

.conn-main { flex: 1; min-width: 0; }
.conn-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.conn-queue {
  font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em;
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: 999px; padding: 1px 7px;
}
.conn-sub {
  font-size: 11px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conn-sub code { font-size: 11px; }

.conn-actions { display: flex; gap: 4px; flex: none; }
.icon-button {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 7px;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1;
  transition: background .12s, color .12s, border-color .12s;
}
.icon-button:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text, #e6e6e6); }
.icon-button.danger:hover:not(:disabled) { color: var(--danger, #ff6b6b); border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent); }
.icon-button:disabled { opacity: .35; cursor: default; }

.conn-empty { font-size: 13px; color: var(--muted); padding: 18px 4px; }

.button.small { padding: 4px 12px; font-size: 12px; }

/* The Test row inside the add/edit dialog. */
.dialog-test {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.dialog-test-result { font-size: 12px; color: var(--muted); }

/* --- home dashboard ------------------------------------------------------- */

.home-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 8px 0 18px;
}
.home-head h2 { margin: 0; font-size: 22px; font-weight: 500; }
.home-role {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 9px;
}

.home-welcome { max-width: 560px; padding: 8px 0; }
.home-welcome h2 { font-size: 24px; font-weight: 500; margin: 0 0 12px; }
.home-welcome p { color: var(--muted); line-height: 1.6; margin: 0 0 12px; }
.home-steps-label { color: var(--text, #e6e6e6) !important; font-weight: 500; margin-top: 18px; }
.home-steps { margin: 8px 0 20px; padding-left: 20px; display: grid; gap: 8px; }
.home-steps li { line-height: 1.5; }

.home-alert {
  font-size: 12px; line-height: 1.5;
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 9%, transparent);
  border-radius: 8px; padding: 10px 12px; margin: 0 0 16px;
}
.home-alert.bad {
  border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent);
  background: color-mix(in srgb, var(--danger, #ff6b6b) 9%, transparent);
}

.home-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.home-tile {
  display: flex; flex-direction: column; gap: 4px;
  text-align: left; cursor: pointer;
  background: var(--panel-2, rgba(255,255,255,.03));
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px;
  transition: border-color .12s, background .12s;
}
.home-tile:hover { border-color: var(--border-strong, #3a4150); background: color-mix(in srgb, var(--accent) 5%, transparent); }
.home-tile-label { font-size: 12px; color: var(--muted); }
.home-tile-value { font-size: 26px; font-weight: 500; line-height: 1.1; }
.home-tile-value.warn { color: var(--warn); }
.home-tile-value.ok { color: var(--ok); }
.home-tile-sub { font-size: 11px; color: var(--muted); }

.home-callout {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 18px;
}
.home-callout i { color: var(--warn); font-style: normal; }

.home-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.home-panel {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.home-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.home-panel-empty { padding: 16px 14px; font-size: 12px; color: var(--muted); }
.link-button {
  background: transparent; border: 0; color: var(--accent, #5b8cff);
  font-size: 12px; cursor: pointer; padding: 0;
}

.home-run, .home-conn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; font-size: 12px;
}
.home-run + .home-run, .home-conn + .home-conn {
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.home-run:hover, .home-conn:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.home-run-ref { font-family: var(--font-mono, monospace); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-run-time { color: var(--muted); flex: none; }
.home-conn-name { flex: 1; }
.home-conn .conn-logo .connector-logo { width: 16px; height: 16px; }

/* ===========================================================================
   QA remediation: accessibility, mobile, contrast, motion
   =========================================================================== */

/* Skip link — first tab stop, jumps keyboard users past the sidebar. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  background: var(--btn);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
}
.skip-link:focus { left: 8px; }

/* One consistent, high-contrast focus ring across the app — the browser's 1px
   black outline was invisible on the dark background. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [role="button"]:focus-visible,
[tabindex]:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Visible connection status: dot plus a word, not a colour and a tooltip. */
.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  flex: none;
}
.conn-status .conn-status-dot { width: 8px; height: 8px; }
.conn-status.on { color: var(--ok); }
.conn-status.off { color: var(--bad); }
.conn-status.unknown { color: var(--muted); }
.conn-status.on .conn-status-dot { background: var(--ok); }
.conn-status.off .conn-status-dot { background: var(--bad); }
.conn-status.unknown .conn-status-dot { background: var(--muted); }

/* Touch targets: at least 44px where a finger lands. */
.theme-toggle { min-height: 36px; }
.icon-button { min-width: 30px; min-height: 30px; }
@media (pointer: coarse) {
  .nav-item { min-height: 44px; }
  .theme-toggle, .icon-button, .button, .button.small,
  .link-button, .menu-item { min-height: 44px; }
  .link-button { display: inline-flex; align-items: center; }
}

/* A readability floor — nothing below 11px. */
.field-hint, .dialog-note, .conn-sub, .home-tile-sub, .home-tile-label,
.tier-badge, .conn-queue, .row-flag, .conn-count, .table-count {
  font-size: 11px;
}

/* --- mobile navigation drawer (below 720px) ------------------------------- */

.mobile-bar { display: none; }
.nav-scrim { display: none; }
.mobile-logo { height: 26px; width: auto; }
.nav-toggle { font-size: 18px; }

@media (max-width: 720px) {
  .app { display: block; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 40;
  }
  .mobile-bar .mobile-logo:first-of-type { margin-right: auto; }
  .mobile-bar .brand-logo-light { margin-right: auto; }
  .mobile-bar .theme-toggle { margin-left: 0; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 60;
    overflow-y: auto;
  }
  .app.nav-open .sidebar { transform: translateX(0); }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 50;
  }
  .nav-scrim[hidden] { display: none; }

  .content { min-width: 0; }
  .content-head { padding: 12px 16px; }
  .content-head h1 { font-size: 18px; }
  main#view { padding: 14px 16px; }
}

/* Desktop keeps the sidebar in the flow; the mobile bar never shows. */
@media (min-width: 721px) {
  .mobile-bar, .nav-scrim { display: none !important; }
  .sidebar { transform: none !important; }
}

/* Respect a reduced-motion preference: no slides, fades or flashes. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Screen-reader-only utility. */
.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;
}

/* --- compact workflow cards ----------------------------------------------- */
.wf-card {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 10px;
}
.wf-main { flex: 1; min-width: 0; }
.wf-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wf-title strong { font-size: 14px; }
.wf-meta {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 4px; font-size: 12px; color: var(--muted);
}
.wf-meta span:first-child { text-transform: capitalize; }
.wf-warn { color: var(--warn); }
.wf-actions { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* --- runs table numeric columns ------------------------------------------- */
.data-table th.num, .data-table td.num { text-align: right; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* --- compact approval cards ----------------------------------------------- */
.appr-card {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
}
.appr-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.appr-head strong { font-size: 13.5px; line-height: 1.4; flex: 1; min-width: 180px; }
.appr-chips { display: flex; gap: 5px; flex-wrap: wrap; flex: none; }
.appr-cause { font-size: 12.5px; margin: 10px 0 0; line-height: 1.5; }
.appr-label {
  display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-right: 6px; font-weight: 600;
}
.appr-note {
  font-size: 12px; color: var(--warn); margin: 8px 0 0; line-height: 1.5;
}
.appr-steps {
  margin: 10px 0 0; padding: 0; list-style: none;
  counter-reset: step; display: grid; gap: 6px;
}
.appr-steps li {
  counter-increment: step; position: relative;
  padding: 7px 10px 7px 30px;
  background: var(--panel-2, rgba(255,255,255,.03));
  border-radius: 8px; font-size: 12.5px; line-height: 1.45;
}
.appr-steps li::before {
  content: counter(step); position: absolute; left: 9px; top: 7px;
  width: 15px; height: 15px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text); font-size: 9px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.appr-step-action { display: block; }
.appr-step-aside {
  display: inline-block; margin-right: 12px; margin-top: 2px;
  font-size: 11px; color: var(--muted);
}
.appr-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.appr-hash { font-size: 11px; color: var(--muted); font-family: var(--font-mono, monospace); }
.appr-actions { display: flex; gap: 8px; }

/* --- agents grouped by workflow (tabs) ------------------------------------ */
.agent-tabbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin: 18px 0 16px; flex-wrap: wrap;
}
.agent-tabs {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px;
  width: min(100%, 760px); padding: 6px;
  background: var(--panel-2, rgba(255,255,255,.03));
  border: 1px solid var(--border); border-radius: 999px;
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text) 5%, transparent);
}
.agent-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 50px; padding: 10px 24px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: 16px; font-weight: 560; cursor: pointer;
  transition: background .14s, color .14s, box-shadow .14s, transform .14s;
}
.agent-tab:hover { color: var(--text); }
.agent-tab:active { transform: translateY(1px); }
.agent-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 50%, transparent);
  outline-offset: 2px;
}
.agent-tab.on {
  background: var(--btn); color: #fff;
  box-shadow: 0 5px 16px color-mix(in srgb, var(--btn) 28%, transparent);
}
.agent-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; min-height: 26px; padding: 1px 9px;
  font-size: 13px; font-weight: 700; line-height: 1;
  background: color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 999px; text-align: center;
}
.agent-tab.on .agent-tab-count { background: rgba(255,255,255,.25); }

@media (max-width: 720px) {
  .agent-tabbar { align-items: stretch; }
  .agent-tabs { width: 100%; gap: 4px; padding: 4px; }
  .agent-tab { min-height: 46px; gap: 7px; padding: 8px 10px; font-size: 13px; }
  .agent-tab-count { min-width: 28px; min-height: 23px; padding: 1px 7px; font-size: 12px; }
}

/* --- custom agents (author + review) -------------------------------------- */
.review-panel {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border));
  background: color-mix(in srgb, var(--warn) 6%, transparent);
  border-radius: 12px; padding: 12px 14px; margin: 14px 0;
}
.review-panel.muted {
  border-color: var(--border); background: transparent; opacity: .8;
}
.review-head {
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px;
}
.custom-agent { border-style: dashed; }

.tool-checklist {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px; margin: 6px 0 4px;
}
.tool-check {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  cursor: pointer; font-size: 13px;
}
.tool-check input { margin: 0; }
.tool-check code { font-size: 12px; }
.tool-tier {
  margin-left: auto; font-size: 10px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted);
}
