:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212d;
  --line: #243041;
  --ink: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3d8bfd;
  --accent-2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 139, 253, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 197, 94, 0.1), transparent 50%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 18px 80px;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 22px;
}
.back {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.back:hover { color: var(--ink); }
h1 {
  margin: 0 0 6px;
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}
.lede {
  margin: 0;
  color: var(--muted);
  max-width: 54ch;
  font-size: 0.95rem;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: none;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: 600 0.9rem/1 var(--sans);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: #3a4d66; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(180deg, #4d96ff, #2f78e8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(47, 120, 232, 0.35);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost[aria-pressed="true"] {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.45);
  color: #86efac;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
.metric-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric-val {
  font-family: var(--mono);
  font-size: clamp(1.45rem, 3vw, 1.85rem);
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.unit {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.metric-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}
.metric-bar {
  margin-top: 10px;
  height: 4px;
  background: #1c2736;
  border-radius: 99px;
  overflow: hidden;
}
.metric-bar > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #7dd3fc);
  border-radius: inherit;
  transition: width 0.25s ease;
}
#bar-up { background: linear-gradient(90deg, var(--accent-2), #86efac); }
#bar-live { background: linear-gradient(90deg, #a78bfa, #c4b5fd); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card h2 {
  margin: 0;
  font-size: 1rem;
}
.pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
}
.pill.run { color: #93c5fd; border-color: rgba(61, 139, 253, 0.4); }
.pill.live { color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.pill.err { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }

.chart-card canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #0d131b;
  border: 1px solid #1a2433;
  border-radius: 10px;
}
.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.facts {
  margin: 0;
  display: grid;
  gap: 8px;
}
.facts > div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #1a2433;
}
.facts > div:last-child { border-bottom: 0; }
.facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.facts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  text-align: right;
}

.history {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}
.history.empty {
  color: var(--muted);
  font-size: 0.9rem;
}
.hist-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 0.8fr;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid #1a2433;
  border-radius: 8px;
}
.hist-row span:first-child { color: var(--muted); }

.note ul {
  margin: 8px 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.note li { margin-bottom: 0.45rem; }
.note strong { color: var(--ink); }
.note code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: #0d131b;
  border: 1px solid #1a2433;
  padding: 0.1em 0.35em;
  border-radius: 5px;
  color: #c7d2fe;
}

@media (max-width: 820px) {
  .hero-metrics { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .top { flex-direction: column; }
}
@media (max-width: 480px) {
  .hist-row { grid-template-columns: 1fr 1fr; }
  .hist-row span:nth-child(n+3) { display: none; }
}
