:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-hover: #1a1a26;
  --border: #1e1e2e;
  --border-subtle: #16161f;
  --text: #e2e2e8;
  --text-dim: #6b6b80;
  --text-muted: #44445a;
  --accent: #6c5ce7;
  --accent-dim: rgba(108, 92, 231, 0.15);
  --green: #00d26a;
  --green-glow: rgba(0, 210, 106, 0.12);
  --yellow: #ffc048;
  --yellow-glow: rgba(255, 192, 72, 0.12);
  --red: #ff5757;
  --blue: #4ea8de;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-left h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo { margin-right: 4px; }

.subtitle {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--green-glow); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px transparent; }
}

/* Totals Bar */
.totals-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 24px;
}

.totals-content {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.total-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.total-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.total-value {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -0.5px;
}

.total-value.dim {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-dim);
}

.total-item.accent .total-value {
  color: var(--accent);
}

.total-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* Dashboard Grid — 5 agents: 3 top, 2 bottom centered */
#dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Center the last row when it has fewer items */
#dashboard .agent-card:nth-child(4) {
  grid-column-start: 1;
}

@media (max-width: 1100px) {
  #dashboard { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  #dashboard { grid-template-columns: 1fr; }
  .app { padding: 16px; }
  .totals-content { gap: 16px; }
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* Agent Card */
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
  min-width: 0;
}

.agent-card:hover {
  border-color: #2a2a3e;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

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

.agent-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.agent-emoji {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-hover);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.agent-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

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

/* Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-active {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(0, 210, 106, 0.2);
}

.status-idle {
  background: var(--yellow-glow);
  color: var(--yellow);
  border: 1px solid rgba(255, 192, 72, 0.2);
}

.status-standby {
  background: rgba(78, 168, 222, 0.1);
  color: var(--blue);
  border: 1px solid rgba(78, 168, 222, 0.2);
}

.status-missing {
  background: rgba(255, 87, 87, 0.1);
  color: var(--red);
  border: 1px solid rgba(255, 87, 87, 0.2);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-active .status-dot {
  animation: pulse 2s ease-in-out infinite;
}

/* Sections */
.agent-section { margin-top: 16px; }

.section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Token Usage */
.usage-row {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.usage-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.usage-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.usage-value {
  font-size: 14px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.usage-stat.accent .usage-value {
  color: var(--accent);
}

/* Cron Jobs */
.cron-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cron-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  gap: 8px;
  min-width: 0;
}

.cron-name {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.cron-schedule {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-hover);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.cron-disabled { opacity: 0.4; }

.empty-state {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0;
}

/* Activity Log */
.log-entries {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.log-entries::-webkit-scrollbar { width: 4px; }
.log-entries::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.log-entry {
  font-size: 12px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.6;
  padding: 2px 8px;
  border-left: 2px solid var(--border);
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Last Activity */
.last-activity {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}
