:root {
  --bg: #f4f5f7; --card: #ffffff; --text: #14181f; --muted: #6b7280; --line: #e3e6ea;
  --accent: #e8590c; --ok: #2f9e44; --bad: #c92a2a; --peak: #fff4e6; --peak-text: #a33f00;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f; --card: #1e242d; --text: #eef1f4; --muted: #9aa3ad; --line: #2c333d;
    --peak: #3a2412; --peak-text: #ffb27a;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
header h1 { font-size: 22px; margin: 0; flex: 1; }
main { padding: 0 16px 24px; max-width: 720px; margin: 0 auto; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--bad); }
button { font: inherit; color: inherit; cursor: pointer; }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: var(--peak); color: var(--peak-text); font-weight: 600; }
.banner.active { border: 2px solid var(--accent); }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.presets button {
  display: flex; flex-direction: column; align-items: center; padding: 14px 8px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card); font-weight: 600;
}
.presets small { color: var(--muted); font-weight: 400; }

.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.room { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.room.offline { opacity: .5; }
.room-head { display: flex; justify-content: space-between; align-items: center; min-height: 24px; }
.room-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-body { margin-top: 6px; }
.temp b { font-size: 34px; font-weight: 600; }
.temp small { margin-left: 4px; color: var(--muted); }
.setpoint { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.setpoint button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); font-size: 22px; line-height: 1;
}
.setpoint .sp { font-size: 18px; font-weight: 600; }

/* login + admin */
body.login main { max-width: 360px; padding-top: 12vh; }
form { display: grid; gap: 10px; margin: 12px 0; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text);
}
form button, .btn {
  padding: 11px 14px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font-weight: 600;
}
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.error { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h2 { margin-bottom: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.code { font: 600 28px ui-monospace, monospace; letter-spacing: 4px; }
