[hidden] { display: none !important; }
:root {
  --bg: #f4f1ea; --ink: #1b1b1b; --muted: #5d5a52; --card: #fff; --line: #d9d3c6;
  --brand: #1f3b2d; --ok: #2e7d32; --warm: #c77700; --hot: #c62828; --unk: #6b6f76; --blue: #1d5fa8;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Phones: no double-tap zoom on controls (pinch-zoom stays on for accessibility), and form fields are
   at least 16px so iPhone Safari does not zoom in when one is focused. More specific rules may go bigger. */
a, button, input, select, textarea, label, summary, [role="button"], .btn { touch-action: manipulation; }
input, select, textarea { font-size: 16px; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--brand); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 1.25rem; margin: 0; }
.top nav { display: flex; gap: 14px; align-items: center; }
.top nav a, .link { color: #fff; font-size: 1rem; background: none; border: 0; padding: 8px 0; text-decoration: underline; cursor: pointer; }

.banner { margin: 10px 12px 0; padding: 14px 16px; border-radius: 10px; font-size: 1.05rem; }
.banner strong { display: block; font-size: 1.2rem; letter-spacing: .02em; }
.banner.alert { background: var(--hot); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.banner.offline { background: #3a3d42; color: #fff; border-left: 8px solid #f2c94c; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(198,40,40,.25); } }
@media (prefers-reduced-motion: reduce) { .banner.alert { animation: none; } }
.badge-dry { margin: 10px 12px 0; padding: 8px 12px; border-radius: 8px; background: #fff3cd; border: 1px dashed #b88a00; color: #5c4400; font-size: .9rem; font-weight: 600; }

.status { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 10px 16px 0; color: var(--muted); font-size: .9rem; }
.status b { color: var(--ink); font-weight: 600; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1050px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card { background: var(--card); border: 1px solid var(--line); border-top: 10px solid var(--ok); border-radius: 12px; padding: 12px 14px 14px; }
.card.warm { border-top-color: var(--warm); }
.card.hot { border-top-color: var(--hot); background: #fff5f5; border-color: var(--hot); border-width: 3px; border-top-width: 10px; }
.card.na { border-top-color: var(--unk); }
.card.stale { opacity: .55; filter: grayscale(.8); }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card h2 { margin: 0; font-size: 1.2rem; }
.temp { display: flex; align-items: baseline; gap: 4px; margin: 2px 0 6px; }
.temp .num { font-size: 4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.temp .unit { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.card.hot .temp .num { color: var(--hot); }
.card.warm .temp .num { color: #8a5200; }
.bar { position: relative; height: 10px; background: #ece7dc; border-radius: 6px; overflow: visible; }
.bar .fill { height: 100%; background: var(--ok); border-radius: 6px; }
.card.warm .bar .fill { background: var(--warm); }
.card.hot .bar .fill { background: var(--hot); }
.bar .mark { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--hot); }
.sub { color: var(--muted); font-size: .85rem; margin-top: 6px; }

.pill { font-weight: 800; font-size: .85rem; padding: 4px 10px; border-radius: 999px; }
.pill.hot { background: var(--hot); color: #fff; }

.blower { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.blower h3 { margin: 0 0 8px; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fact { display: flex; flex-direction: column; gap: 4px; }
.fact .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chip { display: inline-block; text-align: center; font-weight: 800; padding: 6px 6px; border-radius: 8px; font-size: .95rem; }
.chip.on { background: #d8f0da; color: #1b5e20; }
.chip.off { background: #ebe8e1; color: #444; }
.chip.unk { background: #e6e8ec; color: #3d4148; border: 1px dashed #8a8f98; font-weight: 700; }
.chip.mode-auto { background: #dbe8f8; color: var(--blue); }
.chip.mode-manual { background: #ffe8c7; color: #8a4b00; }
.chip.mode-unknown { background: #e6e8ec; color: #3d4148; }

.seg { display: grid; grid-template-columns: 1fr 1fr; margin-top: 12px; border: 2px solid var(--brand); border-radius: 10px; overflow: hidden; }
.seg-btn { min-height: 52px; font-size: 1.05rem; font-weight: 800; border: 0; background: #fff; color: var(--brand); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 2px solid var(--brand); }
.seg-btn.active { background: var(--brand); color: #fff; }
.seg-btn:disabled { cursor: default; }
.seg-btn:not(.active):disabled { color: #9a9a9a; background: #f1f1f1; }
.seg-btn:not(:disabled):active { background: #e3ece6; }

.legend { color: var(--muted); font-size: .85rem; padding: 0 16px 24px; }

dialog { border: 0; border-radius: 14px; padding: 20px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.5); }
.confirm-text { font-size: 1.15rem; font-weight: 600; white-space: pre-line; margin-top: 0; }
.row { display: flex; gap: 10px; justify-content: flex-end; }
.btn { min-height: 48px; padding: 0 18px; border-radius: 10px; font-size: 1rem; font-weight: 700; cursor: pointer; border: 2px solid var(--brand); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.secondary { background: #fff; color: var(--brand); }

.toast { position: fixed; left: 12px; right: 12px; bottom: 16px; padding: 14px 16px; border-radius: 10px; background: #222; color: #fff; font-weight: 600; z-index: 20; pointer-events: none; }
.toast.good { background: var(--ok); } .toast.bad { background: var(--hot); } .toast.warn { background: #8a6d00; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(100%, 360px); display: grid; gap: 14px; }
.login-card h1 { margin: 0; color: var(--brand); }
.login-card label { display: grid; gap: 6px; font-weight: 600; }
.login-card input { font-size: 1.1rem; padding: 12px; border: 1px solid #bbb; border-radius: 8px; }
.login-card form { display: grid; gap: 14px; }
.faceid-btn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 72px; font-size: 1.25rem; border-radius: 14px; }
.faceid-icon { width: 34px; height: 34px; flex: none; }
.passkey-box { display: grid; gap: 8px; }
.passkey-box .hint { margin: 0; color: var(--muted, #666); font-size: .9rem; text-align: center; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted, #666); font-size: .9rem; margin: 6px 0 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
/* My sign-in page + home Face ID banner */
.acct { padding: 12px 16px 32px; display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.acct h2 { margin: 8px 0 0; }
.acct .card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 10px; }
.acct .muted, .admin-pk .muted, .pk-meta { color: var(--muted, #666); font-size: .92rem; margin: 0; }
.pk-list { display: grid; gap: 10px; }
.pk { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--brand); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.pk.revoked { border-left-color: #aaa; opacity: .75; }
.pk-name { font-weight: 700; font-size: 1.1rem; }
.pk .row { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-banner { margin: 0 16px 4px; background: #eef6f0; border: 1px solid #b9d6c2; border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; }
.setup-banner p { margin: 0; }
.setup-banner .row { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-pk { display: grid; gap: 6px; margin-top: 6px; }
.admin-pk .pk { padding: 8px 10px; }
.err { color: var(--hot); min-height: 1.2em; margin: 0; font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px 0; }
.filters label { display: flex; gap: 6px; align-items: center; min-height: 40px; }
.log { padding: 12px; display: grid; gap: 8px; }
.entry { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--brand); border-radius: 8px; padding: 10px 12px; }
.entry.dry { border-left-color: #b88a00; }
.entry.t-temp_alert, .entry.t-device_offline, .entry.t-login_failed { border-left-color: var(--hot); }
.entry .when { color: var(--muted); font-size: .85rem; }
.entry .what { font-weight: 700; }
.entry .detail { color: var(--muted); font-size: .9rem; word-break: break-word; }
.entry pre { white-space: pre-wrap; word-break: break-all; font-size: .8rem; background: #f6f6f6; padding: 8px; border-radius: 6px; max-height: 160px; overflow: auto; }
.empty { color: var(--muted); padding: 12px; }

/* ---- shared additions ---- */
.top-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-left h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .home { font-size: 1.6rem; text-decoration: none; line-height: 1; padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,.12); }
.hello { padding: 14px 16px 0; margin: 0; font-size: 1.1rem; font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; align-items: center; gap: 2px 12px; padding: 18px; background: #fff; border: 1px solid var(--line); border-left: 10px solid var(--brand); border-radius: 12px; text-decoration: none; min-height: 92px; }
.tile-icon { grid-row: span 2; font-size: 2.4rem; text-align: center; }
.tile-title { font-size: 1.3rem; font-weight: 800; }
.tile-desc, .tile-badge { color: var(--muted); font-weight: 600; }
.tile.lvl-alert { border-left-color: var(--hot); } .tile.lvl-alert .tile-badge { color: var(--hot); }
.tile.lvl-warn { border-left-color: var(--warm); } .tile.lvl-warn .tile-badge { color: #8a5200; }
.tile.lvl-ok { border-left-color: var(--ok); }

.title-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill.regime { background: #e9e4f5; color: #4a2f86; }
.pill.regime.r1 { background: #fde9cf; color: #7a4100; }
.pill.regime.r2 { background: #ffd9d2; color: #8f1d0b; }
.pill.regime.r3 { background: #d9ecf7; color: #134b6e; }
.pill.empty { background: #e6e8ec; color: #3d4148; border: 1px dashed #8a8f98; }
.card.inactive { border-top-color: #9aa0a6; background: #f5f5f3; }
.card.inactive .temp .num { color: #8a8f98; font-size: 2.6rem; }
.trend { margin-top: 8px; }
.spark { width: 100%; height: 46px; display: block; background: #faf8f3; border-radius: 6px; }
.spark-line { fill: none; stroke: #1f3b2d; stroke-width: 2; vector-effect: non-scaling-stroke; }
.card.hot .spark-line { stroke: var(--hot); }
.spark-alert { stroke: var(--hot); stroke-dasharray: 4 4; stroke-width: 1; vector-effect: non-scaling-stroke; }
.trend-label { font-size: .8rem; color: var(--muted); }
.admin-row { margin-top: 8px; justify-content: stretch; } .admin-row .btn { flex: 1; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 12px 0 0; font-size: .9rem; cursor: pointer; }
.field { display: grid; gap: 6px; margin: 0 0 14px; font-weight: 600; }
.field input, .field select, .field textarea { font: inherit; font-size: 1.05rem; padding: 12px; border: 1px solid #bbb; border-radius: 8px; background: #fff; width: 100%; }
.field textarea { min-height: 110px; resize: vertical; }

/* ---- Home: big buttons; section menus ---- */
.sections { display: grid; grid-template-columns: 1fr; gap: 14px; padding: 12px; }
@media (min-width: 640px) { .sections { grid-template-columns: repeat(2, 1fr); } }
.bigbtn { position: relative; display: grid; grid-template-columns: 72px 1fr 24px; grid-template-rows: auto auto; align-items: center; gap: 2px 12px;
  padding: 22px 16px; min-height: 120px; background: #fff; border: 1px solid var(--line); border-left: 12px solid var(--brand); border-radius: 16px;
  text-decoration: none; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.bigbtn:active { transform: scale(.99); }
.big-icon { grid-row: span 2; font-size: 3rem; text-align: center; }
.big-title { font-size: 1.6rem; font-weight: 800; }
.big-status { grid-column: 2; color: var(--muted); font-weight: 600; font-size: 1.02rem; }
.big-arrow { grid-column: 3; grid-row: 1 / span 2; font-size: 2rem; color: var(--muted); }
.bigbtn.lvl-alert { border-left-color: var(--hot); } .bigbtn.lvl-alert .big-status { color: var(--hot); }
.bigbtn.lvl-warn { border-left-color: var(--warm); } .bigbtn.lvl-warn .big-status { color: #8a5200; }
.bigbtn.lvl-ok { border-left-color: var(--ok); }
.backbar { display: block; padding: 12px 16px 4px; font-weight: 700; font-size: 1.05rem; color: var(--brand); text-decoration: none; }
.section-menu { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 8px 12px 20px; }
@media (min-width: 640px) { .section-menu { grid-template-columns: repeat(2, 1fr); } }
.coming-soon { background: #fff; border: 2px dashed var(--line); border-radius: 16px; padding: 32px 20px; text-align: center; color: var(--muted); font-size: 1.15rem; font-weight: 600; }
.cs-icon { font-size: 3rem; margin-bottom: 8px; }

/* Offline mode: banner under the header, locked blower controls, review dialog, offline fallback page */
.netbar { margin: 8px 12px 0; padding: 10px 14px; border-radius: 10px; background: #eef3f7; border-left: 6px solid #5b7fa3; display: grid; gap: 4px; font-size: .98rem; }
.netbar.off { background: #3a3d42; color: #fff; border-left-color: #f2c94c; }
.netbar strong { font-size: 1.08rem; }
.netbar .nb-count { font-weight: 700; }
.netbar .nb-failed { color: var(--hot); font-weight: 700; }
.netbar.off .nb-failed { color: #ffb4a8; }
.netbar .link { color: inherit; text-decoration: underline; padding: 0; }
.netbar a { color: inherit; }
.login-card .netbar { margin: 0 0 12px; }
.lock-note { margin: 8px 0 0; padding: 8px 10px; background: #fff4d6; border-radius: 8px; font-size: .92rem; color: #5a4600; }
dialog.review .review-item { border-top: 1px solid #ddd; padding: 10px 0; display: grid; gap: 4px; }
dialog.review .row { display: flex; gap: 8px; }
.offline-page { max-width: 480px; margin: 40px auto; padding: 0 20px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* "View as" preview (admin) */
.viewbar { position: sticky; top: 0; z-index: 7; height: 46px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; background: #f2c94c; color: #1d1d1d; font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; border-bottom: 2px solid #b8901a; }
.viewbar-back { background: #1d1d1d; color: #fff; border: 0; border-radius: 8px; padding: 7px 10px; font-weight: 700; font-size: .95rem; cursor: pointer; flex: none; }
.viewbar-switch { color: #1d1d1d; font-weight: 600; text-decoration: underline; padding: 8px 2px; flex: none; }
body.previewing .top { top: 46px; }
.viewswitch { margin: 8px 12px 4px; padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid #d9d4c7; }
.viewswitch-title { font-weight: 700; margin-bottom: 8px; }
.viewswitch .chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.viewswitch .chipbtn { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--brand); background: #fff; color: var(--brand); font-weight: 700; font-size: 1rem; cursor: pointer; }
.viewswitch .chipbtn.on { background: var(--brand); color: #fff; }
.viewswitch.compact .chips { gap: 6px; flex-wrap: nowrap; }
.viewswitch.compact .chipbtn { min-height: 40px; padding: 0 9px; font-size: .9rem; flex: 1 1 auto; }
.viewswitch .muted { margin: 10px 0 0; }

/* zone card: tappable, compact stage/PFRP/set point line (v0.9.1) */
#zones .card { cursor: pointer; }
.card h2 .zone-link { color: inherit; text-decoration: none; }
.card h2 .zone-link:hover, .card h2 .zone-link:focus { text-decoration: underline; }
.zfacts { font-size: .85rem; font-weight: 700; color: #3d4148; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zfacts2 { font-size: .8rem; color: #3d4148; margin-top: 2px; line-height: 1.3; }
.zfacts2.warn, .zwarn { color: #a32d0f; font-weight: 700; }
