/* IP Monitor — mobile-first dark UI */

:root {
  --bg: #0b0d10;
  --bg-2: #12161b;
  --panel: #161b22;
  --panel-2: #1c222b;
  --border: #232a33;
  --text: #e6edf3;
  --muted: #8b97a6;
  --accent: #22c55e;
  --warn:  #f59e0b;
  --bad:   #ef4444;
  --c1: #60a5fa; /* host 1 — blue */
  --c2: #f472b6; /* host 2 — pink */
  --c3: #34d399; /* host 3 — green */
  --c4: #fbbf24; /* host 4 — amber */
  --c5: #a78bfa; /* host 5 — violet */
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0,0,0,0.35);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fa;
    --bg-2: #eef1f6;
    --panel: #ffffff;
    --panel-2: #f7f9fc;
    --border: #e2e7ee;
    --text: #0b1220;
    --muted: #5a6675;
    --shadow: 0 4px 18px rgba(20,30,50,0.08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: 0.2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.dot.pulse { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); animation: pulse 2s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 14px 28px;
}

/* ── Status cards ───────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
@media (min-width: 640px) { .cards { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 12px; }
.card-title { flex: 1; min-width: 0; }
.label { font-weight: 600; font-size: 16px; line-height: 1.2; }
.ip    { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
         color: var(--muted); font-size: 13px; margin-top: 2px; }

.status-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  background: #6b7280; box-shadow: 0 0 0 3px rgba(107,114,128,0.18);
  transition: background 240ms ease, box-shadow 240ms ease;
}
.status-dot[data-status="up"]   { background: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
.status-dot[data-status="warn"] { background: var(--warn);   box-shadow: 0 0 0 3px rgba(245,158,11,0.18); }
.status-dot[data-status="down"] { background: var(--bad);    box-shadow: 0 0 0 3px rgba(239,68,68,0.20); }

.latency {
  font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 700;
  display: flex; align-items: baseline; gap: 3px;
}
.latency .unit { font-size: 12px; font-weight: 500; color: var(--muted); }

.card-foot {
  margin-top: 12px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  font-size: 13px;
}
.card-foot b { font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Charts ─────────────────────────────────────────────────────── */
.chart-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.chart-head h2 { font-size: 15px; margin: 0; font-weight: 600; }

.tabs { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 160ms ease, color 160ms ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #0b0d10; }

.chart-wrap {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-wrap.small { height: 160px; }

footer { text-align: center; margin-top: 16px; }

/* host-color overrides applied via JS data-host-idx */
.card[data-host-idx="0"] .label::before,
.card[data-host-idx="1"] .label::before,
.card[data-host-idx="2"] .label::before,
.card[data-host-idx="3"] .label::before,
.card[data-host-idx="4"] .label::before {
  content: ""; display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.card[data-host-idx="0"] .label::before { background: var(--c1); }
.card[data-host-idx="1"] .label::before { background: var(--c2); }
.card[data-host-idx="2"] .label::before { background: var(--c3); }
.card[data-host-idx="3"] .label::before { background: var(--c4); }
.card[data-host-idx="4"] .label::before { background: var(--c5); }
