/* Shared visual system. Device validation, pending commands and readback keep their existing state classes. */
:root {
  --cr-ink: #102749;
  --cr-muted: #405b76;
  --cr-blue: #0758b7;
  --cr-line: #c9dcf0;
  --cr-surface: linear-gradient(155deg, #fff 0%, #f6faff 69%, #eaf4fe 100%);
  --cr-shadow: 0 2px 4px #123d6910, 0 6px 16px #16477812;
  --cr-radius: 17px;
  --cr-gap: 16px;
  --cr-pad: clamp(16px, 2vw, 24px);
}
body {
  --ink: var(--cr-ink);
  --muted: var(--cr-muted);
  --blue: var(--cr-blue);
  --line: var(--cr-line);
  --paper: #e5f1fe;
  --nav: #06417d;
  --portal-header-height: 70px;
  color: var(--cr-ink);
  background: radial-gradient(ellipse at top right, #d2e7fc, #edf5fd 62%);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body :is(input, textarea, select, button, .portal-header) {font-family: inherit}
body :is(a, button, select, input, summary):focus-visible {outline: 3px solid #207dc9; outline-offset: 3px}
.icon-library {position: absolute; inset: 0 auto auto 0; pointer-events: none}
.portal-icon {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
body #main {background: none; overflow-wrap: break-word}
body #main [hidden] {display: none !important}
body #main h1,
body #main .live-intro h1 {
  color: var(--cr-ink);
  font-size: clamp(29px, 3vw, 42px);
  font-weight: 760;
  line-height: 1.12;
  letter-spacing: -.038em;
  margin: 0 0 10px;
}
body #main .page-title {margin: 0 0 22px}
body #main .page-title .eyebrow,
body #main .mgmt-eyebrow,
body #main .live-intro .eyebrow {
  margin: 0 0 10px;
  color: var(--cr-blue);
  font-size: 12px;
  font-weight: 730;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .12em;
  word-spacing: .13em;
}
body #main .page-title p:not(.eyebrow) {margin: 0; color: var(--cr-muted); line-height: 1.5}
body #main :is(.card, .control-card, .mgmt-surface, .mgmt-card, .automation-panel, #schedule-editor) {
  min-width: 0;
  border-radius: var(--cr-radius);
}
body #main :is(.card, .mgmt-surface, .mgmt-card, .automation-panel, #schedule-editor),
body #main :is(.control-card):not(.heat-settings-grid > *) {
  border-color: var(--cr-line);
  background: var(--cr-surface);
  box-shadow: var(--cr-shadow);
}
body #main .mgmt-page {max-width: none; margin-inline: 0}
body #main :is(.primary, .secondary, button[type=submit], #heat-save, button[data-discard]):not(:where(.planning-tabs > a)) {
  min-height: 44px;
  border-radius: 12px;
  white-space: normal;
  line-height: 1.3;
}
body #main :is(.primary, .secondary) {gap: 8px}
body #main :is(.form-card, .user-form, .portal-update-card, .form-card > form) {max-width: min(100%, 740px)}
body #main select:not(.native-source) {
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  min-height: 44px;
  padding-inline: 12px 36px;
  border-radius: 11px;
  border-color: #a9c5e0;
  background-color: #f9fcff;
  color: var(--cr-ink);
  text-overflow: ellipsis;
}
body #main :is(select option, select optgroup) {font-family: inherit}
@supports (appearance: base-select) {
  body #main select:not(.native-source):not([multiple]):not([size]),
  body #main select:not(.native-source):not([multiple]):not([size])::picker(select) {appearance: base-select}
  body #main select:not(.native-source):not([multiple]):not([size]) {padding-inline-end: 12px; background-image: none}
  body #main select::picker(select) {
    margin-block: 5px;
    border: 1px solid var(--cr-line);
    border-radius: 12px;
    padding: 4px;
    color: var(--cr-ink);
    box-shadow: var(--cr-shadow);
  }
  body #main select option {padding: 10px; border-radius: 8px}
  body #main select option:checked {color: var(--cr-blue); background: #e8f3ff}
}
body #main footer {color: var(--cr-muted); border-color: var(--cr-line)}
body .sidebar {
  color: white;
  background: #073b72;
  background-image: radial-gradient(ellipse at 100% 90%, #1264a6, transparent 56%), linear-gradient(165deg, #084983, #052e5c 65%);
}
body .sidebar .sidebar-head {background: none}
body .sidebar .brand {font-size: 24px; line-height: 1.1; letter-spacing: -.02em}
body .sidebar .brand-light {font-size: inherit; font-weight: inherit; line-height: inherit}
body .sidebar .brand-mark {
  background: linear-gradient(140deg, #0674c5, #03437d);
  color: white;
  border: 1px solid #8ab9e2;
  border-radius: 13px;
}
body .sidebar .promise {color: #edf6ff; font-size: 13px}
body .sidebar .nav-section {color: #d2eafc; font-size: 11px; letter-spacing: .12em; line-height: 1.3}
body .sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin: 2px 0;
  padding: 9px 11px;
  border-radius: 11px;
  color: #fff;
  font-size: 14px;
  line-height: 1.35;
}
body .sidebar nav a[aria-current=page] {
  color: #063d7b !important;
  background: linear-gradient(150deg, #fff, #c9e3fa) !important;
  box-shadow: inset 0 0 0 1px #ffffffdb;
  font-weight: 720;
}
body .sidebar nav a.nav-overview[aria-current=page] {min-height:48px;padding-block:12px}
body .sidebar nav a:not([aria-current]):hover {background: #ffffff16}
body .sidebar .side-bottom :is(p, button) {display: flex; align-items: center; gap: 9px}
body .portal-header {
  background: #e7f2fe;
  border-bottom: 1px solid #c4dcf1;
  color: var(--cr-muted);
}
body .portal-header .portal-caption {
  color: #235481;
  font-size: 12px;
  font-weight: 720;
  letter-spacing: .095em;
  word-spacing: .13em;
  text-transform: uppercase;
}
body .portal-header #vehicle-menu summary {
  gap: 10px;
  padding: 8px 13px;
  color: #083c77;
  border-radius: 999px;
  border: 1px solid #a7cbed;
  background: var(--cr-surface);
  box-shadow: 0 2px 5px #174c7a16;
}
body .portal-header #vehicle-menu summary .portal-icon {width: 19px; height: 19px}
body .portal-header #vehicle-menu .vehicle-header-arrow {margin-left: auto}
body .portal-header #vehicle-menu ul {border-radius: 14px; border-color: var(--cr-line); box-shadow: var(--cr-shadow)}

@media (min-width: 901px) {
  body {--cr-sidebar: 260px}
  body .sidebar {box-sizing: border-box; width: var(--cr-sidebar) !important; padding: 23px 16px}
  body .sidebar-head {margin: 0 6px 14px; padding-bottom: 13px; border-bottom: 1px solid #ffffff30}
  body #main {
    margin-left: var(--cr-sidebar) !important;
    max-width: calc(var(--portal-content-width) + var(--cr-pad) + var(--cr-pad));
    padding: calc(var(--portal-header-height) + 20px) var(--cr-pad) 26px !important;
  }
  body .portal-header {
    left: var(--cr-sidebar);
    max-width: none;
    padding: 12px var(--cr-pad);
  }
  body .portal-header::after {content: none}
  body .portal-header > .nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: var(--portal-content-width);
  }
}
@media (max-width: 900px) {
  body {--portal-header-height: calc(72px + env(safe-area-inset-top, 0px))}
  body .portal-header > .nav-row {background: #063d76}
  body .portal-header > .status-bar-surface {background: #e5f1fe}
  body .portal-header > .nav-row > .mobile-brand {background: #0860ac}
  body .portal-header > .nav-row > #vehicle-menu summary {
    display: grid;
    grid-template-columns: 19px minmax(0, 1fr) 19px;
    gap: 6px;
    padding-inline: 10px;
    font-size: clamp(16px, 4.7vw, 18px) !important;
  }
  body .portal-header #vehicle-menu .vehicle-header-name {grid-column: 2; text-align: center}
  body .portal-header #vehicle-menu .vehicle-header-arrow {grid-column: 3; margin: 0}
  body .portal-header #vehicle-menu ul a {font-size: 17px !important}
  body #main {
    padding: 16px max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)) !important;
  }
  body #main h1, body #main .live-intro h1 {font-size: clamp(26px, 6.8vw, 34px) !important}
  body #main .page-title {margin-bottom: 18px}
  body .sidebar {
    left: auto !important;
    right: 0 !important;
    width: min(92vw, 420px) !important;
    border-radius: 18px 0 0 18px;
    box-shadow: -14px 0 48px #08214155;
  }
  body.menu-open::after {content: ''; position: fixed; inset: 0; z-index: 45; background: #10274944}
  body .sidebar-scroll {padding-inline: 14px}
}
@media (max-width: 365px) {
  body .portal-header > .nav-row {gap: 6px}
  body .portal-header > .nav-row > #vehicle-menu summary {
    grid-template-columns: 12px minmax(0, 1fr) 12px;
    gap: 2px;
    padding-inline: 3px;
  }
  body .portal-header #vehicle-menu summary > svg {display: none}
  body .portal-header #vehicle-menu .vehicle-header-arrow .portal-icon {width: 12px}
}

/* Keep the overview action in the text column and give the photograph its own space. */
body #main .live-intro {
  padding: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
body #main .live-intro::before {content: none}
body #main .live-intro h1 {text-wrap: balance}
body #main .live-intro:not([data-view=overview]) .eyebrow {display: none}
body #main .live-intro[data-view=overview] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--cr-line);
  border-radius: var(--cr-radius);
  background: var(--cr-surface);
}
body #main .live-intro[data-view=overview]:has(.live-vehicle-photo) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
body #main .live-intro[data-view=overview] .live-intro-copy {
  align-self: center;
  min-width: 0;
  padding: var(--cr-pad);
}
body #main .live-vehicle-photo {
  width: 100%;
  height: 100%;
  min-height: 192px;
  max-height: 250px;
  object-fit: cover;
  object-position: right center;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 37%);
  mask-image: linear-gradient(to right, transparent, #000 37%);
}
body #main .live-intro .voice-entry-shortcut {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 650;
}
@media (max-width: 900px) {
  body #main .live-intro[data-view=overview]:has(.live-vehicle-photo) {
    grid-template-columns: minmax(0, 1fr) clamp(64px, 23vw, 120px);
  }
  body #main .live-intro[data-view=overview] .live-intro-copy {
    position: relative;
    z-index: 1;
    padding: 12px 6px 12px 12px;
  }
  body #main .live-intro[data-view=overview] .eyebrow {display: none}
  body #main .live-intro[data-view=overview] h1 {font-size: clamp(20px, 5.7vw, 30px) !important; margin: 0 0 4px}
  body #main .live-intro[data-view=overview] #page-description {display: none}
  body #main .live-intro .voice-entry-shortcut {margin-top: 5px; min-height: 44px; padding: 6px 8px}
  body #main .live-intro[data-view=overview] .live-vehicle-photo {
    position: absolute;
    inset: 0 0 0 auto;
    width: clamp(118px, 40vw, 218px);
    height: 100%;
    min-height: 0;
    max-height: none;
    object-position: right center;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 clamp(38px, 11vw, 70px));
    mask-image: linear-gradient(to right, transparent, #000 clamp(38px, 11vw, 70px));
  }
}
body #main #connection.live-connection[hidden] {display: none !important}
body #main #connection.live-connection {
  padding: 8px !important;
  gap: var(--cr-gap) !important;
  background: #d4e6f8 !important;
  border: 1px solid #abc8e4 !important;
  border-radius: var(--cr-radius) !important;
  align-items: start;
}
body #main #connection.live-connection .connection-stage {
  min-width: 0;
  padding: 7px 12px !important;
  background: var(--cr-surface) !important;
  border: 1px solid var(--cr-line) !important;
  border-radius: 14px !important;
  box-shadow: var(--cr-shadow) !important;
}
body #main #connection.live-connection .connection-stage > summary {
  display: flex;
  flex-direction: row;
  gap: 7px;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}
body #main .connection-label {display: inline-flex; align-items: center; gap: 7px}
body #main #connection .connection-label {color: var(--cr-ink); font-weight: 700}
body #main #connection.live-connection .connection-stage strong {
  flex: 0 1 auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e5edf6;
}
body #main #connection.live-connection .connection-stage[data-state=ok] strong {background: #d7f3dc; color: #1a5e27}
body #main #connection.live-connection .connection-stage[data-state=warning] strong {background: #fff0d7; color: #824905}
body #main #connection.live-connection .connection-stage[data-state=error] strong {background: #ffe3de; color: #962e27}
body #main #overview-page .metrics {gap: var(--cr-gap) !important}
body #main #overview-page :is(.metric, .automation-overview-item, .device-status-grid > .control-card) {
  border-color: var(--cr-line);
  border-radius: var(--cr-radius);
  box-shadow: var(--cr-shadow);
}
body #main #overview-page .metrics .metric {
  display: flex;
  flex-direction: column;
  background: var(--cr-surface);
  text-align: center;
}
body #main #overview-page .metric-label {color: var(--cr-ink); font-size: 14px}
body #main #overview-page .metrics .metric-label {justify-content: flex-start; text-align: start}
body #main #overview-page .metrics .metric-reading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
}
body #main #overview-page .metrics .metric-reading .metric-value {
  margin: 0;
  text-wrap: balance;
}
body #main #overview-page .metrics .metric-reading-voltage {
  align-items: baseline;
  align-content: center;
  gap: 12px clamp(8px, 3vw, 13px);
}
body #main #overview-page .metrics .metric-reading-voltage .metric-value {white-space: nowrap}
body #main #overview-page .metrics .voltage-battery {
  flex: 0 0 clamp(42px, 38%, 57px);
  position: relative;
  height: 25px;
}
body #main #overview-page .metrics .voltage-battery-terminal {
  display: grid;
  place-items: center;
  position: absolute;
  top: -8px;
  width: 12px;
  height: 9px;
  border: 1px solid #51708a;
  border-bottom: 0;
  border-radius: 2px 2px 0 0;
  color: #294f70;
  font-size: 8px;
  font-weight: 750;
  line-height: 1;
}
body #main #overview-page .metrics .voltage-battery-terminal:first-child {left: 15%}
body #main #overview-page .metrics .voltage-battery-terminal:nth-child(2) {right: 15%}
body #main #overview-page .metrics .voltage-battery-case {
  display: block;
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 1px solid #51708a;
  border-radius: 3px;
}
body #main #overview-page .metrics .voltage-battery-case::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: inset(calc(100% - var(--voltage-level, 0%)) 0 0);
  background: linear-gradient(to bottom, #169c61 0%, #5bb845 32%, #f2d954 55%, #f49943 75%, #e03b43 97%, #d52736 100%);
}
@supports (grid-template-rows: subgrid) {
  body #main #overview-page .metrics .metric {
    display: grid;
    grid-template-rows: subgrid;
    container-type: normal;
    grid-row: span 3;
    row-gap: 0;
  }
  body #main #overview-page .metrics .metric-label {grid-row: 1}
  body #main #overview-page .metrics .metric-reading {grid-row: 2}
  body #main #overview-page .metrics .metric-note {grid-row: 3; align-self: end}
}
body #main #overview-page .metrics .metric-note {margin: auto 0 0; padding-top: 12px}
body #main #overview-page .metric-note,
body #main #gas-overview :is(.gas-status, .gas-detail),
body #main #overview-page .automation-overview-detail {
  font-size: 12px;
  line-height: 1.5;
  color: var(--cr-muted);
}
body #main #overview-page .live-section-icon {border: 0; background: none; color: var(--cr-ink)}
body #main #overview-page .live-section-heading {color: var(--cr-ink)}
body #main #overview-page :is(.automation-overview-grid, #gas-overview, .live-devices-section .device-status-grid) {gap: var(--cr-gap)}
body #main #overview-page :is(.automation-overview-item, .device-status-grid .control-card) h3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-wrap: balance;
}
body #main #overview-page :is(.automation-overview-item, .device-status-grid .control-card) {text-align: center}
body #main #overview-page .automation-overview-item > a {align-self: center; margin-top: auto}
body #main #overview-page .device-status-grid h3::before {content: none}
body #main #overview-page :is(.automation-overview-item, .device-status-grid .control-card) h3 .portal-icon {
  box-sizing: content-box;
  padding: 8px;
  border-radius: 11px;
  background: #e1effe;
  color: var(--cr-blue);
}
body #main #overview-page .automation-overview-item[data-tone=active] .automation-overview-state {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #d7f3df;
  color: #185c24;
}
body #main .gas-overview .gas-card {
  --bottle-width: 62px;
  --gas-ink: #405b76;
  --gas-tone: #8799a8;
  position: relative;
  display: grid;
  grid-template-columns: var(--bottle-width) minmax(0, 1fr);
  align-items: start;
  align-content: start;
  column-gap: 14px;
  background: var(--cr-surface);
}
body #main .gas-overview .gas-card > :not(.gas-illustration) {grid-column: 2}
body #main #gas-overview .gas-card {text-align: center}
body #main #gas-overview .gas-card h3.metric-label {justify-content: center}
body #main #gas-overview .gas-card h3.metric-label::before {content: none}
body #main .gas-overview .gas-card[data-gas-level="normal"] {--gas-ink: #1b653c; --gas-tone: #30894b}
body #main .gas-overview .gas-card[data-gas-level="low"] {--gas-ink: #9c4900; --gas-tone: #d2711a}
body #main .gas-overview .gas-card[data-gas-level="critical"] {--gas-ink: #a52232; --gas-tone: #c53446}
body #main .gas-overview .gas-card .gas-percent {
  color: var(--gas-ink);
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 750;
  margin: 6px 0 7px;
}
body #main .gas-overview .gas-card .gas-track {
  width: 100%;
  height: 9px;
  margin: 9px 0 12px;
  border-radius: 10px;
  background: #e1edf7;
}
body #main .gas-overview .gas-card .gas-fill {
  width: var(--gas-level, 0%);
  background: var(--gas-tone);
}
body #main .gas-overview .gas-card[data-gas-level="critical"] .gas-track {background: #f4dce0}
body #main .gas-overview .gas-card :is(.gas-detail, .gas-status) {font-size: 12px; line-height: 1.5}
body #main .gas-overview .gas-card[data-alarm=true] {border-color: #bc2537; background: #fff2f3}
.gas-illustration {
  grid-row: 1 / span 5;
  align-self: center;
  position: relative;
  justify-self: center;
  width: calc(var(--bottle-width) * .94);
  aspect-ratio: 411 / 852;
}
.gas-illustration::before {
  content: '';
  position: absolute;
  inset: 6% 25% auto;
  height: 19%;
  border: 3px solid #9caeba;
  border-bottom: 0;
  border-radius: 45% 45% 0 0 / 25% 25% 0 0;
  box-shadow: inset 0 1px #fff, 0 -1px 1px #ffffffb3;
}
.gas-illustration::after {
  content: '';
  position: absolute;
  inset: auto 6% 3%;
  height: 8%;
  border: 1px solid #8c9baa;
  border-radius: 0 0 35% 35% / 0 0 27% 27%;
  background: linear-gradient(90deg, #8798a9, #edf2f6 44%, #91a2b1);
  box-shadow: 0 3px 5px #15365528;
}
.gas-bottle-valve {
  position: absolute;
  inset: 12% 38% auto;
  height: 15%;
  background: linear-gradient(#cfac66, #8a632c) center top / 100% 28% no-repeat,
              linear-gradient(90deg, #977039, #e1c485 45%, #987039) center / 36% 100% no-repeat,
              linear-gradient(#d5b778, #95713c) center bottom / 73% 27% no-repeat;
}
.gas-bottle-body {
  position: absolute;
  z-index: 1;
  inset: 22% 0 7%;
  border: 1px solid #8d9eac;
  border-radius: 47% 47% 18% 18% / 22% 22% 8% 8%;
  background: linear-gradient(90deg, #91a0ae, #d6dfe7 27%, #f1f5f9 46%, #a0afbc);
  box-shadow: inset 0 1px #f2f7fbbd;
}
.gas-bottle-body::before {
  content: '';
  position: absolute;
  inset: 18% 6% 3%;
  border-radius: 39% 39% 17% 17% / 13% 13% 8% 8%;
  background: linear-gradient(90deg, #17273e24, #fff3 37%, transparent 62%, #17273e33) bottom / 100% var(--gas-level, 0%) no-repeat,
              linear-gradient(var(--gas-tone), var(--gas-tone)) bottom / 100% var(--gas-level, 0%) no-repeat,
              #7d95aa13;
}
body #main #overview-page .live-devices-section .device-status-grid > .control-card {padding: var(--cr-pad); gap: 7px}
body #main #overview-page .device-status-grid :is(.device-setting,#live-energy-value) {font-size: 17px; order: 1}
body #main #overview-page .device-status-grid :is(.device-freshness,#live-energy-note,.device-power-note) {
  font-size: 12px;
  color: var(--cr-muted);
}
body #main #overview-page .device-status-grid :is(.device-freshness,#live-energy-note) {order: 2}
body #main #overview-page .device-status-grid .device-power-note {order: 3}
body #main #overview-page .device-status-grid .device-planning {order: 4}
body #main #overview-page .device-status-grid a:is([data-device-control],[data-energy-control],[data-extension-control]) {order: 5; min-height: 46px}
body #main #overview-page .automation-overview-item > a {display: inline-flex; align-items: flex-end; min-height: 36px; padding-block: 0}
@media (min-width: 901px) {
  body #main #overview-page .automation-overview-item {padding-bottom: 10px}
  body #main #overview-page .automation-overview-item > a {min-height: 38px}
}
body #main #overview-page::after {content: none}

/* A single, full-row energy editor under the settings it applies to. */
body #main #heat-settings .heat-settings-grid {gap: var(--cr-gap)}
body #main #heat-settings .heat-settings-grid > .control-card {min-width: 0}
body #main #heat-settings #heat-energy {
  margin: var(--cr-gap) 0 0;
  padding: var(--cr-pad);
  border: 1px solid var(--cr-line);
  border-radius: 14px;
  background: #ebf4fd;
}
body #main #heat-energy > h3 {margin: 0 0 6px}
body #main #heat-energy > p {margin: 0 0 16px}
body #main #heat-energy form {margin: 0; max-width: none}
body #main #heat-energy fieldset {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: var(--cr-gap);
  align-items: end;
}
body #main #heat-energy .current {grid-column: 2; grid-row: 1; margin: 0}
body #main #heat-energy label {grid-column: 1; grid-row: 1; margin: 0; max-width: none}
body #main #heat-energy :is(select, .picker-trigger) {width: 100%; max-width: none; margin-top: 6px}
body #main #heat-settings .heat-confirmation {padding-top: var(--cr-pad)}
body #main :is(#heat-panel,#water-panel,#climate-panel) h3 {display: flex; align-items: center; gap: 9px}
body #main :is(.mode-tabs, nav.planning-tabs) {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  width: min(100%, 540px);
  margin: 16px 0 22px;
}
body #main :is(.mode-tabs, nav.planning-tabs) > :is(button,a.secondary) {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 56px;
  margin: 0;
  padding: 7px 8px;
  border: 1px solid #a9c5e0;
  border-radius: 12px;
  background: #f9fcff;
  color: var(--cr-blue);
  font: 650 16px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif;
  white-space: normal;
  text-align: center;
}
body #main :is(.mode-tabs, nav.planning-tabs) > :is(button[aria-selected="true"],a.secondary[aria-current="page"]) {
  background: var(--cr-blue);
  border-color: var(--cr-blue);
  color: #fff;
}

@media (max-width: 1120px) {
  body #main #connection.live-connection .connection-stage > summary {flex-direction: column; justify-content: center}
}
@media (max-width: 900px) {
  :root {--cr-gap: 12px}
  body #main #connection.live-connection {gap: 6px !important; padding: 4px !important}
  body #main #connection.live-connection .connection-stage {padding: 7px 4px !important}
  body #main #connection.live-connection .connection-stage > summary {min-height: 48px; font-size: 11px}
  body #main .connection-label {gap: 4px; justify-content: center; flex-wrap: wrap}
  body #main .connection-label .portal-icon {width: 16px; height: 16px}
  body #main #connection.live-connection .connection-stage strong {font-size: 10px; padding: 3px 4px}
  body #main #overview-page .metrics .metric-label {font-size: 12px; min-height: 25px}
  body #main #overview-page .metrics .live-metric-icon {width: 25px; height: 25px; flex-basis: 25px}
  body #main #overview-page .metrics .metric-note {font-size: 11px; padding-top: 8px}
  body #main #overview-page .metrics .metric {
    display: flex; grid-row: auto; min-height: 0; padding: 12px 11px;
  }
  body #main #overview-page .metrics .metric-reading {min-height: 32px; margin-top: 6px; flex: 1}
  body #main #overview-page .automation-overview-item {padding: 12px 11px; gap: 6px}
  body #main #overview-page .automation-overview-item > a {align-items: flex-end; min-height: 36px; padding-block: 0}

  body #main #overview-page .metrics .metric-reading .metric-value:not(.gas-percent) {
    font-size: clamp(21px, 5.9vw, 27px) !important;
    line-height: 1.08;
  }
  body #main #overview-page .metrics .metric-reading .metric-value.smaller {
    font-size: clamp(17px, 4.5vw, 20px) !important;
    min-height: 0;
    letter-spacing: -.25px;
  }
  body #main #overview-page .metrics .metric-reading-voltage .metric-value:not(.gas-percent) {
    font-size: clamp(19px, 5.6vw, 25px) !important;
  }
  body #main #overview-page .metrics {margin-bottom: 0}
  body #main #overview-page #automation-overview {margin-top: var(--cr-gap)}
  body #main #overview-page #automation-overview > h2 {margin-bottom: var(--cr-gap)}
  body #main #overview-page :is(.metrics .metric, .device-status-grid .control-card)[data-reading-age=fresh]
    :is(.metric-note, .device-freshness, #live-energy-note) {display: none}
  body #main #overview-page :is(.metrics .metric, .device-status-grid .control-card)[data-reading-age=stale]
    :is(.metric-note, .device-freshness, #live-energy-note) {
    margin: 8px 0 0;
    padding: 6px 8px;
    border-radius: 7px;
    background: #fff2b8;
    color: #644b00 !important;
    font-weight: 600;
  }
  body #main #overview-page :is(.metrics .metric, .device-status-grid .control-card)[data-reading-age=expired]
    :is(.metric-note, .device-freshness, #live-energy-note) {
    color: #a51e28 !important;
    font-weight: 600;
  }
  body #main :is(#gas-overview, #sensors-page .gas-overview) {grid-template-columns: minmax(0, 1fr)}
  body #main .gas-overview .gas-card {--bottle-width: 43px; column-gap: 9px; padding: 14px 10px}
  body #main #gas-overview .gas-card h3.metric-label {min-height: 2.4em; align-items: flex-start; line-height: 1.2}
  body #main #sensors-page .gas-overview .gas-card {--bottle-width: 55px; padding-inline: 14px}
  body #main #heat-energy fieldset {grid-template-columns: minmax(0,1fr)}
  body #main #heat-energy .current {grid-column: 1; grid-row: 2}
}
@media (max-width: 520px) {
  body #main :is(#gas-overview, #sensors-page .gas-overview) .gas-card {
    --bottle-width: 55px;
    min-height: 0;
    column-gap: 12px;
    padding: 12px 14px;
  }
  body #main #gas-overview .gas-card h3.metric-label {min-height: 0; font-size: 15px !important}
  body #main :is(#gas-overview, #sensors-page .gas-overview) .gas-card .gas-percent {
    font-size: clamp(25px, 7vw, 32px) !important;
    line-height: 1.15;
    margin: 4px 0;
  }
  body #main :is(#gas-overview, #sensors-page .gas-overview) .gas-card .gas-track {
    height: 8px;
    margin: 5px 0 7px;
  }
  body #main #overview-page .live-devices-section .device-status-grid > .control-card[data-reading-age=fresh] {min-height: 0}
}
@media (max-width: 365px) {
  body #main #overview-page .metrics .metric-label {font-size: 11px; gap: 4px}
  body #main #overview-page .metrics .live-metric-icon {width: 21px; height: 21px; flex-basis: 21px}
}
@media (max-width: 370px) {
  body #main .connection-label .portal-icon {display: none}
}
@media (min-width: 375px) and (max-width: 900px) {
  body #main #overview-page .automation-overview-grid {grid-template-columns: repeat(2, minmax(0, 1fr))}
}
@media (min-width: 375px) and (max-width: 520px) {
  body #main #overview-page .automation-overview-item h3 {line-height: 1.2; min-height: 2.4em}
  body #main #overview-page .automation-overview-item h3 .portal-icon {padding: 4px}
  body #main #overview-page .automation-overview-item .automation-overview-state {font-size: 12px}
  body #main #overview-page .automation-overview-item[data-tone=active] .automation-overview-state {padding-inline: 5px}
  body #main #overview-page .automation-overview-item .automation-overview-state::before {margin-right: 6px}
  body #main #overview-page .automation-overview-item .automation-overview-detail {text-wrap: balance}
  body #main #overview-page .automation-overview-item > a {margin-top: auto}
}

body #main .picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  padding: 9px 13px;
  border: 1px solid #a9c5e0;
  border-radius: 11px;
  background: #f9fcff;
  text-align: left;
  color: var(--cr-ink);
  font: 500 16px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  white-space: normal;
  cursor: pointer;
}
.picker-trigger::after {content: ''; border-right: 2px solid; border-bottom: 2px solid; width: 7px; height: 7px; transform: rotate(45deg); margin: -4px 3px 0 0; flex: none}
.picker-trigger:disabled {opacity: .65; cursor: default}
.picker-options {
  position: fixed;
  inset: auto;
  z-index: 60;
  box-sizing: border-box;
  margin: 0;
  padding: 4px;
  overflow: auto;
  overscroll-behavior: contain;
  background: #f9fcff;
  border: 1px solid var(--cr-line);
  border-radius: 12px;
  box-shadow: 0 6px 22px #16477840;
}
.picker-options button {
  display: block;
  position: relative;
  width: 100%;
  min-height: 44px;
  padding: 9px 30px 9px 10px;
  color: var(--cr-ink);
  font: 500 16px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
  white-space: normal;
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
}
.picker-options button:is(:hover, [aria-selected=true]) {background: #e1effd; color: #064988}
.picker-options button:focus-visible {outline-offset: -3px}
.picker-options [aria-selected=true]::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  width: 6px;
  height: 11px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(-65%) rotate(45deg);
}
.picker-group {font-size: 13px; font-weight: 650; color: var(--cr-muted); padding: 8px 10px 2px}
.picker-error {display: block; margin-top: 6px; color: #a52232; font-size: 14px}
.picker-trigger[aria-invalid=true] {border-color: #c53446}
body #main .voice-speed-field .picker-trigger {max-width: 18rem}
body #main #control-page label:has(.picker-trigger) .picker-trigger,
body #main #sensors-page label:has(.picker-trigger) .picker-trigger {margin-top: 6px}
@media (min-width: 901px) {
  body #main .live-intro .eyebrow {display: none}
}
@media (min-width: 1121px) {
  body #main #connection .connection-label {flex: 0 0 auto; overflow-wrap: normal}
}

body #main #connection.live-connection {align-items: stretch}
body #main #connection.live-connection .connection-stage:not([open]) > summary {height: 100%}
body #main #control-page :is(#heat-panel, #climate-panel) .stepper {max-width: 270px !important}
@media (max-width: 900px) {
  body #main #connection.live-connection .connection-stage > summary {min-height: 60px}
}

body .sidebar nav a:not([aria-current]) {font-weight: 550}
body .sidebar nav a.nav-overview {font-weight: 800}
body #main :is(.account-cards, .portal-update-cards) {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: var(--cr-gap);
  align-items: start;
}
body #main :is(.account-cards, .portal-update-cards) > .card {margin: 0; max-width: none; width: 100%}
body #main :is(.account-cards, .portal-update-cards) form {max-width: none}
body #main .savings-module.savings-portal {max-width: none; margin: 22px 0 0}
body #main .voice-page {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  align-items: start;
  gap: var(--cr-gap);
  max-width: none;
  margin: 0;
}
body #main .voice-page .voice-card {margin: 0; padding: var(--cr-pad)}
body #main .voice-card .voice-speed-field {display: grid; gap: 7px; margin: 16px 0}
body #main .voice-card .voice-audio-controls {gap: 10px; margin-top: 16px}
body #main .voice-card .voice-audio-controls button {white-space: normal}
body #main .voice-card .voice-entry button[type=submit] {
  border: 1px solid var(--cr-blue);
  background: var(--cr-blue);
  color: #fff;
}
body #main .voice-card #voice-text-form {margin-top: 16px}
body #main .voice-card #voice-audio-info {font-size: 14px; line-height: 1.5}
body #main .voice-card .voice-mic .portal-icon {margin-right: 6px}
@media (min-width: 1100px) {
  body #main :is(.account-cards, .portal-update-cards, .voice-page) {grid-template-columns: repeat(2,minmax(0,1fr))}
  body #main .account-cards > .account-password {grid-column: 2; grid-row: 1 / span 2}
  body #main .voice-page .voice-siri-card {grid-column: 1 / -1}
}
body #main .alarm-page > #push-settings {width: 100%; max-width: none}
@media (max-width: 520px) {
  body #main .live-intro-title-suffix {display: block}
  body #main .connection-label {flex-direction: column}
}
@media (max-width: 365px) {
  body #main #connection .connection-label {font-size: 10px}
  body #main #connection.live-connection .connection-stage {padding-inline: 2px !important}
  body #main #connection.live-connection .connection-stage strong {gap: 3px; padding-inline: 3px}
}
@media print {
  body {height: auto; overflow: visible; background: #fff}
  body #main {position: static; max-width: none; margin: 0 !important; padding: 0 !important; overflow: visible}
  body .sidebar, body .portal-header {display: none !important}
}

/* Vehicle selection and its saved mode share the header control. */
body .portal-header #vehicle-menu summary {
  min-height: 46px;
  padding-block: 4px;
}
.vehicle-header-label {display: grid; min-width: 0; text-align: center; line-height: 1.15}
.vehicle-header-label .vehicle-header-name {grid-column: auto !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap}
.vehicle-header-mode {color: #405b77; font-size: 12px; font-weight: 600; margin-top: 2px}
.vehicle-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 10;
  box-sizing: border-box;
  width: min(340px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--cr-line);
  border-radius: 14px;
  background: #fff;
  color: var(--cr-ink);
  box-shadow: var(--cr-shadow);
}
body .portal-header #vehicle-menu .vehicle-menu-panel ul {
  position: static;
  width: auto;
  min-width: 0;
  max-width: none;
  max-height: min(24vh, 210px);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: none;
}
body .portal-header #vehicle-menu .vehicle-menu-panel a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  text-align: left;
  line-height: 1.25;
}
.vehicle-menu-panel .portal-control-switch {margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--cr-line)}
body .portal-header .portal-control-switch button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #fff;
  color: var(--cr-ink);
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}
body .portal-header .portal-control-switch button:hover {background: #eff6fd}
body .portal-header .portal-control-switch button:focus-visible {outline: 2px solid #075ba8; outline-offset: -2px}
.portal-control-switch-state {display: flex; align-items: center; gap: 6px; flex-shrink: 0}
.portal-control-switch-label {color: #526a82; font-size: 13px}
.portal-control-switch-label.selected {color: #075ba8; font-weight: 800}
.portal-control-switch-track {
  display: grid;
  align-items: center;
  box-sizing: border-box;
  width: 36px;
  height: 20px;
  padding-inline: 3px;
  border-radius: 20px;
  background: #526a82;
}
.portal-control-switch-track::before {content: ""; width: 14px; height: 14px; border-radius: 50%; background: #fff}
.portal-control-switch button[aria-checked="true"] .portal-control-switch-track {background: #075ba8}
.portal-control-switch button[aria-checked="true"] .portal-control-switch-track::before {justify-self: end}
button.phone-switch-button[aria-checked="true"] .portal-control-switch-track {background:#075ba8}
button.phone-switch-button[aria-checked="true"] .portal-control-switch-track::before {justify-self:end}
body .alarm-page .automation-toggle{display:flex}
body .alarm-page .automation-toggle::after{display:none}
body .alarm-page .automation-toggle h3{min-width:0;overflow-wrap:normal}
.vehicle-menu-panel a small {display: block; margin-top: 2px; font-size: 12px; color: #405b77}
.vehicle-selected-mark {color: #075ba8}
.vehicle-menu-panel fieldset {min-width: 0; margin: 8px 0 0; padding: 5px 2px 2px; border: 0; border-top: 1px solid var(--cr-line)}
.vehicle-menu-panel legend {font-size: 13px; font-weight: 700; overflow-wrap: anywhere; max-width: 100%; padding: 0 5px}
.vehicle-mode-buttons {display: grid; gap: 5px}
.vehicle-mode-buttons > button {
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 6px 10px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #a7cbed;
  border-radius: 9px;
  background: #fff;
  color: #075194;
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.vehicle-mode-buttons > button[aria-pressed="true"] {background: #075ba8; border-color: #075ba8; color: white}
.vehicle-mode-buttons > button[aria-pressed="true"]::after {content: "✓" / ""; margin-inline-start: 8px}
.desktop-operating-mode {display: none}
@media (max-width: 900px) {
  body .portal-header > .nav-row > #vehicle-menu summary {padding-block: 4px}
  .vehicle-header-label {grid-column: 2}
  .vehicle-menu-panel {left: 50%; right: auto; transform: translateX(-50%); top: calc(100% + 12px)}
  body:has(#vehicle-menu[open]) #main {top: calc(var(--portal-header-height) + var(--vehicle-menu-height, 0px))}
}

@media (min-width: 901px) {
  body #portal-sidebar #control-navigation a.nav-overview > span {font-weight: 900; font-size: 1.04em}
  body:has(.live-intro[data-view="overview"] .desktop-operating-mode) .vehicle-menu-panel > .vehicle-mode-form {display: none}
  body:has(.live-intro[data-view="overview"] .desktop-operating-mode) .vehicle-header-mode:not(.portal-control-off) {display: none}
  body #main .live-intro[data-view=overview]:has(.desktop-operating-mode[open]) {overflow: visible; z-index: 2}
  .desktop-operating-mode {display: block; position: relative; min-width: 0; max-width: 100%}
  .desktop-operating-mode > summary {
    display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 8px;
    box-sizing: border-box; border: 1px solid #a7cbed; border-radius: 9px;
    background: #fff; color: #075194; cursor: pointer; list-style: none;
    font-size: 13px; font-weight: 700;
  }
  .desktop-operating-mode[open] > summary {margin-bottom: 0}
  .desktop-operating-mode > summary::-webkit-details-marker {display: none}
  .desktop-operating-mode > summary svg {width: 14px; height: 14px; flex: none}
  .desktop-operating-mode > .vehicle-mode-form {
    position: absolute; top: calc(100% + 4px); left: 0; z-index: 5;
    width: max-content; min-width: 100%; box-sizing: border-box; margin: 0;
    padding: 6px; border: 1px solid var(--cr-line); border-radius: 10px;
    background: white; box-shadow: var(--cr-shadow);
  }
  .desktop-operating-mode fieldset {min-width: 0; margin: 0; padding: 0; border: 0}
  .desktop-operating-mode legend {position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%)}
  .desktop-operating-mode .vehicle-mode-buttons > button {min-height: 36px}
  body #main .live-intro[data-view=overview]:has(.live-vehicle-photo) {
    grid-template-columns: minmax(0, 53fr) minmax(0, 47fr);
  }
  body #main .live-intro[data-view=overview] .live-intro-copy {
    padding-block: 16px;
  }
  body #main .live-intro[data-view=overview] .live-vehicle-photo {
    contain: size;
    min-height: 150px;
    max-height: none;
    /* The menu can extend beyond the banner, so clip the photo at its own corners. */
    border-top-right-radius: calc(var(--cr-radius) - 1px);
    border-bottom-right-radius: calc(var(--cr-radius) - 1px);
  }

  .live-intro-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px 10px;
    margin-top: 12px;
  }
  body #main .live-intro .live-intro-actions .voice-entry-shortcut {
    min-height: 40px;
    margin: 0;
    padding: 7px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.2;
  }

}

/* Keep the navigation brand independent of page-specific stylesheets. */
body #portal-sidebar .sidebar-head .brand {
  align-items: center;
  gap: 12px;
  margin: 0;
  color: white;
  font: 750 24px/1.1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -.02em;
  text-decoration: none;
}
body #portal-sidebar .sidebar-head .brand-light {
  margin: 0;
  letter-spacing: inherit;
}
body #portal-sidebar .sidebar-head .brand-mark {
  box-sizing: border-box;
  flex: 0 0 50px;
  width: 50px;
  height: 54px;
  letter-spacing: 0;
}
body #portal-sidebar .sidebar-head .promise {
  font: 400 13px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body .portal-header > .nav-row > .mobile-brand {
  line-height: 1;
  letter-spacing: 0;
}

body #main #overview-page .automation-overview-item{padding-block:18px;gap:8px}
body #main #overview-page .automation-overview-item > a{min-height:0;line-height:1.5;align-items:center}
@media(max-width:760px){
  body #main #overview-page .automation-overview-item{padding-block:14px}
}
.setup-countdown:not([hidden]){
  width:fit-content;max-width:100%;margin:8px 0 12px;padding:7px 12px;border-radius:8px;
  background:#e8f2fc;color:#214f76;font-size:.9rem;font-weight:600
}
.setup-countdown time{font-variant-numeric:tabular-nums;white-space:nowrap}
