:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6; /* blue: reachable */
  --series-2:       #eb6834; /* orange: known */
  --seq-blue-450:   #2a78d6;
  --seq-blue-300:   #6da7ec;
  --seq-orange-450: #eb6834;
  --seq-orange-300: #f0966e;
  --good:           #0ca30c;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --seq-blue-450:   #3987e5;
    --seq-blue-300:   #5598e7;
    --seq-orange-450: #d95926;
    --seq-orange-300: #e8814f;
    --good:           #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255,255,255,0.10);
  --series-1:       #3987e5;
  --series-2:       #d95926;
  --seq-blue-450:   #3987e5;
  --seq-blue-300:   #5598e7;
  --seq-orange-450: #d95926;
  --seq-orange-300: #e8814f;
  --good:           #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

header.page-header {
  margin-bottom: 28px;
}
.page-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
header.page-header h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}
.theme-toggle {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.theme-toggle:hover {
  background: var(--grid);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
header.page-header p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.95rem;
}
header.page-header a {
  color: var(--seq-blue-450);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stat-tile .value {
  font-size: 1.7rem;
  font-weight: 600;
  margin-top: 2px;
  font-variant-numeric: proportional-nums;
}
.stat-tile .sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 1rem;
  margin: 0 0 4px;
}
.card .card-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 760px) {
  .charts-row.two-up { grid-template-columns: 1fr 1fr; }
}

.tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.tabs .tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.78rem;
  cursor: pointer;
}
.tabs .tab.active { background: var(--seq-blue-450); color: #fff; border-color: var(--seq-blue-450); }

.legend {
  display: flex;
  gap: 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .item.toggle { cursor: pointer; user-select: none; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; }
.legend .item.toggle:hover { background: var(--grid); }
.legend .item.toggle.off { opacity: 0.4; text-decoration: line-through; }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.land-mass { fill: var(--grid); stroke: var(--axis); stroke-width: 0.5; }
.axis-label { fill: var(--text-muted); font-size: 10px; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.chart-wrap { position: relative; overflow: hidden; }

.bar-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 0.82rem; }
.bar-row.clickable { cursor: pointer; border-radius: 6px; padding: 2px 4px; margin-left: -4px; margin-right: -4px; }
.bar-row.clickable:hover { background: var(--grid); }
.bar-row .bar-label {
  width: 170px; flex: 0 0 170px;
  color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-row .bar-track { flex: 1; background: var(--grid); border-radius: 3px; height: 10px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 3px; }
.bar-row .bar-value { width: 48px; flex: 0 0 48px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.controls input[type="search"],
.controls select {
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
}
.controls input[type="search"] { flex: 1; min-width: 180px; }
.cluster-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--seq-blue-450);
  color: #fff;
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-size: 0.8rem;
  white-space: nowrap;
}
.cluster-chip button {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  line-height: 1;
  font-size: 0.9rem;
}
.cluster-chip button:hover { background: rgba(255,255,255,0.4); }

table.nodes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
table.nodes-table th, table.nodes-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
table.nodes-table th {
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--surface-1);
}
table.nodes-table th:hover { color: var(--text-primary); }
table.nodes-table td.mono { font-variant-numeric: tabular-nums; }
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.up { background: var(--good); }
.status-dot.down { background: var(--text-muted); }

.table-scroll { overflow-x: auto; }
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.pager button {
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.82rem;
}
.pager button:disabled { opacity: 0.4; cursor: default; }

footer.page-footer {
  margin-top: 28px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
