:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16191d;
  --muted: #646c78;
  --border: #e2e5ea;
  --accent: #6b4f3a;          /* coffee brown */
  --pass: #1a7f4b;
  --pass-bg: #e6f4ec;
  --warn: #8a6100;
  --warn-bg: #fdf3e0;
  --fail: #b3261e;
  --fail-bg: #fdeceb;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --card: #1c2025;
    --text: #e8eaed;
    --muted: #9aa3af;
    --border: #2c323a;
    --accent: #c79a72;
    --pass: #4ade80;
    --pass-bg: #14301f;
    --warn: #fbbf24;
    --warn-bg: #332708;
    --fail: #f87171;
    --fail-bg: #3a1614;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.inline { display: inline; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}
.topbar nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.linklike {
  background: none; border: none; padding: 0;
  color: var(--muted); cursor: pointer;
  font: inherit; font-size: 0.85rem; text-decoration: underline;
}

/* ----------------------------------------------------------------- rollup */

.rollup {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.rollup-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}
.rollup-n { font-size: 2rem; font-weight: 650; line-height: 1.1; }
.rollup-l { color: var(--muted); font-size: 0.85rem; }
.rollup-pass .rollup-n { color: var(--pass); }
.rollup-warn .rollup-n { color: var(--warn); }
.rollup-fail .rollup-n { color: var(--fail); }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.site-card { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.site-card.verdict-fail { border-left: 4px solid var(--fail); }
.site-card.verdict-warn { border-left: 4px solid var(--warn); }
.site-card.verdict-pass { border-left: 4px solid var(--pass); }

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-decoration: none;
}
.site-head h2 { margin: 0; font-size: 1.1rem; }
.site-head:hover h2 { text-decoration: underline; }

/* ------------------------------------------------------------- indicators */

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-pass { background: var(--pass-bg); color: var(--pass); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-fail { background: var(--fail-bg); color: var(--fail); }

.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
}
.dot-up { background: var(--pass); }
.dot-warn { background: var(--warn); }
.dot-down { background: var(--fail); }

/* ---------------------------------------------------------------- metrics */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
  margin: 0;
}
.metrics div { margin: 0; }
.metrics dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.metrics dd { margin: 0; }
.metric-big { font-size: 1.5rem; font-weight: 640; line-height: 1.2; }
.unit { font-size: 0.72rem; color: var(--muted); margin-left: 3px; font-weight: 400; }
.metric-small { font-size: 0.95rem; font-weight: 500; line-height: 1.2; }
/* A speed under its store's floor. Colour is a hint, not the only signal - the
   same shortfall is also spelled out in the site's Open issues list. */
.metric-bad { color: var(--fail); }

/* One block per WAN circuit, so a two-uplink store reads as two results rather
   than one ambiguous pair of numbers. */
.wan-speed + .wan-speed { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.wan-speed h3 { margin: 0 0 8px; font-size: 0.95rem; font-weight: 600; }

.wanline, .devices { font-size: 0.9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.reasons { margin: 0; padding-left: 18px; font-size: 0.88rem; }
.reasons.all-clear { padding: 0; color: var(--pass); font-weight: 550; }
.reason-fail { color: var(--fail); }
.reason-warn { color: var(--warn); }

.site-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.footnote { margin-top: 28px; max-width: 70ch; }

/* ----------------------------------------------------------------- tables */

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:last-child td { border-bottom: none; }

.crumbs { margin-bottom: 12px; font-size: 0.9rem; }
.site-hero { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; flex-wrap: wrap; }
.site-hero h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.02em; }

/* ------------------------------------------------------------------- auth */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; margin: 0; }
.auth-card h1 { margin: 0 0 4px; font-size: 1.3rem; }
.auth-card label { display: block; margin: 14px 0 5px; font-size: 0.85rem; font-weight: 600; }
.auth-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.auth-card button {
  width: 100%;
  margin-top: 18px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.auth-card button:hover { filter: brightness(1.08); }
.alert {
  background: var(--fail-bg);
  color: var(--fail);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin: 12px 0 0;
}
.empty { text-align: center; padding: 40px 20px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
