@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("/fonts/inter-latin-700-normal.woff2") format("woff2"); }

/* =====================================================================
   60-30-10 colour system
   60 % neutral   – page, cards, large areas        (--bg, --surface, --surface-2)
   30 % secondary – icons, borders, secondary text  (--secondary, --line, --muted)
   10 % accent    – hero card, CTAs, active states  (--accent = Toasted Orange #C8623D)
   Semantic colours (solar, import, export, battery) only appear as small marks.
   Palette: Ice Cream Blue #C8F3FF + Toasted Orange #C8623D.
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #EDFBFF;
  --surface: #FFFFFF;
  --surface-2: #C8F3FF;          /* Ice Cream Blue */
  --secondary: #86BCCB;
  --line: #CFEFF9;
  --muted: #5A7C86;
  --ink: #122A31;
  --accent: #C8623D;             /* Toasted Orange */
  --on-accent: #FFF4EC;
  --on-accent-muted: rgba(255, 244, 236, .72);
  --pos: #0E9F6E;
  --neg: #CF3F47;
  --sun: #E09A00;
  --battery: #6D5BD0;
  --track: #D9EFF6;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius-lg: 20px;
  --radius: 14px;
  --gap: 16px;
  --pad: 20px;
  --tabbar-h: 64px;
  --rail-w: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0B1E24;
    --surface: #122B33;
    --surface-2: #163642;
    --secondary: #5E8A97;
    --line: #1D3D47;
    --muted: #9AC2CD;
    --ink: #EAFBFF;
    --accent: #C8F3FF;           /* inverted: Ice Cream Blue card with Toasted Orange text */
    --on-accent: #C8623D;
    --on-accent-muted: rgba(200, 98, 61, .78);
    --pos: #3DD69A;
    --neg: #FF7A80;
    --sun: #F5B820;
    --battery: #AE9EF5;
    --track: #20424E;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  font-feature-settings: "cv11";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sprite { position: absolute; }
.num, .hero-value, .tile-val, .row-val, .stats dd, .breakdown .val { font-variant-numeric: tabular-nums; }

/* line icons */
.tabbar svg, .tile-ico svg, .row-ico svg, .hero-ico, .icon-btn svg {
  fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- sign in ---------- */
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(env(safe-area-inset-bottom) + 24px);
}
.login-card {
  width: min(360px, 100%); display: grid; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 28px 24px;
}
.login-card { position: relative; }
.login-mark { width: 48px; height: 48px; }
.lang-seg { position: absolute; top: 16px; right: 16px; }
.login-card h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; }
.login-card label { display: grid; gap: 6px; font-size: .86rem; color: var(--muted); }
.login-card input {
  height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font-size: 1rem;
}
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.form-error { color: var(--neg); min-height: 1.2em; font-size: .9rem; }

.btn-accent {
  height: 48px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.btn-accent:disabled { opacity: .6; }
.btn-outline {
  height: 48px; width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--neg); font-weight: 600;
}
.btn-ghost {
  height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 17px;
  background: var(--surface); font-size: .85rem; font-weight: 600; color: var(--accent);
}
@media (prefers-color-scheme: dark) { .btn-ghost { color: var(--ink); } }
.link { border: 0; background: none; padding: 4px 0; font-size: .85rem; font-weight: 500; color: var(--muted); }
.link:hover { color: var(--ink); }

/* ---------- layout ---------- */
.main {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) max(var(--pad), env(safe-area-inset-right))
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px) max(var(--pad), env(safe-area-inset-left));
}
.view { display: grid; gap: var(--gap); align-content: start; }
.view:not(.active) { display: none; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px; min-width: 0;
}
.card.flush { padding: 4px 16px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sec-head.wrap { flex-wrap: wrap; }
.sec-head h2 { font-size: .98rem; font-weight: 600; }
.sub { color: var(--muted); font-size: .86rem; }
.page-head { display: grid; gap: 2px; padding-top: 4px; }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }

/* ---------- greeting header ---------- */
.greet { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 4px; }
.hello { color: var(--muted); font-size: .86rem; }
.greet h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.status {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 30px; padding: 0 11px; border-radius: 15px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: .78rem; font-weight: 500; color: var(--muted);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--secondary); }
.status.live .dot { background: var(--pos); }
.status.stale .dot { background: var(--sun); }
.status.down .dot { background: var(--neg); }
.hdr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.outside-temp { font-size: .82rem; font-weight: 600; color: var(--muted); }

/* ---------- hero (the 10 % accent) ---------- */
.hero {
  background: var(--accent); color: var(--on-accent);
  border-radius: var(--radius-lg); padding: 16px 18px 16px;
  display: grid; gap: 6px;
}
.hero-top { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--on-accent-muted); }
.hero-ico { width: 18px; height: 18px; stroke: var(--on-accent-muted); }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.hero-value { font-size: 2.1rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; white-space: nowrap; }
.hero-value .unit { font-size: 1rem; font-weight: 500; margin-left: 4px; letter-spacing: 0; color: var(--on-accent-muted); }
.hero-spark { width: 42%; max-width: 160px; height: 40px; overflow: visible; }
.hero-spark path { fill: none; stroke: var(--on-accent); stroke-width: 1.6; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: .85; }
.hero-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .78rem; color: var(--on-accent-muted); min-height: 22px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px;
  background: color-mix(in srgb, var(--on-accent) 14%, transparent); color: var(--on-accent); font-weight: 600;
  white-space: nowrap;
}
.pill:empty { display: none; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- quick tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 2px 0 4px; }
.tile {
  display: grid; justify-items: center; gap: 4px; padding: 4px 0;
  border: 0; background: none; border-radius: 14px; min-width: 0;
}
.tile-ico {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  transition: border-color .15s;
}
.tile:hover .tile-ico { border-color: var(--secondary); }
.tile-ico svg { width: 22px; height: 22px; }
.tile-label { font-size: .74rem; color: var(--muted); }
.tile-val { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.tile-val.pos { color: var(--pos); }
.tile-val.neg { color: var(--neg); }

/* ---------- sensor room tiles ---------- */
.sensor-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sensor-tile {
  position: relative; overflow: hidden;
  border: 0; border-radius: 18px; padding: 16px; text-align: left; min-height: 118px;
  display: grid; align-content: space-between; cursor: pointer;
  background: color-mix(in srgb, var(--c) 78%, black 6%); color: #fff;
  transition: transform .1s;
}
.sensor-tile-spark { position: absolute; inset: auto 0 0 0; width: 100%; height: 34px; opacity: .35; }
.sensor-tile-spark path { fill: none; stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sensor-tile.offline .sensor-tile-spark { display: none; }
.sensor-tile:active { transform: scale(.98); }
.sensor-tile.offline { background: var(--surface-2); color: var(--muted); }
.sensor-tile-val, .sensor-tile-name, .sensor-tile-sub { position: relative; z-index: 1; }
.sensor-tile-val {
  display: flex; flex-wrap: wrap; align-items: baseline; row-gap: 2px; column-gap: 14px;
  font-size: 1.7rem; font-weight: 700; line-height: 1; margin: 0;
}
.sensor-tile-val .metric { display: inline-flex; align-items: baseline; gap: 3px; }
.sensor-tile-val .metric svg {
  align-self: center; width: 19px; height: 19px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sensor-tile-val sup { font-size: 1rem; font-weight: 600; }
.sensor-tile-name { font-size: .92rem; font-weight: 600; margin: 8px 0 0; }
.sensor-tile-sub { font-size: .76rem; opacity: .85; margin: 1px 0 0; }
.sensor-tile-val .gas-dot .dot { width: 14px; height: 14px; border-radius: 50%; align-self: center; }
.sensor-tile-val .gas-dot.good .dot { background: var(--pos); }
.sensor-tile-val .gas-dot.fair .dot { background: var(--sun); }
.sensor-tile-val .gas-dot.poor .dot { background: var(--neg); }
.sensor-chart-wrap { position: relative; height: 140px; }
.sensor-chart { width: 100%; height: 100%; overflow: visible; }
.sensor-chart path { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; }

/* ---------- list rows (transaction style) ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row:last-child, .row:has(+ .row[hidden]:last-child) { border-bottom: 0; }
.row-ico {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--accent);
}
@media (prefers-color-scheme: dark) { .row-ico { color: var(--ink); } }
.row-ico svg { width: 20px; height: 20px; }
.row-ico.tinted { background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--c); }
.row-ico .initial { font-weight: 700; font-size: .95rem; }
.row-main { display: grid; min-width: 0; }
.row-main strong { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main span.err { color: var(--neg); }
.name-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.warn-badge { flex: none; width: 15px; height: 15px; color: var(--neg); display: grid; place-items: center; }
.warn-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.row-end { display: grid; justify-items: end; gap: 1px; }
.row-val { font-size: .92rem; font-weight: 600; white-space: nowrap; }
.row-val.pos { color: var(--pos); }
.row-meta { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.row.clickable { cursor: pointer; }
.empty { color: var(--muted); padding: 12px 0; font-size: .9rem; }

.device-rows .row-end { grid-auto-flow: column; align-items: center; gap: 12px; }
.device-rows .row.offline .row-ico { filter: grayscale(1); opacity: .6; }

/* switch: accent when on */
.switch {
  position: relative; width: 50px; height: 30px; flex: none;
  border: 0; padding: 0; border-radius: 15px; background: var(--track); transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
@media (prefers-color-scheme: dark) { .switch[aria-checked="true"]::after { background: var(--on-accent); } }
.switch:disabled { opacity: .4; cursor: not-allowed; }
.switch.pending::after { animation: pulse .8s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .45; } }

/* protected switch: needs a deliberate press-and-hold, shown as a fill sweep */
.switch.protected { overflow: hidden; }
.switch.protected::before {
  content: ""; position: absolute; inset: 0; width: 0%; background: var(--neg); opacity: .55;
}
.switch.protected.holding::before { width: 100%; transition: width 900ms linear; }
.lock { width: 30px; height: 30px; display: grid; place-items: center; color: var(--secondary); }
.lock svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.clock-badge { width: 22px; height: 22px; display: grid; place-items: center; color: var(--accent); flex: none; }
.clock-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.leaf-badge { width: 22px; height: 22px; display: grid; place-items: center; color: var(--pos); flex: none; }
.leaf-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.leaf-badge.locked { color: var(--sun); }
.bulb-badge {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  animation: pulse 1s ease-in-out infinite alternate;
}
.bulb-badge.on { background: var(--pos); box-shadow: 0 0 6px var(--pos); }
.bulb-badge.off { background: var(--neg); box-shadow: 0 0 6px var(--neg); }

/* ---------- power flow ---------- */
.flow { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; overflow: visible; }
.flow .wire { fill: none; stroke: var(--track); stroke-width: 2; stroke-linecap: round; }
.flow .current { fill: none; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 12; animation: flow linear infinite; }
@keyframes flow { to { stroke-dashoffset: -28; } }
.flow .node-bg { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.flow .node-label { font: 500 11px var(--sans); fill: var(--muted); text-anchor: middle; }
.flow .node-value { font: 700 17px var(--sans); letter-spacing: -.02em; fill: var(--ink); text-anchor: middle; font-variant-numeric: tabular-nums; }
.flow .node-value.big { font-size: 20px; }
.flow .node-icon { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flow .dim { opacity: .5; }
.flow-home-bg { fill: var(--surface-2) !important; }
.flow .branch-wire { fill: none; stroke-width: 2; opacity: .6; }
.flow .branch-dot { stroke: var(--surface); stroke-width: 1.5; }
.flow .branch-name { font: 500 11px var(--sans); fill: var(--ink); dominant-baseline: middle; }
.flow .branch-value { font: 700 12px var(--sans); font-variant-numeric: tabular-nums; dominant-baseline: middle; }

/* ---------- history ---------- */
.stats {
  margin: 0; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.stats > div { padding: 14px; min-width: 0; }
.stats > div + div { border-left: 1px solid var(--line); }
.stats dt { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd { margin: 3px 0 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.stats dd small { font-size: .78rem; font-weight: 500; color: var(--muted); margin-left: 3px; letter-spacing: 0; }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg-full { display: flex; margin-bottom: 12px; }
.seg-sm { padding: 2px; border-radius: 10px; }
.seg-sm button { min-height: 28px; padding: 4px 10px; font-size: .78rem; border-radius: 8px; }
.seg-full button { flex: 1; }
.seg button {
  border: 0; background: none; padding: 6px 12px; border-radius: 9px; min-height: 32px;
  font-size: .82rem; font-weight: 500; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(14, 42, 33, .12), 0 0 0 1px var(--line); }
.chart-wrap { position: relative; height: clamp(210px, 36vh, 300px); touch-action: pan-y; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-tip {
  position: absolute; top: 4px; pointer-events: none; min-width: 140px; white-space: nowrap;
  background: var(--accent); color: var(--on-accent); border-radius: 12px; padding: 8px 11px;
  font-size: .78rem; line-height: 1.4;
}
.chart-tip b { font-weight: 600; float: right; margin-left: 12px; font-variant-numeric: tabular-nums; }
.chart-tip .t { opacity: .7; margin-bottom: 2px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 0 20px; }
.legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.breakdown { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.breakdown li { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: baseline; }
.breakdown .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.breakdown .val { font-size: .9rem; font-weight: 600; }
.breakdown .val small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.breakdown .bar { grid-column: 1 / -1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.breakdown .bar span { display: block; height: 100%; border-radius: 3px; transition: width .6s ease; }
.breakdown .other .name { color: var(--muted); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.rail-brand { display: none; }
.tabbar button {
  height: 52px; border: 0; background: none; border-radius: 12px;
  display: grid; justify-items: center; align-content: center; gap: 3px;
  font-size: .7rem; font-weight: 500; color: var(--secondary);
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar button[aria-current="page"] .fill-on-active { fill: currentColor; }
.tabbar button[aria-current="page"] .fill-on-active + circle { fill: var(--surface); stroke: none; }
@media (prefers-color-scheme: dark) {
  .tabbar button[aria-current="page"] { color: var(--ink); }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 10;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  width: max-content; max-width: min(92vw, 420px);
  background: var(--accent); color: var(--on-accent);
  padding: 11px 16px; border-radius: 14px; font-size: .88rem; font-weight: 500;
  box-shadow: 0 8px 24px rgba(7, 40, 30, .22);
}
.toast.error { background: var(--neg); color: #fff; }


/* ---------- sign-in extras ---------- */
.btn-sso { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; }
.btn-sso svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pw-fields { display: grid; gap: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.notice { background: var(--surface-2); color: var(--ink); border-radius: 12px; padding: 10px 12px; font-size: .86rem; }
.notice.error { background: color-mix(in srgb, var(--neg) 12%, var(--surface)); }
a.btn-ghost { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- alerts ---------- */
.alerts { display: grid; gap: 8px; }
.alert-item {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--neg) 35%, var(--line));
  background: color-mix(in srgb, var(--neg) 8%, var(--surface)); text-align: left; width: 100%;
}
.alert-item svg { width: 20px; height: 20px; fill: none; stroke: var(--neg); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.alert-item strong { display: block; font-size: .9rem; font-weight: 600; }
.alert-item span { display: block; font-size: .8rem; color: var(--muted); }
.alert-item .chev { color: var(--muted); font-size: 1.2rem; }

/* ---------- appliances ---------- */
.row-val.temp { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.row.alerting .row-main span { color: var(--neg); }
.row.alerting .row-val.temp { color: var(--neg); }

/* ---------- account ---------- */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 1.1rem;
}
.avatar.sm { width: 40px; height: 40px; font-size: .95rem; background: var(--surface-2); color: var(--accent); }
@media (prefers-color-scheme: dark) { .avatar.sm { color: var(--ink); } }
.profile .row-main strong { font-size: 1.05rem; }
.hint { margin: -4px 0 6px; }
.hint:empty { display: none; }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 9px; font-size: .7rem; font-weight: 600;
  background: var(--surface-2); color: var(--accent); vertical-align: 1px; margin-left: 6px;
}
@media (prefers-color-scheme: dark) { .badge { color: var(--ink); } }
.row-end .btn-ghost + .btn-ghost { margin-left: 6px; }
.icon-more {
  width: 34px; height: 34px; border: 0; background: var(--surface-2); border-radius: 50%;
  color: var(--muted); display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
.icon-more:hover, .icon-more:active { background: var(--bg); color: var(--ink); }
.icon-more svg { width: 18px; height: 18px; fill: currentColor; }
/* .icon-more is normally a filled dot icon (e.g. the ⋮ "more" menu); buttons
   that embed a stroke-only line icon (e.g. the × close glyph) opt out with
   .icon-line so the path isn't invisibly filled with no area to show. */
.icon-more.icon-line svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.copy-id { border: 0; background: none; padding: 0; color: var(--muted); font-size: .76rem; text-align: left; cursor: copy; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.copy-id:hover { color: var(--ink); text-decoration: underline; }

/* ---------- dialogs (bottom sheet on phones) ---------- */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px;
  background: var(--surface); color: var(--ink);
  border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(7, 40, 30, .25);
}
.sheet::backdrop { background: rgba(4, 24, 18, .45); }
.sheet form { display: grid; gap: 14px; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); }
.sheet h2 { font-size: 1.15rem; font-weight: 700; }
.sheet label { display: grid; gap: 6px; font-size: .84rem; color: var(--muted); }
.sheet label small { font-size: .76rem; }
.sheet input, .sheet select {
  height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font-size: 1rem; width: 100%;
}
.sheet input:focus, .sheet select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.sheet input:disabled { opacity: .6; }
.sso-state { font-size: .84rem; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.sheet-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet-actions .spacer { flex: 1; }
.sheet-actions .btn-accent { padding: 0 18px; }
.btn-text { height: 44px; padding: 0 12px; border: 0; background: none; border-radius: 12px; font-weight: 600; color: var(--muted); }
.btn-text:hover { background: var(--bg); color: var(--ink); }
.btn-text.danger { color: var(--neg); }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 22px; }
  .sheet form { padding: 24px; }
}

/* ---------- device detail sheet ---------- */
.device-detail { display: grid; gap: 14px; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; gap: 12px; }
.sheet-head .row-main { flex: 1; min-width: 0; }
.device-stats dd { font-size: 1.05rem; }
.gas-badge { display: inline-flex; align-items: center; gap: 6px; }
.gas-badge .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.gas-badge.good .dot { background: var(--pos); }
.gas-badge.fair .dot { background: var(--sun); }
.gas-badge.poor .dot { background: var(--neg); }
.device-chart {
  display: flex; align-items: flex-end; gap: 2px; height: 96px;
  overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; scrollbar-width: thin;
}
.device-chart .bar-col { flex: none; width: 6px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.device-chart .bar { width: 100%; min-height: 2px; border-radius: 1px; background: var(--sun); }
.device-chart .state { width: 100%; height: 4px; border-radius: 1px; background: var(--track); flex: none; }
.device-chart .state.on { background: var(--accent); }
.device-chart .state.offline { background: var(--neg); }
.device-chart .empty { margin: auto; color: var(--muted); font-size: .86rem; }
.device-economy .rows { margin: 0; }
.device-economy .row { border-bottom: 0; padding: 0; }
.device-economy.locked .row-ico.tinted { background: color-mix(in srgb, var(--sun) 18%, var(--surface)); color: var(--sun); }
.device-timer h3 { margin: 4px 0 0; font-size: .95rem; }
.device-timer .sub { margin: 0; }
.device-schedule h3 { margin: 4px 0 0; font-size: .95rem; }
.schedule-rule {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.schedule-rule:last-child { border-bottom: 0; }
.schedule-time { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .86rem; }
.schedule-time input[type="time"] {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; color: inherit; font: inherit; min-width: 0;
}
.schedule-rule .icon-more { margin-left: auto; }

/* ---------- larger screens: side rail + two-column home ---------- */
@media (min-width: 900px) {
  :root { --tabbar-h: 0px; --rail-w: 232px; --gap: 20px; }
  .tabbar {
    top: 0; right: auto; width: var(--rail-w);
    display: flex; flex-direction: column; gap: 4px;
    padding: 24px 14px; border-top: 0; border-right: 1px solid var(--line);
    background: var(--surface); backdrop-filter: none;
  }
  .rail-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; padding: 0 10px 22px; }
  .rail-brand svg { width: 30px; height: 30px; }
  .tabbar button {
    height: 44px; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 0 12px;
    font-size: .92rem;
  }
  .tabbar button svg { width: 21px; height: 21px; flex: none; }
  .tabbar button:hover { background: var(--bg); }
  .tabbar button[aria-current="page"] { background: var(--surface-2); }
  .main { margin-left: var(--rail-w); max-width: none; padding: 32px 40px 48px; }
  .view { max-width: 760px; margin: 0 auto; }
  .view-home {
    max-width: 1100px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    grid-template-areas: "greet greet" "alerts alerts" "hero flow" "tiles flow" "top flow";
    align-items: start;
  }
  .view-home .area-greet { grid-area: greet; }
  .view-home .area-alerts { grid-area: alerts; }
  .view-home .area-hero { grid-area: hero; }
  .view-home .area-tiles { grid-area: tiles; }
  .view-home .area-flow { grid-area: flow; align-self: stretch; display: flex; flex-direction: column; }
  .view-home .area-flow .flow { margin: auto; }
  .view-home .area-top { grid-area: top; }
  .view-account { max-width: 560px; }
  .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .flow .current { animation: none; stroke-dasharray: none; }
  .switch, .switch::after, .breakdown .bar span, .tile-ico { transition: none; }
  .bulb-badge { animation: none; }
}
