:root {
  --bg: #ffffff;
  --surface: #f7f7f5;
  --surface-hover: #f0efec;
  --ink: #14171f;
  --ink-muted: #6b7280;
  --ink-faint: #9ca3af;
  --accent: #4f3df5;
  --accent-dark: #3b2fc7;
  --accent-soft: #eeecff;
  --success: #059669;
  --border: #e7e7e4;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 23, 31, 0.07);
  --shadow-lg: 0 24px 60px rgba(20, 23, 31, 0.16);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
}

.subtitle {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
  animation: statusPulse 2.4s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Layout */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 32px 80px;
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 44px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.stat-sub {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-top: 6px;
}

.stat-sub.real { color: var(--success); font-weight: 500; }

/* Roster */
.roster-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 6px;
}

.roster-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  margin: 0;
}

.roster-hint {
  font-size: 12.5px;
  color: var(--ink-faint);
}

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

.agent-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.agent-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #d8d6f8;
}

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

.agent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-status-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 5px;
  font-weight: 500;
}

.agent-status-pill.live {
  background: #e7f6ef;
  color: var(--success);
}

.agent-status-pill.idle {
  background: var(--surface);
  color: var(--ink-faint);
  border: 1px solid var(--border);
}

.agent-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 15.5px;
}

.agent-role {
  font-size: 12.5px;
  color: var(--ink-muted);
  line-height: 1.4;
  min-height: 32px;
}

/* Activity pulse bars — the signature element */
.pulse {
  display: flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 20px;
}

.pulse span {
  flex: 1;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.85;
  animation: pulseBar 1.1s ease-in-out infinite;
}

.agent-card.idle .pulse span {
  background: var(--ink-faint);
  opacity: 0.4;
  animation: none;
  height: 4px !important;
}

@keyframes pulseBar {
  0%, 100% { height: 30%; }
  50% { height: 100%; }
}

.agent-metrics {
  display: flex;
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.agent-metric-value {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  font-size: 13px;
}

.agent-metric-label {
  font-size: 10.5px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}

/* Drawer / drill-down */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 31, 0.32);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px;
  z-index: 50;
}

.overlay.open { display: flex; }

.drawer {
  background: var(--bg);
  border-radius: 18px;
  max-width: 560px;
  width: 100%;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 32px;
  position: relative;
  animation: drawerIn 0.18s ease;
}

@keyframes drawerIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: var(--surface);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--ink-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.drawer h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  margin: 0 0 6px;
}

.drawer .drawer-role {
  color: var(--ink-muted);
  font-size: 13.5px;
  margin-bottom: 20px;
}

.output-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.output-item-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.output-item-body {
  font-size: 13px;
  color: var(--ink-muted);
  line-height: 1.55;
}

.empty-state {
  text-align: center;
  padding: 30px 10px 10px;
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.hooks-label {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 6px;
}

.hooks-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  margin-bottom: 14px;
}

.hooks-generate-btn {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 6px;
}

.hooks-generate-btn:disabled { opacity: 0.6; cursor: default; }

/* Growth chart */
.chart-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 32px;
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.chart-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  margin: 0 0 4px;
}

.chart-hint {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 0;
  max-width: 440px;
  line-height: 1.5;
}

.chart-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--ink-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.chart-svg-wrap {
  margin-top: 10px;
}

.chart-point-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  fill: var(--ink-faint);
}

/* Cycle panel */
.cycle-panel {
  background: var(--accent-soft);
  border: 1px solid #d8d3fb;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 32px;
}

.cycle-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cycle-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  margin: 0 0 4px;
}

.cycle-hint {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0;
  max-width: 460px;
  line-height: 1.5;
}

.cycle-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.cycle-btn:hover { background: var(--accent-dark); }
.cycle-btn:disabled { opacity: 0.6; cursor: default; }

.cycle-steps {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cycle-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.cycle-step-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink-faint);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.cycle-step.active .cycle-step-icon {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

.cycle-step.done .cycle-step-icon {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.cycle-step.done { color: var(--ink); }

.cycle-step.error .cycle-step-icon {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
}

.cycle-step.error { color: #dc2626; }

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

.cycle-detail {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-left: 28px;
}

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .roster-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .stats-row { grid-template-columns: 1fr; }
  .roster-grid { grid-template-columns: 1fr; }
  .wrap { padding: 28px 18px 60px; }
  .topbar { padding: 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse span, .status-dot { animation: none; }
}
