/* HVAC admin shell and components (spec Rev 1.2 §6). Hand-written, hv- prefixed so it
   coexists with the Bootstrap markup that later PRs replace. Never set a sideways overflow rule on
   html or body: overflow is fixed at its source, not masked (HUI-1). */

/* ---- 6.1 Tokens ---------------------------------------------------------- */
:root {
  --primary: #0f766e; --primary-dk: #115e59; --primary-light: #ccfbf1;
  --bg: #f8fafc; --card: #fff; --text: #0f172a; --text-muted: #64748b;
  --border: #e2e8f0; --radius: 14px; --danger: #dc2626; --danger-bg: #fef2f2; --danger-strong: #b91c1c;
  --warning: #92400e; --warning-bg: #fffbeb; --success: #166534; --success-bg: #f0fdf4;
  --info: #115e59; --info-bg: #f0fdfa;
  --heat: #c2410c; --heat-bg: #ffedd5; --cool: #0369a1; --cool-bg: #e0f2fe; --idle: #64748b;
  --focus: #0f766e; --link: #0f766e;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar-h: 56px; --tabbar-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --primary: #2dd4bf; --primary-dk: #5eead4; --primary-light: #134e4a;
  --bg: #0b1220; --card: #111a2c; --text: #e5edf7; --text-muted: #a7b4c6;
  --border: #2a3a55; --danger: #fca5a5; --danger-bg: #3b1219; --danger-strong: #fca5a5; --warning: #fcd34d;
  --warning-bg: #3a2a0b; --success: #86efac; --success-bg: #0f2e1d; --info: #5eead4;
  --info-bg: #0f2a2a; --heat: #fdba74; --heat-bg: #431b07; --cool: #7dd3fc; --cool-bg: #082f49;
  --idle: #a7b4c6; --focus: #5eead4; --link: #5eead4;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --primary: #2dd4bf; --primary-dk: #5eead4; --primary-light: #134e4a;
    --bg: #0b1220; --card: #111a2c; --text: #e5edf7; --text-muted: #a7b4c6;
    --border: #2a3a55; --danger: #fca5a5; --danger-bg: #3b1219; --danger-strong: #fca5a5; --warning: #fcd34d;
    --warning-bg: #3a2a0b; --success: #86efac; --success-bg: #0f2e1d; --info: #5eead4;
    --info-bg: #0f2a2a; --focus: #5eead4; --link: #5eead4;
    color-scheme: dark;
  }
}
/* Bootstrap reads these, so legacy page markup follows the same palette. */
:root, :root[data-bs-theme] {
  --bs-body-bg: var(--bg); --bs-body-color: var(--text); --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-muted); --bs-secondary: var(--text-muted); --bs-link-color: var(--link);
  --bs-link-color-rgb: 15, 118, 110; --bs-link-hover-color: var(--primary-dk);
  --bs-card-bg: var(--card); --bs-tertiary-bg: var(--card);
}
:root[data-theme="dark"] { --bs-link-color-rgb: 94, 234, 212; }

/* ---- Base ---------------------------------------------------------------- */
body.hv-body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  line-height: 1.5; min-height: 100vh; display: flex; flex-direction: column;
}
.hv-body .text-muted { color: var(--text-muted) !important; }
.hv-body a:not(.btn):not(.hv-btn) { color: var(--link); }
/* Legacy Bootstrap buttons take the teal palette until their pages are restyled. */
.hv-body .btn-primary {
  --bs-btn-bg: var(--primary-dk); --bs-btn-border-color: var(--primary-dk); --bs-btn-color: #fff;
  --bs-btn-hover-bg: #134e4a; --bs-btn-hover-border-color: #134e4a; --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: #134e4a; --bs-btn-active-border-color: #134e4a; --bs-btn-active-color: #fff;
  --bs-btn-disabled-bg: var(--primary-dk); --bs-btn-disabled-border-color: var(--primary-dk);
}
.hv-body .btn-outline-primary {
  --bs-btn-color: var(--primary-dk); --bs-btn-border-color: var(--primary-dk);
  --bs-btn-hover-bg: var(--primary-dk); --bs-btn-hover-border-color: var(--primary-dk);
  --bs-btn-active-bg: var(--primary-dk); --bs-btn-active-border-color: var(--primary-dk);
}
:root[data-theme="dark"] .hv-body .btn-primary {
  --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-color: #04201d;
  --bs-btn-hover-bg: var(--primary-dk); --bs-btn-hover-border-color: var(--primary-dk); --bs-btn-hover-color: #04201d;
  --bs-btn-active-bg: var(--primary-dk); --bs-btn-active-color: #04201d;
  --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-color: #04201d;
}
:root[data-theme="dark"] .hv-body .btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); }
/* Bootstrap's text and outline colours miss 4.5:1 on our backgrounds; map them to tokens. */
.hv-body .text-success { color: var(--success) !important; }
.hv-body .text-danger { color: var(--danger) !important; }
.hv-body .text-warning { color: var(--warning) !important; }
.hv-body .text-info { color: var(--info) !important; }
.hv-body .text-secondary { color: var(--text-muted) !important; }
.hv-body .text-primary { color: var(--primary-dk) !important; }
.hv-body .btn-outline-secondary { --bs-btn-color: var(--text); --bs-btn-border-color: var(--text-muted); --bs-btn-hover-bg: var(--text-muted); --bs-btn-hover-border-color: var(--text-muted); --bs-btn-hover-color: var(--card); --bs-btn-active-bg: var(--text-muted); --bs-btn-active-color: var(--card); }
.hv-body .btn-outline-success { --bs-btn-color: var(--success); --bs-btn-border-color: var(--success); --bs-btn-hover-bg: var(--success); --bs-btn-hover-border-color: var(--success); --bs-btn-hover-color: var(--card); --bs-btn-active-bg: var(--success); --bs-btn-active-color: var(--card); }
.hv-body .btn-outline-danger { --bs-btn-color: var(--danger); --bs-btn-border-color: var(--danger); --bs-btn-hover-bg: var(--danger); --bs-btn-hover-border-color: var(--danger); --bs-btn-hover-color: var(--card); --bs-btn-active-bg: var(--danger); --bs-btn-active-color: var(--card); }
.hv-body .btn-outline-warning { --bs-btn-color: var(--warning); --bs-btn-border-color: var(--warning); --bs-btn-hover-bg: var(--warning); --bs-btn-hover-border-color: var(--warning); --bs-btn-hover-color: var(--card); --bs-btn-active-bg: var(--warning); --bs-btn-active-color: var(--card); }
.hv-body .btn-outline-info { --bs-btn-color: var(--info); --bs-btn-border-color: var(--info); --bs-btn-hover-bg: var(--info); --bs-btn-hover-border-color: var(--info); --bs-btn-hover-color: var(--card); --bs-btn-active-bg: var(--info); --bs-btn-active-color: var(--card); }
.hv-body .form-text { color: var(--text-muted) !important; }
:root[data-theme="dark"] .hv-body .badge.bg-info,
:root[data-theme="dark"] .hv-body .badge.bg-info.text-dark { background: #155e75 !important; color: #ecfeff !important; }
:root[data-theme="dark"] .hv-body .badge.bg-primary { background: #1d4ed8 !important; color: #eff6ff !important; }
:root[data-theme="dark"] .hv-body .badge.bg-secondary { background: #334155 !important; color: #f8fafc !important; }
:root[data-theme="dark"] .hv-body .badge.bg-success { background: #166534 !important; color: #f0fdf4 !important; }
:root[data-theme="dark"] .hv-body .badge.bg-danger { background: #991b1b !important; color: #fef2f2 !important; }
:root[data-theme="dark"] .hv-body .alert-warning { background: #422006 !important; color: #fef3c7 !important; border-color: #92400e !important; }
:root[data-theme="dark"] .hv-body .alert-warning a { color: #fde68a !important; }
:root[data-theme="dark"] .hv-body .alert-info { background: #082f49 !important; color: #e0f2fe !important; border-color: #075985 !important; }
:root[data-theme="dark"] .hv-body .alert-info a { color: #7dd3fc !important; }
:root[data-theme="dark"] .hv-body .alert-danger { background: #450a0a !important; color: #fecaca !important; border-color: #991b1b !important; }
/* Long names inside legacy badges and buttons wrap instead of pushing the page wider (HUI-3). */
.hv-page .badge { white-space: normal; overflow-wrap: break-word; text-align: start; max-width: 100%; }
/* Buttons never wrap (spec Rev 1.6 R1). The page-wide `min-width: 0` and `overflow-wrap` of `anywhere`
   (there so long names wrap) used to let a flex row squeeze a button to one letter ("Sav" / "e"), and
   `.btn` was allowed to wrap. Now a button is never narrower than its label (`min-width: auto` is the
   label's width; the reference sketch's min() of max-content and 100% is not valid CSS), never
   wraps, and a row that holds one wraps instead of squeezing it. */
.hv-btn, .hv-page .btn, .hv-page button:not(.hv-flash__close):not(.btn-close), .hv-page input[type="submit"],
.hv-page input[type="button"], .hv-subtab, .hv-menu-link, .hv-menu-button, .hv-theme__options button {
  white-space: nowrap; overflow-wrap: normal; word-break: normal;
}
.hv-body .hv-btn, .hv-page .btn, .hv-page button:not(.hv-flash__close):not(.btn-close), .hv-page input[type="submit"],
.hv-page input[type="button"], .hv-body .hv-subtab { flex-shrink: 0; min-width: auto; }
.hv-page .flex-shrink-0 { flex-shrink: 0 !important; max-width: 100%; }
/* At 200% text a header row, or a form row of columns, may hold more buttons than fit side by side (Overrides:
   "Apply", "Cancel All Overrides"): the row wraps, and a column holding a button is never narrower than it. */
.hv-page .d-flex:has(:is(.btn, button, .hv-btn, input[type="submit"])):not(.flex-column):not(.flex-nowrap):not(.btn) { flex-wrap: wrap; }
.hv-page .row > [class*="col"]:has(> :is(.btn, button, .hv-btn, input[type="submit"])) { min-width: min-content; }
/* A button as wide as its container (the Google sign-in) may break between words, never past its edge. */
.hv-page .btn.w-100, .hv-page .hv-btn.w-100 { white-space: normal; }
/* A form that holds only buttons (and hidden fields) is never narrower than its button. */
.hv-page form:not(:has(input:not([type="hidden"]), select, textarea)) { min-width: min-content; }
/* 200% text on a phone (Rev 1.7 R3): a label wider than its whole row may wrap, between words only (a word is
   never split: `min-width: auto` keeps the longest word whole and `overflow-wrap` is `normal`). At 100% text every
   label fits its row, so it stays on one line. */
@media (max-width: 767.98px) {
  .hv-page .btn-sm { font-size: min(.875rem, 15px); } /* one long word ("SmartBuildings") must fit at 200% text */
  /* A phone button is .9rem (14.4 px at 100% text) so "Fetch from SmartBuildings" fits one line in a 262 px card
     with the widest fonts (the CI's DejaVu); it grows with larger text up to 7vw (22 px at 320 px), where the longest
     word ("SmartBuildings") still fits. */
  .hv-page .hv-btn { font-size: min(.9rem, max(14px, 7vw)); padding-left: 10px; padding-right: 10px; }
  .hv-btn, .hv-page .btn, .hv-page button:not(.hv-flash__close):not(.btn-close), .hv-page input[type="submit"],
  .hv-page input[type="button"], .hv-subtab, .hv-menu-link, .hv-menu-button, .hv-theme__options button { white-space: normal; }
  .hv-btn, .hv-page .btn, .hv-page button:not(.hv-flash__close):not(.btn-close), .hv-page input[type="submit"],
  .hv-page input[type="button"] { max-width: 100%; }
}
@media (max-width: 768px) {
  .hv-page .d-flex:not(.flex-column):not(.flex-nowrap):not(.btn) { flex-wrap: wrap; }
  .hv-page .btn-group { flex-wrap: wrap; }
}
/* The thermostat label row ("Add label..." + Save), Rev 1.6 R2. The markup still carries d-flex, gap-1 and an inline
   max-width:250px, so the layout is set here with !important (the template is owned by the Today PR). One row from
   481 px, Save under the input on a phone. */
.hv-page form[action$="/label"] { max-width: none !important; width: 100%; display: flex; flex-wrap: wrap !important; gap: 8px !important; }
.hv-page form[action$="/label"] :is(.form-control, .hv-input) { flex: 1 1 9rem; min-width: min(9rem, 100%); width: auto; }
.hv-page form[action$="/label"] :is(.btn, .hv-btn) { flex: 0 0 auto; }
@media (max-width: 480px) { .hv-page form[action$="/label"] :is(.btn, .hv-btn) { flex: 1 1 100%; min-height: 44px; } }
.hv-body :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hv-body img, .hv-body svg, .hv-body video { max-width: 100%; }
.hv-page, .hv-page * { min-width: 0; }
/* Long names wrap. `break-word` only. The `anywhere` and `break-all` values shrink a flex child's min-content to one
   character, which is what let a row squeeze "Save" to "Sav" / "e" (Rev 1.7 R3). No element that contains a
   button, tab or menu row may compute either. */
.hv-page, .hv-page .card { overflow-wrap: break-word; } /* Bootstrap cards reset it to break-word */
/* Plain text that contains no button may break a long word (break-word, not anywhere), so a 200% heading or label never sideways-scrolls. */
.hv-page :is(h1, h2, h3, h4, h5, h6, p, label, legend):not(:has(button, .btn, .hv-btn, input[type="submit"])) { overflow-wrap: break-word; }
.hv-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Skip link: first focusable element, visible on focus. */
.hv-skip {
  position: absolute; left: 8px; top: -100px; z-index: 1100; padding: 10px 16px;
  background: var(--card); color: var(--text); border: 2px solid var(--focus); border-radius: 8px;
}
.hv-skip:focus { top: 8px; }

/* ---- Top bar: one calm row, site name | tabs | account (spec Rev 1.6 R3) ------- */
.hv-topbar {
  container: hvbar / inline-size;
  position: sticky; top: 0; z-index: 1030; background: var(--card); box-sizing: border-box;
  border-bottom: 1px solid var(--border);
}
.hv-topbar__inner {
  max-width: 72rem; margin: 0 auto; padding: 0 16px; height: var(--topbar-h); box-sizing: border-box;
  display: flex; align-items: center; gap: 0 16px; flex-wrap: nowrap;
}
.hv-brand {
  display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; flex: 0 0 auto; margin-right: 8px;
  font-size: 1.05rem; letter-spacing: -.01em; color: var(--text) !important; text-decoration: none; white-space: nowrap;
}
.hv-topbar__end { margin-left: auto; display: flex; align-items: center; gap: 12px; flex: 0 0 auto; min-width: 0; max-width: 100%; }
/* The weather is plain muted text, only where there is room (Today's heading shows it too). */
.hv-chip { display: none; align-items: center; gap: 6px; color: var(--text-muted); font-size: .9rem; white-space: nowrap; }
.hv-chip svg { width: 16px; height: 16px; flex: none; }
/* In rem, so large text asks for the room too: the weather needs 68.75rem (1100 px at 100% text). */
@container hvbar (min-width: 68.75rem) { .hv-chip { display: inline-flex; } }

/* ---- Section tabs: in the top bar from 900 px, the bottom bar below ---------- */
.hv-tabs { order: 0; flex: 0 1 auto; min-width: 0; align-self: stretch; }
.hv-tabs ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; flex-wrap: nowrap; height: 100%; }
.hv-tabs li { display: flex; }
.hv-tab {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 100%; padding: 0 14px; color: var(--text-muted) !important; text-decoration: none;
  white-space: nowrap; font-weight: 600;
}
.hv-tab svg { width: 22px; height: 22px; flex: none; }
.hv-tab:hover { color: var(--text) !important; }
.hv-tab[aria-current="page"] { color: var(--primary-dk) !important; font-weight: 700; }
:root[data-theme="dark"] .hv-tab[aria-current="page"] { color: var(--primary) !important; }
.hv-tab[aria-current="page"]::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px;
  border-radius: 3px 3px 0 0; background: var(--primary);
}
/* The label reserves its bold width, so tabs don't shift when the current one changes. */
.hv-tab__label { display: inline-flex; flex-direction: column; align-items: center; }
.hv-tab__label::after { content: attr(data-label); font-weight: 700; height: 0; visibility: hidden; overflow: hidden; }
.hv-tab:focus-visible { outline-offset: -3px; border-radius: 6px; }
.hv-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.4em;
  height: 1.4em; padding: 0 .4em; border-radius: 999px; font-size: .75rem; font-weight: 700;
  line-height: 1; background: var(--primary-dk); color: #fff;
}
:root[data-theme="dark"] .hv-badge { color: #04201d; }
.hv-badge--danger, .hv-subtab .badge.bg-danger { background: #b91c1c !important; color: #fff !important; }

@media (min-width: 900px) { .hv-tab svg { display: none; } }
/* 200% text on a tablet or laptop (HUI-67): five tabs, the site name and the account button need about 42rem. Below
   48rem of bar (900 px at 100% text never gets here) the tabs take their own row under the site name and the
   account button, and a tab that still doesn't fit moves to the next line, so every tab stays on screen. */
@media (min-width: 900px) {
  @container hvbar (max-width: 48rem) {
    .hv-topbar__inner { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding-top: 4px; padding-bottom: 4px; }
    .hv-tabs { order: 3; flex: 1 1 100%; align-self: auto; }
    .hv-tabs ul { flex-wrap: wrap; height: auto; }
    .hv-tab { height: auto; min-height: 48px; }
  }
}
@media (max-width: 899.98px) {
  :root { --topbar-h: 52px; }
  .hv-topbar__inner { padding: 0 12px; gap: 0 8px; }
  .hv-brand { margin-right: 0; font-size: 1rem; }
  .hv-tab__label::after { content: none; }
  /* The top bar is only the site name and the account button; the bottom bar is the nav. */
  body:not(.hv-has-tabbar) .hv-tabs { display: none; }
  .hv-has-tabbar .hv-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; background: var(--card);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); height: auto;
  }
  .hv-has-tabbar .hv-tabs ul { justify-content: space-around; }
  .hv-has-tabbar .hv-tabs li { flex: 1 1 auto; min-width: min-content; } /* the widest label gets the room it needs */
  /* Bottom-bar labels (spec Rev 1.9 HUI-82): one line each, 12 px at 100% text and 14 px at 200%, never under
     11 px. This is the one text size that grows less than the user's setting (the icons and the top-bar links at
     900 px and up carry the rest); it is the single rule for the label size. */
  .hv-has-tabbar .hv-tab {
    flex-direction: column; gap: 2px; min-height: var(--tabbar-h); padding: 6px 1px;
    width: 100%; min-width: 0; box-sizing: border-box;
    font-size: clamp(11px, 0.75rem, 14px); border-radius: 0; white-space: nowrap; text-align: center;
    max-width: 100%; overflow: visible; font-weight: 500;
  }
  .hv-has-tabbar .hv-tab__label {
    display: block; max-width: 100%; white-space: nowrap; overflow-wrap: normal;
  }
  .hv-has-tabbar .hv-tab[aria-current="page"] { font-weight: 700; }
  .hv-has-tabbar .hv-tab[aria-current="page"]::after {
    left: 18%; right: 18%; top: 0; bottom: auto; border-radius: 0 0 3px 3px;
  }
  .hv-has-tabbar .hv-tab .hv-badge { position: absolute; top: 4px; right: 4px; }
  .hv-has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
}
/* 200% text on a phone: one row no longer fits, so the bar grows to two rows instead of overflowing. */
@media (max-width: 767.98px) {
  .hv-topbar__inner { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding-top: 4px; padding-bottom: 4px; }
  .hv-brand { min-width: 0; }
}
/* iPhone landscape: the bar would take a fifth of the height, so it sits in flow. */
@media (max-width: 899.98px) and (max-height: 420px) {
  .hv-topbar__inner { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; }
  .hv-has-tabbar .hv-tabs { position: static; border-top: 0; order: 3; flex-basis: 100%; }
  .hv-has-tabbar .hv-tab { min-height: 44px; padding-top: 2px; padding-bottom: 2px; }
  .hv-has-tabbar .hv-tab svg { width: 18px; height: 18px; }
  .hv-has-tabbar .hv-tabs ul { flex-wrap: wrap; } /* the widest fonts (the CI's DejaVu) need a second line at 320 px and 200% text */
  .hv-has-tabbar { padding-bottom: 0; }
}

/* ---- Account menu (<details>): a labelled button, not an initial (Rev 1.6 R4) ---- */
.hv-account { position: relative; min-width: 0; }
.hv-account > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; min-width: 0; max-width: 100%; padding: 0 8px 0 10px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.hv-account > summary::-webkit-details-marker { display: none; }
.hv-account > summary:hover { background: var(--bg); }
.hv-account[open] > summary { border-color: var(--primary); }
.hv-account__icon { width: 18px; height: 18px; flex: none; }
.hv-account__chev { width: 14px; height: 14px; flex: none; color: var(--text-muted); transition: transform .15s; }
.hv-account[open] .hv-account__chev { transform: rotate(180deg); }
.hv-account__name { white-space: nowrap; max-width: 12.5rem; overflow: hidden; text-overflow: ellipsis; }
.hv-account__word { display: none; }
@media (max-width: 359.98px) { .hv-account__name { display: none; } .hv-account__word { display: inline; } }
.hv-account__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1040;
  width: min(20rem, calc(100vw - 24px)); max-height: calc(100vh - 2 * var(--topbar-h) - 24px); overflow-y: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .18); padding: 0 0 8px;
}
.hv-account__who { padding: 12px 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.hv-account__who strong { display: block; overflow-wrap: break-word; }
.hv-account__who span { display: block; color: var(--text-muted); font-size: .9rem; overflow-wrap: break-word; }
.hv-account__panel > a, .hv-account__panel > form, .hv-account__panel > fieldset { margin-left: 8px; margin-right: 8px; width: auto; }
.hv-menu-link, .hv-menu-button {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 10px; background: none; color: var(--text) !important;
  text-decoration: none; font: inherit; text-align: left; cursor: pointer;
  white-space: nowrap;
}
.hv-menu-link:hover, .hv-menu-button:hover { background: var(--bg); }
.hv-menu-link[aria-current="page"] { font-weight: 700; color: var(--primary-dk) !important; }
.hv-menu-sep { height: 0; margin: 8px 0; border: 0; border-top: 1px solid var(--border); }
.hv-theme { border: 0; padding: 0; margin: 0 8px; min-width: 0; }
.hv-theme legend { padding: 0 8px; font-weight: 600; font-size: .85rem; color: var(--text-muted); float: none; width: auto; margin: 0; }
.hv-theme__options { display: flex; flex-direction: column; gap: 0; }
.hv-theme__options button {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 10px; background: none; text-align: left; font: inherit; color: var(--text); cursor: pointer;
}
.hv-theme__options button:hover { background: var(--bg); }
.hv-theme__options button[aria-pressed="true"] { color: var(--primary-dk); font-weight: 700; }
:root[data-theme="dark"] .hv-theme__options button[aria-pressed="true"] { color: var(--primary); }
.hv-theme__options button[aria-pressed="true"]::after { content: "✓"; }
.hv-account form { margin: 0 8px; }

/* ---- 6.2 Layout ------------------------------------------------------------ */
.hv-page { width: 100%; max-width: 72rem; margin: 0 auto; padding: 16px; flex: 1 0 auto; }
/* Bootstrap gutters are in rem, so at 200% text they outgrow the page padding. */
.hv-page .row { --bs-gutter-x: min(1.5rem, 24px); }
@media (max-width: 359.98px) { .hv-page { padding: 12px; } .hv-page .row { --bs-gutter-x: 16px; } }
.hv-stack { display: flex; flex-direction: column; gap: 12px; }
.hv-page fieldset { min-width: 0; max-width: 100%; border: 0; margin: 0 0 12px; padding: 0; }
.hv-page legend { font-weight: 600; padding: 0; }
/* Bootstrap's .form-check-label is inline-block, so an unbroken zone name sets the row width. */
.hv-page .form-check-label { max-width: 100%; }
.hv-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hv-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
.hv-page-title { font-size: 1.5rem; line-height: 1.25; font-weight: 700; margin: 4px 0 8px; }
.hv-page-header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; margin-bottom: 8px; }
.hv-page-header .hv-page-title { flex: 1 1 14rem; }
.hv-subtitle { color: var(--text-muted); margin: 0 0 8px; }

/* Sub-tabs: links under the title, wrap, never scroll. */
.hv-subtabs ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.hv-subtabs li { max-width: 100%; }
.hv-subtab {
  display: inline-block; max-width: 100%; min-height: 44px; padding: 10px 14px;
  border-radius: 999px; border: 1px solid var(--border); color: var(--text) !important;
  text-decoration: none; background: var(--card); line-height: 1.3;
}
.hv-subtab[aria-current="page"] { background: var(--primary-dk); border-color: var(--primary-dk); color: #fff !important; font-weight: 700; }
:root[data-theme="dark"] .hv-subtab[aria-current="page"] { color: #04201d !important; background: var(--primary); }
.hv-subtab .badge { font-size: .75rem; }
.hv-subtab, .hv-subtabs li { max-width: 100%; }

/* ---- 6.3 Components -------------------------------------------------------- */
.hv-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.hv-card + .hv-card { margin-top: 12px; }
.hv-card__title { font-size: 1.1rem; font-weight: 700; margin: 0 0 8px; }
.hv-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  border: 1px solid currentColor; font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.hv-pill svg { width: 12px; height: 12px; flex: none; }
.hv-pill--heat { color: var(--heat); background: var(--heat-bg); }
.hv-pill--cool { color: var(--cool); background: var(--cool-bg); }
.hv-pill--idle, .hv-pill--muted { color: var(--idle); white-space: normal; }
.hv-pill--ok { color: var(--success); background: var(--success-bg); }
.hv-pill--warn { color: var(--warning); background: var(--warning-bg); }
.hv-pill--bad { color: var(--danger); background: var(--danger-bg); }
.hv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: inherit;
  font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; text-align: center;
  white-space: nowrap;
}
/* Link buttons and "needs a look" rows carry a sentence or an event title.
   Those wrap at word boundaries. Command buttons stay on one line. */
.hv-btn--link, .today-look {
  white-space: normal; max-width: 100%; overflow-wrap: break-word;
}
.hv-btn--primary { background: var(--primary-dk); color: #fff !important; }
:root[data-theme="dark"] .hv-btn--primary { background: var(--primary); color: #04201d !important; }
.hv-btn--secondary { background: var(--card); color: var(--text) !important; border-color: var(--border); }
.hv-btn--danger { background: #b91c1c; color: #fff !important; }
.hv-btn--link { background: none; color: var(--link) !important; text-decoration: underline; padding: 0 4px; }
.hv-btn[disabled] { opacity: .6; cursor: progress; }
.hv-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.hv-field label { font-weight: 600; }
.hv-field__hint { color: var(--text-muted); font-size: .9rem; }
.hv-field__error { color: var(--danger); font-size: .9rem; font-weight: 600; }
.hv-input {
  box-sizing: border-box; min-width: 0; max-width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-size: 16px; width: 100%;
}
/* A long value must not set the form's width (HUI-1 at 200% text). */
.hv-input-button { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.hv-input-button .hv-input { flex: 1 1 8rem; width: 1%; min-width: 0; overflow: hidden; }
.hv-input[aria-invalid="true"] { border-color: var(--danger); }
.hv-choice { position: relative; display: inline-flex; max-width: 100%; min-width: 0; }
.hv-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
/* inline-block, not inline-flex: a flex label's anonymous text item keeps the full word as its
   minimum, so a long room name spills. min-width: 0 lets this flex child shrink; break-word wraps it. */
.hv-choice label {
  display: inline-block; box-sizing: border-box; max-width: 100%; min-width: 0; white-space: normal;
  min-height: 44px; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
}
.hv-choice input:checked + label { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.hv-choice input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.hv-empty, .hv-error-state { text-align: center; padding: 24px 16px; }
.hv-empty__title, .hv-error-state__title { font-size: 1.15rem; font-weight: 700; margin: 0 0 4px; }
.hv-empty p, .hv-error-state p { color: var(--text-muted); margin: 0 0 12px; }
.hv-danger-zone { border-color: var(--danger); margin-top: 24px; }
.hv-danger-zone .hv-card__title { color: var(--danger); }
.hv-disclosure > summary {
  cursor: pointer; display: flex; align-items: center; min-height: 44px; font-weight: 600; list-style: none;
  white-space: normal; max-width: 100%; overflow-wrap: break-word;
}
.hv-disclosure > summary::-webkit-details-marker { display: none; }
.hv-disclosure > summary::after { content: "▾"; margin-left: 6px; }
.hv-disclosure[open] > summary::after { content: "▴"; }

/* ---- 6.5 Flash messages ---------------------------------------------------- */
.hv-flashes { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.hv-flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 6px 10px 12px;
  border: 1px solid var(--border); border-left: 6px solid; border-radius: 10px; background: var(--card);
}
.hv-flash svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.hv-flash__body { flex: 1; padding-top: 1px; }
.hv-flash__kind { font-weight: 700; margin-right: 4px; }
.hv-flash--success { border-left-color: var(--success); background: var(--success-bg); }
.hv-flash--success svg, .hv-flash--success .hv-flash__kind { color: var(--success); }
.hv-flash--info { border-left-color: var(--info); background: var(--info-bg); }
.hv-flash--info svg, .hv-flash--info .hv-flash__kind { color: var(--info); }
.hv-flash--warning { border-left-color: var(--warning); background: var(--warning-bg); }
.hv-flash--warning svg, .hv-flash--warning .hv-flash__kind { color: var(--warning); }
.hv-flash--error { border-left-color: var(--danger); background: var(--danger-bg); }
.hv-flash--error svg, .hv-flash--error .hv-flash__kind { color: var(--danger-strong); }
.hv-flash__close {
  flex: none; width: 44px; height: 44px; margin: -8px 0; border: 0; background: none;
  color: var(--text-muted); font-size: 1.4rem; line-height: 1; cursor: pointer; border-radius: 8px;
}

/* ---- Footer ------------------------------------------------------------------ */
.hv-footer { border-top: 1px solid var(--border); background: var(--card); }
.hv-footer ul {
  list-style: none; margin: 0 auto; max-width: 72rem; padding: 4px 16px;
  display: flex; flex-wrap: wrap; gap: 0 16px;
}
.hv-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text-muted) !important; white-space: nowrap; }

/* ---- 6.4 Tables become cards below the breakpoint ---------------------- */
.hv-page td, .hv-page th { overflow-wrap: break-word; }
/* A long address or serial in a cell with no button in it wraps anywhere, so a table can shrink to the screen at
   200% text. (Never in a cell that holds a button: HUI-67 keeps `anywhere` out of every button's ancestors.) */
.hv-page :is(td, th):not(:has(:is(.btn, button, .hv-btn, input[type="submit"], input[type="button"], summary))) { overflow-wrap: anywhere; }
@media (max-width: 719.98px) {
  .hv-page table:not(.hv-table--stack), .hv-page table:not(.hv-table--stack) > tbody { display: block; width: 100%; }
  .hv-page table:not(.hv-table--stack) > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .hv-page table:not(.hv-table--stack) tr {
    display: block; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px;
    margin-bottom: 12px; background: var(--card);
  }
  .hv-page table:not(.hv-table--stack) td, .hv-page table:not(.hv-table--stack) tbody th {
    display: block; border: 0 !important; padding: 4px 0 !important; text-align: left !important; width: auto !important;
  }
  .hv-page td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; font-size: .8rem; font-weight: 700; color: var(--text-muted);
  }
  .hv-page td:last-child :is(.btn, button, .hv-btn) { width: 100%; }
}
@media (max-width: 959.98px) {
  .hv-page table.hv-table--wide, .hv-page table:has(> thead > tr > :nth-child(5)) { display: block; }
  .hv-page table.hv-table--wide > thead, .hv-page table:has(> thead > tr > :nth-child(5)) > thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
  }
  .hv-page table.hv-table--wide > tbody, .hv-page table:has(> thead > tr > :nth-child(5)) > tbody,
  .hv-page table.hv-table--wide tr, .hv-page table:has(> thead > tr > :nth-child(5)) tr {
    display: block; width: 100%;
  }
  .hv-page table.hv-table--wide tr, .hv-page table:has(> thead > tr > :nth-child(5)) tr {
    border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px;
  }
  .hv-page table.hv-table--wide td, .hv-page table:has(> thead > tr > :nth-child(5)) td {
    display: block; border: 0 !important; padding: 4px 0 !important;
  }
  .hv-page table.hv-table--wide td[data-label]::before,
  .hv-page table:has(> thead > tr > :nth-child(5)) td[data-label]::before {
    content: attr(data-label); display: block; font-size: .8rem; font-weight: 700; color: var(--text-muted);
  }
}
/* Two-column reference tables (Help): first cell is the term, second its text. */
@media (max-width: 719.98px) {
  .hv-page table.hv-table--stack, .hv-page table.hv-table--stack > tbody,
  .hv-page table.hv-table--stack tr, .hv-page table.hv-table--stack td,
  .hv-page table.hv-table--stack th { display: block; width: 100%; }
  .hv-page table.hv-table--stack > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .hv-page table.hv-table--stack td:first-child { font-weight: 700; border: 0; padding-bottom: 0; }
}
.hv-table-wrap { max-width: 100%; }

/* ---- 6.6 Touch targets and form text on legacy (Bootstrap) markup ------------ */
@media (pointer: coarse) {
  .hv-btn, .hv-page .btn, .hv-page button, .hv-page summary, .hv-page select,
  .hv-page input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=range]),
  .hv-page textarea, .hv-page .form-check-label, .hv-page .dropdown-item, .hv-page .nav-link,
  .hv-page .list-group-item-action, .hv-page .page-link, .hv-page .form-select, .hv-page .form-control {
    min-height: 44px;
  }
  .hv-page .btn, .hv-page summary {
    display: inline-flex; align-items: center; justify-content: center;
  }
  /* A checkbox/radio label is a block, not a flex row: with `inline-flex` every loose text run, <br>, <small>
     and <a> inside it became its own flex item (iPhone/WebKit squeezed "Email me HVAC alerts" to one word per
     line and the "privacy policy" link to 2-3 letters per line). As a block the text flows and wraps at word
     boundaries; padding gives the 44px target. */
  .hv-page .form-check-label { display: block; flex: 1 1 0; min-width: 0; padding-block: 10px; box-sizing: border-box; }
  .hv-page a:not(p a):not(label a):not(.hv-skip) { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; }
  .hv-page .hv-error-page a.hv-btn {
    display: inline-block; box-sizing: border-box; max-width: 100%; height: auto;
    white-space: normal; overflow-wrap: break-word;
  }
  .hv-page .form-check { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 8px; min-height: 44px; }
  .hv-page .form-check > :not(input):not(label) { flex: 1 1 100%; min-width: 0; margin: 0 !important; } /* a description is a full row under the toggle + label */
  .hv-page .form-check .form-check-input { margin-top: 14px; flex: none; }
  /* A label that wraps its own input: flex row only while it holds nothing but the input and text. */
  .hv-page label:has(> input[type=checkbox], > input[type=radio]):not(:has(> :not(input))) { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
  .hv-page label:has(> input[type=checkbox], > input[type=radio]):has(> :not(input)) { display: block; min-height: 44px; padding-block: 10px; box-sizing: border-box; }
  .hv-page label:has(> input[type=checkbox], > input[type=radio]):has(> :not(input)) > input { margin-inline-end: 8px; vertical-align: middle; }
  .hv-page .btn-close { width: 44px; height: 44px; }
}
/* ---- Phones: toggle / checkbox rows and pick-cards (iPhone squish sweep) ------------------------------------
   <= 480px: [toggle] [label] on one line, the description (any sibling that is not the input or label, a full
   row from the touch block above) starts at the row's left edge instead of the label's indent. */
@media (max-width: 480px) {
  .hv-page .form-check:has(> :not(input):not(label)) { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 8px; padding-left: 0; }
  .hv-page .form-check:has(> :not(input):not(label)) > .form-check-input { margin-left: 0; }
  .hv-page .form-check:has(> :not(input):not(label)) > .form-check-label { flex: 1 1 0; min-width: 0; }
  .hv-page .form-check > :not(input):not(label) { flex: 1 1 100%; min-width: 0; margin: 0 !important; }
}
/* Large text on a phone (iOS "aA" zoom, 150-200%): rem-based padding and list indents grow with the text and left a
   116px column for a checkbox label. On phones, spacing stops growing past its 100% size; text still does. */
@media (max-width: 480px) {
  .hv-page .card-body, .hv-page .p-3 { padding: min(1rem, 16px) !important; }
  .hv-page .p-4 { padding: min(1.5rem, 20px) !important; }
  .hv-page .px-3 { padding-inline: min(1rem, 16px) !important; }
  .hv-page .px-4 { padding-inline: min(1.5rem, 20px) !important; }
  .hv-page :where(ul, ol):where(:not([class])) { padding-left: min(2rem, 20px); }   /* low specificity: .hv-subtabs ul, .list-unstyled keep their own */
}
@media (pointer: coarse) {
  .hv-page .btn { min-width: 44px; }   /* "Edit" was 43px and "All" 34px wide: a 44 x 44 target */
}
.hv-page .badge { font-size: max(.75em, 11px); }   /* .75em inside .small was 10.5px */
/* A pick-card holding a name over a serial (Find thermostats): the two stack instead of sharing one row. */
.hv-choice label:has(> div, > strong) { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding-block: 8px; border-radius: 22px; min-width: 0; }
.hv-choice .tstat-title, .hv-choice .tstat-serial { max-width: 100%; min-width: 0; }
@media (max-width: 768px) {
  .hv-body input, .hv-body select, .hv-body textarea,
  .hv-body .form-control, .hv-body .form-select, .hv-body .form-control-sm, .hv-body .form-select-sm {
    font-size: 16px !important;
  }
}

/* ---- Error pages ------------------------------------------------------------ */
.hv-error-page { max-width: 34rem; margin: 24px auto; text-align: center; }
.hv-error-page .hv-page-title { margin-bottom: 8px; }
.hv-error-page p { color: var(--text-muted); }
.hv-error-page .hv-btn {
  display: inline-block; box-sizing: border-box; max-width: 100%; height: auto;
  padding: 10px 16px; white-space: normal; overflow-wrap: break-word;
}

@media print { .hv-topbar, .hv-tabs, .hv-footer { display: none; } }

/* ==== Requests: comfort reports and event requests (PR 4) ====================
   One self-contained section so it merges cleanly beside the shell rules (PR 2.1).
   Spec Rev 1.7 HUI-67: labels stay on one line at 100% text; the phone block at the end of
   this section lets them wrap between words only at 200% text. No overflow-wrap:anywhere or
   word-break:break-all anywhere in a button, tab, nav or menu chain. ============ */
.hv-filter { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.hv-filter a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card); color: var(--text) !important; text-decoration: none;
  flex: 0 0 auto; white-space: nowrap;
}
.hv-filter a[aria-current] { background: var(--primary-dk); border-color: var(--primary-dk); color: #fff !important; font-weight: 700; }
:root[data-theme="dark"] .hv-filter a[aria-current] { background: var(--primary); color: #04201d !important; }
.hv-list { display: flex; flex-direction: column; gap: 12px; margin: 0 0 16px; padding: 0; list-style: none; }
.hv-list > li { margin: 0; }
.hv-item { position: relative; display: flex; flex-direction: column; gap: 8px; }
.hv-item + .hv-item { margin-top: 0; }
.hv-item__title { font-size: 1.1rem; font-weight: 700; margin: 0; line-height: 1.3; }
/* inline-block, not inline-flex, so a long room name wraps. align-content centers the line in the 44px box. */
.hv-page .hv-item__title .hv-item__link {
  display: inline-block; box-sizing: border-box; align-content: center; max-width: 100%; min-width: 0; min-height: 44px;
  color: var(--text) !important; text-decoration: none;
}
.hv-item__link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.hv-item__link:focus-visible::after { outline: 3px solid var(--focus); outline-offset: 2px; }
.hv-item__meta { margin: 0; color: var(--text-muted); font-size: .95rem; }
.hv-item__note {
  margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hv-item__extra { position: relative; z-index: 1; }
.hv-item__extra > summary { color: var(--link); }
.hv-item__extra form { margin: 8px 0 0; }
.hv-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.hv-chips li {
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); font-size: .9rem;
}
.hv-fieldset { border: 0; padding: 0; margin: 0 0 12px; min-width: 0; }
.hv-fieldset > legend { font-weight: 600; padding: 0; margin-bottom: 4px; font-size: 1rem; float: none; width: auto; }
.hv-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.hv-facts { margin: 0; }
.hv-facts dt { font-weight: 600; margin-top: 12px; }
.hv-facts dt:first-child { margin-top: 0; }
.hv-facts dd { margin: 2px 0 0; }
@media (min-width: 480px) {
  .hv-facts { display: grid; grid-template-columns: max-content 1fr; column-gap: 16px; row-gap: 8px; }
  .hv-facts dt, .hv-facts dd { margin: 0; }
}
.hv-decision { display: grid; gap: 12px; margin: 0 0 12px; }
@media (min-width: 720px) { .hv-decision { grid-template-columns: 1fr 1fr; align-items: start; } }
.hv-decision .hv-btn { width: 100%; }
.hv-zone-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin: 0 0 8px; }
.hv-zone-row .hv-field { margin: 8px 0 0; }
/* Two columns only when "Start time" and "End time" still fit on one line at 200% text
   (DejaVu, the CI font). Measured: 440 px / 32 px root wraps "Start time"; 441 px does not. */
.hv-temps { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 441px) { .hv-temps { grid-template-columns: 1fr 1fr; } }
.hv-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.hv-actions-row > * { flex: 1 1 10rem; }
.hv-item .hv-pill, .hv-zone-row .hv-pill { max-width: 100%; white-space: normal; overflow-wrap: break-word; }
.hv-prewrap { white-space: pre-line; overflow-wrap: break-word; }
.hv-btn-note { margin-top: 4px; }
.hv-item__extra .hv-btn, .hv-decision .hv-btn { white-space: nowrap; }
@media (max-width: 767.98px) {
  .hv-item__extra .hv-btn { width: 100%; }
  .hv-filter a, .hv-item__extra .hv-btn, .hv-decision .hv-btn, .hv-actions-row > .hv-btn { white-space: normal; }
}
/* A 27-character label ("Resolve and email Jane Doee", HUI-62) must stay on one line at 320 px even in a
   wide fallback font, so the card buttons give up a little padding and size there. rem, so 200% text scales it. */
@media (max-width: 359.98px) {
  .hv-item__extra .hv-btn { padding-inline: 8px; font-size: .9rem; }
}
/* ==== end Requests ==== */

/* HUI-82 full-width buttons
   At 480px and below, a label that does not fit beside its field takes the
   full width on the next line. Words stay whole: normal wrapping only, never
   a mid-word break. */
@media (max-width: 480px) {
  [data-fetch-thermostats],
  button[name="apply_now"],
  form[action="/admin/thermostats/assign"] > .hv-btn,
  .hv-input-button > .hv-btn {
    box-sizing: border-box;
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
    height: auto;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
  }
  /* .72rem is 11.5px at 100% text, so the full label stays one line in a 262px
     card with the wide CI font. At 200% text it grows up to 7vw and wraps between words. */
  .hv-page [data-fetch-thermostats] { font-size: min(.72rem, max(11px, 7vw)); }
}

/* ---- Phone section menu (HUI-84, HUI-83) ---------------------------------
   At 480px and below, every .hv-subtab group is one full-width <details> menu
   in normal flow (not sticky, not an overlay). Above 480px the pill row is
   unchanged and this menu is hidden. Both layouts are rendered from the same
   `tabs` list in templates/_ui.html. Labels wrap at word boundaries and keep
   at least an 8ch line box: no overflow-wrap:anywhere and no word-break:break-all. */
.hv-section-menu { display: none; position: static; margin: 0 0 12px; max-width: 100%; }
@media (max-width: 480px) {
  .hv-subtabs ul.hv-subtabs__pills { display: none; }
  .hv-page .hv-section-menu { display: block; position: static; width: 100%; max-width: 100%; }
  .hv-page .hv-section-menu > summary {
    display: flex; align-items: center; justify-content: flex-start; gap: 8px;
    width: 100%; max-width: 100%; box-sizing: border-box; min-height: 44px; height: auto;
    margin: 0; padding: 10px 14px; list-style: none; cursor: pointer;
    background: var(--card); color: var(--text); border: 1px solid var(--border);
    border-radius: var(--radius); position: static;
    white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: none;
  }
  .hv-page .hv-section-menu > summary::-webkit-details-marker { display: none; }
  .hv-page .hv-section-menu > summary::marker { content: ""; }
  .hv-page .hv-section-menu__name,
  .hv-page .hv-section-menu__label {
    flex: 1 1 auto; min-width: 8ch; max-width: 100%;
    white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: none;
  }
  .hv-page .hv-section-menu__name { font-weight: 700; text-align: start; }
  .hv-page .hv-section-menu__chev {
    flex: 0 0 16px; width: 16px; height: 16px; min-width: 16px; margin-left: 0; color: var(--text-muted);
  }
  .hv-page .hv-section-menu[open] > summary .hv-section-menu__chev { transform: rotate(180deg); }
  .hv-page .hv-section-menu__sum { flex: none; }
  .hv-page .hv-section-menu .badge.bg-danger { background: #b91c1c !important; color: #fff !important; }
  .hv-page .hv-section-menu__panel {
    position: static; margin-top: 8px; background: var(--card); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius); max-width: 100%;
  }
  .hv-page .hv-section-menu__list { display: block; gap: 0; list-style: none; margin: 0; padding: 0; }
  .hv-page .hv-section-menu__list li { margin: 0; max-width: 100%; }
  .hv-page .hv-section-menu__list li + li { border-top: 1px solid var(--border); }
  .hv-page .hv-section-menu a.hv-section-menu__link {
    display: flex; align-items: center; justify-content: flex-start; gap: 8px;
    width: 100%; max-width: 100%; box-sizing: border-box; min-height: 44px; height: auto;
    padding: 10px 14px; text-decoration: none; color: var(--text) !important;
    font-weight: 500; background: transparent; position: static;
    white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: none;
  }
  .hv-page .hv-section-menu a.hv-section-menu__link[aria-current="page"] { font-weight: 700; }
  .hv-page .hv-section-menu a.hv-section-menu__link[aria-current="page"]::after {
    content: "✓"; flex: none; margin-left: auto; color: var(--primary); font-weight: 700;
  }
  .hv-page .hv-section-menu .badge { flex: none; white-space: nowrap; }
}
