:root {
  --bg: #0a0e14;
  --panel: #10161f;
  --panel-2: #141c28;
  --border: #232f3f;
  --text: #dce6f0;
  --text-dim: #8a9bb0;
  --accent: #3fd0e0;
  --accent-2: #5ab8ff;
  --green: #3ecf8e;
  --amber: #f0b74e;
  --red: #ef5a6f;
  --purple: #b48bf0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top, #0d1420 0%, var(--bg) 55%);
  color: var(--text);
  padding: 0 20px 60px;
}

a { color: var(--accent-2); }

h1, h2, h3 { margin: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 4px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-icon { font-size: 34px; }
.tagline { margin: 2px 0 0; color: var(--text-dim); font-size: 13px; }

.tick-badge {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--accent);
  font-size: 14px;
  white-space: nowrap;
}

.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 4px;
  flex-wrap: wrap;
}

.controls-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #1a2331; border-color: #34445a; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #06131a; border: none; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #5a2632; color: var(--red); }
.btn-danger:hover { background: #2a1218; }
.btn-small { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-approve { border-color: #1f4d38; color: var(--green); }
.btn-approve:hover { background: #10241a; }
.btn-deny { border-color: #5a2632; color: var(--red); }
.btn-deny:hover { background: #2a1218; }

.filter-label { color: var(--text-dim); font-size: 13px; }
select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}

section { margin: 22px 0; }
section h2 { font-size: 15px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.hint { text-transform: none; letter-spacing: 0; font-size: 12px; color: #5c6c80; }

.count-pill {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  color: var(--accent);
}

.empty-state { color: #5c6c80; font-size: 13px; padding: 10px 2px; }

.approval-queue { display: flex; flex-direction: column; gap: 10px; }
.approval-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.approval-card.anomaly { border-left-color: var(--red); background: #1a0f12; }
.approval-meta { display: flex; flex-direction: column; gap: 3px; }
.approval-agent { font-size: 12px; color: var(--text-dim); }
.approval-agent .team-tag { margin-left: 6px; }
.approval-text { font-size: 14px; }
.approval-amount { font-size: 12px; color: var(--amber); }
.anomaly-flag { color: var(--red); font-weight: 600; font-size: 12px; }
.approval-actions { display: flex; gap: 8px; }

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agent-card.status-contained { border-color: #5a2632; box-shadow: 0 0 0 1px #5a2632 inset; }
.agent-card.status-killed { opacity: 0.55; }

.agent-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.agent-name { font-size: 16px; font-weight: 600; }
.agent-job { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.team-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}
.status-running { background: #0e2a1e; color: var(--green); }
.status-paused { background: #2a2410; color: var(--amber); }
.status-awaiting_approval { background: #2a2410; color: var(--amber); }
.status-contained { background: #2a1218; color: var(--red); }
.status-killed { background: #1c1c1c; color: #888; }

.drift-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.drift-bar { flex: 1; height: 7px; background: #1a2331; border-radius: 999px; overflow: hidden; }
.drift-fill { height: 100%; border-radius: 999px; transition: width 0.25s ease; }
.drift-value { font-family: Consolas, Menlo, monospace; width: 34px; text-align: right; }

.current-task { font-size: 13px; }
.current-task .label { color: var(--text-dim); }

.blocker-line { font-size: 12.5px; padding: 6px 8px; border-radius: 6px; background: #2a2410; color: var(--amber); }
.blocker-line.anomaly { background: #2a1218; color: var(--red); }

.recent-actions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-dim); }
.recent-actions li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.stats-row { display: flex; gap: 16px; font-size: 12px; color: var(--text-dim); }
.stats-row b { color: var(--text); font-weight: 600; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.replay-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.replay-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.replay-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.replay-entry { font-size: 12.5px; padding: 7px 10px; border-radius: 6px; background: var(--panel-2); border-left: 3px solid var(--border); }
.replay-entry .tick { color: var(--text-dim); margin-right: 8px; font-family: Consolas, Menlo, monospace; }
.replay-entry.type-anomaly_detected { border-left-color: var(--red); }
.replay-entry.type-blocked_pending_approval { border-left-color: var(--amber); }
.replay-entry.type-approved { border-left-color: var(--green); }
.replay-entry.type-denied { border-left-color: var(--red); }

.audit-log {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  max-height: 320px;
  overflow-y: auto;
  font-size: 12.5px;
  display: flex;
  flex-direction: column-reverse;
  gap: 5px;
}
.audit-row { display: flex; gap: 10px; padding: 4px 0; border-bottom: 1px dashed #1a2331; }
.audit-row .tick { color: var(--text-dim); font-family: Consolas, Menlo, monospace; width: 46px; flex-shrink: 0; }
.audit-row .agent { color: var(--accent-2); width: 130px; flex-shrink: 0; }
.audit-row .text { color: var(--text); }
.audit-row.type-anomaly_detected .text { color: var(--red); }
.audit-row.type-agent_killed .text { color: var(--red); }

.footer { margin-top: 30px; color: #4a5b70; font-size: 12px; text-align: center; }

@media (max-width: 640px) {
  .topbar, .controls-bar { flex-direction: column; align-items: flex-start; }
  .audit-row { flex-wrap: wrap; }
}
