/* Location page (/location_detail_v2/<id>), v1.4.0: overview column + booth LIST (booth rows with
   filter rows), booth view (#booth=<name>), Needs attention, TV mode. Loaded only on page-board. */

/* ==== Phone app bar: page tools go into the "..." sheet ==== */
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  body.has-tabbar [data-app-action] { display: none !important; }
  body.has-tabbar .sheet__body > [data-app-action] { display: grid !important; gap: var(--sp-2); }
  .sheet__body .switch { min-height: 52px; }
  .appbar__title.is-long { font-size: var(--h4); }
}

/* ==== Layout: overview column (left) + booth list (right) at 1200px and up ==== */
.board-layout { display: grid; gap: var(--card-gap, var(--sp-4)); }
.board-side, .board-main { min-width: 0; }
@media (min-width: 1200px) {
  .board-layout { grid-template-columns: minmax(320px, 360px) minmax(0, 1fr); align-items: start; }
  /* v1.4.1 (#20): no inner scrolling. Sticky only when board.js sees the whole column fits in the window (.is-sticky). */
  .board-side { display: grid; gap: var(--sp-3); }
  .board-side.is-sticky { position: sticky; top: var(--sp-4); }
  .board-side > * { margin-bottom: 0; }
  .board-side .board-hero__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-3); }
  .board-side .board-hero__actions .btn-sbs { min-height: 36px; padding-inline: var(--sp-2); }
  .board-side .board-hero__primary { grid-column: 1 / -1; }
  .board-side .board-hero__actions .btn-sbs__long { display: none; }
  .page-board .board-side .hero { padding: var(--sp-3) var(--sp-4); }
}

/* ==== Overview hero ==== */
.hero__badge { border-color: var(--sbs-control-line); color: var(--sbs-ink); }
.hero__title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.hero__title-row .hero__title { margin: 0; }
.board-updated { margin: var(--sp-1) 0 0; }
.board-updated__btn { position: relative; z-index: 1; min-height: 0; }
.board-updated__btn::after { content: ""; position: absolute; inset: -12px -10px; }
.admin-links { margin: var(--sp-1) 0 0; }
.crumbs--single { display: none; }
.btn-sbs__long { white-space: nowrap; }
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  .board-hero { position: relative; display: grid; gap: var(--sp-3); padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
  .board-hero .eyebrow { display: none; }
  .board-hero .hero__title { font-size: var(--fs-xl); margin: 0 0 var(--sp-1); }
  .board-hero .hero__title-row { padding-right: 52px; }
  .board-hero .hero__title-row .help-q { position: absolute; top: var(--sp-2); right: var(--sp-2); }
  .board-hero .hero__meta, .board-updated { display: inline; margin: 0; font-size: var(--fs-body); }
  .board-updated { margin-left: var(--sp-1); }
  .board-updated::before { content: "\00b7 "; }
  .board-hero__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
  .board-hero__primary { grid-column: 1 / -1; }
  .board-hero__actions .btn-sbs { padding-inline: var(--sp-3); }
  .board-hero__actions .btn-sbs__long { display: none; }
  [data-board] > .banner { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); }
  [data-board] > .banner .banner__icon { width: 18px; height: 18px; }
}
main .sample-banner .banner__text > a.link { display: inline-block; padding-block: 12px; margin-block: -12px; }

/* ==== #9 Status tiles: number above the label; the label may wrap, so "Change soon" (and
   "Cambiar pronto") always fits inside its tile ==== */
.summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); }
.summary-strip .stat-tile { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: var(--sp-1); min-width: 0; min-height: var(--tap); padding: var(--sp-3); font: inherit; text-align: left; color: inherit; cursor: pointer; }
.summary-strip .stat-tile__num { font-size: 1.75rem; line-height: 1; }
.stat-tile__label { display: flex; align-items: flex-start; gap: 0.3em; max-width: 100%; white-space: normal; line-height: 1.2; overflow-wrap: break-word; text-wrap: balance; }
.stat-tile__label::before { margin-top: 0.05em; }
.stat-tile[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor; }
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  .summary-strip { margin-bottom: var(--sp-3); }
  .summary-strip .stat-tile { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px var(--sp-2); padding: var(--sp-2) var(--sp-3); }
  .summary-strip .stat-tile__num { font-size: 1.5rem; }
  .summary-strip .stat-tile__label { font-size: var(--fs-xs); }
}
@media (max-width: 400px) {
  .summary-strip .stat-tile__label::before { display: none; }
  .summary-strip .stat-tile { padding-inline: var(--sp-2); }
}

/* ==== #9 All / Needs attention: its own full-width row, never squished ==== */
.board-filter { margin-bottom: var(--sp-3); }
.board-filter .chip-group.seg { display: flex; flex-wrap: wrap; width: 100%; border-radius: 24px; }
.board-filter .chip-group.seg .chip { flex: 1 1 auto; min-width: max-content; justify-content: center; gap: var(--sp-2); padding-inline: var(--sp-3); }
.chip__short { display: none; }
@media (min-width: 1200px) {
  .board-side .board-filter { margin-bottom: 0; }
  .board-side .board-seg .chip__long { display: none; }
  .board-side .board-seg .chip__short { display: inline; }
}
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  .board-seg .chip__long { display: none; }
  .board-seg .chip__short { display: inline; }
}

/* ==== #13 Needs attention ==== */
.attention { margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4); }
.attention .section-title { margin: 0 0 var(--sp-2); font-size: var(--fs-lg); }
.attention__group { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0 var(--sp-1); font-size: var(--fs-sm); font-weight: 700; }
.attention__group:first-child { margin-top: 0; }
.attention__group::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--sbs-control-line); }
.attention__group--bad { color: var(--bad); }
.attention__group--bad::before { background: var(--bad); }
.attention__group--warn { color: var(--warn); }
.attention__group--warn::before { background: var(--warn-bar); }
.attention__group--stale { color: var(--sbs-muted-text); }
.attention__list { margin: 0; padding: 0; list-style: none; }
.attention__item + .attention__item { border-top: 1px solid var(--sbs-line); }
.attention .attention__item > a.attention__link { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--sp-1) var(--sp-2); min-height: var(--tap); padding: var(--sp-1) var(--sp-2); margin: 0 calc(-1 * var(--sp-2)); border-radius: var(--radius-sm); color: var(--sbs-ink); text-decoration: none; }
.attention__link:hover { background: var(--sbs-bg); }
.attention__link:hover .attention__where { text-decoration: underline; }
.attention__where { min-width: 0; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.attention__booth { font-weight: 700; }
.attention__reading { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.attention__reading .unit { font-weight: 400; color: var(--sbs-muted-text); font-size: var(--fs-xs); }
.attention__link .status-pill { font-size: var(--fs-xs); padding-inline: var(--sp-2); }
.attention__empty { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: 0; color: var(--sbs-ink); }
.attention__more { margin-top: var(--sp-1); font-weight: 700; }
.attention__item[hidden], .attention__group[hidden] { display: none; }
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  .attention { padding: var(--sp-3); }
  .attention .attention__item > a.attention__link { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "where pill" "reading pill"; gap: 0 var(--sp-2); padding-block: var(--sp-1); }
  .attention__where { grid-area: where; }
  .attention__reading { grid-area: reading; }
  .attention__link .status-pill { grid-area: pill; font-size: var(--fs-xs); }
  .board-hero__actions .btn-sbs { min-height: var(--tap); }
}

/* ==== #10 List toolbar: Sort · Expand all · TV mode · Auto-refresh ==== */
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--sbs-line); border-radius: var(--radius-lg); background: var(--sbs-surface); }
.list-toolbar__sort { display: inline-flex; align-items: center; gap: var(--sp-2); margin: 0; font-size: var(--fs-sm); font-weight: 600; }
/* v1.4.1 (#21): the standard field look, so the arrow sits inside the field like the other selects */
.list-toolbar__sort select { width: auto; min-height: 36px; padding: var(--sp-1) var(--sp-3); }
.list-toolbar__tools { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-left: auto; }
.list-toolbar .switch { min-height: 36px; }
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  .list-toolbar { padding: var(--sp-2); gap: var(--sp-2); }
  .list-toolbar__sort { flex: 1 1 auto; }
  .list-toolbar__sort select { min-height: var(--tap); flex: 1 1 auto; max-width: 13rem; }
  .list-toolbar__expand { min-height: var(--tap); }
}

/* ==== #11 Booth list ==== */
.page-board .booth-list { display: block; border: 1px solid var(--sbs-line); border-radius: var(--radius-lg); background: var(--sbs-surface); overflow: hidden; }
.page-board .booth-list:empty { display: none; }
.bl-booth { min-width: 0; }
.bl-booth + .bl-booth { border-top: 1px solid var(--sbs-line); }
.bl-booth__head { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto auto auto; grid-template-areas: "tog name sum stale pill"; align-items: center; gap: 0 var(--sp-3); min-height: 44px; padding: 2px var(--sp-3) 2px var(--sp-2); }
.bl-booth[data-level="bad"] > .bl-booth__head { box-shadow: inset 4px 0 0 var(--bad-bar); }
.bl-booth[data-level="warn"] > .bl-booth__head { box-shadow: inset 4px 0 0 var(--warn-bar); }
.bl-toggle { grid-area: tog; position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--sbs-ink); cursor: pointer; }
.bl-toggle::before { content: ""; position: absolute; inset: -6px; }
.bl-toggle:hover { background: var(--sbs-bg); }
.bl-toggle svg { width: 24px; height: 24px; transition: transform var(--dur) ease; }
.bl-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.bl-booth__name { grid-area: name; min-width: 0; margin: 0; font-size: var(--fs-md); font-weight: 700; line-height: 1.25; }
.bl-booth__name:focus { outline: none; }
.bl-booth__link { display: inline-flex; align-items: center; min-height: 32px; color: var(--sbs-ink); text-decoration: underline; text-decoration-color: var(--sbs-line); text-underline-offset: 4px; overflow-wrap: anywhere; }
.bl-booth__link:hover { color: var(--sbs-red-dark); text-decoration-color: currentColor; }
.bl-booth__sum { grid-area: sum; font-size: var(--fs-sm); white-space: nowrap; }
.bl-booth__next { display: none; }
.bl-booth__stale { grid-area: stale; display: inline-flex; align-items: center; padding: 0 var(--sp-2); border: 1px dashed var(--sbs-control-line); border-radius: var(--radius-pill); color: var(--sbs-muted-text); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; }
.bl-booth__stale[hidden] { display: none; }
.bl-booth__pill { grid-area: pill; justify-self: end; min-width: 7.5rem; justify-content: center; }
.bl-booth .status-pill { min-height: 26px; padding-block: 1px; }

/* Filter rows: name · reading · status · slim life bar */
.bl-filters { margin: 0; padding: 0 0 var(--sp-1); list-style: none; }
.bl-booth.is-collapsed .bl-filters { display: none; }
.bl-filter { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 7.5rem minmax(90px, 160px); grid-template-areas: "name reading status bar"; align-items: center; gap: 0 var(--sp-3); min-height: 36px; padding: 2px var(--sp-3) 2px calc(var(--sp-2) + 32px + var(--sp-3)); }
.bl-filter + .bl-filter { border-top: 1px solid var(--sbs-bg); }
.bl-filter:hover { background: #fafaf8; }
.bl-filters .bl-filter > a.bl-filter__name { grid-area: name; display: inline-flex; margin-block: 0; padding-block: 0; align-items: center; min-width: 0; min-height: 32px; color: var(--sbs-ink); font-size: var(--fs-sm); text-decoration: none; }
.bl-filter__name:hover .bl-filter__label { color: var(--sbs-red-dark); text-decoration: underline; }
.bl-filter__label { overflow-wrap: break-word; word-break: normal; min-width: 0; }
.bl-filter__reading { grid-area: reading; display: inline-flex; align-items: baseline; justify-content: flex-end; gap: 4px; font-size: var(--fs-md); font-weight: 700; white-space: nowrap; }
.bl-filter__reading .unit, .bl-filter__reading .tip__btn { font-size: var(--fs-xs); font-weight: 400; color: var(--sbs-muted-text); }
.bl-filter__reading .tip__btn { min-height: 0; padding: 0; }
.bl-filter__status { grid-area: status; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.bl-filter__status .status-pill { font-size: var(--fs-xs); padding-inline: var(--sp-2); }
.bl-filter__bar { grid-area: bar; min-width: 0; }
.bl-filter .level-bar__track { position: relative; height: 6px; overflow: visible; }
.bl-filter .level-bar__fill { border-radius: var(--radius-pill); }
.level-bar__tick { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; }
.level-bar__tick--warn { left: 50%; background: var(--warn-bar); }
.level-bar__tick--bad { left: 75%; background: var(--bad); }
.level-bar__hint { display: none; }
.bl-filter .level-bar__label { display: none; }
.bl-filter.is-stale .level-bar { opacity: 0.6; }
/* v1.5.1 (#A5): a stale reading is muted by colour, not opacity, so its "in. w.c." keeps 4.5:1 */
.bl-filter.is-stale .reading, .bl-filter.is-stale .reading .unit, .bl-filter.is-stale .reading .tip__btn { color: var(--sbs-muted-text); }
.bl-filter[data-waiting] .level-bar { visibility: hidden; }
.filter-row__lastknown, .filter-row__odd { display: none; font-size: var(--fs-xs); }
.bl-filter__detail, .bl-booth__detail, .bl-booth .pastdue-warn, .bl-booth .booth-card__power { display: none; }
.bl-filter--empty { display: block; padding: var(--sp-2) var(--sp-4); }
.page-board .booth-list .attention-empty { margin: var(--sp-3); }

/* Phones: the same list, compact, 44px taps */
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  .bl-booth__head { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "tog name pill" "tog sum stale"; gap: 0 var(--sp-2); padding: var(--sp-1) var(--sp-3) var(--sp-1) 0; }
  .bl-toggle { width: 44px; height: 44px; }
  .bl-toggle::before { content: none; }
  .bl-booth__link { min-height: var(--tap); }
  .bl-booth__sum { white-space: normal; font-size: var(--fs-xs); }
  .bl-booth__stale { justify-self: end; }
  .bl-booth__pill { min-width: 0; }
  .bl-booth .status-pill { font-size: var(--fs-xs); white-space: normal; text-align: center; padding-inline: var(--sp-2); }
  .bl-filter { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name reading status" "bar bar bar"; gap: 0 var(--sp-2); padding: 0 var(--sp-3) var(--sp-2) 44px; }
  .bl-filters .bl-filter > a.bl-filter__name { min-height: var(--tap); font-size: var(--fs-body, 1rem); }
  .bl-filter__reading { font-size: var(--fs-md); }
  .bl-filter__reading .tip__btn { min-height: var(--tap); }
  .bl-filter__reading .tip__i { display: none; }
  .bl-filter__status { align-items: flex-end; }
  .bl-filter .level-bar__track { height: 4px; }
}
@media (max-width: 359.98px) {
  .bl-filter { padding-left: var(--sp-3); }
}

/* ==== #12 Booth view (#booth=<name>) ==== */
.booth-detail-bar { margin-bottom: var(--sp-2); }
.booth-detail-bar[hidden] { display: none; }
.booth-detail-bar__back { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 700; }
body.booth-detail .list-toolbar { display: none; }
body.booth-detail .bl-booth:not(.is-detail) { display: none; }
body.booth-detail .bl-booth.is-detail .bl-booth__head { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name stale pill" "sum sum sum"; padding: var(--sp-3) var(--sp-4) var(--sp-2); }
body.booth-detail .bl-booth.is-detail .bl-toggle { display: none; }
body.booth-detail .bl-booth.is-detail .bl-booth__name { font-size: var(--fs-xl); }
body.booth-detail .bl-booth.is-detail .bl-booth__link { pointer-events: none; text-decoration: none; }
body.booth-detail .bl-booth.is-detail .bl-booth__sum { white-space: normal; }
body.booth-detail .bl-booth.is-detail .bl-booth__next { display: inline; }
body.booth-detail .bl-booth.is-detail .bl-booth__sum, body.booth-detail .bl-booth.is-detail .bl-booth__next { grid-column: 1 / -1; }
body.booth-detail .bl-booth.is-detail .bl-filters { display: block; padding: 0 var(--sp-4) var(--sp-2); }
body.booth-detail .bl-booth.is-detail .pastdue-warn { display: flex; margin: 0 var(--sp-4) var(--sp-2); }
body.booth-detail .bl-booth.is-detail .bl-filter { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name reading status" "bar bar bar" "detail detail detail"; gap: var(--sp-1) var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--sbs-line); }
body.booth-detail .bl-booth.is-detail .bl-filter:hover { background: none; }
body.booth-detail .bl-booth.is-detail .bl-filter > a.bl-filter__name { font-size: var(--fs-lg); font-weight: 700; }
body.booth-detail .bl-booth.is-detail .bl-filter__reading { font-size: var(--fs-xl); }
body.booth-detail .bl-booth.is-detail .bl-filter__reading .tip { display: inline-flex; }
body.booth-detail .bl-booth.is-detail .bl-filter__status .status-pill { font-size: var(--fs-sm); }
body.booth-detail .bl-booth.is-detail .level-bar { display: flex; align-items: center; gap: var(--sp-2); }
body.booth-detail .bl-booth.is-detail .level-bar__track { flex: 1 1 auto; height: 8px; }
body.booth-detail .bl-booth.is-detail .level-bar__label { display: block; flex: none; margin: 0; color: var(--sbs-muted-text); font-size: var(--fs-xs); white-space: nowrap; }
body.booth-detail .bl-booth.is-detail .filter-row__lastknown, body.booth-detail .bl-booth.is-detail .filter-row__odd { display: block; }
body.booth-detail .bl-booth.is-detail .bl-filter__detail { grid-area: detail; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: start; gap: var(--sp-1); }
.bl-filter__detail > * { grid-area: auto !important; grid-column: 1 / -1; }
.bl-filter__detail > .meta-text { font-size: var(--fs-xs); }
.filter-row__next { margin: 0; color: var(--sbs-ink); font-size: var(--fs-sm); font-weight: 600; }
.filter-row__next:empty { display: none; }
.filter-row__trend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); min-height: 28px; }
.filter-row__trend:empty { display: none; }
.filter-row__forecast { display: inline-flex; flex-wrap: wrap; gap: 0 var(--sp-2); font-size: var(--fs-sm); }
.filter-row__confirm { margin: 0; padding: var(--sp-1) var(--sp-2); border-radius: var(--radius-sm); background: var(--ok-bg); color: var(--ok); font-size: var(--fs-sm); font-weight: 700; }
.filter-row__confirm.is-waiting { background: var(--sbs-bg); color: var(--sbs-ink); font-weight: 400; }
.filter-row__changed { margin: 0; }
.filter-row__actions { display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); }
.filter-row__actions .btn-sbs--text { padding-inline: 0; }
body.booth-detail .bl-booth.is-detail .bl-booth__detail { display: grid; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) var(--sp-4); border-top: 1px solid var(--sbs-line); background: var(--sbs-bg); }
body.booth-detail .bl-booth.is-detail .booth-card__power:not([hidden]) { display: block; margin: 0 var(--sp-4) var(--sp-2); font-size: var(--fs-xs); }
body.booth-detail .bl-booth.is-detail .booth-card__power > span[hidden] { display: none; }
.booth-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.booth-actions > .btn-sbs, .booth-actions > .link, .booth-actions > .link-btn { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--sp-4); border: 1px solid var(--btn-line); border-radius: var(--radius-pill); background: var(--sbs-surface); color: var(--sbs-ink); font-size: var(--btn-fs); font-weight: 600; text-decoration: none; }
.booth-actions > :first-child { border-color: var(--sbs-red); background: var(--sbs-red); color: var(--sbs-white); }
.booth-actions > *:hover { border-color: var(--sbs-ink); }
.booth-actions > :first-child:hover { background: var(--sbs-red-dark); color: var(--sbs-white); }
.diag { font-size: var(--fs-sm); }
.diag > summary { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--sbs-muted-text); cursor: pointer; }
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  body.booth-detail .board-side { display: none; }
  .filter-row__actions .btn-sbs--text { min-height: var(--tap); }
  body.booth-detail .bl-booth.is-detail .bl-booth__head { padding: var(--sp-3); }
  body.booth-detail .bl-booth.is-detail .bl-filters { padding: 0 var(--sp-3) var(--sp-2); }
  body.booth-detail .bl-booth.is-detail .bl-booth__detail { padding: var(--sp-3); }
  .booth-actions > .btn-sbs, .booth-actions > .link, .booth-actions > .link-btn { flex: 1 1 calc(50% - var(--sp-2)); justify-content: center; text-align: center; padding: 0 var(--sp-3); }
}

/* ==== Booth history (?view=booth&booth=, v1.3.0) ==== */
.booth-history { margin-bottom: var(--sp-3); }
.booth-history__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3); }
.booth-history__head .section-title { margin: 0; }
.booth-history__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: var(--sp-4); }
.booth-history__item { margin: 0; }
.booth-history__item .spark { width: 100%; height: auto; }
.booth-history__item figcaption { margin-bottom: var(--sp-1); }
body.booth-view .booth-list, body.booth-view .list-toolbar, body.booth-view .attention, body.booth-view .booth-detail-bar { display: none; }

/* ==== TV mode: light, all booths with their filters, type scales with the screen ==== */
html:has(> body.tv-mode) { font-size: clamp(16px, min(0.95vw, 1.7vh), 44px); overflow: hidden; }
body.tv-mode .container-sbs { max-width: none; }
body.tv-mode .board-layout { display: block; }
body.tv-mode .board-side { position: static; }
body.tv-mode .hero__title { font-size: 2.5rem; }
/* v1.4.1 (#22, #23, #25): TV starts with the location container (clock and Exit on its right), then the booths */
body.tv-mode .page-section { padding-top: var(--sp-3); }
body.tv-mode .sample-banner, body.tv-mode [data-stale-banner], body.tv-mode [data-offline-banner], body.tv-mode .viewas-banner, body.tv-mode .viewas-note,
body.tv-mode .summary-strip { display: none !important; }
body.tv-mode .board-hero { display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: var(--sp-4); margin: 0 0 var(--sp-3); padding: var(--sp-3) var(--sp-5); }
body.tv-mode .board-hero__main { min-width: 0; }
body.tv-mode .board-hero .eyebrow { display: block; }
body.tv-mode .tv-stale { margin-top: var(--sp-1); }
.tv-stale[hidden] { display: none; }
body:not(.tv-mode) .tv-stale { display: none; }
body.tv-mode .tv-bar { position: static; display: flex; flex: none; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-3); margin-left: auto; font-size: var(--fs-md); }
body.tv-mode .tv-bar .tv-exit { position: static; }
.tv-clock { margin: 0; padding: var(--sp-1) var(--sp-3); border-radius: var(--radius-pill); background: var(--sbs-surface); border: 1px solid var(--sbs-line); font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.tv-pages { margin: 0; }
.tv-pages:empty, .tv-clock:empty { display: none; }
body:not(.tv-mode) .tv-clock, body:not(.tv-mode) .tv-pages { display: none; }
body.tv-mode .tv-hide { display: none !important; }
body.tv-mode .list-toolbar, body.tv-mode .board-filter, body.tv-mode .attention, body.tv-mode .booth-detail-bar, body.tv-mode .hero__badge, body.tv-mode .admin-links,
body.tv-mode .help-q, body.tv-mode .board-updated, body.tv-mode .page-foot, body.tv-mode .tip__i, body.tv-mode .bl-toggle, body.tv-mode .bl-filter__detail,
body.tv-mode .bl-booth__detail, body.tv-mode .bl-booth__sum { display: none !important; }
body.tv-mode.page-board .booth-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); gap: var(--sp-3); align-items: start; border: 0; background: none; overflow: visible; }
body.tv-mode .bl-booth { border: 1px solid var(--sbs-line) !important; border-radius: var(--radius-lg); background: var(--sbs-surface); break-inside: avoid; }
body.tv-mode .bl-booth.is-collapsed .bl-filters { display: block; }
body.tv-mode .bl-booth__head { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "name stale pill"; padding: var(--sp-2) var(--sp-3); }
body.tv-mode .bl-booth__name { font-size: var(--fs-xl); }
body.tv-mode .bl-booth__link { pointer-events: none; text-decoration: none; }
body.tv-mode .bl-filter { grid-template-columns: minmax(5.5em, 1fr) auto auto; grid-template-areas: "name reading status" "bar bar bar"; gap: 2px var(--sp-2); padding: 0.3rem var(--sp-3); }
body.tv-mode .bl-filter + .bl-filter { border-top-color: var(--sbs-line); }
/* v1.4.1: in TV every booth lists all its filters; it is never collapsed and has no toggle.
   Fit steps (board.js) add columns and tighten rows until everything fits one screen. */
body.tv-mode .bl-booth .bl-filters, body.tv-mode .bl-booth.is-collapsed .bl-filters { display: block !important; }
/* Each step scales the whole TV layout down a little (same proportions, so more columns fit and nothing overlaps) */
html:has(> body.tv-mode.tv-dense-1) { font-size: max(15px, calc(clamp(16px, min(0.95vw, 1.7vh), 44px) * 0.9)); }
html:has(> body.tv-mode.tv-dense-2) { font-size: max(14px, calc(clamp(16px, min(0.95vw, 1.7vh), 44px) * 0.8)); }
html:has(> body.tv-mode.tv-dense-3) { font-size: max(13px, calc(clamp(16px, min(0.95vw, 1.7vh), 44px) * 0.72)); }
body.tv-mode.tv-dense-3.page-board .booth-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19.5rem), 1fr)); gap: var(--sp-2); }
body.tv-mode.tv-dense-3 .bl-filter { gap: 0 var(--sp-1); }
body.tv-mode .bl-filter__label, body.tv-mode .bl-booth__link { overflow-wrap: normal; word-break: normal; hyphens: none; }
/* Narrowest step: the unit is said once in the location container, and the filter pills already say "No recent data" */
body.tv-mode.tv-dense-3 .bl-filter__reading .tip, body.tv-mode.tv-dense-3 .bl-filter__reading .unit, body.tv-mode.tv-dense-3 .bl-booth__stale { display: none !important; }
body:not(.tv-dense-3) .tv-unit { display: none; }
body.tv-mode .bl-booth__head { grid-template-columns: minmax(6em, 1fr) auto auto; }
/* Denser steps also tighten the location container so the booths get the room */
body.tv-mode:is(.tv-dense-1, .tv-dense-2, .tv-dense-3) .board-hero { padding: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-2); }
body.tv-mode:is(.tv-dense-1, .tv-dense-2, .tv-dense-3) .hero__title { font-size: 1.75rem; }
body.tv-mode:is(.tv-dense-1, .tv-dense-2, .tv-dense-3) .board-hero .eyebrow { display: none; }
body.tv-mode:is(.tv-dense-1, .tv-dense-2, .tv-dense-3) .tv-clock { font-size: var(--fs-lg); }
body.tv-mode .bl-filter > a.bl-filter__name { pointer-events: none; font-size: var(--fs-lg); }
body.tv-mode .bl-filter__reading { font-size: var(--fs-xl); }
/* v1.4.1 (#26): pills sized for across the room, with room to breathe (the TV root font scales with the screen) */
body.tv-mode .status-pill, body.tv-mode .bl-booth .status-pill, body.tv-mode .bl-filter__status .status-pill { min-height: 0; padding: 0.2em 0.8em; font-size: 1rem; line-height: 1.3; white-space: nowrap; }
body.tv-mode .bl-booth__pill { min-width: 0; }
body.tv-mode .bl-filter__status { align-items: flex-end; }
body.tv-mode .bl-filter .level-bar__track { height: 0.5rem; }
body.tv-mode .bl-booth .pastdue-warn { display: none; }

/* ==== Print: every booth open, no controls ==== */
@media print {
  .page-board .topstrip, .page-board .app-header, .page-board .app-footer { display: none !important; }
  .list-toolbar, .board-filter, .bl-toggle, .booth-detail-bar, .diag, .booth-actions, .board-updated, .filter-row__trend .spark, .help-q, .crumbs { display: none !important; }
  .board-layout { display: block; }
  .board-side { position: static; max-height: none; overflow: visible; }
  .bl-booth.is-collapsed .bl-filters { display: block !important; }
  .bl-booth { break-inside: avoid; }
  .page-board .booth-list { visibility: visible; animation: none; }
}

/* The booth list stays invisible (space kept) until board.js has added its row state;
   if the script never runs, it shows after 1.2 s anyway. */
.page-board .booth-list:not(.is-ready) { visibility: hidden; animation: sbs-reveal 0s linear 1.2s forwards; }
.page-board:has(.booth-list:not(.is-ready)) :is(.page-foot, .app-footer) { visibility: hidden; animation: sbs-reveal 0s linear 1.2s forwards; }
@keyframes sbs-reveal { to { visibility: visible; } }

/* v1.5.0 (#34): Demo display names. Admins see the real panel name small beside the shown name,
   and the booths hidden on the demo in their own section, last (both .admin-only: View as customer hides them). */
.demo-hidden { margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-style: dashed; }
.demo-hidden .section-title { margin: 0 0 var(--sp-1); font-size: var(--fs-md); }
.demo-hidden > .meta-text { margin: 0 0 var(--sp-2); }
.demo-hidden__list { margin: 0; padding: 0; list-style: none; }
.demo-hidden__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); min-height: var(--tap); border-top: 1px solid var(--sbs-bg); }
.demo-hidden__row .num { margin-left: auto; font-weight: 700; }
.demo-hidden__row .unit { color: var(--sbs-muted-text); font-size: var(--fs-xs); font-weight: 400; }
.demo-hidden__name { display: inline-flex; align-items: center; gap: 0.3em; min-height: var(--tap); color: var(--sbs-ink); }
body.tv-mode .demo-hidden, body.tv-mode .real-name { display: none !important; }
@media print { .demo-hidden { display: none; } }

/* v1.5.1 (#A7): TV mode on phones and small tablets: no text under 13px (big-screen TV sizes unchanged) */
@media (max-width: 767.98px), (pointer: coarse) and (max-width: 1024px), (max-height: 500px) {
  body.tv-mode .sample-badge, body.tv-mode .board-hero .hero__meta, body.tv-mode .tv-unit, body.tv-mode .tv-exit, body.tv-mode .tv-pages { font-size: 13px; }
  /* #A4: the auto-refresh checkbox is a 44px target that still looks 22px */
  .switch input[type="checkbox"] { flex: none; width: var(--tap); height: var(--tap); margin: -10px -6px -10px -10px; border: 0; background: center / 22px 22px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Crect x='1' y='1' width='20' height='20' rx='5' fill='%23fff' stroke='%238a8b8a' stroke-width='2'/%3E%3C/svg%3E"); -webkit-appearance: none; appearance: none; cursor: pointer; }
  .switch input[type="checkbox"]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Crect x='0' y='0' width='22' height='22' rx='6' fill='%231c2228'/%3E%3Cpath d='M6 11.5l3.2 3.2L16 8' fill='none' stroke='%23fff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
  .switch input[type="checkbox"]:focus-visible { outline: 2px solid var(--sbs-ink); outline-offset: -8px; border-radius: var(--radius-sm); }
  /* the clock, page count and Exit TV mode wrap under the site name instead of pushing it sideways */
  body.tv-mode .board-hero { flex-wrap: wrap; padding-inline: var(--sp-4); }
  body.tv-mode .board-hero__main { flex: 1 1 100%; }
  body.tv-mode .tv-bar { flex: 1 1 100%; justify-content: flex-start; gap: var(--sp-2); margin-left: 0; }
}
