/* Infence component styling (UI components sub-project, docs/superpowers/specs/2026-10-02-ui-components-design.md).
   Global, not component-scoped: these target MudBlazor component internals, which scoped CSS cannot reach.
   Built only on the Foundation tokens in infence-shell.css (loaded before this file), so light, dark and
   High contrast all follow automatically. MudBlazor.min.css loads before both, so a selector here wins
   at equal specificity. */

/* ===== Dialogs ================================================================================ */
.mud-dialog {
    background-color: var(--mud-palette-surface);
    border: 1px solid var(--edge);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-menu);
}

.mud-dialog .mud-dialog-title {
    padding: 16px 20px;
    border-bottom: 1px solid var(--edge);
}

.mud-dialog .mud-dialog-title .mud-typography-h6 {
    font-size: .96875rem;   /* 15.5px */
    font-weight: 620;
    letter-spacing: -.01em;
}

/* Three classes on purpose: MudBlazor positions the close button with
   ".mud-dialog .mud-dialog-title .mud-button-close", which a shorter selector here would lose to.
   Centred on the 54px title row: touch keeps MudBlazor's 48px target (top 3px), a fine pointer gets
   the 32px button (top 12px, set with the icon-button size below). */
.mud-dialog .mud-dialog-title .mud-button-close {
    top: 3px;
    right: 4px;
    border-radius: var(--radius-md);
}

/* Long forms scroll inside the content; title and actions stay put. */
.mud-dialog .mud-dialog-content {
    padding: 18px 20px;
    overflow-y: auto;
}

.mud-dialog .mud-dialog-actions {
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--edge);
    background-color: color-mix(in srgb, var(--mud-palette-text-primary) 2%, transparent);
}

/* Form helpers for long dialogs: an uppercase group label and a two-up field row. */
.dlg-group {
    margin: 4px 0 8px;
    font-size: .6875rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.dlg-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

/* Fields carry Class="mb-3" for the one-column flow; inside a row the grid gap does the spacing. */
.dlg-two > * {
    margin-bottom: 0 !important;
}

@media (max-width: 599.98px) {
    .dlg-two {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Confirm dialog (Components/ConfirmDialog.razor). */
.mud-dialog.confirm-dialog {
    max-width: 400px;
}

.confirm-dialog__title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.confirm-dialog__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background-color: rgba(var(--mud-palette-error-rgb), var(--tint-strong));
    color: var(--mud-palette-error);
    font-weight: 700;
}

.confirm-dialog__target {
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    overflow-wrap: anywhere;
}

.confirm-dialog__message {
    line-height: 1.5;
    color: var(--mud-palette-text-secondary);
}

/* Read by screen readers, not drawn: e.g. the confirm target inside the dialog title, which names the
   dialog. Not display:none, which would drop it from the accessible name too. Neither host links Bootstrap,
   so this is the app's only copy of the utility. */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ===== Banners (MudAlert, choice A: tinted fill + edge) ======================================== */
.mud-alert.mud-alert-text-info,
.mud-alert.mud-alert-text-success,
.mud-alert.mud-alert-text-warning,
.mud-alert.mud-alert-text-error,
.mud-alert.mud-alert-text-normal {
    padding: 11px 14px;
    border: 1px solid;
    border-radius: 10px;
    color: var(--mud-palette-text-primary);
}

.mud-alert.mud-alert-text-info { background-color: rgba(var(--mud-palette-info-rgb), .08); border-color: rgba(var(--mud-palette-info-rgb), .28); }
.mud-alert.mud-alert-text-success { background-color: rgba(var(--mud-palette-success-rgb), .08); border-color: rgba(var(--mud-palette-success-rgb), .28); }
.mud-alert.mud-alert-text-warning { background-color: rgba(var(--mud-palette-warning-rgb), .08); border-color: rgba(var(--mud-palette-warning-rgb), .28); }
.mud-alert.mud-alert-text-error { background-color: rgba(var(--mud-palette-error-rgb), .08); border-color: rgba(var(--mud-palette-error-rgb), .30); }
.mud-alert.mud-alert-text-normal { background-color: color-mix(in srgb, var(--mud-palette-text-secondary) 8%, transparent); border-color: var(--edge); }

/* The icon carries the severity colour; the text stays readable body text. */
.mud-alert.mud-alert-text-info .mud-alert-icon { color: var(--mud-palette-info); }
.mud-alert.mud-alert-text-success .mud-alert-icon { color: var(--mud-palette-success); }
.mud-alert.mud-alert-text-warning .mud-alert-icon { color: var(--mud-palette-warning); }
.mud-alert.mud-alert-text-error .mud-alert-icon { color: var(--mud-palette-error); }

.mud-alert.mud-dense {
    padding: 8px 12px;
}

/* ===== Toasts (MudSnackbar, choice A: bottom-right) ============================================ */
/* MudBlazor paints a filled severity colour; here every toast is a neutral surface and the severity
   lives in a tinted dot, so a burst of errors is calm to read. MudBlazor sets that fill with a single
   ".mud-alert-filled-<severity>" class (no !important), so this rule beats it by loading later. */
.mud-snackbar {
    position: relative;
    width: 340px;
    max-width: calc(100vw - 32px);
    padding: 11px 12px;
    border: 1px solid var(--edge);
    border-radius: 12px;
    background-color: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    box-shadow: var(--shadow-menu);
}

.mud-snackbar .mud-snackbar-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    margin-right: 10px;
}

.mud-snackbar .mud-snackbar-icon .mud-icon-root { font-size: 14px; }

/* Below 960px the fixed 56px bottom nav (BottomNav.razor.css) is on screen, and MudBlazor's bottom: 24px
   put the toast stack over it, on a higher layer. Errors stay until closed, so the nav icons under one
   could not be tapped. Lift the stack over the nav plus a 12px gap, with the same safe-area term as
   .infence-bottomnav-spacer. MudBlazor sets bottom with this single class, so loading later wins. */
@media (max-width: 959.98px) {
    .mud-snackbar-location-bottom-right {
        bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 12px);
    }
}

.mud-snackbar[class*="-success"] .mud-snackbar-icon { color: var(--mud-palette-success); background-color: rgba(var(--mud-palette-success-rgb), .16); }
.mud-snackbar[class*="-info"] .mud-snackbar-icon,
.mud-snackbar[class*="-normal"] .mud-snackbar-icon { color: var(--mud-palette-info); background-color: rgba(var(--mud-palette-info-rgb), .16); }
.mud-snackbar[class*="-warning"] .mud-snackbar-icon { color: var(--mud-palette-warning); background-color: rgba(var(--mud-palette-warning-rgb), .16); }
.mud-snackbar[class*="-error"] .mud-snackbar-icon { color: var(--mud-palette-error); background-color: rgba(var(--mud-palette-error-rgb), .16); }

/* Life bar for the auto-hiding toasts: errors stay until closed (SeverityAwareSnackbar sets RequireInteraction
   for Severity.Error only) and have none. 4000ms is VisibleStateDuration in AddTrackingUi and 10000ms, below, is
   SeverityAwareSnackbar.WarningDuration; UiComponentsContractTests.ToastLifeBar_RunsForTheToastDurations pins
   both, by these two selectors. MudBlazor 9.7 marks severity as mud-alert-{variant}-{severity} on the
   snackbar (mud-alert-filled-warning here), hence the substring match. The bar starts with the 300ms
   fade-in, so it empties about 0.3s before the 700ms fade-out begins. */
.mud-snackbar:not([class*="-error"])::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background-color: currentColor;
    opacity: .35;
    transform-origin: left;
    animation: infence-toast-life 4000ms linear forwards;
}

.mud-snackbar[class*="-warning"]::after {
    animation-duration: 10000ms;
}

.mud-snackbar:hover::after {
    animation-play-state: paused;
}

@keyframes infence-toast-life {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* ===== Tabs (choice A: underline) ============================================================== */
.mud-tabs .mud-tabs-tabbar {
    background-color: transparent;
    box-shadow: inset 0 -1px 0 var(--edge);
}

/* The first label lines up with the table text under the bar. */
.mud-tabs .mud-tabs-tabbar-wrapper {
    padding-inline-start: var(--row-pad-x);
}

/* Tabs size to their label. MudTabs writes min-width:160px inline (MinimumTabWidth) and sets width:100%,
   which made every tab 182px and pushed a third tab behind scroll arrows at phone width; the inline
   value can only be beaten with !important. */
.mud-tabs .mud-tab {
    min-width: 0 !important;
    width: auto;
    margin-right: 22px;
    padding: 10px 2px;
    border-radius: 6px 6px 0 0;
    text-transform: none;
    font-size: .875rem;
    font-weight: 520;
    letter-spacing: normal;
    color: var(--mud-palette-text-secondary);
}

/* Phones get a 12px gap. MudTabs shows its scroll arrows only when the summed tab widths exceed
   .mud-tabs-tabbar-content, and neither these margins nor the 14px inset are in that sum, so a row they push
   past the bar is clipped with no arrows: at 360px the 22px gaps put Notifications' "Webhooks" 16px out of
   view. 12px fits it with 4px to spare; a longer row or a narrower screen can still clip the same way
   (Notifications at 320px). */
@media (max-width: 599.98px) {
    .mud-tabs .mud-tab {
        margin-right: 12px;
    }
}

/* Hover fills are gated like MudBlazor's own, so a tap on a touch screen doesn't leave the tint stuck. */
@media (hover: hover) and (pointer: fine) {
    .mud-tabs .mud-tab:hover {
        background-color: rgba(var(--mud-palette-primary-rgb), var(--tint-soft));
    }
}

/* The 2px indicator is drawn by the active tab itself. MudBlazor's slider sizes itself as a share of
   the summed tab widths, which leaves out the 22px gaps, so under content-width tabs it drifted off
   the label (a 90px bar under a 73px tab). */
.mud-tabs .mud-tab.mud-tab-active {
    color: var(--mud-palette-text-primary);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--mud-palette-primary);
}

.mud-tabs .mud-tab-slider {
    display: none;
}

/* ===== Menus and popovers (not tooltips — those are popovers too) ============================== */
.mud-popover:not(.mud-tooltip) {
    border: 1px solid var(--edge);
    border-radius: 12px;
    background-color: var(--mud-palette-surface);
    box-shadow: var(--shadow-menu);
}

/* A select with no options (e.g. Webhooks before any exist) would open as a 14px bordered sliver:
   only the list padding and this border. Nothing to choose, so nothing to show. */
.mud-popover:not(.mud-tooltip):has(> .mud-list:empty) {
    display: none;
}

/* Two sets of rules, because MudBlazor renders two kinds of list: MudSelect and the pickers use
   .mud-list / .mud-list-item; MudMenu (TenantPicker, ThemeMenu) uses .mud-menu-list / .mud-menu-item. */
.mud-popover:not(.mud-tooltip) .mud-list,
.mud-popover:not(.mud-tooltip) .mud-menu-list {
    padding: 6px;
}

.mud-popover:not(.mud-tooltip) .mud-list-item,
.mud-popover:not(.mud-tooltip) .mud-menu-item {
    min-height: 36px;
    border-radius: 7px;
}

@media (hover: hover) and (pointer: fine) {
    .mud-popover:not(.mud-tooltip) .mud-list-item-clickable:hover,
    .mud-popover:not(.mud-tooltip) .mud-menu-item:hover {
        background-color: rgba(var(--mud-palette-primary-rgb), var(--tint-soft));
    }
}

/* MudBlazor also puts "mud-primary-hover" on the selected item, and that class sets its background
   with !important, so background-color alone is never seen. It reads --mud-palette-primary-hover, so
   re-pointing that variable here gives the selected item the stronger tint without any !important. */
.mud-popover:not(.mud-tooltip) .mud-selected-item {
    --mud-palette-primary-hover: rgba(var(--mud-palette-primary-rgb), var(--tint-strong));
    background-color: rgba(var(--mud-palette-primary-rgb), var(--tint-strong));
}

.mud-popover:not(.mud-tooltip) .mud-divider {
    border-color: var(--edge);
}

/* ===== Tooltips: an inverted chip (light on dark, dark on light) ============================== */
.mud-tooltip.mud-tooltip-default {
    padding: 5px 9px;
    border-radius: 7px;
    background-color: var(--mud-palette-text-primary);
    color: var(--mud-palette-background);
    font-size: .75rem;
    font-weight: 560;
    box-shadow: var(--shadow-float);
}

/* ===== Buttons ================================================================================= */
/* Secondary = outlined default, ghost = text default, danger = Color.Error. Primary keeps its fill;
   its text colour comes from the palette's PrimaryContrastText (InfenceThemes.cs). */
.mud-button-outlined.mud-button-outlined-default {
    border-color: color-mix(in srgb, var(--mud-palette-text-primary) 14%, transparent);
}

.mud-button-text.mud-button-text-default {
    color: var(--mud-palette-text-secondary);
}

/* Hover fills only where a real hover exists (MudBlazor gates its own the same way). */
@media (hover: hover) and (pointer: fine) {
    .mud-button-text.mud-button-text-default:hover {
        background-color: rgba(var(--mud-palette-primary-rgb), var(--tint-soft));
        color: var(--mud-palette-text-primary);
    }
}

/* Icon buttons: 8px radius, 6% hover fill, 32px box. The :where(:not(...)) leaves out the icon buttons
   MudBlazor uses as carriers, which must keep their own shape and padding: the switch thumb, the
   calendar day cells and the checkbox/radio halos are all round, and the switch thumb positions itself
   with its own 9px padding. :where() adds no specificity, so MudBlazor's own contextual rules (outlined
   and filled icon buttons, the picker's month arrows, pagination) still win where they set a value. */
.mud-icon-button:where(:not(.mud-switch-base, .mud-day, .mud-checkbox .mud-icon-button, .mud-radio .mud-icon-button)) {
    border-radius: var(--radius-md);
}

@media (hover: hover) and (pointer: fine) {
    .mud-icon-button:where(:not(.mud-switch-base, .mud-day, .mud-checkbox .mud-icon-button, .mud-radio .mud-icon-button)):hover {
        background-color: color-mix(in srgb, currentColor 6%, transparent);
    }

    /* 32px = a 24px glyph + 4px padding on each side (MudBlazor's medium is 12px, i.e. 48px). Only for
       a fine pointer: touch keeps the 48px default for tap targets. Small and large keep their own sizes.
       Input adornments (the date and time pickers' calendar/clock button) keep 12px too: MudBlazor's
       edge-end margin of -12px assumes that padding, and with 4px the glyph sat ~6px from the outline. */
    .mud-icon-button:where(:not(.mud-icon-button-size-small, .mud-icon-button-size-large, .mud-switch-base, .mud-day, .mud-checkbox .mud-icon-button, .mud-radio .mud-icon-button, .mud-input-adornment-icon-button)) {
        padding: 4px;
    }

    .mud-dialog .mud-dialog-title .mud-button-close {
        top: 12px;
        right: 12px;
    }
}

.mud-button-root:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* ===== Muted text ============================================================================== */
/* Pages mark captions and helper lines `<MudText Color="Color.Secondary">` to mean "quieter text". MudBlazor reads that as the palette's
   Secondary colour, which is the framework's teal (it was navy before the palette changed): a teal caption on every page is not what
   anyone meant. Muted text takes the theme's secondary-text colour, which follows every mode and High contrast.
   MudBlazor's own `.mud-secondary-text` is `!important`, so this has to be too (the one place the stylesheets use it). */
.mud-typography.mud-secondary-text {
    color: var(--mud-palette-text-secondary) !important;
}

/* ===== Table-row actions ======================================================================= */
/* Icon-only action cells (Class="row-actions" / CellClass="row-actions") appear on row hover or
   keyboard focus. They stay in layout (opacity, not display) so columns never jump, and are always
   visible where hover doesn't exist (touch) and in High contrast. The opacity sits on the cell's
   content, not the cell: on the <td> it also hid the cell's own bottom border, so every row divider
   stopped short at the actions column. The transition lists MudBlazor's own icon-button one (copied from
   .mud-icon-button) as well, because where the child is the button itself a lone opacity transition
   replaced it and the hover fill snapped on instead of easing in. */
/* The cell holds only a 26px icon button. With the full 10px row padding that is a 46px cell, and it sets the
   height of the whole row (46-47px, against ~40px for a text row); 5px keeps the row's height with its text.
   Four classes, to beat the three of the shared cell-padding rule in infence-shell.css. */
.mud-table-dense * .mud-table-row .mud-table-cell.row-actions {
    padding-top: 5px;
    padding-bottom: 5px;
}

.mud-table-row .row-actions > * {
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-standard),
                background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
}

.mud-table-row:hover .row-actions > *,
.mud-table-row:focus-within .row-actions > * {
    opacity: 1;
}

@media (hover: none) {
    .mud-table-row .row-actions > * { opacity: 1; }
}

:root[data-infence-theme="contrast"] .mud-table-row .row-actions > * {
    opacity: 1;
}

/* --- Vehicle state icons (spec 2026-10-03) -------------------------------------------------------
   Body colour per motion, from the palette so light, dark and High contrast follow automatically.
   text-secondary, not text-disabled, for Not working: it keeps a Not working vehicle a solid, readable
   grey against the map tiles. Used by the Live map markers (vehicle-icon.js) and by
   VehicleIcon (lists, legend, asset form). */
.veh--running   { --veh-c: var(--mud-palette-success); }
.veh--overspeed { --veh-c: var(--mud-palette-error); }
.veh--idle      { --veh-c: var(--mud-palette-warning); }
.veh--stopped   { --veh-c: var(--mud-palette-info); }
.veh--offline   { --veh-c: var(--mud-palette-text-secondary); }

.veh-marker {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Explicit, so Leaflet's drag-time cursor swap on the icon does not restyle every sprite subtree. */
    cursor: pointer;
}

.veh-body {
    display: flex;
    transform-origin: 50% 50%;
}

.veh-body svg,
.veh-icon svg {
    display: block;
    overflow: visible;
}

/* Overlay treatments: faded for No recent data, a grey ghost for No GPS fix (option A). */
.veh--stale .veh-body,
.veh-icon.veh--stale > svg {
    opacity: .55;
    filter: saturate(.55);
}

.veh--nofix .veh-body,
.veh-icon.veh--nofix > svg {
    opacity: .45;
    filter: grayscale(1);
}

/* One upright badge. The glyph uses the surface colour: dark ink on the bright dark-mode palette,
   white on the deeper light-mode one. */
.veh-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mud-palette-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
    pointer-events: none;
}

.veh--alarm .veh-badge { background: var(--mud-palette-error); }
.veh--stale .veh-badge { background: var(--mud-palette-warning); }
.veh--nofix .veh-badge { background: var(--mud-palette-text-secondary); }

/* Alarm ring: transform/opacity only, so many alarming markers stay cheap. */
.veh-ring {
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 2.5px solid var(--mud-palette-error);
    pointer-events: none;
    animation: veh-alarm-pulse 1.3s ease-out infinite;
}

@keyframes veh-alarm-pulse {
    0% { transform: scale(.85); opacity: 1; }
    100% { transform: scale(1.25); opacity: 0; }
}

/* The pulse pauses while the map is panned, so the compositor is not redrawing every ring per frame. */
.leaflet-dragging .veh-ring { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
    .veh-ring { animation: none; }
}

/* Upright list/legend icon (VehicleIcon). */
.veh-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.veh-icon .veh-badge {
    top: -3px;
    right: -5px;
    width: 14px;
    height: 14px;
}

/* Vehicle access dialog: the pickable vehicles scroll inside the dialog instead of stretching it. */
.va-list {
    max-height: 320px;
    overflow-y: auto;
    margin-top: 8px;
    padding: 4px 8px;
    border: 1px solid var(--edge, var(--mud-palette-lines-default));
    border-radius: var(--mud-default-borderradius);
}

/* ===========================================================================================================
   Gauges (device page instruments, Cockpit fleet charts). Drawn as inline SVG by the components in
   Components/*.razor; every colour is a palette token, so each theme and High contrast follow.
   =========================================================================================================== */
.gg { display: block; width: 100%; height: auto; max-height: 220px; }
.gg-ok { --gg-c: var(--mud-palette-success); }
.gg-warn { --gg-c: var(--mud-palette-warning); }
.gg-alarm { --gg-c: var(--mud-palette-error); }
.gg-info { --gg-c: var(--mud-palette-info); }
.gg-neutral { --gg-c: var(--mud-palette-text-primary); }
.gg-seg { stroke: var(--gg-c); stroke-width: 3.4; stroke-linecap: round; transition: opacity .25s; }
.gg-seg.gg-off { opacity: .16; }
.gg-tickline { stroke: var(--mud-palette-text-secondary); stroke-width: 1.3; }
.gg-tick { fill: var(--mud-palette-text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.gg-marker { fill: var(--mud-palette-text-primary); }
.gg-needle { transform-box: view-box; transform-origin: 100px 100px; transition: transform .45s cubic-bezier(.3, 1.3, .5, 1); }
.gg-needleline { stroke: var(--mud-palette-text-primary); stroke-width: 2.6; stroke-linecap: round; }
.gg-hub { fill: var(--mud-palette-text-primary); }
.gg-hubdot { fill: var(--mud-palette-surface); }
.gg-readout { fill: var(--gg-c, var(--mud-palette-text-primary)); font-size: 36px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gg-unit { fill: var(--mud-palette-text-secondary); font-size: 12px; }
.gg-strong { fill: var(--mud-palette-text-primary); font-size: 14px; font-weight: 600; }
.gg-alarm.gg-unit { fill: var(--mud-palette-error); font-weight: 600; }
.gg-track { fill: var(--mud-palette-background-gray); stroke: var(--mud-palette-lines-default); stroke-width: 1; }
.gg-liquid { fill: var(--gg-c); opacity: .85; transition: y .45s ease, height .45s ease; }
.gg-limit { stroke: var(--mud-palette-error); stroke-width: 1.5; stroke-dasharray: 4 3; }
.gg-ring-outline { fill: none; stroke: var(--mud-palette-lines-default); stroke-width: 1; }
.gg-card { transform-box: view-box; transform-origin: 100px 88px; transition: transform .45s ease; }
.gg-tick-north { stroke: var(--mud-palette-error); stroke-width: 2; }
.gg-cardletter { fill: var(--mud-palette-text-primary); font-size: 18px; font-weight: 600; }
.gg-cardletter.gg-north { fill: var(--mud-palette-error); }
.gg-pointer { fill: var(--mud-palette-primary); stroke: var(--mud-palette-text-primary); stroke-width: 1; }
.gg-donut-track { fill: none; stroke: var(--mud-palette-background-gray); stroke-width: 22; }
.gg-donut-slice { fill: none; stroke: var(--gg-c); stroke-width: 22; transition: stroke-dasharray .45s ease; }
.gg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gg-c); flex: none; }
.gg-dot.gg-neutral { background: var(--mud-palette-text-secondary); }
.gg-donut-slice.gg-neutral { stroke: var(--mud-palette-text-secondary); opacity: .55; }

/* Donut with its legend */
.donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut__svg { width: 168px; max-height: 168px; flex: none; }
.donut__legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 150px; }
.donut__legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.donut__legend li span { flex: 1; color: var(--mud-palette-text-secondary); }
.donut__legend li b { font-variant-numeric: tabular-nums; }

/* Odometer digits */
.odo { display: flex; gap: 2px; justify-content: center; align-items: center; padding: 6px 0 2px; flex-wrap: nowrap; max-width: 100%; }
.odo__digit { background: var(--mud-palette-text-primary); color: var(--mud-palette-surface); font-size: 19px; font-weight: 600; line-height: 1;
    padding: 6px 3px; border-radius: 4px; min-width: 19px; text-align: center; font-variant-numeric: tabular-nums; }
.odo__unit { margin-left: 5px; color: var(--mud-palette-text-secondary); font-size: 12px; }

/* Signal bars */
.sigbars { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; vertical-align: middle; }
.sigbars__bar { width: 5px; border-radius: 1px; background: var(--mud-palette-lines-default); }
.sigbars__bar--on { background: var(--mud-palette-text-primary); }

/* Instrument panel on the device page: one "bezel" card per instrument, all the same size, with the title row and the dial aligned */
.instruments { padding: 14px 16px 16px; margin-bottom: 14px; }
.instruments__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
.instruments__title { font-weight: 600; font-size: 15px; }
.instruments__hint { color: var(--mud-palette-text-secondary); font-size: 12px; }
.instruments__grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.inst-tile { min-width: 0; display: flex; flex-direction: column; border-radius: 14px; padding: 10px 10px 12px;
    border: 1px solid var(--mud-palette-lines-default);
    background:
        radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--mud-palette-primary) 7%, transparent), transparent 70%),
        color-mix(in srgb, var(--mud-palette-background-gray) 60%, var(--mud-palette-surface));
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--mud-palette-surface) 70%, transparent), inset 0 -8px 18px color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent); }
.inst-tile__title { margin: 0 0 6px; padding: 0 2px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
    font-size: 13px; font-weight: 600; color: var(--mud-palette-text-primary); white-space: nowrap; }
.inst-tile__title > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.inst-tile__sub { flex: none; font-size: 11.5px; font-weight: 500; color: var(--mud-palette-text-secondary); }
.inst-tile__body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 172px; }
.inst-tile__body > .gg { width: 100%; max-width: 210px; max-height: 172px; }
.inst-facts { margin: 8px 0 0; padding: 0 4px; width: 100%; display: grid; gap: 5px; }
.inst-facts > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; min-height: 22px;
    border-bottom: 1px dashed var(--mud-palette-lines-default); }
.inst-facts > div:last-child { border-bottom: 0; }
.inst-facts dt { color: var(--mud-palette-text-secondary); }
.inst-facts dd { margin: 0; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.inst-ok { color: var(--mud-palette-success); }
.inst-alarm { color: var(--mud-palette-error); }
:root[data-infence-theme="contrast"] .inst-tile { background: var(--mud-palette-surface); box-shadow: none; border-color: var(--mud-palette-text-primary); }

/* Cockpit fleet charts */
.cockpit-gauges { display: grid; gap: var(--gap, 12px); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: var(--gap, 12px); }
.cockpit-gauges__panel { padding: 14px 16px 16px; display: flex; flex-direction: column; }
.cockpit-gauges__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.cockpit-gauges__title { font-weight: 600; font-size: 15px; }
.cockpit-gauges__body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 196px;
    border-radius: 14px; padding: 10px;
    border: 1px solid var(--mud-palette-lines-default);
    background:
        radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--mud-palette-primary) 7%, transparent), transparent 70%),
        color-mix(in srgb, var(--mud-palette-background-gray) 60%, var(--mud-palette-surface)); }
.cockpit-gauges__body .gg { max-width: 230px; }
.cockpit-gauges__note { color: var(--mud-palette-text-secondary); font-size: 13px; text-align: center; margin-top: 6px; }
:root[data-infence-theme="contrast"] .cockpit-gauges__body { background: var(--mud-palette-surface); border-color: var(--mud-palette-text-primary); }

@media (prefers-reduced-motion: reduce) {
    .gg-needle, .gg-card, .gg-seg, .gg-liquid, .gg-donut-slice { transition: none; }
}

/* ===========================================================================================================
   Cockpit graphics: proportion bars, column charts, vehicle tiles, entrance motion.
   =========================================================================================================== */
.stackbar { display: flex; gap: 2px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--mud-palette-background-gray); }
.stackbar__part { display: block; height: 100%; background: var(--gg-c); transition: width .45s ease; min-width: 3px; }
.stackbar__part.gg-neutral { background: var(--mud-palette-text-secondary); opacity: .5; }
.stackbar__part--empty { opacity: .35; }

.bars { display: flex; align-items: stretch; justify-content: center; gap: 8px; width: 100%; height: 168px; padding: 2px 4px 0; }
.bars__col { flex: 1 1 0; min-width: 0; max-width: 54px; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; gap: 4px; }
.bars__value { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--mud-palette-text-primary); }
.bars__track { width: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 8px;
    background: color-mix(in srgb, var(--mud-palette-text-primary) 5%, transparent); }
.bars__bar { display: block; width: 100%; border-radius: 8px 8px 3px 3px; background: var(--gg-c);
    background-image: linear-gradient(to top, color-mix(in srgb, var(--gg-c) 82%, black), var(--gg-c));
    transition: height .5s cubic-bezier(.3, 1.2, .5, 1); }
.bars__bar.gg-neutral { background: var(--mud-palette-text-secondary); opacity: .55; }
.bars__label { font-size: 11px; color: var(--mud-palette-text-secondary); white-space: nowrap; }

/* Vehicle tiles */
.vtiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); padding: 12px 14px 14px; }
.vtile { --vt-c: var(--mud-palette-text-secondary); position: relative; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "icon main speed" "fuel fuel fuel" "ago ago ago";
    align-items: center; gap: 4px 10px; padding: 10px 12px 9px 14px; border-radius: 14px; text-decoration: none; color: inherit; overflow: hidden;
    border: 1px solid var(--mud-palette-lines-default);
    background:
        radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--vt-c) 10%, transparent), transparent 65%),
        color-mix(in srgb, var(--mud-palette-background-gray) 55%, var(--mud-palette-surface));
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.vtile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--vt-c); }
.vtile:hover { transform: translateY(-2px); border-color: var(--vt-c); box-shadow: 0 6px 18px color-mix(in srgb, var(--mud-palette-text-primary) 12%, transparent); text-decoration: none; }
.vtile:focus-visible { outline: 2px solid var(--mud-palette-primary); outline-offset: 2px; }
.vtile--ok { --vt-c: var(--mud-palette-success); }
.vtile--warn { --vt-c: var(--mud-palette-warning); }
.vtile--alarm { --vt-c: var(--mud-palette-error); }
.vtile > .veh { grid-area: icon; }
.vtile__main { grid-area: main; min-width: 0; display: flex; flex-direction: column; }
.vtile__name { font-weight: 600; font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.vtile__state { font-size: 12px; color: var(--vt-c); font-weight: 600; }
.vtile__speed { grid-area: speed; font-size: 22px; font-weight: 640; line-height: 1; font-variant-numeric: tabular-nums; text-align: right; }
.vtile__speed small { display: block; font-size: 10px; font-weight: 500; color: var(--mud-palette-text-secondary); margin-top: 2px; }
.vtile__fuel { grid-area: fuel; display: block; height: 5px; border-radius: 999px; background: var(--mud-palette-background-gray); overflow: hidden; margin-top: 4px; }
.vtile__fuel i { display: block; height: 100%; border-radius: 999px; background: var(--mud-palette-info); }
.vtile__fuel--low i { background: var(--mud-palette-error); }
.vtile__ago { grid-area: ago; font-size: 11px; color: var(--mud-palette-text-secondary); display: flex; justify-content: space-between; gap: 8px; }
:root[data-infence-theme="contrast"] .vtile { background: var(--mud-palette-surface); border-color: var(--mud-palette-text-primary); }

/* Cockpit headline pill: a live pulse next to the update time */
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--mud-palette-success); margin-right: 6px; vertical-align: middle;
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--mud-palette-success) 55%, transparent); animation: pulse 2.2s ease-out infinite; }
.pulse--off { background: var(--mud-palette-text-secondary); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Panels rise in one after another (the delay comes from the --i custom property on each) */
.rise { animation: rise .45s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .rise, .pulse { animation: none; }
    .vtile, .stackbar__part, .bars__bar { transition: none; }
}

/* ===========================================================================================================
   Modern finish for every page: insight cards, richer tables and panels, motion. Palette tokens only (so the
   themes and High contrast follow); motion is switched off for reduced-motion users at the end.
   =========================================================================================================== */

/* Insight strip under a page header */
.insights { display: grid; gap: var(--gap, 12px); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); flex-shrink: 0;
    padding: var(--gap, 12px) var(--pad-base, 16px) 0; }
.insight { padding: 11px 14px 12px; border-radius: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
    border: 1px solid var(--mud-palette-lines-default);
    background:
        radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--mud-palette-primary) 7%, transparent), transparent 65%),
        color-mix(in srgb, var(--mud-palette-background-gray) 55%, var(--mud-palette-surface)); }
.insight__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.insight__title { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--mud-palette-text-secondary); }
.insight__total { font-size: 17px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.insight__legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.insight__legend li { display: inline-flex; align-items: center; gap: 6px; }
.insight__legend li span { color: var(--mud-palette-text-secondary); }
.insight__legend li b { font-variant-numeric: tabular-nums; }
:root[data-infence-theme="contrast"] .insight { background: var(--mud-palette-surface); border-color: var(--mud-palette-text-primary); }

/* Panels: a faint glow at the top edge so a card reads as a surface, not a flat rectangle */
.surface-panel { background-image: radial-gradient(140% 70% at 50% -10%, color-mix(in srgb, var(--mud-palette-primary) 5%, transparent), transparent 60%); }
:root[data-infence-theme="contrast"] .surface-panel { background-image: none; }

/* Tables: a quieter, tinted header and a primary accent on the hovered row */
.mud-table-container .mud-table-head .mud-table-cell,
.mud-table-sticky-header .mud-table-container .mud-table-head .mud-table-cell {
    background-color: color-mix(in srgb, var(--mud-palette-background-gray) 70%, var(--mud-palette-surface));
    font-weight: 600; letter-spacing: .02em; }
.mud-table-hover .mud-table-body .mud-table-row { transition: background-color .15s ease; }
.mud-table-hover .mud-table-body .mud-table-row:hover > .mud-table-cell:first-child { box-shadow: inset 3px 0 0 var(--mud-palette-primary); }
.mud-table-cell { font-variant-numeric: tabular-nums; }

/* Controls: a soft focus glow on inputs and a small lift on buttons */
.mud-input-outlined:focus-within .mud-input-outlined-border { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mud-palette-primary) 18%, transparent); }
.mud-button-root { transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease; }
.mud-button-filled:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 4px 12px color-mix(in srgb, var(--mud-palette-primary) 28%, transparent); }
.mud-button-filled:not(:disabled):active { transform: none; box-shadow: none; }
:root[data-infence-theme="contrast"] .mud-button-filled:not(:disabled):hover { box-shadow: none; transform: none; }

/* Page content rises in (opacity and offset only: nothing is left transformed once it has finished) */
.infence-page > .surface-panel, .infence-page > .insights, .infence-page > .page-body { animation: rise .4s cubic-bezier(.2, .7, .2, 1) both; }

@media (max-width: 599.98px) {
    .insights { grid-template-columns: minmax(0, 1fr); padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .infence-page > .surface-panel, .infence-page > .insights, .infence-page > .page-body { animation: none; }
    .mud-table-hover .mud-table-body .mud-table-row, .mud-button-root { transition: none; }
    .mud-button-filled:not(:disabled):hover { transform: none; }
}

/* ===========================================================================================================
   Table-cell graphics (Phase 2): fuel meter, speed badge, voltage chip, signal cell
   =========================================================================================================== */
.meter { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.meter__bar { display: inline-block; width: 52px; height: 7px; border-radius: 999px; background: var(--mud-palette-background-gray); overflow: hidden; flex: none; }
.meter__fill { display: block; height: 100%; border-radius: 999px; transition: width .4s ease; background: var(--mud-palette-text-secondary); }
.meter__fill--ok { background: var(--mud-palette-success); }
.meter__fill--warn { background: var(--mud-palette-warning); }
.meter__fill--alarm { background: var(--mud-palette-error); }
.meter__text { font-variant-numeric: tabular-nums; }
.meter__none { color: var(--mud-palette-text-secondary); }

.speedb { display: inline-flex; align-items: baseline; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.speedb small { font-size: 11px; color: var(--mud-palette-text-secondary); }
.speedb--parked b { font-weight: 500; color: var(--mud-palette-text-secondary); }
.speedb--moving b { font-weight: 700; color: var(--mud-palette-success); }
.speedb--over b { font-weight: 700; color: var(--mud-palette-warning); }

.volt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.volt--low { color: var(--mud-palette-error); font-weight: 600; }

.sigcell { display: inline-flex; align-items: center; gap: 8px; }

/* Profile header */
.profile-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; margin-bottom: 14px; }
.profile-hero__avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 20px; font-weight: 700;
    color: var(--mud-palette-primary-text); background: linear-gradient(135deg, var(--mud-palette-primary), color-mix(in srgb, var(--mud-palette-primary) 55%, var(--mud-palette-info)));
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--mud-palette-primary) 18%, transparent); }
.profile-hero__who { min-width: 0; flex: 1 1 220px; }
.profile-hero__name { font-size: 18px; font-weight: 640; letter-spacing: -.01em; }
.profile-hero__sub { color: var(--mud-palette-text-secondary); font-size: 13px; overflow-wrap: anywhere; }
.profile-hero__chips { display: flex; gap: 6px; flex-wrap: wrap; }
