:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #647381;
  --line: #dbe3e8;
  --surface: #ffffff;
  --wash: #f3f7f8;
  --blue: #086f93;
  --blue-soft: #dff2f7;
  --amber: #b66b00;
  --amber-soft: #fff0d0;
  --red: #b54343;
  --red-soft: #fde5e5;
  --green: #287651;
  --green-soft: #e1f2e9;
  --shadow: 0 18px 55px rgba(34, 67, 84, 0.10);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 0 0, rgba(8, 111, 147, 0.10), transparent 33rem),
    linear-gradient(135deg, #f8fbfb 0%, #eef4f5 100%);
}
button { font: inherit; }
.shell { max-width: 1440px; margin: 0 auto; padding: 34px 30px 70px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 30px; }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; margin: 0 0 8px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 48px); line-height: 1; letter-spacing: -.045em; margin-bottom: 0; }
h2 { font-size: clamp(24px, 4vw, 36px); line-height: 1.05; letter-spacing: -.035em; }
h3 { font-size: 20px; margin-bottom: 3px; }
.topbar-meta { align-items: flex-end; display: flex; flex-direction: column; gap: 9px; }
.mono { font-family: "IBM Plex Mono", "SFMono-Regular", monospace; font-size: 12px; color: var(--muted); }
.pill { border-radius: 999px; display: inline-flex; padding: 6px 10px; font-size: 11px; font-weight: 700; }
.pill-muted { background: #e8eef0; color: #566773; }
.login-panel, .thermostat-card, .empty-state {
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(207, 220, 225, .92);
  box-shadow: var(--shadow);
}
.login-panel { max-width: 600px; padding: 48px; border-radius: 25px; }
.signal-mark { display: flex; align-items: flex-end; gap: 5px; height: 31px; margin-bottom: 28px; }
.signal-mark span { display: block; width: 7px; border-radius: 3px; background: var(--blue); }
.signal-mark span:nth-child(1) { height: 12px; opacity: .42; }
.signal-mark span:nth-child(2) { height: 22px; opacity: .68; }
.signal-mark span:nth-child(3) { height: 31px; }
.muted { color: var(--muted); }
.button { border: 0; border-radius: 10px; cursor: pointer; font-weight: 750; padding: 12px 16px; }
.button-primary { background: var(--blue); color: white; margin-top: 12px; }
.button-primary:hover { background: #075d7a; }
.error-text { color: var(--red); min-height: 20px; margin: 14px 0 0; font-size: 13px; }
.dashboard-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.tabs, .periods { display: flex; gap: 7px; flex-wrap: wrap; }
.tabs button, .period {
  border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.75);
  color: var(--muted); cursor: pointer; padding: 9px 13px; font-weight: 700;
}
.tabs button[aria-selected="true"], .period.is-active { background: var(--ink); color: white; border-color: var(--ink); }
.board-summary { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.status { border-radius: 999px; padding: 6px 11px; font-size: 12px; font-weight: 800; }
.status-connected { color: var(--green); background: var(--green-soft); }
.status-stale, .status-unknown { color: var(--amber); background: var(--amber-soft); }
.status-disconnected { color: var(--red); background: var(--red-soft); }
.thermostat-list { display: grid; gap: 18px; }
.room-row { min-width: 0; }
.room-heading { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px 2px; }
.room-heading h2 { font-size: 21px; margin: 0; }
.room-heading span { color: var(--muted); font-size: 12px; }
.room-thermostats { display: flex; gap: 16px; min-width: 0; overflow-x: auto; padding: 1px 2px 10px; scroll-snap-type: x proximity; }
.thermostat-card { border-radius: 18px; padding: 20px; overflow: hidden; flex: 0 0 min(560px, calc(100vw - 76px)); min-width: 420px; scroll-snap-align: start; }
.card-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.card-id { color: var(--muted); font-size: 12px; font-family: "IBM Plex Mono", monospace; }
.current-reading { color: var(--blue); font-size: 13px; font-weight: 800; margin-top: 7px; }
.relay-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 7px; }
.legend-item { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 22px; height: 4px; border-radius: 3px; background: var(--blue); }
.legend-swatch.relay { height: 9px; background: #f1b84b; border: 1px solid #d99b30; }
.device-links { margin: 0 0 12px; padding: 10px 12px; border-left: 3px solid #2563eb; background: #f1f6ff; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.device-links span { color: #475569; }
.device-links strong { color: #14263d; font-weight: 650; }
.chart-wrap { position: relative; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfd; overflow: hidden; }
.chart { display: block; width: 100%; height: 280px; }
.chart-note { display: flex; gap: 7px; flex-wrap: wrap; min-height: 27px; margin-top: 12px; }
.note { border-radius: 6px; padding: 5px 8px; font-size: 11px; font-weight: 700; background: var(--amber-soft); color: var(--amber); }
.note-red { background: var(--red-soft); color: var(--red); }
.note-diagnostic { background: var(--blue-soft); color: var(--blue); }
.empty-state { padding: 34px; border-radius: 18px; color: var(--muted); }
.chart-tooltip { position: fixed; z-index: 5; pointer-events: none; background: #17212b; color: white; border-radius: 8px; box-shadow: 0 8px 22px rgba(0,0,0,.18); padding: 9px 11px; font-size: 12px; line-height: 1.45; max-width: 260px; }
@media (max-width: 720px) {
  .shell { padding: 22px 14px 50px; }
  .topbar, .dashboard-toolbar, .board-summary, .card-header { align-items: flex-start; flex-direction: column; }
  .topbar-meta { align-items: flex-start; }
  .login-panel { padding: 30px 23px; }
  .periods { width: 100%; }
  .period { flex: 1; }
  .thermostat-card { padding: 15px; min-width: min(420px, calc(100vw - 30px)); flex-basis: min(420px, calc(100vw - 30px)); }
  .chart { height: 230px; }
}
