/* Inter, self-hosted (SIL OFL 1.1 — fonts/inter/LICENSE.txt). Both hosts load it from this RCL, so the
   console renders the same type offline and inside the MAUI WebView; there is no CDN fallback by design.
   One variable file per style covers every weight, so no weight is ever faux-bolded. */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter/InterVariable.woff2") format("woff2");
}

@font-face {
    font-family: "Inter";
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter/InterVariable-Italic.woff2") format("woff2");
}

/* Infence app-shell chrome (global, not component-scoped).
   These style elements that live inside MudBlazor component slots/internals, where Blazor's
   ::deep scoping can't reach from MainLayout — so they are plain global rules loaded by both hosts. */

/* ===== Design tokens =========================================================================
   Single source of truth for density, radius, depth and motion. Component stylesheets reference these
   instead of repeating literals.

   DIRECTION — refined SaaS (2026-10-02 UI foundation spec):
     · Three surface levels: the canvas (sidebar ground), the sheet (the page), cards/panels on the
       sheet. Separation comes from tone plus a soft --elev-card and a near-invisible --edge, not from
       a hard border on every box.
     · Comfortable density: 14px type, 40px controls, ~40px table rows.
     · Color means STATE or SECTION. The accent is interaction and section identity; success/warning/
       error are status. A zero count is never tinted.
     · High contrast trades depth for edges: no shadow, solid hairline (see its block below).

   Status colors are deliberately NOT tokenized here — use var(--mud-palette-success/warning/error)
   directly so status dots, chips and stripes follow whichever theme (including High contrast) is
   active. A literal hex here would break that silently. */
:root {
    /* Density. Inputs get their height from MudBlazor itself (Margin.Dense + Variant.Outlined renders
       ~39px at 14px; 38.8 measured) — no rule reads --control-h for them. --control-h (40px) is the
       height buttons are lifted to, so a button beside an input is ~1px taller. The compact height is
       for the 56px page-header bar only.
       --gap is the gap between panels in a page grid (Cockpit). */
    --control-h: 40px;
    --control-h-compact: 36px;
    --row-pad-y: 10px;
    --row-pad-x: 14px;
    --pad-tight: 10px;
    --pad-base: 16px;
    --pad-roomy: 24px;
    --gap: 16px;
    --shell-bar-h: 56px;   /* page header (cockpit bar) height inside the sheet */

    /* Radius steps: controls → buttons → panels → the shell sheet. */
    --radius-xs: 4px;   /* dots, stripes, micro-chips */
    --radius-sm: 6px;   /* inputs, small chips */
    --radius-md: 8px;   /* buttons, nav items, badges (LayoutProperties.DefaultBorderRadius) */
    --radius-lg: 12px;  /* panels, cards, tables, the map */
    --radius-xl: 16px;  /* the shell sheet, floating overlays over the map */

    /* Surfaces (light). The sheet has no MudBlazor palette slot, so it lives here; canvas and card are
       Palette Background / Surface. */
    --surface-sheet: #FAFBFD;
    --edge: #E8EAF0;
    --elev-card: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px -8px rgba(16, 24, 40, .10);

    /* Floating things keep stronger shadows than resting cards. */
    --shadow-float: 0 4px 16px rgba(15, 20, 29, .08);   /* panels over the map, overlay drawer */
    --shadow-menu: 0 8px 28px rgba(15, 20, 29, .16);    /* dropdowns, dialogs */

    /* Accent tint strengths, applied as rgba(var(--mud-palette-<color>-rgb), var(--tint-*)). */
    --tint-strong: .14;  /* icon badges, active nav pill */
    --tint-soft: .06;    /* hover */

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);              /* entrances (fade/slide-in) */
    --ease-standard: cubic-bezier(0.25, 0.8, 0.25, 1);      /* chrome hover */
    --ease-material: cubic-bezier(0.4, 0, 0.2, 1);          /* focus glows, icon micro-motion */

    --duration-fast: .12s;
    --duration-base: .2s;
    --duration-slow: .32s;

    /* Frosted-glass overlay surface. Scope: content floating over the MAP only (fleet panel, map
       filter chips, map toolbars). Page surfaces use the opaque --mud-palette-surface. */
    --glass-bg: rgba(255, 255, 255, 0.82);
    --glass-bg-strong: rgba(255, 255, 255, 0.93);
    --glass-border: var(--mud-palette-lines-default);
    --glass-blur: 14px;
}

/* MudBlazor's MudThemeProvider does not add a "mud-theme-dark" class anywhere in the DOM in the
   version this project uses (it only injects palette variables into a <style> tag) — so every
   dark-mode override in this file must key off the attribute theme-interop.js stamps onto <html>.
   Rules written against .mud-theme-dark never fire. */
:root[data-infence-mode="dark"] {
    --surface-sheet: #161628;
    --edge: rgba(255, 255, 255, .06);
    --elev-card: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -12px rgba(0, 0, 0, .55);

    --shadow-float: 0 4px 16px rgba(0, 0, 0, .34);
    --shadow-menu: 0 8px 28px rgba(0, 0, 0, .48);

    --glass-bg: rgba(26, 26, 46, 0.82);
    --glass-bg-strong: rgba(26, 26, 46, 0.94);
}

/* High contrast (either mode): contrast is the point, so surfaces separate by a solid hairline, never
   by a shadow or a translucent edge, and the sheet is the plain surface. Declared after the dark block
   so it wins at equal specificity. */
:root[data-infence-theme="contrast"] {
    --surface-sheet: var(--mud-palette-surface);
    --edge: var(--mud-palette-lines-default);
    --elev-card: none;
}

/* Tabular figures everywhere digits line up: tables, stat readouts, coordinates, timestamps.
   Proportional digits made column alignment drift by a pixel per row on the health/report grids. */
.mud-table-cell,
.mud-table-cell *,
.stat-readout,
.stat-readout * {
    font-variant-numeric: tabular-nums;
}

/* Respect the user's motion preference: collapse animation/transition duration instead of
   disabling transforms outright (keeps end-state layout correct, just skips the tween). */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Cockpit shell: the drawer owns the chrome ---------------------------------------------- */
/* There is no app bar. Brand, workspace and appearance live in the drawer, so the content column
   starts at the top of the viewport and every page gets that band back. */
/* The content column is a fixed-height flex column, and `.infence-page` inside it is the single
   scroll region. This is what makes tables auto-size: a `surface-panel--fill` panel is
   `flex: 1; min-height: 0` inside a parent whose height is definite, so it takes exactly the space
   left over and re-measures on every window resize. Nothing subtracts pixel constants.
   (It previously did: --cockpit-h + --grid-pager-h + padding, hand-measured, and it drifted the
   moment a page put a taller control in the cockpit bar's Actions slot.)

   One rule owns the padding, too. It used to be split between `.mud-main-content { padding-top: 0 }`
   and `.infence-main { padding: … }`; the two-class selector won, top padding was really 0, the
   cockpit bar's negative top margin escaped by margin-collapsing, and the whole shell sat 14px too
   high — the brand bar stopped lining up and the drawer ended short of the bottom.
   The shell is three levels: the canvas (MudLayout background, where the sidebar sits), the sheet
   (.infence-sheet — the page's raised surface), and cards on the sheet. */
.infence-shell {
    background-color: var(--mud-palette-background);
}

.infence-shell .mud-main-content {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px 8px 8px 0;
}

.infence-sheet {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-sheet);
    border: 1px solid var(--edge);
    border-radius: var(--radius-xl);
    box-shadow: var(--elev-card);
    overflow: hidden;
}

.infence-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: var(--pad-base);
    overflow: auto;
}

/* Full-screen pages (the Live map, the Devices grid, Fuel and Device health): the page fills the whole
   content area, edge to edge. The canvas inset around the sheet, the sheet's border, corners and shadow,
   and the page padding all go, so nothing sits between the content and the window edge or the navigation
   rail. A page opts in through its root element: `.livemap`, `.devices-page`, or the shared marker class
   `.fill-bleed` (put it on the page's top-level panel, or on the wrapper that holds it), so no other
   page changes. Table pages mark their panel `fill-bleed`; pages of cards and forms wrap their body in `page-body`, which keeps the
   cards and pads them evenly. Desktop only: below 960px the sheet is already edge to edge, and the phone rules of these
   pages are sized around the page padding.

   The header's negative margins and sticky offset cancel the padding that is no longer there, so they go
   to zero with it. For `.livemap` and `.devices-page` that is done by the page (Devices.razor.css);
   `.fill-bleed` pages get it here, and the panel (or the panels inside the wrapper) loses its card
   border, corners and shadow: the header's bottom hairline is the only rule left above the grid. */
@media (min-width: 960px) {
    .infence-shell .mud-main-content:has(.infence-page > .livemap),
    .infence-shell .mud-main-content:has(.infence-page > .devices-page),
    .infence-shell .mud-main-content:has(.infence-page > .fill-bleed),
    .infence-shell .mud-main-content:has(.infence-page > .page-body) {
        padding: 0;
    }

    .infence-sheet:has(.infence-page > .livemap),
    .infence-sheet:has(.infence-page > .devices-page),
    .infence-sheet:has(.infence-page > .fill-bleed),
    .infence-sheet:has(.infence-page > .page-body) {
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .infence-page:has(> .livemap),
    .infence-page:has(> .devices-page),
    .infence-page:has(> .fill-bleed),
    .infence-page:has(> .page-body) {
        padding: 0;
    }

    /* Specificity (0,3,0) beats PageHeader's scoped `.cockpit[b-…]` (0,2,0). */
    .infence-page:has(> .fill-bleed) .cockpit,
    .infence-page:has(> .page-body) .cockpit {
        margin: 0;
    }

    .infence-page:has(> .fill-bleed) .cockpit--sticky,
    .infence-page:has(> .page-body) .cockpit--sticky {
        top: 0;
    }

    .surface-panel.fill-bleed,
    .fill-bleed > .surface-panel,
    .surface-panel.bleed-panel {
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* A page of cards and forms (Profile, Alert thresholds, Device detail, Fuel history): the header and the page are flush with
       the window, and the cards keep their borders on an even margin of their own (the page padding they used to rely on). */
    .page-body {
        padding: var(--pad-base);
    }
}

/* Brand lockup at the head of the rail. It sits on the canvas, separate from the page header, so the
   two no longer share a height or a hairline. */
.infence-drawer__brandbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    height: 56px;
    padding: 0 16px;
    text-decoration: none;
    color: var(--mud-palette-text-primary);   /* drives the monogram "F" (currentColor) */
    line-height: 1;
}

.infence-drawer__brandbar:hover {
    text-decoration: none;
    opacity: .82;
}

/* The brand lockup and, on desktop, the button that folds the sidebar. */
.infence-drawer__brandrow {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    padding-right: 8px;
}

.infence-drawer__brandrow > .infence-drawer__brandbar {
    flex: 1 1 auto;
    min-width: 0;
}

.infence-drawer__fold {
    flex: 0 0 auto;
    color: var(--mud-palette-text-secondary);
}

.infence-brand__word {
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--mud-palette-text-primary);
}

/* Only the nav scrolls; the brand bar and the workspace footer stay put. */
.infence-drawer__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Drawer-overlay toggle, only rendered below the Md breakpoint. */
.infence-drawer__toggle {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1200;
    background: var(--mud-palette-surface) !important;
    border: 1px solid var(--edge);
    box-shadow: var(--shadow-menu);
}

/* --- Drawer: on the canvas, workspace + appearance anchored to the bottom ----------------- */
.infence-drawer .mud-drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.infence-drawer.mud-drawer {
    background-color: transparent;
    border-right: 0;
}

.infence-drawer__footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    flex: 0 0 auto;
    padding: 10px;
}

/* Version + up to four small icon buttons (bell, profile, sign out, appearance) in a 232px rail: the
   gap is tight and the version label is the part that gives way, so the appearance menu is never
   pushed out of the rail. */
.infence-drawer__footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding-left: 4px;
}

.infence-drawer__ver {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .6875rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

/* The tenant picker is the widest thing in the rail foot: a subtle card on the canvas.
   Direct children only: the appearance menu (ThemeMenu) is also a .mud-menu, one level down in the
   footer row, and a descendant selector stretched it to 100% and pushed it out of the rail. */
.infence-drawer__footer > .mud-menu,
.infence-drawer__footer > .mud-menu > .mud-button-root {
    width: 100%;
    justify-content: flex-start;
}

.infence-drawer__footer > .mud-menu > .mud-button-root {
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--edge);
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-card);
}

/* --- Content column + mobile bottom-bar spacer -------------------------------------------- */
/* Shown while the identity and active tenant load, before any page is allowed to render. */
.infence-boot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 40dvh;
}

.infence-gate {
    max-width: 720px;
    margin: var(--pad-roomy) auto;
}

.infence-bottomnav-spacer {
    height: calc(56px + env(safe-area-inset-bottom, 0px));
}

/* --- Shared operational-page furniture ----------------------------------------------------- */
/* A segmented readout, a filter row and a pager, used by the alert queue, fleet health, devices,
   fuel and reports. Global rather than component-scoped because all of them want the identical
   treatment and there were previously three drifting copies of the same idea.

   The readout replaces the old free-standing .stat-tile cards: six bordered, shadowed, rail-accented
   boxes for six integers cost ~90px of vertical space and pushed the actual table below the fold.
   One hairline unit with internal dividers says the same thing in ~55px less and reads as a single
   group instead of six competing objects. */
.stat-readout {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: var(--pad-base);
    border: 1px solid var(--edge);
    border-radius: var(--radius-lg);
    background: var(--mud-palette-surface);
    box-shadow: var(--elev-card);
    overflow: hidden;
}

.stat-readout__cell {
    flex: 1 1 118px;
    min-width: 112px;
    padding: 13px var(--pad-base);
    border-right: 1px solid var(--edge);
}

.stat-readout__cell:last-child {
    border-right: 0;
}

.stat-readout__value {
    font-size: 1.5rem;
    font-weight: 640;
    line-height: 1.15;
    letter-spacing: -.02em;
    color: var(--mud-palette-text-primary);
}

/* Status modifiers tint the NUMBER, which is the thing being read — not a rail beside it. */
.stat-readout__value--ok { color: var(--mud-palette-success); }
.stat-readout__value--warn { color: var(--mud-palette-warning); }
.stat-readout__value--error { color: var(--mud-palette-error); }

.stat-readout__label {
    margin-top: 2px;
    font-size: .6875rem;
    font-weight: 640;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

/* Icon variant, used by Devices and Fuel.

   These two pages previously carried their own copies of this idea in Devices.razor.css /
   Fuel.razor.css, applied to a <MudPaper Class="devices-stat">. Blazor CSS isolation stamps its
   scope attribute on elements the component itself renders — a child component's root element does
   NOT receive it, so `.devices-stat[b-xxxx]` matched nothing and those rules had never applied.
   Living here, in the global sheet, they are immune to that whole class of failure — which is the
   same reason .filter-row and .pager-row are global. */
.stat-readout__cell--icon {
    display: flex;
    align-items: center;
    gap: 11px;
}

.stat-readout__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-md);
    background: rgba(var(--mud-palette-primary-rgb), var(--tint-strong));
    color: var(--mud-palette-primary);
}

.stat-readout__badge .mud-icon-root {
    font-size: 1.05rem;
}

.stat-readout__cell--warn .stat-readout__badge {
    background: rgba(var(--mud-palette-warning-rgb), .14);
    color: var(--mud-palette-warning);
}

/* Secondary figure inside a value, e.g. the "/ 7" in "5 / 7 reporting". */
.stat-readout__of {
    margin-left: 3px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
}

/* A panel that fills the leftover viewport height and scrolls its own rows.

   Add `surface-panel--fill` next to `surface-panel` when the table should own the rest of the
   screen (Devices, Device health, the admin registries). The chain below is what makes it work —
   every level needs `min-height: 0`, because a flex item's default `min-height: auto` refuses to
   shrink below its content and the table would push the panel past the viewport instead of
   scrolling inside it.

   MudTable and MudDataGrid render the same shape: an optional toolbar, a `.mud-table-container`
   that already has `overflow: auto`, and a pager *after* the container. Only the container flexes;
   the toolbar and pager keep their natural height. Because it is all flexbox the grid re-measures
   itself on window resize with no JS and no pixel arithmetic — which is what the previous
   `Height="calc(100dvh - …)"` could never do reliably. */
.surface-panel--fill {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Every other panel placed straight in the page keeps its natural height, so the page scrolls instead.
   `.surface-panel` has `overflow: hidden`, which drops a flex item's automatic minimum height to zero.
   Without this, such a panel was squeezed to fit the viewport and clipped. That happened to Fuel's
   History panel: nothing could scroll to it. A fill panel must therefore be the page's last panel. */
.infence-page > .surface-panel:not(.surface-panel--fill) {
    flex-shrink: 0;
}

/* The table is the part that grows. Descendant, not child, because a tabbed panel puts it two
   levels down — MudTabs renders `.mud-tabs > .mud-tabs-panels > .mud-tab-panel`, and the panel is
   `display: contents`, so the table ends up as a flex item of `.mud-tabs-panels`.

   `.mud-data-grid` is its own root class, distinct from `.mud-table` — MudDataGrid does not carry
   `.mud-table` on its root the way MudTable does, only on the `.mud-table-container` it nests
   inside. Without it here, MudDataGrid-based pages (Devices, History) never stretched: the inner
   `.mud-table-container` had `flex: 1 1 auto` but its non-growing `.mud-data-grid` parent left a
   gap below the grid instead of filling the viewport. */
.surface-panel--fill .mud-table,
.surface-panel--fill .mud-data-grid,
.surface-panel--fill > .mud-tabs,
.surface-panel--fill .mud-tabs-panels,
.surface-panel--fill .report-scroll {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.surface-panel--fill .mud-table-container {
    flex: 1 1 auto;
    min-height: 0;
}

/* Everything with its own natural height keeps it and never steals from the table. */
.surface-panel--fill .mud-table-toolbar,
.surface-panel--fill .mud-table-pagination,
.surface-panel--fill .mud-tabs-tabbar,
.surface-panel--fill .filter-row,
.surface-panel--fill .pager-row,
.surface-panel--fill .report-meta {
    flex: 0 0 auto;
}

.surface-panel--fill .mud-table-pagination {
    display: block;
}

/* Panel: the one card treatment — a soft lift off the sheet. Tone, --edge and --elev-card do the
   separating; High contrast swaps them for a solid hairline (token block above). */
.surface-panel {
    border: 1px solid var(--edge);
    border-radius: var(--radius-lg);
    background: var(--mud-palette-surface);
    box-shadow: var(--elev-card);
    overflow: hidden;
}

.filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: var(--pad-tight) var(--pad-base);
    border-bottom: 1px solid var(--edge);
}

.filter-row > * {
    flex: 0 1 200px;
    min-width: 150px;
}

/* Opt-out for items that should stay their natural width (labels, counts, buttons). */
.filter-row > .filter-row__aside {
    flex: 0 0 auto;
    min-width: 0;
    margin-left: auto;
    font-size: .6875rem;
    color: var(--mud-palette-text-secondary);
}

.pager-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 7px var(--pad-base);
    border-top: 1px solid var(--edge);
}

/* Severity stripe: 3px on the row's first cell. This is where the accent rail went — off the
   decorative card and onto the one place where a colored bar carries information. Apply
   `sev sev-error|warn|ok` to a <tr>. */
.sev > td:first-child {
    position: relative;
    padding-left: 17px !important;
}

.sev > td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--mud-palette-text-disabled);
}

.sev-ok > td:first-child::before { background: var(--mud-palette-success); }
.sev-warn > td:first-child::before { background: var(--mud-palette-warning); }
.sev-error > td:first-child::before { background: var(--mud-palette-error); }

/* Secondary line inside a table cell (IMEI under an asset name, "1h ago" under a timestamp). */
.cell-sub {
    display: block;
    font-size: .75rem;
    color: var(--mud-palette-text-secondary);
}

.cell-name {
    font-weight: 570;
    color: var(--mud-palette-text-primary);
}

/* --- MudBlazor component alignment --------------------------------------------------------- */
/* One header treatment for every MudTable and MudDataGrid: sunken fill, small uppercase label.
   Deliberately NOT scoped to .surface-panel — it used to be, and the tables that sat in another
   wrapper (Device detail's trips/stops, the History grid) silently fell back to MudBlazor's
   default header and read as a different product. The second selector matches MudBlazor's own
   sticky-header rule (4 classes, surface fill), which otherwise won on FixedHeader grids (Devices,
   History) and left their header rows the colour of the card. */
.mud-table-container .mud-table-head .mud-table-cell,
.mud-table-sticky-header .mud-table-container .mud-table-head .mud-table-cell {
    background-color: var(--mud-palette-background-gray);
    border-bottom: 1px solid var(--edge);
    font-size: .6875rem;
    font-weight: 650;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

/* Comfortable rows (~40px). Same specificity as MudBlazor's dense-cell rule and loaded after it, so
   this wins without !important. */
.mud-table-dense * .mud-table-row .mud-table-cell,
.mud-table-dense * .mud-table-row .mud-table-cell:first-child {
    padding: var(--row-pad-y) var(--row-pad-x);
    padding-inline: var(--row-pad-x);
}

/* Body cells at the 14px body size. MudBlazor sets them from Body2 (13px) with this same selector
   (0,3,0); loaded later, this wins. (Subtitle2 is MudBlazor's header-cell font, restyled above.) */
.mud-table-root .mud-table-body .mud-table-cell {
    font-size: var(--mud-typography-body1-size);
    font-weight: 400;
    border-bottom-color: var(--edge);
}

.surface-panel .mud-table-root {
    background-color: transparent;
}

/* A table's own toolbar (the search box on Devices/Fuel/Health) is part of the panel, so it gets
   the same padding rhythm as .filter-row and a hairline separating it from the header row —
   without it the search box floated in an unbounded band above the columns. */
.surface-panel .mud-table-toolbar {
    height: auto;
    min-height: 0;
    padding: var(--pad-tight) var(--pad-base);
    border-bottom: 1px solid var(--edge);
}

/* A table that fills the viewport scrolls its own rows (.mud-table-container), so its header row
   stays pinned — on every such page, not only where someone remembered FixedHeader="true" (it was
   set on the two MudDataGrids and on none of the fifteen MudTables). The opaque fill above is what
   keeps scrolled rows from showing through. */
.surface-panel--fill .mud-table-container .mud-table-head .mud-table-cell {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Status pills: a 999px pill, a 12% wash of the chip's own colour and a leading dot. Small text-variant
   chips are how every page renders state (online, severity, review), so restyling them here changes all
   of them with no markup change. Chips that carry their own icon (the "live" chip) get no dot. */
.mud-chip.mud-chip-size-small {
    height: 22px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

/* MudBlazor gives every chip a 4px margin. Inside a table cell that is 8px of extra row height (a 22px chip
   makes a 30px cell body, so rows measured 50px against the ~40px the density tokens aim for); the cell's own
   padding already spaces it. Horizontal margins stay, so chips side by side keep their gap. */
.mud-table-cell .mud-chip {
    margin-top: 0;
    margin-bottom: 0;
}

.mud-chip.mud-chip-text.mud-chip-size-small {
    background-color: color-mix(in srgb, currentColor 12%, transparent);
}

.mud-chip.mud-chip-text.mud-chip-size-small:not(:has(.mud-chip-icon))::before {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    margin-right: 6px;
    border-radius: 50%;
    background-color: currentColor;
}

/* Infence light only: the palette's status hues are AA as plain text on white, but not as 12px text on
   their own 12% wash (primary measured 3.98:1 on a card, 3.66:1 on a hovered row). The label is darkened
   a step; the wash and the dot keep the chip's own colour. On the content span, not the chip: inside the
   `color` property currentColor is the inherited value, so on the chip it would pick up the parent's text
   colour. 87% is the least darkening that keeps every status ≥4.5:1 on card, sheet and hovered row
   (8-bit rounded). Dark and High contrast are deliberately left as they are. */
:root:not([data-infence-mode="dark"]):not([data-infence-theme="contrast"]) .mud-chip.mud-chip-text.mud-chip-size-small > .mud-chip-content {
    color: color-mix(in srgb, currentColor 87%, #000);
}

/* The dark-mode mirror: on a hovered row the error pill measured 4.42:1. Lightening the text toward
   white by 2% is the computed minimum for ≥4.5:1 on card, sheet and hovered row for every status
   colour; 6% leaves margin for 8-bit rounding. Dark Infence only — High contrast is untouched. */
:root[data-infence-mode="dark"]:not([data-infence-theme="contrast"]) .mud-chip.mud-chip-text.mud-chip-size-small > .mud-chip-content {
    color: color-mix(in srgb, currentColor 94%, #fff);
}

/* Buttons match the input height. Medium is MudBlazor's default size and has no size class, hence the
   negative selector. The page-header bar overrides this with --control-h-compact (PageHeader.razor.css). */
.mud-button-root.mud-button:not([class*="-size-small"]):not([class*="-size-large"]) {
    min-height: var(--control-h);
}

/* ...except MudNumericField's stacked spin buttons, which share one input height between them; at 40px
   each the decrement button fell out of the field onto the helper-text line. Same specificity as the
   rule above, later in the sheet. */
.mud-input-numeric-spin > .mud-button-root.mud-button.mud-button-text {
    min-height: 0;
}

/* Bootstrap used to style <code> (tenant codes, permission codes, reset subjects); without it the
   browser default is Courier at 13px. A system monospace stack keeps it self-hosted-safe. */
code, kbd, samp {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: .875em;
}

/* Leaflet's panes carry z-index 400-700 with no stacking context of their own, so a track polyline
   painted over the sticky page header while the page scrolled (History, Device detail). Isolating the
   map keeps those z-indexes inside it; Live map's own overlays are siblings and are unaffected. */
.leaflet-container {
    isolation: isolate;
}

/* --- Focus visibility (keyboard nav) ------------------------------------------------------- */
/* MudBlazor components already carry their own focus ring; this is a floor for the bespoke
   button-like elements (chips, toolbar buttons, panel toggles) defined in the page stylesheets. */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* Shared entrance keyframes — used by LiveMap's provider menu and other floating popovers. */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Scrollbars ----------------------------------------------------------------------------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(91, 104, 121, 0.28);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast) ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(91, 104, 121, 0.5);
}

/* Keyed off the attribute, not .mud-theme-dark — see the note at the top of this file. These two
   rules previously never fired, so dark mode was running the light-mode thumb. */
:root[data-infence-mode="dark"] ::-webkit-scrollbar-thumb {
    background: rgba(234, 239, 246, 0.16);
}

:root[data-infence-mode="dark"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(234, 239, 246, 0.32);
}

/* --- Narrow viewport ------------------------------------------------------------------------ */
@media (max-width: 959.98px) {
    /* Phones/small tablets: every pixel counts at 412px, so the sheet loses its inset, corners and lift,
       and the overlay drawer becomes an opaque floating panel (it covers the page, not the canvas). */
    .infence-shell .mud-main-content {
        padding: 0;
    }

    .infence-sheet {
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .infence-drawer.mud-drawer {
        background-color: var(--mud-palette-surface);
        box-shadow: var(--shadow-float);
    }

    /* Tighter gutters: at 412px the desktop padding costs a visible share of the row. */
    .infence-page {
        padding: var(--pad-tight);
    }

    /* The cockpit bar's own narrow-viewport margins live in PageHeader.razor.css (scoped CSS outranks
       an unscoped class here). The readout's full-bleed scroller keeps !important for the same reason. */
    .cockpit__readout {
        margin: 0 calc(var(--pad-tight) * -1) !important;
        padding: 0 var(--pad-tight) !important;
    }

    /* A responsive MudTable collapses to stacked label/value rows; give each record a visible
       boundary or the whole list reads as one undifferentiated column of pairs. */
    .surface-panel .mud-table-row {
        border-bottom: 1px solid var(--edge);
    }
}
