@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

:root {
    /* Data completeness: broad status colours, with detailed reasons retained in drilldowns. */
    --nxs-data-attention: #d1771c;
    --nxs-data-progress: #5e87ed;
    --nxs-data-failure: #b8403a;
    --nxs-data-unassessed: #747984;
    /* Not expected and acknowledged: lighter than unassessed so the two greys differ in lightness, not only hue. */
    --nxs-data-not-expected: #8a939d;
    --nxs-data-acknowledged: #b48ce6;
    --transition-speed-hover: 0.1s;
    --nxs-warning: #ffcc33;
    --nxs-surface-radius: 1rem;

    /* ── Design tokens (single source of truth; see docs/plans/ui-and-ux/design-tokens-retrofit.md) ──
       The MudTheme in MainLayout references these; component CSS must use them, not literals. */

    /* Radius — flat scale */
    --nxs-radius-sm: 4px;    /* chips (non-pill), small/inset controls */
    --nxs-radius-md: 6px;    /* default — buttons, inputs, cards */
    --nxs-radius-lg: 8px;    /* panels, grids, modals, large surfaces */
    --nxs-radius-pill: 999px;

    /* Spacing — 4px-based scale for margin / padding / gap. Token number = pixel value;
       value is rem for accessibility (assumes 16px root). Round raw spacing to the nearest
       step. Structural values (vh/vw, calc(), grid track sizes) are NOT spacing — leave them. */
    --nxs-space-2:  0.125rem; /* 2px  — hairline gaps */
    --nxs-space-4:  0.25rem;  /* 4px  */
    --nxs-space-6:  0.375rem; /* 6px  */
    --nxs-space-8:  0.5rem;   /* 8px  */
    --nxs-space-12: 0.75rem;  /* 12px */
    --nxs-space-16: 1rem;     /* 16px — base rhythm */
    --nxs-space-20: 1.25rem;  /* 20px */
    --nxs-space-24: 1.5rem;   /* 24px */
    --nxs-space-32: 2rem;     /* 32px */
    --nxs-space-48: 3rem;     /* 48px — section spacing */
    --nxs-space-card-inset: var(--nxs-space-12);

    /* Type size — font-size scale (see docs/plans/ui-and-ux/chip-size-tokens.md; broader Pass 9 extends
       it site-wide). Named -size to avoid colliding with the --nxs-text* colour family. */
    --nxs-text-size-xs: 0.75rem;   /* 12px — dense chips / micro-labels */
    --nxs-text-size-sm: 0.8125rem; /* 13px — compact chips / labels */
    --nxs-text-size-md: 0.875rem;  /* 14px — standard chips / base component text */
    --nxs-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Control height — standard fixed heights for interactive controls. */
    --nxs-control-h-chip: 20px; /* dense data badge (e.g. dimension-matrix conformance pill) */
    --nxs-control-h-sm: 28px;   /* compact interactive controls */
    --nxs-control-h-md: 32px;   /* standard interactive pill (removable / helper chips) */
    --nxs-control-h-lg: 36px;   /* standard action button */
    --nxs-control-h-form: var(--nxs-control-h-lg); /* ordinary input bodies share the 36px action height */
    --nxs-control-w-select: 16rem; /* standalone selectors; shrink to fit narrower containers */
    --nxs-control-w-file: 48rem; /* ordinary file pickers stay readable instead of spanning a wide workflow */
    /* Motion — shared durations for repeated decorative treatments. */
    --nxs-motion-duration-shimmer: 2.2s;
    --nxs-motion-duration-reveal: 150ms; /* hover reveals and small anchored panels */

    /* Layout — all pages share the full-width content gutter.
       See docs/plans/ui-and-ux/page-width-layout.md. */
    --nxs-content-gutter: 1.5rem; /* horizontal page padding (replaces the old global px-4) */
    --nxs-dialog-workflow-max: 72rem; /* data-bearing forms/dialogs: wide enough for a grid, bounded for readable fields */
    --nxs-dialog-wide-max: 96rem; /* dialogs that host whole record pages, such as the machine and its measurements */
    /* Shared browse tiles: the narrowest a tile may be. auto-fill picks the column count from
       it, and the columns then share the row, so a tile is this wide or wider. */
    --nxs-tile-width-min: 17rem;
    --nxs-chart-height-xs: 6rem;   /* 96px — sparkline inside a statistic tile, no axes */
    --nxs-chart-height-sm: clamp(320px, 42vh, 440px);
    --nxs-chart-height-md: clamp(420px, 58vh, 560px);
    --nxs-chart-height-lg: clamp(510px, 70vh, 640px);
    --nxs-chart-height-xl: clamp(510px, 78vh, 780px);
    --nxs-grid-fill-min-height: 320px; /* floor for FillViewport grids — 100vh shrinks in CSS px under browser zoom, so without a floor calc(100vh - offset) collapses the grid to nothing */
    --nxs-grid-detail-height: 20rem;
    --nxs-grid-dialog-height: clamp(20rem, 58dvh, 35rem);
    --nxs-grid-source-picker-height: 33dvh;
    --nxs-grid-cell-max-width: 20rem;

    /* Surfaces — neutral dark ladder (tinted darks are NOT surfaces — handled as status tokens) */
    --nxs-bg: #222222;            /* page background */
    --nxs-surface: #121212;       /* primary panel/card surface */
    --nxs-surface-inset: #101010; /* wells/insets (absorbs #0f0f0f/#0d0d0d/#141414/#151515) */
    --nxs-surface-raised: #1a1a1a;/* raised panels (absorbs #161616/#181818/#191919/#1b1b1b/#1d1d1d/#1e1e1e/#1f1f1f) */
    --nxs-surface-40: color-mix(in srgb, var(--nxs-surface) 40%, transparent);
    --nxs-surface-80: color-mix(in srgb, var(--nxs-surface) 80%, transparent);
    --nxs-geometry-surface: var(--nxs-surface-raised); /* canonical geometry viewer / thumbnail surface */
    --nxs-surface-2: #2a2a2a;     /* secondary fills (absorbs #232323/#242424/#262626/#272727/#2b2b2b) */
    --nxs-surface-3: #383838;     /* raised/hover fills (absorbs #333333/#353535/#3a3a3a/#444444) */
    --nxs-field-backdrop: var(--nxs-bg); /* inherited field surface for browser autofill */

    /* Borders / lines */
    --nxs-border: #363636;
    --nxs-border-60: color-mix(in srgb, var(--nxs-border) 60%, transparent);
    --nxs-border-strong: #4f4f4f; /* absorbs #3a3a3a/#5f5f5f */
    --nxs-divider: var(--nxs-overlay-12); /* = white 12% overlay step (see ladder below) */

    /* Text */
    --nxs-text: #ffffff;          /* headings / primary */
    --nxs-text-body: #e6e6e6;     /* body */
    --nxs-text-muted: #9aa3ad;    /* labels / secondary */
    --nxs-text-subtle: #b8c3cf;   /* absorbs #aeb7c2/#cfd6de/#9aa0a6 */
    --nxs-text-faint: #5b636d;    /* inert glyphs and absent readings, quieter than muted */

    /* Accent / status */
    --nxs-accent: #00bcd4;
    --nxs-accent-bright: #00d4ee; /* absorbs #00c8ff/#74edff — hover/glow */
    --nxs-assembly-am: #d08045; /* AM source nodes in assembly routes */
    --nxs-assembly-balancing: #b69cdc; /* balancing stages and their legend */
    --nxs-danger: #f05252;        /* fail / out-of-tolerance fill */
    --nxs-danger-strong: #d71920; /* strong error */
    --nxs-danger-bg: #3f1014;     /* error background tint */
    --nxs-success: #2e9e5f;       /* in-tolerance / pass fill */
    --nxs-success-bg: #0f3f25;    /* dark green fill */
    --nxs-info-bg: #0f1720;       /* info/note panels (absorbs #101114/#05070b/#0d1117) */

    /* Categorical import phases: stable across rows; not warning/success indicators. */
    --nxs-import-phase-queued: #94a3b8;
    --nxs-import-phase-dequeued: #d1b98b;
    --nxs-import-phase-resolving-request: #c4b5fd;
    --nxs-import-phase-building-request: #f5a86f;
    --nxs-import-phase-validating-request: #a3d977;
    --nxs-import-phase-validating-source: #e1d873;
    --nxs-import-phase-queueing: #729fcf;
    --nxs-import-phase-calling-airtable: #a8dff0;
    --nxs-import-phase-ensuring-build: #f2a4cc;
    --nxs-import-phase-cloning-build: #3fb8a8; /* visible on inset surfaces and distinct from ensuring-build */
    --nxs-import-phase-resolving-importer: #ad9bea;
    --nxs-import-phase-evaluating-capability: #f2c94c;
    --nxs-import-phase-running-importer: #4dc7ed;
    --nxs-import-phase-importing-gom-histograms: #2fbf6a;
    --nxs-import-phase-importing-gom-dimensions: #9b7fe0;
    --nxs-import-phase-importing-machine-run: #e0a96d;
    --nxs-import-phase-linking-external-cmm-nodes: var(--nxs-import-phase-importing-gom-dimensions);
    --nxs-import-phase-creating-preview-meshopt-bundle: #b980e6;
    --nxs-import-phase-persisting-melt-pool-measurements: #5bd7b4;
    --nxs-import-phase-creating-melt-pool-thumbnails: #d3ab61;
    --nxs-import-phase-recording-result: #c7ce81;
    --nxs-import-phase-sending-recovery-notification: #e98d75;
    --nxs-import-phase-processing-recovery-reply: #d898b5;
    --nxs-import-phase-syncing-recovery-to-airtable: #73afb3;
    --nxs-import-phase-retrieving-route-card: #8fb3d9;
    --nxs-import-phase-synchronising-route-card: #6f9ec4;
    --nxs-import-phase-hot-fire-fetching: #e0a96d;
    --nxs-import-phase-hot-fire-parsing: #d4876a;
    --nxs-import-phase-hot-fire-saving: #c26a5a;
    --nxs-import-phase-completed: #81ce94;
    --nxs-import-phase-failed: var(--nxs-danger);

    /* Turbo heat-map palette — eight evenly spaced stops ordered low → high and shared
       by rendered data and its legend so the scale precisely represents the display. */
    --nxs-heatmap-stop-0: #466be3;
    --nxs-heatmap-stop-1: #29bbec;
    --nxs-heatmap-stop-2: #31f199;
    --nxs-heatmap-stop-3: #a3fd3d;
    --nxs-heatmap-stop-4: #edd03a;
    --nxs-heatmap-stop-5: #fb8022;
    --nxs-heatmap-stop-6: #d23105;
    --nxs-heatmap-stop-7: #7a0403;

    /* Machine comparison palette — cycled by slot when a chart plots several machines together,
       and mirrored by ChartPalette.MachineSeries so a trace and the menu entry that selects it
       agree on the colour. */
    --nxs-machine-series-0: #e53935;
    --nxs-machine-series-1: #8e24aa;
    --nxs-machine-series-2: #3949ab;
    --nxs-machine-series-3: #00897b;
    --nxs-machine-series-4: #f4511e;
    --nxs-machine-series-5: #6d4c41;

    /* ChartPalette.Series slots used by the machine-run sensor selectors. */
    --nxs-chart-series-0: #00c8ff;
    --nxs-chart-series-4: #7c4dff;
    --nxs-chart-series-5: #ff9100;
    --nxs-chart-series-6: #2979ff;
    --nxs-chart-series-8: #e040fb;
    --nxs-chart-series-9: #1de9b6;

    /* Process palette */
    --nxs-process-default: #5ac9dd;
    --nxs-process-am-build: #5de7ff;
    --nxs-process-heat-treatment: #ffb86b;
    --nxs-process-tumbling: #e68ae0;
    --nxs-process-cnc: #94baff;
    --nxs-process-cmm: #7ee4a5;
    --nxs-process-gom: #c7a7ff;
    --nxs-tag-blue: #00bcd4;        /* NxsTagChip blue */
    --nxs-tag-green: #7ee4a5;       /* NxsTagChip green */
    --nxs-tag-purple: #c7a7ff;      /* NxsTagChip purple */
    --nxs-process-ct: #ff8c8c;
    --nxs-process-surface-roughness: #3dbef5;
    --nxs-process-radiography: #ff9ff3;
    --nxs-process-thermal-camera: #ff9f7a;
    --nxs-process-tensile: #ffd86b;
    --nxs-process-fatigue: #8fb2ff;
    --nxs-process-sem: #9ccb4a;
    --nxs-process-bearing-flow: #45d6a8;

    /* Status foreground/border — light variants for pass/fail chips on the *-bg fills above
       (the dark --nxs-danger/-success can't be used as foreground text; they're fills). */
    --nxs-success-text: #86f7ae;   /* pass chip text/icon */
    --nxs-success-border: #2fbf6a; /* pass chip border */
    --nxs-danger-text: #ff7f7f;    /* fail chip text/icon */
    --nxs-danger-border: #bf4248;  /* fail chip border */
    --nxs-success-text-14: color-mix(in srgb, var(--nxs-success-text) 14%, transparent); /* pass pill fill */
    --nxs-danger-text-14: color-mix(in srgb, var(--nxs-danger-text) 14%, transparent);   /* fail pill fill */

    /* Info / highlight — bright sky-blue foreground (pairs with --nxs-info-bg); absorbs the
       drifting #67d5ff/#7dc9ff/#54d8e6 highlight blues. Tints via color-mix, like the accent. */
    --nxs-info: #67d5ff;
    --nxs-info-8:  color-mix(in srgb, var(--nxs-info) 8%, transparent);
    --nxs-info-20: color-mix(in srgb, var(--nxs-info) 20%, transparent);

    /* White overlays — fixed opacity ladder. Round any raw rgba(255,255,255,a) to the nearest
       step. NOTE: higher white-alphas (>=~0.42) are muted/near-opaque TEXT, not overlays —
       use the --nxs-text-* ladder for those, not these tokens. */
    --nxs-overlay-3:  rgba(255, 255, 255, 0.03); /* faintest fills / zebra (absorbs 0.02–0.04) */
    --nxs-overlay-8:  rgba(255, 255, 255, 0.08); /* hover / active fill (absorbs 0.06–0.10) */
    --nxs-overlay-12: rgba(255, 255, 255, 0.12); /* dividers / hairlines */
    --nxs-overlay-20: rgba(255, 255, 255, 0.20); /* visible borders (absorbs 0.16–0.24) */
    --nxs-overlay-32: rgba(255, 255, 255, 0.32); /* strong borders / emphasis (absorbs 0.28–0.35) */

    /* Back-compat aliases — existing names now map onto the ladder steps */
    --nxs-overlay-subtle: var(--nxs-overlay-3);
    --nxs-overlay-hover:  var(--nxs-overlay-8);

    /* Scrollbars — one site-wide thumb; the transparent track reveals its owning surface. */
    --nxs-scrollbar-thumb: var(--nxs-overlay-20);

    /* Accent tints — brand accent at low alpha, derived from --nxs-accent so they stay in sync.
       Same step numbers as the white ladder. */
    --nxs-accent-8:  color-mix(in srgb, var(--nxs-accent) 8%, transparent);  /* faint wash (absorbs 0.08–0.12) */
    --nxs-accent-20: color-mix(in srgb, var(--nxs-accent) 20%, transparent); /* chip / selected-row fill (absorbs 0.15–0.18) */
    --nxs-accent-30: color-mix(in srgb, var(--nxs-accent) 30%, transparent); /* chip border / strong tint (absorbs 0.30–0.35) */

    /* Row selection — the house selected-row treatment (see .nxs-grid__row--selected):
       accent tint + a white hairline around each contiguous selected block. An accent
       HUE (not a neutral lift) keeps selection visible on any housing surface and distinct
       from hover; adjacent selected rows merge into one surface without doubled seams. */
    --nxs-row-selected-bg: var(--nxs-accent-20);
    --nxs-row-selected-line: rgba(255, 255, 255, 0.75);

    /* Scrims / shadow — black-alpha axis */
    --nxs-scrim:  rgba(0, 0, 0, 0.6);  /* modal / backdrop scrim (absorbs 0.35–0.72) */
    --nxs-shadow: rgba(0, 0, 0, 0.22); /* drop shadows (absorbs 0.2/0.24) */
    --nxs-surface-veil: rgba(18, 18, 18, 0.35); /* translucent dark veil for in-content loading/disabled overlays (absorbs 0.28–0.38) */
}

/* Autofill follows the painted field surface. Labels remain transparent and use a
   gap in the outline instead of a background mask. Shared custom surfaces override
   the autofill backdrop alongside their own background declaration. */
.mud-paper,
.mud-dialog,
.mud-expand-panel,
.mud-table,
.mud-tabs-tabbar {
    --nxs-field-backdrop: var(--mud-palette-surface);
}

.mud-input-label-outlined {
    /* Also override older scoped surface masks; no field state may paint a label fill. */
    background: transparent !important;
}

.mud-input-control {
    --nxs-field-label-inset: calc(var(--nxs-space-12) + var(--nxs-space-2));
}

/* MudBlazor's dialog content is a scroll container with no top padding (its gap to the
   title is a margin), so it clips anything painted above its top edge. A dialog that opens
   with an outlined field loses the top half of that field's floating label. Trading the
   margin for padding keeps every dialog's layout identical while giving the label room.
   Workflow dialogs set their own content padding below. */
.mud-dialog:not(.nxs-dialog--workflow) .mud-dialog-content {
    margin-top: 0;
    padding-top: var(--nxs-space-8);
}

/* Browser autofill uses the field's neutral surface.
   Chromium's autofill background is !important in its user-agent stylesheet;
   an inset shadow covers that fill without hiding the field outline or focus. */
.mud-input-root:is(:autofill, :-webkit-autofill) {
    box-shadow: 0 0 0 100vmax var(--nxs-field-backdrop, var(--nxs-bg)) inset;
    -webkit-text-fill-color: var(--nxs-text);
    caret-color: var(--nxs-text);
}

/* Ordinary outlined fields align by their visible body, not their floating label.
   Keep grid cells/popup editors and specialist composers on their own contracts.
   Geometry uses !important only where vendor density rules otherwise reintroduce
   padding/headroom; real helper/validation rows remain in normal document flow. */
.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)):has(> .mud-input-control-input-container > .mud-input-outlined) {
    margin-block: 0 !important;
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined:not(:has(textarea)) {
    height: var(--nxs-control-h-form);
    min-height: var(--nxs-control-h-form);
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined > .mud-input-root:not(textarea):not(.mud-input-root-multiline) {
    box-sizing: border-box;
    height: var(--nxs-control-h-form);
    padding-block: 0 !important;
}

/* Select renders its displayed value in a div, while text/numeric/date controls
   use an input. Both occupy the same body and centre their text within it. */
.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined > div.mud-input-root:not(.mud-input-root-multiline):not([style*="display:none"]):not([style*="display: none"]) {
    display: flex !important;
    align-items: center;
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined .mud-input-numeric-spin {
    height: var(--nxs-control-h-form);
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined .mud-input-numeric-spin button {
    height: 50%;
    padding-block: 0;
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined .mud-input-numeric-spin .mud-icon-root {
    height: 100%;
}

/* Label typography is shared even when compact controls retain native body geometry. */
.mud-input-control > .mud-input-control-input-container > .mud-input-label-outlined {
    font-size: var(--nxs-text-size-sm);
    font-weight: 400;
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container:not(:has(textarea)) > .mud-input-label-outlined {
    transform: translate(var(--nxs-field-label-inset), calc(var(--nxs-control-h-form) / 2 - 50%));
    background: transparent;
}

.mud-input-control:not(:where(.mud-table-cell *, .k-grid *, .k-filter-menu *, .k-popup *, .mud-popover *, .nxs-input-shell *, .nxs-numeric-override *, .matrix-search-input, .matrix-search-input *)) > .mud-input-control-input-container > .mud-input-outlined .mud-input-adornment-icon-button {
    width: var(--nxs-control-h-form);
    height: var(--nxs-control-h-form);
    padding: var(--nxs-space-6);
}

/* Floating moves the label without scaling its type or required marker.
   This applies to ordinary fields and compact editors; body sizing remains separate.
   NxsSelect can render selected option content in a div while its underlying value
   is empty (for example, New filter). That visible content must also float the label;
   an empty native input still follows the normal empty-field behaviour. */
.mud-input-control > .mud-input-control-input-container > :is(.mud-shrink, .mud-input:focus-within) ~ label.mud-input-label.mud-input-label-outlined,
.nxs-select .mud-input:has(> div.mud-input-slot:not(:empty)) ~ label.mud-input-label.mud-input-label-outlined {
    font-size: var(--nxs-text-size-sm);
    font-weight: 400;
    transform: translate(var(--nxs-field-label-inset), -50%);
}

/* App.razor.js measures the unscaled label, including required markers and translated
   text. Cut only the top border when the label floats; the label never paints a fill.
   Use the same input state as the label, without an additional ancestor :has() condition:
   selecting a null option must not invalidate the focused field's notch. Without a
   measured label width the clip is invalid, so unlabelled fields keep their full outline. */
.mud-input-control > .mud-input-control-input-container > :is(.mud-shrink, .mud-input:focus-within) > .mud-input-outlined-border,
.nxs-select .mud-input:has(> div.mud-input-slot:not(:empty)) > .mud-input-outlined-border {
    --nxs-outline-notch-start: calc(var(--nxs-field-label-inset) - var(--nxs-space-2));
    --nxs-outline-notch-end: calc(var(--nxs-field-label-inset) + var(--nxs-outline-label-width) + var(--nxs-space-2));
    clip-path: polygon(0 0,
        var(--nxs-outline-notch-start) 0,
        var(--nxs-outline-notch-start) var(--nxs-space-2),
        var(--nxs-outline-notch-end) var(--nxs-space-2),
        var(--nxs-outline-notch-end) 0,
        100% 0, 100% 100%, 0 100%);
}

/* Native Bootstrap-backed single-line editors have no floating label but still
   participate in the same ordinary form rows. Textareas keep their natural height. */
:is(input.form-control:not([type="file"]), select.form-control, select.form-select):not(:where(.k-grid *, .mud-table-cell *)) {
    box-sizing: border-box;
    height: var(--nxs-control-h-form);
    min-height: var(--nxs-control-h-form);
}

/* MudBlazor supplies the required marker as a label pseudo-element. Give the asterisk
   deliberate separation and keep it locked to MudBlazor's field error colour. */
.mud-input-control.mud-input-required > .mud-input-control-input-container > .mud-input-label::after {
    content: "✱";
    display: inline-block;
    margin-inline-start: var(--nxs-space-6);
    color: var(--mud-palette-error);
    font-size: 1em;
    line-height: 1;
    transform: translateY(-0.08em);
    vertical-align: middle;
}

/* A required marker is sufficient when no more specific validation guidance exists.
   Collapse MudBlazor's otherwise empty helper row while retaining genuine error copy. */
.mud-input-control-helper-container:has(> .mud-input-helper-text.mud-input-error > .me-auto:empty:only-child) {
    display: none;
}

/* Global scrollbar appearance. `!important` is intentional: the compiled Telerik theme ships
   component-specific scrollbar rules and is loaded before this stylesheet. The standard thin
   width replaces component geometry while the Nexus thumb stays universal and the track reveals
   its surface. */
* {
    scrollbar-color: var(--nxs-scrollbar-thumb) transparent !important;
    scrollbar-width: thin !important;
}

*::-webkit-scrollbar {
    display: block !important;
    width: auto !important;
    height: auto !important;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--nxs-scrollbar-thumb) !important;
    border: revert !important;
    border-radius: revert !important;
}

*::-webkit-scrollbar-track,
*::-webkit-scrollbar-corner {
    background-color: transparent !important;
}

/* Stable single-edge gutters. Keep this list centralized: component/page CSS owns overflow and
   sizing, while the app stylesheet owns gutter policy. Stable is reserved for the page scroll
   owner and for surfaces whose overflow toggles while the user is working in them — the page
   scroller changes overflow state on every navigation, and filter-as-you-type lists and form
   modal bodies (validation growing in place) pop their scrollbar mid-interaction, where a
   content jump under the pointer reads as a glitch. */
:where(
    article.content,
    .dropdown-container,
    .dropdown-container-expanded-animation,
    .nxs-modal__scroll-region,
    .nxs-virtualized-multi-select__list,
    .k-list-scroller,
    .k-list-content,
    .k-virtual-content,
    .k-virtual-scroller,
    .k-prompt-container
) {
    scrollbar-gutter: stable;
}

/* Everything else defaults to `auto`: bounded panels whose overflow is fixed for a given content
   set reclaim the edge, because a permanently reserved strip reads as lopsided padding while
   preventing a shift that rarely happens. The owners below are listed for documentation — they
   carry their own padding that absorbs the thin scrollbar (nav, rails, drawer panel bodies, chip
   boxes, read-only detail/chart windows), or are grids, where a reserved gutter additionally
   reads as an empty final column. */
:where(
    .nexus-nav,
    .agent-conversation-list,
    .nxs-drawer-panel__panel-body,
    .component-surface-roughness-selector__body,
    .chart-group-chips,
    .panx-text-artifact-dialog__content,
    .sfc-avg-comparison-content,
    .gom-histogram-dialog-content,
    .caliper-window-content,
    .airtable-attachment-container,
    .k-window-content,
    .nxs-grid .mud-table-container,
    .k-grid-content,
    .k-grid-content-locked,
    .nxs-sticky-grid-shell__scroll,
    .component-tensile-scroll
) {
    scrollbar-gutter: auto;
}

/* Symmetric gutters are reserved for scroll owners whose contents are intentionally centred.
   Keep the Agent selector explicit so its both-edges policy wins over generic scrollbar rules. */
.agent-messages {
    scrollbar-gutter: stable both-edges;
}

/* Explicit escape hatch for the rare surface where reclaiming the gutter is more important than
   preventing horizontal movement when a vertical scrollbar appears or disappears. */
.nxs-scrollbar-gutter-auto {
    scrollbar-gutter: auto !important;
}

/* NxsChip<T> — the site's standard chip primitive. Semantic wrappers such as
   NxsResultChip and NxsValueChip compose this, so the baseline chrome lives here. */
/* NxsPageHeader — title left, contextual actions right, centred on the title line.
   The row owns the gutter below itself and suppresses NxsTitle's own gutter so the
   actions sit level with the title and clear of tab bars/content underneath. Recipe
   mirrors the component-view header. */
.nxs-title {
    margin-bottom: var(--nxs-space-16);
}

.nxs-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nxs-space-16);
    flex-wrap: wrap;
    margin-bottom: var(--nxs-space-16);
    min-height: var(--nxs-control-h-lg);
    min-width: 0;
}

.nxs-page-header__title {
    min-width: 0;
}

.nxs-page-header__title .nxs-title {
    margin-bottom: 0;
}

.nxs-page-header__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--nxs-space-8);
    flex-wrap: wrap;
    max-width: 100%;
    min-width: 0;
}

/* NxsModal — one shared modal shell. Header and footer stay fixed while the body
   owns the scrollbar and follows the centralized stable-gutter policy above. */
.nxs-modal-overlay {
    position: fixed;
    inset: calc(var(--mud-appbar-height) - var(--mud-appbar-height) / 8) 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--nxs-space-24);
    overflow: hidden;
    overscroll-behavior: contain;
    background: var(--nxs-scrim);
    z-index: 1200;
}

.mud-paper.nxs-modal {
    --nxs-field-backdrop: var(--nxs-surface-2);
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: 100%;
    overflow: hidden;
    border: 1px solid var(--nxs-divider);
    border-radius: var(--nxs-radius-lg);
    background: var(--nxs-surface-2);
    color: var(--nxs-text-body);
}

.mud-paper.nxs-modal--wide {
    width: min(var(--nxs-dialog-workflow-max), 100%);
    container: nxs-modal / inline-size;
}

.nxs-modal--flush-content .nxs-modal__scroll-region {
    padding: 0;
    gap: 0;
}

/* Match MudMainContent's responsive app-bar offset so the scrim, centring and
   available modal height are always relative to the region below the header. */
@media (min-width: 0) and (orientation: landscape) {
    .nxs-modal-overlay {
        inset-block-start: calc(var(--mud-appbar-height) - var(--mud-appbar-height) / 4);
    }
}

@media (min-width: 600px) {
    .nxs-modal-overlay {
        inset-block-start: var(--mud-appbar-height);
    }
}

.nxs-modal__header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: var(--nxs-space-16);
    padding: var(--nxs-space-16) var(--nxs-space-20);
    border-bottom: 1px solid var(--nxs-overlay-hover);
    background: var(--nxs-surface-2);
}

.nxs-modal__header h4 {
    margin: 0;
    color: var(--nxs-text);
    font-size: 1.1rem;
    font-weight: 700;
}

.nxs-modal__title {
    flex: 1 1 auto;
    min-width: 0;
}

.nxs-modal__header-actions {
    display: flex;
    align-items: center;
    gap: var(--nxs-space-12);
}

/* Composed workflow headers keep their title readable in a narrow container.
   Ordinary modals retain their existing one-line header layout. */
@container nxs-modal (max-width: 600px) {
    .nxs-modal__header {
        flex-wrap: wrap;
    }

    .nxs-modal__title {
        flex-basis: 100%;
    }

    .nxs-modal__header-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        min-width: 0;
    }
}

.nxs-modal__scroll-region {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--nxs-space-24);
    min-width: 0;
    min-height: 0;
    padding: var(--nxs-space-20) var(--nxs-space-20) var(--nxs-space-24);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--nxs-overlay-20) var(--nxs-surface-2);
}

/* A composed header can fill a short landscape viewport. Let the whole wide
   modal scroll there so its body remains readable instead of shrinking to a sliver. */
@media (max-height: 500px) {
    .mud-paper.nxs-modal--wide {
        overflow-y: auto;
    }

    .nxs-modal--wide .nxs-modal__scroll-region {
        flex: 0 0 auto;
        overflow: visible;
    }
}

.nxs-modal__footer {
    flex: 0 0 auto;
    padding: var(--nxs-space-16) var(--nxs-space-20);
    border-top: 1px solid var(--nxs-divider);
    background: var(--nxs-surface-2);
}

.nxs-modal__veil {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--nxs-surface-veil);
    z-index: 1;
}

@media (max-width: 600px) {
    .nxs-modal-overlay {
        padding: var(--nxs-space-16);
    }

    .mud-paper.nxs-modal {
        width: 100%;
        max-height: 100%;
    }
}

.nxs-chip.mud-chip {
    border: 1px solid var(--nxs-border-strong);
    border-radius: var(--nxs-radius-pill);
    background: var(--nxs-overlay-8);
    color: var(--nxs-text-body);
    font-weight: 700;
}

/* NxsChip<T> selected state — neutral selectable pills use MudChip's built-in Selected
   property plus this shared visual treatment on the whole chip. */
.nxs-chip.is-selected.mud-chip {
    border-color: var(--nxs-accent);
    color: var(--nxs-text);
    opacity: 1;
}

/* NxsOverflowChip's popover. MudPopover's element is rendered by the popover provider outside the
   component, so the component's scoped CSS cannot reach it. This is the one rule of the copy and
   overflow chips that stays global; the rest are in their .razor.css files. */
.nxs-overflow-chip__popover.mud-popover {
    transition-duration: var(--nxs-motion-duration-reveal);
}

@media (prefers-reduced-motion: reduce) {
    .nxs-overflow-chip__popover.mud-popover {
        transition: none;
    }
}

.nxs-chip.mud-chip-color-success {
    border-color: var(--nxs-success-border);
    background: color-mix(in srgb, var(--nxs-success-text) 20%, transparent);
    color: var(--nxs-success-text);
}

.nxs-chip.mud-chip-color-error {
    border-color: var(--nxs-danger-border);
    background: color-mix(in srgb, var(--nxs-danger-text) 20%, transparent);
    color: var(--nxs-danger-text);
}

.nxs-chip.mud-chip-color-warning {
    border-color: var(--nxs-warning);
    background: color-mix(in srgb, var(--nxs-warning) 24%, transparent);
    color: color-mix(in srgb, var(--nxs-warning) 45%, var(--nxs-text));
}

.nxs-chip.mud-chip-color-info {
    border-color: var(--nxs-info);
    background: var(--nxs-info-20);
    color: var(--nxs-info);
}

.nxs-chip.mud-chip-color-secondary {
    border-color: var(--nxs-overlay-32);
    background: var(--nxs-overlay-12);
    color: var(--nxs-text-subtle);
}

.nxs-chip.mud-chip-color-primary {
    border-color: var(--nxs-accent-30);
    background: var(--nxs-accent-20);
    color: var(--nxs-accent);
}

.nxs-chip.nxs-sem-sample-condition--as-built {
    border-color: color-mix(in srgb, var(--nxs-process-am-build) 30%, transparent);
    background: color-mix(in srgb, var(--nxs-process-am-build) 20%, transparent);
    color: var(--nxs-process-am-build);
}

.nxs-chip.nxs-sem-sample-condition--heat-treated {
    border-color: color-mix(in srgb, var(--nxs-process-heat-treatment) 30%, transparent);
    background: color-mix(in srgb, var(--nxs-process-heat-treatment) 20%, transparent);
    color: var(--nxs-process-heat-treatment);
}

.nxs-chip.nxs-result-chip--pass {
    border-color: var(--nxs-success-border);
    background: color-mix(in srgb, var(--nxs-success-text) 20%, transparent);
    color: var(--nxs-success-text);
}

.nxs-chip.nxs-result-chip--fail {
    border-color: var(--nxs-danger-border);
    background: color-mix(in srgb, var(--nxs-danger-text) 20%, transparent);
    color: var(--nxs-danger-text);
}

/* NxsStatusChip - rounded state pill; tone picks the colour. */
.nxs-chip.nxs-status-chip--good {
    border-color: var(--nxs-success-border);
    background: color-mix(in srgb, var(--nxs-success-text) 20%, transparent);
    color: var(--nxs-success-text);
}

.nxs-chip.nxs-status-chip--attention {
    border-color: var(--nxs-warning);
    background: color-mix(in srgb, var(--nxs-warning) 24%, transparent);
    color: var(--nxs-warning);
}

.nxs-chip.nxs-status-chip--bad {
    border-color: var(--nxs-danger-border);
    background: color-mix(in srgb, var(--nxs-danger-text) 20%, transparent);
    color: var(--nxs-danger-text);
}

/* NxsTagChip - outlined tag with square corners (a quarter of the small radius, so it reads
   as a tag and not a pill); colour picks the outline and text. */
.nxs-chip.nxs-tag-chip {
    border-radius: calc(var(--nxs-radius-sm) / 2);
    background: transparent;
    color: var(--nxs-text-muted);
}

.nxs-chip.nxs-tag-chip--blue {
    border-color: var(--nxs-tag-blue);
    color: var(--nxs-tag-blue);
}

.nxs-chip.nxs-tag-chip--green {
    border-color: var(--nxs-tag-green);
    color: var(--nxs-tag-green);
}

.nxs-chip.nxs-tag-chip--purple {
    border-color: var(--nxs-tag-purple);
    color: var(--nxs-tag-purple);
}

.nxs-chip.nxs-tag-chip--red {
    border-color: var(--nxs-danger-border);
    color: var(--nxs-danger-text);
}

.nxs-chip.nxs-tag-chip--amber {
    border-color: var(--nxs-warning);
    color: var(--nxs-warning);
}

/* NxsRemovableChip — dismissible token pills (applied search filters, saved presets).
   Structure/radius come from .nxs-chip above; these supply the neutral base look and an
   accent variant, plus tame the built-in MudChip close button to the token scale. Colour
   isn't a bespoke prop — it rides MudBlazor's Color: Color.Default = neutral base here,
   Color.Primary adds .mud-chip-color-primary which we repaint with the accent tokens.
   Placed after the .nxs-chip rules so the background/border/colour win on equal specificity. */
.nxs-chip.nxs-removable-chip {
    min-height: var(--nxs-control-h-md);
    height: auto;
    font-size: var(--nxs-text-size-md);
    font-weight: 500;
    border-color: var(--nxs-overlay-20);
    background: var(--nxs-overlay-subtle);
    color: var(--nxs-text);
}

.nxs-chip.nxs-removable-chip.mud-chip-color-primary {
    border-color: var(--nxs-accent-30);
    background: var(--nxs-accent-20);
    color: var(--nxs-accent);
}

.nxs-removable-chip .mud-chip-close-button {
    color: inherit;
    opacity: 0.7;
}

.nxs-removable-chip .mud-chip-close-button:hover {
    opacity: 1;
}

.nxs-removable-chip:not(.mud-chip-color-primary) .mud-chip-close-button:hover {
    color: var(--nxs-danger);
}

/* NxsDataGrid<T> — the site's standard data grid: one cohesive dark rounded panel
   (toolbar + header + rows), matching the metrology grids. Striping off / elevation 0 /
   outlined are forced in the component; the rules here cover what props can't express. */
.nxs-grid.mud-table {
    --nxs-field-backdrop: var(--nxs-surface);
    background: var(--nxs-surface);
    border-radius: var(--nxs-radius-lg);
    overflow: hidden; /* clip the square table to the rounded panel corners */
}

.nxs-grid .mud-table-container,
.nxs-grid .mud-table-body .mud-table-row {
    background: var(--nxs-surface);
}

/* A grid without a Height grows with its rows and must never scroll vertically. Mud gives the
   container `overflow-y: auto; max-height: 100%`; inside a CSS grid or flex parent the stretched
   root has a definite height, so 100% resolves to the root's content box — 2px short of the rows
   because of the outline — and a full-height scrollbar appears for those two pixels. Mud writes
   an explicit Height as an inline style on the container, so those grids keep their cap. */
.nxs-grid .mud-table-container:not([style*="height"]) {
    max-height: none;
}

/* MudDataGrid emits an empty footer row even without footer content. That makes
   tbody cease to be the last child, bypassing Mud's final-row border reset and
   doubling the grid's bottom outline. Keep separators above populated footers. */
.nxs-grid .mud-table-root:not(:has(> .mud-table-foot td, > .mud-table-foot th)) > .mud-table-body:last-of-type > .mud-table-row:last-child > .mud-table-cell {
    border-bottom: none;
}

/* The root panel does ALL the rounding (overflow:hidden clip). Everything inside stays
   square — inner radii draw curved seams where they meet the optional toolbar. Square=true
   in the component disables Mud's normal panel rounding, but FixedHeader grids get a
   SEPARATE rounding from `.mud-table-sticky-header * ... .mud-table-cell:first-child`
   (specificity 0,5,0 — independent of Square), so the sticky-header selectors below must
   carry 0,6,0 to win. */
.nxs-grid .mud-table-container,
.nxs-grid .mud-table-toolbar,
.nxs-grid.mud-table-sticky-header .mud-table-root .mud-table-head .mud-table-cell:first-child,
.nxs-grid.mud-table-sticky-header .mud-table-root .mud-table-head .mud-table-cell:last-child,
.nxs-grid .mud-table-head .mud-table-cell:first-child,
.nxs-grid .mud-table-head .mud-table-cell:last-child {
    border-radius: 0;
}

/* Toolbar geometry is OURS. Mud's .mud-toolbar sets a FIXED height (64px) and gutter
   padding (0 8px 0 16px) — both read unbalanced next to the content. Content-driven
   height, uniform 12px padding. */
.nxs-grid .mud-table-toolbar {
    height: auto;
    min-height: 0;
    padding: var(--nxs-space-12);
    gap: var(--nxs-space-12);
    border-bottom: 1px solid var(--nxs-border);
}

/* Opt-in for list toolbars whose combined filters exceed a constrained viewport. */
.nxs-grid.nxs-grid--wrap-toolbar .mud-table-toolbar {
    flex-wrap: wrap;
}

/* NxsGridTitle — compact, consistently weighted title for embedded grid toolbars. */
.nxs-grid-title {
    font-weight: 700;
}

/* Grid toolbars own their visible inter-control gap. Offset the standard switch's
   leading track inset and remove its trailing margin so it uses the toolbar gap. */
.nxs-grid .mud-table-toolbar .mud-switch {
    margin-inline-start: calc(-1 * var(--nxs-space-12)) !important;
    margin-inline-end: 0 !important;
}

/* Standard search field (NxsSearchField): fixed width WHEREVER it appears — a default
   MudTextField is full-width and stretches edge-to-edge. Pages may override per layout
   (e.g. full-width on narrow screens) via a ::deep rule on their own class. */
.nxs-search {
    /* The 360px is a WIDTH, not a flex-basis. A basis is measured along the main axis, so in a
       toolbar that stacks its filters (flex-direction: column on narrow screens) a basis of 360px
       became the field's height and left a ~320px hole under a 40px input. */
    flex: 0 1 auto;
    width: 360px;
    min-width: 180px;
}

/* MudSelect popovers render outside the component subtree, so NxsFilterDropdown
   supplies this class via PopoverClass rather than relying on scoped CSS. */
.nxs-filter-dropdown__popover,
.nxs-filter-dropdown__popover .mud-paper,
.nxs-filter-dropdown__popover .mud-list {
    border-top-left-radius: 0 !important;
    min-width: 190px;
    max-width: min(320px, calc(100vw - var(--nxs-space-32)));
}

.nxs-filter-dropdown__popover .mud-list-item,
.nxs-filter-dropdown__popover .mud-list-item-text {
    min-width: 0;
}

.nxs-filter-dropdown__popover .nxs-filter-dropdown__option-text {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* MudSelect renders its menu at the document root. Keep this workflow-specific
   menu above Telerik's dynamically incremented stack of nested windows. */
.scanfield-average-summary-scale-popover {
    z-index: 11000 !important;
}

/* Uniform with toolbar + rows; row hover is the only lift. The sticky-header variant must
   carry 0,5,0 specificity: FixedHeader grids get their header background from Mud's
   `.mud-table-sticky-header * .mud-table-root .mud-table-head * .mud-table-cell` (0,4,0),
   which beats a plain 0,3,0 override. Keep this OPAQUE — rows scroll under the sticky head. */
.nxs-grid .mud-table-head .mud-table-cell,
.nxs-grid.mud-table-sticky-header .mud-table-root .mud-table-head .mud-table-cell {
    background: var(--nxs-surface);
}

/* Outlined labels paint above their input borders. Editable body cells need
   clearance even in dense grids; keep display cells and filter toolbars compact. */
.nxs-grid .mud-table-body .mud-table-cell:has(.mud-input-label-outlined) {
    padding-block: var(--nxs-space-16);
}

/* Flush: the grid is nested in something that already owns the boundary — a detail row or an
   expansion panel — so it contributes no panel of its own and the host's surface shows through.
   Prefixed with .nxs-grid to out-specify the panel rules above. */
.nxs-grid.nxs-grid--flush.mud-table {
    background: transparent;
    border: 0;
    border-radius: 0;
}

.nxs-grid.nxs-grid--flush .mud-table-container,
.nxs-grid.nxs-grid--flush .mud-table-body .mud-table-row,
.nxs-grid.nxs-grid--flush .mud-table-head .mud-table-cell {
    background: transparent;
}

/* Compact trailing row actions — the icon group in a grid's last column. One rule for every
   grid, so a measurement family does not re-declare the same flex row in its own stylesheet. */
.nxs-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--nxs-space-2);
    width: 100%;
}

.nxs-grid .mud-table-body .mud-table-row:hover > .mud-table-cell {
    --nxs-field-backdrop: var(--nxs-surface-raised);
    background: var(--nxs-surface-raised);
}

/* NxsDataGrid Striping: a faint overlay on alternate body rows or columns. It is a background
   image, so it layers over the surface, hover and selected fills rather than replacing them.
   Rows count only data rows: child/detail rows (a single colspan cell) would otherwise shift
   the banding, e.g. EndOfListContent puts one after every row. */
.nxs-grid.nxs-grid--stripe-rows .mud-table-body > .mud-table-row:nth-child(even of :not(:has(> .mud-table-cell[colspan]))) > .mud-table-cell,
.nxs-grid.nxs-grid--stripe-columns .mud-table-body > .mud-table-row > .mud-table-cell:nth-child(even):not([colspan]) {
    background-image: linear-gradient(var(--nxs-overlay-3), var(--nxs-overlay-3));
}

/* Links in body cells inherit the cell's typography instead of MudLink's body1
   default, so linked and plain values in the same column render at the same size.
   Pages should not set Typo on grid row links. */
.nxs-grid .mud-table-body .mud-table-cell .mud-link {
    font-size: inherit;
    line-height: inherit;
}

/* NxsDataGrid EndOfListContent: MudDataGrid follows every row with a full-width child row, and
   only the last row's carries the end-of-list content. The empty ones are hidden so they add no
   height between rows. The content row is not a data row, so it takes no hover lift. */
.nxs-grid.nxs-grid--end-of-list .mud-table-body > .mud-table-row:has(> .mud-table-cell[colspan]:empty) {
    display: none;
}

.nxs-grid.nxs-grid--end-of-list .mud-table-body > .mud-table-row:has(> .mud-table-cell[colspan]):hover > .mud-table-cell {
    background: transparent;
}

/* Master-detail row selection — the house treatment: accent-tint fill + one hairline
   around each contiguous selected block. Both classes are emitted by NxsDataGrid itself: the root
   `nxs-grid--clickable-rows` whenever a RowClick handler is wired, and
   `nxs-grid__row--selected` on rows matching the page's IsRowSelected predicate. Pages
   never write these class names. The :hover variant must be stated (and sit after the
   generic hover lift above) so the selected fill survives hover. Mud's ordinary cell
   divider is suppressed around selected blocks so it cannot double the hairline. */
.nxs-grid.nxs-grid--clickable-rows .mud-table-body .mud-table-row {
    cursor: pointer;
}

.nxs-grid .mud-table-body .nxs-grid__row--selected > .mud-table-cell,
.nxs-grid .mud-table-body .nxs-grid__row--selected:hover > .mud-table-cell {
    --nxs-selected-block-top-line: transparent;
    --nxs-selected-block-bottom-line: transparent;

    background: var(--nxs-row-selected-bg);
    border-bottom-color: transparent;
    box-shadow: inset 0 1px 0 var(--nxs-selected-block-top-line),
                inset 0 -1px 0 var(--nxs-selected-block-bottom-line);
}

/* Remove the normal separator immediately above a selected block. The selected block's
   own top hairline is the only boundary that should remain. */
.nxs-grid .mud-table-body .mud-table-row:has(+ .nxs-grid__row--selected) > .mud-table-cell {
    border-bottom-color: transparent;
}

/* A selected row starts a block when it is the first row or follows an unselected row. */
.nxs-grid .mud-table-body > .nxs-grid__row--selected:first-child > .mud-table-cell,
.nxs-grid .mud-table-body > .mud-table-row:not(.nxs-grid__row--selected) + .nxs-grid__row--selected > .mud-table-cell {
    --nxs-selected-block-top-line: var(--nxs-row-selected-line);
}

/* A selected row ends a block when the next row is not selected (or there is no next row). */
.nxs-grid .mud-table-body > .nxs-grid__row--selected:not(:has(+ .nxs-grid__row--selected)) > .mud-table-cell {
    --nxs-selected-block-bottom-line: var(--nxs-row-selected-line);
}

/* No-records and loading rows: Mud paints both var(--mud-palette-surface) — a lighter
   shade than the grid panel, so they read as a stray band. Pin them to the panel surface.
   The sticky-header loading selector needs 0,5,0 to beat Mud's 0,4,0 (same story as the
   header cells above). */
.nxs-grid .nxs-unit-header,
.nxs-grid .nxs-unit-header * {
    --mud-typography-body2-text-transform: none;
    --mud-typography-button-text-transform: none;
    --mud-typography-subtitle2-text-transform: none;
    text-transform: none !important;
}

.nxs-grid .mud-table-empty-row,
.nxs-grid.mud-table-sticky-header .mud-table-root .mud-table-head .mud-table-loading {
    background-color: var(--nxs-surface);
}

.nxs-grid:has(.mud-table-loading) {
    cursor: wait;
}

.nxs-grid .mud-table-loading {
    display: none !important;
}

.nxs-grid .mud-table-empty-row .mud-table-cell {
    padding-block: var(--nxs-space-24);
}

/* Empty grids collapse to their message instead of reserving a viewport/grid footprint. This
   overrides both NxsDataGrid's FillViewport height and any 100% shell sizing on the no-records
   path. First-load grids deliberately keep their sized footprint: collapsing to the spinner
   and expanding again when rows arrive makes the panel and pager jump on every list page. */
.mud-table:has(> .mud-table-container > .mud-table-root > .mud-table-body > .mud-table-empty-row .nxs-empty-state) {
    height: auto !important;
}

.mud-table:has(> .mud-table-container > .mud-table-root > .mud-table-body > .mud-table-empty-row .nxs-empty-state) > .mud-table-container {
    flex: 0 0 auto;
    min-height: 0;
    height: auto !important;
}

/* MudSwitch unchecked track: Mud paints it var(--mud-palette-black) at 48% opacity — and
   our palette Black IS --nxs-surface, so on surface panels the track is invisible (only the
   thumb shows). Lift it to the raised-fill token, full opacity. Checked state is unaffected:
   Mud's .mud-checked rules out-specify this and keep the accent track. */
.mud-switch-span .mud-switch-track {
    background-color: var(--nxs-surface-3);
    opacity: 1;
}

/* NxsButton — the standard primary action button: accent fill, dark text.
   .mud-button-root included for specificity over Mud's filled-primary colours. */
.mud-button-root.nxs-btn {
    --nxs-button-boundary-color: var(--nxs-accent);
    background: var(--nxs-button-boundary-color);
    color: var(--nxs-surface);
}

.mud-button-root.nxs-btn:hover,
.mud-button-root.nxs-btn:focus-visible {
    --nxs-button-boundary-color: var(--nxs-accent-bright);
    background: var(--nxs-button-boundary-color);
}

/* Nexus action buttons have one exact shared height rather than Mud's
   typography-and-padding-derived size variants. */
.mud-button-root.nxs-btn-action {
    box-sizing: border-box;
    height: var(--nxs-control-h-lg);
    min-height: var(--nxs-control-h-lg);
    padding: 0 var(--nxs-space-16);
    white-space: nowrap;
}

/* Compact standalone icon actions share one outlined, tokenized control boundary. */
.mud-icon-button.nxs-icon-button--outlined {
    box-sizing: border-box;
    width: var(--nxs-control-h-sm);
    min-width: var(--nxs-control-h-sm);
    height: var(--nxs-control-h-sm);
    min-height: var(--nxs-control-h-sm);
    padding: 0;
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-md);
}

/* NxsAsyncButton keeps a fixed trailing slot so replacing its action icon with the
   standard spinner never changes the button's dimensions. */
.mud-button-root.nxs-async-button {
    padding: 0 var(--nxs-space-12);
}

.nxs-async-button__content {
    display: inline-flex;
    align-items: center;
    gap: var(--nxs-space-12);
}

/* IconFirst: the icon slot, and so the spinner, sits before the text, matching buttons with a leading icon. */
.nxs-async-button--icon-first .nxs-async-button__icon {
    order: -1;
}

.nxs-async-button__icon {
    display: inline-flex;
    flex: 0 0 var(--nxs-space-20);
    align-items: center;
    justify-content: center;
    width: var(--nxs-space-20);
    height: var(--nxs-space-20);
    min-width: 0;
    min-height: 0;
    line-height: 0;
}

.nxs-async-button__icon .mud-icon-root,
.nxs-async-button__icon .nxs-async-button__spinner {
    display: block;
    flex: none;
    margin: 0;
}

/* NxsButton secondary (Kind="Secondary"): outlined accent for actions beside a primary button. */
.mud-button-root.nxs-btn-secondary {
    --nxs-button-boundary-color: var(--nxs-border-strong);
    background: transparent;
    color: var(--nxs-accent);
    border: 1px solid var(--nxs-button-boundary-color);
}

.mud-button-root.nxs-btn-secondary:hover,
.mud-button-root.nxs-btn-secondary:focus-visible {
    --nxs-button-boundary-color: var(--nxs-accent);
    background: var(--nxs-accent-8);
    border-color: var(--nxs-button-boundary-color);
    color: var(--nxs-accent-bright);
}

/* NxsButton neutral (Kind="Neutral"): outlined grey for an action that must not compete with
   the accent actions on its surface, such as a pointer to another view. */
.mud-button-root.nxs-btn-neutral {
    --nxs-button-boundary-color: var(--nxs-border-strong);
    background: transparent;
    color: var(--nxs-text-body);
    border: 1px solid var(--nxs-button-boundary-color);
}

.mud-button-root.nxs-btn-neutral:hover,
.mud-button-root.nxs-btn-neutral:focus-visible {
    --nxs-button-boundary-color: var(--nxs-text-subtle);
    background: var(--nxs-overlay-8);
    color: var(--nxs-text);
}

/* NxsButton danger (Kind="Danger"): borderless red text for an action that deletes a record or
   stops its work, such as removing access or deleting a run. It is in the danger colour
   throughout (text, icon and hover tint), so the click that opens its confirmation cannot be
   mistaken for an ordinary one. The icon takes its colour from the variable. */
.mud-button-root.nxs-btn-danger {
    --nxs-button-boundary-color: var(--nxs-danger-text);
    background: transparent;
    color: var(--nxs-button-boundary-color);
}

.mud-button-root.nxs-btn-danger:hover,
.mud-button-root.nxs-btn-danger:focus-visible {
    background: var(--nxs-danger-bg);
    color: var(--nxs-button-boundary-color);
}

/* NxsButton text (Kind="Text"): borderless accent text for low-emphasis inline actions
   (e.g. an alert's retry). */
.mud-button-root.nxs-btn-text {
    --nxs-button-boundary-color: var(--nxs-accent);
    background: transparent;
    color: var(--nxs-button-boundary-color);
}

.mud-button-root.nxs-btn-text:hover,
.mud-button-root.nxs-btn-text:focus-visible {
    --nxs-button-boundary-color: var(--nxs-accent-bright);
    background: var(--nxs-accent-8);
    color: var(--nxs-button-boundary-color);
}

.mud-button-root.nxs-btn--attention-pulse-a {
    animation: nxs-button-attention-pulse-a 700ms ease-in-out 2;
}

.mud-button-root.nxs-btn--attention-pulse-b {
    animation: nxs-button-attention-pulse-b 700ms ease-in-out 2;
}

@keyframes nxs-button-attention-pulse-a {
    0%,
    100% {
        box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent;
    }

    50% {
        box-shadow:
            0 0 0 var(--nxs-space-4) color-mix(in srgb, var(--nxs-button-boundary-color) 34%, transparent),
            0 0 var(--nxs-space-16) var(--nxs-space-6) color-mix(in srgb, var(--nxs-button-boundary-color) 22%, transparent);
    }
}

@keyframes nxs-button-attention-pulse-b {
    0%,
    100% {
        box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent;
    }

    50% {
        box-shadow:
            0 0 0 var(--nxs-space-4) color-mix(in srgb, var(--nxs-button-boundary-color) 34%, transparent),
            0 0 var(--nxs-space-16) var(--nxs-space-6) color-mix(in srgb, var(--nxs-button-boundary-color) 22%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mud-button-root.nxs-btn--attention-pulse-a,
    .mud-button-root.nxs-btn--attention-pulse-b {
        animation: none;
    }
}

/* NxsInputShell — the house input pill shared by the global-search bar and the agent
   composer: flat outlined surface (no drop shadow, per the house panel style), leading
   action / input / trailing actions in one row. The --soft modifier is the rounded-rect
   variant for content that grows tall (multiline composer); narrow viewports soften the
   pill the same way. */
.mud-paper.nxs-input-shell {
    display: flex;
    align-items: center;
    gap: var(--nxs-space-8);
    width: 100%;
    min-width: 0;
    padding: var(--nxs-space-4) var(--nxs-space-12);
    background: var(--nxs-surface-2);
    border: 1px solid var(--nxs-border-strong);
    border-radius: var(--nxs-radius-pill);
    transition: border-color 120ms ease;
}

.mud-paper.nxs-input-shell:focus-within {
    border-color: var(--nxs-accent);
}

.mud-paper.nxs-input-shell.nxs-input-shell--soft {
    border-radius: var(--nxs-radius-lg);
    /* Tall-content variant: the input can grow to several lines, so the leading and
       trailing actions pin to the bottom edge (beside the newest line) instead of
       floating in the vertical middle of the block. */
    align-items: flex-end;
}

/* The bottom-pinned action slots are sized to exactly one text line's box (1.5rem
   line-height plus the input slot's two 8px pads) with the icon centred inside it.
   That centres the icons on the text at a single line AND keeps them centred on the
   newest line as the field grows — one rule, no per-state offsets. */
.nxs-input-shell--soft .nxs-input-shell__leading,
.nxs-input-shell--soft .nxs-input-shell__trailing {
    height: calc(1.5rem + (2 * var(--nxs-space-8)));
    align-items: center;
}

.nxs-input-shell__leading,
.nxs-input-shell__trailing {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.nxs-input-shell__content {
    flex: 1 1 auto;
    min-width: 0;
}

/* Inputs inside the shell render bare — the shell IS the field chrome, so a Mud
   outlined field placed in it must not draw a second border (focus feedback comes from
   the shell's focus-within accent). These target Mud's input internals deliberately:
   no Mud parameter can remove the outlined border, and the global-search input already
   establishes this bare-inside-the-pill treatment. !important because NxsFieldShell
   pins this element's border with its own !important state rules. */
.nxs-input-shell__content .mud-input-outlined-border {
    display: none !important;
    border: 0 !important;
}

.nxs-input-shell__content .mud-input-control {
    margin: 0;
}

.nxs-input-shell__content .mud-input-control-input-container {
    padding: 0;
}

.nxs-input-shell__content .mud-input-slot {
    padding: var(--nxs-space-8) 0;
    background: transparent;
}

@media (max-width: 640px) {
    .mud-paper.nxs-input-shell {
        border-radius: var(--nxs-radius-lg);
    }
}

/* NxsCard — the site's standard content card: outlined, padded, rounded panel with an
   optional titled header (MudText + divider) and an optional divider-anchored footer.
   Chrome is token-driven; lives here (global) so it reaches the MudPaper root without ::deep. */
.mud-paper.nxs-card {
    --nxs-field-backdrop: var(--nxs-surface-raised);
    padding: var(--nxs-space-card-inset);
    background: var(--nxs-surface-raised);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-lg);
}

/* A section panel on wide record views: the same surface and border as NxsFormSection, so
   read-only record sections match form pages, with a roomier inset. A section card is never
   also a chart card, so the two rules do not compete. */
.mud-paper.nxs-card.nxs-card--section {
    --nxs-space-card-inset: var(--nxs-space-24);
    background: var(--nxs-surface-2);
    border-color: var(--nxs-border);
}

/* Chart cards keep NxsCard spacing/chrome, but use the same surface as Plotly charts so
   chart margins and surrounding card padding read as one continuous chart surface. */
.mud-paper.nxs-card.nxs-chart-card {
    --nxs-field-backdrop: var(--nxs-surface);
    background: var(--nxs-surface);
}

/* A responsive row of chart cards, one chart per test record. */
.nxs-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 34rem), 1fr));
    gap: var(--nxs-space-16);
}

/* Empty charts size to their shared message, including inside stretching dashboard rows. */
.nxs-chart-card:has(.nxs-chart > .nxs-chart__plot > .nxs-empty-state) {
    align-self: start;
    min-height: 0;
    height: auto;
}

/* Telerik's no-records row otherwise retains a configured scrolling viewport. */
.k-grid:has(.k-grid-norecords .nxs-empty-state),
.k-grid:has(.k-grid-norecords .nxs-empty-state) .k-grid-content {
    min-height: 0;
    height: auto !important;
}

/* Geometry-viewer cards use their header divider as the exact top edge of the
   visualisation. The viewer host owns any spacing inside the body. */
.mud-paper.nxs-card.nxs-card--flush-viewer > .nxs-card__header {
    margin-bottom: 0;
}

/* Timeline cards share edge-to-edge dividers/scrollbars. Header/footer chrome owns
   its inset; the timeline and zoom controls own the spacing inside the body. */
.mud-paper.nxs-card.nxs-card--timeline {
    padding: 0;
}

.mud-paper.nxs-card.nxs-card--timeline > .nxs-card__header {
    margin-bottom: 0;
    padding: var(--nxs-space-16) var(--nxs-space-card-inset);
    flex-wrap: wrap;
    row-gap: var(--nxs-space-12);
}

.mud-paper.nxs-card.nxs-card--timeline > .nxs-card__actions {
    margin-top: 0;
    padding: var(--nxs-space-16) var(--nxs-space-card-inset) var(--nxs-space-card-inset);
}

/* NxsCard semantic edge variants — a status-coloured left edge for stat/status cards
   (e.g. the SPC machine-health tiles). The variant owns ONLY the edge; surface,
   padding, and content styling stay with the card and the consuming page. Pair the
   colour with text or an icon (UX principle 10). */
.mud-paper.nxs-card.nxs-card--edge-danger {
    border-left: 3px solid var(--nxs-danger-border);
}

.mud-paper.nxs-card.nxs-card--edge-warning {
    border-left: 3px solid var(--nxs-warning);
}

.mud-paper.nxs-card.nxs-card--edge-success {
    border-left: 3px solid var(--nxs-success-border);
}

.nxs-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nxs-space-16);
    margin-bottom: var(--nxs-space-16);
    padding-bottom: var(--nxs-space-12);
    border-bottom: 1px solid var(--nxs-border);
}

/* Section cards title their content without a divider, like NxsFormSection headers. */
.mud-paper.nxs-card.nxs-card--section > .nxs-card__header {
    padding-bottom: 0;
    border-bottom: none;
}

.nxs-card__title {
    margin: 0;
    font-weight: 400;
}

.nxs-card__heading {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    flex: 1 1 18rem;
    min-width: 0;
    gap: var(--nxs-space-4) var(--nxs-space-12);
}

.nxs-card__subtitle {
    min-width: 0;
    color: var(--nxs-text-muted);
    font-size: var(--nxs-text-size-sm);
    overflow-wrap: anywhere;
}

.nxs-card__header-actions {
    display: flex;
    align-items: center;
    gap: var(--nxs-space-8);
    flex-shrink: 0;
}

.nxs-card__actions {
    margin-top: var(--nxs-space-16);
    padding-top: var(--nxs-space-16);
    border-top: 1px solid var(--nxs-border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--nxs-space-12);
}

/* Shared grid/chart empty presentation. Templates own their text and actions. */
.nxs-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--nxs-space-12);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: var(--nxs-space-24);
    color: var(--nxs-text-muted);
    font-size: var(--nxs-text-size-md);
    font-weight: normal;
    line-height: 1.5;
    text-align: center;
}

/* Standard grid first-load state — NxsDataGrid renders this by default when Loading is true
   and there are no rows yet (refreshes with rows visible stay still; the built-in header
   progress bar is suppressed by the .nxs-grid .mud-table-loading rule above). */
.nxs-grid-loading {
    display: grid;
    place-items: center;
    padding: var(--nxs-space-24);
}

/* Grid filter panel (MudDataGrid Simple mode, rendered in a body-level popover). MudBlazor fixes the
   panel at 700px and lays each row on 1/4/3/4 grid columns, which squeezes a date and time picker into a
   third of the row and adds a horizontal scrollbar. These rules let the fields share the row instead. */
.mud-popover.filters-panel {
    width: min(52rem, calc(100vw - 2 * var(--nxs-space-16))) !important;
    max-width: none !important;
    padding: var(--nxs-space-12) var(--nxs-space-16) var(--nxs-space-8) !important;
    overflow-x: hidden;
    border: 1px solid var(--nxs-border-strong);
    border-radius: var(--nxs-radius-lg);
}

/* The panel's Column and Operator dropdowns. MudBlazor opens them over their own field and the panel
   cannot pass NxsSelect's bottom anchor, so while the panel is open they drop below the field and get the panel's outline. */
body:has(.mud-popover-open.filters-panel) .mud-popover-open.mud-popover-anchor-top-center.mud-popover-relative-width:not(.filters-panel) {
    margin-top: calc(var(--nxs-space-48) + var(--nxs-space-4));
    /* An outline, not a border: a border adds height, which overflows MudBlazor's sized popover into a second scroll bar. */
    outline: 1px solid var(--nxs-border-strong);
    outline-offset: -1px;
    border-radius: var(--nxs-radius-lg);
}

/* One filter row: remove button, column, operator, value. */
.filters-panel .mud-grid:has(> .mud-grid-item > .remove-filter-button) {
    flex-wrap: nowrap;
    align-items: flex-end;
    column-gap: var(--nxs-space-12);
    width: 100%;
    margin: 0;
}

.filters-panel .mud-grid:has(> .mud-grid-item > .remove-filter-button) > .mud-grid-item {
    flex: 1 1 0;
    max-width: none;
    min-width: 0;
}

.filters-panel .mud-grid:has(> .mud-grid-item > .remove-filter-button) > .mud-grid-item:has(> .remove-filter-button) {
    flex: 0 0 auto;
}

/* The value column holds the date and time pair, so it takes the most room. */
.filters-panel .mud-grid:has(> .mud-grid-item > .remove-filter-button) > .mud-grid-item:has(.filter-input-date) {
    flex-grow: 1.6;
}

/* MudBlazor pins the cross to the field's underline; this centres it on the inputs' text line. */
.filters-panel .remove-filter-button {
    align-self: flex-end !important;
    margin-bottom: var(--nxs-space-8);
}

/* Date and time pickers side by side within the value column. */
.filters-panel .mud-grid:has(> .mud-grid-item > .filter-input-date) {
    flex-wrap: nowrap;
    column-gap: var(--nxs-space-8);
    width: 100%;
    margin: 0;
}

.filters-panel .mud-grid:has(> .mud-grid-item > .filter-input-date) > .mud-grid-item {
    flex: 1 1 0;
    max-width: none;
    min-width: 0;
}

.filters-panel .mud-grid:has(> .mud-grid-item > .filter-input-date) > .mud-grid-item:has(> .filter-input-time) {
    flex-grow: 0.75;
}

/* File fields fill ordinary form columns but remain bounded in single-column workflows.
   FullWidth is an explicit component choice for data-heavy layouts that need the whole row. */
.nxs-form-field.nxs-file-upload-field {
    width: 100%;
    max-width: var(--nxs-control-w-file);
}

.nxs-form-field.nxs-file-upload-field--full {
    max-width: none;
}

/* Standard bounded workflow dialog. It keeps form fields readable on wide screens while
   preserving enough room for a data grid once the workflow produces results. */
.mud-dialog.nxs-dialog--workflow {
    --nxs-field-backdrop: var(--mud-palette-surface);
    width: min(calc(100vw - var(--nxs-space-48)), var(--nxs-dialog-workflow-max));
    max-width: var(--nxs-dialog-workflow-max);
}

/* A workflow dialog that hosts a whole record page with grids and charts side by side. */
.mud-dialog.nxs-dialog--workflow.nxs-dialog--wide {
    --nxs-dialog-workflow-max: var(--nxs-dialog-wide-max);
}

/* A popup that hosts record sections takes the page background, as behind a form page such
   as fatigue create, so its nxs-card--section cards read the same as on the page. */
.mud-dialog.nxs-surface--page,
.mud-paper.nxs-modal.nxs-surface--page {
    --nxs-field-backdrop: var(--mud-palette-background);
    background: var(--mud-palette-background);
}

/* NxsModal paints its own header strip; on the page surface it joins the body, as the
   MudDialog title does on the machine popups. */
.mud-paper.nxs-modal.nxs-surface--page .nxs-modal__header {
    border-bottom: none;
    background: transparent;
}

.mud-dialog.nxs-dialog--workflow .mud-dialog-title {
    padding: var(--nxs-space-16) var(--nxs-space-20) var(--nxs-space-12);
}

.mud-dialog.nxs-dialog--workflow .mud-dialog-content {
    margin-top: 0;
    padding: var(--nxs-space-8) var(--nxs-space-20) var(--nxs-space-20);
}

.mud-dialog.nxs-dialog--workflow .mud-dialog-actions {
    gap: var(--nxs-space-8);
    padding: 0 var(--nxs-space-20) var(--nxs-space-16);
}

/* ── NxsTabs — the site's shared tab strip ─────────────────────────────────────────
   Two variants, one modifier:
     --primary    framed rounded bar; page-level sections.
     --secondary  dense hairline strip; sub-sections inside an already-framed area.
     --contained  (modifier, Contained="true") bar + panel area join into one bordered
                  panel — the bar is the top edge, content shares the raised surface.
                  Tab-bar toolbars go in MudTabs' native Header slot, which renders
                  inline inside the bar (no overlay/reserved-width tricks). */
.nxs-tabs {
    min-width: 0;
}

.nxs-tabs > .mud-tabs-panels > div {
    min-width: 0;
}

/* Header slot (MudTabs Header fragment, HeaderPosition defaults to After): inline
   toolbar at the right end of the bar row. */
.nxs-tabs .mud-tabs-header {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    justify-content: flex-end;
    min-width: 0;
    gap: 8px;
    padding: 4px 12px 4px 16px;
}

.nxs-tabs--primary > .mud-tabs-tabbar {
    background: var(--nxs-surface-raised);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-lg);
    overflow: hidden;
}

/* Tab cells must fill the bar's FULL height even when Header content (toolbars) makes
   the bar taller than the tabs — the active underline is the cell's bottom edge and has
   to sit on the bar's bottom border. Mud breaks the height-stretch chain in two places:
   .mud-tabs-tabbar-content is inline-block, and each tab sits in a `d-inline-block`
   utility wrapper (display:inline-block !important — hence the !important here). */
.nxs-tabs .mud-tabs-tabbar .mud-tabs-tabbar-inner {
    min-height: 0;
    align-items: stretch;
}

.nxs-tabs .mud-tabs-tabbar-content {
    display: flex;
    align-items: stretch;
}

.nxs-tabs .mud-tabs-tabbar-content .mud-tabs-tabbar-wrapper {
    align-items: stretch;
}

/* Mud measures tab widths to decide whether scroll buttons are needed. Keep the
   horizontal strip at its intrinsic width: shrinking it into the viewport changes
   those measurements and wraps labels whenever the scroll buttons appear. */
.nxs-tabs .mud-tabs-tabbar-content .mud-tabs-tabbar-wrapper:not(.mud-tabs-vertical) {
    flex: 0 0 max-content;
}

.nxs-tabs .mud-tabs-tabbar-wrapper > div {
    display: inline-flex !important;
    align-items: stretch;
}

.nxs-tabs .mud-tab {
    flex: 0 0 auto;
    min-height: var(--nxs-tabs-tab-min-height, 38px);
    padding: var(--nxs-tabs-tab-padding, 6px 14px);
    font-size: var(--nxs-tabs-tab-font-size, inherit);
    color: var(--nxs-text-subtle);
    transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,
                color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
}

/* The active underline is drawn on the tab cell itself (inset shadow), not Mud's
   JS-measured .mud-tab-slider — the slider is positioned from pixel measurements that
   drift out of line with the cell (and with the hover highlight, which IS the cell).
   Same element for highlight and underline = aligned by construction. */
/* Specificity must beat the wrapper-children stretch rule below (also !important, and
   its `> div` type selector adds 0,2,1 — a bare .nxs-tabs .mud-tab-slider at 0,2,0
   LOSES and the slider quietly comes back). */
.nxs-tabs .mud-tabs-tabbar-wrapper > div.mud-tab-slider {
    display: none !important;
}

.nxs-tabs .mud-tab.mud-tab-active {
    color: var(--nxs-text);
    box-shadow: inset 0 -2px 0 var(--nxs-accent);
}

@media (hover: hover) and (pointer: fine) {
    .nxs-tabs .mud-tab:hover {
        background-color: var(--nxs-overlay-hover);
        color: var(--nxs-text);
    }

    .nxs-tabs .mud-tab.mud-tab-active:hover {
        background-color: var(--nxs-overlay-hover);
        box-shadow: inset 0 -2px 0 var(--nxs-accent);
    }
}

/* The bar's children stretch (so tab cells reach the bottom border) — the scroll-button
   wrappers stretch too, so they must centre their fixed-size chevrons themselves. */
.nxs-tabs .mud-tabs-scroll-button {
    display: flex;
    align-items: center;
}

.nxs-tabs .mud-tabs-scroll-button .mud-button-root {
    width: 36px;
    height: 36px;
    border-radius: var(--nxs-radius-pill);
    color: var(--nxs-text-subtle);
}

@media (hover: hover) and (pointer: fine) {
    .nxs-tabs .mud-tabs-scroll-button .mud-button-root:hover {
        background: var(--nxs-overlay-hover);
        color: var(--nxs-text);
    }
}

/* Secondary: dense strip anchored by a hairline so it never reads as floating text. */
.nxs-tabs--secondary > .mud-tabs-tabbar {
    background: transparent;
    border-bottom: 1px solid var(--nxs-divider);
}

.nxs-tabs--secondary .mud-tab {
    font-weight: 600;
}

.nxs-tabs--secondary .mud-tabs-scroll-button .mud-button-root {
    width: 36px;
    height: 36px;
}

/* Contained: bar + panels join into one framed panel. The bar keeps only its top
   corners; the panel area carries the remaining frame and its own padding (the strip's
   pt-* gap utility is suppressed by the component in this mode). */
.nxs-tabs--contained {
    --nxs-tabs-panel-pad: 16px;
}

.nxs-tabs--contained > .mud-tabs-tabbar {
    border-radius: var(--nxs-radius-lg) var(--nxs-radius-lg) 0 0;
}

.nxs-tabs--contained > .mud-tabs-panels {
    --nxs-field-backdrop: var(--nxs-surface-raised);
    padding: var(--nxs-tabs-panel-pad);
    background: var(--nxs-surface-raised);
    border: 1px solid var(--nxs-border);
    border-top: 0;
    border-radius: 0 0 var(--nxs-radius-lg) var(--nxs-radius-lg);
}

/* Fill="true": the strip stretches down its flex-column parent. The bar keeps its height and
   the active panel takes the rest, scrolling when its content is taller. Mud hides an inactive
   panel (KeepPanelsAlive) with an inline display: none, which outranks the panel rule. */
.nxs-tabs--fill {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

/* Only the panels area gives way to a tall panel; the bar never shrinks. The rule is needed
   because the primary bar's overflow: hidden lowers its minimum flex height to 0. */
.nxs-tabs--fill > .mud-tabs-tabbar {
    flex-shrink: 0;
}

.nxs-tabs--fill > .mud-tabs-panels {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
}

/* The panel is the scroll owner for content taller than the space left, such as a long list
   of files. Without it the content would draw past the page layout, and the page's bottom
   gutter would land above the content's end. The house gap (PanelClass pt-*) is on the panels
   area, outside the scroller, so it does not scroll away. */
.nxs-tabs--fill > .mud-tabs-panels > div {
    display: grid;
    flex: 1 1 auto;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    overflow-y: auto;
}

/* A secondary strip LEADING a contained panel (Docked="true") sits flush under the
   parent's tab bar while keeping its divider aligned to the same inset as the content
   below. The pad var inherits from the containing .nxs-tabs--contained. */
.nxs-tabs--docked > .mud-tabs-tabbar {
    margin-block: calc(-1 * var(--nxs-tabs-panel-pad, 16px)) var(--nxs-tabs-panel-pad, 16px);
    margin-inline: 0;
    padding: 0;
}

/* ── NxsTabHeader — one frame for a two-row tab header ────────────────────────────
   NxsTabs still owns tab selection; rows render strip-only (their empty Mud panel
   areas are hidden). Page content lives OUTSIDE the stack.

   Geometry: deliberately simple. The whole stack is ONE bordered rounded panel on
   the raised surface; the rows are separated by a hairline divider. Active tabs use
   the standard .nxs-tabs accent underline in both rows — same indicator as the rest
   of the app. Grouping is communicated by containment, not per-tab borders. */
.nxs-tab-header {
    min-width: 0;
    background: var(--nxs-surface-raised);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-lg);
    overflow: hidden; /* clip row hover overlays to the rounded corners */
}

.nxs-tab-header__row {
    display: flex;
    align-items: stretch;
    min-width: 0;
}

.nxs-tab-header__tabs {
    flex: 1 1 auto;
    min-width: 0;
}

/* Rows host bare strips: the stack owns the chrome, so strip chrome comes off and
   the (empty) panel areas are hidden. */
.nxs-tab-header__tabs > .nxs-tabs,
.nxs-tab-header__tabs > .nxs-tabs > .mud-tabs-tabbar {
    height: 100%;
    min-width: 0;
}

.nxs-tab-header__tabs > .nxs-tabs > .mud-tabs-tabbar {
    background: transparent;
    border: 0;
    border-radius: 0;
}

.nxs-tab-header__tabs > .nxs-tabs > .mud-tabs-panels {
    display: none;
}

/* With a child row present, the parent's selection is shown by the shared highlight
   alone (active tab + sub row share the same fill) — the accent underline belongs to
   the child row only, so it comes OFF the parent here, including on hover (the shared
   .nxs-tabs :hover rule would otherwise re-add it). */
.nxs-tab-header--has-subtabs .nxs-tabs--primary .mud-tab.mud-tab-active {
    background-color: var(--nxs-surface-2);
    box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
    .nxs-tab-header--has-subtabs .nxs-tabs--primary .mud-tab.mud-tab-active:hover {
        background-color: var(--nxs-surface-2);
        box-shadow: none;
    }
}

/* No divider between the rows: the sub row's lighter fill separates them tonally, and
   a hairline would cut through the active tab's connection to its sub row (they share
   the same fill so the selection reads as one region). */
.nxs-tab-header__row--subtabs {
    background-color: var(--nxs-surface-2);
}

html, body {
    font-family: Roboto, serif;
    /* Lock the window so the only vertical scrollbar is the content area's (article.content),
       not a full-height window scrollbar running behind the fixed app bar. */
    height: 100%;
    overflow: hidden;
}

/* NxsFormSections / NxsFormSection — one surface for static and collapsible form
   sections. Mud prefixes out-specify its stock joined panels and expand margins;
   static sections share the same declarations rather than a separate visual theme. */
.nxs-form-sections.mud-expansion-panels {
    display: flex;
    flex-direction: column;
    gap: var(--nxs-space-16);
}

.nxs-form-sections.mud-expansion-panels .mud-expand-panel,
.nxs-form-sections > .nxs-form-section--static {
    background: var(--nxs-surface-2);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-lg);
    overflow: hidden; /* the panel owns its rounding; everything inside stays square */
}

/* Sections keep a fixed gap; Mud's expand/collapse margin choreography and the
   joined-panel border/radius juggling would make the list jump and seam. */
.nxs-form-sections.mud-expansion-panels .mud-expand-panel.mud-panel-expanded {
    margin: 0;
}

.nxs-form-sections.mud-expansion-panels .mud-expand-panel:last-child,
.nxs-form-sections.mud-expansion-panels .mud-expand-panel.mud-panel-next-expanded {
    border-bottom: 1px solid var(--nxs-border);
}

.nxs-form-sections.mud-expansion-panels .mud-expand-panel-header,
.nxs-form-section__static-header {
    min-height: 3rem;
    padding: var(--nxs-space-12) var(--nxs-space-16);
    font-size: var(--nxs-text-size-md);
    font-weight: 700;
}

.nxs-form-section__static-header {
    display: flex;
    align-items: center;
}

/* Chevron leads the section title (same reading order as the heater-plate accordion) */
.nxs-form-sections.mud-expansion-panels .mud-expand-panel-header .mud-expand-panel-icon {
    order: -1;
    margin-left: 0;
    margin-right: var(--nxs-space-8);
}

.nxs-form-sections.mud-expansion-panels .mud-expand-panel-header .mud-expand-panel-text {
    flex: 0 1 auto;
}

/* A section carrying header actions needs the full title row to push them to the
   end; a plain titled section keeps the hug-content width above. */
.nxs-form-sections.mud-expansion-panels .mud-expand-panel-header .mud-expand-panel-text:has(.nxs-form-section__header) {
    flex: 1 1 auto;
    min-width: 0;
}

.nxs-form-section__header {
    display: flex;
    align-items: center;
    gap: var(--nxs-space-8);
    width: 100%;
    min-width: 0;
    line-height: 1.5;
}

.nxs-form-section__title {
    margin: 0;
    font: inherit;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nxs-form-section__actions {
    display: flex;
    align-items: center;
    gap: var(--nxs-space-4);
    /* The header sets a bold section weight; actions are chrome, not title text. */
    margin-left: auto;
    font-weight: 400;
}

/* The trigger anchors the popover, so the host establishes the positioning context. */
.nxs-info-popover {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--nxs-space-4);
}

/* Portalled out of the component subtree, so these rules cannot live in scoped CSS. */
.nxs-info-popover__surface.mud-popover {
    max-width: min(32rem, calc(100vw - var(--nxs-space-32)));
    /* Leave enough room for the anchor and viewport edges. Long reference content
       scrolls inside the popover because the page cannot reliably scroll while a
       portalled overlay is open. */
    /* At most 48% of the viewport guarantees that the surface fits on whichever
       side of its anchor MudPopover chooses, including anchors near mid-screen. */
    max-height: min(42rem, 48dvh);
    overflow: hidden;
    background: var(--nxs-surface-raised);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-md);
}

/* NxsInfoPopover keeps the popover open while this class fades the surface out, then closes it.
   The open class's opacity transition, timed by the component, carries the fade both ways. */
.nxs-info-popover__surface--closing.mud-popover {
    opacity: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .nxs-info-popover__surface.mud-popover {
        transition: none;
    }
}

.nxs-info-popover__content {
    display: flex;
    flex-direction: column;
    gap: var(--nxs-space-8);
    max-height: inherit;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--nxs-space-12) var(--nxs-space-16);
}

/* The anemometer reference panel carries two histories and behaves more like a
   compact dialog than a short anchored hint. Centre it so expanding content can
   use the viewport without either edge being clipped. `translate` is independent
   of MudPopover's transform animation. */
.anemometer-grid__info-surface.mud-popover {
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    max-height: min(42rem, calc(100dvh - var(--nxs-space-32)));
    translate: -50% -50%;
}

.nxs-info-popover__title {
    color: var(--nxs-text);
}

/* Present only to catch the dismissing click; it must not tint the page. */
.nxs-info-popover__overlay.mud-overlay {
    background: transparent;
}

/* A MudMenu renders its surface outside the component subtree, so the house popover
   treatment arrives by PopoverClass rather than scoped CSS. Without it the menu sits
   flush against its trigger with square corners and no edge against the page. */
.nxs-source-menu.mud-popover {
    background: var(--nxs-surface-raised);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-md);
    margin-top: var(--nxs-space-4);
    min-width: 15rem;
    overflow: hidden;
}

.nxs-source-menu.mud-popover .mud-list-item-icon {
    color: var(--nxs-text-muted);
    min-width: var(--nxs-space-32);
}

.nxs-form-sections.mud-expansion-panels .mud-expand-panel .mud-expand-panel-content,
.nxs-form-section__body {
    padding: var(--nxs-space-16);
    /* Browser autofill inside the panel follows its fill. */
    --nxs-field-backdrop: var(--nxs-surface-2);
}

/* Dense form grids need room between rows for labels painted above input bodies.
   The grid owns this separation, not individual fields. Preserve horizontal
   gutters and any caller-selected spacing of 16px or more. */
.nxs-form-section .mud-grid:is(.mud-grid-spacing-xs-0, .mud-grid-spacing-xs-1, .mud-grid-spacing-xs-2, .mud-grid-spacing-xs-3) {
    margin-top: 0;
    row-gap: var(--nxs-space-16);
}

.nxs-form-section .mud-grid:is(.mud-grid-spacing-xs-0, .mud-grid-spacing-xs-1, .mud-grid-spacing-xs-2, .mud-grid-spacing-xs-3) > .mud-grid-item {
    padding-top: 0;
}

/* MudStack can arrange several field grids as separate row groups. Their
   separation needs the same minimum as rows within one grid. Restrict this to
   dense vertical stacks with direct grid children; preserve horizontal stacks
   and larger caller-selected gaps. */
.nxs-form-section .d-flex.flex-column:is(.gap-0, .gap-1, .gap-2, .gap-3):has(> .mud-grid) {
    /* Bootstrap marks the shared gap utility !important. Override only its row gap. */
    row-gap: var(--nxs-space-16) !important;
}

/* Dialogs already provide the outer frame; retain section headings and spacing. */
.nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .nxs-form-section {
    background: transparent;
    border: 0;
    border-radius: 0;
}

.nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .nxs-form-section__static-header,
.nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .mud-expand-panel-header {
    padding-inline: 0;
}

.nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .nxs-form-section__body,
.nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .mud-expand-panel .mud-expand-panel-content {
    padding-inline: 0;
    --nxs-field-backdrop: var(--mud-palette-surface);
}

/* A popup on the page surface hosts a whole record workflow, so its sections keep the page
   panel (as on build creation) instead of the borderless dialog variant above. */
.nxs-surface--page .nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .nxs-form-section {
    background: var(--nxs-surface-2);
    border: 1px solid var(--nxs-border);
    border-radius: var(--nxs-radius-lg);
}

.nxs-surface--page .nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .nxs-form-section__static-header {
    padding-inline: var(--nxs-space-16);
}

.nxs-surface--page .nxs-form-sections.mud-expansion-panels.nxs-form-sections--dialog .nxs-form-section__body {
    padding-inline: var(--nxs-space-16);
    --nxs-field-backdrop: var(--nxs-surface-2);
}



table {
    width: auto;
    border-collapse: collapse;
}

td {
    vertical-align: middle;
    border: none;
}

input {
    width: 100%;
    height: 100%;
    padding-left: 1em;

    background-color: var(--bs-secondary-bg);
    border: none;
}

select {
    background-color: var(--bs-secondary-bg);
    border: none;
}

input[type="file"] {
    padding: 0;
    border: 2px solid #444444;
    border-radius: var(--nxs-radius-lg);

    &:hover {
        cursor: pointer;
    }

    &::file-selector-button {
        margin-right: 1em;
        padding: 0.75em;
        border: none;

        color: var(--nxs-text);
        background-color: var(--nxs-surface-3);
    }

    &::file-selector-button:hover {
        cursor: pointer;
    }
}

ul, .submenu{
    list-style: none;
}

textarea {
    height: 10em;
    min-height: 10em;
    max-height: 25em;

    padding: 0.5em;
    border: none;
    background-color: var(--bs-secondary-bg);
}

/* Mud owns the height of auto-growing Nxs fields. Neutralise the legacy native-textarea
   dimensions above only for this explicit house component mode. */
.nxs-text-field--auto-grow textarea {
    height: auto;
    min-height: 0;
    max-height: none;
}

select {
    padding-left: 1em;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    text-decoration: none;
    color: var(--nxs-accent);
}

.warning{
    color: orange;
}

.nxs-button {
    width: 100%;
}

.nxs-section {
    --nxs-field-backdrop: var(--nxs-surface-2);
    padding: 3em;
    border-radius: var(--nxs-radius-lg);

    background-color: var(--nxs-surface-2);
    box-shadow: 0 0 5px var(--bs-box-shadow);
    /*border: 1px var(--bs-emphasis-color) solid;*/

    transition: box-shadow 0.1s;
    margin-bottom: 4em;
}

.nxs-section-label {
    padding-left: 0.5em;
    font-weight: bold;
    margin-bottom: 0.5em;
}

.nxs-section-as-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 3em;
}

/* A section item that spans every column of the .nxs-section-as-grid* families. Pages were
   declaring `style="grid-column: 1 / 3"` inline on each one; this is the same rule, once, and it
   holds for the triple and quad variants too. */
.nxs-section-item--full {
    grid-column: 1 / -1;
}

.nxs-section-as-flex {
    display: flex;
    flex-direction: column;
    gap: 3em;
}

.nxs-section-as-grid-triple {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    row-gap: 3em;
    column-gap: 3em;
}

.nxs-section-as-grid-quad {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    row-gap: 3em;
    column-gap: 2em;
}

.nxs-section-item {
    flex: auto;
    display: flex;
    flex-direction: column;
    row-gap: 0.5em;
    max-width: 100%;
}

.airtable-source-selector {
    width: 100%;
}

.airtable-source-selector__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    width: 100%;
}

.airtable-source-selector__label-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    min-width: 0;
}

.airtable-source-selector__show-all {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    margin-left: auto;
    white-space: nowrap;
    font-weight: normal;
}

.airtable-source-selector__checkbox[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    padding-left: 0;
    margin: 0;
    flex: 0 0 auto;
}

.nxs-section-chart {
    width: 45em;
    height: 45em;
    align-self: center;
}

.nxs-section-item-read-only-value {
    padding: 0.75em;
    background-color: var(--bs-body-bg);

    box-shadow: 0 0 10px var(--bs-box-shadow);
    border-radius: var(--nxs-radius-md);
    user-select: none;

    overflow: hidden;
    text-overflow: ellipsis;

}


.nxs-section-item-read-only-value:hover {
    cursor: pointer;
    box-shadow: 0 0 10px 2px var(--bs-box-shadow);
}

.nxs-section-item-read-only-value:active {
    box-shadow: 0 0 5px 0 var(--bs-box-shadow);
}

.nxs-section-item-read-only-note {
    padding: 0.75em;
    background-color: var(--bs-body-bg);
    box-shadow: 0 0 10px var(--bs-box-shadow);
    border-radius: var(--nxs-radius-md);
    height: 10em;
    white-space: pre-wrap;
    user-select: none;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nxs-section-item-read-only-note:hover {
    cursor: pointer;
    box-shadow: 0 0 10px 2px var(--bs-box-shadow);
}

.nxs-section-item-read-only-note:active {
    box-shadow: 0 0 5px 0 var(--bs-box-shadow);
}



.nxs-center-content-vertically {
    display: flex;
    flex-direction: column;
    justify-content: center;

    height: 100%;
}

.nxs-center-content-horizontally {
    margin: auto;
}

.nxs-row-flex {
    display: flex;
    flex-direction: row;
    column-gap: 1em;
}

/* -------- Renderer CSS -------- */

.center-in-container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.part-listbox {
    position: absolute;
    margin-left: 1em;
    margin-top: 1em;

    max-height: calc(100% - 2.5em) !important;
}



/* ------------------------------ */


.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--nxs-success);
}

.invalid {
    outline: 1px solid var(--nxs-danger);
}

.italic {
    font-style: italic;
}

.validation-message {
    color: var(--nxs-danger);
}

.fill-splitter-pane {
    height: 100% !important;
}

.file-input-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--nxs-accent);
    color: black;
    border-color: black;
    cursor: pointer;
    position: relative;
    text-transform: uppercase;
    font-weight: 500;
    padding-block: 8px;
    padding-inline: 18px;
    font-size: 14px;
    line-height: 1.4285714286;
    box-sizing: border-box;
    border-width: 1px;
    border-style: solid;
    gap: 8px;
    border-radius: var(--nxs-radius-sm);
}

    .file-input-zone:hover {
        background-color: var(--nxs-accent);
    }

    .file-input-zone input[type=file] {
        position: absolute;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
    }



/* --- Blazor Overrides --- */

.combo-box-input-text {
    display: inline-block;
    border: none;
    border-radius: var(--nxs-radius-sm) 0 0 var(--nxs-radius-sm);
}

.combo-box-input-text:focus {
    outline: none;
}

/* --- Measurement Grid Layout --- */

.measurement-grid-scroll {
    width: 100%;
    min-width: 0;
}

.measurement-grid-scroll .k-table,
.measurement-grid-scroll .k-grid-table {
    min-width: 100%;
}

/* For japanese localization font override */
.lang-ja {
    --bs-font-sans-serif: "Roboto", "Noto Sans JP", sans-serif;
}

.lang-ja,
.lang-ja body,
.lang-ja button,
.lang-ja input,
.lang-ja select,
.lang-ja textarea,
.lang-ja .mud-typography,
.lang-ja .k-widget {
    font-family: "Roboto", "Noto Sans JP", sans-serif !important;
}

/* --- App shell chrome (MudAppBar/MudDrawer are component roots, so scoped
       ::deep rules from MainLayout.razor.css cannot reach them) --- */

.mud-appbar.app-header {
    background: var(--nxs-surface-raised);
    border-bottom: 1px solid var(--nxs-border);
}

.app-breadcrumbs {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
    margin-left: var(--nxs-space-24);
}

.mud-drawer.app-nav-drawer {
    border-right: 1px solid var(--nxs-border);
}

.eos-parameter-detail__heading {
    grid-column: 1 / -1;
}

/* Confine scrolling to the content area below the fixed app bar. The layout fills the viewport;
   main-content fills the layout and keeps MudBlazor's app-bar-height top padding but does NOT
   scroll itself — the inner article (article.content, a plain element that already sits below the
   bar) is the scroll container. So its scrollbar spans only from the bar's bottom edge down. */
.mud-layout {
    height: 100vh;
}

/* The agent chat is a full-bleed, app-like page that owns all of its scrolling internally
   (rail list, transcript). The content region therefore drops its gutter padding and the
   page fills it exactly — if the document kept even a few hidden overflow pixels, any
   focus or scrollIntoView (e.g. MudList revealing a selected row) would shift the whole
   page sideways/upwards to spend them. */
/* The .mud-main-content prefix lifts this above the scoped MainLayout gutter rule
   (article.content[scope]) — without it the two tie on specificity and the winner
   depends on stylesheet link order. */
.mud-main-content article.content:has(.agent-page) {
    padding: 0;
}

.mud-main-content {
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.component-spc-chart-card__rule-definitions-tooltip {
    box-sizing: border-box;
    width: min(28rem, calc(100vw - var(--nxs-space-32)));
    max-width: min(28rem, calc(100vw - var(--nxs-space-32)));
    max-height: 18rem;
    overflow-y: auto;
    white-space: normal;
}

.component-spc-chart-card__rule-definitions-tooltip-title {
    display: block;
    margin-bottom: var(--nxs-space-8);
}

.component-spc-chart-card__rule-definitions-tooltip-list {
    display: grid;
    gap: var(--nxs-space-8);
    margin: 0;
    padding-inline-start: var(--nxs-space-16);
}

.component-spc-chart-card__rule-definition {
    display: grid;
    gap: var(--nxs-space-4);
    line-height: 1.4;
}

.component-spc-chart-card__rule-definition span {
    color: var(--nxs-text-subtle);
}

/* Confirmations are destructive by convention here: UX_GUIDELINES routes destructive actions
   through IDialogService.ShowMessageBox, and every call site in this app is a removal or a
   deletion. The confirming button carries the danger colour so the two buttons cannot be told
   apart by position alone. A message box renders as its own dialog, outside the component that
   raised it, so this cannot be scoped to one. */
.mud-message-box .mud-dialog-actions {
    gap: var(--nxs-space-8);
    flex-wrap: wrap;
    padding: var(--nxs-space-8) var(--nxs-space-20) var(--nxs-space-16);
}

.mud-message-box .mud-dialog-actions .mud-button-text-primary {
    color: var(--nxs-danger-text);
}

.mud-message-box .mud-dialog-actions .mud-button-text-primary:hover {
    background-color: var(--nxs-danger-bg);
}

.mud-message-box .mud-dialog-actions .mud-button-filled-primary {
    background-color: var(--nxs-danger);
    color: var(--nxs-text);
}

.mud-message-box .mud-dialog-actions .mud-button-filled-primary:hover {
    background-color: var(--nxs-danger-strong);
}

/* Access-role chips, coloured from the process palette so the access table reads in the same
   language as the part overview rather than inventing a second one. Colour never carries the
   meaning alone: every chip using these also carries its role icon, and names the role in its own
   text or its tooltip. */
.nxs-chip.nxs-access-role--reader {
    border-color: color-mix(in srgb, var(--nxs-process-cmm) 30%, transparent);
    background: color-mix(in srgb, var(--nxs-process-cmm) 20%, transparent);
    color: var(--nxs-process-cmm);
}

.nxs-chip.nxs-access-role--contributor {
    border-color: color-mix(in srgb, var(--nxs-process-cnc) 30%, transparent);
    background: color-mix(in srgb, var(--nxs-process-cnc) 20%, transparent);
    color: var(--nxs-process-cnc);
}

.nxs-chip.nxs-access-role--admin {
    border-color: color-mix(in srgb, var(--nxs-process-gom) 30%, transparent);
    background: color-mix(in srgb, var(--nxs-process-gom) 20%, transparent);
    color: var(--nxs-process-gom);
}

/* The absence the other three are measured against, so it stays out of the palette. Access held on
   an OFFICIAL-SENSITIVE project by someone without clearance also confers nothing, so it shares
   the style. */
.nxs-chip.nxs-access-role--none,
.nxs-chip.nxs-access-dormant {
    border-color: var(--nxs-border);
    background: var(--nxs-surface-inset);
    color: var(--nxs-text-muted);
}

.nxs-chip.nxs-access-deactivated {
    border-color: color-mix(in srgb, var(--nxs-process-heat-treatment) 30%, transparent);
    background: color-mix(in srgb, var(--nxs-process-heat-treatment) 20%, transparent);
    color: var(--nxs-process-heat-treatment);
}

/* The manage-access dialog's chrome. These live here rather than in the component's own stylesheet
   because every element they touch is rendered by MudBlazor, and a component's markup never
   carries the scope attribute of the razor file that placed it — a scoped rule for them compiles
   to a selector that cannot match. */
.manage-project-access-dialog .mud-dialog-actions {
    padding-top: var(--nxs-space-16);
}

/* One height across both tabs. Without it the build tab collapsed to the height of an empty list
   and the dialog jumped on every switch, which reads as something having gone wrong rather than as
   a change of subject. Sized to the taller tab, the four project-access cards. */
.manage-project-access-dialog .mud-tabs-panels {
    min-height: 17rem;
}

/* A closed tab looked exactly like an open one. Pointer events come back with the styling, because
   MudBlazor removes them and a tab that cannot be hovered carries neither the cursor nor the
   tooltip saying why it is closed; activating it is refused in the component instead. */
.manage-project-access-dialog .mud-tab.mud-disabled {
    opacity: 0.45;
    pointer-events: auto;
    cursor: not-allowed;
}


/* A little more room than MudBlazor's small chip gives, so these carry the same weight as the
   pass/fail chips on the metrology pages rather than reading as a smaller class of thing. */
.nxs-chip.nxs-access-chip.mud-chip {
    height: var(--nxs-control-h-sm);
    padding: 0 var(--nxs-space-12);
}

/* The icon qualifies the label rather than partnering it, so it sits below the text's weight. */
.nxs-chip.nxs-access-chip.mud-chip .mud-icon-root {
    font-size: 1rem;
}

/* Carried by NxsChip and NxsSelect, which render their own markup and so never carry the placing
   file's scope attribute — the same reason the dialog chrome above lives here. */
.project-access__build {
    max-width: 22ch;
    overflow: hidden;
}

/* The ellipsis goes on the label rather than the chip. MudBlazor gives both .mud-chip and
   .mud-chip-content display:inline-flex, and text-overflow acts only on inline content of a block
   container, so on either of them as they come it renders nothing and a long name is cut off
   mid-character instead. Blockifying the label is what gives the text a box to overflow.
   height:auto goes with it: MudBlazor sets the label to height:100%, which under block layout
   stretches the box to the full chip and leaves the text sitting at the top of it. Sized to its
   text instead, the chip's own align-items:center centres it again. */
.project-access__build .mud-chip-content {
    display: block;
    height: auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The chip that says something is missing is the one thing the row must not clip. */
.project-access__build--more {
    max-width: none;
}

/* A build grant that has expired but was never revoked. It stays in the row so it can be renewed,
   but reads as spent by shape as well as by its hourglass icon: a dashed boundary and a
   struck-through name. The role colour stays, because the grant still says which role it would
   give back on renewal. */
.nxs-chip.project-access__build--expired {
    border-style: dashed;
}

.project-access__build--expired .mud-chip-content {
    text-decoration: line-through;
}

/* The count of lapsed grants in the Expiry column. The warning palette, like deactivation, because
   both describe access that no longer works rather than a role. */
.nxs-chip.nxs-access-expired {
    border-color: color-mix(in srgb, var(--nxs-warning) 40%, transparent);
    background: color-mix(in srgb, var(--nxs-warning) 16%, transparent);
    color: color-mix(in srgb, var(--nxs-warning) 45%, var(--nxs-text));
}

/* On the MudText under each role's name, so it lives here for the same reason as the rest of this
   block: the element is rendered by the component, not by the razor file that placed the class. */
.manage-project-access-dialog .manage-access-option__hint {
    display: block;
    color: var(--nxs-text-muted);
}

.manage-project-access-dialog .manage-access-grant__role {
    flex: 0 0 auto;
    width: 10rem;
}

/* The expiry picker takes the same fixed column as the role picker beside it, so the rows line up
   whether or not a date is set. */
.manage-project-access-dialog .manage-access-grant__expiry {
    flex: 0 0 auto;
    width: 10rem;
}

.manage-project-access-dialog .manage-access-grant__remove {
    flex: 0 0 auto;
    color: var(--nxs-danger-text);
}

/* Component SPC chart-type selects carry their descriptions as Mud tooltips. The tooltip roots are
   stretched so they neither shrink the select nor limit the option's hover target to its text.
   These are global because the options render in Mud's popover layer, outside the page's scope. */
.component-spc-chart-type-tooltip,
.component-spc-chart-type-option {
    display: block;
    width: 100%;
}

/* NxsSplitButton menu. MudMenu renders its list in the popover provider, outside the component
   subtree, so NxsSplitButton supplies these classes via PopoverClass/ListClass and they are
   styled here rather than in NxsSplitButton.razor.css. */
.nxs-split-button__popover.mud-popover {
    min-width: min(25rem, calc(100vw - var(--nxs-space-32)));
    max-width: min(27rem, calc(100vw - var(--nxs-space-32)));
    margin-top: var(--nxs-space-6);
    border: 1px solid var(--nxs-border-strong);
    border-radius: var(--nxs-radius-lg);
    background: var(--nxs-surface-raised);
}

.nxs-split-button__popover .nxs-split-button__list {
    display: flex;
    flex-direction: column;
    gap: var(--nxs-space-2);
    padding: var(--nxs-space-6);
}

/* Disabled items are wrapped in NxsDisabledReason (FullWidth) for their tooltip; keep each on its own row. */
.nxs-split-button__popover .nxs-split-button__list > * {
    display: block;
    width: 100%;
}

.nxs-split-button__popover .mud-menu-item {
    border-radius: var(--nxs-radius-sm);
    padding: var(--nxs-space-8) var(--nxs-space-12);
    white-space: normal;
}

.nxs-split-button__popover .mud-menu-item:hover:not(.mud-disabled) {
    background: var(--nxs-overlay-8);
}

.nxs-split-button__popover .nxs-split-button__item-content {
    display: flex;
    align-items: flex-start;
    gap: var(--nxs-space-12);
    width: 100%;
    min-width: 0;
}

.nxs-split-button__popover .nxs-split-button__item-check {
    flex: none;
    display: inline-flex;
    width: 18px;
    height: 18px;
    margin-top: var(--nxs-space-2);
}

.nxs-split-button__popover .nxs-split-button__selected-icon {
    color: var(--nxs-accent);
}

.nxs-split-button__popover .nxs-split-button__item-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--nxs-space-2);
    min-width: 0;
}

.nxs-split-button__popover .nxs-split-button__item-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--nxs-space-12);
}

.nxs-split-button__popover .nxs-split-button__item-label {
    color: var(--nxs-text);
    font-size: var(--nxs-text-size-md);
    font-weight: 500;
    white-space: normal;
}

.nxs-split-button__popover .nxs-split-button__item-description {
    color: var(--nxs-text-muted);
    font-size: var(--nxs-text-size-xs);
    line-height: 1.4;
    white-space: normal;
}

/* Pills ("Default", "Not available yet") never wrap or shrink. */
.nxs-split-button__popover .nxs-split-button__pill {
    flex: none;
    display: inline-flex;
    align-items: center;
    height: var(--nxs-control-h-chip);
    padding-inline: var(--nxs-space-8);
    border: 1px solid var(--nxs-border-strong);
    border-radius: var(--nxs-radius-pill);
    color: var(--nxs-text-muted);
    font-size: var(--nxs-text-size-xs);
    font-weight: 500;
    line-height: 1;
    white-space: normal;
}

/* "Not available yet" items: hatched, muted, not-allowed. */
.nxs-split-button__popover .mud-menu-item.mud-disabled {
    background: repeating-linear-gradient(135deg, var(--nxs-overlay-3) 0 6px, transparent 6px 12px);
    cursor: not-allowed;
    opacity: 0.7;
}

.nxs-split-button__popover .mud-menu-item.mud-disabled .nxs-split-button__item-label {
    color: var(--nxs-text-muted);
}
