/* The loading screen's background, matching the theme it's about to show: dark unless this browser
   chose light (html[data-theme]). Once the layout renders, MudBlazor's theme owns the background. */
body:not(:has(.mud-layout)) {
    background: #16181d;
    color-scheme: dark;
}

:root[data-theme="light"] body:not(:has(.mud-layout)) {
    background: #f5f6f8;
    color-scheme: light;
}

/* ---- DataGrid (Components/Grid), after Artemes' .grid__* rules, in MudBlazor's theme colours ---- */
.grid {
    display: flex;
    flex-direction: column;
    font-size: 0.8125rem;
}

.grid__bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 6px 10px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
}

.grid__count {
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.grid__ctl {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    cursor: pointer;
}

.grid__ctl--button {
    background: transparent;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    padding: 2px 9px;
}

.grid__ctl--button:hover {
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-text-primary);
}

.grid__select {
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    color: var(--mud-palette-text-primary);
    font: inherit;
    padding: 2px 6px;
}

.grid__picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    align-items: center;
    padding: 8px 10px;
    background: var(--mud-palette-background-gray);
    border: 1px solid var(--mud-palette-lines-default);
    border-bottom: none;
}

.grid__pick {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
}

.grid__scroll {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 0 0 8px 8px;
    overflow: auto;
    background: var(--mud-palette-surface);
}

.grid__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.grid__table th,
.grid__table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--mud-palette-table-lines);
    text-align: left;
    vertical-align: middle;
}

/* The header and filter row stay in view while the rows scroll. */
.grid__table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--mud-palette-background-gray);
    color: var(--mud-palette-text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.grid__table thead tr.grid__filters th {
    top: 29px;
    z-index: 1;
    padding: 2px 4px;
    font-weight: normal;
}

.grid__head {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font: inherit;
    color: inherit;
}

.grid__head--sortable {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.grid__sort {
    font-size: 1rem !important;
    opacity: 0.3;
}

.grid__sort--on,
.grid__head--sortable:hover .grid__sort {
    opacity: 1;
}

.grid__filter {
    width: 100%;
    min-width: 3.5rem;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 4px;
    color: var(--mud-palette-text-primary);
    font: inherit;
    padding: 2px 6px;
}

.grid__filter:focus {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: -1px;
}

.grid__choice {
    min-width: 4.5rem;
    margin: 0 !important;
}

.grid__choice .mud-input {
    font-size: 0.8125rem;
}

.grid__row:hover > td {
    background: var(--mud-palette-table-hover);
}

.grid__row:focus {
    outline: none;
}

.grid__row:focus > td {
    background: var(--mud-palette-action-default-hover);
    box-shadow: inset 0 1px 0 var(--mud-palette-primary), inset 0 -1px 0 var(--mud-palette-primary);
}

/* Selected rows: a tint and a bar on the left, so a selection is visible on a phone too. */
.grid__row--selected > td {
    background: color-mix(in srgb, var(--mud-palette-primary) 16%, transparent);
}

.grid__row--selected > td:first-child {
    box-shadow: inset 3px 0 0 var(--mud-palette-primary);
}

.grid__row--selected:hover > td {
    background: color-mix(in srgb, var(--mud-palette-primary) 22%, transparent);
}

.grid__selection {
    color: var(--mud-palette-primary);
}

/* Pilot's read-only rows: channels the user can't allocate. */
.grid__row--system > td {
    font-style: italic;
}

.grid__num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.grid__group > td {
    background: var(--mud-palette-background-gray);
    cursor: pointer;
}

.grid__empty {
    padding: 16px;
    margin: 0;
}

/* Narrowing: the queries measure the grid itself, not the window, so an open sidebar counts.
   Below 600 px is the phone layout (HideOnPhone drops columns, PhoneOnly stand-ins appear).
   From 600 px up, columns drop by GridColumn.Priority, least important first. */
.grid {
    container-type: inline-size;
}

@container (min-width: 600px) {
    .grid__phone-only {
        display: none;
    }

    .nowrap {
        white-space: nowrap;
    }
}

@container (min-width: 600px) and (max-width: 679.98px) {
    .grid__prio-2 {
        display: none;
    }
}

@container (max-width: 959.98px) {
    .grid__prio-3,
    .grid__prio-4 {
        display: none;
    }
}

@container (max-width: 1319.98px) {
    .grid__prio-4 {
        display: none;
    }
}

@container (max-width: 599.98px) {
    .grid__phone-hidden {
        display: none;
    }

    .grid__table th,
    .grid__table td {
        padding: 4px 6px;
    }

    .grid__table td {
        overflow-wrap: anywhere;
    }

    .channel-value {
        min-width: 2.5rem;
        max-width: 7rem;
    }

    .channel-edit {
        width: 4.5rem;
    }
}

/* ---- Chart panel: docked above the status bar, the full width of the window ---- */
.chart-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--status-bar-total);
    height: var(--chart-panel-height);
    /* Beside the docked sidebar (left comes from the layout), and under a phone's sliding one. */
    z-index: calc(var(--mud-zindex-drawer) - 1);
    transition: left 225ms cubic-bezier(0, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    padding: 0 env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
    box-sizing: border-box;
}

.chart-panel__resize {
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    touch-action: none;
}

.chart-panel--collapsed .chart-panel__resize {
    cursor: default;
}

.chart-panel__head {
    flex: none;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    font-size: 0.8125rem;
}

.chart-legend {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.chart-legend__item {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 2px 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    white-space: nowrap;
}

.chart-legend__swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.chart-legend__value {
    color: var(--mud-palette-text-secondary);
    font-variant-numeric: tabular-nums;
}

.chart-legend__axis,
.chart-legend__remove {
    display: inline-flex;
    align-items: center;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--mud-palette-text-secondary);
    font: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 1px 4px;
    cursor: pointer;
}

.chart-legend__axis {
    border: 1px solid var(--mud-palette-lines-inputs);
}

.chart-legend__axis:hover,
.chart-legend__remove:hover {
    background: var(--mud-palette-action-default-hover);
    color: var(--mud-palette-text-primary);
}

.chart-panel__tools {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.chart-panel__error {
    flex: none;
    padding: 0 12px 4px;
    font-size: 0.75rem;
}

.chart-panel__plot {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chart-panel__plot .u-over {
    cursor: grab;
}

.chart-panel__plot .u-over:active {
    cursor: grabbing;
}


/* ---- Setup ---- */
.setup-card {
    overflow: hidden;
}

.setup-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 16px 4px;
}

.setup-card .grid__bar,
.setup-card .grid__scroll {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

.setup-card .grid__scroll {
    border-bottom: 0;
}

/* The upload button is a label around a hidden file input, so the whole button opens the picker. */
.setup-file-input {
    display: none;
}

.setup-list {
    margin: 4px 0 12px 20px;
}

/* ---- Power supplies ---- */
.psu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr));
    gap: 16px;
}

.psu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.psu__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.psu__title {
    font-weight: 600;
}

.psu__state {
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--mud-palette-action-disabled-background);
    color: var(--mud-palette-text-secondary);
}

.psu__state--on {
    background: var(--mud-palette-success);
    color: var(--mud-palette-success-text);
}

.psu__body {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 24px;
}

.psu__setpoints {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 14rem;
}

.psu__setpoint {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.psu__setpoint-label,
.psu__reading-label,
.psu__hint {
    font-size: 0.75rem;
}

.psu__setpoint-label,
.psu__reading-label {
    color: var(--mud-palette-text-secondary);
}

.psu__setpoint-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.psu__input {
    width: 7rem;
    font-size: 1rem;
    padding: 4px 6px;
}

.psu__unit {
    min-width: 2rem;
    color: var(--mud-palette-text-secondary);
}

.psu__readbacks {
    display: grid;
    grid-template-columns: repeat(2, minmax(7rem, 1fr));
    gap: 8px 16px;
    flex: 1 1 14rem;
}

.psu__reading {
    display: flex;
    flex-direction: column;
}

.psu__reading-value {
    font-size: 1.5rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.psu__reading-value small {
    font-size: 0.85rem;
    color: var(--mud-palette-text-secondary);
}

.psu__trend {
    height: 160px;
}

/* ---- Calibration ---- */
.cal-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.cal-modules {
    flex: 0 1 18rem;
    min-width: 14rem;
}

.cal-table {
    flex: 1 1 28rem;
    min-width: 0;
}

.cal-grid {
    max-width: 36rem;
}

.cal-input {
    width: 9rem;
}

.cal-input--changed {
    border-color: var(--mud-palette-warning);
    background: color-mix(in srgb, var(--mud-palette-warning) 12%, var(--mud-palette-surface));
}

.cal-input--invalid {
    border-color: var(--mud-palette-error);
    background: color-mix(in srgb, var(--mud-palette-error) 12%, var(--mud-palette-surface));
}

/* ---- Logs ---- */
.logs-tabs {
    flex: none;
}

.logs-tabs .mud-tabs-panels {
    display: none;
}

.log-message {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.log-row--error > td {
    color: var(--mud-palette-error);
}

.log-row--warn > td {
    color: var(--mud-palette-warning);
}

.log-row--debug > td {
    color: var(--mud-palette-text-secondary);
}

/* Value editing. */
.channel-value--editable {
    background: none;
    border: 1px dashed transparent;
    border-radius: 4px;
    color: inherit;
    font: inherit;
    cursor: text;
    padding: 0 4px;
    min-height: 1.5em;
    vertical-align: middle;
}

.channel-value__empty {
    color: var(--mud-palette-text-disabled);
    font-style: italic;
}

.channel-value--editable:hover,
.channel-value--editable:focus-visible {
    border-color: var(--mud-palette-primary);
}

/* Inputs and system channels: visibly not something to click, as Pilot darkens them. */
.channel-value--readonly .mud-switch {
    opacity: 0.55;
}

.channel-value--editing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    overflow: visible;
}

.channel-edit {
    width: 6.5rem;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-primary);
    border-radius: 4px;
    color: var(--mud-palette-text-primary);
    font: inherit;
    text-align: right;
    padding: 1px 4px;
}

.channel-choice {
    max-width: 9rem;
    padding: 1px 4px;
}

.channel-stat {
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

/* Pilot's highlight of a new minimum (red) or maximum (blue), for HighlightTime = 500 ms. */
.channel-stat--flash-min,
.channel-stat--flash-max {
    animation: stat-flash 500ms ease-out;
}

.channel-stat--flash-min {
    --flash: var(--mud-palette-error);
}

.channel-stat--flash-max {
    --flash: var(--mud-palette-info);
}

/* Bold-looking without font-weight: a heavier weight is wider and would resize the column on
   every flash. A same-colour text shadow thickens the glyphs without moving anything. */
@keyframes stat-flash {
    from {
        color: var(--flash);
        text-shadow: 0.35px 0 0 var(--flash), -0.35px 0 0 var(--flash);
    }
}

/* Pilot's data bar ("Blue Gradient") behind a value with a known scale. */
.channel-value--bar {
    background: linear-gradient(to right,
        color-mix(in srgb, var(--mud-palette-primary) 45%, transparent),
        color-mix(in srgb, var(--mud-palette-primary) 15%, transparent) var(--bar),
        transparent var(--bar));
    /* An editable value has a transparent border; without these the bar tiles into it. */
    background-origin: border-box;
    background-repeat: no-repeat;
    border-radius: 3px;
    padding-inline: 4px;
    /* The bar's scale is the cell, not the text, so equal values give equal bars. */
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    text-align: right;
}

@media (prefers-reduced-motion: reduce) {
    .channel-stat--flash-min,
    .channel-stat--flash-max {
        animation: none;
    }
}

:root {
    --status-bar-height: 28px;
    /* The bar plus the iPhone's home-indicator area, which it covers rather than sits inside. */
    --status-bar-total: calc(var(--status-bar-height) + env(safe-area-inset-bottom, 0px));
    /* Set by chart.js: 0 without a chart, the header's height when it's collapsed. */
    --chart-panel-height: 0px;
    --bottom-docked: calc(var(--status-bar-total) + var(--chart-panel-height));
}

/* A phone held sideways has little height to spare: a slimmer app bar (dense is 3/4 of this).
   html:root outranks the :root rule MudBlazor's theme provider writes after this sheet. */
@media (max-height: 500px) {
    html:root {
        --mud-appbar-height: 53.334px;
    }
}

/* Keep page and drawer content clear of the status bar, and in landscape clear of the notch. */
.mud-main-content {
    padding-bottom: var(--bottom-docked);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.mud-drawer .mud-drawer-content {
    padding-bottom: var(--status-bar-total);
    padding-left: env(safe-area-inset-left, 0px);
}

.mud-appbar .mud-toolbar {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.status-bar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: calc(var(--mud-zindex-appbar) + 2);
    height: var(--status-bar-total);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 max(8px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(8px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    background: var(--mud-palette-appbar-background);
    color: var(--mud-palette-text-secondary);
    border-top: 1px solid var(--mud-palette-lines-default);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
}

.status-bar-modules {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.status-bar-module {
    border: 0;
    border-radius: 4px;
    padding: 2px 8px;
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.status-bar-module:hover {
    background: var(--mud-palette-primary-darken);
}

.status-bar-slot {
    opacity: 0.8;
    margin-right: 6px;
}

.status-bar-host {
    flex: none;
}

@media (max-width: 599.98px) {
    .status-bar-host {
        display: none;
    }
}

/* ---- Layout ---- */
.drawer-body {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Collapsed to icons, the sidebar shows no text at all (its links have titles instead). */
.mud-drawer .mud-nav-link {
    white-space: nowrap;
}

.mud-drawer--closed.mud-drawer-mini .mud-nav-link-text,
.mud-drawer--closed.mud-drawer-mini .esharp-link .mud-typography {
    display: none;
}

.app-title,
.esharp-link {
    color: inherit;
    text-decoration: none;
}

.esharp-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    white-space: nowrap;
    overflow: hidden;
}

.esharp-link svg {
    flex: none;
}

.page {
    padding: 16px 24px;
}

@media (max-width: 599.98px) {
    .page {
        padding: 12px;
    }
}

/* A page that fills everything between the app bar and the status bar, edge to edge, with its
   content (the channel grid) scrolling inside. */
.page--fill {
    padding: 0;
    height: calc(100dvh - (var(--mud-appbar-height) - var(--mud-appbar-height) / 4) - var(--bottom-docked));
    display: flex;
    flex-direction: column;
}

.channel-grid {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.channel-grid .grid {
    flex: 1;
    min-height: 0;
}

.channel-grid .grid__scroll {
    flex: 1;
    min-height: 0;
}

/* Edge to edge: no rounded box with page background around it. */
.channel-grid .grid__bar,
.channel-grid .grid__picker,
.channel-grid .grid__scroll {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
}

.channel-grid .grid__scroll {
    border-bottom: 0;
}

.poll-status {
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

/* The app bar: brand, then the page's name. On a phone the logo stands in for the brand. */
.app-page-title::before {
    content: "›";
    margin: 0 10px;
    opacity: 0.5;
}

.app-page-title:empty {
    display: none;
}

@media (max-width: 599.98px) {
    .app-brand,
    .app-page-title::before {
        display: none;
    }

    .app-page-title {
        margin-left: 8px;
    }
}

/* Page controls in the grid's bar: search, then pause, interval, clear history, reload. */
.grid__search {
    flex: 1 1 10rem;
    max-width: 26rem;
    min-width: 7rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 6px;
    color: var(--mud-palette-text-secondary);
}

.grid__search:focus-within {
    border-color: var(--mud-palette-primary);
}

.grid__search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
}

.grid__tools {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.grid__interval {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--mud-palette-text-secondary);
}

.grid__interval input {
    width: 4.2rem;
    padding: 2px 4px;
    border: 1px solid var(--mud-palette-lines-inputs);
    border-radius: 4px;
    background: var(--mud-palette-surface);
    color: var(--mud-palette-text-primary);
    font: inherit;
    text-align: right;
}

/* In a narrow grid the bar's buttons drop their words and keep their icons and counts. */
@container (max-width: 959.98px) {
    .grid__label {
        display: none;
    }

    .grid__bar {
        gap: 8px;
        padding: 4px 8px;
    }
}

.esharp-link:hover .mud-typography {
    text-decoration: underline;
}

.channel-value {
    display: inline-block;
    min-width: 4rem;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
    vertical-align: middle;
}

.trend {
    display: block;
    width: 96px;
    height: 20px;
    color: var(--mud-palette-primary);
}

/* A long press opens the context menu on touch screens; stop iOS selecting text
   or showing its link callout on the same gesture. */
@media (pointer: coarse) {
    .context-target {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

.mono {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
    font-size: 0.85em;
}

#blazor-error-ui {
    background: #fff4ce;
    color: #1f1f1f;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "This part of the page failed to render.";
    }

.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 25vh 0 auto 0;
    margin: 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #8882;
        stroke-width: 0.5rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1e5aa8;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-family: system-ui, sans-serif;
    color: #888;
    inset: calc(25vh + 2.5rem) 0 auto 0;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

/* The Numeric page (P3-NUM): settings on the left, the panes filling the rest. */
.numeric {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 12px;
    padding: 12px;
    flex: 1;
    min-height: 0;
}

.numeric__side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
}

.numeric__chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    min-width: 0;
}

.numeric-pane {
    display: flex;
    flex-direction: column;
    min-height: 160px;
    flex: 1 1 0;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    padding: 4px 8px;
}

.numeric-pane--wave {
    flex-grow: 1.6;
}

.numeric-pane[hidden] {
    display: none;
}

.numeric-pane__title {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.numeric-pane__plot {
    flex: 1 1 auto;
    min-height: 0;
}

.numeric-stats td {
    padding: 2px 6px !important;
}

@media (max-width: 900px) {
    /* Stacked, the settings and panes are taller than the screen: the page scrolls instead. */
    .page--fill:has(> .numeric) {
        height: auto;
    }

    .numeric {
        grid-template-columns: 1fr;
        height: auto;
    }

    .numeric__chart .numeric-pane {
        min-height: 240px;
    }
}

/* ---- Bus transactions ---- */
.bus {
    display: grid;
    grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
}

.bus__fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bus__data {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.bus__log {
    grid-column: 1 / -1;
    min-width: 0;
}

.bus__history td {
    vertical-align: middle;
}

.bus__bytes {
    max-width: 18rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bus__history--error td {
    color: var(--mud-palette-error);
}

.nowrap {
    white-space: nowrap;
}

@media (max-width: 900px) {
    .bus {
        grid-template-columns: minmax(0, 1fr);
    }
}

.hexview {
    max-height: 22rem;
    overflow: auto;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    padding: 6px 8px;
    line-height: 1.6;
}

.hexview--empty {
    font-size: 0.875rem;
}

.hexview__row {
    display: flex;
    gap: 14px;
    white-space: nowrap;
}

.hexview__offset {
    color: var(--mud-palette-text-secondary);
}

.hexview__bytes {
    display: inline-grid;
    grid-template-columns: repeat(16, 2.4ch);
    column-gap: 0.5ch;
}

.hexview__byte {
    background: transparent;
    border: 0;
    border-radius: 3px;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.hexview__byte:hover {
    background: var(--mud-palette-action-default-hover);
}

.hexview__byte--selected {
    background: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
}

.hexview__ascii {
    color: var(--mud-palette-text-secondary);
    white-space: pre;
}

.bus__kinds {
    width: 100%;
}

.bus__details pre {
    white-space: pre-wrap;
    font-size: 0.75rem;
    max-height: 12rem;
    overflow: auto;
}

/* ---- System and Files ---- */
.system,
.files {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.firmware {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1100px;
}

.firmware__source {
    min-width: 18rem;
    flex: 1 1 24rem;
}

.firmware__table {
    overflow-x: auto;
}

.firmware__notes {
    min-width: 12rem;
}

/* Release notes, rendered from Markdown: compact, so a table row stays a row. */
.firmware__notes-text > :first-child {
    margin-top: 0;
}

.firmware__notes-text > :last-child {
    margin-bottom: 0;
}

.firmware__notes-text p,
.firmware__notes-text ul,
.firmware__notes-text ol {
    margin: 0.25rem 0;
}

.firmware__notes-text ul,
.firmware__notes-text ol {
    padding-left: 1.25rem;
}

.firmware__notes-text li {
    list-style: disc;
}

.firmware__notes-text ol li {
    list-style: decimal;
}

.firmware__notes-text h1,
.firmware__notes-text h2,
.firmware__notes-text h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
}

.firmware__notes-text code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
    font-size: 0.85em;
}

/* A release before the minimum version: listed for reference, installed only with Pilot. */
.firmware--old td {
    opacity: 0.55;
}

.firmware__log {
    max-height: 60vh;
    overflow: auto;
    font-size: 0.75rem;
    white-space: pre-wrap;
}

.startup {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 1100px;
}

.startup__bar {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* A section boot.config doesn't apply while it is off: still editable, visibly not in force. */
.startup--off {
    opacity: 0.6;
}

.startup__table {
    overflow-x: auto;
}

.startup__table td {
    vertical-align: middle;
}

.startup__add {
    max-width: 16rem;
}

.startup__field {
    min-width: 14rem;
    flex: 1 1 14rem;
}

.startup__iface {
    max-width: 7rem;
}

.system__clock td:first-child {
    width: 9rem;
}

.files__crumb {
    min-width: 0;
    text-transform: none;
}

.files__disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ---- Environment meters ---- */
.envmeter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 34rem), 1fr));
    gap: 12px;
}

.envmeter {
    padding: 12px 16px;
}

.envmeter__main {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7.25rem, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.envmeter__tile {
    position: relative;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 8px 10px;
}

.envmeter__label {
    font-size: 0.8rem;
    color: var(--mud-palette-text-secondary);
}

.envmeter__value {
    font-size: 1.45rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.envmeter__unit {
    font-size: 0.9rem;
    color: var(--mud-palette-text-secondary);
}

.envmeter__trend .trend {
    width: 100%;
    height: 24px;
    color: var(--mud-palette-primary);
}

.envmeter__range {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.envmeter__chart {
    position: absolute;
    top: 2px;
    right: 2px;
}

/* ---- PoE testers ---- */
.poe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 40rem), 1fr));
    gap: 12px;
}

.poe {
    padding: 12px 16px;
}

.poe__readings {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 6px 14px;
    margin-top: 8px;
}

.poe__label {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

.poe__value {
    font-variant-numeric: tabular-nums;
}

.poe__reading .trend {
    width: 100%;
    height: 16px;
}

.poe__ports {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: 10px;
    margin-top: 12px;
}

.poe__port {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    padding: 8px 10px;
}

.poe__polarity {
    max-width: 11rem;
}

.poe__modes {
    width: 100%;
}

.poe__led {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid var(--mud-palette-lines-default);
}

.poe__led--on {
    background: var(--mud-palette-success);
    border-color: var(--mud-palette-success);
}

.poe__led--off {
    background: transparent;
}

.poe__led--unknown {
    background: var(--mud-palette-action-disabled);
}

.poe__ledlabel {
    font-size: 0.75rem;
    color: var(--mud-palette-text-secondary);
}

/* ---- Audio ---- */
.audio {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audio__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr));
    gap: 12px;
}

.audio__fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audio__player {
    width: 100%;
    max-width: 32rem;
}

.audio__player--idle {
    display: none;
}
