/* Agent Console visual system — dark-first product console.
 *
 * Constraints (docs/phase-17-agent-ui.md): no build step, no external fonts
 * or CDNs (CSP default-src 'self'), no inline styles or scripts. Everything
 * is tokens on :root consumed by components. Dark is the design's home;
 * light is a full palette selected via prefers-color-scheme or the topbar
 * toggle (data-theme), never a naive inversion.
 */

:root {
  color-scheme: dark light;
  /* Ground & surfaces */
  --bg: #0b0e17;
  --bg-sidebar: #0d1120;
  --surface: #121728;
  --surface-2: #181e33;
  --border: #222941;
  --border-strong: #303a5c;
  /* Ink */
  --fg: #e8ebf5;
  --muted: #98a0b6;
  --faint: #646d86;
  /* Accent */
  --accent: #7b93ff;
  --accent-strong: #4f68e6;
  --accent-hover: #93a6ff;
  --accent-soft: #1b2342;
  --on-accent: #ffffff;
  /* Hero gradient */
  --hero-from: #2036a8;
  --hero-to: #4f68e6;
  --hero-ink: #ffffff;
  --hero-muted: #c1cbff;
  --hero-card: rgba(13, 17, 32, 0.35);
  /* Semantic (status) — separate from the accent */
  --ok-fg: #4ade80;
  --ok-soft: #10281c;
  --error-bg: #341d20;
  --error-fg: #f8867e;
  --warning-bg: #33270f;
  --warning-fg: #f2c464;
  /* Chart series: fixed categorical order (validated CVD-safe adjacency);
     identity always also carried by legends/labels, never color alone. */
  --series-1: #7b93ff;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  /* Depth & shape */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 24px rgba(0, 0, 0, 0.25);
  --shadow-raised: 0 8px 24px rgba(0, 0, 0, 0.5), 0 24px 64px rgba(0, 0, 0, 0.55);
  --radius: 12px;
  --radius-small: 8px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light dark;
    --bg: #f2f4f8;
    --bg-sidebar: #ffffff;
    --surface: #ffffff;
    --surface-2: #f4f6fa;
    --border: #e2e6ef;
    --border-strong: #c9d0e0;
    --fg: #171b26;
    --muted: #5b6478;
    --faint: #8b93a7;
    --accent: #3652d9;
    --accent-strong: #3652d9;
    --accent-hover: #2a41b8;
    --accent-soft: #e9edfc;
    --on-accent: #ffffff;
    --hero-from: #2c46c9;
    --hero-to: #5b74f2;
    --hero-ink: #ffffff;
    --hero-muted: #d4dbff;
    --hero-card: rgba(255, 255, 255, 0.14);
    --ok-fg: #1d7a3f;
    --ok-soft: #e5f4ea;
    --error-bg: #fdecec;
    --error-fg: #b3261e;
    --warning-bg: #fdf3dc;
    --warning-fg: #8a5a00;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --shadow: 0 1px 2px rgba(23, 26, 32, 0.05), 0 4px 16px rgba(23, 26, 32, 0.05);
    --shadow-raised: 0 4px 12px rgba(23, 26, 32, 0.1), 0 16px 40px rgba(23, 26, 32, 0.14);
  }
}

:root[data-theme="light"] {
  color-scheme: light dark;
  --bg: #f2f4f8;
  --bg-sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --border: #e2e6ef;
  --border-strong: #c9d0e0;
  --fg: #171b26;
  --muted: #5b6478;
  --faint: #8b93a7;
  --accent: #3652d9;
  --accent-strong: #3652d9;
  --accent-hover: #2a41b8;
  --accent-soft: #e9edfc;
  --on-accent: #ffffff;
  --hero-from: #2c46c9;
  --hero-to: #5b74f2;
  --hero-ink: #ffffff;
  --hero-muted: #d4dbff;
  --hero-card: rgba(255, 255, 255, 0.14);
  --ok-fg: #1d7a3f;
  --ok-soft: #e5f4ea;
  --error-bg: #fdecec;
  --error-fg: #b3261e;
  --warning-bg: #fdf3dc;
  --warning-fg: #8a5a00;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --shadow: 0 1px 2px rgba(23, 26, 32, 0.05), 0 4px 16px rgba(23, 26, 32, 0.05);
  --shadow-raised: 0 4px 12px rgba(23, 26, 32, 0.1), 0 16px 40px rgba(23, 26, 32, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: no-preference) {
  a,
  button,
  .switch::after,
  .progress-fill,
  .clickable-row {
    transition:
      background-color 130ms ease,
      border-color 130ms ease,
      color 130ms ease,
      box-shadow 130ms ease,
      width 200ms ease;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-small);
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* --- Auth pages ------------------------------------------------------------ */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent),
    var(--bg);
}

.auth-card {
  width: min(380px, 92vw);
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.auth-card h1 {
  margin-top: 0;
}

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

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.sidenav {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 1.1rem 0.8rem;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
  overflow-y: auto;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0.35rem 0.9rem;
  color: var(--fg);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.nav-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: var(--hero-ink);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.nav-group-label {
  margin: 0.95rem 0.7rem 0.3rem;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--faint);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.48rem 0.7rem;
  border-radius: var(--radius-small);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-icon {
  opacity: 0.85;
}

.nav-link:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.nav-link-active,
.nav-link-active:hover {
  color: var(--fg);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
  font-weight: 600;
}

.nav-link-active .nav-icon {
  color: var(--accent);
  opacity: 1;
}

.nav-footer {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.nav-user-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.35rem;
}

.nav-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  flex: none;
}

.nav-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nav-user-name {
  font-size: 0.82rem;
  font-weight: 600;
}

.nav-user-email {
  color: var(--faint);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-logout {
  margin: 0;
  padding: 0.35rem 0.65rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 550;
}

.nav-logout:hover {
  color: var(--fg);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

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

/* --- Top bar -------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(8px);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  min-width: 0;
}

.crumb-section {
  color: var(--muted);
}

.crumb-divider {
  color: var(--faint);
}

.crumb-page {
  font-weight: 600;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-pills {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  gap: 2px;
}

.range-pill {
  margin: 0;
  padding: 0.22rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.range-pill:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.range-pill-active,
.range-pill-active:hover {
  background: var(--accent-soft);
  color: var(--fg);
}

.topbar-button {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.84rem;
  font-weight: 550;
}

.topbar-button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.topbar-icon-button {
  padding: 0.35rem 0.5rem;
}

/* --- Page & panels ------------------------------------------------------------------ */

.page {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.75rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.page-head {
  margin-bottom: 0.25rem;
}

.page-title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.page-sub {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 70ch;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel h1,
.card-title {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem;
}

.card-sub {
  margin: 0 0 0.9rem;
  color: var(--faint);
  font-size: 0.8rem;
}

h2 {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 1.4rem 0 0.6rem;
}

.panel-note {
  margin: -0.2rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 70ch;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.1rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidenav {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.2rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 1rem;
  }
  .nav-brand {
    margin: 0 0.6rem 0 0;
  }
  .nav-brand-name,
  .nav-group-label,
  .nav-user-card {
    display: none;
  }
  .nav-footer {
    margin: 0 0 0 auto;
    padding: 0;
    border: none;
    flex-direction: row;
    align-items: center;
  }
  .page,
  .topbar {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* --- Hero ------------------------------------------------------------------------------ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 1.25rem;
  padding: 1.5rem 1.6rem;
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--hero-from), var(--hero-to));
  color: var(--hero-ink);
  box-shadow: var(--shadow-raised);
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

.hero-label {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--hero-muted);
}

.hero-value {
  margin: 0.35rem 0 0.4rem;
  font-size: 2.6rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.hero-caption {
  margin: 0;
  color: var(--hero-muted);
  font-size: 0.86rem;
  max-width: 46ch;
}

.hero-side {
  border-radius: 10px;
  background: var(--hero-card);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.hero-side-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.86rem;
  color: var(--hero-muted);
}

.hero-side-row strong {
  color: var(--hero-ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.hero-side-line {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hero-side-note {
  margin: 0;
  font-size: 0.74rem;
  color: var(--hero-muted);
}

.hero-side-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.35rem;
  font-size: 0.86rem;
}

.hero-side-facts > div {
  display: flex;
  flex-direction: column;
}

.hero-fact-label {
  color: var(--hero-muted);
  font-size: 0.72rem;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #ffffff;
}

.progress-warn {
  background: var(--warning-fg);
}

.progress-over {
  background: var(--error-fg);
}

/* --- KPI cards ---------------------------------------------------------------------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1rem;
}

.kpi-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-label {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--faint);
}

.kpi-value {
  margin: 0.3rem 0 0.15rem;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-caption {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* --- Charts ---------------------------------------------------------------------------------- */

.chart-frame {
  width: 100%;
  overflow-x: auto;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.chart-tick {
  fill: var(--faint);
  font-size: 10.5px;
  font-family: var(--font-ui);
}

.chart-hit {
  fill: transparent;
}

.chart-hit:hover {
  fill: color-mix(in srgb, var(--accent) 10%, transparent);
}

.area-line {
  stroke: var(--series-1);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.area-stop-top {
  stop-color: var(--series-1);
  stop-opacity: 0.34;
}

.area-stop-bottom {
  stop-color: var(--series-1);
  stop-opacity: 0;
}

.bar-a {
  fill: var(--series-1);
}

.bar-b {
  fill: var(--series-2);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-1 { background: var(--series-1); }
.swatch-2 { background: var(--series-2); }
.swatch-3 { background: var(--series-3); }
.swatch-4 { background: var(--series-4); }
.swatch-5 { background: var(--series-5); }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-wrap: wrap;
}

.donut-svg {
  width: 168px;
  height: 168px;
  flex: none;
}

.donut-seg.series-1 { stroke: var(--series-1); }
.donut-seg.series-2 { stroke: var(--series-2); }
.donut-seg.series-3 { stroke: var(--series-3); }
.donut-seg.series-4 { stroke: var(--series-4); }
.donut-seg.series-5 { stroke: var(--series-5); }

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 200px;
  flex: 1;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
}

.donut-legend-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend-value {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hbar-row {
  margin-bottom: 0.9rem;
}

.hbar-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}

.hbar-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.hbar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--series-1);
}

/* --- Forms & notices ---------------------------------------------------------------------------- */

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--muted);
  margin: 0.85rem 0 0.3rem;
}

input,
textarea,
button,
select {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface-2);
  color: var(--fg);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

select {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface-2);
  color: var(--fg);
}

button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  background: var(--accent-strong);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

button:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.button-secondary {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
}

.button-secondary:hover {
  background: var(--surface-2);
}

.button-danger {
  background: transparent;
  color: var(--error-fg);
  border: 1px solid var(--error-fg);
}

.button-danger:hover {
  background: var(--error-bg);
}

.form-error {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-small);
  background: var(--error-bg);
  color: var(--error-fg);
  font-size: 0.88rem;
}

.form-notice {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-small);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.reasoning-warning,
.warning-box {
  margin: 0.5rem 0;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-small);
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 0.88rem;
  font-weight: 600;
}

/* --- Modal --------------------------------------------------------------------------------------- */

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-raised);
  padding: 1.4rem 1.5rem;
  width: min(440px, 92vw);
}

.modal::backdrop {
  background: rgba(5, 8, 16, 0.6);
  backdrop-filter: blur(2px);
}

.modal-title {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 650;
}

.modal-body {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.modal-actions button {
  margin-top: 0;
}

/* --- Security page bits ---------------------------------------------------------------------------- */

.secret-text {
  display: inline-block;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  user-select: all;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0.75rem 0;
  padding: 0.75rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.totp-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

/* --- Output blocks ----------------------------------------------------------------------------------- */

.output-text,
.output-json {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 0.75rem;
  font-size: 0.88rem;
}

.output-empty {
  color: var(--faint);
  font-style: italic;
}

/* --- Tables -------------------------------------------------------------------------------------------- */

.runs-table {
  width: 100%;
  border-collapse: collapse;
}

.runs-table th {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  white-space: nowrap;
}

.runs-table td {
  text-align: left;
  padding: 0.6rem 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.runs-table tr:last-child td {
  border-bottom: none;
}

.runs-table a {
  color: var(--accent);
  text-decoration: none;
}

.runs-table a:hover {
  text-decoration: underline;
}

.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th.num-col {
  text-align: right;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover,
.clickable-row:focus-visible {
  background: var(--surface-2);
  outline: none;
}

/* --- Status badges ----------------------------------------------------------------------------------------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.14rem 0.6rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--muted);
  text-transform: capitalize;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-completed,
.fleet-state-running,
.fleet-health-healthy {
  background: var(--ok-soft);
  color: var(--ok-fg);
}

.status-failed,
.status-timed_out,
.fleet-state-not_found,
.fleet-state-unknown,
.fleet-health-unhealthy {
  background: var(--error-bg);
  color: var(--error-fg);
}

.status-cancelled,
.fleet-state-stopped {
  background: var(--surface-2);
  color: var(--muted);
}

.status-running,
.status-waiting_for_tool,
.status-queued {
  background: var(--accent-soft);
  color: var(--accent);
}

.fleet-health-starting,
.fleet-pending {
  background: var(--warning-bg);
  color: var(--warning-fg);
}

/* --- Run detail ----------------------------------------------------------------------------------------------- */

.run-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.run-header button {
  margin-top: 0;
  margin-left: auto;
}

.steps-list,
.events-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.step,
.event {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
}

.step-header,
.event-header {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--muted);
}

/* --- Fleet cards ---------------------------------------------------------------------------------------------- */

.fleet-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}

.fleet-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.fleet-card:hover {
  border-color: var(--border-strong);
}

.fleet-card-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.fleet-name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.fleet-channel {
  color: var(--faint);
  font-size: 0.8rem;
}

.fleet-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.fleet-meta {
  margin: 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.fleet-control {
  margin-top: auto;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.fleet-control-label {
  font-size: 0.84rem;
  font-weight: 550;
  color: var(--muted);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--faint);
}

.switch[aria-checked="true"] {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.switch[aria-checked="true"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.switch[aria-checked="true"]::after {
  left: auto;
  right: 2px;
  background: #ffffff;
}

/* --- Filters, pager, drawer -------------------------------------------------------------------------------------- */

.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-2);
}

.filter-label {
  margin: 0;
  font-size: 0.78rem;
}

.filter-bar select {
  background: var(--surface);
}

.filter-count {
  margin-left: auto;
  color: var(--faint);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}

.pager button {
  margin-top: 0;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  padding: 0.32rem 0.8rem;
  font-weight: 550;
}

.pager button:hover:not(:disabled) {
  background: var(--surface-2);
}

.pager-label {
  color: var(--faint);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(470px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-raised);
  padding: 1.1rem 1.35rem;
  overflow-y: auto;
  z-index: 10;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.drawer-header h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.drawer-close {
  margin: 0 0 0 auto;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border-strong);
  padding: 0.25rem 0.65rem;
  font-weight: 550;
}

.drawer-close:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.drawer-body h3 {
  font-size: 0.68rem;
  margin: 1.1rem 0 0.45rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.drawer-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
  font-size: 0.88rem;
}

.drawer-facts dt {
  color: var(--muted);
}

.drawer-facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.audit-arrow {
  color: var(--faint);
}
