/* pages.css: per-page layouts. Every page is a grid with minmax(0,1fr) tracks so content shrinks, never overflows. */
/* arc gauges (gauge.js): the SVG carries a viewBox only; the cell sizes it */
.gcell { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; }
.gcell svg { width: 100%; height: 100%; max-height: 100%; }
.gcell.vt svg { width: auto; height: 100%; max-width: 100%; }
.gauge-svg text { font-family: inherit; }
/* brief: landscape = hero spans 2 rows on the left, 2x2 right; portrait = hero on top, 2x2 under */
.brief { display: grid; gap: 10px; grid-template-columns: 5fr 3fr 3fr; grid-template-rows: repeat(2, minmax(0, 1fr)); }
.brief .hero { grid-row: span 2; }
@media (orientation: portrait) {
  .brief { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 40fr) minmax(0, 30fr) minmax(0, 30fr); }
  .brief .hero { grid-row: auto; grid-column: span 2; }
}
.gtile { display: grid; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); padding: 6px; color: inherit; text-decoration: none; }
.shore-t { place-items: center; }
.shore { text-align: center; min-width: 0; }
.shore .k { display: block; color: var(--dim); font-size: .78rem; }
.shore .v { display: block; font-size: clamp(18px, 3.5vw, 30px); font-weight: 700; line-height: 1.15; }
.shore .v2 { display: block; font-size: clamp(14px, 2.4vw, 20px); color: var(--dim); font-variant-numeric: tabular-nums; }
/* overview */
.pfhost { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; }
.pfwrap { position: relative; min-height: 0; }
#pf { position: absolute; inset: 0; width: 100%; height: 100%; }
.stats3 { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pf-track { fill: none; stroke: var(--border); stroke-width: 2; }
.pf-flow { fill: none; stroke-width: 2.5; stroke-dasharray: 6 10; animation: pfdash 2s linear infinite; }
.pf-flow.off { display: none; }
@keyframes pfdash { to { stroke-dashoffset: -16; } }
@media (prefers-reduced-motion: reduce) { .pf-flow { animation: none; marker-end: url(#pfArrow); } }
.pf-node { fill: var(--card); stroke: var(--border); stroke-width: 1.5; }
.pf-batt { stroke: var(--accent); stroke-width: 2.5; }
.pf-lbl { fill: var(--dim); font-size: 15px; }
.pf-num { fill: var(--text); font-size: 32px; font-weight: 700; }
.pf-num.sm { font-size: 20px; }
.pf-sub { fill: var(--dim); font-size: 14px; }
.pf-led { stroke-width: 1; }
.pf-led.hot { fill: var(--bad); stroke: var(--bad); filter: drop-shadow(0 0 3px var(--bad)); }
.pf-led.warm { fill: var(--warn); stroke: var(--warn); filter: drop-shadow(0 0 3px var(--warn)); }
.pf-led.cold { fill: var(--accent); stroke: var(--accent); filter: drop-shadow(0 0 3px var(--accent)); }
.pf-led.na { display: none; }
/* overview dials: portrait = flow / dials / strip; landscape tablet = flow+strip left, 2x2 dials right */
.ovw { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 5fr) minmax(0, 4fr) auto; }
.ovw .pfhost { display: contents; }
.ovw .pfwrap { grid-row: 1; min-height: 0; }
.ovw .stats3 { grid-row: 3; font-size: .8rem; gap: 4px; }
.ovdials { grid-row: 2; display: grid; gap: 6px; min-height: 0; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
.ovdials .gcell { min-height: 0; min-width: 0; }
@media (max-width: 599px) {
  .ovw { grid-template-rows: minmax(0, 4fr) minmax(0, 5fr) auto; }
  .ovdials { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 900px) and (orientation: landscape) {
  .ovw { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); grid-template-rows: minmax(0, 1fr) auto; }
  .ovw .pfwrap { grid-column: 1; grid-row: 1; }
  .ovw .stats3 { grid-column: 1; grid-row: 2; font-size: inherit; gap: 8px; }
  .ovdials { grid-column: 2; grid-row: 1 / 3; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
}
/* levels */
.levels { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
.lv-grid { display: grid; gap: 6px; padding: 6px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); grid-auto-rows: minmax(0, 1fr); }
@media (orientation: portrait) {
  /* tanks (3) fill the first row; temps follow, two per row */
  .lv-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .lv-grid .gcell.vt { grid-column: span 2; }
  .lv-grid .gcell:not(.vt) { grid-column: span 3; }
}
.hws { padding: 8px 10px; display: grid; gap: 6px; }
.hw-row { display: flex; align-items: center; gap: 10px; }
.hw-row .toggle, .hw-row .confirm { flex: 1 1 0; min-width: 0; }
.hw-state small { display: block; color: var(--dim); font-size: .7rem; }
.hw-state .big { font-size: clamp(22px, 5vw, 32px); }
.hws .confirm p { margin: 0 0 4px; font-size: .95rem; }
.hws .confirm .chk { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .9rem; cursor: pointer; }
.hws .confirm .chk input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.hws .stat { padding: 3px 8px; }
.hws .msg { margin: 0; font-size: .8rem; }
.hws .msg:empty { display: none; }
/* car (Black Betty): status card, six number cards, stats strip */
.car { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.car-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 8px 12px; }
.car-head h2 { margin: 0; font-size: 1rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.car-dev { font-size: .8rem; color: var(--dim); }
.car-dev b { color: var(--text); margin-right: 4px; }
.car-dev i { font-style: normal; font-weight: 600; }
.car-dev i.ok { color: var(--accent); }
.car-dev i.bad { color: var(--bad); }
.car-foot { font-size: .8rem; gap: 4px; padding: 6px 8px; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }   /* 4-5 stats on one row where they fit, not 3 + an orphan */
.car-foot .stat { padding: 3px 8px; }
.car-foot.hidden { display: none; }
.car-setup { padding: 12px 16px; overflow-y: auto; font-size: .9rem; line-height: 1.45; }
.car-setup h2 { font-size: .9rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.car-setup code { background: var(--track); padding: 1px 5px; border-radius: 4px; }
.car-setup ul { margin: 4px 0 0; padding-left: 18px; }
/* number cards (views/car.js cardHtml): the phone layout since web 2.15.5, every screen since web 2.24. Base rules
   are the phone's (2 across, natural height); wider screens go 3 across and stretch to fill the panel. */
.car-cards { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; min-height: 0; overflow-y: auto; }
.car-card b { font-size: clamp(1.5rem, 8vw, 2.2rem); line-height: 1.15; font-variant-numeric: tabular-nums; }
.car-card b small { font-size: .85rem; color: var(--dim); font-weight: 500; margin-left: 3px; }
.car-card em { display: block; font-style: normal; color: var(--dim); font-size: .72rem; min-height: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-card em i { font-style: normal; font-weight: 600; }
.car-card.stale { opacity: .6; }   /* device out of range: last values held, dimmed */
@media (min-width: 600px) {
  /* value sized from the panel's width (cqw), not the viewport's: beside the tyres panel the cards are 58% as wide,
     and a vw size cut "12.31 V" off. The vw line is the fallback for a browser without container units. */
  .car-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); align-content: stretch; container-type: inline-size; }
  .car-card { display: flex; flex-direction: column; justify-content: center; padding: 8px 14px; }
  .car-card span { font-size: .85rem; }
  .car-card b { font-size: clamp(1.5rem, 3.6vw, 3.6rem); font-size: clamp(1.5rem, 6.6cqw, 3.6rem); }
  .car-card b small { font-size: 1.1rem; }
  .car-card em { font-size: .85rem; white-space: normal; }
}
/* Car page = car panel (cards fill it) + tyres panel underneath (natural height, scrolls past 45%) */
.car-page { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.car-page > .car { min-height: 0; }
.car-tyres { min-height: 0; max-height: 45vh; display: grid; grid-template-rows: minmax(0, 1fr); }
.car-tyres .tyres { grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
@media (max-height: 520px) {
  .car-page { grid-template-rows: auto auto; }
  .car-page > .car { grid-template-rows: auto auto auto; }
  .car-tyres { max-height: none; }
}
/* tyres (bridge 1.12): status card, one block per vehicle with a tile per wheel */
.tyres { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.tyres-body { display: grid; gap: 8px; min-height: 0; overflow-y: auto; align-content: start; }
.tyres-veh { padding: 8px 10px; }
.tyres-veh h3 { margin: 0 0 6px; font-size: .72rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.tyres-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.tyre { border: 2px solid var(--border); border-radius: 10px; padding: 6px 10px; display: grid; gap: 2px; background: var(--track); }
.tyre.ok { border-color: var(--accent); }
.tyre.warn { border-color: var(--warn); }
.tyre.bad { border-color: var(--bad); }
.tyre.quiet { opacity: .6; }
.tyre .tl { font-size: .72rem; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.tyre .tp { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tyre .tp small { font-size: .8rem; font-weight: 500; color: var(--dim); margin-left: 3px; }
.tyre .ts { font-size: .78rem; color: var(--dim); }
.tyre .ts i { font-style: normal; font-weight: 600; }
.tyre .ts i.ok { color: var(--accent); }
.tyre .ts i.warn { color: var(--warn); }
.tyre .ts i.bad { color: var(--bad); }
.tyres-setup ul { margin: 4px 0 0; padding-left: 18px; }
/* caravan drawing (web 2.13, landscape since 2.15): top view nose left, tyre colour = grade, readouts above/below each tyre */
.tyres-draw { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.tyres-draw h3 { justify-self: start; }
.tyres-van { width: 100%; max-width: 620px; height: auto; max-height: calc(45vh - 136px); display: block; }   /* 45vh panel minus head card, title, notes: whole van visible, no scroll */
.vt-line { fill: none; stroke: var(--dim); stroke-width: 3; stroke-linecap: round; }
.vt-van circle.vt-line { fill: var(--card); }
.vt-body { fill: var(--track); stroke: var(--dim); stroke-width: 3; }
.vt-roof { fill: none; stroke: var(--border); stroke-width: 2; }
.vt-tag { fill: var(--dim); font-size: 11px; letter-spacing: .12em; font-weight: 600; }
/* Tyres overlap the body outline, so they must be opaque: the old grey (--border, 8% alpha, at 55% group opacity when
   quiet) let the outline show through and strike out the temperature printed on the tyre (web 2.21). */
.vt-tyre { fill: var(--card); fill: color-mix(in srgb, var(--dim) 30%, var(--card)); stroke: var(--dim); stroke-width: 2; }
.vt-tread { fill: var(--card); opacity: .5; }
.vt.ok .vt-tyre { fill: var(--accent); stroke: var(--accent); }
.vt.warn .vt-tyre { fill: var(--warn); stroke: var(--warn); }
.vt.bad .vt-tyre { fill: var(--bad); stroke: var(--bad); }
.vt.quiet text { opacity: .6; }   /* dim the readings, not the tyre (group opacity made it see-through) */
.vt-psi { fill: var(--text); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.vt-u { fill: var(--dim); font-size: 12px; font-weight: 500; }
.vt-tin { fill: #fff; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.vt.quiet .vt-tin { fill: var(--text); }
.vt-batt { fill: var(--warn); font-size: 11px; font-weight: 600; }
.tyres-notes { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; font-size: .78rem; color: var(--dim); padding-top: 4px; }
.vn b { font-weight: 600; color: var(--text); }
.vn.warn { color: var(--warn); } .vn.bad { color: var(--bad); }
.vn.warn b, .vn.bad b { color: inherit; }
@media (max-width: 599px) {
  .tyres-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* history */
.hist { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; }
.hctl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(64px, 1fr)); gap: 6px; flex: 1 1 260px; max-width: 420px; }
.seg button { min-height: 40px; padding: 0; font-weight: 600; background: var(--track); color: var(--text); }
.seg button.on { background: var(--accent); color: #031722; }
.hupd { color: var(--dim); font-size: .8rem; }
.herr { color: var(--bad); font-size: .8rem; }
.herr:empty { display: none; }
.hgrid { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); min-height: 0; }
@media (max-width: 699px), (max-height: 599px) {
  /* phone fallback: the only vertical scroll in the app */
  .hgrid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: 210px; overflow-y: auto; align-content: start; }
}
.hcard { display: flex; flex-direction: column; padding: 8px 10px; gap: 2px; }
.hhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex: none; }
.hhead h3 { margin: 0; font-size: .72rem; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.hhead a { color: var(--accent); cursor: pointer; text-decoration: underline; font-size: .8rem; }
.hleg { flex: none; display: flex; flex-wrap: wrap; gap: 0 10px; font-size: .68rem; min-height: 0; }
.hleg span { display: inline-flex; align-items: center; gap: 4px; }
.hleg i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.hplot { flex: 1 1 0; min-height: 0; position: relative; overflow: hidden; }
.hplot > .uplot { position: absolute; left: 0; top: 0; }
.uplot, .u-legend { color: var(--text); font-size: 12px; }
.htable { flex: 1 1 0; min-height: 0; overflow: auto; font-size: .8rem; font-variant-numeric: tabular-nums; }
.htable table { border-collapse: collapse; width: 100%; }
.htable th, .htable td { padding: 3px 8px; text-align: right; white-space: nowrap; border-top: 1px solid var(--border); }
.htable th { position: sticky; top: 0; background: var(--card); color: var(--dim); font-weight: 600; }
.htable th:first-child, .htable td:first-child { text-align: left; }
/* history lightbox: a tapped card is moved into .hzoom on <body>; .hph holds its grid cell meanwhile */
.hcard { cursor: pointer; }
.hhead h3 { flex: 1 1 auto; min-width: 0; }
.hclose, .hseg { display: none; }
.hzoom { position: fixed; inset: 0; z-index: 18; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.75);
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.hzoom .hcard { width: 100%; height: 100%; max-width: 1200px; max-height: 800px; padding: 10px 14px 12px; gap: 6px; cursor: default;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.hzoom .hhead { align-items: center; gap: 14px; }
.hzoom .hhead h3 { font-size: .95rem; }
.hzoom .hhead a { font-size: 1rem; padding: 10px 4px; }
.hzoom .hclose { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; padding: 0;
  font-size: 1.5rem; line-height: 1; background: var(--track); color: var(--text); }
.hzoom .hseg { display: grid; flex: 0 1 320px; grid-template-columns: repeat(4, minmax(48px, 1fr)); }
@media (max-width: 699px) {
  .hzoom .hhead { flex-wrap: wrap; row-gap: 6px; }
  .hzoom .hseg { order: 3; flex: 1 1 100%; max-width: none; }
}
.hzoom .hleg { font-size: .9rem; gap: 2px 16px; }
.hzoom .hleg i { width: 12px; height: 12px; }
.hzoom .htable { font-size: .95rem; }
/* settings: gui-v2 style master list + detail pane; each pane scrolls on its own */
.sx { display: grid; gap: 10px; grid-template-columns: minmax(200px, 340px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.sx-list, .sx-detail { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px; }
.sx-list h2 { padding: 2px 4px 6px; }
.sx-g { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left;
  width: 100%; min-height: 48px; padding: 6px 4px 6px 10px; border-radius: 10px; background: transparent; color: var(--text); border-top: 1px solid var(--border); border-radius: 0; }
.sx-g:first-of-type { border-top: 0; }
.sx-g.on { background: var(--accent-track); border-radius: 10px; border-top-color: transparent; }
.sx-g.on + .sx-g { border-top-color: transparent; }
.sx-gt { font-weight: 600; grid-column: 1; }
.sx-gs { grid-column: 1; color: var(--dim); font-size: .75rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-chev { grid-column: 2; grid-row: 1 / 3; color: var(--dim); font-size: 1.4rem; line-height: 1; }
.sx-wait { padding: 10px 4px; }
.sx-dh { display: flex; align-items: baseline; gap: 10px; flex: none; padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.sx-dh h2 { margin: 0; font-size: .9rem; color: var(--text); text-transform: none; letter-spacing: 0; flex: 1 1 auto; }
.sx-back { display: none; min-height: 36px; padding: 0 10px; font-size: 1.6rem; line-height: 1; background: var(--track); color: var(--text); align-self: center; }
.sx-warn { flex: none; background: rgba(250,178,25,.15); color: var(--warn); border-radius: 8px; padding: 6px 10px; font-size: .8rem; margin: 4px 0; }
.sx-rows { flex: 1 1 auto; }
.sx-row { border-top: 1px solid var(--border); }
.sx-row:first-child { border-top: 0; }
.sx-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 4px 4px 4px 2px;
  background: transparent; color: var(--text); border-radius: 0; text-align: left; }
.sx-head:disabled { opacity: 1; cursor: default; }
.sx-l { flex: 1 1 auto; min-width: 0; white-space: pre-wrap; }
.sx-v { flex: 0 1 auto; display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-variant-numeric: tabular-nums; text-align: right; max-width: 60%; }
.sx-row.ro .sx-v { color: var(--dim); }
.sx-row.open .sx-head { color: var(--accent); }
/* detail body: a plain group is one column of rows, capped so label and control stay near each other on a wide screen;
   a folded group (Tanks, Temperature sensors) is a grid of cards, one per device */
.sx-body { flex: 1 1 auto; }
.sx-body > .sx-rows { max-width: 720px; }
.sx-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; padding-top: 6px; }
.sx-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 4px 10px 6px; min-width: 0; }
.sx-ch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 2px 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.sx-ch h3 { margin: 0; font-size: .95rem; font-weight: 700; color: var(--text); text-transform: none; letter-spacing: 0; flex: 1 1 auto; min-width: 0; }
.sx-tag { padding: 1px 8px; border-radius: 999px; background: var(--track); color: var(--dim); font-size: .72rem; font-weight: 600; white-space: nowrap; }
.sx-card .sx-head { min-height: 44px; }
.sx-sub.has-cap { justify-content: space-between; align-items: center; }
.sx-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 0 4px 6px 2px; font-size: .75rem; margin-top: -4px; }
.sx-hint { color: var(--dim); }
.sx-note { color: var(--dim); font-weight: 600; } .sx-note.ok { color: var(--ok); } .sx-note.bad { color: var(--bad); }
.sx-ed { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 2px 2px 10px; }
.sx-in { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); flex: 1 1 140px; min-width: 0; font-size: 16px; }
.sx-unit { color: var(--dim); }
.sx-save { background: var(--accent); color: #031722; font-weight: 700; min-height: 42px; }
.sx-cancel { background: var(--track); color: var(--text); min-height: 42px; }
.sx-cap { flex: 1 1 100%; background: var(--track); color: var(--text); font-weight: 600; min-height: 42px; }
.sx-il { cursor: default; }
.sx-v .sx-inl { flex: 0 1 auto; width: auto; max-width: 100%; min-height: 38px; padding: 6px 10px; font-size: 15px; }
.sx-v input.sx-inl { width: 6.5em; text-align: right; }
.sx-sub .sx-cap { flex: 0 1 auto; min-height: 34px; padding: 0 12px; font-size: .75rem; }
/* action rows (firmware check / install, charge to 100%, restart) and the install progress bar */
.sx-bh { cursor: default; }
.sx-btn { background: var(--accent); color: #031722; font-weight: 700; min-height: 38px; padding: 0 14px; white-space: nowrap; }
.sx-btn:disabled { opacity: .45; }
.sx-prog { flex: 1 1 100%; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.sx-prog i { display: block; height: 100%; background: var(--accent); transition: width .5s; }
/* toggle switch */
.sw { position: relative; display: inline-block; width: 46px; height: 26px; border-radius: 13px; background: var(--track); transition: background .2s; }
.sw i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); transition: left .2s; }
.sw.on { background: var(--ok); } .sw.on i { left: 23px; }
@media (max-width: 699px) {
  /* phone: one pane at a time, Back returns to the list */
  .sx { grid-template-columns: minmax(0, 1fr); }
  .sx .sx-detail { display: none; } .sx.detail .sx-list { display: none; } .sx.detail .sx-detail { display: flex; }
  .sx-back { display: inline-block; }
}
@media (max-height: 520px) {
  .sx { grid-template-rows: none; }
  .sx-list, .sx-detail { overflow: visible; height: auto; }
}
/* analog dial theme (gauge.js): dark default, cream face in light theme */
:root { --dg-text: #e8ecf2; --dg-tick: rgba(232,236,242,.85); --dg-minor: rgba(232,236,242,.4); --dg-needle: #d7382d; --dg-face: url(#dg-fd); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --dg-text: #23262b; --dg-tick: rgba(35,38,43,.9); --dg-minor: rgba(35,38,43,.45); --dg-needle: #c62828; --dg-face: url(#dg-fl); }
}
:root[data-theme="light"] { --dg-text: #23262b; --dg-tick: rgba(35,38,43,.9); --dg-minor: rgba(35,38,43,.45); --dg-needle: #c62828; --dg-face: url(#dg-fl); }
.dg { shape-rendering: geometricPrecision; text-rendering: geometricPrecision; overflow: visible; }
.dg-face { fill: var(--dg-face); }
.dg-num, .dg-label { fill: var(--dg-text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.dg-label { font-variant-caps: all-small-caps; letter-spacing: .06em; font-weight: 600; }
.dg-major { stroke: var(--dg-tick); } .dg-minor { stroke: var(--dg-minor); }
.dg-ndl { fill: var(--dg-needle); }
.dg-liq, .dg-merc { transition: transform .8s cubic-bezier(.2,.8,.2,1), opacity .3s; }
.dg-needle { transform-origin: 100px 100px; transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.dg-lcd-v { fill: #e6f0e6; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; }
.dg-unit { fill: #9fb0a0; }
.dg-sub-t { fill: var(--dim); font-family: inherit; }
.dg-word { font-family: inherit; }
@media (prefers-reduced-motion: reduce) { .dg-needle, .dg-liq, .dg-merc { transition: none; } }
/* short viewport (phone in landscape): the fixed one-screen grids cannot fit, so each page scrolls vertically
   with fixed-height rows instead. The horizontal page swipe still works. */
@media (max-height: 520px) {
  .page { overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: none; }
  .page::-webkit-scrollbar { display: none; }
  .page > * { height: auto; min-height: 100%; }
  .brief { grid-template-columns: 5fr 3fr 3fr; grid-template-rows: repeat(2, 150px); }
  .brief .hero { grid-row: span 2; }
  .ovw { grid-template-columns: minmax(0, 1fr); grid-template-rows: 260px auto auto; }
  .ovw .pfwrap { grid-column: 1; grid-row: 1; }
  .ovw .ovdials { grid-column: 1; grid-row: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, 170px); }
  .ovw .stats3 { grid-column: 1; grid-row: 3; font-size: .8rem; gap: 4px; }
  .levels { grid-template-rows: auto auto; }
  .lv-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); grid-auto-rows: 200px; }
  .lv-grid .gcell.vt, .lv-grid .gcell:not(.vt) { grid-column: auto; }
  .hist { grid-template-rows: auto auto; }
  .hgrid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-auto-rows: 210px; overflow: visible; align-content: start; }
}

/* diesel heater (bridge 1.13): one control card - state + toggle (the hot-water idiom), a setpoint stepper, stat tiles */
.heater { display: grid; gap: 8px; grid-template-rows: auto; align-content: start; }
.heater-ctl .big.fault { color: var(--bad); }
.heater-ctl .confirm .small { font-size: .8rem; font-weight: 400; color: var(--dim); }
.sp-row { display: flex; align-items: center; gap: 10px; }
.sp-lbl { flex: 0 0 auto; color: var(--text); font-weight: 600; }
.sp-lbl small { display: block; color: var(--dim); font-size: .7rem; font-weight: 400; }
.sp-btn { width: 52px; min-height: 52px; font-size: 1.6rem; font-weight: 700; background: var(--track); color: var(--text); padding: 0; }
.sp-val { font-size: clamp(26px, 6vw, 40px); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: center; }
.sp-val small { font-size: .9rem; color: var(--dim); margin-left: 3px; font-weight: 500; }
.sp-val.pend { color: var(--warn); }
.sp-amb { margin-left: auto; text-align: right; color: var(--dim); font-size: .72rem; }
.sp-amb b { display: block; color: var(--text); font-size: 1rem; }
.heater-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.heater-stats.fuel { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.heater-stats .stat b small { font-size: .7rem; color: var(--dim); font-weight: 400; }
@media (min-width: 700px) { .heater-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } .heater-stats.fuel { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* hot water timers (Levels card, web 2.11) */
.hw-main { display: grid; gap: 6px; }
.hw-timers { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.hw-timers:empty { display: none; }
.hw-th { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .85rem; color: var(--dim); }
.hw-th button, .hw-t button, .hw-tf .hw-tcancel { background: var(--track); color: var(--text); min-height: 36px; padding: 0 12px; }
.hw-t { display: flex; align-items: center; gap: 10px; }
.hw-t b { font-variant-numeric: tabular-nums; min-width: 3.2em; font-size: 1.05rem; }
.hw-t span { flex: 1 1 auto; min-width: 0; font-size: .85rem; }
.hw-t.off b { opacity: .5; }
.hw-t button { min-width: 44px; font-size: 1.2rem; line-height: 1; }
.hw-tf { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hw-tf input, .hw-tf select { font: inherit; font-size: 16px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); min-width: 0; }
.hw-tf .hw-tset { background: var(--accent); color: #031722; font-weight: 700; min-height: 40px; }
.hw-tf .hw-tcancel { min-height: 40px; }

/* Phone rules for the Car page, kept at the END of the file: they override .car-page / .car / .tyres-van rules of equal
   specificity declared above, so they must come later in the cascade (08/11/2026: an earlier copy sat before them and lost) */
@media (max-width: 599px) {   /* phone: compact head card; the car and tyre panels stack at natural height and the page scrolls */
  .car-head { padding: 5px 10px; gap: 2px 12px; }
  .car-head h2 { font-size: .9rem; }
  .car-dev { font-size: .72rem; }
  .car-dev small { display: none; }
  /* block stacking, not grid: as grid tracks (auto or max-content) Chromium sized the car panel short and the cards
     spilled under the tyres panel (measured on the Pixel 08/11/2026, WebView 156) */
  .car-page { display: block; overflow-y: auto; }
  .car-page > .car { display: block; }
  .car-page > .car > * + *, .car-tyres { margin-top: 8px; }
  .car-cards { overflow: visible; }
  .car-tyres { max-height: none; }
  .tyres-van { max-height: none; }
}
/* Landscape tablet / desktop (web 2.20): car panel left, tyres panel right, both full height. Stacked, the tyres panel
   took up to 45% of the height and squeezed the car panel (the dials it then held drew about 35 px tall on a 960x600 tablet).
   Also at the END of the file, for the same cascade reason as the phone rules. Short viewports (a phone on its side)
   keep the max-height: 520px rule above. */
@media (min-width: 900px) and (min-height: 521px) and (orientation: landscape) {
  .car-page { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); grid-template-rows: minmax(0, 1fr); }
  .car-tyres { max-height: none; }
  .tyres-body { grid-template-rows: minmax(0, 1fr); grid-auto-rows: auto; align-content: stretch; }   /* first vehicle (the van drawing) takes the spare height */
  .tyres-draw { grid-template-rows: auto minmax(0, 1fr) auto; }
  .tyres-van { width: 100%; height: 100%; max-width: none; max-height: none; min-height: 0; }
}
/* Phone on its side: the page scrolls (max-height: 520px rules above), so the van drawing takes a fixed height. Was
   declared with those rules, before the base .tyres-van max-height, and lost to it: the van drew 49 px tall (web 2.20). */
@media (max-height: 520px) {
  .tyres-van { max-height: 260px; }
}

/* tyre alarm (alarm.js, web 2.22): a banner over every page while a live tyre is low / high / hot; flashes while the siren is due */
.tyre-alarm { position: fixed; inset: 0 0 auto 0; z-index: 900; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bad); color: #fff; box-shadow: 0 4px 24px rgba(0,0,0,.55); }
.tyre-alarm[hidden] { display: none; }
.tyre-alarm.loud { animation: ta-flash 1s steps(1, end) infinite; }
@keyframes ta-flash { 50% { background: #7a0e0e; } }
.tyre-alarm .ta-in { max-width: 900px; margin: 0 auto; }
.tyre-alarm .ta-h { font-size: clamp(22px, 5vw, 34px); font-weight: 800; letter-spacing: .06em; }
.tyre-alarm ul { list-style: none; margin: 4px 0 6px; padding: 0; font-size: clamp(16px, 3.6vw, 22px); }
.tyre-alarm li span { opacity: .85; font-size: .85em; margin-left: 4px; }
.tyre-alarm .ta-note { font-size: .85rem; opacity: .9; margin-bottom: 6px; }
.tyre-alarm .ta-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.tyre-alarm button { background: #fff; color: #7a0e0e; font-weight: 700; min-height: 52px; flex: 1 1 140px; font-size: 1.1rem; }
.tyre-alarm button[data-ta="show"] { background: rgba(255,255,255,.18); color: #fff; }
.ta-ctl button { min-height: 32px; padding: 0 12px; margin-left: 6px; }
@media (prefers-reduced-motion: reduce) { .tyre-alarm.loud { animation: none; outline: 4px solid #fff; outline-offset: -4px; } }
