:root {
  --bg: #0b0d12;
  --bg-card: #131722;
  --bg-card-2: #1a1f2e;
  --border: #232a3a;
  --text: #e6e9ef;
  --text-dim: #8a93a6;
  --text-faint: #5a6478;
  --accent: #4ea1f7;
  --us: #4ea1f7;
  --sg: #f7a14e;
  --ok: #3fb96b;
  --warn: #f5c252;
  --err: #ef5b5b;
  --shadow: 0 1px 0 rgba(255,255,255,0.04), 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: 0.2px; }
.brand .subtitle { color: var(--text-dim); font-size: 12px; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.control-group {
  display: inline-flex;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.control-group button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px 11px;
  cursor: pointer;
  font: inherit;
  border-right: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}
.control-group button:last-child { border-right: none; }
.control-group button:hover { color: var(--text); background: rgba(78, 161, 247, 0.08); }
.control-group button.active {
  color: #fff;
  background: var(--accent);
}

.now {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card-2);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px 24px 0;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}

.status-card .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.status-card .label { color: var(--text-dim); font-size: 12px; }
.status-card .value { font-variant-numeric: tabular-nums; font-weight: 600; }
.status-card h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.status-card .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text-dim);
}
.status-card.us .pill { color: var(--us); border-color: rgba(78, 161, 247, 0.4); }
.status-card.sg .pill { color: var(--sg); border-color: rgba(247, 161, 78, 0.4); }
.pill.ok   { color: var(--ok); border-color: rgba(63, 185, 107, 0.4); }
.pill.warn { color: var(--warn); border-color: rgba(245, 194, 82, 0.4); }
.pill.err  { color: var(--err); border-color: rgba(239, 91, 91, 0.4); }

.bar {
  height: 6px; background: var(--bg-card-2); border-radius: 999px; overflow: hidden;
}
.bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--warn) 70%, var(--err));
  transition: width 0.4s ease;
}

main#hosts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(640px, 1fr));
  gap: 16px;
  padding: 16px 24px;
}

@media (max-width: 1100px) {
  main#hosts-grid { grid-template-columns: 1fr; }
}

.host-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.host-block header.host-header {
  position: static;
  background: transparent;
  border: none;
  padding: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
}

.host-block h2 { margin: 0; font-size: 16px; }
.host-block.us h2::before { content: "🇺🇸  "; }
.host-block.sg h2::before { content: "🇸🇬  "; }
.host-block .meta { font-size: 12px; color: var(--text-dim); }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .charts { grid-template-columns: 1fr; } }
.chart-wrap {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px 4px;
  position: relative;
}
.chart-wrap h4 {
  margin: 0 0 4px; font-size: 12px; color: var(--text-dim); font-weight: 500;
  display: flex; justify-content: space-between; align-items: baseline;
}
.chart-wrap .chart-current {
  font-variant-numeric: tabular-nums;
  font-weight: 600; color: var(--text); font-size: 12px;
}
.chart-wrap canvas { height: 160px !important; max-height: 160px; }

.events-panel {
  margin: 8px 24px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.events-panel h2 { margin: 0 0 8px; font-size: 16px; }
.events-panel .muted { font-weight: normal; color: var(--text-dim); font-size: 13px; margin-left: 8px; }
.events-controls { display: flex; gap: 14px; padding: 0 0 10px; flex-wrap: wrap; color: var(--text-dim); font-size: 13px; }
.events-controls input { accent-color: var(--accent); }

.events-list {
  display: grid;
  grid-template-columns: 90px 90px 110px 80px 1fr;
  gap: 0;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.events-list .row {
  display: contents;
}
.events-list .row > div {
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-card-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.events-list .row.head > div {
  border-top: none;
  background: var(--bg-card);
  color: var(--text-dim);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.events-list .row > div:nth-child(5) { white-space: normal; color: var(--text-dim); }
.events-list .row.us  > div:first-child { border-left: 3px solid var(--us); }
.events-list .row.sg  > div:first-child { border-left: 3px solid var(--sg); }
.kind-scrape_start { color: var(--accent); }
.kind-scrape_end   { color: var(--ok); }
.kind-error        { color: var(--err); }
.kind-info         { color: var(--text-dim); }

footer {
  padding: 18px 24px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
