:root {
  color-scheme: light;
  --page-plane:     #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --meter-track:    #cde2fb;
  --meter-fill:     #2a78d6;
  --status-good:    #0ca30c;
  --status-good-bg: #e6f6e6;
  --status-warn:    #fab219;
  --status-warn-bg: #fdf1d9;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-plane:     #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --border:         rgba(255, 255, 255, 0.10);
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --meter-track:    #184f95;
    --meter-fill:     #3987e5;
    --status-good:    #0ca30c;
    --status-good-bg: rgba(12, 163, 12, 0.16);
    --status-warn:    #fab219;
    --status-warn-bg: rgba(250, 178, 25, 0.16);
  }
}

* { box-sizing: border-box; }

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

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

a { color: var(--series-1); }

.muted { color: var(--text-muted); font-weight: 400; }

.page-header {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.pill-muted { color: var(--text-muted); }
.pill-good { color: var(--status-good); background: var(--status-good-bg); border-color: transparent; }
.pill-warn { color: var(--status-warn); background: var(--status-warn-bg); border-color: transparent; }

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

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 600;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 20px;
}

.card-head h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-sub {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  max-width: 68ch;
}

.card-foot {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.badge-live {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--status-good);
  background: var(--status-good-bg);
  border-radius: 999px;
  padding: 2px 8px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td.empty {
  color: var(--text-muted);
  white-space: normal;
}

td.num, th.num { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-warn { color: var(--status-warn); background: var(--status-warn-bg); }
.badge-good { color: var(--status-good); background: var(--status-good-bg); }

.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}
.meter-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--meter-track);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--meter-fill);
}
.meter-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--text-secondary);
  width: 2.4em;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--gridline);
}
.timeline li {
  position: relative;
  padding: 0 0 18px 20px;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--series-1);
  border: 2px solid var(--surface-1);
}
.timeline-date {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.timeline-change {
  font-weight: 600;
  margin: 2px 0;
}
.timeline-detail {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

/* Antenna comparison chart */

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.chart-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.table-toggle {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--series-1);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
.table-toggle:hover { background: var(--page-plane); }
.table-toggle[aria-pressed="true"] {
  background: var(--series-1);
  color: #fff;
  border-color: transparent;
}

.chart-body {
  position: relative;
}

.chart-body.is-table-view { display: none; }
.chart-table-view[hidden] { display: none; }

.bar-group:hover path,
.bar-group:focus-within path {
  filter: brightness(1.1);
}
.bar-group:focus-within path {
  outline: 2px solid var(--series-1);
  outline-offset: 1px;
}
.bar-group { outline: none; }

/* Success-over-time chart */

.trend-point:focus-within {
  outline: 2px solid var(--series-1);
  outline-offset: 1px;
}
.trend-point { outline: none; }

.trend-flag:hover circle.dot,
.trend-flag:focus-within circle.dot {
  stroke: var(--series-1);
}
.trend-flag:focus-within {
  outline: 2px solid var(--series-1);
  outline-offset: 1px;
}
.trend-flag { outline: none; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.1s ease;
  white-space: nowrap;
  z-index: 5;
}
.chart-tooltip.is-visible { opacity: 1; }
.chart-tooltip.tt-below { transform: translate(-50%, 14px); }
.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-tooltip .tt-key {
  width: 8px;
  height: 2px;
  flex: none;
}
.chart-tooltip .tt-value {
  font-weight: 700;
  color: var(--text-primary);
}
.chart-tooltip .tt-label {
  color: var(--text-secondary);
}
.chart-tooltip .tt-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.page-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px 40px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .page-header { flex-direction: column; }
  .card { padding: 16px; }
}
