/* ═══════════════════════════════════════════════════════════════════════════
   Governor Ops Console — Dark Terminal Aesthetic v2
   IBM Plex Mono for data, Instrument Sans for labels/UI
   Single scrollable view, horizontal backend cards, slide-out drawer
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Surface palette — deep blue-charcoal */
  --bg-0: #080b10;
  --bg-1: #0d1117;
  --bg-2: #151b23;
  --bg-3: #1c2333;
  --bg-4: #242d3d;
  --border: #2a3444;
  --border-bright: #3d4f65;

  /* Text */
  --text-0: #e6edf3;
  --text-1: #b1bac4;
  --text-2: #7d8590;
  --text-3: #484f58;

  /* Accent — electric teal */
  --accent: #58a6ff;
  --accent-dim: #264f78;

  /* Semantic */
  --green: #22c55e;
  --green-dim: #16331e;
  --green-glow: rgba(34, 197, 94, 0.15);
  --yellow: #eab308;
  --yellow-dim: #3d3000;
  --yellow-glow: rgba(234, 179, 8, 0.15);
  --red: #ef4444;
  --red-dim: #3d1111;
  --red-glow: rgba(239, 68, 68, 0.15);
  --orange: #f97316;

  /* Model colors */
  --haiku: #22c55e;
  --sonnet: #58a6ff;
  --sonnet5: #2dd4bf;
  --opus: #c084fc;
  --fable: #f472b6;
  /* S5.3: neutral fallback for any model the dashboard has no dedicated color for yet (see
     dashboard/app.js modelClass()/modelColorVar() -- unrecognized models render with this instead
     of silently taking default/no styling). */
  --model-unknown: #7d8590;

  /* Typography */
  --font-mono: "IBM Plex Mono", "Cascadia Code", "Fira Code", monospace;
  --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --header-height: 52px;
  --footer-height: 32px;
  --radius: 6px;
  --radius-sm: 4px;
  --section-gap: 24px;
  --content-pad: 20px;
}

/* ─── Reset & Base ────────────────────────────────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  background: var(--bg-0);
}

body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text-0);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Subtle scanline effect */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.025) 2px,
    rgba(0, 0, 0, 0.025) 4px
  );
}

.mono {
  font-family: var(--font-mono);
}
.hidden {
  display: none !important;
}

/* ─── Overlay / Auth ──────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-box {
  background: var(--bg-2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 40px 48px;
  text-align: center;
  min-width: 360px;
  box-shadow: 0 0 80px rgba(88, 166, 255, 0.06);
}

.auth-logo {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 4px;
}

.accent {
  color: var(--accent);
}

.auth-sub {
  color: var(--text-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 28px;
}

.auth-box input {
  display: block;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px 14px;
  margin-bottom: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.auth-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.auth-box button {
  width: 100%;
  background: var(--accent);
  color: var(--bg-0);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-box button:hover {
  background: #79b8ff;
}

.auth-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 12px;
}

/* ─── Confirm Dialog ──────────────────────────────────────────────────── */

.confirm-box {
  background: var(--bg-2);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 28px 32px;
  min-width: 340px;
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.1);
}

.confirm-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--red);
}

.confirm-box p {
  color: var(--text-1);
  margin-bottom: 20px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ─── Toast ───────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  background: var(--bg-3);
  color: var(--text-0);
  animation: toast-in 0.3s ease-out;
  max-width: 380px;
}

.toast.success {
  border-color: var(--green);
}
.toast.error {
  border-color: var(--red);
}
.toast.warn {
  border-color: var(--yellow);
}

.toast.fade-out {
  animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ─── C2 fix: degraded-banner stack sits BELOW the fixed header ───────── */
/* #header is position:fixed (removed from flow) -- an in-flow sibling placed before it in the DOM
   still renders starting at y=0 and gets painted over (z-index:100). This reserves the header's
   own height so the whole banner stack (0-5 rows depending on which flags are active) renders
   directly below it instead, whether the page is scrolled or not. */
#degraded-banners {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  z-index: 90;
}

/* ─── Header ──────────────────────────────────────────────────────────── */

#header {
  height: var(--header-height);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

/* Subtle gradient glow on header bottom */
#header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent-dim),
    transparent
  );
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.header-logo {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
}

/* ─── Dots ────────────────────────────────────────────────────────────── */

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-green {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.dot-yellow {
  background: var(--yellow);
  box-shadow: 0 0 6px var(--yellow);
}

.dot-red {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

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

/* 2.5: admin-disabled — an INTENTIONAL operator action, not a fault, so it gets its own neutral
   (non-pulsing, non-alarm) dot rather than dot-red. */
.dot-off {
  background: var(--text-2);
}

/* Pulsing animation for status dots */
.dot-green,
.dot-yellow,
.dot-red {
  animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.stat-group {
  display: flex;
  align-items: center;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 18px;
}

.stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-0);
  line-height: 1.2;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.sse-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sse-indicator .label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-3);
}

/* ─── C1: FABLE gate chip (header, next to BRAKE) ─────────────────────── */

.fable-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 3px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.fable-chip.on {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
}

.fable-chip.off {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-3);
}

/* ─── C1: QUEUE stat warning state (>=50% of max_pending) ─────────────── */

.stat-value.stat-warn {
  color: var(--yellow);
}

/* ─── Brake Badge ─────────────────────────────────────────────────────── */

.brake-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 3px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 1px;
  animation: brake-pulse 1s ease-in-out infinite;
}

@keyframes brake-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0);
  }
}

/* ─── 2.5: Admin-toggle state-degraded banner ───────────────────────────── */

.degraded-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-dim);
  border-bottom: 1px solid var(--red);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 6px var(--content-pad);
}

/* ─── Gear Button ─────────────────────────────────────────────────────── */

.gear-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s;
  flex-shrink: 0;
}

.gear-btn:hover {
  background: var(--bg-3);
  border-color: var(--border-bright);
  color: var(--text-0);
}

/* ─── Main Scroll Area ────────────────────────────────────────────────── */

#main {
  margin-top: var(--header-height);
  margin-bottom: var(--footer-height);
  padding: var(--content-pad);
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  overflow-y: auto;
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* ─── Section Layout ──────────────────────────────────────────────────── */

.dash-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-sub {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}

/* ─── dash-redesign: fleet TABLE (replaces the card grid, specs/dash-redesign-spec.md) ────────
   Row background/hover/expanded states parallel the old .backend-card's states (selected ->
   row-expanded); the layout itself is a table, not a card grid -- no responsive column-count
   breakpoints needed, columns just stay fixed and the table scrolls its own container if the
   viewport is ever narrower than the content (never the page body, see .fleet-table-wrap). */

.recovery-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-1);
  margin-bottom: 4px;
}
.strip-sep {
  color: var(--text-3);
}
.strip-segment {
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 3px;
  transition:
    background 0.15s,
    color 0.15s;
}
.strip-segment:hover {
  background: var(--bg-2);
  color: var(--text-0);
}
.strip-segment.active {
  background: var(--accent-dim);
  color: var(--accent);
}
/* dash-auth-demote (2026-08-12) -- the trailing "N usage n/a" segment: a usage-annotation count,
   never a fault, so it stays dim even when active (never borrows the fault-red the old "need
   reseed" segment implied). */
.strip-segment.strip-secondary {
  color: var(--text-3);
}
.strip-segment.strip-secondary.active {
  background: var(--bg-2);
  color: var(--text-1);
}

.fleet-provenance {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  margin-bottom: 10px;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.filter-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.filter-chip:hover {
  border-color: var(--border-bright);
  color: var(--text-0);
}
.filter-chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.filter-chip-count {
  color: var(--text-3);
}
.filter-chip.active .filter-chip-count {
  color: var(--accent);
}

/* Own scroll container: wide row content (many columns at a narrow viewport) scrolls HERE, never
   the page body -- keeps horizontal overflow contained per the render-gate's no-page-scroll rule. */
.fleet-table-wrap {
  overflow-x: auto;
}

#fleet-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11px;
}

#fleet-table thead th {
  text-align: left;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-2);
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
#fleet-table thead th:hover {
  color: var(--text-0);
}
#fleet-table thead th.col-toggle-header {
  cursor: default;
}

.fleet-row {
  cursor: pointer;
  transition: background 0.15s;
}
.fleet-row:hover {
  background: var(--bg-2);
}
.fleet-row.row-expanded {
  background: var(--bg-2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.fleet-row td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Section C: filtering hides rows via display:none, never destroys them. */
.row-filtered-out {
  display: none;
}

.col-account {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.row-email {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-0);
  min-width: 20ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-status {
  white-space: nowrap;
}
.status-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 2px 6px;
  border-radius: 3px;
}
.status-chip.status-ready {
  background: var(--green-dim);
  color: var(--green);
}
.status-chip.status-low {
  background: var(--yellow-dim);
  color: var(--yellow);
}
.status-chip.status-full,
.status-chip.status-down {
  background: var(--red-dim);
  color: var(--red);
}
.status-chip.status-parked {
  background: var(--bg-4);
  color: var(--text-2);
}

.col-traffic {
  color: var(--text-1);
  white-space: nowrap;
}

/* Live in-flight chip inside the TRAFFIC cell — nonzero slots_used only */
.traffic-live {
  color: var(--green);
  background: var(--green-dim);
  border-radius: 3px;
  padding: 0 5px;
  font-weight: 600;
}

.col-bar {
  min-width: 90px;
}
.bar-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bar-cell .card-usage-track {
  flex: 1;
  min-width: 36px;
}
.bar-cell-sub {
  font-size: 8px;
  color: var(--text-2);
  margin-top: 1px;
}
/* X-D (leg-16) -- the always-on 5h/7d countdown's static prefix ("resets "), dimmer than the
   ticking value beside it, matching the existing usage-cred/dim-annotation convention. */
.bar-cell-sub-prefix {
  color: var(--text-3);
}

/* dash-auth-demote (2026-08-12) -- a dead usage-reporting chain (never the serving credential)
   renders "n/a" here, dim, never red: the worker itself is unaffected. */
.usage-cred {
  color: var(--text-3);
}

.col-backin {
  color: var(--text-1);
  white-space: nowrap;
}

.col-toggle {
  text-align: right;
  white-space: nowrap;
}

/* ─── section E: row-expansion detail panel ──────────────────────────────────────────────── */
.fleet-detail-row td {
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.detail-badges {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.detail-slots-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.detail-row {
  font-size: 10px;
  color: var(--text-2);
}
.detail-label {
  color: var(--text-3);
  margin-right: 6px;
  text-transform: uppercase;
  font-size: 8px;
}
.detail-cb-fail {
  color: var(--red);
}

.badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-green {
  background: var(--green-dim);
  color: var(--green);
}
.badge-yellow {
  background: var(--yellow-dim);
  color: var(--yellow);
}
.badge-red {
  background: var(--red-dim);
  color: var(--red);
}
.badge-accent {
  background: var(--accent-dim);
  color: var(--accent);
}
.badge-dim {
  background: var(--bg-3);
  color: var(--text-3);
  border: 1px solid var(--border);
}
/* 2.5: ROUTING OFF — distinct from badge-red (fault) / badge-yellow (rate-limited) since an
   admin-disabled backend is an intentional operator decision, not a health problem. */
.badge-off {
  background: var(--bg-4);
  color: var(--text-2);
  border: 1px solid var(--border-bright);
}
/* usage-live: DEAD-CHAIN -- distinct from solid badge-red (an active fault elsewhere) since this
   marks a terminal OAuth chain state (no_credentials/invalid_grant) that needs re-seeding, not a
   transient failure. */
.badge-red-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}

/* 2.5: per-card routing toggle switch (checked = routing ON, i.e. NOT admin-disabled) */
.routing-toggle {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}
.routing-toggle-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.routing-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: 999px;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.routing-toggle-slider::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  left: 1px;
  top: 1px;
  background: var(--text-0);
  border-radius: 50%;
  transition: transform 0.15s;
}
.routing-toggle-input:checked + .routing-toggle-slider {
  background: var(--green-dim);
  border-color: var(--green);
}
.routing-toggle-input:checked + .routing-toggle-slider::before {
  transform: translateX(12px);
}

/* ─── card-usage spec sections A/B: tri-bar micro-meter + state line ──────
   Placed below the identity row, above the slots row (quota outranks slot/pool detail; identity
   still leads). Bars reuse the SAME accent/yellow/red status ramp as the USAGE panel's bars
   (measured CVD-safe, see specs/card-usage-spec.md) -- never green. Color is reinforcement only:
   bar length + the numeric percent + the state-line token carry the signal. */
.card-usage-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-usage-tribar {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-usage-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Binding emphasis (the row whose utilization is the fleet-wide MAX): full opacity + --text-0
   percent text. Subordinate rows: opacity 0.55 + --text-2 percent text (set on .card-usage-pct
   below). No extra glyph/arrow -- opacity plus text weight is the whole signal. */
.card-usage-row.subordinate {
  opacity: 0.55;
}

.card-usage-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  width: 5ch;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-usage-track {
  flex: 1;
  height: 4px;
  min-width: 20px;
  background: var(--bg-3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

/* Null rule: an empty track must be VISIBLE -- a 0% bar and a no-data bar have to look different.
   No fill div is emitted for a null bucket (see app.js cardUsageBarRow); the dashed border is the
   whole signal. */
.card-usage-track.unknown {
  border: 1px dashed var(--border-bright);
  background: transparent;
}

.card-usage-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}

.card-usage-fill.warn {
  background: var(--yellow);
}

.card-usage-fill.serious {
  background: var(--red);
}

.card-usage-pct {
  font-family: var(--font-mono);
  font-size: 9px;
  width: 4ch;
  text-align: right;
  flex-shrink: 0;
  color: var(--text-2);
}

.card-usage-row.binding .card-usage-pct {
  color: var(--text-0);
}

.card-usage-stateline {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Slots row — now also holds inline CB status + RL count to kill the trailing row */
.card-slots-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-slots-info {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  flex-shrink: 0;
  white-space: nowrap;
}

.slot-bar {
  flex: 1;
  height: 2px;
  min-width: 20px;
  background: var(--bg-0);
  border-radius: 2px;
  overflow: hidden;
}

.slot-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition:
    width 0.5s ease-out,
    background 0.3s;
  background: var(--accent);
}

.slot-bar-fill.warn {
  background: var(--yellow);
}
.slot-bar-fill.crit {
  background: var(--red);
}

.rl-hits {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-3);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Inline CB indicator inside the slots row */
.card-slots-row .card-cb {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.pool-dead {
  color: var(--red);
}
.route-reason {
  color: var(--red);
  font-weight: 700;
}

/* ─── Uniform worker-pool monitor (identical for local + remote backends) ── */
.card-pool {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border, #1c2333);
}
.pool-counts {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
}
.pool-pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}
.pip {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--text-3);
  transition: background 0.18s ease;
  flex: 0 0 auto;
}
.pip-idle {
  background: var(--green);
}
.pip-busy {
  background: var(--yellow);
}
.pip-dead {
  background: var(--red);
}
.pip-starting {
  background: var(--text-3);
  opacity: 0.6;
}
.pool-pips-empty {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-3);
  letter-spacing: 0.5px;
}
.pool-probe {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0 3px;
  border-radius: 2px;
}
.pool-probe-ok {
  color: var(--green);
}
.pool-probe-failed {
  color: var(--red);
}
.pool-probe-pending {
  color: var(--text-3);
}
.pool-stale {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  color: #000;
  background: var(--yellow);
  padding: 0 3px;
  border-radius: 2px;
}

/* Pool / Limiter / Exhaustion rows */
.card-info-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-info-line {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.card-info-line .info-label {
  color: var(--text-3);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.card-cb {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
}

.card-cb.cb-closed {
  color: var(--green);
}
.card-cb.cb-open {
  color: var(--red);
}
.card-cb.cb-half_open {
  color: var(--yellow);
}

.exhaustion-timer {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  animation: blink-slow 1.5s ease-in-out infinite;
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  flex-wrap: wrap;
  line-height: 1.35;
}
.exhaustion-window {
  background: var(--red);
  color: var(--bg-0);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: none;
}
.exhaustion-absolute {
  color: var(--text-1);
  animation: none;
  font-weight: 600;
}
.exhaustion-relative {
  color: var(--text-dim);
  font-weight: 400;
  animation: none;
  font-size: 8px;
}

@keyframes blink-slow {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ─── C3: FABLE section ────────────────────────────────────────────────── */

.fable-off-line {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.fable-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fable-ledger-tile {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.fable-ledger-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fable-ledger-label {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.fable-ledger-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-0);
}

.fable-ledger-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.fable-watched-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.fable-watched-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.fable-stat {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fable-stat-label {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.fable-stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
}

.fable-stat-value.muted {
  color: var(--text-3);
}

.fable-stat-value.warn {
  color: var(--yellow);
}

.fable-stat-value.flash {
  animation: fable-flash 1.2s ease-out;
}

@keyframes fable-flash {
  0% {
    text-shadow: 0 0 8px var(--yellow);
  }
  100% {
    text-shadow: none;
  }
}

.fable-cooldown-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.fable-cooldown-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--yellow);
}

.fable-cooldown-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
}

/* ─── C5: USAGE section ────────────────────────────────────────────────── */

.usage-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.usage-account {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.usage-account-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-0);
}

/* usage-live: per-account state accent, mirrors the .toast state-border idiom (left border only,
   card background/border stay neutral). */
.usage-account-low {
  border-left: 3px solid var(--yellow);
}
.usage-account-exhausted {
  border-left: 3px solid var(--red);
}
.usage-account-unknown {
  border-left: 3px solid var(--border-bright);
}

/* usage-live: header row (account name + badges + freshness) above the 5h/7d/model bars. */
.usage-account-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage-badges {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-wrap: nowrap;
}

.usage-freshness {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  margin-left: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.usage-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.usage-row-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
  width: 46px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* F2 fix round note (superseded by usage-live): the est fallback still emits no bar (no real
   denominator on /status.usage); usage-live's bars below are what these rules were reserved for. */
.usage-bar-track {
  flex: 1;
  height: 6px;
  min-width: 60px;
  background: var(--bg-0);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

/* usage-live: null bucket -- an EMPTY track (no fill div at all, see app.js usageLiveBarRow) plus
   a dashed border so it reads distinctly from a real, low, 0%-ish fill rather than looking like
   one. The "?" glyph is centered inside via flex on the track itself. */
.usage-bar-track.unknown {
  border: 1px dashed var(--border-bright);
  display: flex;
  align-items: center;
  justify-content: center;
}

.usage-bar-unknown-glyph {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  line-height: 1;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.usage-bar-fill.warn {
  background: var(--yellow);
}

.usage-bar-fill.serious {
  background: var(--red);
}

.usage-row-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  white-space: nowrap;
  flex-shrink: 0;
}

.usage-est-badge {
  font-size: 8px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0 3px;
  text-transform: uppercase;
}

.usage-reset {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  flex-shrink: 0;
}

.usage-nodata,
.usage-empty {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

/* usage-live: fleet summary strip, sits above the per-account rows inside #usage-body. */
.usage-fleet-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
}

.usage-fleet-reset {
  color: var(--text-3);
  flex-shrink: 0;
  white-space: nowrap;
}

/* card-usage spec section C -- provenance + freshness line (source mix, pushing machine(s), age
   of the newest reading), sits once per panel between the fleet strip and the exceptions list. */
.usage-provenance {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  padding: 2px 2px 8px;
}

/* card-usage spec section C -- the exceptions-only list (credential errors + dead chains, not all
   N accounts) reuses .usage-body's existing flex/gap via a plain wrapper; the empty state is one
   quiet line, not an empty box. */
.usage-exceptions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.usage-exceptions-empty {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

/* ─── C6: OPS section ──────────────────────────────────────────────────── */

.ops-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.ops-tile {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ops-tile.muted {
  color: var(--text-2);
}

.ops-tile.warn {
  border-color: var(--yellow);
  background: var(--yellow-dim);
}

.ops-tile-label {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.ops-tile-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
}

.ops-tile.warn .ops-tile-value {
  color: var(--yellow);
}

.ops-tile-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-2);
}

.ops-tile-warntext {
  color: var(--yellow);
  font-weight: 600;
}

/* ─── Active Requests Strip ───────────────────────────────────────────── */

.active-strip {
  display: flex;
  gap: 20px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  align-items: center;
  flex-wrap: wrap;
}

.active-model {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
}

.active-model-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.active-model-name {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.active-model-name.haiku {
  color: var(--haiku);
}
.active-model-name.sonnet {
  color: var(--sonnet);
}
.active-model-name.opus {
  color: var(--opus);
}
.active-model-name.sonnet5 {
  color: var(--sonnet5);
}
.active-model-name.fable {
  color: var(--fable);
}
.active-model-name.unknown {
  color: var(--model-unknown);
}

.active-model-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-0);
}

.active-model-reserved {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
}

.active-bar-track {
  height: 6px;
  background: var(--bg-0);
  border-radius: 3px;
  overflow: visible;
  position: relative;
}

.active-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-out;
  max-width: 100%;
}

.active-bar-fill.haiku {
  background: var(--haiku);
}
.active-bar-fill.sonnet {
  background: var(--sonnet);
}
.active-bar-fill.opus {
  background: var(--opus);
}
.active-bar-fill.sonnet5 {
  background: var(--sonnet5);
}
.active-bar-fill.fable {
  background: var(--fable);
}
.active-bar-fill.unknown {
  background: var(--model-unknown);
}

.active-overflow {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--orange);
  margin-top: 2px;
}

.active-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── Per-Model Latency ───────────────────────────────────────────────── */

.latency-grid {
  display: grid;
  /* S5.1/S5.3: the model set is data-driven (up to 5 known models today, more later) -- a fixed
     3-column grid broke as soon as sonnet5/fable showed up. Auto-fit lets it grow/shrink cleanly. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.latency-col {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.latency-col-header {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.latency-col-header.haiku {
  color: var(--haiku);
}
.latency-col-header.sonnet {
  color: var(--sonnet);
}
.latency-col-header.opus {
  color: var(--opus);
}
.latency-col-header.sonnet5 {
  color: var(--sonnet5);
}
.latency-col-header.fable {
  color: var(--fable);
}
.latency-col-header.unknown {
  color: var(--model-unknown);
}

.latency-stat-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 5px 0;
}

.latency-stat-label {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 1px;
}

.latency-stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-0);
}

.latency-stat-value.dim {
  color: var(--text-3);
  font-size: 13px;
}

/* ─── Throughput Section ──────────────────────────────────────────────── */

#section-throughput .dash-section {
  gap: 12px;
}

#throughput-canvas {
  width: 100%;
  display: block;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ─── Logs Section ────────────────────────────────────────────────────── */

.logs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.logs-filters,
.logs-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.log-select,
.log-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
}

.log-select:focus,
.log-input:focus {
  border-color: var(--accent);
}

.log-input {
  width: 160px;
}

#log-container {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  position: relative;
  height: 400px;
}

/* Terminal-like inner glow */
#log-container::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

#log-entries {
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
}

.log-line {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 1px 0;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 2px;
}

.log-line:hover {
  background: var(--bg-2);
}

.log-ts {
  color: var(--text-3);
  flex-shrink: 0;
  width: 70px;
}

.log-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 2px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.log-badge.backend {
  background: var(--bg-4);
  color: var(--text-1);
  min-width: 64px;
  text-align: center;
}

.log-badge.model-haiku {
  background: rgba(34, 197, 94, 0.15);
  color: var(--haiku);
}
.log-badge.model-sonnet {
  background: rgba(88, 166, 255, 0.15);
  color: var(--sonnet);
}
.log-badge.model-opus {
  background: rgba(192, 132, 252, 0.15);
  color: var(--opus);
}
.log-badge.model-sonnet5 {
  background: rgba(45, 212, 191, 0.15);
  color: var(--sonnet5);
}
.log-badge.model-fable {
  background: rgba(244, 114, 182, 0.15);
  color: var(--fable);
}
.log-badge.model-unknown {
  background: rgba(125, 133, 144, 0.15);
  color: var(--model-unknown);
}

.log-badge.level-info {
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
}
.log-badge.level-warn {
  background: var(--yellow-glow);
  color: var(--yellow);
}
.log-badge.level-error {
  background: var(--red-glow);
  color: var(--red);
}

.log-msg {
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.log-meta {
  display: none;
  padding: 6px 12px 6px 86px;
  font-size: 10px;
  color: var(--text-2);
  background: var(--bg-2);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-all;
}

.log-meta.expanded {
  display: block;
}

/* ─── Controls Drawer ─────────────────────────────────────────────────── */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.6);
  backdrop-filter: blur(2px);
  z-index: 200;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: var(--bg-1);
  border-left: 1px solid var(--border);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease-out;
  overflow: hidden;
}

.drawer.hidden {
  display: flex !important;
  transform: translateX(100%);
  pointer-events: none;
}

.drawer-backdrop.hidden {
  display: none !important;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.drawer-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-2);
}

.drawer-close-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition:
    color 0.15s,
    background 0.15s;
  line-height: 1;
}

.drawer-close-btn:hover {
  color: var(--text-0);
  background: var(--bg-3);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Controls ────────────────────────────────────────────────────────── */

.control-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.control-section-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 14px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
}

.control-section-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-3);
  text-transform: uppercase;
}

.control-body {
  padding: 16px;
}

.control-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.control-subsection {
  margin-bottom: 16px;
}

.control-subsection:last-child {
  margin-bottom: 0;
}

.control-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-3);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.control-full-width {
  width: 100%;
}

.token-input-row {
  display: flex;
  gap: 8px;
}

.control-input {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 12px;
  outline: none;
  flex: 1;
  transition: border-color 0.15s;
}

.control-input:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn-action {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  white-space: nowrap;
}

.btn-action:disabled,
.control-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-action:hover {
  background: var(--bg-4);
  border-color: var(--border-bright);
  color: var(--text-0);
}

.btn-small {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-small:hover {
  background: var(--bg-4);
}

.btn-small.active {
  background: var(--yellow-dim);
  color: var(--yellow);
  border-color: var(--yellow);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 7px 14px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.btn-ghost:hover {
  color: var(--text-1);
  border-color: var(--border-bright);
}

.btn-danger {
  background: var(--red);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Limits grid */
.limits-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

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

.limit-name {
  font-size: 11px;
  color: var(--text-2);
}

.limit-input {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 8px;
  width: 60px;
  outline: none;
  text-align: right;
  transition: border-color 0.15s;
}

.limit-input:focus {
  border-color: var(--accent);
}

/* Emergency */
.emergency {
  background: var(--bg-1);
  border: 1px solid var(--red-dim);
  border-radius: var(--radius);
  padding: 14px;
}

.emergency .control-label {
  color: var(--red);
}

.emergency-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-emergency {
  background: var(--red-dim);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 20px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background 0.15s;
}

.btn-emergency:hover {
  background: var(--red);
  color: #fff;
}

.btn-emergency.active {
  background: var(--red);
  color: #fff;
  animation: emergency-pulse 1s ease-in-out infinite;
}

@keyframes emergency-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

#emergency-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}

.control-row-spaced {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.control-row-spaced > .control-subsection {
  flex: 1;
}

/* ─── Footer ──────────────────────────────────────────────────────────── */

#footer {
  height: var(--footer-height);
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-size: 11px;
  color: var(--text-3);
  padding: 0 20px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

/* ─── Scrollbar ───────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}

/* ─── Selection ───────────────────────────────────────────────────────── */

::selection {
  background: var(--accent-dim);
  color: var(--text-0);
}
