:root {
  color-scheme: light dark;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6b6a66;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-dustbunny: #2a78d6;
  --series-discord: #eb6834;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --nodata: #e1e0d9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #a3a29b;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-dustbunny: #3987e5;
    --series-discord: #d95926;
    --nodata: #2c2c2a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px max(16px, env(safe-area-inset-right)) 48px
    max(16px, env(safe-area-inset-left));
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.top,
main,
.error {
  max-width: 1040px;
  margin-inline: auto;
}

.top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

.sub,
.muted {
  color: var(--muted);
}

.sub {
  margin: 2px 0 0;
}

.who {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  text-align: right;
}

#user {
  color: var(--text-2);
}

.error {
  margin-bottom: 16px;
  padding: 10px 14px;
  border: 1px solid var(--critical);
  border-radius: 8px;
  background: var(--surface);
}

main {
  display: grid;
  gap: 16px;
  transition: opacity 0.15s;
}

main.loading {
  opacity: 0.6;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.card,
.panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.key {
  flex: none;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.card .sub {
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.badge svg {
  width: 16px;
  height: 16px;
}

.detail {
  margin: 12px 0 0;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 0;
}

.stats dt {
  color: var(--muted);
  font-size: 12px;
}

.stats dd {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.facts {
  margin: 14px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--grid);
  color: var(--text-2);
  list-style: none;
}

.facts li + li {
  margin-top: 4px;
}

.facts a {
  color: inherit;
}

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.seg button {
  min-width: 52px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
}

.seg button:hover {
  background: var(--grid);
}

.seg button[aria-pressed='true'] {
  background: var(--text);
  color: var(--surface);
  font-weight: 600;
}

.seg button:focus-visible,
summary:focus-visible,
.chart svg:focus-visible,
.strip:focus-visible {
  outline: 2px solid var(--series-dustbunny);
  outline-offset: 2px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0 0 8px;
  color: var(--text-2);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.legend i.sw {
  height: 10px;
  border-radius: 2px;
}

.chart {
  position: relative;
}

.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart text {
  fill: var(--muted);
  font-size: 11px;
}

.chart .label {
  fill: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.table-view {
  margin-top: 12px;
}

summary {
  color: var(--text-2);
  cursor: pointer;
}

.scroll {
  max-height: 280px;
  margin-top: 8px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 500;
}

.num {
  text-align: right;
}

.tl {
  margin-bottom: 14px;
}

.tl-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  color: var(--text-2);
  font-weight: 600;
}

.tl-head span:last-child {
  color: var(--muted);
  font-weight: 400;
}

.strip {
  display: flex;
  gap: 1px;
  height: 30px;
}

.strip b {
  flex: 1;
  min-width: 1px;
  border-radius: 1px;
}

.strip b:hover {
  outline: 2px solid var(--text);
  outline-offset: -1px;
}

.up {
  background: var(--good);
}
.degraded {
  background: var(--warning);
}
.down {
  background: var(--critical);
}
.nodata {
  background: var(--nodata);
}

.tip {
  position: fixed;
  z-index: 10;
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  font-size: 12px;
}

.tip .when {
  margin-bottom: 4px;
  color: var(--muted);
}

.tip .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tip .row i {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.tip .row b {
  margin-left: auto;
  padding-left: 12px;
  font-size: 13px;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .stats dd {
    font-size: 18px;
  }
}
