/* Layout: one-screen app. Phone: header, state strip, Mapa/Dispositivos switch, bottom sheet for the device.
   Tablet and up: device tree on the left, map on the right, states card and device card floating on the map. */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --fg: #1d2433; --muted: #5b6475; --line: #dde2ea; --soft: #eceff4;
  --accent: #3274d9; --accent-soft: rgba(50, 116, 217, .1);
  --ok: #37a53f; --warn: #e0b400; --crit: #e02f44; --unk: #d63fc7; --off: #8e8e8e;
  --land: #f2efe9; --sea: #aad3df; --lagoon: #d3e8d6; --road: #ffffff; --road-case: #d6cfc3; --road-major: #f7dfa0; --block: #e8e2d8; --map-label: #5d6a73; --sea-label: #4f7f93;
  --raise: #ffffff;
  --shadow: 0 6px 24px rgba(20, 30, 50, .16); --drop: 0 8px 28px rgba(0, 0, 0, .16);
  --font: "Poppins", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317; --surface: #181c22; --fg: #e4e8ef; --muted: #8f98a8; --line: #2a313b; --soft: #20262e;
    --accent: #5b93e6; --accent-soft: rgba(91, 147, 230, .14);
    --land: #1e2329; --sea: #142c38; --lagoon: #1b2f26; --road: #39414c; --road-case: #2a3038; --road-major: #6b5a32; --block: #252b33; --map-label: #8d99a5; --sea-label: #6b9bb0;
    --raise: #343c48; --shadow: 0 6px 24px rgba(0, 0, 0, .5); --drop: 0 8px 28px rgba(0, 0, 0, .55); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101317; --surface: #181c22; --fg: #e4e8ef; --muted: #8f98a8; --line: #2a313b; --soft: #20262e;
  --accent: #5b93e6; --accent-soft: rgba(91, 147, 230, .14);
  --land: #1e2329; --sea: #142c38; --lagoon: #1b2f26; --road: #39414c; --road-case: #2a3038; --road-major: #6b5a32; --block: #252b33; --map-label: #8d99a5; --sea-label: #6b9bb0;
  --raise: #343c48; --shadow: 0 6px 24px rgba(0, 0, 0, .5); --drop: 0 8px 28px rgba(0, 0, 0, .55); color-scheme: dark;
}
/* Scroll bars as in wim-server: the browser's own thin bar coloured light blue (Chrome, Edge and Firefox);
   the browser draws it as a fine line and widens it under the mouse */
:root { --sb: #a9c8f2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sb: #3d5f8e; } }
:root[data-theme="dark"] { --sb: #3d5f8e; }
/* Chrome, Edge and Safari: drawn by hand to make it thinner than the browser's thin bar. The bar keeps 10 px so it is
   easy to catch; the transparent border leaves a 2 px line at rest and 6 px under the mouse or while dragging */
::-webkit-scrollbar { width: 10px; height: 10px; background: transparent; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sb); background-clip: padding-box; border: 4px solid transparent; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover, ::-webkit-scrollbar-thumb:active { border-width: 2px; }
/* Firefox: its own thin bar, which it already narrows at rest */
@supports not selector(::-webkit-scrollbar) { * { scrollbar-width: thin; scrollbar-color: var(--sb) transparent; } }
/* Base reset, so the page in the www behaves the same as the mockup */
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 14px; overflow: hidden; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { height: 100%; display: flex; flex-direction: column; gap: 10px; box-sizing: border-box;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 0 12px; }

/* Header */
.top { display: flex; align-items: center; gap: 12px; min-height: 54px; border-bottom: 1px solid var(--line); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { height: 32px; width: auto; flex: none; }
.bname { display: grid; line-height: 1.15; }
.brand b { font-size: 17px; font-weight: 700; letter-spacing: .06em; }
.bname small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.sectc { width: auto; min-width: 190px; }
.sectc .combo-t { height: 38px; font-weight: 600; font-size: 14.5px; }
.sectc .combo-p { left: 0; right: auto; width: 250px; z-index: 45; }
.opt .ico { width: 17px; height: 17px; color: var(--accent); }
.combo-l hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.top .sp { flex: 1; }
.clock { text-align: right; line-height: 1.25; font-variant-numeric: tabular-nums; }
.clock b { display: block; font-size: 14px; font-weight: 600; }
.clock span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bell { all: unset; position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.bell:hover { background: var(--accent-soft); color: var(--accent); }
.bell svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell i { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; background: var(--crit); color: #fff; font-size: 11px; font-weight: 700; font-style: normal; display: grid; place-items: center; animation: blink 1.1s steps(1) infinite; }

/* State strip (phone) and states card (tablet+) share the same data */
.stripbox { position: relative; flex: none; }
.strip { display: flex; gap: 8px; overflow: hidden; }
/* When the state chips do not fit, they keep only the square and the number (the name goes to the tooltip) */
.strip.compact .chip .lbl { display: none; }
.strip.compact .chip { flex: 1; justify-content: center; padding: 0 11px; gap: 6px; }
.strip::-webkit-scrollbar { display: none; }
.chip { all: unset; flex: none; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chip b { font-weight: 700; }
.chip .sq { width: 9px; height: 9px; }
.chip[aria-pressed="true"] { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 12%, var(--surface)); }
.chip.total { --c: var(--accent); }

/* Phone: Mapa / Dispositivos as a rounded two-way switch: the open view is the raised white pill; they replace the pane titles */
.views { display: flex; gap: 4px; flex: none; align-items: center; padding: 4px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); }
.views button[role="tab"] { all: unset; flex: 1; text-align: center; height: 34px; line-height: 34px; border-radius: 999px; font-weight: 500; font-size: 14px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s, transform .1s; }
.views button[role="tab"]:hover { color: var(--fg); }
.views button[role="tab"]:active { transform: translateY(1px); }
.views button[aria-selected="true"] { background: var(--raise); color: var(--fg); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .14); }
@media (max-width: 759px) { .pane .ph { display: none; } .tree-pane .tools { padding-top: 10px; } }
.ph-only { display: none !important; }
@media (max-width: 759px) { .ph-only { display: grid !important; } .tools .inf { width: 36px; height: 36px; } .ctrl .inf { width: 38px; height: 38px; border-radius: 0; color: var(--fg); } .ctrl .inf svg { width: 18px; height: 18px; } }

.split { display: none; position: relative; flex-direction: column; align-items: center; justify-content: center; cursor: col-resize; touch-action: none; }
.split .dots { all: unset; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.split .dots::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); transition: background .15s, transform .15s; }
.split .dots:hover::before { background: var(--accent); transform: scale(1.25); }
.split.drag, .split:hover { background: var(--accent-soft); }
.split button { all: unset; position: absolute; left: 50%; width: 20px; height: 26px; margin-left: -10px; display: grid; place-items: center; cursor: pointer; color: var(--muted); border-radius: 4px; }
.split button:hover { color: var(--accent); background: var(--accent-soft); }
.split button svg { width: 10px; height: 10px; fill: currentColor; }
.split .sl { top: 22%; } .split .sr { top: 72%; }
/* Connection with the server lost: icon beside the clock (its text in the tooltip), states in grey and without blinking until it comes back */
.conn { all: unset; flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; cursor: help; background: color-mix(in srgb, var(--unk) 14%, transparent); animation: blink 1.1s steps(1) infinite; }
.conn svg { width: 19px; height: 19px; fill: none; stroke: var(--unk); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.conn.back { background: color-mix(in srgb, var(--ok) 14%, transparent); animation: none; }
.conn.back svg { stroke: var(--ok); }
.stale .strip, .stale .tree, .stale .layer, .stale .states, .stale .pop { filter: grayscale(1); opacity: .55; }
.stale .sq, .stale .halo, .stale .bell i { animation: none !important; }
.stale .halo { display: none !important; }
.main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; position: relative; }
.pane { min-height: 0; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.main[data-view="map"] .tree-pane { display: none; }
.main[data-view="tree"] .map-pane { display: none; }

/* Status square, the same as the desktop client: blinks on alarm and on no communication */
.sq { flex: none; width: 11px; height: 11px; border-radius: 2px; background: var(--c); }
[data-st="ok"] { --c: var(--ok); } [data-st="warn"] { --c: var(--warn); } [data-st="crit"] { --c: var(--crit); } [data-st="unk"] { --c: var(--unk); } [data-st="off"] { --c: var(--off); }
.sq.blink, [data-st="crit"] > .sq, [data-st="unk"] > .sq { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Device tree */
.tree-pane { display: flex; flex-direction: column; }
.tools { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.search { flex: 1; min-width: 0; position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { width: 100%; box-sizing: border-box; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); padding: 0 10px 0 32px; font: inherit; font-size: 14px; }
.tools { position: relative; }
/* Combo box as in wim-server (Devices): box with pill and chevron; list with filter, selected option in blue with its check */
.combo { position: relative; flex: none; width: 168px; }
.combo-t { all: unset; box-sizing: border-box; width: 100%; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 13.5px; }
.combo-t[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.combo-t .ico { width: 15px; height: 15px; color: var(--accent); }
.combo-v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-t .cv { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.combo-t[aria-expanded="true"] .cv { transform: rotate(180deg); }
.combo-p { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: max(100%, 190px); max-width: calc(100vw - 40px); box-sizing: border-box; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--drop); padding: 6px; }
.combo-f { width: 100%; box-sizing: border-box; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 14px; background: var(--surface); color: var(--fg); outline: none; }
.combo-f:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.combo-l { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.opt { all: unset; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.opt:hover, .opt:focus-visible { background: var(--accent-soft); }
.opt[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.opt .pill { min-width: 30px; height: 22px; padding: 0 8px; box-sizing: border-box; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.opt[aria-selected="true"] .pill { background: var(--accent); color: #fff; }
.opt .on { font-weight: 500; white-space: nowrap; }
.opt[aria-selected="true"] .on { font-weight: 600; }
.opt small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.opt .ck { width: 16px; height: 16px; margin-left: auto; flex: none; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.opt[aria-selected="true"] .ck { visibility: visible; }
.combo-none { padding: 10px; color: var(--muted); font-size: 13px; }
.tree { flex: 1; overflow-y: auto; padding: 4px 0 12px; -webkit-overflow-scrolling: touch; }
.node { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; cursor: pointer; }
.node:hover { background: var(--accent-soft); }
.node .chev { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.node[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.node .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl1 { font-weight: 600; font-size: 14.5px; }
.lvl2 { padding-left: 32px; font-weight: 600; color: var(--accent); }
.dev { padding-left: 56px; font-size: 14px; }
.ico { display: inline-block; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.dev .ic { width: 16px; height: 16px; color: var(--muted); }
.dev .when { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dev[data-st="crit"] .when, .dev[data-st="unk"] .when { color: var(--c); font-weight: 600; }
.dev[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.badges { display: flex; gap: 4px; }
.badges span { min-width: 22px; height: 22px; padding: 0 7px; box-sizing: border-box; border-radius: 999px; font-size: 12px; font-weight: 600; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

/* Map */
.map-pane { display: flex; flex-direction: column; }
.map-wrap { position: relative; flex: 1; min-height: 0; }
/* Pane header: title and (i) with its tooltip, as the panels of the dashboards */
.ph { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; flex: none; border-bottom: 1px solid var(--line); }
.ph h2 { margin: 0; font-size: 15px; font-weight: 600; }
.ph-n { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.inf { all: unset; width: 22px; height: 22px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; cursor: help; color: var(--muted); }
.inf:hover, .inf:focus-visible { color: var(--accent); }
.inf svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tip { position: fixed; z-index: 60; max-width: min(320px, calc(100vw - 32px)); box-sizing: border-box; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--drop); padding: 10px 12px; font-size: 13px; line-height: 1.55; pointer-events: none; }
.states-h h3 { flex: 0 1 auto; }
.states-h .inf { margin-right: auto; }
.map { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; background: var(--sea); }
.map.drag { cursor: grabbing; }
.map svg.base { position: absolute; inset: 0; width: 100%; height: 100%; }
.tiles { position: absolute; inset: 0; }
.tiles img { position: absolute; max-width: none; pointer-events: none; user-select: none; }
.map.tiled { background: var(--land); }
.map.tiled svg.base, .map.tiled #labels { display: none; }
.layer { position: absolute; inset: 0; pointer-events: none; }
.mlabel { position: absolute; transform: translate(-50%, -50%); font-size: 11.5px; font-weight: 600; color: var(--map-label); white-space: nowrap; letter-spacing: .02em; text-shadow: 0 0 3px var(--land), 0 0 3px var(--land); }
.mlabel.sea { color: var(--sea-label); font-style: italic; font-weight: 500; text-shadow: none; letter-spacing: .12em; }
.mlabel.town { font-size: 13px; font-weight: 700; color: var(--fg); }

.pin { position: absolute; width: 0; height: 0; pointer-events: auto; }
.pin .dot, .clu { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-sizing: border-box; box-shadow: 0 3px 10px rgba(0, 0, 0, .35); display: grid; place-items: center; cursor: pointer; transition: transform .15s; }
.pin .dot:hover, .clu:hover { transform: scale(1.12); }
.pin .dot .ico { width: 15px; height: 15px; color: #fff; }
.halo { pointer-events: none; position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%; background: var(--c); animation: halo 1.6s ease-out infinite; }
@keyframes halo { 0% { transform: scale(1); opacity: .65; } 100% { transform: scale(3.2); opacity: 0; } }
.pin[data-st="ok"] .halo, .pin[data-st="warn"] .halo, .pin[data-st="off"] .halo { display: none; }
.pin.cluster .halo { display: block; }
.pin.cluster .halo[hidden] { display: none; }
.clu { transition: background-color .25s; }
.pin .lbl { position: absolute; left: 0; top: -38px; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--c); text-shadow: 0 0 3px var(--land), 0 0 3px var(--land), 0 0 2px var(--land); pointer-events: none; }
.map.nolbl .pin .lbl { display: none; }
.pin.sel .dot { outline: 3px solid var(--accent); outline-offset: 2px; }
.pin.dim { opacity: .25; }
.clu { left: -18px; top: -18px; width: 36px; height: 36px; color: #fff; font-weight: 700; font-size: 14px; }
.pin.cluster .halo { left: -18px; top: -18px; width: 36px; height: 36px; }

.ctrl { position: absolute; left: 10px; top: 10px; z-index: 5; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.ctrl button { all: unset; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; font-size: 19px; }
.ctrl button + button { border-top: 1px solid var(--line); }
.ctrl button:hover { background: var(--accent-soft); color: var(--accent); }
.ctrl svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.attr { position: absolute; right: 6px; bottom: 4px; z-index: 5; font-size: 10.5px; color: var(--muted); background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 1px 6px; border-radius: 4px; }
.scale { position: absolute; left: 12px; bottom: 8px; z-index: 5; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale i { display: block; height: 5px; border: 2px solid var(--muted); border-top: 0; margin-bottom: 2px; }

/* States card (tablet+) */
.states { display: none; position: absolute; right: 12px; top: 12px; z-index: 6; width: 250px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; }
.states { transition: width .2s ease; }
.states-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.states-h h3 { margin: 0; flex: 1; font-size: 14px; font-weight: 600; }
.states-h .badges span { height: 22px; }
.fold { all: unset; width: 28px; height: 28px; margin: -4px -6px -4px 0; flex: none; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.fold:hover { background: var(--accent-soft); color: var(--accent); }
.fold svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.states.min { width: auto; padding: 8px 12px; }
.states.min .states-h { margin: 0; }
.states.min .donut, .states.min .legend { display: none; }
.states:not(.min) .states-h .badges { display: none; }
.states.min .fold svg { transform: rotate(180deg); }
.donut { width: 128px; height: 128px; margin: 4px auto 10px; border-radius: 50%; display: grid; place-items: center; }
.donut div { width: 96px; height: 96px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; line-height: 1.15; }
.donut b { font-size: 28px; font-weight: 700; display: block; font-variant-numeric: tabular-nums; }
.donut span { font-size: 12px; color: var(--muted); }
.legend { display: grid; gap: 2px; }
.legend button { all: unset; display: grid; grid-template-columns: 11px 1fr auto 48px; gap: 8px; align-items: center; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.legend button:hover { background: var(--accent-soft); }
.legend button[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 14%, transparent); }
.legend b { font-weight: 700; text-align: right; }
.legend em { font-style: normal; color: var(--muted); text-align: right; }

/* Device popup: the same card as the camera maps in Grafana (cm-card), anchored to the device with its arrow */
.pop { position: absolute; z-index: 8; width: 360px; max-width: calc(100% - 24px); box-sizing: border-box; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 10px;
  box-shadow: var(--drop); font-size: 14px; cursor: default; pointer-events: auto; transform: translate(calc(-50% + var(--dx, 0px)), calc(-100% - 26px)); }
.pop::after { content: ''; position: absolute; left: calc(50% - var(--dx, 0px)); bottom: -7px; width: 12px; height: 12px; background: var(--surface); border: solid var(--line); border-width: 0 1px 1px 0; transform: translateX(-50%) rotate(45deg); border-radius: 0 0 2px 0; }
.pop.below { transform: translate(calc(-50% + var(--dx, 0px)), 26px); }
.pop.below::after { bottom: auto; top: -7px; border-width: 1px 0 0 1px; border-radius: 2px 0 0 0; }
.pop.free { position: fixed; z-index: 40; left: 50%; top: 50%; max-width: calc(100vw - 32px); transform: translate(-50%, -50%); }
.pop.free::after { display: none; }
.pop-h { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pop-h b { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.3; }
.state-chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.state-chip .sq { width: 7px; height: 7px; border-radius: 50%; }
.x { all: unset; flex: none; width: 24px; height: 24px; margin: -4px -6px -4px 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; }
.x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.x:hover { background: color-mix(in srgb, var(--crit) 12%, transparent); color: var(--crit); }
.sep { height: 1px; background: var(--line); margin: 8px 0; }
.rows > div { display: grid; grid-template-columns: 165px minmax(0, 1fr); gap: 8px; padding: 3px 0; }
.rows span { font-size: 13px; }
.rows span { color: var(--muted); }
.rows b { font-weight: 500; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.rows b.late { color: var(--unk); font-weight: 700; }
.more { display: none; }
.pop.open .more { display: block; }
.alarms > span { color: var(--muted); }
.alarms div { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.al { display: inline-flex; gap: 6px; align-items: baseline; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.al em { font-style: normal; font-weight: 400; opacity: .8; }
.al.none { --c: var(--muted); font-weight: 500; background: none; padding: 0; }
.foot { display: flex; justify-content: space-between; margin-top: 8px; }
.tog { all: unset; font-size: 13px; font-weight: 500; color: var(--accent); cursor: pointer; }
.tog:hover { text-decoration: underline; }

/* Grafana dashboard of the device, embedded as is */
.dview { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; animation: up .2s ease-out;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.dview-h { display: flex; align-items: center; gap: 10px; min-height: 54px; }
.dview-h b { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.dview-h .x { width: 34px; height: 34px; margin: 0; }
.vtabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 10px; flex: none; }
.vtabs button { all: unset; flex: none; padding: 7px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--fg); cursor: pointer; transition: background .15s, color .15s, transform .1s; }
.vtabs button:hover { background: var(--accent-soft); color: var(--accent); }
.vtabs button:active { transform: translateY(1px); }
.vtabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.vbody { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.acts { display: grid; gap: 0; padding-block: 4px; }
.act { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--soft); }
.act > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.act b { font-weight: 600; font-size: 14px; }
.act span { color: var(--muted); font-size: 12.5px; }
.abtn { all: unset; flex: none; padding: 7px 16px; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; transition: filter .15s, transform .1s; }
.abtn:hover { filter: brightness(1.1); }
.abtn:active { transform: translateY(1px); }
.abtn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); padding: 6px 15px; }
.aconf { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--accent-soft); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; font-size: 13.5px; }
.aconf div { display: flex; gap: 8px; }
.aconf.done { background: color-mix(in srgb, var(--ok) 14%, transparent); }
@media (max-width: 420px) { .act { flex-wrap: wrap; } }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 13.5px; max-width: 640px; }
.dview-b { flex: 1; min-height: 0; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface); display: grid; place-items: center; padding: 16px; text-align: center; }
.dview-b p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; max-width: 60ch; }
.dview-b code { font-family: var(--mono); font-size: 12px; color: var(--fg); overflow-wrap: anywhere; }
.dview-b svg { width: min(520px, 100%); height: 140px; }

/* Tablet and up */
@media (min-width: 760px) {
  .stripbox, .views { display: none; }
  .main, .main[data-view] { grid-template-columns: min(var(--tw, 340px), calc(100% - 232px)) 12px minmax(0, 1fr); gap: 0; }
  .main.tcol { grid-template-columns: 0 12px minmax(0, 1fr); }
  .main.tmax { grid-template-columns: minmax(0, 1fr) 12px 0; }
  .main.tcol .tree-pane, .main.tmax .map-pane { visibility: hidden; border-width: 0; }
  .split { display: flex; }
  .main[data-view] .tree-pane { display: flex; }
  .main[data-view] .map-pane { display: flex; }
  .states { display: block; }
}
@media (max-width: 480px) { .bname { display: none; } .sectc { min-width: 0; } .sectc .combo-t > .ico { display: none; } .clock span { display: none; } .top { gap: 8px; } .rows > div { grid-template-columns: 135px minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) {
  .sq.blink, [data-st="crit"] > .sq, [data-st="unk"] > .sq, .bell i { animation: none; }
  .halo { animation: none; transform: scale(1.7); opacity: .3; }
  .dview { animation: none; }
}

/* Device and section icons: one SVG file each, painted with a mask so they take the colour of the text */
.i-camera { --i: url(../assets/icons/devices/camera.svg); }
.i-pc { --i: url(../assets/icons/devices/pc.svg); }
.i-server { --i: url(../assets/icons/devices/server.svg); }
.i-dash { --i: url(../assets/icons/devices/dash.svg); }
.i-meteo { --i: url(../assets/icons/devices/meteo.svg); }
.i-layers { --i: url(../assets/icons/devices/layers.svg); }
.i-monitor { --i: url(../assets/icons/devices/monitor.svg); }
.i-alarm { --i: url(../assets/icons/devices/alarm.svg); }
.i-hist { --i: url(../assets/icons/devices/hist.svg); }
.i-report { --i: url(../assets/icons/devices/report.svg); }
.i-devcfg { --i: url(../assets/icons/devices/devcfg.svg); }
.i-users { --i: url(../assets/icons/devices/users.svg); }
.i-about { --i: url(../assets/icons/devices/about.svg); }
