:root {
  --bg: #f6f8f5;
  --surface: #ffffff;
  --sunk: #eef1ed;
  --ink: #171a17;
  --muted: #5b625b;
  --line: #d7dcd5;
  --accent: #26596b;
  --pass: #2c7a54;
  --review: #8a6110;
  --fail: #ae3b29;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111412; --surface: #1a1e1b; --sunk: #151916;
    --ink: #e7ebe6; --muted: #98a198; --line: #2c322d;
    --accent: #74b4c8; --pass: #5fbe8b; --review: #d3a342; --fail: #de7160;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem clamp(1rem, 4vw, 2rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
}
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.spacer { flex: 1; }
.env {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.2rem 0.55rem;
  display: inline-flex;
  gap: 0.4rem;
  align-items: baseline;
}
/* Which portal is being acted on is the single most important thing to be
   sure of before approving anything, so it is stated, not implied. */
.env.sandbox {
  color: var(--review);
  border-color: var(--review);
  background: color-mix(in srgb, var(--review) 8%, transparent);
}
.env.prod {
  color: var(--fail);
  border-color: var(--fail);
  background: color-mix(in srgb, var(--fail) 10%, transparent);
  font-weight: 700;
}
.env b { color: var(--ink); font-weight: 600; }
.env .pid { color: var(--muted); }

/* ---- poller ring ---- */
.poller {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.85rem 1rem;
}
.ring { position: relative; width: 76px; height: 76px; flex: none; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .track { stroke: var(--line); }
.ring .bar {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.ring .count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.ring.off .bar { stroke: var(--muted); }
.ring.busy .bar { stroke: var(--pass); }
.poller-facts { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.84rem; }
.poller-facts .head { font-weight: 600; }
.poller-facts .sub { color: var(--muted); font-size: 0.8rem; }
.poller-facts .sub b { color: var(--ink); font-weight: 600; }

/* ---- check legend ---- */
/* The S/L/A/T column is only readable if the letters are spelled out
   somewhere on the same screen. */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: var(--sunk);
}
.legend b {
  font-family: var(--mono);
  color: var(--ink);
  font-weight: 600;
  margin-right: 0.15rem;
}
.legend-title {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.legend-sep { flex: 1; min-width: 0; }
.legend .swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 1px solid;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: baseline;
}
.legend .swatch.pass { border-color: var(--pass); background: color-mix(in srgb, var(--pass) 25%, transparent); }
.legend .swatch.review { border-color: var(--review); background: color-mix(in srgb, var(--review) 25%, transparent); }
.legend .swatch.fail { border-color: var(--fail); background: color-mix(in srgb, var(--fail) 25%, transparent); }
.legend .swatch.none { border-color: var(--line); }

/* The legend sits directly on top of the table. */
.legend + .card { border-radius: 0 0 3px 3px; }

/* ---- notices ---- */
/* Whether these messages are actually reaching franchisees is the one fact a
   reader must not have to infer, so it is stated at the top of the page. */
.banner {
  font-size: 0.85rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 3px;
  background: var(--surface);
}
.banner.live { border-left-color: var(--fail); }
.banner.dry { border-left-color: var(--review); }
.banner.off { border-left-color: var(--line); color: var(--muted); }

.notice { border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.notice > summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-size: 0.86rem;
}
.notice > summary:hover { background: var(--sunk); }
.notice > summary::marker { color: var(--muted); }
.notice .kind { font-size: 0.72rem; color: var(--muted); }
.notice .to { color: var(--muted); white-space: nowrap; }
.notice .subj {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.notice .when { font-size: 0.75rem; white-space: nowrap; }
.notice-body { padding: 0 0.85rem 0.9rem; }
.notice-body .meta { font-size: 0.74rem; margin-bottom: 0.5rem; }
.notice-body pre { white-space: pre-wrap; }

.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.4rem;
  border: 1px solid;
  border-radius: 2px;
}
.badge.on { color: var(--pass); border-color: var(--pass); }
.badge.off { color: var(--muted); border-color: var(--line); }
.quiet { color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.quiet:hover { color: var(--ink); }

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.25rem) clamp(1rem, 4vw, 2rem) 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

h1 { font-size: 1.35rem; margin: 0; letter-spacing: -0.01em; }
h2 {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

/* ---- stat tiles ---- */
.tiles { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.85rem 1rem;
}
.tile .n {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.tile .k {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tile.pass .n { color: var(--pass); }
.tile.review .n { color: var(--review); }
.tile.fail .n { color: var(--fail); }

/* ---- tables ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--sunk); }
td.mono, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.dim { color: var(--muted); }

/* ---- verdict pills ---- */
.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 0.16rem 0.45rem;
  border-radius: 2px;
  border: 1px solid;
  white-space: nowrap;
}
.pill.PASS { color: var(--pass); border-color: var(--pass); }
.pill.FAIL { color: var(--fail); border-color: var(--fail); }
.pill.NEEDS_REVIEW, .pill.AMBIGUOUS { color: var(--review); border-color: var(--review); }
.pill.none { color: var(--muted); border-color: var(--line); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--pass); }
.dot.bad { background: var(--fail); }

/* ---- buttons / forms ---- */
button, .btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { opacity: 0.9; color: #fff; }
button[disabled] { opacity: 0.5; cursor: default; }

input[type=text], input[type=password], select {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}
input:focus, button:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

pre {
  font-family: var(--mono);
  font-size: 0.78rem;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.85rem;
  overflow-x: auto;
  margin: 0;
}

.empty { padding: 2rem; text-align: center; color: var(--muted); font-size: 0.9rem; }
.note { font-size: 0.82rem; color: var(--muted); margin: 0; }

/* ---- login ---- */
.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1.75rem;
  width: min(22rem, 90vw);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.login h1 { font-family: var(--mono); font-size: 1.05rem; }
.error {
  font-size: 0.83rem;
  color: var(--fail);
  border-left: 2px solid var(--fail);
  padding-left: 0.6rem;
}
