:root {
  --color-accent: #2c5f8a;
  --color-sidebar-bg: #1e293b;
  --color-sidebar-text: #cbd5e1;
  --color-sidebar-active: #2c5f8a;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-badge-active-bg: #dcfce7;
  --color-badge-active-text: #166534;
  --color-badge-paused-bg: #fee2e2;
  --color-badge-paused-text: #991b1b;
  --color-badge-watch-bg: #fef9c3;
  --color-badge-watch-text: #854d0e;
  --color-badge-continue-bg: #dcfce7;
  --color-badge-continue-text: #166534;
  --color-badge-stop-bg: #fee2e2;
  --color-badge-stop-text: #991b1b;
  --color-ae-low: #166534;
  --color-ae-mid: #854d0e;
  --color-ae-high: #991b1b;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.sidebar {
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.5rem;
  overflow-y: auto;
}

.main-content {
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

/* --- Data table --- */
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data-table thead {
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
}

table.data-table th,
table.data-table td {
  padding: 5px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

table.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

table.data-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

table.data-table tbody tr:hover {
  background: #e2e8f0;
}

/* --- Status badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-active   { background: var(--color-badge-active-bg);   color: var(--color-badge-active-text); }
.badge-paused   { background: var(--color-badge-paused-bg);   color: var(--color-badge-paused-text); }
.badge-watch    { background: var(--color-badge-watch-bg);    color: var(--color-badge-watch-text); }
.badge-continue { background: var(--color-badge-continue-bg); color: var(--color-badge-continue-text); }
.badge-stop     { background: var(--color-badge-stop-bg);     color: var(--color-badge-stop-text); }

/* --- AE rate cells --- */
.ae-low  { color: var(--color-ae-low); }
.ae-mid  { color: var(--color-ae-mid); }
.ae-high { color: var(--color-ae-high); font-weight: 700; }

/* --- Metric cards --- */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.metric-card .metric-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.metric-card .metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* --- Progress bar --- */
.progress-bar-track {
  background: var(--color-border);
  border-radius: 4px;
  height: 6px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* --- Sidebar nav --- */
.nav-link {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  border-radius: 4px;
}

.nav-link.active,
.nav-link:hover {
  background: var(--color-sidebar-active);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  color: var(--color-sidebar-text);
}

/* --- Safety page --- */
.safety-banner {
  padding: 0.75rem 1.25rem;
  border-radius: 4px;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: #fff;
}
.safety-banner--ok    { background: #22c55e; }
.safety-banner--alert { background: #ef4444; }

.paused-arms-banner {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 4px;
  padding: 0.75rem 1.25rem;
  color: #92400e;
  margin-top: 1.5rem;
}

.chart-section {
  margin-bottom: 2rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  color: #b91c1c;
  margin-bottom: 1rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) auto 1fr;
  }

  .sidebar {
    display: none;
  }
}
