:root {
  --bg: #0b1220;
  --card: #141d2f;
  --border: #22304a;
  --text: #e5eaf3;
  --muted: #8b98ad;
  --ok: #22c55e;
  --warn: #fab219;
  --bar: #256abf;
  --bar-current: #3987e5;
  --axis: #383835;
  --down: #ef4444;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px);
}

header { display: flex; align-items: center; justify-content: space-between; }
h1 { font-size: 1.6rem; margin: 0 0 12px; }
h2 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 28px 0 10px; }

.muted { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
.error { color: var(--down); }

.summary {
  padding: 16px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 6px solid var(--muted);
}
.summary.ok { border-left-color: var(--ok); }
.summary.warn { border-left-color: var(--warn); }
.summary.down { border-left-color: var(--down); }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
}
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.down { background: var(--down); box-shadow: 0 0 8px var(--down); }
.name { font-weight: 600; word-break: break-all; }
.detail { color: var(--muted); font-size: .85rem; }
.detail.problem { color: var(--warn); }
.metric { text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; white-space: nowrap; }

form { display: grid; gap: 14px; margin-top: 20px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
input {
  font-size: 16px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
}
button {
  font-size: 16px;
  padding: 12px;
  border-radius: 10px;
  border: 0;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
}
button.link { background: none; color: var(--muted); padding: 6px; font-weight: 400; }

h3 { font-size: .9rem; color: var(--muted); font-weight: 500; margin: 16px 0 10px; }
.note { margin-top: 12px; }

.card.bw { display: block; }
.bw-top { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 12px; }
.card.bw > .detail { margin: 4px 0 0 26px; }

.spark { margin-top: 12px; }
.spark svg { display: block; width: 100%; height: 44px; touch-action: pan-y; cursor: crosshair; outline: none; }
.spark svg:focus-visible { outline: 2px solid var(--bar-current); outline-offset: 4px; border-radius: 4px; }
.spark .axis { stroke: var(--axis); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark .bar { fill: var(--bar); }
.spark .bar.current { fill: var(--bar-current); }
.spark .bar.spike { fill: var(--warn); }
.spark .bar.active { stroke: var(--text); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; margin-top: 4px; }
.readout { font-size: .85rem; margin: 6px 0 0; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.readout:not(.muted) { color: var(--text); font-weight: 600; }

details { margin-top: 8px; }
summary { color: var(--muted); font-size: .85rem; cursor: pointer; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: .85rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 4px 0; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
td:not(:first-child), th:not(:first-child) { text-align: right; }
.spike-row td { color: var(--warn); }
