/* Shared by index.html (dashboard) and status.html (diagnostics). One file,
   no build step - the pages differ in content, not in look. */

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --fg: #e8edf5;
  --muted: #8a97ab;
  --accent: #4fb0ff;
  --accent-dim: rgba(79, 176, 255, 0.18);
  --stale: #ff6b5e;
  --ok: #4fd48a;
  --warn: #ffc86b;
  --card: #121b2e;
  --line: #22304a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 3rem;
  gap: 1.25rem;
}

.page {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
}

.card {
  background: var(--card);
  border-radius: 1rem;
  padding: 1.5rem;
}

.card h2 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
}

.eyebrow {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---- live reading ---- */

.live {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
}

@media (max-width: 520px) {
  .live {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
}

.speed {
  font-size: 3.75rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 0.35rem 0 0.15rem;
}

.speed-secondary {
  font-size: 0.95rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.beaufort {
  margin-top: 0.6rem;
  font-size: 0.95rem;
  color: var(--fg);
}

.unit-toggle {
  margin-top: 0.9rem;
  display: inline-flex;
  gap: 0.4rem;
}

button {
  font: inherit;
  cursor: pointer;
}

.unit-toggle button,
.chip {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
}

.unit-toggle button[aria-pressed='true'],
.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #051422;
  font-weight: 600;
}

/* ---- compass ---- */

.compass {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.compass svg {
  width: 190px;
  height: 190px;
}

.compass-arrow {
  transition: transform 400ms ease;
  transform-origin: 100px 100px;
}

.compass-label {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
}

.compass-name {
  font-size: 0.9rem;
  color: var(--muted);
}

.age {
  margin-top: 1.1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.age.stale {
  color: var(--stale);
  font-weight: 600;
}

/* ---- time range control ---- */

.timerange {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.timerange .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.timerange .resolution {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.timerange select {
  font: inherit;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 320px;
}

.chart-wrap.short {
  height: 200px;
}

canvas {
  width: 100%;
  height: 100%;
}

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

/* ---- diagnostics ---- */

.kv {
  display: grid;
  grid-template-columns: minmax(9rem, auto) 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.9rem;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid currentColor;
}

.badge.ok {
  color: var(--ok);
}

.badge.warn {
  color: var(--warn);
}

.badge.bad {
  color: var(--stale);
}

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

/* 50 raw readings is ~2000px of page. Keep the data reachable without letting
   it push the rest of the diagnostics off the screen. */
.table-wrap.scroll {
  max-height: 24rem;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(34, 48, 74, 0.5);
}

tbody tr:hover {
  background: var(--accent-dim);
}

/* ---- footer ---- */

.note {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

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

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  font-size: 0.85rem;
}
