:root {
  --bg-primary:      #0f1117;
  --bg-secondary:    #1a1d27;
  --bg-card:         #22263a;
  --bg-card-hover:   #272b40;
  --text-primary:    #e8eaf0;
  --text-muted:      #8892a4;
  --border:          #2a2f45;
  --accent-upper:    #4a9eff;
  --accent-lower:    #4caf7d;
  --band-upper:      rgba(74, 158, 255, 0.12);
  --band-lower:      rgba(76, 175, 125, 0.12);
  --warning-delayed: #f5a623;
  --warning-stale:   #e74c3c;
  --radius:          10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Staleness banner ────────────────────────────────────── */
.banner {
  padding: 0.8rem 2rem;
  font-weight: 500;
  text-align: center;
  font-size: 0.95rem;
}

.banner.delayed { background: var(--warning-delayed); color: #1a1200; }
.banner.stale   { background: var(--warning-stale);   color: #fff; font-size: 1rem; }

/* ── Layout ──────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.hidden { display: none !important; }

.section {
  margin-bottom: 2.5rem;
}

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

/* ── No-data state ───────────────────────────────────────── */
.no-data-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
}

.no-data-card .muted { color: var(--text-muted); margin-top: 0.5rem; font-size: 0.9rem; }

/* ── Current readings ────────────────────────────────────── */
.readings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}

.reading-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  border-left: 4px solid transparent;
  transition: background 0.15s;
}

.reading-card:hover { background: var(--bg-card-hover); }
.reading-card.upper { border-left-color: var(--accent-upper); }
.reading-card.lower { border-left-color: var(--accent-lower); }

.sensor-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.sensor-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.sensor-value {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.reading-card.upper .sensor-value { color: var(--accent-upper); }
.reading-card.lower .sensor-value { color: var(--accent-lower); }

.sensor-unit {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.last-updated {
  margin-top: 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Charts ──────────────────────────────────────────────── */
.chart-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  height: 320px;
  position: relative;
}

.chart-wrapper canvas {
  max-height: 100%;
}

/* ── About ───────────────────────────────────────────────── */
.about {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
}

.about p {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 70ch;
}

/* ── Footer ──────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem 2rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  header { padding: 1.2rem 1rem; }
  header h1 { font-size: 1.25rem; }
  main { padding: 1.25rem 1rem; }
  .sensor-value { font-size: 2.4rem; }
  .chart-wrapper { height: 260px; }
}
