:root {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1f2328;
  --muted: #6b7280;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --green-dark: #15803d;
  --amber: #f59e0b;
  --red: #ef4444;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --series-1: #22c55e;
  --series-1-fill: rgba(34, 197, 94, 0.10);
  --series-2: #6366f1;
  --series-2-fill: rgba(99, 102, 241, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --panel: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8b949e;
    --green: #3fb950;
    --green-soft: #0f2d18;
    --green-dark: #56d364;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --series-1: #3fb950;
    --series-1-fill: rgba(63, 185, 80, 0.15);
    --series-2: #8b94f5;
    --series-2-fill: rgba(139, 148, 245, 0.15);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header.site {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 18px;
}
.brand .logo {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--green);
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}
.brand .title small {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
  margin-left: 4px;
}
.brand .live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.brand .live .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}
.brand .live[data-state="live"] .dot { background: var(--green); }
.brand .live[data-state="live"] { color: var(--green-dark); }
.brand .live[data-state="connecting"] .dot {
  background: var(--amber);
  animation: pulse 1.4s infinite ease-in-out;
}
.brand .live[data-state="error"] .dot { background: var(--red); }
.brand .live[data-state="hover"] .dot { background: var(--series-2); }
.brand .live[data-state="hover"] { color: var(--series-2); }
.hover-label {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  margin-right: 8px;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.hover-label.show { opacity: 1; }
.brand .live { margin-left: 0; }
body.hovering .card .value { font-style: italic; }
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
}

.card .head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.card h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card .sub {
  font-size: 12px;
  color: var(--muted);
}
.card .value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.card .value .unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 4px;
}
.card .value .small {
  font-size: 16px;
  font-weight: 500;
  color: var(--muted);
}
.card .row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.card .row strong {
  color: var(--text);
  font-weight: 500;
}

.bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--green);
  transition: width 0.4s ease;
}
.bar.warn > span { background: var(--amber); }
.bar.crit > span { background: var(--red); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--border);
}
.pill .pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.pill.green { color: var(--green-dark); background: var(--green-soft); }
.pill.green .pill-dot { background: var(--green); }
.pill.amber { color: #b45309; background: rgba(245, 158, 11, 0.12); }
@media (prefers-color-scheme: dark) {
  .pill.amber { color: #fbbf24; }
}
.pill.amber .pill-dot { background: var(--amber); }

.spark {
  margin-top: 4px;
  width: 100%;
  height: 60px;
}
.spark.tall { height: 80px; }

.footnote {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0 40px;
  margin: 0;
}

/* uPlot tweaks: sparkline-style, hide axes/grid by default */
.u-wrap { background: transparent !important; }
.uplot, .uplot canvas { background: transparent !important; }
/* Cursor crosshair: subtle vertical line on hover. */
.uplot .u-cursor-x {
  border-left: 1px dashed var(--muted) !important;
  opacity: 0.55;
}
.uplot .u-cursor-y { display: none !important; }
.uplot .u-select {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.4);
}
