:root
{
    color-scheme: dark light;
    --bg: #0e1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c232c;
    --bg-overlay: rgba(13, 17, 23, 0.7);
    --border: #2d333b;
    --fg: #e6edf3;
    --fg-dim: #7d8590;
    --accent: #4493f8;
    --warn: #d29922;
    --danger: #f85149;
    --ok: #3fb950;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: light)
{
    :root
    {
        --bg: #f6f8fa;
        --bg-card: #ffffff;
        --bg-card-hover: #f0f3f6;
        --bg-overlay: rgba(255, 255, 255, 0.7);
        --border: #d0d7de;
        --fg: #1f2328;
        --fg-dim: #59636e;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body
{
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
}

header
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

header h1
{
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.header-meta
{
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.outside
{
    font-size: 12px;
    color: var(--fg-dim);
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.outside.hidden { display: none; }

/* All header chrome pills share the same skeleton so the cluster keeps
   a consistent rhythm and every control reaches the WCAG 2.5.5 24 CSS px
   minimum tap target even on desktop. The shared rule below uses
   `inline-flex` + `align-items: center` so the visible label stays
   centred when we bump `min-height`. Individual pill rules only need to
   override visuals (font-size, letter-spacing, capitalisation). */
.link-pill,
.view-toggle,
.admin-login,
.locale-toggle
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    background: var(--bg-card);
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px 12px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    font: inherit;
}
.link-pill { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.view-toggle { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }

.link-pill:hover,
.view-toggle:hover,
.admin-login:hover,
.locale-toggle:hover { background: var(--bg-card-hover); color: var(--fg); }

/* Admin login pill. Same skeleton as .view-toggle; we keep it on its
   own selector for the post-login `is-authed` accent.  */
.admin-login
{
    font-size: 11px;
    text-transform: none;
    letter-spacing: 0.02em;
}
.admin-login.is-authed
{
    border-color: var(--accent-ok, #4caf50);
    color: var(--fg);
    cursor: default;
}

/* The single source of truth for "this control mutates state".
   Hidden by default, revealed when admin_auth.js flips body.is-admin.
   Use `display: revert` so each element keeps its block/inline/flex
   nature when shown — `display: initial` would force `inline` for
   <button> and break flex layouts. */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: revert !important; }

.bell-wrapper { position: relative; }

.bell
{
    background: var(--bg-card);
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: 999px;
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.bell:hover { background: var(--bg-card-hover); color: var(--fg); }

.bell-badge
{
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bell-badge.hidden { display: none; }

.bell-dropdown
{
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(360px, calc(100vw - 24px));
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
    overflow: hidden;
}

.bell-dropdown.hidden { display: none; }

.dropdown-head
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.link-btn
{
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.link-btn:hover { text-decoration: underline; }

.dropdown-list
{
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}

.dropdown-list li
{
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.dropdown-list li:last-child { border-bottom: none; }
.dropdown-list li:hover { background: var(--bg-card-hover); }

.dropdown-list li.alert-read { opacity: 0.55; }

.dropdown-list .alert-msg { font-size: 13px; }
.dropdown-list .alert-when { font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }

.dropdown-list .empty-state
{
    padding: 20px;
    text-align: center;
    color: var(--fg-dim);
    font-size: 12px;
    cursor: default;
}

.dropdown-list .empty-state:hover { background: transparent; }

.dropdown-foot
{
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.dropdown-foot a
{
    color: var(--accent);
    font-size: 12px;
    text-decoration: none;
}

.dropdown-foot a:hover { text-decoration: underline; }

.delete-btn
{
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    align-self: flex-start;
}

.delete-btn:hover { background: rgba(248, 81, 73, 0.1); }

.status
{
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-connecting { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.status-live       { background: rgba(63, 185, 80, 0.15); color: var(--ok); }
.status-down       { background: rgba(248, 81, 73, 0.15); color: var(--danger); }

main
{
    flex: 1;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Cards live inside ``.sensors`` along with ``.group-header`` <h2>
   markers that introduce each location. The grid makes headers span
   the full row (grid-column: 1/-1) so the next card starts on a fresh
   row and the visual grouping reads as a section, not as a stray
   inline title above one card. */
.sensors
{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.group-header
{
    grid-column: 1 / -1;
    margin: 8px 0 0;
    padding: 0 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-dim);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

.group-header:first-child { margin-top: 0; }

/* "Rez-de-chaussée" / "Étage" / "Cave" / "Extérieur": the top-level
   floor section heading. Heavier than ``.group-header`` so the eye
   reads "floor > room > card" at a glance, and pushed off from the
   previous group with a slightly bigger gap. */
.floor-header
{
    grid-column: 1 / -1;
    margin: 20px 0 4px;
    padding: 0 4px 4px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg);
}
.floor-header:first-child { margin-top: 0; }
/* Tighten the room header right after a floor header (we just used
   a heavy separator above, no need to double the spacing). */
.floor-header + .group-header { margin-top: 4px; }

/* "Unassigned · needs a room": nudge to encourage acting. Subtle
   amber tint so it stands out from neutral location headers without
   being alarming. */
.group-header-new
{
    color: var(--warn, #b97a06);
    border-bottom-color: var(--warn, #b97a06);
}

.card
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 18px;
    transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
    position: relative;
    overflow: hidden;
}

.card:hover { background: var(--bg-card-hover); }

.card.fresh { animation: pulse 700ms ease-out; }

@keyframes pulse
{
    0%   { box-shadow: 0 0 0 0 rgba(68, 147, 248, 0.45); }
    100% { box-shadow: 0 0 0 14px rgba(68, 147, 248, 0); }
}

.card .pill
{
    position: absolute;
    top: 14px;
    right: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.status-ok    .pill { color: var(--ok);     background: var(--ok); }
.status-warn  .pill { color: var(--warn);   background: var(--warn); }
.status-alert .pill { color: var(--danger); background: var(--danger); }
.status-silent .pill { color: var(--danger); background: var(--danger); animation: blink 1.4s infinite; }
.status-unknown .pill { color: var(--fg-dim); background: var(--fg-dim); }

@keyframes blink
{
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

.status-alert  { border-color: rgba(248, 81, 73, 0.55); }
.status-silent { border-color: rgba(248, 81, 73, 0.55); }
.status-warn   { border-color: rgba(210, 153, 34, 0.55); }

.card-head
{
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-right: 22px;
}

.card-icon
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-dim);
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.status-warn  .card-icon { color: var(--warn); }
.status-alert .card-icon { color: var(--danger); }
.status-silent .card-icon { color: var(--danger); opacity: 0.6; }

.card-label
{
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    border: 1px dashed transparent;
    border-radius: 6px;
    padding: 2px 6px;
    margin-left: -6px;
    cursor: text;
    outline: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-label:hover  { border-color: var(--border); }
.card-label:focus  { border-color: var(--accent); border-style: solid; background: var(--bg); }

/* Room pill in the card header (advanced view only). Empty when the
   sensor is unassigned; the ``.hidden`` toggle from app.js folds it. */
.card-location
{
    font-size: 10px;
    color: var(--fg-dim);
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-location.hidden { display: none; }

.settings-btn
{
    background: transparent;
    border: 1px solid var(--border);
    color: var(--fg-dim);
    border-radius: 6px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 120ms ease, border-color 120ms ease;
}

.settings-btn:hover { color: var(--fg); border-color: var(--fg-dim); }

.advanced-only { display: block; }
body.simple-mode .advanced-only { display: none !important; }
body.simple-mode .card-uid { display: none !important; }
body.simple-mode .card-foot-right { display: none !important; }
body.simple-mode .card-label { cursor: default; pointer-events: none; }

/* Gear stays visible in simple mode too — it's the only desktop
   affordance for opening settings (mobile users have long-press,
   power users have right-click, everyone has the gear). Tone it
   down so it doesn't compete with the live data. */
body.simple-mode .settings-btn { opacity: 0.45; }
body.simple-mode .settings-btn:hover,
body.simple-mode .settings-btn:focus-visible { opacity: 1; }

.metrics
{
    display: flex;
    gap: 18px;
    margin-bottom: 10px;
}

.metric
{
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.metric-value
{
    font-size: 30px;
    font-weight: 600;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.metric-unit
{
    font-size: 15px;
    font-weight: 400;
    color: var(--fg-dim);
    margin-left: 2px;
}

.metric-label
{
    font-size: 11px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.metric-range
{
    font-size: 11px;
    color: var(--fg-dim);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.metric-line
{
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.metric-sub
{
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.metric-sub.hidden { display: none; }

.trend
{
    font-size: 12px;
    font-weight: 600;
    margin-left: 4px;
    color: var(--fg-dim);
    line-height: 1;
}

.trend.trend-up   { color: var(--warn); }
.trend.trend-down { color: var(--accent); }
.trend.trend-flat { color: var(--fg-dim); opacity: 0.6; }

.card-delta
{
    display: flex;
    margin-top: 4px;
    margin-bottom: 4px;
}

.card-delta.hidden { display: none; }

.delta-badge
{
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--fg-dim);
    font-variant-numeric: tabular-nums;
}

.delta-badge.delta-hot
{
    color: var(--danger);
    border-color: rgba(248, 81, 73, 0.4);
    background: rgba(248, 81, 73, 0.08);
}

.delta-badge.delta-cool
{
    color: var(--accent);
    border-color: rgba(68, 147, 248, 0.4);
    background: rgba(68, 147, 248, 0.08);
}

.vigilance-banner
{
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.vigilance-banner.hidden { display: none; }

.vigilance-pill
{
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.vigilance-banner[data-level="green"]  { border-color: rgba(63, 185, 80, 0.4); }
.vigilance-banner[data-level="green"]  .vigilance-pill { background: var(--ok); color: var(--ok); }
.vigilance-banner[data-level="yellow"] { border-color: rgba(210, 153, 34, 0.45); }
.vigilance-banner[data-level="yellow"] .vigilance-pill { background: var(--warn); color: var(--warn); }
.vigilance-banner[data-level="orange"] { border-color: rgba(240, 136, 62, 0.55); background: linear-gradient(135deg, rgba(240, 136, 62, 0.10), rgba(240, 136, 62, 0.03)); }
.vigilance-banner[data-level="orange"] .vigilance-pill { background: #f0883e; color: #f0883e; }
.vigilance-banner[data-level="red"]    { border-color: rgba(248, 81, 73, 0.6); background: linear-gradient(135deg, rgba(248, 81, 73, 0.14), rgba(248, 81, 73, 0.04)); }
.vigilance-banner[data-level="red"]    .vigilance-pill { background: var(--danger); color: var(--danger); animation: blink 1.4s infinite; }

.vigilance-text
{
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.vigilance-text strong { font-size: 13px; font-weight: 600; }
.vigilance-text span   { font-size: 12px; color: var(--fg-dim); }

.pull-indicator
{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(-60px);
    text-align: center;
    color: var(--fg-dim);
    font-size: 12px;
    padding: 12px 0;
    opacity: 0;
    transition: transform 0.18s ease-out, opacity 0.18s ease-out;
    pointer-events: none;
    z-index: 50;
}

/* Segmented control — was previously defined in detail.css and
   alerts.css with identical rules. Moved here so /energy (which uses
   the same `.seg` markup) actually gets an active-state visual without
   importing a third copy. Per-page CSS can still override visuals
   without losing the active highlight. */
.seg
{
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-card);
}

.seg button
{
    background: transparent;
    color: var(--fg-dim);
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    font: inherit;
}

.seg button.active
{
    background: var(--accent);
    color: white;
}

.seg button + button { border-left: 1px solid var(--border); }

.seg button:focus-visible
{
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Shared back arrow — every secondary page hand-rolled `.back` (in its
   own per-page CSS) with a 16×18 px font glyph and 4 px padding, giving
   a 24×26 hit box well under the 24×24 AA / 44×44 AAA minimum. Promote
   to a square button-style hit area; per-page CSS can still tweak
   typography (e.g. font-size) without losing the tap target. */
.back,
.back-link
{
    color: var(--fg-dim);
    text-decoration: none;
    font-size: 22px;
    line-height: 1;
    padding: 4px 10px;
    border-radius: 8px;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.back:hover,
.back-link:hover { background: var(--bg-card-hover); color: var(--fg); }

/* Keyboard navigability — the previous styles only set `:hover`, so
   tab-focused controls had no visible ring at all (browsers default to
   the OS-themed focus ring which is invisible on dark themes here).
   `:focus-visible` keeps the ring keyboard-only — mouse users never
   see it on click. */
.link-pill:focus-visible,
.view-toggle:focus-visible,
.admin-login:focus-visible,
.locale-toggle:focus-visible,
.back:focus-visible,
.back-link:focus-visible,
.bell:focus-visible,
.settings-btn:focus-visible,
.link-btn:focus-visible
{
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 768px)
{
    .link-pill,
    .view-toggle,
    .admin-login,
    .locale-toggle { min-height: 44px; padding: 8px 14px; }
    .bell { min-width: 44px; min-height: 44px; }
    .settings-btn { min-width: 44px; min-height: 44px; }
    .back, .back-link { min-width: 44px; min-height: 44px; }
    .card-label { padding: 6px 4px; }
    header h1 { font-size: 18px; }
}

.heat-banner
{
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(248, 81, 73, 0.12), rgba(210, 153, 34, 0.12));
    border: 1px solid rgba(248, 81, 73, 0.35);
    border-radius: 14px;
    padding: 14px 18px;
    margin-bottom: 14px;
    color: var(--fg);
}

.heat-banner.hidden { display: none; }
.heat-banner[data-level="ok"] { border-color: rgba(63, 185, 80, 0.4); background: linear-gradient(135deg, rgba(63, 185, 80, 0.10), rgba(63, 185, 80, 0.04)); }
.heat-banner[data-level="warn"] { border-color: rgba(210, 153, 34, 0.4); }
.heat-banner[data-level="alert"], .heat-banner[data-level="danger"], .heat-banner[data-level="extreme"]
{
    border-color: rgba(248, 81, 73, 0.55);
    background: linear-gradient(135deg, rgba(248, 81, 73, 0.16), rgba(210, 153, 34, 0.10));
}

.heat-icon
{
    display: inline-flex;
    align-items: center;
    color: var(--danger);
}

.heat-text
{
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.heat-text strong { font-size: 14px; font-weight: 600; }
.heat-text span   { font-size: 13px; color: var(--fg-dim); }

.forecast-strip
{
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px 8px;
    margin-bottom: 14px;
}

.forecast-strip.hidden { display: none; }

.forecast-head
{
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 12px;
}

.forecast-title
{
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-dim);
}

.forecast-summary
{
    font-size: 12px;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

.forecast-chart
{
    width: 100%;
    height: 70px;
    display: block;
}

.forecast-ticks
{
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--fg-dim);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

.forecast-ticks span { text-align: center; line-height: 1.2; }
.forecast-ticks strong { font-size: 11px; color: var(--fg); }

.advisor
{
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
}

.advisor.hidden { display: none; }

.advisor-pill
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    font-weight: 600;
    color: var(--fg-dim);
    flex-shrink: 0;
}

.advisor[data-kind="open"]     { border-color: rgba(63, 185, 80, 0.45); }
.advisor[data-kind="open"]     .advisor-pill { color: var(--ok); border-color: rgba(63, 185, 80, 0.55); }
.advisor[data-kind="close"]    { border-color: rgba(248, 81, 73, 0.45); }
.advisor[data-kind="close"]    .advisor-pill { color: var(--danger); border-color: rgba(248, 81, 73, 0.55); }
.advisor[data-kind="marginal"] .advisor-pill { color: var(--warn); }
.advisor[data-kind="hold"]     .advisor-pill { color: var(--fg-dim); }

.advisor-text { color: var(--fg); }

.sparkline
{
    width: 100%;
    height: 32px;
    display: block;
    margin-top: 4px;
}

.sparkline path { fill: none; stroke-width: 1.6; }
.sparkline .sparkline-temp { stroke: var(--accent); }
.sparkline .sparkline-hum  { stroke: var(--fg-dim); stroke-dasharray: 2 3; opacity: 0.7; }

.card-foot
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 10px;
}

.card-uid
{
    font-size: 11px;
    color: var(--fg-dim);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Battery low badge — visible in both simple and advanced view.
   We promote it to a small pill instead of the previous text-only
   styling so it reads at a glance on the dashboard. The "(Nd)" age
   suffix is rendered inline; the full timestamp is in the title attr. */
.battery
{
    font-size: 11px;
    color: var(--fg-dim);
    font-variant-numeric: tabular-nums;
}

.battery-low
{
    color: var(--danger);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(248, 81, 73, 0.10);
    border: 1px solid rgba(248, 81, 73, 0.35);
}

.silent-warning { color: var(--danger); font-weight: 600; }

.empty
{
    text-align: center;
    color: var(--fg-dim);
    margin-top: 40px;
    font-size: 14px;
}

.empty.hidden { display: none; }

footer
{
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    color: var(--fg-dim);
    font-size: 11px;
    display: flex;
    justify-content: center;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}

.sep { opacity: 0.4; }

dialog
{
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--fg);
    padding: 0;
    max-width: 480px;
    width: 92vw;
    /* Hard cap the dialog height to the visual viewport so it can never
       overflow the screen on short windows / mobile keyboards. The form
       inside scrolls instead of cropping the action row at the bottom
       (a long-standing UX trap on phones with the comfort + calibration
       + alerts fieldsets all stacked). `100dvh` accounts for the iOS
       Safari URL bar; falls back to 100vh transparently. */
    max-height: 90vh;
    max-height: 90dvh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

dialog::backdrop { background: rgba(0, 0, 0, 0.55); }

dialog form
{
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    /* Inside-the-form scroll: the head + foot keep their margins, so we
       have to size the form against the dialog's max-height. Use
       `min-height: 0` so the form's children can shrink past their
       intrinsic size and the scroll actually engages. */
    max-height: inherit;
    min-height: 0;
    overflow-y: auto;
}

.dialog-head
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    margin: -20px -20px 0 -20px;
    padding: 16px 20px;
}

.dialog-head h2
{
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.dialog-head .close
{
    background: transparent;
    border: none;
    color: var(--fg-dim);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    /* Was 0 × 4 px → ~24 × 16 px hit area, below AA 24×24. Bump to
       40 × 40 so it's comfortable on touch and visible to keyboard
       users via :focus-visible (inherited from the global pill rule). */
    min-width: 40px;
    min-height: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dialog-head .close:hover { background: var(--bg-card-hover); color: var(--fg); }
.dialog-head .close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dialog-foot
{
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
    margin: 14px -20px -20px -20px;
    padding: 14px 20px;
}

dialog button
{
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
}

dialog button.primary { background: var(--accent); color: white; border-color: var(--accent); }

dialog fieldset
{
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px 12px;
    margin: 0;
}

dialog legend
{
    font-size: 11px;
    text-transform: uppercase;
    color: var(--fg-dim);
    letter-spacing: 0.05em;
    padding: 0 6px;
}

dialog label
{
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

dialog label > span
{
    font-size: 11px;
    color: var(--fg-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

dialog input
{
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
}

dialog input:focus { outline: none; border-color: var(--accent); }

dialog select
{
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
}

dialog select:focus { outline: none; border-color: var(--accent); }

.row
{
    display: flex;
    gap: 10px;
}

.hint
{
    font-size: 11px;
    color: var(--fg-dim);
    margin: 4px 0 0 0;
}

@media (max-width: 540px)
{
    header { padding: 10px 14px; }
    main { padding: 14px; }
    .sensors { grid-template-columns: 1fr; }
    .metric-value { font-size: 26px; }
}
