/* Copyright (c) 2026 NavX Systems Inc. All rights reserved. */

/*
 * Halo Cloud design: a console for cargo condition in transit. The map is the canvas; controls float on it
 * (a panel on the left, an asphalt toolbar on top; on phones a bottom sheet).
 *
 * Subject: condition in transit. Did the cargo arrive in good shape: kept in its
 * temperature range, and handled with care (shocks, drops, tilt, a rough ride)?
 * Palette: frost #EEF1F3 (ground), asphalt #1B1F24 (toolbar), steel #20262D (text),
 * NavX hi-vis orange #F26B1D (actions only), reefer blue #2F7FBF (the allowed
 * temperature band), excursion red #D7263D (out of range, critical handling), amber
 * for warnings.
 * Type: Barlow, from US highway signs; Barlow Semi Condensed for names, headings and
 * figures, with tabular figures so numbers line up. Scale 12 / 14 / 16 / 20 / 24 / 36.
 * The one bold element: a device opens on its timeline, its whole life on one slider,
 * to find where it was at any time.
 */

:root {
  color-scheme: light dark;
  --bg: #eef1f3;           /* frost */
  --panel: rgb(250 251 252 / 0.84);
  --panel-solid: #fafbfc;
  --raised: rgb(255 255 255 / 0.94);
  --text: #20262d;         /* steel */
  --muted: #5d6b78;
  --separator: rgb(32 38 45 / 0.12);
  --fill: rgb(93 107 120 / 0.1);
  --fill-strong: rgb(93 107 120 / 0.18);
  --accent: #f26b1d;       /* NavX hi-vis orange: actions */
  --accent-text: #ffffff;
  --accent-tint: rgb(242 107 29 / 0.12);
  --cold: #2f7fbf;         /* reefer blue: the allowed band */
  --cold-tint: rgb(47 127 191 / 0.12);
  --ok: #1f7a4d;
  --warn: #a65400;
  --error: #d7263d;        /* excursion red */
  --font: "Barlow", system-ui, sans-serif;
  --font-cut: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --shadow: 0 8px 32px rgb(0 0 0 / 0.14), 0 1px 3px rgb(0 0 0 / 0.08);
  --shadow-deep: 0 24px 64px rgb(0 0 0 / 0.28), 0 2px 8px rgb(0 0 0 / 0.12);
  /* The toolbar stays dark in both themes: the NavX logo is white and orange */
  --toolbar: rgb(27 31 36 / 0.9);   /* asphalt */
  --toolbar-text: #f5f5f7;
  --radius-l: 16px;
  --radius-m: 12px;
  --radius-s: 8px;
  --blur: blur(24px) saturate(180%);
  --toolbar-h: 56px;
  --panel-w: 384px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a;
    --panel: rgb(27 31 36 / 0.84);   /* asphalt */
    --panel-solid: #1b1f24;
    --raised: rgb(37 43 49 / 0.94);
    --text: #e8ecef;
    --muted: #93a0ac;
    --separator: rgb(232 236 239 / 0.12);
    --fill: rgb(147 160 172 / 0.16);
    --fill-strong: rgb(147 160 172 / 0.26);
    --accent-tint: rgb(242 107 29 / 0.2);
    --cold: #5aa6e0;
    --cold-tint: rgb(90 166 224 / 0.16);
    --ok: #4cc38a;
    --warn: #ffb340;
    --error: #ff5468;
    --shadow: 0 8px 32px rgb(0 0 0 / 0.5), 0 1px 3px rgb(0 0 0 / 0.4);
    --shadow-deep: 0 24px 64px rgb(0 0 0 / 0.6), 0 2px 8px rgb(0 0 0 / 0.4);
  }
}

/* Solid surfaces when the person asks for less transparency, borders for more contrast */
@media (prefers-reduced-transparency: reduce) {
  :root { --panel: var(--panel-solid); --raised: var(--panel-solid); --toolbar: #101216; --blur: none; }
}
@media (prefers-contrast: more) {
  :root { --separator: rgb(128 128 128 / 0.7); --panel: var(--panel-solid); --blur: none; }
  .glass, dialog, #devices { outline: 1px solid var(--separator); }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* iPhone: no double-tap zoom (pinch still zooms) and no text inflation in landscape */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* iOS Safari zooms the page into a field whose text is under 16 px and leaves it zoomed,
   so the whole page then scrolls sideways. Touch screens get 16 px fields */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
  dialog.signin input[name="code"] { font-size: 20px !important; }
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Type: Barlow for text, the semi-condensed cut for names, headings and figures */
h2 { font: 600 24px/1.15 var(--font-cut); margin: 0; }
h3, h4 {
  font: 600 16px/1.3 var(--font-cut);
  color: var(--text); margin: 24px 0 8px;
}
h4 { margin: 20px 2px 8px; }
.muted { color: var(--muted); }
a { color: var(--accent); }

/* Materials */
.glass {
  background: var(--panel);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}

/* The map is the canvas */
#map { position: fixed; inset: 0; }

/* Toolbar: dark material across the top, content scrolls (the map) under it */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  height: var(--toolbar-h);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px;
  background: var(--toolbar);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  color: var(--toolbar-text);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: auto; display: block; }
.brand img.company { height: 34px; }
.brand img.product { height: 20px; padding-left: 14px; border-left: 1px solid rgb(255 255 255 / 0.2); }

/* The panel floats over the map on the left */
aside {
  position: fixed; z-index: 2;
  top: calc(var(--toolbar-h) + 12px); left: 12px; bottom: 12px;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  border-radius: var(--radius-l);
  overflow: hidden;
}
.panel-scroll {
  flex: 1; overflow-y: auto; padding: 4px 16px 16px;
  /* A soft edge where content meets the panel's top, instead of a divider */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12px);
  mask-image: linear-gradient(180deg, transparent 0, #000 12px);
}
.grabber { display: none; }
.panel-head { padding: 16px 16px 8px; }
.aside-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fleet-bar { display: flex; gap: 8px; margin: 12px 0 0; }
.fleet-bar[hidden] { display: none; }
.manage-menu { right: auto; width: 220px; }
.manage-open::after { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 0 3px 8px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.fleet-bar select { flex: 1; min-width: 0; }
.fleet-bar button { padding: 6px 10px; }
footer { padding: 8px 16px 12px; font-size: 11px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; }
footer a { color: inherit; }

/* Map chrome sits below the toolbar and clear of the panel */
.maplibregl-ctrl-top-right { top: calc(var(--toolbar-h) + 4px); }
.maplibregl-ctrl-group { border-radius: var(--radius-s) !important; box-shadow: var(--shadow) !important; overflow: hidden; }

/* Controls: filled accent and tinted secondary buttons, instant press feedback */
button {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 590;
  min-height: 32px; padding: 6px 14px;
  border-radius: var(--radius-s);
  background: var(--accent); color: var(--accent-text);
  transition: transform 100ms var(--ease), background-color 150ms var(--ease), opacity 150ms;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.97); opacity: 0.85; }
button.secondary { background: var(--fill); color: var(--text); }
button.secondary:hover { background: var(--fill-strong); }
button.confirm { background: var(--error); color: #fff; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid rgb(242 107 29 / 0.45); outline-offset: 1px;
}

select, input {
  appearance: none; -webkit-appearance: none;
  font: inherit; color: var(--text);
  background: var(--fill);
  border: 0; border-radius: var(--radius-s);
  padding: 7px 10px; min-height: 32px;
}
select {
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
input[type="checkbox"] {
  appearance: auto; -webkit-appearance: checkbox; min-height: 0; padding: 0;
  width: 18px; height: 18px; accent-color: var(--accent); background: none;
}

/* Device list: an inset grouped list */
:is(#devices, #all-list) { list-style: none; margin: 8px 0 0; padding: 0; background: var(--raised); border-radius: var(--radius-m); overflow: hidden; }
:is(#devices, #all-list) li { position: relative; }
:is(#devices, #all-list) li.muted { padding: 10px 14px; }
/* Each row is a button: reachable by Tab, opened by Enter or Space */
button.row {
  display: grid; width: 100%; min-height: 0; padding: 10px 14px; border-radius: 0;
  background: none; color: inherit; font-weight: inherit; text-align: left;
  transition: background-color 120ms var(--ease);
}
button.row:focus-visible { outline-offset: -3px; }
:is(#devices, #all-list) li + li::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--separator);
}
button.row:hover { background: var(--fill); }
button.row:active { background: var(--fill-strong); transform: none; opacity: 1; }
button.row.selected { background: var(--accent-tint); }
:is(#devices, #all-list) .name, .list .name { font: 600 16px/1.25 var(--font-cut); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:is(#devices, #all-list) .muted { font-size: 12px; }

/* A row: the name and what it is doing on the left, its temperature and battery as figures on the right */
.dev { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; }
.dev-sub { display: flex; flex-wrap: wrap; gap: 0 10px; font-size: 13px; color: var(--muted); margin-top: 1px; }
.state { font-weight: 600; }
.state.moving { color: var(--ok); }
.state.still { color: var(--text); }
.state.offline { color: var(--error); }
.state.done { color: var(--muted); }
.dev-sub .late { color: var(--error); }
.dev-range { font-size: 12px; color: var(--muted); }
.dev-figures { text-align: right; }
.dev-temp { font: 600 20px/1.1 var(--font-cut); white-space: nowrap; }
.dev-temp.bad { color: var(--error); }
.alarm-mark { color: var(--warn); font-size: 14px; margin-right: 4px; vertical-align: 2px; }
.alarm-mark.critical { color: var(--error); }
.dev-bat { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.dev-bat.low { color: var(--error); }
.dev-bat .plug { font-size: 11px; line-height: 1; color: var(--ok); }
/* A battery: its outline filled to the charge */
.cell { width: 16px; height: 8px; border: 1px solid currentColor; border-radius: 2px; position: relative; opacity: 0.85;
  background: linear-gradient(to right, currentColor var(--soc), transparent var(--soc)) content-box; padding: 1px; }
.cell::after { content: ""; position: absolute; right: -3px; top: 2px; width: 2px; height: 2px; background: currentColor; border-radius: 0 1px 1px 0; }
/* All devices: each fleet's name above its devices, once */
:is(#devices, #all-list) li.group-head { cursor: default; padding: 14px 14px 4px; font: 600 14px/1.2 var(--font-cut); color: var(--muted);
  display: flex; justify-content: space-between; background: var(--fill); }
:is(#devices, #all-list) li.group-head:hover { background: var(--fill); }
:is(#devices, #all-list) li.group-head::before, :is(#devices, #all-list) li.group-head + li::before { display: none; }
.group-head .count { font-weight: 500; }

/* Segmented control (Devices | Shipments) */
.segmented { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.segmented button {
  background: transparent; color: var(--text); min-height: 28px; padding: 4px 14px; border-radius: 7px;
  font-weight: 590; font-size: 13px;
}
.segmented button[aria-selected="true"] { background: var(--raised); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }
.segmented button:active { transform: none; opacity: 0.7; }

/* Shipments list: same inset grouped style as devices */
.list { list-style: none; margin: 8px 0 0; padding: 0; background: var(--raised); border-radius: var(--radius-m); overflow: hidden; }
.list li { position: relative; }
.list li.muted { padding: 10px 14px; }
.list li + li::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--separator); }
.list .muted { font-size: 12px; }
.badge.planned { background: var(--fill); color: var(--muted); }
.badge.in_transit { background: color-mix(in srgb, #0a84ff 16%, transparent); color: #0a84ff; }
.badge.delivered { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.cancelled { background: var(--fill); color: var(--muted); text-decoration: line-through; }
.ship-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Capsules */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0;
  padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
  background: var(--fill); color: var(--muted);
}
.badge.active { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.offline { background: color-mix(in srgb, var(--error) 14%, transparent); color: var(--error); }
.badge.alarm { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.alarm.critical { background: color-mix(in srgb, var(--error) 14%, transparent); color: var(--error); }
.badge.fleet { background: transparent; box-shadow: inset 0 0 0 1px var(--separator); }

/* Device detail */
#detail { margin-top: 8px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin: 16px 0 12px; }
.detail-title { min-width: 0; }
/* Back to the list, as an iOS navigation bar */
button.back { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 2px; margin: 4px 0 -8px -2px;
  font-size: 15px; font-weight: 500; min-height: 32px; }
button.back::before { content: ""; width: 9px; height: 9px; border-left: 2.5px solid currentColor;
  border-bottom: 2.5px solid currentColor; transform: rotate(45deg); margin-right: 2px; }
#detail:not([hidden]) { animation: push 260ms var(--ease); }
/* Inside a device: a page slides in from the right, Back takes it out the same way */
.pane.push { animation: push 260ms var(--ease); }
.pane.pop { animation: pop 220ms var(--ease); }
.pane-title { margin: 14px 0 12px; }
.pane-title:focus { outline: none; }
.pane-title .muted { font: 500 14px var(--font); }
.now .gauges { margin-top: 4px; }
.now .meters { border-bottom: 0; }
/* The rows that open a device's pages: an inset grouped list with a chevron */
.nav-rows { list-style: none; margin: 20px 0 0; padding: 0; background: var(--raised); border-radius: var(--radius-m); overflow: hidden; }
.nav-rows li { position: relative; }
.nav-rows li + li::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--separator); }
button.nav-row { grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px; align-items: center; }
.nav-row .nav-title { font: 600 15px/1.25 var(--font-cut); }
.nav-row .nav-sub { grid-column: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-row::after { content: ""; grid-column: 2; grid-row: 1 / span 2; width: 7px; height: 7px; margin-right: 4px;
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); }
@keyframes push { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
#devices:not([hidden]), #shipments:not([hidden]) { animation: pop 220ms var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
.status-line { font-size: 13px; color: var(--muted); margin-top: 4px; }
/* IDs and coordinates: tabular figures, not a typewriter face */
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }

/* Open alarms: first thing under the name */
.alarm-banner { list-style: none; margin: 0 0 12px; padding: 4px 14px; border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--warn) 12%, var(--raised)); }
.alarm-banner:has(li.critical) { background: color-mix(in srgb, var(--error) 12%, var(--raised)); }
.alarm-banner li { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline; padding: 7px 0; font-size: 13px; }
.alarm-banner li + li { border-top: 1px solid var(--separator); }
.alarm-banner .sev-dot { align-self: center; }

/* Summary tiles: the readings that matter, at a glance */
/* The device's whole life on one slider (setupTimeline): where it was at a picked time */
.timeline { margin: 12px 0 4px; padding: 12px 14px; background: var(--raised); border-radius: var(--radius-m); }
.tl-head { display: flex; justify-content: flex-end; align-items: center; min-height: 24px; }
.tl-actions { display: flex; gap: 12px; }
.tl-ends { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; margin-top: -2px; }
.tl-range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.tl-range label { display: flex; align-items: center; gap: 6px; flex: 1 1 130px; min-width: 0; }
.tl-range input { flex: 1; min-width: 0; }
.tl-where { margin-top: 8px; font-size: 13px; color: var(--muted); min-height: 18px; }
.tl-where strong { color: var(--text); font-weight: 600; margin-right: 4px; }
.timeline .gauges { margin: 10px 0 0; font-size: 12px; }
/* Where the picked reading was taken */
.pick-marker { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 3px solid var(--raised);
  box-shadow: 0 0 0 2px var(--text), 0 2px 6px rgba(0, 0, 0, 0.35); }
/* Plain facts under it: a label, the value, and an aside */
dl.facts dd .aside { margin-left: 10px; color: var(--muted); }
dl.facts dd.warn, dl.facts dd .aside.warn { color: var(--warn); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tiles .tile { background: var(--raised); border-radius: var(--radius-m); padding: 10px 12px; min-width: 0; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile-value { font-size: 22px; font-weight: 650; line-height: 1.25; margin-top: 2px;
  font-variant-numeric: tabular-nums; }
.tile-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.bad .tile-value { color: var(--error); }
.tile.warn .tile-value { color: var(--warn); }

/* Folded sections: technical details one level deeper */
details.fold { margin-top: 20px; }
details.fold > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 2px; border-radius: var(--radius-s);
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 200ms var(--ease); margin-right: 2px;
}
details.fold[open] > summary::before { transform: rotate(45deg); }
details.fold > summary:hover { color: var(--text); }
details.fold > dl, details.fold > .readings { margin-top: 8px; }
.readings { list-style: none; margin: 0; padding: 4px 14px; background: var(--raised); border-radius: var(--radius-m); font-size: 13px; }
.readings li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.readings li + li { border-top: 1px solid var(--separator); }
.readings .when { color: var(--muted); white-space: nowrap; }
.detail-head h2 { color: var(--text); font: 600 24px/1.15 var(--font-cut); margin: 0; }
.detail-head h2:focus { outline: none; }
#detail h3 { margin: 20px 2px 8px; }
dl {
  display: grid; grid-template-columns: auto 1fr; gap: 0 12px; margin: 0;
  background: var(--raised); border-radius: var(--radius-m); padding: 4px 14px;
}
dt, dd { padding: 7px 0; border-top: 1px solid var(--separator); }
dt:first-of-type, dt:first-of-type + dd { border-top: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
.device-card dl { background: none; padding: 0; }
.device-card dt, .device-card dd { padding: 2px 0; border: 0; }

/* Events */
.events { list-style: none; margin: 0; padding: 4px 14px; font-size: 13px; background: var(--raised); border-radius: var(--radius-m); }
.event { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: baseline; padding: 7px 0; }
.event + .event { border-top: 1px solid var(--separator); }
.event .sev { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.event.warning .sev { background: var(--warn); }
.event.critical .sev { background: var(--error); }
.ev-meta { white-space: nowrap; font-size: 12px; }

/* Attention without alarm, e.g. "Stationary for 3 h" */
.warn { color: var(--warn); }
.error { color: var(--error); min-height: 1em; }

/* Tables and charts */
table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--raised); border-radius: var(--radius-m); padding: 4px 10px; }
.table-wrap td { white-space: nowrap; }
th, td { text-align: left; padding: 6px 4px; }
th { color: var(--muted); font-weight: 600; }
tbody tr + tr td, tbody tr:first-child td { border-top: 1px solid var(--separator); }
svg.spark { width: 100%; height: 28px; display: block; margin-top: 6px; }
svg.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--fill); padding: 10px; border-radius: var(--radius-s); }

/* Map popups and legend: the same material */
.maplibregl-popup-content {
  background: var(--panel); color: var(--text);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  padding: 8px 12px; border-radius: var(--radius-m); font-size: 12px;
  box-shadow: var(--shadow);
}
.maplibregl-popup-tip { display: none; }
.device-card .maplibregl-popup-content { padding: 10px 14px; min-width: 240px; }
.device-card .card-head { margin-bottom: 6px; font-size: 13px; }
.device-card .card-head strong { font-size: 14px; }
.device-card .maplibregl-popup-content { min-width: 340px; }
.chip { display: inline-block; font-size: 11px; padding: 0 7px; margin-left: 4px; border-radius: 99px; background: var(--fill); }

/* Last report gauges (deviceCard): colour only where a reading means something */
.gauges { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; margin: 4px 0 8px; text-align: center; }
.gauges.stale { opacity: 0.5; }
.gauge svg.dial { width: 100%; height: auto; display: block; fill: none; stroke-linecap: round; }
.dial .track { stroke: var(--fill-strong); stroke-width: 8; }
.dial .track.empty { stroke-dasharray: 3 4; }
.dial .zone { stroke-width: 8; stroke-linecap: butt; stroke-opacity: 0.3; }
.dial .zone.band { stroke: var(--cold); }
.dial .zone.warn { stroke: var(--warn); }
.dial .zone.bad { stroke: var(--error); }
.dial .reach { stroke: var(--muted); stroke-width: 2.5; }
.dial .reach.cold { stroke: var(--cold); }
.dial .reach.ok { stroke: var(--ok); }
.dial .reach.warn { stroke: var(--warn); }
.dial .reach.bad { stroke: var(--error); }
.dial .needle { stroke: var(--text); stroke-width: 2.5; }
.dial .hub { fill: var(--text); }
.dial .limit { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 2 2; stroke-linecap: butt; }
.dial .box { stroke: var(--text); stroke-width: 2; stroke-linejoin: round; }
.dial .needle.warn, .dial .box.warn { stroke: var(--warn); }
.dial .bat-cell { stroke: var(--text); stroke-width: 2.5; }
.dial .bat-cell.empty { stroke: var(--fill-strong); stroke-dasharray: 3 4; }
.dial .bat-nub { fill: var(--text); }
.dial .bat-charge { fill: var(--muted); }
.dial .bat-charge.ok { fill: var(--ok); }
.dial .bat-charge.warn { fill: var(--warn); }
.dial .bat-charge.bad { fill: var(--error); }
.dial .bolt { fill: var(--text); stroke: var(--raised); stroke-width: 1.5; stroke-linejoin: round; }
.g-value { font: 600 16px/1.1 var(--font-cut); margin-top: -4px; font-variant-numeric: tabular-nums; }
.g-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.g-status { font-size: 11px; color: var(--muted); }
.g-status.ok { color: var(--ok); }
.g-status.warn { color: var(--warn); }
.g-status.bad { color: var(--error); }

.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 8px 0; margin-bottom: 6px;
          border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator); }
.m-top { display: flex; justify-content: space-between; gap: 6px; }
.m-top span:first-child, .m-note { color: var(--muted); }
.m-note { font-size: 11px; }
.m-bar { height: 5px; margin-top: 3px; border-radius: 3px; background: var(--fill-strong); overflow: hidden; }
.m-bar i { display: block; height: 100%; background: var(--muted); }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 11px; margin-right: 4px; vertical-align: -1px; }
.bars b { width: 3px; border-radius: 1px; background: var(--fill-strong); }
.bars b:nth-child(1) { height: 4px; } .bars b:nth-child(2) { height: 6px; }
.bars b:nth-child(3) { height: 9px; } .bars b:nth-child(4) { height: 11px; }
.bars b.on { background: var(--text); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0;
       box-shadow: 0 0 0 1.5px rgb(255 255 255 / 0.7); }
.legend-toggle { display: flex; align-items: center; gap: 6px; margin-top: 4px; padding-top: 4px;
  border-top: 1px solid var(--separator); cursor: pointer; }
.legend-toggle input { width: 14px; height: 14px; }
.map-legend {
  background: var(--panel) !important; color: var(--text);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-radius: var(--radius-m) !important; padding: 8px 12px; font-size: 12px; line-height: 1.7;
  box-shadow: var(--shadow) !important;
}

/* Dialogs: a sheet of heavier material over a dimmed map; it materializes (scale + blur) */
dialog {
  border: 0; padding: 20px; color: var(--text);
  background: var(--raised);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-deep);
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  opacity: 1; transform: none; filter: none;
  transition: opacity 240ms var(--ease), transform 320ms var(--ease), filter 240ms var(--ease),
              overlay 240ms allow-discrete, display 240ms allow-discrete;
}
dialog:not([open]) { opacity: 0; transform: scale(0.96); filter: blur(6px); }
@starting-style { dialog[open] { opacity: 0; transform: scale(0.96); filter: blur(6px); } }
dialog::backdrop {
  background: rgb(0 0 0 / 0.32);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
dialog h2 { margin-bottom: 8px; }
dialog p { margin: 4px 0 12px; }
dialog label { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
dialog input { display: block; width: 100%; margin-top: 6px; color: var(--text); }
dialog select { display: block; width: 100%; margin-top: 6px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.sev-chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; }
.sev-chip.warning { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.sev-chip.critical { background: color-mix(in srgb, var(--error) 14%, transparent); color: var(--error); }

/* Settings sheet (Alerts): a sticky header of material, a segmented control, inset
   grouped lists with switches, and composers that open in place */
dialog.sheet { padding: 0; width: min(560px, calc(100vw - 24px)); overflow: hidden;
  display: none; flex-direction: column; }
dialog.sheet[open] { display: flex; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px 8px;
}
.sheet-head h2 { margin: 0; font: 600 24px/1.15 var(--font-cut); }
button.plain { background: none; color: var(--accent); padding: 6px 4px; font-weight: 600; font-size: 15px; }
button.plain:hover { opacity: 0.75; }
.sheet-tabs { padding: 4px 20px 12px; border-bottom: 1px solid transparent; transition: border-color 150ms var(--ease); }
.sheet-tabs .segmented { display: flex; }
.sheet-tabs .segmented button { flex: 1; }
dialog.sheet.scrolled .sheet-tabs { border-bottom-color: var(--separator); }
.sheet-body { overflow-y: auto; padding: 4px 20px 20px; overscroll-behavior: contain; }
.sheet-body section[hidden] { display: none; }
/* flex: 1 1 auto, not flex: 1: the sheet has no set height, and WebKit (Safari, every
   iPhone browser) sizes a 0 % basis in it to nothing, so the sheet showed only its backdrop */
dialog.sheet > form:not([hidden]), dialog.sheet > .sheet-pane:not([hidden]) {
  display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto;
}
dialog.sheet .sheet-body { flex: 1 1 auto; min-height: 0; }

/* Form sheets: Cancel on the left, the title, the action on the right (as iOS) */
.form-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--separator); }
.form-head h2 { font: 600 18px/1.2 var(--font-cut); text-align: center; }
.form-head > button:first-child { justify-self: start; }
.form-head > button:last-child { justify-self: end; }
button.plain.strong { font-weight: 700; }
dialog.form-sheet .sheet-body { padding-top: 16px; }
dialog.sheet .sheet-body > .group + .caption, dialog.sheet .sheet-body > h4:first-child { margin-top: 8px; }
dialog.sheet h4 { margin: 20px 4px 8px; }
dialog.sheet pre { margin: 0; font-size: 13px; user-select: all; }

/* A name edited in place, like a row title */
input.inline-name { width: 100%; margin: 0; padding: 2px 6px; margin-left: -6px; background: transparent;
  font-size: 15px; min-height: 0; border-radius: 6px; }
input.inline-name:hover { background: var(--fill); }
input.inline-name:focus { background: var(--fill-strong); }

/* Reporting presets: cards with a title and what they mean */
.presets { display: grid; gap: 8px; }
.preset { position: relative; display: block; margin: 0; cursor: pointer; }
.preset input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.preset > span { display: grid; gap: 2px; padding: 10px 14px; border-radius: var(--radius-m); background: var(--fill);
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow 150ms var(--ease), background-color 150ms var(--ease); }
.preset strong { font-size: 15px; font-weight: 600; color: var(--text); }
.preset .muted { font-size: 12px; }
.preset input:checked + span { box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-tint); }
.preset input:focus-visible + span { outline: 3px solid rgb(242 107 29 / 0.45); }
.preset.hidden-custom { display: none; }

/* Placing a site: a hint over the map, out of the way of the panel */
.place-hint { position: fixed; top: calc(var(--toolbar-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); }
.place-hint[hidden] { display: none; }

.group { list-style: none; margin: 0; padding: 0; background: var(--fill); border-radius: var(--radius-m); overflow: hidden; }
.group > li, .group > .row {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 8px 14px;
}
.group > li + li::before, .group > .row + .row::before, .group > .row + .preview::before {
  content: ""; position: absolute; top: 0; left: 14px; right: 0; height: 1px; background: var(--separator);
}
.group > li.muted { color: var(--muted); justify-content: center; }
.group > li.event { display: grid; min-height: 0; padding: 9px 14px; }
.events.group { padding: 0; }
.group .grow { flex: 1; min-width: 0; }
.group .title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.group .sub { font-size: 12px; color: var(--muted); }
.group .trail { display: flex; gap: 6px; align-items: center; flex: none; }
.group .trail button { min-height: 28px; padding: 4px 10px; font-size: 13px; }
.sev-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.sev-dot.warning { background: var(--warn); }
.sev-dot.critical { background: var(--error); }
li.off .title, li.off .sev-dot { opacity: 0.45; }
.group-add {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 8px;
  background: var(--fill); color: var(--accent); justify-content: flex-start;
  min-height: 44px; padding: 8px 14px; border-radius: var(--radius-m); font-size: 15px;
}
.group-add:hover { background: var(--fill-strong); }
.group-add .plus { position: relative; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); flex: none; }
.group-add .plus::before, .group-add .plus::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 2px; margin: -1px 0 0 -5px;
  background: #fff; border-radius: 1px; transition: transform 200ms var(--ease);
}
.group-add .plus::after { transform: rotate(90deg); }
.group-add[aria-expanded="true"] .plus::after { transform: rotate(0deg); }
.caption { font-size: 12px; color: var(--muted); margin: 8px 14px 20px; }

/* Composer: rows open in place (grid rows 0fr to 1fr, so it can be reversed mid-way) */
.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 280ms var(--ease), opacity 200ms var(--ease); }
.reveal > * { overflow: hidden; min-height: 0; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal .composer { margin-top: 8px; }
dialog .composer label.row, dialog .composer .row { margin: 0; color: var(--text); font-size: 15px; justify-content: space-between; }
dialog .composer select, dialog .composer input:not([type="checkbox"]):not([type="radio"]) {
  display: inline-block; width: auto; margin: 0; background: var(--fill); text-align: right;
}
dialog .composer select { text-align: left; max-width: 60%; }
dialog .composer label.row input[type="email"] { flex: 1; max-width: 70%; text-align: left; }
.composer .row.stack { flex-wrap: wrap; }
.with-unit { display: inline-flex; align-items: center; gap: 6px; }
dialog .with-unit input { width: 6.5em; }
.unit { color: var(--muted); font-size: 13px; min-width: 2.5em; }
.preview { position: relative; margin: 0; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.composer-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px 12px; }
.banner code, .caption code { font: 12px ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all; }
.banner code { display: block; margin: 8px 0; padding: 8px 10px; background: var(--fill); border-radius: var(--radius-s); user-select: all; }
.group .mono { font: 12px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); }
/* An operator viewing a partner org: the org's name above the list, and the way back */
.view-bar:not([hidden]) { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.view-bar .grow { flex: 1; min-width: 0; }
body.viewing #register-open, body.viewing #shipment-open, body.viewing #manage-open,
body.viewing #api-open, body.viewing #configure-open, body.viewing .ship-actions { display: none; }
.all-search { width: 100%; margin: 0 0 4px; }
#all-list { margin-top: 4px; }

.banner { background: var(--accent-tint); color: var(--text); border-radius: var(--radius-m); padding: 10px 14px; margin: 0 0 12px; font-size: 13px; }

/* Segmented radio group (forms submit it natively) */
.segmented.small { display: inline-flex; }
.segmented.small label { margin: 0; position: relative; color: var(--text); font-size: 13px; }
.segmented.small input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.segmented.small span { display: block; padding: 4px 12px; border-radius: 7px; font-weight: 590; transition: background-color 150ms var(--ease), box-shadow 150ms var(--ease); }
.segmented.small input:checked + span { background: var(--raised); box-shadow: 0 1px 3px rgb(0 0 0 / 0.15); }
.segmented.small input:focus-visible + span { outline: 3px solid rgb(242 107 29 / 0.45); }

/* Switch: a checkbox with role="switch" */
input.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none;
  width: 51px; height: 31px; border-radius: 16px; padding: 0; margin: 0; cursor: pointer;
  background: var(--fill-strong); transition: background-color 200ms var(--ease);
}
input.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgb(0 0 0 / 0.15), 0 1px 1px rgb(0 0 0 / 0.16);
  transition: transform 260ms cubic-bezier(0.3, 1.3, 0.5, 1);
}
input.switch:checked { background: var(--ok); }
input.switch:checked::after { transform: translateX(20px); }
input.switch:active::after { width: 31px; }
input.switch:checked:active::after { transform: translateX(16px); }

@media (prefers-contrast: more) { .group { outline: 1px solid var(--separator); } }
@media (max-width: 720px) {
  /* html: wins over the narrower sheets' own widths (dialog.pair, dialog.signin) */
  html dialog.sheet { width: 100vw; max-width: 100vw; max-height: calc(100dvh - 24px); margin: auto 0 0; border-radius: var(--radius-l) var(--radius-l) 0 0; }
  dialog .composer select { max-width: 55%; }
}

/* Phones: the panel is a bottom sheet with a grabber (app.js moves it between detents) */
@media (max-width: 720px) {
  :root { --toolbar-h: 52px; }
  .brand img.company { height: 28px; }
  .brand img.product { height: 16px; }
  aside {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: calc(100dvh - var(--toolbar-h) - 8px);
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    transform: translateY(var(--sheet-y, 60%));
    will-change: transform;
    touch-action: none;
  }
  /* The sheet is as tall as the screen and slides down by --sheet-y: without this padding
     its last rows would sit below the screen's edge, out of reach of any scrolling */
  .panel-scroll { touch-action: pan-y; padding-bottom: calc(16px + var(--sheet-y, 0px)); }
  .grabber {
    display: block; width: 36px; height: 5px; border-radius: 3px;
    background: var(--fill-strong); margin: 8px auto 0;
  }
  .panel-head { padding-top: 8px; cursor: grab; }
  .maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { display: none; }
}

/* Reduced motion: no scaling or blurring, short cross-fades only */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  dialog:not([open]), dialog[open] { transform: none; filter: none; }
  input.switch::after { transition: none; }
  @starting-style { dialog[open] { transform: none; filter: none; } }
  button:active { transform: none; }
}

button:disabled { opacity: 0.45; cursor: default; pointer-events: none; }

/* Touch screens: every control at least 44 pt tall, as Apple asks */
@media (pointer: coarse) {
  button, select, input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; }
  .segmented button, .segmented.small span { min-height: 36px; display: inline-flex; align-items: center; }
  .group .trail button { min-height: 36px; }
  input.inline-name { min-height: 36px; }
  button.row { padding-top: 12px; padding-bottom: 12px; }
}

/* Legend */
.legend-head { font: 600 13px/1.4 var(--font-cut); color: var(--muted); }
.dot.glow { box-shadow: 0 0 0 1.5px rgb(255 255 255 / 0.7), 0 0 8px 3px rgb(46 204 113 / 0.7); }

/* "Load older" under a history list */
button.older { display: block; width: 100%; margin-top: 8px; }
button.older[hidden] { display: none; }

/* Units switch in the toolbar: the toolbar's dark material, a segmented control */
.header-right { display: flex; align-items: center; gap: 12px; }
.unit-switch { display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: rgb(255 255 255 / 0.12); }
.unit-switch button { min-height: 26px; padding: 3px 10px; border-radius: 7px; background: transparent;
  color: rgb(245 245 247 / 0.75); font-size: 12px; font-weight: 600; letter-spacing: 0; }
.unit-switch button:hover { color: var(--toolbar-text); }
.unit-switch button[aria-checked="true"] { background: rgb(255 255 255 / 0.9); color: #101216;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); }
.unit-switch button:active { transform: none; opacity: 0.8; }
@media (pointer: coarse) { .unit-switch button { min-height: 32px; } }
/* Phones: the toolbar is 390 pt wide. One logo, "°C | °F" (the distance unit follows),
   so the switch and the account button fit with room to tap (they were pushed off the edge) */
@media (max-width: 720px) {
  header { padding: 0 12px; }
  .brand img.company { display: none; }
  .brand img.product { padding-left: 0; border-left: 0; }
  .header-right { gap: 8px; }
  .unit-switch button { min-width: 44px; padding: 3px 8px; font-size: 13px; }
  .unit-switch .unit-more { display: none; }
}

/* Playback: sensor condition and transport share a floating stack over the map. */
.playback-stack {
  position: fixed; z-index: 2; bottom: 12px;
  left: calc(var(--panel-w) + 24px); right: 12px;
  margin: 0 auto; max-width: 760px;
  display: flex; flex-direction: column; gap: 8px;
  animation: materialize 280ms var(--ease);
}
.playback-stack[hidden] { display: none; }
.playback {
  border-radius: var(--radius-l); padding: 10px 14px 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.playback[hidden] { display: none; }
@keyframes materialize { from { opacity: 0; transform: translateY(8px) scale(0.98); filter: blur(6px); } }
body.playing .map-legend { display: none; }

/* The condition at the map's exact playback time. Both lanes use one playhead. */
.pb-telemetry { border-radius: var(--radius-l); overflow: hidden; }
.pb-telemetry[hidden] { display: none; }
.pbt-head {
  min-height: 58px; padding: 9px 14px;
  display: grid; grid-template-columns: minmax(140px, 1fr) auto;
  align-items: center; gap: 20px; border-bottom: 1px solid var(--separator);
}
.pbt-title { min-width: 0; }
.pbt-title strong, .pbt-title span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbt-title strong { font: 600 15px/1.2 var(--font-cut); }
.pbt-title span { margin-top: 2px; font-size: 11px; }
.pbt-metric { min-width: 118px; }
.pbt-label { display: block; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.pbt-reading { display: flex; align-items: baseline; gap: 7px; margin-top: 1px; white-space: nowrap; }
.pbt-reading strong { font: 600 23px/1 var(--font-cut); }
.pbt-reading small { font-size: 11px; font-weight: 600; }
.pbt-reading small.ok { color: var(--ok); }
.pbt-reading small.bad { color: var(--error); }
.pbt-gauges { grid-template-columns: repeat(3, minmax(0, 130px)); justify-content: space-around; margin: 0; padding: 8px 14px 4px;
               border-bottom: 1px solid var(--separator); font-size: 12px; }
.pbt-gauges[hidden] { display: none; }
.g-age { font-size: 10px; color: var(--muted); min-height: 13px; }
.pbt-chart { height: 140px; background: color-mix(in srgb, var(--raised) 50%, transparent); }
.pbt-chart svg { display: block; width: 100%; height: 100%; }
.pbt-chart .lane-label { font: 600 10px var(--font-cut); fill: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.pbt-chart .axis { font: 500 9px var(--font-cut); fill: var(--muted); }
.pbt-chart .range { fill: var(--cold-tint); }
.pbt-chart .limit { stroke: var(--cold); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.pbt-chart .divider, .pbt-chart .baseline { stroke: var(--separator); stroke-width: 1; }
.pbt-chart .temp-line { fill: none; stroke: var(--cold); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pbt-chart .temp-dot { fill: var(--cold); stroke: var(--raised); stroke-width: 2; }
.pbt-chart .temp-dot.bad { fill: var(--error); }
.pbt-chart .ride-bar { fill: var(--muted); opacity: 0.58; }
.pbt-chart .playhead { stroke: var(--accent); stroke-width: 2; }
.pbt-chart .play-dot { fill: var(--accent); stroke: var(--raised); stroke-width: 2; }
.pbt-chart .time-tag { font: 600 9px var(--font-cut); fill: var(--text); }
.pbt-chart.loading { opacity: 0.55; }
.pbt-chart.loading::before {
  content: ""; display: block; height: 100%;
  background: linear-gradient(100deg, transparent 20%, var(--fill-strong) 38%, transparent 56%) 0 0 / 220% 100%,
    linear-gradient(var(--fill) 0 0) 54px 26px / calc(100% - 70px) 34px no-repeat,
    linear-gradient(var(--fill) 0 0) 54px 92px / calc(100% - 70px) 24px no-repeat;
  animation: telemetry-load 1.2s linear infinite;
}
@keyframes telemetry-load { to { background-position: -220% 0, 54px 26px, 54px 92px; } }
.pbt-message { min-height: 84px; display: grid; place-items: center; padding: 18px; text-align: center; font-size: 13px; }
.pbt-message[hidden] { display: none; }
.pb-head { display: flex; align-items: center; gap: 12px; }
.pb-title { flex: 1; min-width: 0; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-head button.plain { padding: 4px 2px; }
.pb-custom[hidden] { display: none; }
.pb-custom { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.pb-custom label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin: 0; }
.pb-custom input { min-width: 0; }
.pb-transport { display: flex; align-items: center; gap: 12px; }
button.pb-play { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; flex: none;
  display: grid; place-items: center; }
.pb-play svg { width: 20px; height: 20px; fill: currentColor; grid-area: 1 / 1; }
.pb-play .icon-pause, .pb-play.on .icon-play { display: none; }
.pb-play.on .icon-pause { display: block; }
.pb-scrubber { position: relative; flex: 1; min-width: 0; height: 28px; }
.pb-ticks { position: absolute; left: 8px; right: 8px; top: 50%; height: 14px; transform: translateY(-50%);
  pointer-events: none; }
.pb-ticks i { position: absolute; top: 0; width: 2px; height: 14px; margin-left: -1px; border-radius: 1px;
  background: var(--muted); opacity: 0.55; }
.pb-ticks i.warning { background: var(--warn); opacity: 0.9; }
.pb-ticks i.critical { background: var(--error); opacity: 1; }
#pb-scrub, #tl-scrub { position: relative; width: 100%; height: 28px; margin: 0; padding: 0; background: none;
  min-height: 0; border: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
#pb-scrub::-webkit-slider-runnable-track, #tl-scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--played, 0%), var(--fill-strong) var(--played, 0%)); }
#pb-scrub::-moz-range-track, #tl-scrub::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill-strong); }
#pb-scrub::-moz-range-progress, #tl-scrub::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
#pb-scrub::-webkit-slider-thumb, #tl-scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.3), 0 0 0 0.5px rgb(0 0 0 / 0.1);
  transition: transform 100ms var(--ease); }
#pb-scrub:active::-webkit-slider-thumb, #tl-scrub:active::-webkit-slider-thumb { transform: scale(1.15); }
#pb-scrub::-moz-range-thumb, #tl-scrub::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.3); }
#pb-scrub:disabled, #tl-scrub:disabled { cursor: default; opacity: 0.5; }
.pb-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; min-height: 16px; }
.pb-time { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0; white-space: nowrap; }
.pb-foot .muted { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The map control that opens it */
.maplibregl-ctrl button.pb-open svg { width: 16px; height: 16px; fill: #333; display: block; margin: auto; }
@media (max-width: 720px) {
  .playback-stack { top: calc(var(--toolbar-h) + 8px); bottom: auto; left: 8px; right: 8px; padding: 0; gap: 6px; }
  .playback { order: 1; padding: 8px 10px; }
  .pb-telemetry { order: 2; }
  .pbt-head { min-height: 52px; padding: 7px 10px; grid-template-columns: minmax(90px, 1fr) auto; gap: 8px; }
  .pbt-gauges { padding: 6px 6px 2px; }
  .pbt-title span { display: none; }
  .pbt-title strong { font-size: 14px; }
  .pbt-metric { min-width: 0; }
  .pbt-label { font-size: 9px; }
  .pbt-reading { gap: 4px; }
  .pbt-reading strong { font-size: 18px; }
  .pbt-reading small { max-width: 64px; overflow: hidden; text-overflow: ellipsis; font-size: 9px; }
  .pbt-chart { height: 118px; }
  .pb-head { flex-wrap: wrap; row-gap: 6px; }
  .pb-head .segmented { order: 3; width: 100%; display: flex; }
  .pb-head .segmented label { flex: 1; text-align: center; }
  .pb-transport { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .playback-stack, .pbt-chart.loading::before { animation: none; }
}

/* Sign-in (HALO_AUTH=otp): a sheet that cannot be dismissed, over an empty canvas */
dialog.signin { width: min(400px, calc(100vw - 32px)); }
dialog.signin .sheet-body { padding: 28px 24px 20px; text-align: center; }
dialog.signin .signin-brand { display: block; height: 24px; width: auto; margin: 0 auto 20px; }
dialog.signin h2 { font: 600 24px/1.15 var(--font-cut); margin-bottom: 4px; }
dialog.signin .signin-lead { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
dialog.signin .group { text-align: left; }
dialog.signin .signin-submit { width: 100%; min-height: 44px; margin-top: 16px; font-size: 16px; }
dialog.signin .signin-back { margin-top: 8px; }
dialog.signin input[name="code"] { font: 600 20px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.3em; }
dialog.signin .error { margin-top: 12px; }
dialog.signin [hidden] { display: none; }
dialog.signin .signin-links { display: flex; justify-content: center; gap: 16px; margin-top: 8px; }
dialog.signin .signin-links:not(:has(button:not([hidden]))) { display: none; }
dialog.signin input[name="code"]:placeholder-shown { font: inherit; letter-spacing: normal; }

/* Signed out: only the sign-in sheet, over the bare map canvas; nothing to press behind it */
body.signed-out #panel, body.signed-out .header-right { visibility: hidden; }

/* A row that opens something (a disclosure chevron) or acts (Sign out), as iOS settings */
.group > li.link-row { padding: 0; }
.group > li.link-row[hidden] { display: none; }
.row-link { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 14px;
  background: none; color: var(--text); font-weight: 400; font-size: 15px;
  text-align: left; border-radius: 0; }
.row-link:hover { background: var(--fill); }
.row-link:active { transform: none; background: var(--fill-strong); }
.row-link:not(.destructive)::after { content: ""; width: 7px; height: 7px; flex: none; margin: 0 2px 0 4px;
  border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); opacity: 0.7; }
.row-link.destructive { justify-content: center; color: var(--error); }
.head-lead { display: flex; flex-direction: column; align-items: flex-start; }
.head-lead button.back { margin: -4px 0 2px -2px; padding-left: 0; }
.composer-error { margin: 0; padding: 0 14px 12px; text-align: right; font-size: 13px; }
.composer-error:empty { display: none; }

/* Press to pair: one centered step at a time, as the sign-in sheet */
dialog.pair { width: min(420px, calc(100vw - 32px)); }
dialog.pair [hidden] { display: none; }
dialog.pair .head-spacer { width: 56px; }
dialog.pair .pair-lead { color: var(--muted); font-size: 14px; margin: 4px 0 16px; text-align: center; }
dialog.pair input[name="device_id"] { font: 600 16px var(--font-cut); letter-spacing: 0.06em; }
dialog.pair input[name="device_id"]:placeholder-shown { font: inherit; letter-spacing: normal; }
dialog.pair .pair-submit { width: 100%; min-height: 44px; margin-top: 16px; font-size: 16px; }
dialog.pair .pair-wide { width: 100%; min-height: 44px; margin-top: 8px; }
dialog.pair .pair-links { display: flex; justify-content: center; margin-top: 8px; }
dialog.pair .error { margin-top: 12px; text-align: center; }
dialog.pair .error:empty { display: none; }
dialog.pair .pair-center { padding: 28px 24px 20px; text-align: center; }
dialog.pair .pair-center h2 { font: 600 24px/1.2 var(--font-cut); outline: none; }
dialog.pair .mono { letter-spacing: 0.04em; }
dialog.pair .pair-time { font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text); margin: 0 0 12px; }
dialog.pair .caption { margin: 0 0 12px; text-align: center; }
dialog.pair .caption:empty { display: none; }
/* Pairing by moving the board: the steps, ticked off as the board reports them */
.pair-moves { list-style: none; counter-reset: step; margin: 0 0 12px; padding: 0; text-align: left; }
.pair-moves li { counter-increment: step; display: flex; gap: 10px; align-items: center;
  padding: 8px 12px; border-radius: 10px; color: var(--muted); }
.pair-moves li::before { content: counter(step); flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; background: var(--fill-strong); color: var(--text); }
.pair-moves li.now { color: var(--text); font-weight: 600; background: var(--fill-strong); }
.pair-moves li.now::before { background: var(--accent); color: #fff; }
.pair-moves li.done { color: var(--ok); }
.pair-moves li.done::before { content: "✓"; background: var(--ok); color: #fff; }

/* The countdown: a ring that empties, around a button that pulses toward a press */
.pair-dial { position: relative; width: 120px; height: 120px; margin: 0 auto 20px; }
.pair-dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.pair-dial circle { fill: none; stroke-width: 5; }
.pair-dial .track { stroke: var(--fill-strong); }
.pair-dial .left { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100;
  stroke-dashoffset: var(--gone, 0); transition: stroke-dashoffset 1s linear; }
.pair-button { position: absolute; inset: 36px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-tint); animation: pair-pulse 1.6s ease-out infinite; }
@keyframes pair-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); transform: scale(1); }
  20% { transform: scale(0.94); }
  40% { transform: scale(1); }
  100% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.pair-check { width: 72px; height: 72px; margin: 4px auto 20px; border-radius: 50%; background: var(--ok); position: relative; }
.pair-check::after { content: ""; position: absolute; left: 25px; top: 18px; width: 16px; height: 30px;
  border-right: 5px solid #fff; border-bottom: 5px solid #fff; transform: rotate(45deg); border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { .pair-button { animation: none; } }

/* Header: the gear (the org's settings) and the avatar (account menu), as macOS toolbars */
.header-icon, button.header-user { width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: 50%;
  display: inline-grid; place-items: center; color: var(--toolbar-text); background: transparent; }
.header-icon svg { width: 20px; height: 20px; opacity: 0.85; }
.header-icon:hover { background: rgb(255 255 255 / 0.12); }
.header-icon:hover svg { opacity: 1; }
.header-icon[hidden] { display: none; }
button.header-user { font-size: 0; background: rgb(255 255 255 / 0.16); opacity: 1; }
button.header-user::before { content: attr(data-initial); font-size: 14px; font-weight: 600; color: var(--toolbar-text); }
button.header-user:hover { background: rgb(255 255 255 / 0.24); }
.header-icon:active, button.header-user:active { transform: scale(0.94); }
/* Touch: a 44 pt target around the 32 pt circle, as Apple asks */
@media (pointer: coarse) {
  .header-icon, button.header-user { position: relative; }
  .header-icon::after, button.header-user::after { content: ""; position: absolute; inset: -6px; }
}
.header-icon:focus-visible, button.header-user:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The account menu: a popover under the avatar (light dismiss and Esc come with it) */
.menu { position: fixed; inset: auto; top: calc(var(--toolbar-h) + 6px); right: 12px; margin: 0;
  width: min(280px, calc(100vw - 24px)); padding: 6px; border: 0; color: var(--text);
  background: var(--raised); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-radius: 14px; box-shadow: var(--shadow-deep); transform-origin: top right;
  opacity: 0; transform: scale(0.96) translateY(-4px);
  transition: opacity 160ms var(--ease), transform 160ms var(--ease), display 160ms allow-discrete, overlay 160ms allow-discrete; }
.menu:popover-open { opacity: 1; transform: none; }
@starting-style { .menu:popover-open { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.menu-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; margin-bottom: 4px;
  border-bottom: 1px solid var(--separator); }
.menu-head .grow { min-width: 0; }
.menu-head .title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head .sub { font-size: 12px; color: var(--muted); }
.avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 600; font-size: 16px; }
.menu-item { display: block; width: 100%; min-height: 36px; padding: 8px 10px; border-radius: 8px; text-align: left;
  background: none; color: var(--text); font-weight: 400; font-size: 14px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--fill); outline: none; }
.menu-item:active { transform: none; background: var(--fill-strong); }
.menu-item.destructive { color: var(--error); }
.menu-item[hidden] { display: none; }
@media (pointer: coarse) { .menu-item { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { .menu, .menu:popover-open { transform: none; } }

/* Configure: deleting the device, last and apart (admins only) */
#configure-danger { margin-top: 24px; }
#configure-danger[hidden] { display: none; }
.row-link.destructive.confirm { background: var(--error); color: #fff; font-weight: 600; }
