/* Agent Dashboard — UI Revamp */
:root {
  /* Surfaces */
  --bg-base: #0B0E14;
  --bg-surface: #141821;
  --bg-elevated: #1C2130;
  --bg-overlay: rgba(0, 0, 0, 0.6);

  /* Borders */
  --border-default: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --border-active: rgba(99, 102, 241, 0.4);
  --border-subtle: rgba(255, 255, 255, 0.03);

  /* Text */
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-muted: #9CA3AF;
  --text-tertiary: #6B7280;
  --text-disabled: #4B5563;

  /* Accent */
  --accent-green: #10B981;
  --accent-blue: #3B82F6;
  --accent-amber: #F59E0B;
  --accent-red: #EF4444;
  --accent-indigo: #818CF8;

  /* Status backgrounds */
  --status-running-bg: rgba(16, 185, 129, 0.08);
  --status-running-border: rgba(16, 185, 129, 0.2);
  --status-running-text: #6EE7B7;
  --status-queued-bg: rgba(59, 130, 246, 0.08);
  --status-queued-border: rgba(59, 130, 246, 0.2);
  --status-queued-text: #93C5FD;
  --status-warning-bg: rgba(245, 158, 11, 0.08);
  --status-warning-border: rgba(245, 158, 11, 0.2);
  --status-warning-text: #FCD34D;
  --status-failed-bg: rgba(239, 68, 68, 0.08);
  --status-failed-border: rgba(239, 68, 68, 0.2);
  --status-failed-text: #FCA5A5;
  --status-completed-bg: rgba(107, 114, 128, 0.08);
  --status-completed-border: rgba(107, 114, 128, 0.2);
  --status-completed-text: #9CA3AF;
  --status-paused-bg: rgba(245, 158, 11, 0.08);
  --status-paused-border: rgba(245, 158, 11, 0.2);
  --status-paused-text: #FCD34D;

  /* Code */
  --code-text: #A5B4FC;
  --code-bg: rgba(165, 180, 252, 0.08);

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;

  /* Transitions */
  --transition-fast: 100ms ease;
  --transition-default: 150ms ease;
  --transition-slow: 250ms ease;

  /* Interactive surfaces (extracted from hardcoded rgba) */
  --interactive-bg: rgba(255, 255, 255, 0.04);
  --interactive-border: rgba(255, 255, 255, 0.08);
  --interactive-bg-hover: rgba(255, 255, 255, 0.08);
  --interactive-border-hover: rgba(255, 255, 255, 0.12);
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);
  --row-alt-bg: rgba(255, 255, 255, 0.015);
  --row-hover-bg: rgba(255, 255, 255, 0.02);
  --progress-pending: rgba(255, 255, 255, 0.06);
  --shadow-medium: rgba(0, 0, 0, 0.4);
  --badge-pr-text: #C4B5FD;
  --badge-merged-text: #5EEAD4;
  --card-hover-gradient: rgba(28, 33, 48, 0.3);

  /* Navbar (always dark, no light-theme overrides) */
  --color-navbar-bg: #2A2724;
  --color-text-on-dark: #F7F5F2;
  --color-navbar-muted: #9C8F7E;
  --color-navbar-divider: #3D3730;
  --color-navbar-hover: rgba(255, 255, 255, 0.06);
  --color-navbar-border: rgba(255, 255, 255, 0.06);
  --color-accent-hover: #4338CA;
  --color-accent-light: #EEF2FF;
}

/* ============================================
   THEME: Light mode
   ============================================ */
[data-theme="light"] {
  --bg-base: #F7F5F2;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F0EDE8;
  --bg-overlay: rgba(0, 0, 0, 0.3);
  --bg-navbar: #2A2724;

  --border-default: #E8E3DC;
  --border-hover: #D9D2C9;
  --border-active: #C7D2FE;
  --border-subtle: #F0EDE8;

  --text-primary: #1C1A17;
  --text-secondary: #4A4540;
  --text-muted: #9C8F7E;
  --text-tertiary: #9C8F7E;
  --text-disabled: #C8BFB2;

  --accent-green: #0D9488;
  --accent-blue: #4F46E5;
  --accent-amber: #DC6B19;
  --accent-red: #DC2626;
  --accent-indigo: #4F46E5;

  --status-running-bg: rgba(13, 148, 136, 0.08);
  --status-running-border: rgba(13, 148, 136, 0.2);
  --status-running-text: #0D9488;
  --status-queued-bg: #EEF2FF;
  --status-queued-border: #C7D2FE;
  --status-queued-text: #4F46E5;
  --status-warning-bg: #FFF7ED;
  --status-warning-border: rgba(220, 107, 25, 0.2);
  --status-warning-text: #DC6B19;
  --status-failed-bg: rgba(220, 38, 38, 0.08);
  --status-failed-border: rgba(220, 38, 38, 0.2);
  --status-failed-text: #B91C1C;
  --status-completed-bg: rgba(156, 143, 126, 0.08);
  --status-completed-border: rgba(156, 143, 126, 0.2);
  --status-completed-text: #4A4540;
  --status-paused-bg: #FFF7ED;
  --status-paused-border: rgba(220, 107, 25, 0.2);
  --status-paused-text: #DC6B19;

  --code-text: #4F46E5;
  --code-bg: rgba(79, 70, 229, 0.06);

  --interactive-bg: rgba(0, 0, 0, 0.03);
  --interactive-border: #E8E3DC;
  --interactive-bg-hover: rgba(0, 0, 0, 0.06);
  --interactive-border-hover: #D9D2C9;
  --scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);
  --row-alt-bg: rgba(0, 0, 0, 0.015);
  --row-hover-bg: rgba(0, 0, 0, 0.02);
  --progress-pending: rgba(0, 0, 0, 0.06);
  --shadow-medium: rgba(0, 0, 0, 0.1);
  --badge-pr-text: #4F46E5;
  --badge-merged-text: #0D9488;
  --card-hover-gradient: rgba(240, 237, 232, 0.5);
}

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

body {
  font-family: var(--font-primary);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

/* Focus ring */
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-base), 0 0 0 4px rgba(99, 102, 241, 0.5);
}

/* ============================================
   COMPONENT: Buttons
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-sm); font-size: 13px;
  font-weight: 500; font-family: var(--font-primary); cursor: pointer;
  border: 1px solid transparent; transition: background var(--transition-default), border-color var(--transition-default), color var(--transition-default);
  line-height: 20px; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.98); transition: transform var(--transition-fast); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-primary {
  flex: 1;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--interactive-bg);
  border: 1px solid var(--interactive-border);
  color: var(--text-secondary);
}
.btn-primary:hover:not(:disabled) { background: var(--interactive-bg-hover); border-color: var(--interactive-border-hover); }

.btn-secondary {
  background: var(--interactive-bg);
  border: 1px solid var(--interactive-border);
  color: var(--text-secondary);
  border-radius: var(--radius-lg);
  height: 40px;
}
.btn-secondary:hover:not(:disabled) { background: var(--interactive-bg-hover); border-color: var(--interactive-border-hover); }

.btn-ghost {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 400;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-elevated); color: var(--text-secondary); }

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  border-radius: var(--radius-lg);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.18); }

/* Stop button — icon-only square */
.btn-stop {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-default);
  padding: 0;
}
.btn-stop:hover { background: rgba(239, 68, 68, 0.18); }
.btn-stop__icon {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent-red);
}

/* Header control buttons — see .header-* block below */

/* ============================================
   COMPONENT: Status Badge
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 14px;
}

.badge-running { background: var(--status-running-bg); border: 1px solid var(--status-running-border); color: var(--status-running-text); }
.badge-queued { background: var(--status-queued-bg); border: 1px solid var(--status-queued-border); color: var(--status-queued-text); }
.badge-completed { background: var(--status-completed-bg); border: 1px solid var(--status-completed-border); color: var(--status-completed-text); }
.badge-failed { background: var(--status-failed-bg); border: 1px solid var(--status-failed-border); color: var(--status-failed-text); }
.badge-paused { background: var(--status-paused-bg); border: 1px solid var(--status-paused-border); color: var(--status-paused-text); }
/* Aliases for backward compat state names */
.badge-blocked { background: var(--status-failed-bg); border: 1px solid var(--status-failed-border); color: var(--status-failed-text); }
.badge-waiting { background: var(--status-warning-bg); border: 1px solid var(--status-warning-border); color: var(--status-warning-text); }
.badge-review { background: var(--status-running-bg); border: 1px solid var(--status-running-border); color: var(--status-running-text); }
.badge-pr { background: rgba(129, 140, 248, 0.08); border: 1px solid rgba(129, 140, 248, 0.2); color: var(--badge-pr-text); }
.badge-merged { background: rgba(45, 212, 191, 0.08); border: 1px solid rgba(45, 212, 191, 0.2); color: var(--badge-merged-text); }

/* ============================================
   COMPONENT: Status Dot
   ============================================ */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.status-dot--running {
  background: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: pulse-dot 2.5s ease-in-out infinite;
}
.status-dot--queued, .status-dot--blocked { background: var(--accent-blue); }
.status-dot--waiting { background: var(--accent-amber); }
.status-dot--idle, .status-dot--completed, .status-dot--merged { background: #6B7280; }
.status-dot--failed { background: var(--accent-red); }
.status-dot--paused { background: var(--accent-amber); }
.status-dot--review { background: var(--accent-green); }
.status-dot--pr { background: var(--accent-indigo); }

/* Legacy group-name dots */
.state-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; }
.state-dot-BLOCKED { background: var(--accent-red); }
.state-dot-WAITING { background: var(--accent-amber); }
.state-dot-RUNNING { background: var(--accent-green); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); animation: pulse-dot 2.5s ease-in-out infinite; }
.state-dot-REVIEW { background: var(--accent-green); }
.state-dot-PR { background: var(--accent-indigo); }
.state-dot-MERGED { background: #6B7280; }

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
  50% { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.08); }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot--running, .state-dot-RUNNING {
    animation: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  }
}

/* ============================================
   COMPONENT: Cards
   ============================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  transition: border-color 150ms ease, background-color 150ms ease;
  min-height: 88px;
}
.card[onclick], .card.clickable { cursor: pointer; }
.card[onclick]:hover, .card.clickable:hover {
  border-color: var(--border-hover);
  background: linear-gradient(var(--bg-surface), var(--card-hover-gradient));
}
.card--active {
  border-color: var(--border-active);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15);
}

/* ============================================
   COMPONENT: Header (Top bar)
   ============================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 48px;
  background: var(--bg-navbar, var(--bg-base));
  border-bottom: 0.5px solid var(--color-navbar-border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 0;
}

.header-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent-indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 10px;
  border: none;
  cursor: pointer;
  padding: 0;
}

.header-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-on-dark);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-text-btn {
  font-size: 13px;
  font-weight: 400;
  color: var(--color-navbar-muted);
  padding: 5px 10px;
  border-radius: 7px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition-default);
}
.header-text-btn:hover { background: var(--color-navbar-hover); }

.header-divider {
  width: 0.5px;
  height: 18px;
  background: var(--color-navbar-divider);
  margin: 0 6px;
  flex-shrink: 0;
}

.header-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-navbar-muted);
  margin: 0 4px;
  transition: background var(--transition-default);
}
.header-icon-btn:hover { background: var(--color-navbar-hover); }

.header-cta {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-accent-light);
  background: var(--accent-indigo);
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.header-cta:hover { background: var(--color-accent-hover); }
.header-cta:active { transform: scale(0.98); }

/* ============================================
   COMPONENT: Tabs
   ============================================ */
.tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border-default);
  background: transparent;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 12px 16px;
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-default), border-color var(--transition-default);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  font-weight: 500;
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}

.tab-content {
  display: none;
  padding: var(--space-3);
}

.tab-content.active {
  display: block;
}

/* ============================================
   COMPONENT: Empty state
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  max-width: 320px;
  margin: 0 auto;
}

.empty-state-icon { display: block; margin: 0 auto 12px; width: 48px; height: 48px; color: var(--text-tertiary); }
.empty-state-title { font-size: 15px; font-weight: 500; color: var(--text-muted); margin-bottom: 4px; }
.empty-state-subtitle { font-size: 13px; color: var(--text-tertiary); }

/* ============================================
   COMPONENT: Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  border: 1px solid var(--border-default);
}

.toast.visible { opacity: 1; }
.toast.success { background: var(--status-running-bg); color: var(--status-running-text); border-color: var(--status-running-border); }
.toast.error { background: var(--status-failed-bg); color: var(--status-failed-text); border-color: var(--status-failed-border); }

/* ============================================
   COMPONENT: Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal {
  background: var(--bg-elevated);
  padding: 24px;
  border-radius: var(--radius-xl);
  max-width: 340px;
  width: 90%;
  text-align: center;
  border: 1px solid var(--border-default);
  box-shadow: 0 4px 12px var(--shadow-medium);
}

.modal h3 { margin-bottom: 12px; font-size: 16px; font-weight: 500; }
.modal p { color: var(--text-secondary); margin-bottom: 20px; font-size: 14px; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ============================================
   COMPONENT: Skeleton loading
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line { height: 14px; margin-bottom: 8px; border-radius: var(--radius-sm); }
.skeleton-block { height: 48px; margin-bottom: 8px; border-radius: var(--radius-lg); }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--bg-elevated);
  }
}

/* ============================================
   COMPONENT: Spinner
   ============================================ */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.spinner-inline {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-left: 4px;
}

.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

/* header-home removed — logo is now .header-logo */

/* ============================================
   COMPONENT: Inline code
   ============================================ */
.code-inline {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--code-text);
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  word-break: break-all;
}

/* ============================================
   VIEW: Agent List
   ============================================ */
.agent-list {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
}

.state-group {
  margin-bottom: var(--space-6);
}

.state-group-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  padding: 0 0 var(--space-3);
}

.agent-card {
  margin-bottom: var(--space-2);
}

.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.agent-name {
  font-weight: 500;
  font-size: 15px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
  letter-spacing: -0.005em;
}

.agent-branch {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-meta {
  display: flex;
  gap: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  flex-wrap: wrap;
  line-height: 18px;
  margin-top: var(--space-1);
}

.agent-meta span {
  white-space: nowrap;
}

.agent-meta span:not(:last-child)::after {
  content: ' \00B7 ';
  color: var(--text-tertiary);
  margin: 0 4px;
}

.agent-bottom-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.agent-cost {
  color: var(--accent-green);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  margin-left: auto;
}
.agent-cost:empty { display: none; }

.agent-cost-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: var(--font-primary);
  font-weight: 400;
  margin-right: var(--space-1);
}

.agent-current-tool {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--font-mono);
}

.agent-preview {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 20px;
}

/* ============================================
   VIEW: Detail
   ============================================ */
.detail-header {
  background: transparent;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-default);
}

.detail-back {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
  font-family: var(--font-primary);
  font-weight: 400;
  transition: color var(--transition-default);
}
.detail-back:hover { color: var(--text-secondary); }

.detail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.detail-title h2 {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}

.detail-meta {
  display: flex;
  gap: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  flex-wrap: wrap;
  line-height: 18px;
}

.detail-meta span:not(:last-child)::after {
  content: ' \00B7 ';
  margin: 0 4px;
}

body.view-detail { overflow: hidden; }

.detail-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.detail-pinned {
  flex-shrink: 0;
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.detail-content {
  max-width: 960px;
  margin: 0 auto;
}

/* ============================================
   COMPONENT: Vital Signs Strip
   ============================================ */
.vital-signs {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  margin: var(--space-3) var(--space-6);
}

.vital-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vital-label {
  font-family: var(--font-primary);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  line-height: 16px;
}

.vital-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 20px;
}

.vital-value--cost { color: var(--accent-green); }
.vital-value--phase { font-family: var(--font-primary); }
.vital-value--phase .vital-phase-name { color: var(--text-muted); }

.vital-divider {
  width: 1px;
  height: 24px;
  background: var(--border-default);
  flex-shrink: 0;
}

.progress-segments {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.progress-segment {
  width: 20px;
  height: 4px;
  border-radius: 2px;
}

.progress-segment--complete { background: var(--accent-green); }
.progress-segment--current { background: rgba(16, 185, 129, 0.4); }
.progress-segment--pending { background: var(--progress-pending); }

/* ============================================
   COMPONENT: Subagent Pills Section
   ============================================ */
.subagent-summary-list {
  display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) 0;
}

.subagent-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color var(--transition-default), background var(--transition-default);
  max-width: 320px;
  font-size: 12px;
}

.subagent-pill:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

.subagent-pill--muted { border-style: dashed; opacity: 0.6; }
.subagent-type { font-weight: 500; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; }
.subagent-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-tertiary); font-weight: 400; }
.subagent-mode { color: var(--accent-blue); white-space: nowrap; font-family: var(--font-mono); font-size: 11px; flex-shrink: 0; }
.subagent-time { color: var(--text-tertiary); white-space: nowrap; margin-left: auto; flex-shrink: 0; font-weight: 400; }

/* ============================================
   VIEW: Conversation (Chat)
   ============================================ */
.conversation {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

.msg-role-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 12px 0 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-role-label__icon {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 22px;
  word-wrap: break-word;
}

.msg-human {
  max-width: 75%;
  margin-left: auto;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--text-secondary);
  border-radius: 14px 14px 4px 14px;
  align-self: flex-end;
}

.msg-assistant {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 16px 16px 16px 4px;
  color: var(--text-secondary);
  align-self: flex-start;
}

.msg-time {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.msg-human .msg-time { color: var(--text-tertiary); }
.msg-optimistic { opacity: 0.7; }

.msg-assistant .markdown-body { color: var(--text-secondary); }
.msg-assistant .markdown-body code { background: var(--code-bg); color: var(--code-text); }

/* ============================================
   VIEW: Activity Timeline
   ============================================ */
.activity-log {
  font-family: var(--font-primary);
  font-size: 13px;
  line-height: 20px;
}

.timeline-entry {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 14px var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-default);
}

.timeline-entry:hover {
  background: var(--row-alt-bg);
}

.timeline-entry.hidden { display: none; }

.timeline-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.timeline-icon--human { background: rgba(59, 130, 246, 0.12); color: #60A5FA; }
.timeline-icon--assistant { background: rgba(129, 140, 248, 0.12); color: #818CF8; }
.timeline-icon--tool { background: rgba(107, 114, 128, 0.1); color: #9CA3AF; }

.timeline-icon svg { width: 14px; height: 14px; }

.timeline-content {
  flex: 1;
  min-width: 0;
}

.timeline-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.timeline-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.timeline-timestamp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
  flex-shrink: 0;
  min-width: 56px;
  text-align: right;
}

.timeline-detail {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 20px;
}

/* Tool call groups */
.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-2) 0 0;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 12px;
}

.tool-group:hover { color: var(--text-muted); }

.tool-group__chevron {
  width: 12px;
  height: 12px;
  transition: transform var(--transition-default);
  display: inline-block;
  font-size: 10px;
}

.tool-group--expanded .tool-group__chevron {
  transform: rotate(90deg);
}

.tool-call {
  padding: 8px 0 8px 16px;
  border-left: 1px solid var(--border-default);
  margin-left: 6px;
  margin-top: 4px;
}

.tool-call__name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--code-text);
}

.tool-call__status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* Legacy activity entry styles (fallback) */
.activity-time { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 11px; }
.activity-kind { font-weight: 500; color: var(--text-secondary); }
.tool-name { color: var(--code-text); font-family: var(--font-mono); }

/* Activity filter pills */
.activity-filter-bar {
  display: flex;
  gap: 6px;
  padding: var(--space-2) var(--space-5);
}

.activity-filter-btn {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--transition-default);
  font-family: var(--font-primary);
  text-transform: capitalize;
}

.activity-filter-btn:hover:not(.active) {
  border-color: var(--border-hover);
  color: var(--text-secondary);
}

.activity-filter-btn.active {
  background: var(--bg-elevated);
  border-color: var(--border-hover);
  color: var(--text-primary);
  font-weight: 500;
}

/* Tool group within timeline */
.activity-tool-group.hidden { display: none; }
.tool-group-summary {
  font-size: 12px; font-weight: 500; color: var(--text-tertiary);
  cursor: pointer; padding: 4px 0; display: flex; align-items: center; gap: 6px;
  list-style: none; font-family: var(--font-primary);
}
.tool-group-summary::-webkit-details-marker { display: none; }
.tool-group-summary::before { content: '\25B6'; font-size: 8px; transition: transform var(--transition-default); display: inline-block; }
details[open] > .tool-group-summary::before { transform: rotate(90deg); }
.tool-group-summary:hover { color: var(--text-muted); }

/* ============================================
   VIEW: Diff
   ============================================ */
.diff-view {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 250px);
}

.diff-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.diff-controls { display: flex; align-items: center; gap: 12px; }
.diff-view-toggle { display: inline-flex; gap: 0; border-radius: var(--radius-sm); overflow: hidden; }
.diff-toggle-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-family: var(--font-primary);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: background var(--transition-default), color var(--transition-default);
  line-height: 1.4;
  white-space: nowrap;
}
.diff-toggle-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.diff-toggle-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.diff-toggle-btn.active { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); font-weight: 500; }
.diff-toggle-btn:hover:not(.active) { background: var(--interactive-bg); }

.diff-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.diff-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  flex-shrink: 0;
}

.diff-sidebar-header {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 1;
}

.diff-dir-group { border-bottom: 1px solid var(--border-subtle); }
.diff-dir-group:last-child { border-bottom: none; }
.diff-dir-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.diff-dir-summary::-webkit-details-marker { display: none; }
.diff-dir-summary::before {
  content: '\25B6';
  font-size: 8px;
  transition: transform var(--transition-default);
  color: var(--text-tertiary);
}
.diff-dir-group[open] > .diff-dir-summary::before { transform: rotate(90deg); }
.diff-dir-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-dir-summary .diff-stats { font-weight: 400; }

.diff-sidebar-file {
  padding: 5px 12px 5px 24px;
  font-size: 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-default);
}

.diff-sidebar-file:hover { background: var(--bg-elevated); }

.diff-sidebar-file.active {
  background: var(--bg-elevated);
  border-left-color: var(--accent-indigo);
}

.diff-sidebar-name { color: var(--text-primary); }
.diff-sidebar-dir { color: var(--text-tertiary); }

.diff-stats { margin-left: auto; font-size: 10px; white-space: nowrap; flex-shrink: 0; }
.diff-stats-add { color: var(--accent-green); }
.diff-stats-del { color: var(--accent-red); }

.diff-content {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

/* Diff2html dark overrides */
.diff-content .d2h-wrapper { border: none; }
.diff-content .d2h-file-header {
  background: var(--bg-elevated); border-color: var(--border-default); color: var(--text-primary);
  position: sticky; top: 0; z-index: 10;
}
.diff-content .d2h-file-name-wrapper { color: var(--text-primary); }
.diff-content .d2h-file-name { color: var(--text-primary); }
.diff-content .d2h-diff-table { font-family: var(--font-mono); font-size: 12px; border-collapse: collapse; width: 100%; table-layout: auto; }

/* Horizontal scroll for long lines */
.diff-content .d2h-code-line-ctn { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.diff-content .d2h-code-line-ctn::-webkit-scrollbar { height: 6px; }
.diff-content .d2h-code-line-ctn::-webkit-scrollbar-track { background: var(--bg-base); border-radius: 3px; }
.diff-content .d2h-code-line-ctn::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
.diff-content .d2h-code-line-ctn::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* Wrap toggle */
.diff-content.diff-wrap .d2h-code-line-ctn { white-space: pre-wrap; word-break: break-all; overflow-x: visible; }
.diff-content .d2h-code-linenumber { background: var(--bg-surface); border-color: var(--border-default); color: var(--text-tertiary); cursor: default; text-align: right; vertical-align: top; position: static !important; }
.diff-content .d2h-code-line { background: var(--bg-base); color: var(--text-primary); }
.diff-content .d2h-code-line-ctn { color: var(--text-primary); }

/* Added lines */
.diff-content .d2h-ins { background: rgba(16, 185, 129, 0.06); border-color: transparent; }
.diff-content .d2h-ins .d2h-code-line { background: rgba(16, 185, 129, 0.06); }
.diff-content .d2h-ins .d2h-code-linenumber { background: rgba(16, 185, 129, 0.12); color: var(--accent-green); border-color: var(--border-default); }
.diff-content .d2h-ins .d2h-code-line-ctn { color: var(--text-primary); }
.diff-content ins { background: rgba(16, 185, 129, 0.25); text-decoration: none; }

/* Deleted lines */
.diff-content .d2h-del { background: rgba(239, 68, 68, 0.06); border-color: transparent; }
.diff-content .d2h-del .d2h-code-line { background: rgba(239, 68, 68, 0.06); }
.diff-content .d2h-del .d2h-code-linenumber { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); border-color: var(--border-default); }
.diff-content .d2h-del .d2h-code-line-ctn { color: var(--text-primary); }
.diff-content del { background: rgba(239, 68, 68, 0.25); text-decoration: none; }

/* Empty placeholders and borders */
.diff-content .d2h-emptyplaceholder { background: var(--bg-surface); border-color: var(--border-default); }
.diff-content .d2h-file-diff { border-color: var(--border-default); }
.diff-content .d2h-file-side-diff { border-color: var(--border-default); }
.diff-content .d2h-files-diff { border: none; }
.diff-content .d2h-code-linenumber.d2h-move-handler { cursor: default; }
.diff-content .hljs { background: transparent !important; color: var(--text-primary); }

/* Side-by-side layout */
.diff-content .d2h-file-side-diff { width: 50%; display: inline-block; vertical-align: top; }
.diff-content .d2h-code-side-linenumber { background: var(--bg-surface); border-color: var(--border-default); color: var(--text-tertiary); cursor: default; text-align: right; vertical-align: top; position: static !important; }
.diff-content .d2h-code-side-line { background: var(--bg-base); color: var(--text-primary); }
.diff-content .d2h-code-side-line .d2h-code-line-ctn { color: var(--text-primary); }

/* Side-by-side added lines */
.diff-content .d2h-ins .d2h-code-side-line { background: rgba(16, 185, 129, 0.08); }
.diff-content .d2h-ins .d2h-code-side-linenumber { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }

/* Side-by-side deleted lines */
.diff-content .d2h-del .d2h-code-side-line { background: rgba(239, 68, 68, 0.08); }
.diff-content .d2h-del .d2h-code-side-linenumber { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }

/* Inline word-level highlights */
.diff-content .d2h-ins .d2h-code-side-line ins,
.diff-content .d2h-ins .d2h-code-line-ctn ins { background: rgba(16, 185, 129, 0.30); text-decoration: none; border-radius: 2px; }
.diff-content .d2h-del .d2h-code-side-line del,
.diff-content .d2h-del .d2h-code-line-ctn del { background: rgba(239, 68, 68, 0.30); text-decoration: none; border-radius: 2px; }

/* Hide hunk headers */
.diff-content .d2h-info { display: none; }
.diff-content .d2h-code-side-emptyplaceholder { background: var(--bg-surface); }

/* Hide diff2html UI artifacts */
.diff-content .d2h-file-header label,
.diff-content .d2h-file-header .d2h-file-stats,
.diff-content .d2h-tag { display: none; }

/* File sections */
.diff-file-section { border-bottom: 1px solid var(--border-default); }
.diff-file-section:last-child { border-bottom: none; }
.diff-file-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-default);
}
.diff-file-header:hover { background: var(--interactive-bg); }
.diff-file-path {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.diff-file-chevron {
  font-size: 10px;
  color: var(--text-tertiary);
  transition: transform var(--transition-default);
  display: inline-block;
  flex-shrink: 0;
}
.diff-file-chevron.expanded { transform: rotate(90deg); }
.diff-file-body .d2h-file-header { display: none; }
.diff-file-body .d2h-wrapper { border: none; }
.diff-file-body .d2h-files-diff { border: none; }

/* ============================================
   VIEW: Plan
   ============================================ */
.plan-content {
  font-size: 14px;
  line-height: 22px;
  color: var(--text-secondary);
}

.plan-content h1 {
  font-size: 17px; font-weight: 500; color: var(--text-primary);
  margin: 0 0 16px; line-height: 26px;
}
.plan-content h2 {
  font-size: 15px; font-weight: 500; color: var(--text-primary);
  margin: 24px 0 8px; line-height: 22px;
}
.plan-content h3 {
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  margin: 16px 0 6px; line-height: 22px;
}
.plan-content p { margin: 0 0 12px; }
.plan-content ul, .plan-content ol { padding-left: 20px; margin: 0 0 12px; }
.plan-content li { margin-bottom: 4px; }

.plan-content code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.plan-content pre {
  background: var(--bg-surface);
  padding: 12px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 8px 0;
}

.plan-content pre code { background: none; padding: 0; }

/* ============================================
   VIEW: Usage
   ============================================ */
.usage-view { padding: 12px; max-width: 960px; margin: 0 auto; overflow-x: hidden; }

/* Metrics strip */
.usage-metrics {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  margin: 0 0 24px;
}
.usage-metric {
  flex: 1;
  padding: 0 24px;
  border-right: 1px solid var(--border-default);
}
.usage-metric:first-child { padding-left: 0; }
.usage-metric:last-child { padding-right: 0; border-right: none; }
.usage-metric__label {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.usage-metric__value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 32px;
}
.usage-metric__delta {
  font-family: var(--font-primary);
  font-size: 11px;
  font-weight: 400;
  margin-top: 4px;
  line-height: 16px;
}
.usage-metric__delta--up { color: var(--text-tertiary); }
.usage-metric__delta--down { color: var(--accent-green); }
.usage-metric__delta--neutral { color: var(--text-tertiary); }

/* Rate-limit card */
.rate-limit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.rate-limit-card .card-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rate-limit-plan {
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: capitalize;
}
.rate-limit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.rate-limit-label {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 120px;
  flex-shrink: 0;
}
.rate-limit-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  min-width: 100px;
}
.rate-limit-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.rate-limit-pct {
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}
.rate-limit-reset {
  font-size: 12px;
  color: var(--text-tertiary);
  min-width: 100px;
}
.rate-limit-extra {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Chart card */
.usage-chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  margin-bottom: 24px;
}
.usage-chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.usage-chart__title {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Chart grid + axes */
.usage-chart-container { position: relative; padding-left: 50px; }
.usage-y-axis {
  position: absolute; left: 0; top: 0; bottom: 24px; width: 45px;
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; padding-right: 8px;
}
.usage-y-label { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }
.usage-grid-line {
  position: absolute; left: 50px; right: 0;
  border-top: 1px solid var(--border-subtle);
  pointer-events: none;
}

/* Chart bars */
.usage-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  padding: 0 0 24px;
  position: relative;
}
.usage-chart:hover .usage-bar:not(:hover) { opacity: 0.4; }

.usage-bar {
  flex: 1;
  background: rgba(16, 185, 129, 0.7);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  position: relative;
  cursor: pointer;
  transition: opacity var(--transition-default);
}
.usage-bar:hover { background: rgba(16, 185, 129, 1.0); }

.usage-bar--today {
  background: var(--accent-green);
  filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.2));
}

.usage-bar-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  font-family: var(--font-mono);
}
.usage-bar-today-label {
  position: absolute;
  bottom: -34px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-green);
  white-space: nowrap;
}

/* Chart tooltip (shown on hover) */
.chart-tooltip {
  position: absolute;
  top: -38px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  box-shadow: 0 4px 12px var(--shadow-medium);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.chart-tooltip::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-hover);
  border-bottom: 1px solid var(--border-hover);
}
.usage-bar:hover .chart-tooltip { opacity: 1; }

/* Date range selector */
.date-range-selector {
  display: flex;
  gap: 2px;
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
}
.date-range-option {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-default);
  border: none;
  background: transparent;
}
.date-range-option:hover { color: var(--text-secondary); }
.date-range-option--active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 500;
}

/* Table card container */
.usage-table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.usage-table__title {
  font-family: var(--font-primary);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* Usage breakdown table */
.usage-breakdown-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.usage-breakdown-table th {
  text-align: left; font-size: 11px; font-weight: 500; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.05em; padding: 0 16px 12px 0;
  border-bottom: 1px solid var(--border-default); white-space: nowrap;
}
.usage-breakdown-table td {
  font-family: var(--font-primary); font-size: 13px; font-weight: 400;
  color: var(--text-secondary); padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--border-subtle); vertical-align: middle;
}
.usage-breakdown-table .num {
  text-align: right; font-family: var(--font-mono); font-size: 13px;
}
.usage-breakdown-table th.num { text-align: right; }
.usage-breakdown-table td.agent-name { font-weight: 500; color: var(--text-primary); }
.usage-breakdown-table td.model {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); text-transform: lowercase;
}
.usage-breakdown-table td.cost {
  font-family: var(--font-mono); font-size: 13px; font-weight: 500;
  color: var(--accent-green); text-align: right;
}
.usage-breakdown-table tbody tr {
  transition: background var(--transition-default); cursor: pointer;
}
.usage-breakdown-table tbody tr:hover { background: var(--row-hover-bg); }
.usage-breakdown-table tfoot td {
  font-weight: 500; color: var(--text-primary);
  padding-top: 12px; border-top: 1px solid var(--border-default); border-bottom: none;
}

/* Subagent rows on agent card */
.agent-card__subagents {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-card__subagent-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 18px;
  color: var(--text-tertiary);
}
.subagent-status-dot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
}
.subagent-status-dot--running { background: var(--accent-green); }
.subagent-status-dot--completed { background: var(--text-tertiary); }
.subagent-status-dot--failed { background: var(--accent-red); }
.subagent-status-dot--queued { background: var(--accent-blue); }
.subagent-status-dot--blocked { background: var(--accent-red); }
.subagent-status-dot--paused { background: var(--accent-amber); }
.subagent-status-dot--warning { background: var(--accent-amber); }
.subagent-status-dot--pr { background: var(--accent-indigo); }
.subagent-status-dot--merged { background: #5EEAD4; }
.agent-card__subagent-name {
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agent-card__subagent-task {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; color: var(--text-tertiary);
}
.agent-card__subagent-mode {
  flex-shrink: 0; font-family: var(--font-mono);
  font-size: 11px; color: var(--accent-blue);
}
.agent-card__subagent-duration {
  flex-shrink: 0; margin-left: auto; font-family: var(--font-mono);
  font-size: 12px; color: var(--text-tertiary);
}
.agent-card__cost {
  display: flex; align-items: baseline; gap: 4px;
  margin-left: auto; flex-shrink: 0;
}
.agent-card__cost-label {
  font-size: 11px; font-weight: 400; color: var(--text-tertiary);
}
.agent-card__cost-value {
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--accent-green);
}

/* File status indicators */
.file-status {
  width: 14px; height: 14px; border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500; flex-shrink: 0;
}
.file-status--added { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.file-status--modified { background: none; }
.file-status--modified::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-amber);
}
.file-status--deleted { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.file-status--renamed { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); font-size: 10px; }

/* Toggle switch */
.toggle-switch {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
}
.toggle-switch__label { font-size: 13px; color: var(--text-tertiary); }
.toggle-switch__input { display: none; }
.toggle-switch__track {
  width: 28px; height: 14px; border-radius: 7px;
  background: var(--border-default); position: relative; transition: background var(--transition-default);
}
.toggle-switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted); transition: transform var(--transition-default), background var(--transition-default);
}
.toggle-switch__input:checked + .toggle-switch__track { background: rgba(16, 185, 129, 0.3); }
.toggle-switch__input:checked + .toggle-switch__track::after {
  transform: translateX(14px); background: var(--accent-green);
}

/* ============================================
   VIEW: Create Agent
   ============================================ */
.create-form-card {
  max-width: 600px;
  margin: 16px auto;
  padding: 24px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
}
.create-form-card .btn { width: 100%; }
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 11px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.form-hint { font-size: 11px; margin-top: 4px; min-height: 16px; }
.form-hint-error { color: var(--accent-red); }
.form-hint-ok { color: var(--accent-green); }

.create-form-card select.action-input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}

/* ============================================
   COMPONENT: Collapsible Section
   Reusable <details>/<summary> component matching
   the diff-dir-summary and tool-group-summary pattern.
   ============================================ */
.collapsible-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-1) var(--space-6);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  list-style: none;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.collapsible-summary::-webkit-details-marker { display: none; }
.collapsible-summary::before {
  content: '\25B6';
  font-size: 8px;
  transition: transform var(--transition-default);
  display: inline-block;
}
.collapsible-section[open] > .collapsible-summary::before {
  transform: rotate(90deg);
}
.collapsible-summary:hover { color: var(--text-muted); }

/* ============================================
   COMPONENT: Action bar
   ============================================ */
.action-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 56px;
  padding: 8px 16px;
  background: var(--bg-base);
  border-top: 1px solid var(--border-default);
  z-index: 100;
}

.action-bar.hidden { display: none; }

.action-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-family: var(--font-primary);
  transition: border-color var(--transition-default);
}

.action-input::placeholder { color: var(--text-tertiary); }
.action-input:focus { outline: none; border-color: var(--border-hover); }

/* ============================================
   COMPONENT: Markdown body
   ============================================ */
.markdown-body { font-size: 14px; line-height: 22px; word-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 12px 0 6px; color: var(--text-primary); font-weight: 500; }
.markdown-body h1 { font-size: 18px; }
.markdown-body h2 { font-size: 16px; }
.markdown-body h3 { font-size: 14px; font-weight: 500; }
.markdown-body code { background: var(--code-bg); color: var(--code-text); padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: var(--font-mono); }
.markdown-body pre { background: var(--bg-surface); padding: 12px; border-radius: var(--radius-md); overflow-x: auto; margin: 8px 0; }
.markdown-body pre code { background: none; padding: 0; color: var(--text-primary); }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin: 4px 0; }
.markdown-body li { margin: 2px 0; }
.markdown-body p { margin: 4px 0; }
.markdown-body blockquote { border-left: 3px solid var(--border-hover); padding-left: 12px; color: var(--text-secondary); margin: 8px 0; }
.markdown-body a { color: var(--code-text); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body table { border-collapse: collapse; margin: 8px 0; width: 100%; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border-default); padding: 6px 10px; text-align: left; font-size: 13px; }
.markdown-body th { background: var(--bg-elevated); font-weight: 500; }

/* ============================================
   VIEW: Login
   ============================================ */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 640px) {
  .msg { max-width: 70%; }
  .msg-human { max-width: 65%; }
}

/* Tablet */
@media (max-width: 768px) {
  .agent-list { padding: var(--space-4); }
  .diff-view { height: auto; }
  .diff-summary-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .diff-layout { flex-direction: column; }
  .diff-sidebar { width: 100%; min-width: unset; max-height: 200px; border-right: none; border-bottom: 1px solid var(--border-default); }
  .diff-content { max-height: none; }
  .diff-toggle-btn[data-mode="side-by-side"] { display: none; }
}

/* Mobile diff summary (replaces diff viewer on narrow screens) */
.mobile-diff-summary {
  padding: var(--space-4);
}
.mobile-diff-stats {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
}
.mobile-diff-files {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-4);
  max-height: 300px;
  overflow-y: auto;
}
.mobile-diff-file {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}
.mobile-diff-file-path {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.mobile-pr-link {
  display: block;
  text-align: center;
  padding: 14px var(--space-4);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.mobile-pr-link--active {
  background: var(--accent-green);
  color: #fff;
}
.mobile-pr-link--active:hover {
  background: var(--accent-green-hover, #1a7f37);
}
.mobile-pr-link--inactive {
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 13px;
}

/* Mobile */
@media (max-width: 480px) {
  .vital-signs {
    flex-wrap: wrap;
    gap: var(--space-3);
  }
  .vital-cell {
    flex: 1 1 calc(50% - 12px);
    min-width: 100px;
  }
  .vital-divider { display: none; }
  .progress-segments { flex-basis: 100%; }
  .subagent-summary-list { flex-direction: column; }
  .subagent-pill { max-width: 100%; }

  /* Action bar: wrap so buttons don't overflow */
  .action-bar {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
  }
  .action-input { flex: 1 1 60%; min-width: 0; }

  /* Usage: metrics strip stacks on mobile */
  .usage-metrics {
    flex-direction: column;
    gap: 0;
    padding: 12px 16px;
  }
  .usage-metric {
    padding: 8px 0;
    border-right: none;
    border-bottom: 1px solid var(--border-default);
  }
  .usage-metric:last-child { border-bottom: none; }
  .usage-metric:first-child { padding-top: 0; }
  .usage-metric:last-child { padding-bottom: 0; }

  /* Usage: rate-limit rows stack on mobile */
  .rate-limit-card { padding: 16px; }
  .rate-limit-row { flex-wrap: wrap; gap: 4px 8px; }
  .rate-limit-label { min-width: 0; flex-basis: 100%; flex-shrink: 1; }
  .rate-limit-bar-track { min-width: 0; flex-basis: 0; }
  .rate-limit-pct { min-width: 0; }
  .rate-limit-reset { min-width: 0; font-size: 11px; flex-basis: 100%; }

  /* Usage: chart card header wraps */
  .usage-chart-card { padding: 16px; }
  .usage-chart-card__header { flex-wrap: wrap; gap: 8px; }
  .date-range-selector { flex-wrap: wrap; }

  /* Usage: chart x-axis labels smaller */
  .usage-bar-label { font-size: 9px; }
  .usage-bar-today-label { font-size: 8px; bottom: -30px; }
  .usage-chart { height: 130px; }

  /* Usage: table card */
  .usage-table-container { padding: 16px; overflow-x: auto; }
}

/* Safe area for mobile notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .header { padding-top: env(safe-area-inset-top); height: calc(48px + env(safe-area-inset-top)); }
  .detail-layout { height: 100dvh; }
  .action-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}
