/* ============================================================================
   AGENTCOLLISION DASHBOARD — v0.5 redesign
   ============================================================================

   Single-file embedded HTML. No build step. No external CDN.
   Served by the Go daemon at http://127.0.0.1:7777/ui/.

   Architecture:
     - Sidebar nav (left) + content area (right)
     - 5 in-page routes: overview, chats, leases, files, events
     - Shared state object updated by SSE + polling
     - All UI rendered from state — no DOM manipulation outside renderers
     - Tooltips via data-tooltip attributes + custom CSS positioning

   Design system:
     - Dark by default, light mode via manual toggle
     - Deep blue-black palette, glassmorphism panels
     - Inter for UI text, JetBrains Mono for code/IDs
     - 8px spacing scale, smooth animations throughout
     - Loading skeletons for initial data fetch
     - Page transitions, card enter animations, micro-interactions
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  --sidebar-w: 260px;
  --content-max: 1400px;
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-med: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Brand ramp. Used by .btn-primary gradient, focus rings, and the
     accent links. Ported from Roadmapper's Tailwind brand scale so
     the two products feel related. Theme-agnostic (used by both
     dark and light modes). */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;
  --brand-900: #1e3a8a;
}

/* dark theme (default) */
:root, [data-theme="dark"] {
  --bg-base: #060a14;
  --bg-panel: rgba(15, 22, 40, 0.7);
  --bg-panel-solid: #0f1628;
  --bg-panel-hover: rgba(26, 36, 60, 0.8);
  --bg-elevated: rgba(25, 35, 58, 0.9);
  --bg-overlay: rgba(6, 10, 20, 0.85);
  --bg-glass: rgba(15, 22, 40, 0.5);
  --bg-soft: rgba(25, 35, 58, 0.55); /* alias for code blocks + chips */
  --bg: var(--bg-panel-solid); /* generic alias for inline-styled inputs */

  --border: rgba(56, 78, 128, 0.2);
  --border-strong: rgba(80, 110, 170, 0.3);
  --border-glow: rgba(96, 165, 250, 0.15);

  --text: #e8ecf4;
  --text-secondary: #8b96b0;
  --text-tertiary: #4f5b73;
  --text-muted: #8b96b0; /* alias used by inline styles */
  --text-inverse: #060a14;
  --text-display: #ffffff; /* page titles + headings on dark */

  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --accent-dim: #2563eb;
  --accent-bg: rgba(96, 165, 250, 0.08);
  --accent-bg-strong: rgba(96, 165, 250, 0.15);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --success-glow: rgba(52, 211, 153, 0.2);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --info: #a78bfa;
  --info-bg: rgba(167, 139, 250, 0.1);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(96, 165, 250, 0.1);

  --gradient-hero: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(139, 92, 246, 0.05) 50%, rgba(52, 211, 153, 0.03) 100%);
  --gradient-sidebar: linear-gradient(180deg, #0a1020 0%, #060a14 100%);
}

/* light theme — Roadmapper-style. Slate-50 base, white panels,
   slate-700 default text, very-soft shadows. The inline-styled
   buttons we still have in HTML use these tokens directly, so
   this is the load-bearing palette for the light look. */
[data-theme="light"] {
  --bg-base: #f8fafc;            /* slate-50 */
  --bg-panel: #ffffff;
  --bg-panel-solid: #ffffff;
  --bg-panel-hover: #f1f5f9;     /* slate-100 */
  --bg-elevated: #f1f5f9;        /* slate-100 — used for chip/disabled bg */
  --bg-overlay: rgba(248, 250, 252, 0.92);
  --bg-glass: rgba(255, 255, 255, 0.7);
  --bg-soft: #f1f5f9;            /* slate-100, alias for code blocks */
  --bg: #ffffff;                  /* generic alias for inline-styled inputs */

  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --border-glow: rgba(37, 99, 235, 0.18);

  --text: #334155;               /* slate-700 default body */
  --text-secondary: #64748b;     /* slate-500 */
  --text-tertiary: #94a3b8;      /* slate-400 */
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --text-display: #0f172a;       /* slate-900 — page titles + headings */

  --accent: var(--brand-600);
  --accent-strong: var(--brand-700);
  --accent-dim: var(--brand-500);
  --accent-bg: rgba(37, 99, 235, 0.06);
  --accent-bg-strong: rgba(37, 99, 235, 0.12);

  --success: #16a34a;
  --success-bg: rgba(22, 163, 74, 0.08);
  --success-glow: rgba(22, 163, 74, 0.15);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #e11d48;             /* rose-600 — matches Roadmapper btn-danger */
  --danger-bg: rgba(225, 29, 72, 0.08);
  --info: #7c3aed;
  --info-bg: rgba(124, 58, 237, 0.08);

  /* Roadmapper-spec soft shadows. Two stacked rgba layers for
     depth without darkness. */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 0 0 4px rgba(37, 99, 235, 0.12);

  --gradient-hero: linear-gradient(135deg, rgba(37, 99, 235, 0.04) 0%, rgba(139, 92, 246, 0.03) 50%, rgba(22, 163, 74, 0.02) 100%);
  --gradient-sidebar: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* ----- Animations ----- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--success-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
@keyframes breathe {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes drawerIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes eventSlide {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes eventFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes heroGlow {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* ----- Skeleton loaders ----- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--r-md);
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-text.med { width: 60%; }
.skeleton-heading { height: 24px; width: 50%; margin-bottom: 12px; }
.skeleton-stat { height: 36px; width: 60px; }
.skeleton-card {
  height: 120px;
  margin-bottom: var(--s4);
  border-radius: var(--r-lg);
}
.skeleton-row {
  height: 44px;
  margin-bottom: 2px;
}

/* ----- Page transition ----- */
.page-enter {
  animation: fadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ----- reset + base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Inter optical / contextual / stylistic alternates — turns on
     the friendlier rounded "g/y/l", proper open "1", and slightly
     softer letter shapes that read as a well-considered design
     system rather than default web typography. Matches the
     Roadmapper feel; cheap (~50 bytes of font config). */
  font-feature-settings: "cv02", "cv11", "ss01";
  letter-spacing: -0.01em;
  overflow-x: hidden;
}
::selection { background: var(--accent-bg-strong); color: var(--text); }
button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--font-mono); font-size: 12.5px; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ----- layout shell ----- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ----- sidebar ----- */
.sidebar {
  background: var(--gradient-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
}
.sidebar-brand {
  padding: var(--s5) var(--s5) var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s3);
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img, .sidebar-brand svg {
  flex-shrink: 0;
  border-radius: 6px;
  transition: transform var(--transition-spring), box-shadow var(--transition-med);
}
.sidebar-brand:hover img, .sidebar-brand:hover svg {
  transform: scale(1.05) rotate(-2deg);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.2);
}
.sidebar-brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-brand-text .ver {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  margin-top: 1px;
}
.sidebar-nav {
  flex: 1;
  padding: var(--s3) var(--s2);
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px var(--s3);
  margin: 2px 0;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent-bg) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}
.nav-item:hover {
  background: var(--bg-panel-hover);
  color: var(--text);
  border-color: var(--border);
  z-index: 1;
}
.nav-item:hover::before { opacity: 1; }
.nav-item.active {
  background: var(--accent-bg-strong);
  color: var(--accent);
  font-weight: 600;
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
}
.nav-item.active::before { opacity: 1; }
.nav-item svg { flex-shrink: 0; opacity: 0.8; position: relative; z-index: 1; }
.nav-item span { position: relative; z-index: 1; }
.nav-item .badge {
  margin-left: auto;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  min-width: 22px;
  text-align: center;
  position: relative;
  z-index: 1;
  transition: all var(--transition-fast);
}
.nav-item.active .badge {
  background: var(--accent);
  color: var(--text-inverse);
}
.nav-section-label {
  padding: var(--s4) var(--s3) var(--s2);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.sidebar-footer {
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 11px;
  color: var(--text-tertiary);
}
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 600;
  font-size: 11px;
  transition: all var(--transition-med);
}
.connection-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulseGlow 2s ease-in-out infinite;
}
.connection-pill.disconnected {
  background: var(--danger-bg);
  color: var(--danger);
}
.connection-pill.disconnected .dot { background: var(--danger); animation: pulse 1s ease-in-out infinite; }
/* "Connected to API but no daemon yet / all daemons offline" — amber, not success green */
.connection-pill.idle {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
}
.connection-pill.idle .dot { background: var(--warning); animation: none; }
.theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(15deg); }

/* ----- content area ----- */
.content {
  padding: var(--s6);
  max-width: var(--content-max);
  width: 100%;
  /* Flex child default min-width: auto can blow the layout wider than the
     viewport when any descendant has white-space: nowrap on long content
     (e.g. the install command). Explicitly cap at 0 to force the flex
     sibling to respect the container width and push overflow inward. */
  min-width: 0;
}
.page { display: none; }
.page.active { display: block; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--s5);
  gap: var(--s4);
}
.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--s1);
  background: linear-gradient(135deg, var(--text) 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 720px;
  line-height: 1.6;
}
.page-actions { display: flex; gap: var(--s2); align-items: center; }

/* ----- segmented control ----------------------------------------------
   Tab-like row of mutually exclusive buttons. Used for the Overview's
   time-range picker (24h / 7d / 30d). Keep visually quiet so it sits
   alongside other page-actions without competing with primary buttons. */
.segmented-control {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 0;
}
.segmented-button {
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: calc(var(--r-md) - 2px);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 120ms, color 120ms;
}
.segmented-button:hover {
  color: var(--text-primary);
}
.segmented-button.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}
.segmented-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ----- buttons --------------------------------------------------------
   One base .btn + variant classes. Tuned for a tighter, more modern look
   after the 2026-04-22 polish pass:
     - Resting shadow on primary/danger so they feel "clickable" at rest
     - Smoother 180ms transition (was blanket transition-fast which is
       punchier than it needs to be for color changes)
     - Visible focus ring for keyboard users (missing before)
     - .btn-ghost variant for secondary actions that were using the base
       .btn and looked too similar to primary
     - Disabled state is coherent across variants (was only half-defined)
---------------------------------------------------------------------- */
/* ─── Roadmapper-style button system ──────────────────────────────
   Five variants: primary (gradient), secondary (white/elevated +
   border), ghost (text-only, hover bg), danger (rose gradient),
   plus -sm / -icon size modifiers. Every variant shares:
     - inset top highlight (1px white-alpha) for "lit from above"
       physical feel
     - colored hover shadow that matches the button's hue (primary
       gets brand-blue, danger gets rose) — a small detail that
       lifts perceived polish
     - active: scale(0.98) for tactile click feedback
     - focus-visible: ring-2 colored to the variant
   The base `.btn` is still the secondary/neutral fallback for
   call-sites that don't pick a variant.
   ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 100ms ease, color 150ms ease;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  border-color: var(--border-strong);
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg-strong), var(--shadow-sm);
  border-color: var(--accent);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Catch-all for inline-styled <button>s (legacy) that don't use
   the .btn class. Keeps disabled buttons visibly disabled across
   the app even before they're migrated to .btn. */
button:disabled:not(.btn) {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── primary: gradient + inset highlight + colored hover shadow */
.btn-primary {
  background: linear-gradient(to bottom, var(--brand-500), var(--brand-600));
  color: #ffffff;
  border-color: var(--brand-600);
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.20) inset, 0 1px 2px rgba(15, 23, 42, 0.10);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(to bottom, var(--brand-600), var(--brand-700));
  border-color: var(--brand-700);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.20) inset, 0 2px 8px rgba(37, 99, 235, 0.30);
}
.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--brand-300), 0 1px 0 rgba(255, 255, 255, 0.20) inset;
  border-color: var(--brand-700);
}

/* ── secondary: white/elevated panel with border. Use next to a
      primary when the action is supportive but not the default. */
.btn-secondary {
  background: var(--bg-panel-solid);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  border-color: var(--border-strong);
}

/* ── ghost: text-only with hover bg. Cancel / secondary-secondary
      action. Doesn't compete with primaries. */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

/* ── pick: dashed-outline button that lives inside sentence
      forms. Reads unambiguously as clickable (the dashed border
      + + sign cue) without competing visually with primaries.
      Use for "+ tool", "+ path", "+ priority", etc. */
.btn-pick {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
  line-height: 1.4;
  vertical-align: middle;
  font-family: inherit;
}
.btn-pick:hover:not(:disabled) {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
  border-style: solid;
}
.btn-pick:active:not(:disabled) { transform: scale(0.97); }
.btn-pick:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-bg-strong);
  border-color: var(--accent);
  border-style: solid;
}

/* ─── Tooltip positioning anchor ─────────────────────────────────
   `[data-tooltip]` elements get `position: relative` so any nested
   absolutely-positioned UI (focus rings, chevrons) anchors here.
   The actual hover popup is rendered by the JS-driven `#ac-tooltip`
   widget (see dashboard/src/widgets.js — `installTooltip()`), which
   handles edge-clamping and viewport overflow that pure CSS can't.
   Previously a `[data-tooltip]:hover::before` block ALSO rendered a
   tooltip via CSS; that produced two overlapping tooltips per hover
   (the CSS one clipped at the right viewport edge because it used
   transform: translateX(-50%)). Removed in favour of the JS widget.
   ────────────────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

/* ─── Rule-row responsive behavior ──────────────────────────────
   The dense rule rows (.policy-rule-row, .priority-rule-row) pack
   8+ flex items per row. Below ~720px viewport this wraps awkwardly.
   Hide the inline sentence column on narrow viewports — the user
   can still click the row to expand and read the full sentence,
   and the row stays usable for drag/edit/delete on mobile/iPad.
   ────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .policy-rule-row .policy-rule-sentence,
  .priority-rule-row .priority-rule-sentence {
    display: none;
  }
  .policy-rule-row strong,
  .priority-rule-row strong {
    /* Let the name expand into the space freed by hiding the sentence */
    max-width: none !important;
  }
}
@media (max-width: 540px) {
  /* Tighten further at phone widths: drop the "Default" chip on
     name-decorated rules and the secondary audit/preempt chips
     keep their colored signal but lose their text. */
  .policy-rule-row .chip,
  .priority-rule-row .chip {
    padding: 2px 6px;
  }
}

/* Focus rings on drag-handle + chevron + chips — currently they
   have no visible focus state so keyboard users can't tell what's
   selected. Cheap accessibility win. */
.policy-rule-row:focus-within,
.priority-rule-row:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text);
}
/* Onboarding choice buttons */
.onboard-choice { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: left; cursor: pointer; transition: all var(--transition-fast); color: var(--text); font-family: inherit; }
.onboard-choice:hover { border-color: var(--border-glow); background: var(--bg-panel-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(96, 165, 250, 0.1); }
.onboard-choice-title { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }
.onboard-choice-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
/* Billing plan picker */
.billing-plan-list { list-style: none; padding: 0; margin: 0 0 var(--s3); font-size: 12px; line-height: 1.7; flex: 1; }
.billing-plan-list li { padding-left: 18px; position: relative; color: var(--text-secondary); }
.billing-plan-list li::before { content: "\2713"; position: absolute; left: 0; color: var(--success); font-weight: 700; }
.billing-plan-card button:disabled { opacity: 0.6; cursor: default; }
@media (max-width: 900px) {
  #billing-plan-cards { grid-template-columns: 1fr !important; }
}
.btn-danger {
  background: linear-gradient(to bottom, #f43f5e, #e11d48);
  color: #ffffff;
  border-color: #e11d48;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.20) inset, 0 1px 2px rgba(15, 23, 42, 0.10);
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(to bottom, #e11d48, #be123c);
  border-color: #be123c;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.20) inset, 0 2px 8px rgba(244, 63, 94, 0.30);
}
.btn-danger:focus-visible {
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.30), 0 1px 0 rgba(255, 255, 255, 0.20) inset;
  border-color: #be123c;
}

/* ── danger-ghost: rose text + rose-tint hover. For "Delete" links
      embedded in a list where a full danger button would be too
      loud. */
.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: #e11d48;
  font-weight: 500;
  box-shadow: none;
}
.btn-danger-ghost:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.08);
}

/* Size variants. .btn-sm was previously 11px font / 4px padding which was
   cramped enough that "Copy" and "Resend" buttons looked like hyperlinks.
   Bumped to 12px / 6px — still compact, but clearly clickable. */
.btn-sm { padding: 6px 12px; font-size: 12px; font-weight: 500; gap: 4px; }
.btn-md { padding: 9px 16px; font-size: 13px; font-weight: 500; gap: 6px; }
.btn-lg { padding: 11px 20px; font-size: 14px; font-weight: 600; gap: 8px; }
.btn-icon { padding: 8px; gap: 0; }

/* ─── Component primitives: .card .label .chip ───────────────────
   Reusable shapes for the new Policy/Agents/Decisions surfaces.
   Small enough to drop in anywhere; the existing .panel rule in
   the next block stays as-is for backwards compatibility — pages
   can migrate to .card incrementally. */
.card {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-padded { padding: var(--s4); }
.card-hover {
  transition: box-shadow 200ms ease, border-color 200ms ease, transform 200ms ease;
}
.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-tertiary);
  font-weight: 600;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.chip-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.chip-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: transparent; }
.chip-info    { background: var(--info-bg);    color: var(--info);    border-color: transparent; }
.chip-accent  { background: var(--accent-bg);  color: var(--accent);  border-color: transparent; }

/* ----- panels (cards) ----- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color var(--transition-med), box-shadow var(--transition-med);
}
.panel:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-glow);
}
.panel-header {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}
.panel-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.panel-title .count {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.panel-body { padding: var(--s5); }
.panel-body.flush { padding: 0; }

/* help icon (?) */
.help-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  margin-left: 4px;
  text-transform: none;
  letter-spacing: 0;
  transition: all var(--transition-fast);
}
.help-icon:hover { color: var(--accent); border-color: var(--accent); transform: scale(1.1); }

/* ----- tooltip system (JS-driven, position: fixed) ----- */
#ac-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: var(--r-md);
  white-space: normal;
  max-width: min(360px, calc(100vw - 16px));
  min-width: 100px;
  width: max-content;
  /* `word-break: break-all` broke mid-word (e.g. "he\nartbeat",
     "ted files in the las"). Switch to overflow-wrap which only
     breaks at word boundaries, then character-breaks as a last
     resort for tokens wider than the box (long file paths, URLs,
     hashes). hyphens: auto adds soft hyphens for clean wrap. */
  overflow-wrap: anywhere;
  word-break: normal;
  hyphens: auto;
  box-shadow: var(--shadow-lg);
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-sans);
  opacity: 0;
  transition: opacity 0.12s ease;
}
#ac-tooltip.visible { opacity: 1; }

/* ----- overview hero ----- */
.hero {
  background: var(--gradient-hero);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--s6);
  margin-bottom: var(--s5);
  position: relative;
  overflow: visible;
  backdrop-filter: blur(20px);
  transition: border-color var(--transition-med);
}
.hero-glow {
  position: absolute;
  inset: 0;
  border-radius: var(--r-xl);
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.hero::before {
  display: none;
}
.hero-glow::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-bg-strong) 0%, transparent 70%);
  pointer-events: none;
  animation: heroGlow 6s ease-in-out infinite;
}
.hero::after { display: none; }
.hero-glow::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.06) 0%, transparent 70%);
  pointer-events: none;
  animation: heroGlow 8s ease-in-out infinite 2s;
}
.hero:hover { border-color: var(--border-glow); }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s5);
  align-items: center;
  position: relative;
  z-index: 1;
}
.hero-stat-large {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-headline {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s2);
  position: relative;
}
.hero-headline .hero-pulse-text {
  /* The text node sits beside the pulse dot but wraps as normal inline
     content — keeping the headline as a plain block so long copy on
     narrow viewports flows the same way it did before the pulse landed. */
}
.hero-detail {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.6;
  position: relative;
}

/* ----- Hero live pulse -----
   Only present on .hero-headline.is-live (activity is happening). The dot
   pulses at the cadence of a slow heartbeat; a soft halo breathes behind
   the headline. Static when idle/disconnected so the motion actually
   means something. */
.hero-headline .hero-pulse-dot {
  display: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent, #8b5cf6);
  position: relative;
  /* vertical-align: middle keeps the dot baseline-aligned with the text
     when the headline wraps to two lines (the dot stays on line 1). */
  vertical-align: middle;
  margin-right: 10px;
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.55);
}
.hero-headline.is-live .hero-pulse-dot {
  display: inline-block;
  animation: heroPulseDot 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.hero-headline.is-live .hero-pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--accent, #8b5cf6);
  opacity: 0;
  animation: heroPulseRing 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
.hero-headline.is-live::before {
  content: "";
  position: absolute;
  left: -40px;
  top: 50%;
  width: 220px;
  height: 120px;
  transform: translateY(-50%);
  background: radial-gradient(
    ellipse at left center,
    rgba(139, 92, 246, 0.14) 0%,
    rgba(139, 92, 246, 0.05) 40%,
    transparent 70%
  );
  pointer-events: none;
  z-index: -1;
  border-radius: 50%;
  /* Opacity-only animation keeps the halo on the compositor — no
     repaint per frame. The earlier version animated transform: scale()
     + filter: blur(), which forced rasterization every tick. */
  animation: heroPulseHalo 4.8s ease-in-out infinite;
}
@keyframes heroPulseDot {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.55);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0);
    transform: scale(1.08);
  }
}
@keyframes heroPulseRing {
  0% { opacity: 0.6; transform: scale(0.6); }
  80% { opacity: 0; transform: scale(2.4); }
  100% { opacity: 0; transform: scale(2.4); }
}
@keyframes heroPulseHalo {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-headline.is-live .hero-pulse-dot,
  .hero-headline.is-live .hero-pulse-dot::after,
  .hero-headline.is-live::before {
    animation: none;
  }
  .hero-headline.is-live::before { opacity: 0.45; }
}
.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, auto));
  gap: var(--s5);
  padding-left: var(--s5);
  border-left: 1px solid var(--border);
}
.hero-stat-cell { display: flex; flex-direction: column; }
.hero-stat-cell .label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.hero-stat-cell .value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
  transition: color var(--transition-fast);
}
.hero-stat-cell .value.accent { color: var(--accent); }
.hero-stat-cell .value.updated {
  animation: countUp 0.3s ease-out;
}
.hero-stat-cell .delta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ----- welcome banner (first-run empty state) ----- */
.welcome-banner { display: none; position: relative; z-index: 1; text-align: center; padding: var(--s5) 0; }
.welcome-banner.visible { display: block; }
.welcome-banner h2 {
  font-size: 22px; font-weight: 700; color: var(--text); margin: 0 0 var(--s1) 0;
}
.welcome-banner .welcome-subtitle {
  font-size: 14px; color: var(--text-secondary); margin-bottom: var(--s6);
}
.welcome-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4);
  max-width: 700px; margin: 0 auto var(--s5) auto;
}
@media (max-width: 700px) { .welcome-steps { grid-template-columns: 1fr; } }
.welcome-step {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s5) var(--s4); text-align: center; transition: border-color var(--transition-fast);
}
.welcome-step:hover { border-color: var(--accent); }
.welcome-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-bg-strong); color: var(--accent);
  font-size: 13px; font-weight: 700; font-family: var(--font-mono);
  margin-bottom: var(--s3);
}
.welcome-step-text {
  font-size: 13px; color: var(--text); line-height: 1.5;
}
.welcome-note {
  font-size: 12px; color: var(--text-tertiary); max-width: 520px;
  margin: 0 auto; line-height: 1.6;
}
.welcome-note code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--accent-bg); color: var(--accent);
  padding: 1px 5px; border-radius: 4px;
}

/* ----- grid layouts ----- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s4); }
@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ----- activity timeline ----- */
.sparkline-wrap {
  background: var(--bg-base);
  border-radius: var(--r-md);
  padding: var(--s3);
  border: 1px solid var(--border);
  transition: border-color var(--transition-fast);
}
.sparkline-wrap:hover { border-color: var(--border-strong); }
.sparkline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s2);
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.sparkline-canvas { width: 100%; height: 100px; display: block; }
.timeline-legend {
  display: flex;
  gap: var(--s3);
  margin-top: var(--s2);
  flex-wrap: wrap;
}
.timeline-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.timeline-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ----- chat card ----- */
.chat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  margin-bottom: var(--s4);
  transition: all var(--transition-med);
  backdrop-filter: blur(10px);
  animation: fadeUp 0.4s ease-out backwards;
  overflow: hidden;
}
.chat-card:nth-child(2) { animation-delay: 0.05s; }
.chat-card:nth-child(3) { animation-delay: 0.1s; }
.chat-card:nth-child(4) { animation-delay: 0.15s; }
.chat-card:nth-child(5) { animation-delay: 0.2s; }
.chat-card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}
.chat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s4);
  gap: var(--s3);
}
.chat-card-id {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}
.chat-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulseGlow 2s ease-in-out infinite;
}
.chat-status-dot.idle { background: var(--warning); box-shadow: 0 0 8px rgba(251, 191, 36, 0.2); animation: pulse 2s ease-in-out infinite; }
.chat-status-dot.browsing { background: var(--info); box-shadow: 0 0 8px rgba(167, 139, 250, 0.2); animation: pulse 2s ease-in-out infinite; }
.chat-status-dot.gone { background: var(--text-tertiary); box-shadow: none; animation: none; }
.chat-label { display: flex; flex-direction: column; min-width: 0; user-select: text; cursor: text; }
.chat-label .name { font-weight: 600; font-size: 15px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.chat-label .uuid { user-select: text;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-card-meta { font-size: 12px; color: var(--text-secondary); text-align: right; flex-shrink: 0; }
.chat-card-meta .recent { color: var(--text); font-weight: 600; }

.chat-card-section {
  margin-top: var(--s4);
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  user-select: text;
  cursor: text;
}
.chat-card-section:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.chat-card-section-label {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  margin-bottom: var(--s2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-bar { display: flex; flex-direction: column; gap: 3px; margin-bottom: var(--s2); }
.file-bar-label { display: flex; justify-content: space-between; font-size: 12px; }
.file-bar-label .name { font-family: var(--font-mono); color: var(--text); }
.file-bar-label .pct { color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.file-bar-track {
  height: 5px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}
.file-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.recent-files-list { display: flex; flex-direction: column; gap: var(--s2); }
.recent-file-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  font-size: 12.5px;
  padding: 5px 0;
  transition: color var(--transition-fast);
}
.recent-file-row:hover { color: var(--accent); }
.recent-file-row .path {
  font-family: var(--font-mono);
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-fast);
}
.recent-file-row:hover .path { color: var(--accent); }
.recent-file-row .age {
  color: var(--text-tertiary);
  font-size: 11px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ----- lease table ----- */
.lease-table { width: 100%; min-width: 800px; border-collapse: collapse; font-size: 11px; table-layout: fixed; }
.lease-table th {
  text-align: left;
  padding: var(--s2) var(--s3);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 9px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  position: sticky;
  top: 0;
  z-index: 2;
}
.lease-table td {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  transition: background var(--transition-fast);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lease-table tr:last-child td { border-bottom: none; }
.lease-table tr { transition: background var(--transition-fast); }
.lease-table tr:hover td { background: var(--bg-panel-hover); }
.lease-table .resource-cell { font-family: var(--font-mono); color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lease-table .agent-cell { font-family: var(--font-mono); color: var(--info); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lease-table .age-cell { color: var(--text-tertiary); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* state badges */
.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: var(--font-mono);
}
.state-badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}
.state-held { background: var(--success-bg); color: var(--success); }
.state-held::before { background: var(--success); }
.state-expired { background: var(--warning-bg); color: var(--warning); }
.state-expired::before { background: var(--warning); }
.state-released { background: var(--bg-elevated); color: var(--text-tertiary); }
.state-released::before { background: var(--text-tertiary); }
.state-revoked { background: var(--danger-bg); color: var(--danger); }
.state-revoked::before { background: var(--danger); }
.state-lock_delay { background: var(--info-bg); color: var(--info); }
.state-lock_delay::before { background: var(--info); }

/* ----- event row ----- */
.event-list { display: flex; flex-direction: column; }
.event-row {
  display: grid;
  grid-template-columns: 80px 180px minmax(120px, 1fr) minmax(120px, 1fr);
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  align-items: center;
  transition: background var(--transition-fast);
}
/* Clickable event row → expands a full writeup. The expand block is a grid
   child that spans every column. */
.event-row-clickable { cursor: pointer; }
.event-row-clickable:hover { background: var(--bg-soft, rgba(255,255,255,0.02)); }
.event-row-open { background: var(--bg-soft, rgba(255,255,255,0.03)); }
.event-expand {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 8px 10px;
  border-left: 2px solid var(--border);
  background: var(--bg-surface, rgba(255,255,255,0.015));
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Reuse the collision-detail k/v styling inside the event expand. */
.event-expand .spend-ix-kv { display: flex; gap: 8px; font-size: 11px; line-height: 1.4; }
.event-expand .spend-ix-k {
  flex: 0 0 110px; color: var(--text-tertiary, var(--text-muted));
  text-transform: uppercase; font-size: 9px; letter-spacing: 0.04em; padding-top: 1px;
}
.event-expand .spend-ix-v { color: var(--text-muted); font-family: var(--font-mono); word-break: break-word; }
.event-row .agent-context {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-row .agent-context .tool-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--info);
}
.event-row .agent-context .wt-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}
/* Visible event-id chip — muted monospace, pushed to the right; click to
   copy. Surfaces the unique id on the row so a specific event can be found
   and referenced (it used to live only in the hover tooltip). */
.event-id {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  opacity: 0.65;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}
.event-id:hover { opacity: 1; color: var(--accent); }
.event-row.new-event {
  animation: eventSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.event-row.new-event.stagger-1 { animation-delay: 0.03s; }
.event-row.new-event.stagger-2 { animation-delay: 0.06s; }
.event-row.new-event.stagger-3 { animation-delay: 0.09s; }
.event-row.new-event.stagger-4 { animation-delay: 0.12s; }
.event-row.new-event.stagger-5 { animation-delay: 0.15s; }
.event-row:last-child { border-bottom: none; }
.event-row:hover { background: var(--bg-panel-hover); }
.event-row .time {
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
/* .type-badge is the canonical pill chip used across the dashboard:
 * Events, Coordination, Leases row chips, decision/message kind
 * labels, worktree state, etc. Base shape lives here (unscoped).
 * Color comes from sibling .tb-* classes (success/warning/etc.) or
 * inline styles on one-offs. The Events page adds a hover-scale
 * micro-interaction; other pages keep it static. */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: transform var(--transition-fast);
}
.event-row .type-badge { cursor: help; }
.event-row:hover .type-badge { transform: scale(1.02); }
.type-badge .ic {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  text-align: center;
}
.event-row .resource {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tb-acquired  { background: var(--success-bg);  color: var(--success);  }
.tb-released  { background: var(--bg-elevated); color: var(--text-secondary); }
.tb-blocked   { background: var(--danger-bg);   color: var(--danger);   }
.tb-expired   { background: var(--warning-bg); color: var(--warning);  }
.tb-heartbeat { background: var(--accent-bg);  color: var(--accent);   }
.tb-cooldown_elapsed { background: var(--info-bg); color: var(--info); }
.tb-unknown   { background: var(--bg-elevated); color: var(--text-tertiary); }

/* ---- row-card layout -------------------------------------------------
 * Three-column card used for Worktrees, Files, and any future list
 * surface that wants the same visual rhythm:
 *   icon (28px) | body (1fr) | aside (right-aligned: time + actions)
 *
 * The icon column gives every row a visual anchor on the left and
 * keeps the eye moving rightward across the body content instead of
 * stacking everything on the left edge. The aside lane holds the
 * timestamp + an optional action button (e.g. Release on the local-
 * mode worktrees page).
 *
 * Body layout:
 *   row-card-titleline  flexbox: title-text grows, chips stick to its right
 *   row-card-subtitle   long path / file path, monospace, wraps cleanly
 *   row-card-meta       inline strip of secondary metadata with middots
 */
.row-card {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.row-card:hover { background: var(--bg-panel-hover, transparent); }
.row-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent-bg);
  margin-top: 2px;
}
.row-card-body { min-width: 0; }
.row-card-titleline {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.row-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  /* Title gets to ellipsis under pressure rather than overflow the
   * row. min-width:0 is required so a long branch name like
   * "chat-2026-05-14-018870/clerk-cleanup-pt3" doesn't push the
   * chips off-row on narrow viewports — without it, flexbox refuses
   * to shrink an item whose intrinsic content width exceeds the
   * container. The chips remain right-aligned because the title's
   * flex parent uses flex-wrap:wrap, so on tight widths the chips
   * fall to the next line instead of clipping. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.row-card-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.row-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  word-break: break-all;
}
.row-card-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.row-card-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s2);
  text-align: right;
  white-space: nowrap;
}
.row-card-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.row-card-actions {
  display: flex;
  gap: 6px;
}

/* Inline stale-heartbeat warning pill — slots into .event-row .resource
   right after the file path. Labeled chip ("⚠ stale heartbeat") so
   the meaning is visible without hovering — earlier icon-only version
   required hover to discover. Tooltip carries the full "check git
   status on this file" explanation. */
.event-warning-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 1px 6px 1px 5px;
  border-radius: var(--r-sm);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 14px;
  white-space: nowrap;
  cursor: help;
  vertical-align: middle;
}
.event-warning-pill .ic { font-size: 11px; line-height: 1; }

/* ----- pagination ----- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom-left-radius: var(--r-lg);
  border-bottom-right-radius: var(--r-lg);
}
.pagination:empty { display: none; }
.pagination .info { font-variant-numeric: tabular-nums; }
.pagination .controls { display: flex; align-items: center; gap: var(--s2); }
.pagination button {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}
.pagination button:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-indicator {
  font-variant-numeric: tabular-nums;
  padding: 0 var(--s3);
  color: var(--text);
  font-weight: 500;
}

/* ----- file item ----- */
.file-item {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
  animation: fadeUp 0.3s ease-out backwards;
}
.file-item:nth-child(2) { animation-delay: 0.04s; }
.file-item:nth-child(3) { animation-delay: 0.08s; }
.file-item:nth-child(4) { animation-delay: 0.12s; }
.file-item:last-child { border-bottom: none; }
.file-item:hover { background: var(--bg-panel-hover); }
.file-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.file-item-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.file-item-stats {
  display: flex;
  gap: var(--s4);
  font-size: 11px;
  color: var(--text-tertiary);
}
.file-item-stats .stat-num {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.file-item-desc { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.file-item-paths {
  margin-top: var(--s3);
  padding-left: var(--s3);
  border-left: 2px solid var(--accent);
  display: none;
  animation: fadeUp 0.2s ease-out;
}
.file-item.open .file-item-paths { display: block; }
.file-item-paths .path {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  padding: 3px 0;
}

/* ----- empty states ----- */
.empty {
  padding: var(--s7) var(--s5);
  text-align: center;
  color: var(--text-secondary);
  /* No animation here — when this rule sat behind `animation: fadeIn`,
   * rapid re-renders (e.g. renderAgentsPage firing 4x in quick
   * succession while fetchAgents settled) would replace the .empty
   * element before the animation's first frame painted. Synchronous
   * reads of getComputedStyle then saw opacity:0 forever, and the
   * panel ancestor's offsetHeight collapsed to 0 because the
   * still-animating element never produced a layout box. Just paint
   * at full opacity. */
}
.empty-icon {
  font-size: 36px;
  margin-bottom: var(--s3);
  opacity: 0.3;
  filter: grayscale(0.5);
}
.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--s2);
}
.empty-detail {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto var(--s4);
  line-height: 1.6;
}
.empty-detail code {
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 12px;
}
.empty-actions { display: flex; gap: var(--s2); justify-content: center; }

/* ----- inline help block ----- */
.help-block {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  line-height: 1.6;
}
.help-block svg { flex-shrink: 0; color: var(--text-tertiary); margin-top: 2px; }
.help-block strong { color: var(--text); }
.help-block code {
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 12px;
}

/* ----- filter bar ----- */
.filter-bar {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s4);
  align-items: center;
}
.filter-input {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px var(--s4);
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: all var(--transition-fast);
  backdrop-filter: blur(10px);
}
.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg), var(--shadow-glow);
}
.filter-input::placeholder { color: var(--text-tertiary); }
.filter-chip {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-chip.active {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(96, 165, 250, 0.3);
}
.filter-chip:hover:not(.active) { background: var(--bg-panel-hover); border-color: var(--border-strong); }

/* ----- modal / drawer ----- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}
.drawer-backdrop.open { display: flex; }
.drawer {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  max-width: 720px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: drawerIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-header {
  padding: var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s3);
}
.drawer-title { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.drawer-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: all var(--transition-fast);
}
.drawer-close:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-elevated); }
.drawer-body { padding: var(--s5); overflow-y: auto; flex: 1; }

/* ----- confirm modal ----- */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.confirm-backdrop.open { display: flex; }
.confirm-box {
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  max-width: 420px;
  width: 90%;
  padding: var(--s6);
  box-shadow: var(--shadow-lg);
  animation: drawerIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.confirm-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s2);
}
.confirm-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--s5);
}
.confirm-body code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s3);
}
.confirm-actions .btn-cancel,
.confirm-actions .btn-confirm-danger,
.confirm-actions .btn-confirm-primary {
  padding: 9px 20px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 120ms ease, filter 180ms ease;
}
.confirm-actions .btn-cancel:focus-visible,
.confirm-actions .btn-confirm-danger:focus-visible,
.confirm-actions .btn-confirm-primary:focus-visible {
  outline: none;
}
.confirm-actions .btn-cancel {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}
.confirm-actions .btn-cancel:hover { color: var(--text); border-color: var(--border-strong); }
.confirm-actions .btn-cancel:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-bg);
  border-color: var(--accent);
  color: var(--text);
}
.confirm-actions .btn-confirm-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.confirm-actions .btn-confirm-danger:hover { filter: brightness(1.1); box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2); }
.confirm-actions .btn-confirm-danger:focus-visible { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.35); }
.confirm-actions .btn-confirm-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.confirm-actions .btn-confirm-primary:hover { filter: brightness(1.1); box-shadow: 0 4px 14px rgba(96, 165, 250, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2); }
.confirm-actions .btn-confirm-primary:focus-visible { box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.35); }

.prompt-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  margin-bottom: var(--s5);
  box-sizing: border-box;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.prompt-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* ----- toasts -----
   Design choices:
   - No left-color bar (the universal "AI generated" giveaway)
   - No icon column, no emoji — kind is conveyed via a small uppercase
     label pill in the toast body itself
   - Slightly tighter geometry so it reads as a notification, not a modal
   - Animation slides + slightly fades, with a soft shadow that sits
     against the panel background. Close glyph is plain × in the
     existing close-button color, no decorative styling.
*/
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 300px;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toastIn 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.toast-out { animation: toastOut 0.18s ease forwards; }
.toast-kind {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.4;
  margin-top: 1px;
  white-space: nowrap;
}
.toast-body { flex: 1 1 auto; word-break: break-word; }
.toast-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 0 0 6px;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.toast-close:hover { opacity: 1; color: var(--text); }
.toast-success .toast-kind {
  background: var(--success-bg);
  color: var(--success);
}
.toast-error .toast-kind {
  background: var(--danger-bg);
  color: var(--danger);
}
.toast-info .toast-kind {
  background: var(--accent-bg-strong);
  color: var(--accent);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(6px) scale(0.985); }
}

/* ----- cancellation survey ----- */
.cancel-reasons {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  margin-bottom: var(--s4);
  max-height: 280px;
  overflow-y: auto;
}
.cancel-reason {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.cancel-reason:hover { border-color: var(--border-strong); }
.cancel-reason input[type="radio"] {
  margin: 0;
  accent-color: var(--accent);
}
.cancel-reason:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-bg);
}

/* ----- shortcut overlay ----- */
.shortcut-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s2) 0;
  font-size: 13px;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}
.shortcut-row:hover { color: var(--text); }

/* ----- settings page ----- */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
}
.setting-row:hover { background: var(--bg-panel-hover); }
.setting-section { border-bottom: none; padding: 20px 20px 10px; margin-top: 4px; border-top: 1px solid var(--border); background: var(--bg-elevated); }
.setting-section:first-child { border-top: none; margin-top: 0; border-radius: var(--r-md) var(--r-md) 0 0; }
.setting-section:hover { background: var(--bg-elevated); }
.setting-section .setting-info { border-left: 3px solid var(--section-accent, var(--accent)); padding-left: 12px; }
.setting-section-title { font-weight: 700; color: var(--section-accent, var(--accent)); font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; }
.setting-section-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }
.setting-section[data-section="leases"] { --section-accent: var(--accent); }
.setting-section[data-section="daemon"] { --section-accent: var(--text-secondary); }
.setting-section[data-section="context"] { --section-accent: var(--success); }
.setting-section[data-section="workspaces"] { --section-accent: var(--info); }
.setting-section[data-section="worktree"] { --section-accent: var(--warning); }
.setting-section[data-section="team"] { --section-accent: var(--accent); }
.setting-text { width: 200px; padding: 6px 10px; font-size: 13px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-sm); font-family: var(--font-mono); }
.setting-info { flex: 1; min-width: 0; margin-right: 16px; }
.setting-label { font-weight: 600; color: var(--text); font-size: 14px; }
.setting-desc { font-size: 12px; color: var(--text-secondary); margin-top: 4px; line-height: 1.5; }
.setting-number {
  width: 80px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: center;
}
.setting-number:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg-strong); }

/* Company Standards editor (team-settings.js) */
.ts-section {
  padding: var(--s3) var(--s5) 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.setting-select {
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 13px;
}
/* Per-row lock toggle. Locked = enforced standard. */
.ts-lock {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.55;
  transition: opacity 0.1s, border-color 0.1s;
}
.ts-lock:hover { opacity: 1; }
.ts-lock-on {
  opacity: 1;
  border-color: var(--accent);
  background: var(--accent-bg-strong);
}
/* A locked row gets a subtle accent rail so enforced standards stand out. */
.ts-row-locked { box-shadow: inset 3px 0 0 var(--accent); }

/* per-workspace scope header (per-BU settings arc) */
.ts-scope-label { color: var(--text-secondary); }
.ts-scope-pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}
.ts-scope-override { background: var(--accent-bg); color: var(--accent); }
.ts-scope-inherited { background: var(--bg-elevated); color: var(--text-tertiary); }

/* default/custom pill — at-a-glance "is this changed from default" */
.ts-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  font-size: 10px;
  line-height: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  vertical-align: middle;
}
.ts-pill-default {
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.ts-pill-custom {
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent);
}
/* `?` help affordance — pairs with the existing [data-tooltip] CSS */
.ts-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: help;
  vertical-align: middle;
  user-select: none;
}
.ts-help:hover, .ts-help:focus { color: var(--accent); border-color: var(--accent); outline: none; }

/* toggle switch (iOS style) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  transition: background 0.2s, border-color 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: white; }

/* ----- loading spinner ----- */
.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.loading-indicator {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text-tertiary);
  font-size: 12px;
  padding: var(--s5);
  justify-content: center;
}

/* responsive */
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .sidebar-brand-text, .nav-item span:not(.badge), .nav-section-label { display: none; }
  .sidebar-brand { justify-content: center; padding: var(--s4); }
  .nav-item { justify-content: center; padding: 10px; }
  .content { padding: var(--s4); }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-stats-grid { padding-left: 0; border-left: none; padding-top: var(--s4); border-top: 1px solid var(--border); }
}
  .auth-screen-v2 {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    background: var(--bg);
  }
  .auth-screen-v2::before,
  .auth-screen-v2::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
  }
  .auth-screen-v2::before {
    width: 520px; height: 520px;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.22), transparent 70%);
    top: -180px; left: -120px;
    animation: auth-drift-a 22s ease-in-out infinite alternate;
  }
  .auth-screen-v2::after {
    width: 420px; height: 420px;
    background: radial-gradient(circle, rgba(192, 132, 252, 0.18), transparent 70%);
    bottom: -160px; right: -100px;
    animation: auth-drift-b 28s ease-in-out infinite alternate;
  }
  @keyframes auth-drift-a {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(40px, 60px) scale(1.08); }
    100% { transform: translate(-30px, 80px) scale(1.03); }
  }
  @keyframes auth-drift-b {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-60px, -40px) scale(1.05); }
    100% { transform: translate(40px, -80px) scale(1.1); }
  }
  .auth-screen-v2 .grid-overlay {
    position: absolute; inset: 0; z-index: 0; pointer-events: none;
    background-image:
      linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  }
  .auth-layout {
    position: relative; z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    gap: 0;
  }
  @media (max-width: 900px) {
    .auth-layout { grid-template-columns: 1fr; }
    .auth-showcase { display: none; }
  }
  .auth-showcase {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px 56px;
    position: relative;
    border-right: 1px solid var(--border);
  }
  .auth-showcase-brand {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 40px;
  }
  .auth-showcase-brand img { border-radius: 8px; }
  .auth-showcase-brand span {
    font-size: 17px; font-weight: 700; letter-spacing: -0.01em; color: var(--text);
  }
  .auth-showcase h2 {
    font-size: 38px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
    margin: 0 0 16px;
    background: linear-gradient(135deg, var(--text) 30%, var(--accent) 120%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .auth-showcase p {
    font-size: 15px; color: var(--text-secondary); line-height: 1.65;
    margin: 0 0 32px; max-width: 420px;
  }
  .auth-proof {
    display: flex; flex-direction: column; gap: 16px;
    max-width: 420px;
  }
  .auth-proof-item {
    display: flex; align-items: flex-start; gap: 12px;
    font-size: 13.5px; color: var(--text-secondary); line-height: 1.5;
  }
  .auth-proof-check {
    flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
    background: rgba(52, 211, 153, 0.15);
    display: flex; align-items: center; justify-content: center;
    margin-top: 1px;
  }
  .auth-proof-item strong { color: var(--text); font-weight: 600; }
  .auth-form-pane {
    display: flex; align-items: center; justify-content: center;
    padding: 60px 40px;
  }
  .auth-form-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 44px 36px;
    max-width: 420px; width: 100%;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 20px 80px rgba(0,0,0,0.4);
  }
  .auth-form-card input[type="email"],
  .auth-form-card input[type="password"] {
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  }
  .auth-form-card input[type="email"]:focus,
  .auth-form-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-elevated-hover, var(--bg-elevated));
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
  }
  .auth-form-card button[id*="-btn"]:not([id*="show"]) {
    transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
  }
  .auth-form-card button[id*="-btn"]:not([id*="show"]):hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(96, 165, 250, 0.3);
  }
  .auth-form-card button[id*="-btn"]:not([id*="show"]):active:not(:disabled) {
    transform: translateY(0);
  }
  .auth-micro {
    position: absolute; bottom: 30px; left: 56px; right: 56px; z-index: 1;
    display: flex; gap: 20px; font-size: 11px; color: var(--text-tertiary);
  }
  @media (max-width: 900px) { .auth-micro { display: none; } }

/* ============================================================
   DEPLOY-MODE GATES (PR #5 / PR #7 unification)

   The dashboard ships from one codebase to three deploy targets:

     local-daemon         Embedded in the daemon binary, served at
                          localhost:7777. No auth, no billing, no
                          team-switcher; shows governance pages.

     cloud-pages          Deployed to Cloudflare Pages at
                          dashboard.agentcollision.com. Full auth,
                          billing, account, team-switcher; hides
                          governance pages (no daemon to back them).

     coordinator-hosted   Reserved — same gates as cloud-pages today.

   config.js detects mode and adds `.deploy-{mode}` to <html>. CSS
   below uses those scoping classes to hide sections that don't
   apply to the active mode.

   `display: none !important` is intentional: many of these elements
   set inline `style="display: none"` initially (e.g. setup-banner,
   auth-screen) and JS later flips it to `display: block` based on
   runtime state. Without `!important` the deploy-mode rule loses to
   the inline style and a cloud-only banner could flash up briefly
   in daemon mode before the JS catches up.
   ============================================================ */

/* Daemon-only sections: governance pages (Policy, Priority, Decisions,
   Spend, Worktrees), visual rule builder modal. Hidden in cloud-pages
   and coordinator-hosted. */
.deploy-cloud-pages .daemon-only,
.deploy-coordinator-hosted .daemon-only {
  display: none !important;
}

/* Cloud-only sections: auth screen, setup/decrypt/trial banners, team
   switcher, account page, analytics page, Documentation external link.
   Hidden in local-daemon mode (the daemon doesn't have a coordinator,
   billing system, or auth provider behind these). */
.deploy-local-daemon .cloud-only {
  display: none !important;
}

/* Nav-gated sections (migration 037 — per-page read scopes). Applied
   to .nav-item and section.page elements when the signed-in user
   lacks the data-scope. Hidden via display:none. The applyNavGating
   pass in src/nav-gating.js toggles this class on every fetchTeamInfo
   resolution. */
.nav-gated {
  display: none !important;
}

/* ===================== Home V2 page =====================
   Activity-stream home page (Phase 1 dashboard unification).
   Component CSS lives here rather than in a separate file to
   match the rest of the dashboard's flat /dashboard layout. When
   Phase 0 (dashboard split) lands, this block should move into
   /unified/styles/home_v2.css. */

#home-v2-tiles.tiles-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.analytics-tile {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s4);
}

.analytics-tile .tile-label {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: var(--s2);
}

.analytics-tile .tile-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
}

.analytics-tile .tile-sub {
  color: var(--text-tertiary);
  font-size: 11px;
  margin-top: var(--s2);
}

#home-v2-pills.pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.decision-pill {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.decision-pill:hover {
  background: var(--bg-panel-hover);
  border-color: var(--brand-500);
}

.decision-pill.active {
  background: var(--brand-600);
  border-color: var(--brand-500);
  color: white;
}

.decision-pill .pill-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

.decision-pill.active .pill-count {
  color: rgba(255, 255, 255, 0.85);
}

#home-v2-stream.stream-list {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  max-height: 60vh;
  overflow-y: auto;
}

.stream-empty {
  padding: var(--s5);
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

.stream-row {
  display: grid;
  grid-template-columns: 80px 220px 200px 1fr;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
}

.stream-row:last-child {
  border-bottom: none;
}

.stream-time {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.stream-type {
  font-weight: 500;
}

.stream-type-green { color: #4ade80; }
.stream-type-red { color: #f87171; }
.stream-type-amber { color: #fbbf24; }
.stream-type-gray { color: var(--text-secondary); }

.stream-agent {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-resource {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-status-dot {
  display: inline-block;
  font-size: 24px;
  line-height: 1;
}

.page-status-dot.status-live { color: #4ade80; }
.page-status-dot.status-connecting { color: #fbbf24; }
.page-status-dot.status-error { color: #f87171; }

/* ============================ SPEND HERO ============================ */
/* Restrained, matches the Overview page: two stacked "bands", each a
   row of compact stat cells (.hero-stats-grid / .hero-stat-cell reused
   from Overview). No equation, no neon left-border, no pill chips. The
   big "usage value" number is anchored against what the user pays (set
   via the plan modal) so it reads as a saving, not a bill. */
.spend-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.spend-band-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-display, var(--text));
  margin-bottom: 14px;
}
.spend-band-head::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.spend-band-usage .spend-band-head::before { background: var(--accent); }
.spend-band-protect .spend-band-head::before { background: var(--success); }
.spend-band-head .spend-band-win {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, var(--text-muted));
}
.spend-band-protect .hero-stat-cell .value { color: var(--success); }
/* Reuse Overview's stat grid but left-align (no left border/padding). */
.spend-stats {
  border-left: none;
  padding-left: 0;
  /* auto-fit so the band reads cleanly at 3 OR 4 metrics (Collisions /
     Conflicts / Edits / Coordinated autonomously) without per-count churn. */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  max-width: 960px;
}
.hero-stat-cell .value.spend-good { color: var(--success); }
.hero-stat-cell .value.spend-muted { color: var(--text-muted); font-weight: 700; }
.hero-stat-cell .value.spend-small { font-size: 16px; }
.spend-band-note {
  font-size: 12px;
  color: var(--text-muted);
}
/* "Set your plan" inline button — looks like a link, not a chip. */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent, var(--brand-600));
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
/* The "$X/mo · edit" chip under "You pay" — subtle, clickable. */
.spend-pay-chip {
  cursor: pointer;
  color: var(--accent, var(--brand-600));
}
.spend-pay-chip:hover { text-decoration: underline; }
.spend-nudge {
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 2px;
}
.spend-nudge .link-btn { font-size: 12px; }

/* ---- plan modal ---- */
.pm-rows { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 14px; }
.pm-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pm-provider {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 96px;
  font-weight: 600;
  color: var(--text);
}
.pm-row select,
.pm-row input,
.pm-total-input input {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.pm-trailer { display: inline-flex; align-items: center; gap: 6px; }
.pm-x { color: var(--text-muted); }
.pm-accts-label, .pm-token-note { font-size: 12px; color: var(--text-muted); }
.pm-switch {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent, var(--brand-600));
  text-decoration: none;
}
.pm-switch:hover { text-decoration: underline; }
.pm-empty { font-size: 13px; color: var(--text-muted); }
.pm-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.pm-total-input { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.pm-total-input input { width: 120px; font-size: 15px; }
.pm-ref { margin: 10px 0; font-size: 11px; color: var(--text-muted); }
.spend-assume {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}
/* protected-you recent example rows */
.spend-ex { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.spend-ex-head {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-tertiary, var(--text-muted));
  margin-bottom: 8px;
}
/* Separate the two hero bands with a divider so Usage and the
   protected-you section read as distinct blocks, not one grid. */
.spend-hero .spend-band + .spend-band {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.spend-ex .event-row:last-child { border-bottom: none; }
/* compact incident example rows (purpose-built, not the wide Events grid) */
.spend-ix-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.spend-ix-row:last-child { border-bottom: none; }
.spend-ix-dot {
  width: 7px; height: 7px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}
.spend-ix-danger { color: var(--danger); }
.spend-ix-warn { color: var(--warning); }
.spend-ix-muted { color: var(--text-muted); }
.spend-ix-dot.spend-ix-danger { background: var(--danger); }
.spend-ix-dot.spend-ix-warn { background: var(--warning); }
.spend-ix-dot.spend-ix-muted { background: var(--text-muted); }
.spend-ix-main { flex: 1; min-width: 0; }
.spend-ix-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.spend-ix-file {
  font-size: 13px; color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.spend-ix-kind {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em;
}
/* Incident reference id (event id locally / lease id on hosted) — muted
   monospace, pushed right, click to copy. */
.spend-ix-id {
  margin-left: auto; font-family: var(--font-mono); font-size: 10px;
  color: var(--text-tertiary); opacity: 0.6; cursor: pointer; white-space: nowrap;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}
.spend-ix-id:hover { opacity: 1; color: var(--accent); }
.spend-ix-why { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.spend-ix-time { font-size: 11px; color: var(--text-tertiary, var(--text-muted)); white-space: nowrap; }
/* Clickable collision row: subtle affordance + hover, expands a full writeup. */
.spend-ix-clickable { cursor: pointer; transition: background var(--transition-fast); }
.spend-ix-clickable:hover { background: var(--bg-soft, rgba(255,255,255,0.02)); }
.spend-ix-open { background: var(--bg-soft, rgba(255,255,255,0.03)); }
/* Expanded detail: labeled key/value lines + the deep-link, indented under the row. */
/* Live coordination — in-flight negotiations on the Protection band. */
.spend-neg-live {
  margin: 10px 0 4px; padding: 8px 10px; border-radius: 6px;
  background: var(--accent-bg, rgba(80,160,255,0.06));
  border: 1px solid var(--accent-soft, rgba(80,160,255,0.18));
}
.spend-neg-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent, #5aa0ff); font-weight: 700; margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.spend-neg-count { font-weight: 500; color: var(--text-tertiary, var(--text-muted)); text-transform: none; letter-spacing: 0; }
.spend-neg-row { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.spend-neg-dot {
  width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: 0 0 7px;
  background: var(--accent, #5aa0ff);
  box-shadow: 0 0 0 0 var(--accent, #5aa0ff); animation: spend-neg-pulse 2s infinite;
}
@keyframes spend-neg-pulse {
  0% { box-shadow: 0 0 0 0 rgba(90,160,255,0.5); }
  70% { box-shadow: 0 0 0 5px rgba(90,160,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(90,160,255,0); }
}
.spend-neg-main { flex: 1; min-width: 0; }
.spend-neg-top { display: flex; gap: 8px; align-items: center; }
.spend-neg-state { font-size: 11px; color: var(--text-muted); }
.spend-neg-who { font-size: 11px; color: var(--text-tertiary, var(--text-muted)); font-family: var(--font-mono); margin-top: 1px; }
.spend-ix-expand {
  margin-top: 8px; padding: 8px 10px; border-left: 2px solid var(--border);
  background: var(--bg-surface, rgba(255,255,255,0.015)); border-radius: 4px;
  display: flex; flex-direction: column; gap: 4px;
}
.spend-ix-kv { display: flex; gap: 8px; font-size: 11px; line-height: 1.4; }
.spend-ix-k {
  flex: 0 0 92px; color: var(--text-tertiary, var(--text-muted));
  text-transform: uppercase; font-size: 9px; letter-spacing: 0.04em; padding-top: 1px;
}
.spend-ix-v { color: var(--text-muted); font-family: var(--font-mono); word-break: break-word; }
.spend-ix-eventlink {
  margin-top: 4px; font-size: 11px; color: var(--accent);
  text-decoration: none; align-self: flex-start;
}
.spend-ix-eventlink:hover { text-decoration: underline; }
/* Hover cue on a stat label that carries a tooltip. */
.stat-label-tip { cursor: help; border-bottom: 1px dotted var(--border); display: inline-block; }
/* Detail chips under a collision: tool, hold duration, priority, verified
   human. Restrained — small, muted, no neon (matches the Overview look). */
.spend-ix-detail {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.spend-ix-chip {
  font-size: 10px; line-height: 1.4; padding: 1px 7px; border-radius: 999px;
  background: var(--bg-soft); color: var(--text-tertiary, var(--text-muted));
  border: 1px solid var(--border); white-space: nowrap;
}
.spend-ix-chip-pri {
  font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--text-secondary);
}
.spend-ix-chip-actor {
  font-family: var(--font-mono); max-width: 220px; overflow: hidden;
  text-overflow: ellipsis;
}
/* ---- per-chat / per-model spend table (clean, app-consistent) ---- */
.spend-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spend-table thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary, var(--text-muted));
  border-bottom: 1px solid var(--border);
}
.spend-table th.num, .spend-table td.num { text-align: right; }
.spend-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.spend-table tbody tr:last-child td { border-bottom: none; }
.spend-table tbody tr:hover { background: var(--bg-elevated, rgba(255,255,255,0.02)); }
.spend-dim { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.spend-cost { font-weight: 700; font-variant-numeric: tabular-nums; }
.spend-table-empty { padding: 24px; text-align: center; color: var(--text-muted); }

.spend-chat-top { display: flex; align-items: center; gap: 8px; }
.spend-tool-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 6px; border-radius: 4px;
  background: var(--accent-bg); color: var(--accent);
}
.spend-chat-id { font-size: 12px; color: var(--text); }
.spend-chat-id-copy { cursor: pointer; transition: color var(--transition-fast); }
.spend-chat-id-copy:hover { color: var(--accent); }
.spend-chat-repo { font-size: 11px; color: var(--text-tertiary, var(--text-muted)); margin-top: 3px; }
.spend-model-chip {
  display: inline-block; font-size: 11px; padding: 2px 7px;
  border-radius: 4px; background: var(--bg-soft); color: var(--text-secondary);
  margin: 1px 4px 1px 0; font-family: var(--font-mono);
}
.spend-ix-agent {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-secondary); background: var(--bg-soft);
  padding: 1px 6px; border-radius: 4px; margin-left: 4px;
}
.spend-ex-foot { margin-top: 10px; font-size: 11px; color: var(--text-muted); }
.spend-ex-link { color: var(--accent, var(--brand-600)); text-decoration: none; }
.spend-ex-link:hover { text-decoration: underline; }
