:root {
  color-scheme: light dark;
  --accent: #2871cc;
  --accent-2: #ba641e;
  --co2: #138374;
  --rh: #8858b0;
  --fg: #24282c;
  --fg-muted: #667078;
  --bg: #f6f7f8;
  --surface: #fff;
  --border: #dfe4e8;
  --subtle: #edf0f2;
  --selected: #e9f1fc;
  --ok: #18835b;
  --warn: #a87113;
  --stale: #b54946;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #72acfa;
    --accent-2: #e7a769;
    --co2: #5ec7b0;
    --rh: #bf9bdf;
    --fg: #e4e7e9;
    --fg-muted: #a0a8af;
    --bg: #17191b;
    --surface: #1d2023;
    --border: #353a3f;
    --subtle: #272b2f;
    --selected: #263449;
    --ok: #69c99d;
    --warn: #e5b960;
    --stale: #ef9186;
  }
}
* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 system-ui, -apple-system, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 14px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: 36px; height: 36px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; color: var(--fg-muted); }
.icon-btn:hover:not(:disabled) { color: var(--fg); background: var(--subtle); }
.icon-btn.compact { border-color: transparent; background: transparent; width: 30px; height: 32px; }
.app-header { height: 66px; padding: 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-size: 17px; font-weight: 650; }
.brand-icon { color: var(--co2); width: 23px; height: 23px; }
.app-actions { display: flex; gap: 20px; align-items: center; }
.header-caption { color: var(--fg-muted); font-size: 12px; }
.layout { max-width: 1560px; margin: 0 auto; display: grid; grid-template-columns: 206px minmax(0, 1fr); }
.rail { padding: 32px 16px; align-self: stretch; border-right: 1px solid var(--border); }
.rail-heading { display: flex; justify-content: space-between; padding: 0 12px; margin-bottom: 14px; color: var(--fg-muted); }
.rail-heading h2 { font-size: 12px; }
#sensor-count { font-size: 12px; font-variant-numeric: tabular-nums; }
.sensor-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.sensor-btn { display: flex; gap: 10px; width: 100%; align-items: center; text-align: left; padding: 12px; border: 1px solid transparent; border-radius: 6px; background: transparent; line-height: 1.4; }
.sensor-btn:hover { background: var(--subtle); }
.sensor-btn.active { background: var(--selected); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.sensor-btn > .icon { color: var(--fg-muted); }
.sensor-btn.active > .icon { color: var(--accent); }
.sensor-copy { min-width: 0; flex: 1; }
.sensor-btn .id { display: block; font-weight: 600; overflow-wrap: anywhere; }
.sensor-btn .age { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--fg-muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.age::before, .status::before { content: ''; width: 6px; height: 6px; flex: 0 0 auto; background: var(--fg-muted); border-radius: 50%; }
[data-state="ok"]::before { background: var(--ok); }
[data-state="warn"]::before { background: var(--warn); }
[data-state="stale"]::before { background: var(--stale); }
.rail-empty { color: var(--fg-muted); padding: 12px; font-size: 13px; }
main { min-width: 0; padding: 30px 36px 20px; }
.room-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.room-header > div:first-child { min-width: 0; }
.muted { color: var(--fg-muted); font-size: 12px; margin-top: 7px; }
.room-actions { display: flex; gap: 14px; align-items: center; flex: 0 0 auto; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--fg-muted); font-size: 12px; white-space: nowrap; }
.status[data-state="ok"] { color: var(--ok); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 30px; }
.metric { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 16px 18px 14px; }
.label { color: var(--fg-muted); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.swatch { height: 7px; width: 7px; flex: 0 0 auto; border-radius: 2px; background: var(--accent); }
[data-color="scd"] .swatch { background: var(--accent-2); }
[data-color="co2"] .swatch { background: var(--co2); }
[data-color="rh"] .swatch { background: var(--rh); }
.value { font-size: 30px; font-weight: 600; margin: 5px 0 1px; line-height: 1.3; white-space: nowrap; font-variant-numeric: tabular-nums; }
.unit { font-size: 14px; font-weight: 400; margin-left: 5px; color: var(--fg-muted); }
.value.long-value { font-size: 24px; }
.metric-detail { font-size: 11px; color: var(--fg-muted); }
.history-heading { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 14px; }
.history-heading h2 { font-size: 16px; }
.signal { color: var(--fg-muted); font-size: 11px; display: flex; gap: 6px; align-items: center; }
.signal .icon { width: 14px; height: 14px; }
.controls { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 12px; }
.presets { display: flex; background: var(--subtle); padding: 3px; border-radius: 6px; gap: 2px; }
.presets button { background: transparent; border: 1px solid transparent; padding: 5px 14px; border-radius: 4px; font-size: 12px; font-weight: 500; min-height: 30px; }
.presets button:hover { color: var(--accent); }
.presets button.active { color: var(--fg); background: var(--surface); border-color: var(--border); box-shadow: 0 1px 2px #00000008; }
.date-controls { display: flex; gap: 8px; align-items: center; }
.day-wrap { display: flex; align-items: center; padding: 0 10px; gap: 8px; height: 36px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--fg-muted); }
.day-wrap input { border: 0; background: transparent; font-size: 12px; min-width: 0; width: 127px; padding: 0; }
.day-wrap .icon { width: 15px; height: 15px; }
.range-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; padding: 12px 0 14px; }
.range-navigation { display: flex; align-items: center; gap: 3px; margin-left: -8px; min-width: 0; }
#range-label { font-size: 12px; font-weight: 500; text-align: center; }
.meta { font-size: 11px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.chart-section { min-width: 0; padding: 18px 0 20px; border-top: 1px solid var(--border); }
.temperature { grid-column: 1 / -1; }
.chart-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; min-height: 24px; gap: 8px 12px; margin-bottom: 15px; }
.chart-heading h3 { display: flex; align-items: center; gap: 8px; }
.chart-heading .icon { color: var(--fg-muted); width: 16px; height: 16px; }
.chart-unit { color: var(--fg-muted); font-size: 11px; font-weight: 400; }
.series-controls { display: flex; gap: 14px; }
.temperature-controls { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.trend-control { display: flex; align-items: center; gap: 8px; color: var(--fg-muted); font-size: 11px; }
.trend-control select { width: 144px; height: 32px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--fg); }
.series-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 4px 0; color: var(--fg-muted); background: transparent; font-size: 11px; }
.series-toggle[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.line-key { display: inline-block; width: 14px; height: 2px; background: var(--accent); }
.scd-key { background: var(--accent-2); }
.chart-wrap { height: 222px; position: relative; }
.temperature .chart-wrap { height: 248px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-content: center; padding: 24px; text-align: center; color: var(--fg-muted); font-size: 13px; background: color-mix(in srgb, var(--bg) 90%, transparent); }
.chart-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; font-size: 11px; color: var(--fg-muted); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: color-mix(in srgb, var(--stale) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--stale) 30%, transparent); padding: 10px 14px; border-radius: 6px; margin-bottom: 18px; color: var(--stale); font-size: 13px; }
.text-btn { background: transparent; border: 0; color: inherit; text-decoration: underline; padding: 6px; }
#pin-modal { border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 8px; width: 340px; max-width: calc(100% - 32px); padding: 28px; }
#pin-modal::backdrop { background: #13181f99; backdrop-filter: blur(3px); }
.lock-icon { color: var(--co2); width: 26px; height: 26px; margin-bottom: 14px; }
#pin-modal h2 { font-size: 20px; margin-bottom: 20px; }
#pin-modal label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--fg-muted); }
#pin-input { width: 100%; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); padding: 10px; font-size: 22px; text-align: center; }
#pin-error { color: var(--stale); display: block; font-size: 12px; min-height: 30px; padding-top: 6px; }
.submit { display: block; width: 100%; border: 0; border-radius: 5px; background: var(--co2); color: var(--surface); font-weight: 600; padding: 11px; }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 178px minmax(0, 1fr); }
  main { padding: 26px 24px 20px; }
  .rail { padding: 28px 10px; }
  .metric { padding: 14px 12px; }
  .value { font-size: 27px; }
}
@media (max-width: 800px) {
  .app-header { height: 58px; padding: 0 20px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 20px; }
  .rail-heading { display: none; }
  .sensor-list { flex-direction: row; overflow-x: auto; }
  .sensor-list li { min-width: 145px; flex: 1; }
  .sensor-btn { padding: 9px 12px; }
  main { padding: 24px 20px 18px; }
  .charts { column-gap: 20px; }
}
@media (max-width: 540px) {
  .header-caption { display: none; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 26px; }
  .metric { padding: 14px 16px; }
  .value { font-size: 30px; }
  .room-header { align-items: flex-start; margin-bottom: 20px; }
  h1 { font-size: 25px; }
  .room-actions { gap: 8px; padding-top: 1px; }
  .status { font-size: 11px; }
  .controls { gap: 10px; }
  .presets { width: 100%; }
  .presets button { flex: 1; padding: 6px 0; min-width: 0; }
  .date-controls { width: 100%; }
  .day-wrap { flex: 1; }
  .day-wrap input { flex: 1; }
  .range-row { padding-bottom: 12px; }
  .meta { padding-left: 1px; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .chart-heading { gap: 10px; }
  .temperature .chart-heading { align-items: flex-start; }
  .series-controls { gap: 10px; }
  .temperature-controls { width: 100%; justify-content: space-between; }
  .trend-control { margin-left: auto; }
  .chart-wrap, .temperature .chart-wrap { height: 215px; }
  .chart-footer { font-size: 10px; }
}
