/* Application styles — token-driven only (WebUI.md §2). */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: var(--font-sans);
    font-size: var(--font-size);
    background: var(--color-bg);
    color: var(--color-text);
}

a { color: var(--color-primary); text-decoration: none; }

.material-symbols-outlined {
    font-family: "Material Symbols Outlined";
    font-weight: normal;
    font-style: normal;
    font-size: 22px;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
}

.app-loading { padding: var(--space-6); color: var(--color-text-muted); }
.pad { padding: var(--space-5); }
.muted { color: var(--color-text-muted); }

/* ---- Shell + tab bar (WebUI.md §7) ---- */
.shell { display: flex; flex-direction: column; min-height: 100vh; }

.tabbar {
    display: flex;
    align-items: stretch;
    height: var(--tabbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--elevation-1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tabs { display: flex; align-items: stretch; }
/* The left tabs take the remaining width and CLIP any overflow, so a long label (e.g. Access
   Control) can never paint over the logo at tight widths; below the breakpoint labels collapse to
   icons (§7) and everything fits comfortably. */
.tabs-left { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tabs-right { flex: 0 0 auto; }

/* Dead-centre logo mode — toggled by window.mohlinkTabbar only when a clear gap remains between the
   tabs and the centred logo (so it reads as a logo, not a tab). Equal 1fr side columns put the logo
   at the true bar centre; tabs sit left, hamburger right. */
.tabbar.centered { display: grid; grid-template-columns: 1fr auto 1fr; }
.tabbar.centered .tabs-left { justify-self: start; }
.tabbar.centered .tabs-right { justify-self: end; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    color: var(--color-text);
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-left: 0; border-right: 0; border-top: 0;
    font: inherit;
}
.tab:hover { background: var(--color-surface-2); }
.tab.active { border-bottom-color: var(--color-primary); color: var(--color-primary); }
.tab.tab-disabled { color: var(--color-disabled); cursor: default; }
.tab.tab-disabled:hover { background: none; }
.tab-icon { padding: 0 var(--space-3); position: relative; }

/* The unread-notification dot on the menu button: presence, not count (the number lives on the
   Notifications item inside the menu). Positioned over the top-right of the hamburger glyph. */
.notif-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
    box-shadow: 0 0 0 2px var(--color-surface);
}

/* The count pill on the Notifications menu item, pushed to the right edge of the row. */
.notif-count {
    margin-left: auto;
    min-width: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--color-text);
}

/* The Mohlink mark (WebUI.md §3.1). Applied as a mask rather than an <img> so the theme
   owns its colour: the asset is a bare silhouette and --color-logo paints it. Sized from
   height alone — aspect-ratio keeps the mark's own proportions, so `contain` never
   letterboxes it inside a mismatched box. */
.logo-mark {
    display: inline-block;
    height: 22px;
    aspect-ratio: 348 / 453;
    flex: 0 0 auto;
    background-color: var(--color-logo);
    -webkit-mask: url('../img/mohlink-mark.svg') no-repeat center / contain;
    mask: url('../img/mohlink-mark.svg') no-repeat center / contain;
}

.menu { position: relative; display: inline-flex; }
/* Sits between the page and the open dropdown so an outside click is caught (closing the menu)
   rather than reaching the UI beneath it. Inside .menu, so it shares the header's stacking context. */
.menu-backdrop { position: fixed; inset: 0; z-index: 19; }
.menu-dropdown {
    position: absolute;
    right: 0;
    top: var(--tabbar-height);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    box-shadow: var(--elevation-1);
    min-width: 180px;
    padding: var(--space-1);
    z-index: 20;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    color: var(--color-text);
    background: none;
    border: 0;
    border-radius: var(--radius-1);
    cursor: pointer;
    font: inherit;
    text-align: left;
}
.menu-item:hover { background: var(--color-surface-2); }

.content { flex: 1 1 auto; }

/* Responsive: collapse left tab labels to icon-only when narrow (WebUI.md §7). The breakpoint is set
   so the six labels only show when they fit alongside the logo + hamburger, avoiding a band where the
   last label would be clipped. */
@media (max-width: 960px) {
    .tabs-left .tab-label { display: none; }
    .logo-text { display: none; }
}

/* ---- Feature view chrome ---- */
.view { display: flex; flex-direction: column; }
.titlebar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.titlebar h1 { font-size: 18px; margin: 0; }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 420px; }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label { color: var(--color-text-muted); font-size: 13px; }
/* A horizontal value + unit pair (e.g. the sensor offline-threshold number + minutes/hours select). */
.input-row { display: flex; gap: var(--space-2); }
.input-row > input { flex: 1 1 auto; min-width: 0; }
.input-row > select { flex: 0 0 auto; }
.input-row > .btn { flex: 0 0 auto; white-space: nowrap; }
.input {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
}
.input:focus { outline: 2px solid var(--color-primary); outline-offset: -1px; }
.input[readonly] { background: var(--color-surface-2); cursor: default; }
.input[readonly]:focus { outline: none; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font: inherit;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--color-primary); color: var(--color-primary-contrast); border-color: var(--color-primary); }
.saved { margin-left: var(--space-3); color: var(--color-event-clear); }

/* ---- Login (WebUI.md §6) ---- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    padding: var(--space-4);
}
.login-card {
    width: 360px;
    max-width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    box-shadow: var(--elevation-1);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-size: 20px;
    font-weight: 600;
}
.login-logo .logo-mark { height: 32px; }
.login-title { font-size: 16px; margin: 0; text-align: center; color: var(--color-text-muted); font-weight: 500; }
.login-card .field { margin-bottom: var(--space-2); }
.login-submit { justify-content: center; }
.login-error {
    background: color-mix(in srgb, var(--color-danger) 12%, transparent);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius-1);
    padding: var(--space-2) var(--space-3);
    font-size: 13px;
}
.login-prefs {
    display: flex;
    gap: var(--space-3);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-4);
}
.login-prefs label { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; font-size: 12px; color: var(--color-text-muted); }
.login-version { margin-top: var(--space-3); text-align: center; font-size: 11px; color: var(--color-text-muted); }

/* ---- Feature layout: group pane + main view (WebUI.md §8.1) ---- */
.feature { display: flex; align-items: stretch; min-height: calc(100vh - var(--tabbar-height)); }
.feature-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.pad-sm { padding: var(--space-2) var(--space-5); }

.grouppane {
    flex: 0 0 auto;
    width: 240px;
    min-width: 160px;
    max-width: 480px;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface);
    resize: horizontal;
    overflow: auto;
}
.grouppane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--color-border);
}
.grouppane-title { font-weight: 600; font-size: 13px; color: var(--color-text-muted); }
.grouptree { list-style: none; margin: 0; padding: var(--space-1); }
.groupnode {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-2);
    border-radius: var(--radius-1);
    cursor: pointer;
}
.groupnode:hover { background: var(--color-surface-2); }
/* The multi-select row's checkbox: hidden from the eye, not from the keyboard or a screen reader. */
.groupnode-check { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.groupnode:has(.groupnode-check:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 1px; }
/* The selected group must be unmistakable: a solid primary fill (not a subtle tint that can vanish on a
   dim screen) with contrast text, plus a heavy left accent bar. Solid colours avoid any dependence on
   color-mix() rendering. */
.groupnode.selected,
.groupnode.selected:hover {
    background: var(--color-primary);
    box-shadow: inset 4px 0 0 var(--color-primary-contrast);
}
/* Flip the label and the FriendlyNameLabel's own span (and the node icon) to the contrast colour so they
   stay legible on the filled row, regardless of nesting. */
.groupnode.selected .groupnode-label,
.groupnode.selected .fname,
.groupnode.selected > .material-symbols-outlined { font-weight: 700; color: var(--color-primary-contrast); }
.groupnode-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groupnode-edit { opacity: 0; color: var(--color-text-muted); font-size: 18px; }
.groupnode:hover .groupnode-edit { opacity: 1; }

/* ---- Toolbar (WebUI.md §8.2) ---- */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}
.toolbar-spacer { flex: 1 1 auto; }
.filter-box { min-width: 200px; }
.filter-wrap { position: relative; display: inline-flex; }
/* Above a popup's backdrop, so a click in the box keeps the focus and the list. */
.filter-wrap:has(.menu-backdrop) .filter-box { position: relative; z-index: 20; }
/* Dimmed placeholder hint (e.g. "free text filter") that clears as the user types. opacity:1 overrides
   the browser default so the colour is exactly the muted token. */
.input::placeholder { color: var(--color-text-muted); opacity: 1; }
.titlebar .friendly-toggle { margin-left: auto; font-size: 12px; color: var(--color-text-muted); }
.titlebar-extras { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
/* When the friendly toggle is also present it already took margin-left:auto, so don't double it. */
.titlebar .friendly-toggle + .titlebar-extras { margin-left: var(--space-2); }

/* ---- Editable label (WebUI.md §8.4) ---- */
.editable { display: inline-flex; align-items: center; gap: var(--space-1); }
.editable.editing {
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-1);
    padding: 2px var(--space-2);
}
.editable-value.empty { color: var(--color-text-muted); font-style: italic; }
.editable-input { border: 0; outline: none; background: transparent; color: var(--color-text); font: inherit; }
.editable-input.invalid { color: var(--color-danger); }
.editable-icon { cursor: pointer; color: var(--color-text-muted); font-size: 18px; }
.editable-icon:hover { color: var(--color-primary); }
.editable-icon.disabled { opacity: 0.4; cursor: default; }
.editable-error { color: var(--color-danger); font-size: 12px; margin-left: var(--space-2); }

/* A date/time condition is evaluated on the customer's clock, which is not always the reader's
   (WebUI.md §Time zones). Styled as a warning rather than a hint: getting it wrong schedules the
   event for a time the operator did not mean, and nothing downstream looks wrong afterwards. */
.cond-clock-warning {
    color: var(--color-danger);
    font-size: 12px;
    margin: 0 0 var(--space-2) 0;
}

/* ---- List view + grid (WebUI.md §8.3) ---- */
.listview { flex: 1 1 auto; display: flex; flex-direction: column; }
.grid { width: 100%; border-collapse: collapse; }
.grid thead th {
    text-align: left;
    font-size: 12px;
    color: var(--color-text-muted);
    font-weight: 600;
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.grid tbody td { padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--color-border); }
.grid tbody tr:hover { background: var(--color-surface-2); }
.sort-header { display: inline-flex; align-items: center; gap: var(--space-1); background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.sort-header:hover { text-decoration: underline; }
.sort-header .material-symbols-outlined { font-size: 14px; }
.grid-empty { text-align: center; padding: var(--space-6); }
/* A selected group's nested child groups, listed above its users: italic, muted, with a smaller
   group icon, so they read as groups-within-the-group rather than as members. The row is a button
   that opens (selects) that group, like clicking it in the group pane. */
.subgroup-row td { color: var(--color-text-muted); }
.subgroup-link { display: inline-flex; align-items: center; background: none; border: 0; padding: 0; font: inherit; font-style: italic; color: inherit; cursor: pointer; }
.subgroup-link:hover { color: var(--color-primary); }
.subgroup-link:hover em { text-decoration: underline; }
.subgroup-link .subgroup-icon { font-size: 16px; margin-right: var(--space-1); color: var(--color-primary); }
.link-name { background: none; border: 0; padding: 0; font: inherit; color: var(--color-primary); cursor: pointer; }
.link-name:hover { text-decoration: underline; }

/* ---- Pagination bar (WebUI.md §8.3) ---- */
.pagebar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}
.iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    border-radius: var(--radius-1);
    color: var(--color-text);
    cursor: pointer;
    padding: var(--space-1);
}
.iconbtn:hover:not(:disabled) { background: var(--color-surface-2); }
.iconbtn:disabled { color: var(--color-disabled); cursor: default; }
.pagebar-pos { display: inline-flex; align-items: center; gap: var(--space-2); }
.pagebar-input { width: 48px; text-align: center; padding: 2px; border: 1px solid var(--color-border); border-radius: var(--radius-1); background: var(--color-surface); color: var(--color-text); font: inherit; }
.pagebar-size { padding: 2px var(--space-2); }
.pagebar-export { position: relative; margin-left: auto; }
.export-menu { top: auto; bottom: 36px; right: 0; min-width: 120px; }

/* ---- Editor view (WebUI.md §8.5) ---- */
.editorview { flex: 1 1 auto; display: flex; flex-direction: column; }
.editor-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}
.editor-name { flex: 1 1 auto; display: flex; justify-content: center; font-size: 16px; font-weight: 600; }
.editor-bar-spacer { flex: 0 0 36px; }
.editor-body { flex: 1 1 auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); overflow: auto; }
.editor-foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.editor-section { display: flex; flex-direction: column; gap: var(--space-3); }
.editor-section h3 { margin: 0; font-size: 14px; }
/* Boxed variant: separates the Event Editor's Conditions and Actions sections (WebUI.md §4). */
.editor-section-boxed {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    padding: var(--space-4);
}
.section-head { display: flex; align-items: center; justify-content: space-between; }
.section-actions { display: flex; align-items: center; gap: var(--space-2); }

/* ---- Event state pills + commands (WebUI.md §9.2) ---- */
.event-state-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.state-pill { display: inline-block; padding: 2px var(--space-3); border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; }
.state-active { background: var(--color-event-active); }
.state-ack { background: var(--color-event-ack); color: #1b1f24; }
.state-clear { background: var(--color-event-clear); }
.forecast-range { width: auto; }
.state-deactivated { background: var(--color-event-deactivated); }
.state-unknown { background: var(--color-disabled); }
.state-masked { background: var(--color-text-muted); }
.state-suppressed { background: var(--color-warning, #b8860b); }
/* Auto-materialised System Implicit Event (EventController.md §10): muted and outlined so it
   reads as provenance, not as another status bit. */
/* Where an event came from, rather than what state it is in: the System pill (an implicit event) and
   the Auto pill (materialised from an external alarm rule). Outlined, not filled, so an origin never
   competes with a status pill for attention. */
.state-origin { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-text-muted); margin-left: var(--space-2); }

/* Every state of a non-alarming event shares one colour: the row is recorded, not actionable, and a
   green "clear" or amber "acknowledged" would read as something an operator has to answer. The pill
   text still names the state. */
.state-nonalarming { background: var(--color-event-nonalarming); }
.state-pills { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* Live-connection status in the tab bar (LiveUpdates.md). Only rendered when NOT connected, so
   these are the degraded states: amber while (re)connecting, muted-danger once the hub is
   unreachable and the views have fallen back to their slow poll. */
.live-status { display: inline-flex; align-items: center; padding: 0 var(--space-2); }
.live-status .material-symbols-outlined { font-size: 20px; }
.live-status-connecting,
.live-status-reconnecting { color: var(--color-warning, #b8860b); }
.live-status-disconnected { color: var(--color-danger); }
.live-status-reconnecting .material-symbols-outlined { animation: live-spin 1.4s linear infinite; }

@keyframes live-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce)
{
    .live-status-reconnecting .material-symbols-outlined { animation: none; }
}

/* State filter toggles on the event list (WebUI.md §9.2): a row of checkboxes + the Clear all button. */
.filter-toggles { display: inline-flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* ---- Condition lines + Condition String (WebUI.md §4) ---- */
.cond-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.cond-line { border: 1px solid var(--color-border); border-radius: var(--radius-1); }
.cond-line.dragging { opacity: 0.5; }
.cond-line-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2); }
.drag-handle { cursor: grab; color: var(--color-text-muted); }
.cond-line-name { display: flex; align-items: center; gap: var(--space-2); background: none; border: 0; font: inherit; color: var(--color-text); cursor: pointer; text-align: left; flex: 1 1 auto; min-width: 0; }
.cond-panel { padding: var(--space-3); border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: var(--space-3); background: var(--color-surface-2); }
.cond-panel-foot { display: flex; justify-content: flex-end; }
.cond-params { font-family: monospace; }
/* The green "active" pill shown at the end of a condition line whose condition currently evaluates true. */
.cond-active-pill {
    display: inline-block;
    padding: 1px var(--space-3);
    border-radius: 999px;
    background: var(--color-event-clear);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: lowercase;
}
.field-narrow { max-width: 160px; }
.weekday-row { flex-wrap: wrap; }

/* ---- Month-day / 24h time picker fields (WebUI.md §4) ---- */
.picker-wrap { position: relative; }
.input-invalid { outline: 2px solid var(--color-danger); outline-offset: -1px; }
.picker-backdrop { position: fixed; inset: 0; z-index: 40; }
.picker-pop {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 41;
    min-width: 240px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    box-shadow: var(--elevation-1);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.picker-title { font-weight: 600; font-size: 13px; }
.picker-grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.picker-grid6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.picker-cell {
    border: 0;
    background: none;
    border-radius: var(--radius-1);
    padding: var(--space-1);
    font: inherit;
    font-size: 12px;
    color: var(--color-text);
    cursor: pointer;
    text-align: center;
}
.picker-cell:hover { background: var(--color-surface-2); }
.picker-cell-selected { background: var(--color-primary); color: var(--color-primary-contrast); }
.picker-cell-selected:hover { background: var(--color-primary); }
.cond-hint {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-2) var(--space-3);
    background: color-mix(in srgb, var(--color-primary) 8%, transparent);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-1);
    font-size: 13px;
    color: var(--color-text);
}
.cond-hint .material-symbols-outlined { font-size: 18px; color: var(--color-primary); }

.cond-string { display: flex; align-items: flex-start; gap: var(--space-2); }
.cond-input { font-family: monospace; resize: vertical; flex: 1 1 auto; min-width: 0; }
.cond-help { color: var(--color-text-muted); cursor: help; font-size: 20px; padding-top: var(--space-1); }
.cond-help:hover, .cond-help:focus { color: var(--color-primary); }
.cond-preview { font-family: monospace; padding: var(--space-2) var(--space-3); border: 1px dashed var(--color-border); border-radius: var(--radius-1); white-space: pre-wrap; word-break: break-word; min-height: 1.6em; }
.cond-empty { color: var(--color-text-muted); font-style: italic; }
.cond-kw { color: var(--color-primary); font-weight: 600; }
.cond-paren { color: var(--color-text-muted); }
.cond-op { color: var(--color-event-clear); }
.cond-unknown { color: var(--color-danger); text-decoration: underline wavy; }

/* ---- Modal dialog (WebUI.md §8.5) ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: var(--space-4);
}
.modal {
    position: relative;
    width: 460px;
    max-width: 100%;
    max-height: 90vh;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    box-shadow: var(--elevation-1);
}
/* The abandon-changes confirmation layered over a dirty dialog. */
/* A wider dialog for content with a table; still capped at the viewport. */
.modal-wide { width: 760px; }

.modal-abandon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--color-surface) 55%, transparent);
    border-radius: var(--radius-2);
    padding: var(--space-4);
}
.modal-abandon-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    box-shadow: var(--elevation-1);
    padding: var(--space-4);
    max-width: 100%;
}
.modal-bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.modal-title { flex: 1 1 auto; text-align: center; font-size: 15px; margin: 0; }
.modal-commit { color: var(--color-primary); }
.modal-body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-2); }

/* ---- Users feature (WebUI.md §9.5) ---- */
.row-actions { display: flex; gap: var(--space-1); justify-content: flex-end; }
.addrow {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-2);
}
.addrow .input { flex: 1 1 auto; min-width: 0; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }

/* Permission-editing control (WebUI.md §8.1) */
.perm-editor { display: flex; flex-direction: column; gap: var(--space-2); }
.perm-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.perm-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 12px;
}
.perm-revoke { cursor: pointer; font-size: 16px; color: var(--color-text-muted); }
.perm-revoke:hover { color: var(--color-danger); }
.perm-add { display: flex; gap: var(--space-2); align-items: center; }
.perm-add .input { flex: 1 1 auto; }
.perm-label { cursor: help; }

/* ---- Wizard (WebUI.md) ---- */
.modal.wizard { width: 560px; }
.wizard-steps {
    list-style: none;
    margin: 0;
    padding: var(--space-3) var(--space-4);
    display: flex;
    gap: var(--space-2);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}
.wizard-step-chip { flex: 0 0 auto; }
.wizard-step-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    background: none;
    border: none;
    padding: var(--space-1) var(--space-2);
    color: var(--color-text-muted);
    cursor: default;
    font-size: 13px;
}
.wizard-step-chip.done .wizard-step-btn { cursor: pointer; }
.wizard-step-chip.active .wizard-step-btn { color: var(--color-text); font-weight: 600; }
.wizard-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    font-size: 12px;
}
.wizard-step-chip.active .wizard-step-num { border-color: var(--color-primary); color: var(--color-primary); }
.wizard-step-chip.done .wizard-step-num {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-primary-contrast);
}
.wizard-step-num .material-symbols-outlined { font-size: 16px; }
.wizard-body { min-height: 180px; }
.wizard-error { margin: 0 var(--space-4); }
.wizard-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border);
}
.wizard-actions-spacer { flex: 1 1 auto; }

/* Service-package presets (New-Tenant wizard) */
.preset-row { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }
.preset-chip {
    padding: 2px var(--space-3);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    color: var(--color-text);
}
.preset-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ---- Editable combo box (WebUI.md) ---- */
.combobox { position: relative; display: flex; align-items: stretch; }
.combobox-input { flex: 1 1 auto; min-width: 0; padding-right: 32px; }
.combobox-toggle { position: absolute; right: 0; top: 0; bottom: 0; }
.combobox-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    list-style: none;
    margin: 2px 0 0;
    padding: var(--space-1);
    max-height: 200px;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
    box-shadow: var(--elevation-1);
}
.combobox-option {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: var(--space-2) var(--space-3);
    color: var(--color-text);
    cursor: pointer;
    border-radius: var(--radius-1);
    font-size: 13px;
}
.combobox-option:hover { background: var(--color-surface-2); }

/* Sensor configuration editor table (Architecture.md §Event actions): inputs fill their
   cells; the value cell also carries the row's error text. */
.sensor-config-grid { table-layout: fixed; }
.sensor-config-grid td { vertical-align: top; }
.sensor-config-grid .input, .sensor-config-grid .combobox { width: 100%; min-width: 0; }
.sensor-config-grid .editable-error { margin-left: 0; }
/* A plain cell, not the flex .row-actions: the draft row has no button, and an empty flex cell collapses
   and breaks the row's borders. */
.sensor-config-actions { text-align: right; white-space: nowrap; width: 1%; }

/* Dual-list-box member editor (WebUI.md §8.1) */
.duallist { display: flex; align-items: stretch; gap: var(--space-3); }
.duallist-col { flex: 1 1 0; display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.duallist-col label { font-size: 12px; color: var(--color-text-muted); }
.duallist-box {
    min-height: 140px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    padding: var(--space-1);
}
.duallist-actions { display: flex; flex-direction: column; justify-content: center; gap: var(--space-2); }

/* ---- Sensors + simulators (WebUI.md §9.1) ---- */
.telemetry-box {
    margin: 0;
    padding: var(--space-3);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
    font-family: monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 240px;
    overflow: auto;
}
.sparkline { display: inline-block; vertical-align: middle; }
.cond-line-head .sparkline { margin-left: auto; flex: 0 0 auto; }
.sim-preview { display: flex; align-items: center; gap: var(--space-2); }
.sim-enabled { align-self: end; }
.sim-badge { font-size: 18px; color: var(--color-text-muted); margin-right: var(--space-1); }

.seg { display: inline-flex; gap: var(--space-4); }

.uvar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.uvar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
}
.uvar-name { flex: 1 1 auto; min-width: 0; }
.uvar-control { display: inline-flex; align-items: center; gap: var(--space-2); }
.uvar-num { width: 120px; }

/* ---- Path browser (WebUI.md §8.6) ---- */
.input-with-button { display: flex; align-items: center; gap: var(--space-1); }
.input-with-button .input { flex: 1 1 auto; min-width: 0; }
.pathtree {
    list-style: none;
    margin: 0;
    padding: var(--space-1);
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-1);
}
.pathnode { display: flex; align-items: center; gap: var(--space-1); padding: 1px 0; }
.pathnode-toggle { cursor: pointer; color: var(--color-text-muted); font-size: 18px; }
.pathnode-leaf { color: var(--color-text-muted); width: 18px; text-align: center; font-size: 10px; }
.pathnode-name {
    background: none;
    border: 0;
    padding: 2px var(--space-2);
    border-radius: var(--radius-1);
    color: var(--color-text);
    cursor: pointer;
    font: inherit;
    text-align: left;
    white-space: nowrap;
}
.pathnode-name:hover { background: color-mix(in srgb, var(--color-primary) 16%, transparent); color: var(--color-primary); }
/* A non-pickable branch label (leaves-only mode): muted, expands on click, no pick highlight. */
.pathnode-branch { color: var(--color-text-muted); }
.pathnode-branch:hover { background: var(--color-surface-2); color: var(--color-text); }

/* Blazor's default error toast. */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #ffe9a8;
    color: #3a2f00;
    padding: var(--space-3) var(--space-4);
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 8px; }

/* Access Control (§9.6) */
.mono { font-family: var(--font-mono, ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace); font-size: 13px; }
.acl-kind { font-size: 18px; vertical-align: middle; margin-right: var(--space-2); color: var(--color-text-muted); }
.acl-effect {
    display: inline-block;
    padding: 2px var(--space-3);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    border: none;
}
button.acl-effect { cursor: pointer; }
.acl-allow { background: var(--color-event-clear); }
.acl-deny { background: var(--color-event-active); }
.acl-field-row { display: flex; gap: var(--space-2); }
.acl-field-row .input { flex: 1 1 auto; min-width: 0; }
.grid-clickable { cursor: pointer; }
/* The collated access cell: "Read, Write, Create" followed by the allow/deny pill. */
.acl-access { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.acl-perms { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
.acl-perms label { display: flex; align-items: center; gap: var(--space-1); font-size: 13px; }
.acl-delete {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-3);
    padding-top: var(--space-3);
}
.acl-delete .btn { color: var(--color-danger); border-color: var(--color-danger); }

/* Log / history views (§9.3, §9.4, §9.7) */
.timerange { display: flex; gap: var(--space-3); align-items: flex-end; }
.timerange-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.logbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.richlist { list-style: none; margin: 0; padding: 0; }
.richrow {
    padding: var(--space-3) var(--space-5);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.richrow-main { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.richrow-title { font-weight: 600; }
.richrow-badge {
    display: inline-block;
    padding: 1px var(--space-2);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--color-disabled);
}
.richrow-badge.badge-on { background: var(--color-event-active); }
.richrow-badge.badge-off { background: var(--color-event-clear); }
.richrow-badge.badge-ack { background: var(--color-event-ack); color: #1b1f24; }
.richrow-badge.badge-masked { background: var(--color-text-muted); }
.richrow-badge.badge-suppressed { background: var(--color-warning, #b8860b); }
/* Tenant label on a collated cross-tenant row (RestApi.md). */
.richrow-badge.badge-tenant { background: var(--color-accent, #4a6); }
.richrow-sub { font-size: 12px; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.richrow-sep { opacity: 0.5; }
.richrow-comment { font-style: italic; }
.richrow-clickable { cursor: pointer; }
.richrow-clickable:hover { background: var(--color-surface-2); }

/* Notifications + External Groups (§9.8) */
.richrow-unread { background: var(--color-surface-alt, rgba(127,127,127,0.08)); }
.richrow-unread .richrow-title { font-weight: 700; }
.notif-icon { font-size: 20px; color: var(--color-text-muted); }
.eg-page { display: flex; flex-direction: column; gap: var(--space-6); max-width: 900px; }
.eg-section { display: flex; flex-direction: column; gap: var(--space-3); }
.eg-section h2 { font-size: 15px; margin: 0; }

/* A distinct, bordered card for each Tenant Settings area (e.g. Sensor Condition Monitoring,
   External Groups) so the page reads as clearly separated sections. */
.settings-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2, 6px);
    background: var(--color-surface-alt, rgba(127,127,127,0.04));
    padding: var(--space-5);
}
.settings-card > h2 {
    font-size: 16px;
    margin: 0;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}
/* A clickable collapse toggle header: chevron + title, with a right-aligned summary. Self-styled so it
   works both as a settings-card heading and standalone (e.g. inside the permission editor dialog). */
.collapse-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    user-select: none;
    font-size: 16px;
    margin: 0;
}
.collapse-header .collapse-summary {
    margin-left: auto;
    font-size: 13px;
    font-weight: normal;
}
/* Collapsed, the heading's underline would run along the bottom of the card with nothing beneath it.
   Driven off aria-expanded so the state is described once, in the markup, rather than twice. */
.settings-card > h2.collapse-header[aria-expanded="false"] {
    padding-bottom: 0;
    border-bottom: none;
}
.collapse-header:hover .collapse-title { text-decoration: underline; }
.collapse-header:focus-visible { outline: 2px solid var(--color-accent, #4b8ddb); outline-offset: 2px; }
/* Flows within a card (the External Groups redeem / invitations / linked lists) are separated by a
   light rule so each is identifiable without competing with the card header. */
.settings-subsection { display: flex; flex-direction: column; gap: var(--space-3); }
.settings-subsection + .settings-subsection { padding-top: var(--space-4); border-top: 1px solid var(--color-border); }
.settings-subsection h3 { font-size: 14px; margin: 0; }
/* On-call settings: a label + control + unit laid out on one line, the control kept narrow. */
.oncall-field { display: flex; align-items: center; gap: var(--space-2); }
.oncall-field > label { min-width: 200px; }
.oncall-field > .input { max-width: 160px; }

/* ---- On-call schedule designer ---- */
.oncall-layout { display: flex; gap: var(--space-3); padding: var(--space-3); align-items: flex-start; }
.oncall-assignees { width: 200px; flex: none; }
.oncall-assignees h3 { margin: 0 0 var(--space-2); font-size: 14px; }
.oncall-assignee-list { display: flex; flex-direction: column; gap: var(--space-1); }
.oncall-assignee {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius-1);
    background: var(--color-surface); user-select: none;
}
.oncall-assignee.draggable { cursor: grab; user-select: none; }
.oncall-assignee.is-group { font-style: italic; }
/* An externally linked contractor group: its members live in another tenant, so it carries the same
   warning mark the Users view puts on a cross-tenant child. */
.oncall-assignee.is-external .material-symbols-outlined { color: var(--color-event-ack); }
.oncall-assign-hint { font-size: 13px; color: var(--color-primary); margin: 0 0 var(--space-2); }
.oncall-main { flex: 1 1 auto; min-width: 0; }
.oncall-toolbar { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); flex-wrap: wrap; }
.oncall-toolbar-field { display: flex; align-items: center; gap: var(--space-1); }
.oncall-toolbar-field .input { max-width: 100px; }
.oncall-spacer { flex: 1 1 auto; }
.oncall-dirty { color: var(--color-warning, #b8860b); font-size: 13px; }
.oncall-schedule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.oncall-schedule-list li { display: flex; align-items: center; justify-content: space-between; }
.oncall-schedule-pick { background: none; border: none; color: var(--color-primary); cursor: pointer; padding: var(--space-1) 0; }

.weekpicker { position: relative; display: inline-flex; align-items: center; gap: var(--space-1); }
.weekpicker-heading { font-weight: 600; font-size: 16px; background: none; border: none; cursor: pointer; padding: var(--space-1) var(--space-2); color: var(--color-text); }
.weekpicker-yearbar { color: var(--color-text); }
.weekpicker-pop {
    position: absolute; top: 100%; left: 0; z-index: 20; margin-top: var(--space-1);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-2);
    padding: var(--space-3); box-shadow: 0 6px 24px rgba(0,0,0,.18); width: 360px;
}
.weekpicker-yearbar { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-bottom: var(--space-2); font-weight: 600; }
.weekpicker-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.weekpicker-monthname { font-size: 12px; color: var(--color-text-muted, #888); margin-bottom: 2px; }
.weekpicker-weeks { display: flex; flex-wrap: wrap; gap: 2px; }
.weekpicker-week { min-width: 24px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text); border-radius: var(--radius-1); cursor: pointer; font-size: 12px; }
.weekpicker-week.selected { background: var(--color-primary); color: #fff; }

/* Paint, move and resize are pointer drags across the grid, which would otherwise select the day
   headings and the period labels they sweep over. */
.oncal { border: 1px solid var(--color-border); border-radius: var(--radius-2); overflow: hidden; display: flex; flex-direction: column; user-select: none; }
.oncal-head { display: flex; border-bottom: 1px solid var(--color-border); flex: none; }
.oncal-dayhead { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; padding: var(--space-1); border-left: 1px solid var(--color-border); }
.oncal-dayname { font-weight: 600; font-size: 13px; }
.oncal-daydate { font-size: 12px; }
/* The body fills the remaining viewport height so the full 24 h is visible without scrolling; the
   24 hour rows and the period percentages all scale to whatever height this resolves to. */
.oncal-body { display: flex; height: calc(100vh - 270px); min-height: 300px; }
.oncal-gutter { width: 48px; flex: none; display: flex; flex-direction: column; }
.oncal-hour { flex: 1 1 0; position: relative; border-bottom: 1px solid var(--color-border); }
.oncal-hour span { position: absolute; top: -7px; right: 4px; font-size: 11px; color: var(--color-text-muted, #888); }
.oncal-grid { position: relative; flex: 1 1 0; touch-action: none; }
.oncal-gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--color-border); opacity: .5; pointer-events: none; }
.oncal-colsep { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--color-border); pointer-events: none; }
/* While dragging, periods ignore the pointer so the grid (not a period) receives pointermove — this
   is what lets a paint/move/resize follow the cursor across day columns (the date line). */
.oncal-grid.dragging .oncal-period { pointer-events: none; }
.oncal-period {
    position: absolute; box-sizing: border-box;
    background: var(--color-primary); color: #fff; border-radius: var(--radius-1);
    border: 1px solid var(--color-surface); font-size: 11px; overflow: hidden; cursor: move; padding: 1px 3px;
}
/* A period that continues past midnight squares off the shared edge so it reads as one span. */
.oncal-period.no-top { border-top-left-radius: 0; border-top-right-radius: 0; border-top-style: dashed; }
.oncal-period.no-bottom { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-style: dashed; }
/* A nested group on call reads as a light green block, so a shift covered by another team
   (a contractor, say) stands apart at a glance from one covered by a named person. The block is
   light, so its text and controls invert to dark. */
.oncal-period.is-group { background: #c8e6c9; color: #14351a; font-style: italic; }
.oncal-period.is-group .oncal-period-label .muted { color: rgba(0, 0, 0, .6); }
.oncal-period.is-group .oncal-del { color: #14351a; }
.oncal-period.oncal-paint { background: rgba(20,102,196,.45); cursor: default; }
.oncal-period-label { display: flex; flex-direction: column; line-height: 1.15; pointer-events: none; }
.oncal-period-label .muted { color: rgba(255,255,255,.8); }
.oncal-handle { position: absolute; left: 0; right: 0; height: 6px; cursor: ns-resize; }
.oncal-handle.top { top: 0; }
.oncal-handle.bottom { bottom: 0; }
.oncal-del { position: absolute; top: 0; right: 0; background: none; border: none; color: #fff; cursor: pointer; padding: 0; opacity: .8; }
.oncal-del .material-symbols-outlined { font-size: 14px; }
.eg-preview {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2, 6px);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

/* ---- Alarms Dashboard (WebUI.md §9.2a) ---- */
/* A uniform, hole-free card field: the grid has no gap of its own — every cell is flush with its
   neighbours — and the visual spacing between cards comes from the cell padding instead. Cells
   are placed at explicit row/column coordinates computed by DashboardLayout (serpentine packing);
   the row height is set inline by the page, which is its single source of truth (the same value
   sizes the outline paths). */
.dashboard {
    padding: var(--space-4);
    --dash-outline-w: 3px;
    --dash-outline-inset: calc(var(--dash-outline-w) / 2);
    --dash-outline-radius: calc(var(--radius-2) + var(--space-2) - var(--dash-outline-inset));
}
.dashboard-grid { position: relative; display: grid; gap: 0; }
.dash-cell { position: relative; padding: var(--space-2); min-width: 0; }

/* Cluster outlines: ONE closed SVG path per multi-event group, built by DashboardOutlinePath from
   the group's traced cell boundary — a single stroke has no joints, so the outline cannot develop
   seams at fractional device pixel ratios (the per-cell border overlays it replaces did). The
   stroke centreline runs a full line width inside the cell boundary (outer stroke edge inset half
   a width, so two adjacent groups keep a full line-width gap); convex corners fillet concentric
   with the card's own corner (--radius-2 + --space-2 − w) and concave notch corners with the
   wrapping radius (--radius-2 + --space-2 + w) that keeps a constant line-width gap around the
   neighbouring group's convex corner. The path coordinates come from the page (measured grid
   width / column count × the inline row height); the stroke width and colour stay CSS-owned here,
   and the geometry the page uses is read from these same custom properties via the resize shim. */
.dash-boundaries { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* The path is filled with the group tray colour: the cards paint on top with their own opaque
   --color-surface, so only the gutters/margins around them inside the group show the tint, which
   reads as a filled tray behind the group (WebUI.md §9.2a). */
.dash-boundaries path { fill: var(--color-dash-group-bg); stroke: var(--color-dash-outline); stroke-width: var(--dash-outline-w); }

/* The group's header label, hosted at the leftmost cell of its topmost row: legend-style, centred
   ON the (inset) top outline line, backed by the page background so it visually cuts the line —
   in dark mode too. It may stretch across the group's topmost-row cells (--dash-label-span, set
   inline by the page) before it ellipsizes, and never captures clicks meant for the cards. */
.dash-group-label {
    position: absolute;
    top: calc(var(--dash-outline-inset) + var(--dash-outline-w) / 2);
    left: calc(var(--dash-outline-inset) + var(--dash-outline-radius));
    transform: translateY(-50%);
    max-width: calc(var(--dash-label-span, 1) * 100% - 2 * (var(--dash-outline-inset) + var(--dash-outline-radius)));
    padding: 0 var(--space-2);
    background: var(--color-bg);
    color: var(--color-text-muted);
    font-size: 11px; line-height: 1.3; font-weight: 600; letter-spacing: 0.02em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    pointer-events: none;
    z-index: 1;
}

/* The card: its border colour carries the live event state, the same token mapping as the Events
   list's pills (active red / acked amber / returned blue / clear green / unknown grey). The border
   is a touch thick so the status colour reads at a glance across the grid. */
.dash-card {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; gap: var(--space-1);
    padding: var(--space-3);
    background: var(--color-surface);
    border: 3px solid var(--color-disabled);
    border-radius: var(--radius-2);
    color: var(--color-text); font: inherit; text-align: left; text-decoration: none;
    cursor: pointer; overflow: hidden;
    transition: box-shadow .15s ease;
    /* --dash-flash is the value-update flash tint: halfway between the card's status border colour
       and its resting surface (set per state below). The default covers the no-state fallback. */
    --dash-flash: color-mix(in srgb, var(--color-disabled) 50%, var(--color-surface));
}
/* Hover lifts the shadow only. A transform here shifted the card under the pointer, which reads
   as the grid twitching when you sweep across it. */
.dash-card:hover { box-shadow: var(--elevation-1); }
.dash-card.dash-active { border-color: var(--color-event-active); --dash-flash: color-mix(in srgb, var(--color-event-active) 50%, var(--color-surface)); }
.dash-card.dash-ack { border-color: var(--color-event-ack); --dash-flash: color-mix(in srgb, var(--color-event-ack) 50%, var(--color-surface)); }
.dash-card.dash-deactivated { border-color: var(--color-event-deactivated); --dash-flash: color-mix(in srgb, var(--color-event-deactivated) 50%, var(--color-surface)); }
.dash-card.dash-clear { border-color: var(--color-event-clear); --dash-flash: color-mix(in srgb, var(--color-event-clear) 50%, var(--color-surface)); }
.dash-card.dash-unknown { border-color: var(--color-disabled); --dash-flash: color-mix(in srgb, var(--color-disabled) 50%, var(--color-surface)); }

/* Value-update flash: a live value change washes the card in its status tint (--dash-flash) and
   fades back to the resting surface over the fade window. Two identical animations exist so the
   component can restart the run by SWAPPING the class (a→b→a) — re-adding an identical animation
   name would not restart it. The 'to' frame equals the resting surface, so there is no snap when
   the one-shot run ends. */
@keyframes dash-flash-a { from { background: var(--dash-flash); } to { background: var(--color-surface); } }
@keyframes dash-flash-b { from { background: var(--dash-flash); } to { background: var(--color-surface); } }
.dash-card.dash-flash-a { animation: dash-flash-a 750ms ease-out; }
.dash-card.dash-flash-b { animation: dash-flash-b 750ms ease-out; }

/* An unacknowledged active alarm keeps pulsing its status tint once a second until it is acknowledged
   or silenced — the update flash's wash, looped. It shares the flash's background channel, so the
   component only ever gives a card one or the other (dash-pulse while it should pulse, and the flash
   class dropped for it). Under reduced motion the tint holds steady so the alarm stays highlighted. */
@keyframes dash-pulse { from { background: var(--dash-flash); } to { background: var(--color-surface); } }
.dash-card.dash-pulse { animation: dash-pulse 1s ease-out infinite; }

@media (prefers-reduced-motion: reduce) {
    .dash-card.dash-flash-a, .dash-card.dash-flash-b { animation: none; }
    .dash-card.dash-pulse { animation: none; background: var(--dash-flash); }
}

.dash-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-sub { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-conds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; overflow: hidden; font-size: 12px; }
.dash-cond { display: flex; justify-content: space-between; gap: var(--space-2); white-space: nowrap; }
.dash-cond-src { overflow: hidden; text-overflow: ellipsis; color: var(--color-text-muted); min-width: 0; }
/* The source's current value: right-aligned next to the threshold, emphasized against it. */
.dash-cond-now { flex: none; margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.dash-cond-val { flex: none; font-variant-numeric: tabular-nums; color: var(--color-text-muted); }

/* ---- Graph tab (WebUI.md §9.4b) ---- */
/* One chart per card. The SVG carries its own width/height attributes (the same string goes into a
   PDF), so the page scales it to the card and lets the height follow the viewBox. */
.graph-card { position: relative; margin-bottom: var(--space-4); }
.graph-card svg { display: block; width: 100%; height: auto; border-radius: var(--radius-1); }
/* The hover cursor: a 1 px line positioned in CSS pixels over the chart. */
.graph-cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--color-text-muted); pointer-events: none; }
.graph-readout { min-height: 1.4em; font-size: 12px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.graph-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.graph-toolbar .input { width: auto; }
.graph-draft { margin-top: var(--space-3); }

/* ---- Map tab (WebUI.md §9.1a) ---- */
.map-feature { height: calc(100vh - var(--tabbar-height)); }
.map-canvas { flex: 1 1 0; min-height: 360px; overflow: hidden; background: var(--color-surface-2); }
.map-note { margin: var(--space-1) var(--space-3); font-size: 12px; min-height: 1.4em; }
.map-stats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); padding: var(--space-1) var(--space-3); font-size: 13px; background: var(--color-surface); border-top: 1px solid var(--color-border); }
.map-stats-item { display: inline-flex; align-items: center; gap: var(--space-1); }
.map-stats .map-dot { width: 10px; height: 10px; margin: 0; border: 0; box-shadow: none; }
.map-pane-tools { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--color-border); }
.map-pane-tools .map-note { margin: 0 0 var(--space-2); }
.map-filters h3 { margin: 0 0 var(--space-2); font-size: 13px; }
.map-filters .check { display: block; margin-bottom: var(--space-1); }
/* The marker: MapLibre positions .map-marker with its own transform, so the dot that is coloured and
   that pops is a child. Colours are the dashboard's card tokens. */
.map-marker { width: 18px; height: 18px; cursor: pointer; }
.map-dot { width: 14px; height: 14px; margin: 2px; border-radius: 50%; border: 2px solid var(--color-surface); background: var(--color-disabled); box-shadow: var(--elevation-1); transform-origin: center; }
.map-dot.map-state-active { background: var(--color-event-active); }
.map-dot.map-state-ack { background: var(--color-event-ack); }
.map-dot.map-state-deactivated { background: var(--color-event-deactivated); }
.map-dot.map-state-clear { background: var(--color-event-clear); }
.map-dot.map-state-forecast { background: var(--color-event-forecast); }
.map-dot.map-state-unknown { background: var(--color-disabled); }
.map-dot.map-dimmed { opacity: 0.25; }
.map-search-pop {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 20;
    width: 340px;
    max-width: calc(100vw - 2 * var(--space-4));
    max-height: 50vh;
    overflow-y: auto;
    margin: var(--space-1) 0 0;
    padding: var(--space-1);
    list-style: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-2);
    box-shadow: var(--elevation-1);
}
.map-search-pop .map-dot { flex: none; }
.map-search-pop .menu-item:focus { background: var(--color-surface-2); }
.map-search-pop .muted { margin-left: auto; font-size: 12px; }
.map-search-empty { padding: var(--space-2) var(--space-3); }
/* The pop on a new value: two identical animations, swapped so a burst restarts it (as the dashboard flashes). */
@keyframes map-pop-a { 0% { transform: scale(1); } 30% { transform: scale(2.2); } 100% { transform: scale(1); } }
@keyframes map-pop-b { 0% { transform: scale(1); } 30% { transform: scale(2.2); } 100% { transform: scale(1); } }
.map-dot.map-pop-a { animation: map-pop-a 700ms ease-out; }
.map-dot.map-pop-b { animation: map-pop-b 700ms ease-out; }
@media (prefers-reduced-motion: reduce) { .map-dot.map-pop-a, .map-dot.map-pop-b { animation: none; } }
.map-popup { font-family: var(--font-sans); font-size: 13px; color: #1b1f24; display: flex; flex-direction: column; gap: 2px; }
.map-popup .muted { color: #5b6470; }
/* MapLibre's credit box is white in both themes; its plain text would inherit a dark theme's light colour. */
.maplibregl-ctrl-attrib { color: #1b1f24; }
/* The search list inside the mobile Filter dialog: in the flow, not a popup. */
.modal .map-search-pop { position: static; width: auto; max-width: none; box-shadow: none; }
/* Show nearest on the mobile map (MobileClient.md). The ring has the dot's colour and outlines of its own on both
   sides; the gap leaves the dot's outline visible. The chevron's point is its origin (mohlink-map-nearest.js). */
.map-nearest-mark.map-state-active { color: var(--color-event-active); }
.map-nearest-mark.map-state-ack { color: var(--color-event-ack); }
.map-nearest-mark.map-state-deactivated { color: var(--color-event-deactivated); }
.map-nearest-mark.map-state-clear { color: var(--color-event-clear); }
.map-nearest-mark.map-state-forecast { color: var(--color-event-forecast); }
.map-nearest-mark.map-state-unknown { color: var(--color-disabled); }
.map-nearest-ring { position: absolute; left: -8px; top: -8px; width: 34px; height: 34px; box-sizing: border-box; border: 4px solid currentColor; border-radius: 50%; box-shadow: 0 0 0 1px var(--color-surface), inset 0 0 0 1px var(--color-surface); pointer-events: none; }
.map-nearest-chevron { position: absolute; left: 0; top: 0; z-index: 1; transform-origin: 50% 0; pointer-events: none; }
.map-nearest-chevron svg { display: block; width: 100%; height: 100%; fill: currentColor; stroke: var(--color-surface); stroke-width: 1; }
.map-nearest-text { position: absolute; left: 0; top: 0; z-index: 1; padding: 1px 6px; border-radius: var(--radius-1); background: rgba(255, 255, 255, 0.75); color: #1b1f24; font-family: var(--font-sans); font-size: 21px; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
/* The device's position: blue like a phone's own maps, so it cannot read as a sensor state. */
.map-you { width: 14px; height: 14px; border-radius: 50%; background: #2a7de1; border: 2px solid #fff; box-shadow: 0 0 0 5px rgba(42, 125, 225, 0.25); pointer-events: none; }
.map-popup-lines { margin: 4px 0 0; padding: 0 0 0 14px; font-variant-numeric: tabular-nums; }
.map-popup-link { padding: 2px 0; border: none; background: none; color: #1466c4; font: inherit; text-align: left; text-decoration: underline; cursor: pointer; }
/* The unplaced-sensor list: rows are dragged onto the map (Sensors.Manage). */
.map-unplaced { list-style: none; margin: 0; padding: 0; }
.map-unplaced li { display: flex; align-items: center; gap: var(--space-1); padding: var(--space-1) 0; cursor: grab; user-select: none; }
.map-unplaced li:active { cursor: grabbing; }
.map-unplaced .material-symbols-outlined { color: var(--color-text-muted); font-size: 18px; }
