/* Portal styles: only what MudBlazor does not cover; never a rule on MudBlazor's own mud-* classes, and no literal colour
   outside the token blocks (AppStylesheetTests fails for either, and for a class used in a .razor file without a rule
   here). The design tokens are DESIGN.md's, as --color-* / --space-* / --radius-* / --font-* custom properties: the
   :root block (Classica light), then the theme set's :root[data-ui-style][data-ui-mode] blocks, with
   prefers-color-scheme handling Sistema before the circuit. System font stacks only. No build step. */

/* ---- Design tokens ---------------------------------- */

/* DESIGN.md's tokens as custom properties: colors.* -> --color-*, spacing.* -> --space-*, rounded.* -> --radius-*,
   typography -> --font-*. The same values PortalTheme gives MudBlazor. */
:root {
    --color-ink: #1f2933;
    --color-ink-muted: #52606d;
    --color-ink-caption: #7b8794;
    --color-ink-disabled: #9aa5b1;
    --color-page: #f5f7fa;
    --color-surface: #ffffff;
    --color-surface-muted: #eef1f5;
    --color-border: #d6dde5;
    --color-primary: #1f6feb;
    --color-on-primary: #ffffff;
    --color-selected: #e3f0ff;
    --color-selected-border: #9cc3f5;
    --color-notice-empty: #fdf6e3;
    --color-notice-empty-ink: #6b5518;
    --color-notice-empty-border: #d9a441;
    --color-warning: #fff4ce;
    --color-warning-border: #e3c766;
    --color-warning-ink: #8a6100;
    --color-error: #b42318;
    --color-on-error: #ffffff;
    --color-backdrop: #1f293373;
    --color-success: #1a7f37;

    --space-2: 2px;
    --space-4: 4px;
    --space-6: 6px;
    --space-8: 8px;
    --space-10: 10px;
    --space-12: 12px;
    --space-14: 14px;
    --space-16: 16px;
    --space-20: 20px;
    --space-page-padding: 12px 16px 16px;
    --space-control-padding: 9px 12px;
    --space-button-padding: 9px 16px;
    --space-button-compact-padding: 4px 10px;
    --space-sidebar-expanded: 220px;
    --space-sidebar-collapsed: 56px;
    --space-viewport-min: 1024px;
    --space-module-card-min: 18rem;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    --font-sans: "Segoe UI", system-ui, sans-serif;
    --font-mono: Consolas, "Courier New", monospace;
    --font-size-title-page: 20px;
    --font-size-title-section: 16px;
    --font-size-body: 14px;
    --font-size-small: 12px;
    --font-size-caption: 11px;
    --font-weight-regular: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-letter-spacing-caps: 0.03em;

    --shadow-banner: 0 -1px 3px rgba(0, 0, 0, 0.15);

    --focus-ring-width: 2px;
    --dialog-width: min(520px, calc(100% - 32px));
    --opacity-disabled: 0.5;
}

/* The theme set (DESIGN.md › Theme set). <html> carries data-ui-style and data-ui-mode, the user's Stile and
   Tema, from the server render (App.razor) and from portal-shell.js's setAppearance on the circuit. Each block redefines
   the --color-* tokens, so every custom class follows, and MudBlazor's palette variables exactly as MudThemeProvider emits
   them for PortalTheme's PaletteDark, so <html>'s attribute decides Mud's palette too (the circuit's first render, before
   the user's appearance is loaded, emits the light palette; this block keeps it dark). Classica dark is DESIGN.md's
   themes.classic.dark, the values PortalTheme maps to PaletteDark (AppStylesheetTests pins them together);
   until approved. */
:root[data-ui-style="classic"][data-ui-mode="dark"] {
    color-scheme: dark;
    --color-ink: #e4e7eb;
    --color-ink-muted: #aab4c0;
    --color-ink-caption: #9aa5b1;
    --color-ink-disabled: #5f6b78;
    --color-page: #0f1115;
    --color-surface: #181b20;
    --color-surface-muted: #23272e;
    --color-border: #636d7a;
    --color-primary: #6ea8fe;
    --color-on-primary: #0f1115;
    --color-selected: #1c2f4d;
    --color-selected-border: #3d6fb3;
    --color-notice-empty: #2b2414;
    --color-notice-empty-ink: #f0d78c;
    --color-notice-empty-border: #8a6d2a;
    --color-warning: #33290f;
    --color-warning-border: #8a6d1f;
    --color-warning-ink: #f2c94c;
    --color-error: #ff8b7e;
    --color-on-error: #0f1115;
    --color-backdrop: #000000a6;
    --color-success: #5fd17f;
    --mud-palette-black: rgba(228,231,235,1);
    --mud-palette-white: rgba(24,27,32,1);
    --mud-palette-primary: rgba(110,168,254,1);
    --mud-palette-primary-rgb: 110,168,254;
    --mud-palette-primary-text: rgba(15,17,21,1);
    --mud-palette-primary-darken: rgb(72,145,254);
    --mud-palette-primary-lighten: rgb(143,188,254);
    --mud-palette-primary-hover: rgba(110,168,254,0.058823529411764705);
    --mud-palette-secondary: rgba(170,180,192,1);
    --mud-palette-secondary-rgb: 170,180,192;
    --mud-palette-secondary-text: rgba(24,27,32,1);
    --mud-palette-secondary-darken: rgb(149,162,177);
    --mud-palette-secondary-lighten: rgb(190,198,207);
    --mud-palette-secondary-hover: rgba(170,180,192,0.058823529411764705);
    --mud-palette-tertiary: rgba(228,231,235,1);
    --mud-palette-tertiary-rgb: 228,231,235;
    --mud-palette-tertiary-text: rgba(24,27,32,1);
    --mud-palette-tertiary-darken: rgb(208,213,220);
    --mud-palette-tertiary-lighten: rgb(249,250,251);
    --mud-palette-tertiary-hover: rgba(228,231,235,0.058823529411764705);
    --mud-palette-info: rgba(170,180,192,1);
    --mud-palette-info-rgb: 170,180,192;
    --mud-palette-info-text: rgba(24,27,32,1);
    --mud-palette-info-darken: rgb(149,162,177);
    --mud-palette-info-lighten: rgb(190,198,207);
    --mud-palette-info-hover: rgba(170,180,192,0.058823529411764705);
    --mud-palette-success: rgba(95,209,127,1);
    --mud-palette-success-rgb: 95,209,127;
    --mud-palette-success-text: rgba(24,27,32,1);
    --mud-palette-success-darken: rgb(65,200,103);
    --mud-palette-success-lighten: rgb(129,218,154);
    --mud-palette-success-hover: rgba(95,209,127,0.058823529411764705);
    --mud-palette-warning: rgba(242,201,76,1);
    --mud-palette-warning-rgb: 242,201,76;
    --mud-palette-warning-text: rgba(24,27,32,1);
    --mud-palette-warning-darken: rgb(239,190,42);
    --mud-palette-warning-lighten: rgb(244,211,113);
    --mud-palette-warning-hover: rgba(242,201,76,0.058823529411764705);
    --mud-palette-error: rgba(255,139,126,1);
    --mud-palette-error-rgb: 255,139,126;
    --mud-palette-error-text: rgba(15,17,21,1);
    --mud-palette-error-darken: rgb(255,108,92);
    --mud-palette-error-lighten: rgb(255,172,163);
    --mud-palette-error-hover: rgba(255,139,126,0.058823529411764705);
    --mud-palette-dark: rgba(228,231,235,1);
    --mud-palette-dark-rgb: 228,231,235;
    --mud-palette-dark-text: rgba(24,27,32,1);
    --mud-palette-dark-darken: rgb(208,213,220);
    --mud-palette-dark-lighten: rgb(249,250,251);
    --mud-palette-dark-hover: rgba(228,231,235,0.058823529411764705);
    --mud-palette-text-primary: rgba(228,231,235,1);
    --mud-palette-text-primary-rgb: 228,231,235;
    --mud-palette-text-secondary: rgba(170,180,192,1);
    --mud-palette-text-secondary-rgb: 170,180,192;
    --mud-palette-text-disabled: rgba(95,107,120,1);
    --mud-palette-text-disabled-rgb: 95,107,120;
    --mud-palette-action-default: rgba(170,180,192,1);
    --mud-palette-action-default-hover: rgba(170,180,192,0.058823529411764705);
    --mud-palette-action-disabled: rgba(95,107,120,1);
    --mud-palette-action-disabled-background: rgba(35,39,46,1);
    --mud-palette-surface: rgba(24,27,32,1);
    --mud-palette-surface-rgb: 24,27,32;
    --mud-palette-background: rgba(15,17,21,1);
    --mud-palette-background-gray: rgba(35,39,46,1);
    --mud-palette-drawer-background: rgba(24,27,32,1);
    --mud-palette-drawer-text: rgba(228,231,235,1);
    --mud-palette-drawer-icon: rgba(170,180,192,1);
    --mud-palette-appbar-background: rgba(24,27,32,1);
    --mud-palette-appbar-text: rgba(228,231,235,1);
    --mud-palette-lines-default: rgba(99,109,122,1);
    --mud-palette-lines-inputs: rgba(99,109,122,1);
    --mud-palette-table-lines: rgba(99,109,122,1);
    --mud-palette-table-striped: rgba(255,255,255,0.2);
    --mud-palette-table-hover: rgba(35,39,46,1);
    --mud-palette-divider: rgba(99,109,122,1);
    --mud-palette-divider-rgb: 99,109,122;
    --mud-palette-divider-light: rgba(99,109,122,1);
    --mud-palette-skeleton: rgba(35,39,46,1);
    --mud-palette-gray-default: #9E9E9E;
    --mud-palette-gray-light: #BDBDBD;
    --mud-palette-gray-lighter: #E0E0E0;
    --mud-palette-gray-dark: #757575;
    --mud-palette-gray-darker: #616161;
    --mud-palette-overlay-dark: #000000a6;
    --mud-palette-overlay-light: rgba(255,255,255,0.4980392156862745);
    --mud-palette-border-opacity: 1;
    --mud-native-html-color-scheme: dark;
}

/* Sistema before the circuit (and on the static sign-in and error pages, which never get one): the OS decides. Exactly the
   dark block above (its --color-* set and MudBlazor's dark palette variables), so the Mud components are dark from the
   first paint too. The selector outranks the provider's plain :root
   style; once the circuit runs, the provider's IsDarkMode agrees with the media query, so the two never fight.
   AppStylesheetTests compares this block with the dark block and with a render of MudThemeProvider. */
@media (prefers-color-scheme: dark) {
    :root[data-ui-style="classic"][data-ui-mode="system"] {
        color-scheme: dark;
        --color-ink: #e4e7eb;
        --color-ink-muted: #aab4c0;
        --color-ink-caption: #9aa5b1;
        --color-ink-disabled: #5f6b78;
        --color-page: #0f1115;
        --color-surface: #181b20;
        --color-surface-muted: #23272e;
        --color-border: #636d7a;
        --color-primary: #6ea8fe;
        --color-on-primary: #0f1115;
        --color-selected: #1c2f4d;
        --color-selected-border: #3d6fb3;
        --color-notice-empty: #2b2414;
        --color-notice-empty-ink: #f0d78c;
        --color-notice-empty-border: #8a6d2a;
        --color-warning: #33290f;
        --color-warning-border: #8a6d1f;
        --color-warning-ink: #f2c94c;
        --color-error: #ff8b7e;
        --color-on-error: #0f1115;
        --color-backdrop: #000000a6;
        --color-success: #5fd17f;
        --mud-palette-black: rgba(228,231,235,1);
        --mud-palette-white: rgba(24,27,32,1);
        --mud-palette-primary: rgba(110,168,254,1);
        --mud-palette-primary-rgb: 110,168,254;
        --mud-palette-primary-text: rgba(15,17,21,1);
        --mud-palette-primary-darken: rgb(72,145,254);
        --mud-palette-primary-lighten: rgb(143,188,254);
        --mud-palette-primary-hover: rgba(110,168,254,0.058823529411764705);
        --mud-palette-secondary: rgba(170,180,192,1);
        --mud-palette-secondary-rgb: 170,180,192;
        --mud-palette-secondary-text: rgba(24,27,32,1);
        --mud-palette-secondary-darken: rgb(149,162,177);
        --mud-palette-secondary-lighten: rgb(190,198,207);
        --mud-palette-secondary-hover: rgba(170,180,192,0.058823529411764705);
        --mud-palette-tertiary: rgba(228,231,235,1);
        --mud-palette-tertiary-rgb: 228,231,235;
        --mud-palette-tertiary-text: rgba(24,27,32,1);
        --mud-palette-tertiary-darken: rgb(208,213,220);
        --mud-palette-tertiary-lighten: rgb(249,250,251);
        --mud-palette-tertiary-hover: rgba(228,231,235,0.058823529411764705);
        --mud-palette-info: rgba(170,180,192,1);
        --mud-palette-info-rgb: 170,180,192;
        --mud-palette-info-text: rgba(24,27,32,1);
        --mud-palette-info-darken: rgb(149,162,177);
        --mud-palette-info-lighten: rgb(190,198,207);
        --mud-palette-info-hover: rgba(170,180,192,0.058823529411764705);
        --mud-palette-success: rgba(95,209,127,1);
        --mud-palette-success-rgb: 95,209,127;
        --mud-palette-success-text: rgba(24,27,32,1);
        --mud-palette-success-darken: rgb(65,200,103);
        --mud-palette-success-lighten: rgb(129,218,154);
        --mud-palette-success-hover: rgba(95,209,127,0.058823529411764705);
        --mud-palette-warning: rgba(242,201,76,1);
        --mud-palette-warning-rgb: 242,201,76;
        --mud-palette-warning-text: rgba(24,27,32,1);
        --mud-palette-warning-darken: rgb(239,190,42);
        --mud-palette-warning-lighten: rgb(244,211,113);
        --mud-palette-warning-hover: rgba(242,201,76,0.058823529411764705);
        --mud-palette-error: rgba(255,139,126,1);
        --mud-palette-error-rgb: 255,139,126;
        --mud-palette-error-text: rgba(15,17,21,1);
        --mud-palette-error-darken: rgb(255,108,92);
        --mud-palette-error-lighten: rgb(255,172,163);
        --mud-palette-error-hover: rgba(255,139,126,0.058823529411764705);
        --mud-palette-dark: rgba(228,231,235,1);
        --mud-palette-dark-rgb: 228,231,235;
        --mud-palette-dark-text: rgba(24,27,32,1);
        --mud-palette-dark-darken: rgb(208,213,220);
        --mud-palette-dark-lighten: rgb(249,250,251);
        --mud-palette-dark-hover: rgba(228,231,235,0.058823529411764705);
        --mud-palette-text-primary: rgba(228,231,235,1);
        --mud-palette-text-primary-rgb: 228,231,235;
        --mud-palette-text-secondary: rgba(170,180,192,1);
        --mud-palette-text-secondary-rgb: 170,180,192;
        --mud-palette-text-disabled: rgba(95,107,120,1);
        --mud-palette-text-disabled-rgb: 95,107,120;
        --mud-palette-action-default: rgba(170,180,192,1);
        --mud-palette-action-default-hover: rgba(170,180,192,0.058823529411764705);
        --mud-palette-action-disabled: rgba(95,107,120,1);
        --mud-palette-action-disabled-background: rgba(35,39,46,1);
        --mud-palette-surface: rgba(24,27,32,1);
        --mud-palette-surface-rgb: 24,27,32;
        --mud-palette-background: rgba(15,17,21,1);
        --mud-palette-background-gray: rgba(35,39,46,1);
        --mud-palette-drawer-background: rgba(24,27,32,1);
        --mud-palette-drawer-text: rgba(228,231,235,1);
        --mud-palette-drawer-icon: rgba(170,180,192,1);
        --mud-palette-appbar-background: rgba(24,27,32,1);
        --mud-palette-appbar-text: rgba(228,231,235,1);
        --mud-palette-lines-default: rgba(99,109,122,1);
        --mud-palette-lines-inputs: rgba(99,109,122,1);
        --mud-palette-table-lines: rgba(99,109,122,1);
        --mud-palette-table-striped: rgba(255,255,255,0.2);
        --mud-palette-table-hover: rgba(35,39,46,1);
        --mud-palette-divider: rgba(99,109,122,1);
        --mud-palette-divider-rgb: 99,109,122;
        --mud-palette-divider-light: rgba(99,109,122,1);
        --mud-palette-skeleton: rgba(35,39,46,1);
        --mud-palette-gray-default: #9E9E9E;
        --mud-palette-gray-light: #BDBDBD;
        --mud-palette-gray-lighter: #E0E0E0;
        --mud-palette-gray-dark: #757575;
        --mud-palette-gray-darker: #616161;
        --mud-palette-overlay-dark: #000000a6;
        --mud-palette-overlay-light: rgba(255,255,255,0.4980392156862745);
        --mud-palette-border-opacity: 1;
        --mud-native-html-color-scheme: dark;
    }
}

/* Moderna (DESIGN.md themes.modern): softer surfaces, larger corners, more page
   whitespace, one indigo accent. The style block holds its non-colour tokens and its light colours (Chiaro, and Sistema
   until the OS asks for dark); the dark block its dark colours; the Sistema block, under prefers-color-scheme, the dark
   colours plus MudBlazor's dark palette variables as MudThemeProvider emits them for PortalTheme.For(Modern)
   (AppStylesheetTests pins all three). */
:root[data-ui-style="modern"] {
    --color-ink: #1e2430;
    --color-ink-muted: #4e5766;
    --color-ink-caption: #58616f;
    --color-ink-disabled: #a3aab5;
    --color-page: #f7f7fb;
    --color-surface: #ffffff;
    --color-surface-muted: #f1f2f8;
    --color-border: #8a92a3;
    --color-primary: #4f46e5;
    --color-on-primary: #ffffff;
    --color-selected: #eceafd;
    --color-selected-border: #a5a0f2;
    --color-notice-empty: #fdf7e7;
    --color-notice-empty-ink: #6b5518;
    --color-notice-empty-border: #d9a441;
    --color-warning: #fff5d6;
    --color-warning-border: #e3c766;
    --color-warning-ink: #7d5800;
    --color-error: #b42318;
    --color-on-error: #ffffff;
    --color-backdrop: #1e243066;
    --color-success: #17803a;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;
    --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
    --font-mono: Consolas, "Courier New", monospace;
    --space-page-padding: 20px 24px 24px;
    --shadow-banner: 0 -2px 8px rgba(0, 0, 0, 0.08);
    --focus-ring-width: 2px;
}

:root[data-ui-style="modern"][data-ui-mode="dark"] {
    color-scheme: dark;
    --color-ink: #e8e9f0;
    --color-ink-muted: #b3b8c6;
    --color-ink-caption: #a3a9b8;
    --color-ink-disabled: #626877;
    --color-page: #14151c;
    --color-surface: #1c1e27;
    --color-surface-muted: #262935;
    --color-border: #6b7183;
    --color-primary: #a5a0ff;
    --color-on-primary: #14151c;
    --color-selected: #2a2850;
    --color-selected-border: #5b55b8;
    --color-notice-empty: #2b2414;
    --color-notice-empty-ink: #f0d78c;
    --color-notice-empty-border: #8a6d2a;
    --color-warning: #33290f;
    --color-warning-border: #8a6d1f;
    --color-warning-ink: #f2c94c;
    --color-error: #ff8b7e;
    --color-on-error: #14151c;
    --color-backdrop: #000000a6;
    --color-success: #6ad68a;
}

@media (prefers-color-scheme: dark) {
    :root[data-ui-style="modern"][data-ui-mode="system"] {
        color-scheme: dark;
        --color-ink: #e8e9f0;
        --color-ink-muted: #b3b8c6;
        --color-ink-caption: #a3a9b8;
        --color-ink-disabled: #626877;
        --color-page: #14151c;
        --color-surface: #1c1e27;
        --color-surface-muted: #262935;
        --color-border: #6b7183;
        --color-primary: #a5a0ff;
        --color-on-primary: #14151c;
        --color-selected: #2a2850;
        --color-selected-border: #5b55b8;
        --color-notice-empty: #2b2414;
        --color-notice-empty-ink: #f0d78c;
        --color-notice-empty-border: #8a6d2a;
        --color-warning: #33290f;
        --color-warning-border: #8a6d1f;
        --color-warning-ink: #f2c94c;
        --color-error: #ff8b7e;
        --color-on-error: #14151c;
        --color-backdrop: #000000a6;
        --color-success: #6ad68a;
        --mud-palette-black: rgba(232,233,240,1);
        --mud-palette-white: rgba(28,30,39,1);
        --mud-palette-primary: rgba(165,160,255,1);
        --mud-palette-primary-rgb: 165,160,255;
        --mud-palette-primary-text: rgba(20,21,28,1);
        --mud-palette-primary-darken: rgb(129,122,255);
        --mud-palette-primary-lighten: rgb(197,194,255);
        --mud-palette-primary-hover: rgba(165,160,255,0.058823529411764705);
        --mud-palette-secondary: rgba(179,184,198,1);
        --mud-palette-secondary-rgb: 179,184,198;
        --mud-palette-secondary-text: rgba(28,30,39,1);
        --mud-palette-secondary-darken: rgb(156,163,180);
        --mud-palette-secondary-lighten: rgb(203,206,216);
        --mud-palette-secondary-hover: rgba(179,184,198,0.058823529411764705);
        --mud-palette-tertiary: rgba(232,233,240,1);
        --mud-palette-tertiary-rgb: 232,233,240;
        --mud-palette-tertiary-text: rgba(28,30,39,1);
        --mud-palette-tertiary-darken: rgb(212,214,227);
        --mud-palette-tertiary-lighten: rgb(255,255,255);
        --mud-palette-tertiary-hover: rgba(232,233,240,0.058823529411764705);
        --mud-palette-info: rgba(179,184,198,1);
        --mud-palette-info-rgb: 179,184,198;
        --mud-palette-info-text: rgba(28,30,39,1);
        --mud-palette-info-darken: rgb(156,163,180);
        --mud-palette-info-lighten: rgb(203,206,216);
        --mud-palette-info-hover: rgba(179,184,198,0.058823529411764705);
        --mud-palette-success: rgba(106,214,138,1);
        --mud-palette-success-rgb: 106,214,138;
        --mud-palette-success-text: rgba(28,30,39,1);
        --mud-palette-success-darken: rgb(79,207,117);
        --mud-palette-success-lighten: rgb(135,222,161);
        --mud-palette-success-hover: rgba(106,214,138,0.058823529411764705);
        --mud-palette-warning: rgba(242,201,76,1);
        --mud-palette-warning-rgb: 242,201,76;
        --mud-palette-warning-text: rgba(28,30,39,1);
        --mud-palette-warning-darken: rgb(239,190,42);
        --mud-palette-warning-lighten: rgb(244,211,113);
        --mud-palette-warning-hover: rgba(242,201,76,0.058823529411764705);
        --mud-palette-error: rgba(255,139,126,1);
        --mud-palette-error-rgb: 255,139,126;
        --mud-palette-error-text: rgba(20,21,28,1);
        --mud-palette-error-darken: rgb(255,108,92);
        --mud-palette-error-lighten: rgb(255,172,163);
        --mud-palette-error-hover: rgba(255,139,126,0.058823529411764705);
        --mud-palette-dark: rgba(232,233,240,1);
        --mud-palette-dark-rgb: 232,233,240;
        --mud-palette-dark-text: rgba(28,30,39,1);
        --mud-palette-dark-darken: rgb(212,214,227);
        --mud-palette-dark-lighten: rgb(255,255,255);
        --mud-palette-dark-hover: rgba(232,233,240,0.058823529411764705);
        --mud-palette-text-primary: rgba(232,233,240,1);
        --mud-palette-text-primary-rgb: 232,233,240;
        --mud-palette-text-secondary: rgba(179,184,198,1);
        --mud-palette-text-secondary-rgb: 179,184,198;
        --mud-palette-text-disabled: rgba(98,104,119,1);
        --mud-palette-text-disabled-rgb: 98,104,119;
        --mud-palette-action-default: rgba(179,184,198,1);
        --mud-palette-action-default-hover: rgba(179,184,198,0.058823529411764705);
        --mud-palette-action-disabled: rgba(98,104,119,1);
        --mud-palette-action-disabled-background: rgba(38,41,53,1);
        --mud-palette-surface: rgba(28,30,39,1);
        --mud-palette-surface-rgb: 28,30,39;
        --mud-palette-background: rgba(20,21,28,1);
        --mud-palette-background-gray: rgba(38,41,53,1);
        --mud-palette-drawer-background: rgba(28,30,39,1);
        --mud-palette-drawer-text: rgba(232,233,240,1);
        --mud-palette-drawer-icon: rgba(179,184,198,1);
        --mud-palette-appbar-background: rgba(28,30,39,1);
        --mud-palette-appbar-text: rgba(232,233,240,1);
        --mud-palette-lines-default: rgba(107,113,131,1);
        --mud-palette-lines-inputs: rgba(107,113,131,1);
        --mud-palette-table-lines: rgba(107,113,131,1);
        --mud-palette-table-striped: rgba(255,255,255,0.2);
        --mud-palette-table-hover: rgba(38,41,53,1);
        --mud-palette-divider: rgba(107,113,131,1);
        --mud-palette-divider-rgb: 107,113,131;
        --mud-palette-divider-light: rgba(107,113,131,1);
        --mud-palette-skeleton: rgba(38,41,53,1);
        --mud-palette-gray-default: #9E9E9E;
        --mud-palette-gray-light: #BDBDBD;
        --mud-palette-gray-lighter: #E0E0E0;
        --mud-palette-gray-dark: #757575;
        --mud-palette-gray-darker: #616161;
        --mud-palette-overlay-dark: #000000a6;
        --mud-palette-overlay-light: rgba(255,255,255,0.4980392156862745);
        --mud-palette-border-opacity: 1;
        --mud-native-html-color-scheme: dark;
    }
}

/* Cyber, dark only (DESIGN.md themes.cyber.dark): near-black surfaces, a neon
   accent, monospace headings (PortalTheme). One block whatever data-ui-mode says: the saved Tema is kept, but Cyber is
   dark, and its MudTheme's PaletteLight is its dark set, so MudBlazor needs no variables here. */
:root[data-ui-style="cyber"] {
    color-scheme: dark;
    --color-ink: #e6f1ff;
    --color-ink-muted: #a3b6cc;
    --color-ink-caption: #93a7bd;
    --color-ink-disabled: #4a5868;
    --color-page: #05070a;
    --color-surface: #0b0f14;
    --color-surface-muted: #131a24;
    --color-border: #3a8a96;
    --color-primary: #00e5ff;
    --color-on-primary: #05070a;
    --color-selected: #062a33;
    --color-selected-border: #00a3b8;
    --color-notice-empty: #1f1a08;
    --color-notice-empty-ink: #ffe066;
    --color-notice-empty-border: #8a7420;
    --color-warning: #221b05;
    --color-warning-border: #8a7420;
    --color-warning-ink: #ffd43b;
    --color-error: #ff5c8a;
    --color-on-error: #05070a;
    --color-backdrop: #000000b3;
    --color-success: #39ff88;
    --radius-sm: 2px;
    --radius-md: 2px;
    --radius-lg: 4px;
    --radius-xl: 4px;
    --radius-full: 9999px;
    --font-sans: "Segoe UI", system-ui, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "Courier New", monospace;
    --space-page-padding: 12px 16px 16px;
    --shadow-banner: 0 -1px 6px rgba(0, 229, 255, 0.35);
    --focus-ring-width: 2px;
}

/* Alto contrasto (DESIGN.md themes.high-contrast): black/white, strong borders, a
   thick focus ring, no muted text. The style block holds its non-colour tokens and its light colours (Chiaro, and Sistema
   until the OS asks for dark); the dark block its dark colours; the Sistema block, under prefers-color-scheme, the dark
   colours plus MudBlazor's dark palette variables as MudThemeProvider emits them for PortalTheme.For(HighContrast)
   (AppStylesheetTests pins all three). */
:root[data-ui-style="high-contrast"] {
    --color-ink: #000000;
    --color-ink-muted: #000000;
    --color-ink-caption: #000000;
    --color-ink-disabled: #595959;
    --color-page: #ffffff;
    --color-surface: #ffffff;
    --color-surface-muted: #f0f0f0;
    --color-border: #000000;
    --color-primary: #0037b3;
    --color-on-primary: #ffffff;
    --color-selected: #e6ecff;
    --color-selected-border: #0037b3;
    --color-notice-empty: #fff8d6;
    --color-notice-empty-ink: #000000;
    --color-notice-empty-border: #000000;
    --color-warning: #fff2b3;
    --color-warning-border: #000000;
    --color-warning-ink: #5c3d00;
    --color-error: #a00000;
    --color-on-error: #ffffff;
    --color-backdrop: #000000b3;
    --color-success: #005a1f;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;
    --font-sans: "Segoe UI", system-ui, sans-serif;
    --font-mono: Consolas, "Courier New", monospace;
    --space-page-padding: 12px 16px 16px;
    --shadow-banner: none;
    --focus-ring-width: 4px;
}

:root[data-ui-style="high-contrast"][data-ui-mode="dark"] {
    color-scheme: dark;
    --color-ink: #ffffff;
    --color-ink-muted: #ffffff;
    --color-ink-caption: #ffffff;
    --color-ink-disabled: #a6a6a6;
    --color-page: #000000;
    --color-surface: #000000;
    --color-surface-muted: #1a1a1a;
    --color-border: #ffffff;
    --color-primary: #8cc8ff;
    --color-on-primary: #000000;
    --color-selected: #00264d;
    --color-selected-border: #8cc8ff;
    --color-notice-empty: #2b2200;
    --color-notice-empty-ink: #ffffff;
    --color-notice-empty-border: #ffd84d;
    --color-warning: #2b2200;
    --color-warning-border: #ffd84d;
    --color-warning-ink: #ffd84d;
    --color-error: #ff9e9e;
    --color-on-error: #000000;
    --color-backdrop: #000000cc;
    --color-success: #7dff9e;
}

@media (prefers-color-scheme: dark) {
    :root[data-ui-style="high-contrast"][data-ui-mode="system"] {
        color-scheme: dark;
        --color-ink: #ffffff;
        --color-ink-muted: #ffffff;
        --color-ink-caption: #ffffff;
        --color-ink-disabled: #a6a6a6;
        --color-page: #000000;
        --color-surface: #000000;
        --color-surface-muted: #1a1a1a;
        --color-border: #ffffff;
        --color-primary: #8cc8ff;
        --color-on-primary: #000000;
        --color-selected: #00264d;
        --color-selected-border: #8cc8ff;
        --color-notice-empty: #2b2200;
        --color-notice-empty-ink: #ffffff;
        --color-notice-empty-border: #ffd84d;
        --color-warning: #2b2200;
        --color-warning-border: #ffd84d;
        --color-warning-ink: #ffd84d;
        --color-error: #ff9e9e;
        --color-on-error: #000000;
        --color-backdrop: #000000cc;
        --color-success: #7dff9e;
        --mud-palette-black: rgba(255,255,255,1);
        --mud-palette-white: rgba(0,0,0,1);
        --mud-palette-primary: rgba(140,200,255,1);
        --mud-palette-primary-rgb: 140,200,255;
        --mud-palette-primary-text: rgba(0,0,0,1);
        --mud-palette-primary-darken: rgb(102,181,255);
        --mud-palette-primary-lighten: rgb(173,216,255);
        --mud-palette-primary-hover: rgba(140,200,255,0.058823529411764705);
        --mud-palette-secondary: rgba(255,255,255,1);
        --mud-palette-secondary-rgb: 255,255,255;
        --mud-palette-secondary-text: rgba(0,0,0,1);
        --mud-palette-secondary-darken: rgb(235,235,235);
        --mud-palette-secondary-lighten: rgb(255,255,255);
        --mud-palette-secondary-hover: rgba(255,255,255,0.058823529411764705);
        --mud-palette-tertiary: rgba(255,255,255,1);
        --mud-palette-tertiary-rgb: 255,255,255;
        --mud-palette-tertiary-text: rgba(0,0,0,1);
        --mud-palette-tertiary-darken: rgb(235,235,235);
        --mud-palette-tertiary-lighten: rgb(255,255,255);
        --mud-palette-tertiary-hover: rgba(255,255,255,0.058823529411764705);
        --mud-palette-info: rgba(255,255,255,1);
        --mud-palette-info-rgb: 255,255,255;
        --mud-palette-info-text: rgba(0,0,0,1);
        --mud-palette-info-darken: rgb(235,235,235);
        --mud-palette-info-lighten: rgb(255,255,255);
        --mud-palette-info-hover: rgba(255,255,255,0.058823529411764705);
        --mud-palette-success: rgba(125,255,158,1);
        --mud-palette-success-rgb: 125,255,158;
        --mud-palette-success-text: rgba(0,0,0,1);
        --mud-palette-success-darken: rgb(92,255,133);
        --mud-palette-success-lighten: rgb(163,255,186);
        --mud-palette-success-hover: rgba(125,255,158,0.058823529411764705);
        --mud-palette-warning: rgba(255,216,77,1);
        --mud-palette-warning-rgb: 255,216,77;
        --mud-palette-warning-text: rgba(0,0,0,1);
        --mud-palette-warning-darken: rgb(255,209,41);
        --mud-palette-warning-lighten: rgb(255,224,112);
        --mud-palette-warning-hover: rgba(255,216,77,0.058823529411764705);
        --mud-palette-error: rgba(255,158,158,1);
        --mud-palette-error-rgb: 255,158,158;
        --mud-palette-error-text: rgba(0,0,0,1);
        --mud-palette-error-darken: rgb(255,122,122);
        --mud-palette-error-lighten: rgb(255,194,194);
        --mud-palette-error-hover: rgba(255,158,158,0.058823529411764705);
        --mud-palette-dark: rgba(255,255,255,1);
        --mud-palette-dark-rgb: 255,255,255;
        --mud-palette-dark-text: rgba(0,0,0,1);
        --mud-palette-dark-darken: rgb(235,235,235);
        --mud-palette-dark-lighten: rgb(255,255,255);
        --mud-palette-dark-hover: rgba(255,255,255,0.058823529411764705);
        --mud-palette-text-primary: rgba(255,255,255,1);
        --mud-palette-text-primary-rgb: 255,255,255;
        --mud-palette-text-secondary: rgba(255,255,255,1);
        --mud-palette-text-secondary-rgb: 255,255,255;
        --mud-palette-text-disabled: rgba(166,166,166,1);
        --mud-palette-text-disabled-rgb: 166,166,166;
        --mud-palette-action-default: rgba(255,255,255,1);
        --mud-palette-action-default-hover: rgba(255,255,255,0.058823529411764705);
        --mud-palette-action-disabled: rgba(166,166,166,1);
        --mud-palette-action-disabled-background: rgba(26,26,26,1);
        --mud-palette-surface: rgba(0,0,0,1);
        --mud-palette-surface-rgb: 0,0,0;
        --mud-palette-background: rgba(0,0,0,1);
        --mud-palette-background-gray: rgba(26,26,26,1);
        --mud-palette-drawer-background: rgba(0,0,0,1);
        --mud-palette-drawer-text: rgba(255,255,255,1);
        --mud-palette-drawer-icon: rgba(255,255,255,1);
        --mud-palette-appbar-background: rgba(0,0,0,1);
        --mud-palette-appbar-text: rgba(255,255,255,1);
        --mud-palette-lines-default: rgba(255,255,255,1);
        --mud-palette-lines-inputs: rgba(255,255,255,1);
        --mud-palette-table-lines: rgba(255,255,255,1);
        --mud-palette-table-striped: rgba(255,255,255,0.2);
        --mud-palette-table-hover: rgba(26,26,26,1);
        --mud-palette-divider: rgba(255,255,255,1);
        --mud-palette-divider-rgb: 255,255,255;
        --mud-palette-divider-light: rgba(255,255,255,1);
        --mud-palette-skeleton: rgba(26,26,26,1);
        --mud-palette-gray-default: #9E9E9E;
        --mud-palette-gray-light: #BDBDBD;
        --mud-palette-gray-lighter: #E0E0E0;
        --mud-palette-gray-dark: #757575;
        --mud-palette-gray-darker: #616161;
        --mud-palette-overlay-dark: #000000cc;
        --mud-palette-overlay-light: rgba(255,255,255,0.4980392156862745);
        --mud-palette-border-opacity: 1;
        --mud-native-html-color-scheme: dark;
    }
}

/* Alto contrasto's thick focus ring, one rule on token variables (no mud-* class): every focusable element,
   MudBlazor's included, gets the --focus-ring-width ring in ink; components keep their own outline offsets. */
:root[data-ui-style="high-contrast"] :focus-visible {
    outline: var(--focus-ring-width) solid var(--color-ink);
}

/* The focus ring: every focusable element, MudBlazor's included, gets the --focus-ring-width ring in primary when it has
   keyboard focus (2 px; Alto contrasto's rule above, more specific, makes it 4 px in ink); components keep their own
   outline offsets. */
:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-primary);
}

/* ---- Document and height chain ------------------------------------------- */

/* The shell is a full-height layout, which only works if html and body are full height too. */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-body);
    color: var(--color-ink);
    background-color: var(--color-page);
}

/* MainLayout's <main>: passes the height down, so a full-height page resolves against a sized parent. */
.app-shell {
    height: 100%;
}

/* The circuit banner (error-banner). It MUST default to display: none: Blazor shows it when the circuit faults. */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    padding: var(--space-10) var(--space-16);
    color: var(--color-ink);
    background-color: var(--color-warning);
    border-top: 1px solid var(--color-warning-border);
    box-shadow: var(--shadow-banner);
    z-index: 2000;
}

/* The banner's "Ricarica" link; Blazor finds it by this class. */
.reload {
    margin-left: var(--space-8);
    cursor: pointer;
}

/* ---- Portal shell (UX-DR3) ------------------------------------------------- */

/* MudLayout fills the height html and body pass down. */
.portal-shell {
    height: 100%;
}

/* MudMainContent: the area beside the sidebar and under the top bar, as tall as the window. */
.portal-content {
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* The content area owns its scroll, vertical only: the page never scrolls horizontally (NFR17); a wide table scrolls
   inside its own .table-scroll. The sidebar does not scroll with it. */
.portal-scroll {
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ---- Top bar ---- */

.portal-topbar {
    border-bottom: 1px solid var(--color-border);
}

.portal-topbar-toggle {
    margin-right: var(--space-4);
}

.portal-product-name {
    white-space: nowrap;
}

/* The centre filter slot: a page's header-filter (HeaderFilter, Story 2.1), empty otherwise. */
.portal-topbar-filter {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    padding: 0 var(--space-16);
}

/* The header-filter: the search field, the clear button (while there is text) and the search button on one line. */
.header-filter {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    width: 100%;
    max-width: var(--dialog-width);
    margin: 0;
}

.header-filter-field {
    flex: 1;
    min-width: 0;
}

/* ---- User menu ---- */

.user-menu {
    flex: none;
    min-width: 0;
}

.user-menu-trigger {
    text-align: right;
}

.user-menu-identity {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* A Customer User's company (its Customer's name, Story 2.3), above the caption; cut like the name. */
.user-menu-company {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-semibold);
}

.user-menu-caption {
    font-size: var(--font-size-caption);
    color: var(--color-ink-muted);
}

/* A long user name is cut with an ellipsis rather than widening the top bar past the viewport. */
.user-menu-name {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--font-weight-semibold);
}

/* A white panel with a hairline. */
.user-menu-panel {
    border: 1px solid var(--color-border);
}

.user-menu-form {
    margin: 0;
}

.user-menu-item {
    justify-content: flex-start;
}

.user-menu-sign-out {
    margin: 0;
}

/* "Aspetto", the menu item above "Esci". */
.user-menu-appearance {
    margin: 0;
}

/* ---- The Aspetto dialog ---------------------------------------------------- */

.appearance-dialog {
    min-width: 0;
}

/* The notice, then Tema and Stile, stacked with the 12 px rhythm. */
.appearance-dialog-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.appearance-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.appearance-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-8);
}

/* Under the disabled Tema while Cyber is selected. */
.appearance-note {
    color: var(--color-ink-muted);
}

/* A style option: its swatch (the style's page, with its surface and primary as chips; the colours are inline, from
   PortalTheme's tokens), then its label. */
.appearance-style-option {
    display: inline-flex;
    align-items: center;
    gap: var(--space-8);
}

.appearance-swatch {
    display: inline-flex;
    gap: var(--space-2);
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.appearance-swatch-chip {
    display: inline-block;
    width: var(--space-12);
    height: var(--space-12);
    border-radius: var(--radius-sm);
}

.appearance-style-label {
    white-space: nowrap;
}

/* ---- Sidebar ---- */

.portal-sidebar {
    border-right: 1px solid var(--color-border);
}

.portal-nav {
    padding: var(--space-8) 0;
}

.sidebar-group {
    margin-bottom: var(--space-4);
}

/* Collapsed: the group headers become separators between the icon groups. */
.sidebar-separator {
    margin: var(--space-4) var(--space-8);
}

.sidebar-item {
    margin: 0 var(--space-4);
}

/* The active item: the selected fill, a 3 px primary marker, ink text in weight 600 (never blue on the selected fill). */
.sidebar-item-active {
    font-weight: var(--font-weight-semibold);
    color: var(--color-ink);
    background-color: var(--color-selected);
    box-shadow: inset 3px 0 0 var(--color-primary);
}

.sidebar-item-label {
    margin-right: var(--space-6);
}

/* ---- Portal pages ---- */

/* Every portal page: the page padding and the 12 px rhythm between blocks. */
.portal-page {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    box-sizing: border-box;
    min-width: 0;
    padding: var(--space-page-padding);
}

.not-found-text {
    margin: 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-12);
}

.page-header-main {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    min-width: 0;
}

/* The round icon disc (a primary MudAvatar). */
.page-header-icon {
    flex: none;
}

.page-header-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-header-title-row {
    display: flex;
    align-items: center;
    gap: var(--space-12);
}

.page-header-title {
    margin: 0;
}

.page-header-breadcrumb {
    margin: 0;
}

/* The breadcrumb's link back to the list (Clienti / {nome}). */
.page-header-breadcrumb-link {
    color: inherit;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-8);
}

/* Route tabs: links in one row under the header, the active one marked by the accent and a bottom rule. */
.route-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.route-tab {
    flex: 0 0 auto;
    padding: var(--space-8) var(--space-12);
    color: var(--color-ink);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.route-tab:hover {
    color: var(--color-primary);
}

.route-tab-active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
}

/* ---- Shared states and components (UX-DR5) ---- */

.page-state-loading {
    margin: 0;
}

.page-state-error-text {
    margin-right: var(--space-12);
}

/* notice-warning / notice-error: inline above the content, persistent. */
.notice-warning,
.notice-error {
    margin: 0;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-12);
}

.empty-state-text {
    margin: 0;
    font-style: italic;
}

/* The confirmation and leave dialogs. */
.confirm-dialog {
    min-width: 0;
}

.confirm-dialog-list {
    margin: var(--space-4) 0;
    padding-left: var(--space-20);
}

/* A typed error code: "{testo} ({codice})". */
.error-code-text {
    color: inherit;
}

.mono-plain {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-regular);
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* A table wider than the content area scrolls inside this wrapper, never the page. */
.table-scroll {
    max-width: 100%;
    overflow-x: auto;
}

/* Read by screen readers only (e.g. a kpi-tile's "non disponibile" behind its dash). */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* state-badge: an 8 px dot and a label in the same state colour; no fill, no border, never a pill. */
.state-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-6);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-semibold);
    color: var(--color-ink-muted);
}

.state-badge::before {
    content: "";
    width: var(--space-8);
    height: var(--space-8);
    border-radius: var(--radius-full);
    background-color: currentColor;
}

.state-badge-ok {
    color: var(--color-success);
}

.state-badge-progress {
    color: var(--color-primary);
}

.state-badge-warning {
    color: var(--color-warning-ink);
}

.state-badge-error {
    color: var(--color-error);
}

.state-badge-neutral {
    color: var(--color-ink-muted);
}

/* kpi-tile: an outlined tile with the label, the value and the sub-line stacked. */
.kpi-tile {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-12) var(--space-16);
    border-radius: var(--radius-lg);
    min-width: 0;
}

.kpi-tile-label,
.kpi-tile-value,
.kpi-tile-subline {
    margin: 0;
}

/* A kpi-tile's unit after the value ("USD", Story 5.7): small, muted, like a cost-figure's. */
.kpi-tile-unit {
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-regular);
}

/* The flag under a kpi-tile's value keeps its own width. */
.kpi-tile .partial-cost-flag {
    align-self: flex-start;
}

/* A row of kpi-tiles (Story 5.7): equal widths of at least 10rem, wrapping. */
.kpi-tile-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--space-12);
    margin-bottom: var(--space-16);
}

/* The stale-write notice: its sentence, then "Ricarica". */
.stale-data-text {
    margin-right: var(--space-12);
}

/* ---- Account pages (Amministratori) ---- */

/* A row's actions, side by side. */
.account-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
}

/* A tab's actions above its table (Utenti: "Nuovo utente"), at the end of the line. */
.tab-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-12);
}

/* ---- Clienti (customer-grid, Story 2.6) ---- */

/* "Mostra clienti eliminati", above the table. */
.customer-grid-toolbar {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-12);
}

/* A Deleted Customer's row: muted ink (its name still a link). */
.customer-row-deleted td,
.customer-row-deleted td a {
    color: var(--color-ink-muted);
}

/* ---- Catalogo moduli (Story 3.1) ---- */

/* The catalog-status badge (Disponibile, Preview, Non disponibile): a state-badge, kept whole on one line. */
.catalog-status-badge {
    display: inline-flex;
    white-space: nowrap;
}

/* ---- Module Grid (a Customer's Moduli tab, Story 4.1) ---- */

/* module-grid: wrapping columns of at least 18rem, 12px gap, every row as tall as the tallest card of the whole grid
   (implicit 1fr rows share one height). */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--space-module-card-min), 1fr));
    grid-auto-rows: 1fr;
    gap: var(--space-12);
}

/* A card's list item: the card fills it, so every card of a row has the same height. */
.module-grid-item {
    display: flex;
    min-width: 0;
}

/* module-card: an outlined surface with the header, the description and the actions stacked. */
.module-card {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-8);
    min-width: 0;
    padding: var(--space-12) var(--space-16);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

/* module-card-locked: a Module the Customer has not enabled, on the white surface (module-card's), its disc and name muted. */
.module-card-locked .module-card-name {
    color: var(--color-ink-muted);
}

.module-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    min-width: 0;
}

/* The icon disc (a small MudAvatar). */
.module-card-icon {
    flex: none;
}

/* The locked card's disc: muted ink on the muted surface. */
.module-card-icon-muted {
    color: var(--color-ink-muted);
    background-color: var(--color-surface-muted);
}

.module-card-name {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: var(--font-size-title-section);
    font-weight: var(--font-weight-semibold);
    overflow-wrap: anywhere;
}

/* The locked card's lock icon, at the header's end. */
.module-card-lock {
    flex: none;
    color: var(--color-ink-muted);
}

.module-card-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-12);
}

.module-card-description {
    margin: 0;
    color: var(--color-ink-muted);
    overflow-wrap: anywhere;
}

/* The card's Sync State (Story 4.3): the sync-badge, then the last error under it. */
.module-card-sync {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
}

.sync-badge {
    display: inline-flex;
    white-space: nowrap;
}

/* Ultimo errore: {testo} ({codice}), small and strong in the error colour. */
.module-card-error {
    margin: 0;
    color: var(--color-error);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-semibold);
    overflow-wrap: anywhere;
}

/* The card's actions, at its bottom. */
.module-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
    margin-top: auto;
}

/* The card's cost figures (Story 5.6): Costo reale and Prezzo cliente side by side, Token on the next row. */
.module-card-figures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8) var(--space-12);
    min-width: 0;
}

/* dati aggiornati al {istante}: small, muted. */
.module-card-meta {
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
}

/* A cost-figure: the label (small, muted), the value with its unit, then the partial-cost-flag. */
.cost-figure {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-width: 0;
}

.cost-figure-label {
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
}

.cost-figure-value {
    font-size: var(--font-size-title-page);
    font-weight: var(--font-weight-semibold);
    overflow-wrap: anywhere;
}

.cost-figure-unit {
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-regular);
}

/* costo parziale: the warning icon and the words, in the warning ink; never dismissible. */
.partial-cost-flag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    color: var(--color-warning-ink);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-semibold);
}

/* The Periodo: selector (Story 5.6): the muted label, the dense select and, for Personalizzato, the range picker to its right. */
.period-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-12);
    margin-bottom: var(--space-12);
}

.period-selector-label {
    color: var(--color-ink-muted);
}

.period-selector-preset {
    flex: 0 1 220px;
    min-width: 0;
}

.period-selector-range {
    flex: 0 1 280px;
    min-width: 0;
}

/* The drill-down's per-scope table (Story 5.7): the number cells right-aligned, the scope wrapping when long. */
.numeric-cell {
    text-align: right;
    white-space: nowrap;
}

.scope-cell {
    overflow-wrap: anywhere;
}

/* A money cell: the value with its unit, then the partial-cost-flag, both at the cell's right edge. */
.scope-money {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-2);
}

/* A Customer User's enabled Synced card (Story 4.8): the whole card is one link, drawn as the card (ink, no underline); on
   hover the muted surface, on hover or keyboard focus its name underlined; the focus ring is the global :focus-visible one. */
.module-card-link {
    color: inherit;
    text-decoration: none;
}

.module-card-link:hover {
    background-color: var(--color-surface-muted);
}

.module-card-link:hover .module-card-name,
.module-card-link:focus-visible .module-card-name {
    text-decoration: underline;
}

/* A Customer User's enabled Sync Pending card (Story 4.8): not a link, no hover. */
.module-card-pending {
    cursor: default;
}

/* modulo non ancora pronto: small, muted. */
.module-card-note {
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
}

/* Mostra moduli eliminati (Story 3.6), above the catalog's table, as the Customer Grid's switch. */
.module-grid-toolbar {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-12);
}

/* A Deleted Module's row (Story 3.6): muted ink (its name still a link). */
.module-row-deleted td,
.module-row-deleted td a {
    color: var(--color-ink-muted);
}

/* ---- Listino (the General Price List, Story 5.1) ---- */

/* The line under the header: a new price applies from its instant, costs already computed never change. */
.price-list-lead {
    margin: 0 0 var(--space-12);
    color: var(--color-ink-muted);
}

/* The Stato cell's badge (Pianificato, Attivo, Scaduto) on one line. */
.price-status-badge {
    display: inline-flex;
    white-space: nowrap;
}

/* An Expired entry's row: muted ink. */
.price-row-expired td {
    color: var(--color-ink-muted);
}

/* Nuova voce: Valida dal's date and time side by side. */
.price-valid-from {
    display: flex;
    gap: var(--space-12);
}

/* Nuova voce: the immutability line, small and muted. */
.price-dialog-notice {
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
}

/* A Module's edit form: one column of fields at a readable width, then Salva. */
.module-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    max-width: var(--dialog-width);
}

.module-form-actions {
    display: flex;
    justify-content: flex-start;
    gap: var(--space-8);
}

/* Rigenera segreto client (danger-quiet), right-aligned on the action row (as Rigenera chiave). */
.module-form-regenerate {
    margin-left: auto;
}

/* ---- Salute ingestione (Story 5.5): four read-only sections, one under the other ---- */

.health-section {
    margin-bottom: var(--space-20);
}

.health-section-title {
    margin: 0 0 var(--space-8);
    font-size: var(--font-size-title-section);
    font-weight: 600;
    color: var(--color-ink);
}

/* The line above the unpriced usage, with its link to Listino. */
.health-section-lead {
    margin: 0 0 var(--space-12);
    color: var(--color-ink-muted);
}

/* The Stato cell's badge on one line. */
.health-status-badge {
    display: inline-flex;
    white-space: nowrap;
}

/* ---- verify-checklist (Story 3.4): the last Verifica modulo run at the Module's current address ---- */

/* The meta line, then the header-less dense table, under the form. */
.verify-checklist {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
    margin-top: var(--space-20);
    max-width: var(--dialog-width);
}

.verify-checklist-meta {
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
}

.verify-checklist-table {
    min-width: 0;
}

.verify-checklist-row {
    vertical-align: top;
}

/* The badge, kept whole on one line. */
.verify-checklist-outcome {
    white-space: nowrap;
    width: 1%;
}

.verify-checklist-description {
    min-width: 0;
}

.verify-checklist-failure {
    min-width: 0;
}

/* The one announcement of a finished run (role="status"): read by screen readers, the checklist shows the rest. */
.verify-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* The account form dialogs (Nuovo amministratore, Nuovo utente, Modifica utente, Reimposta). */
.account-dialog {
    min-width: 0;
}

.account-dialog-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

.account-dialog-body {
    margin-top: var(--space-12);
}

/* ---- Chiave API (api-key-reveal, UX-DR18) ---- */

.api-key-reveal {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
}

/* The field, Mostra/Nascondi, Copia and the Copiata status on one row; Rigenera chiave right-aligned on it. */
.api-key-reveal-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-8);
}

.api-key-reveal-field {
    flex: 1 1 24rem;
    min-width: 0;
}

/* The field's mono-plain reaches its input (the key, or the dots). */
.api-key-reveal-field input {
    font-family: inherit;
}

.api-key-reveal-status {
    min-width: 0;
}

.api-key-reveal-regenerate {
    margin-left: auto;
}

.api-key-reveal-meta {
    margin: 0;
    color: var(--color-ink-muted);
    font-size: var(--font-size-small);
}

/* ---- one-time-secret (Story 3.3): the SSO client secret, shown once at the top of a Module's page ---- */

.one-time-secret {
    display: flex;
    flex-direction: column;
    gap: var(--space-12);
    max-width: var(--dialog-width);
}

/* The field, Copia and the Copiata status on one row. */
.one-time-secret-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-8);
}

.one-time-secret-field {
    flex: 1 1 24rem;
    min-width: 0;
}

/* The field's mono-plain reaches its input (the secret). */
.one-time-secret-field input {
    font-family: inherit;
}

.one-time-secret-status {
    min-width: 0;
}

/* The Conferma la tua password dialog's sentence above its field. */
.confirm-password-body {
    margin-bottom: var(--space-12);
}

/* ---- Registro attività ---- */

/* The filters above the table, side by side. */
.audit-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-12);
}

.audit-filter {
    flex: 0 1 240px;
    min-width: 0;
}

.audit-filter-period {
    flex-basis: 280px;
}

/* The details dialog: the summary, then Prima and Dopo. */
.audit-dialog {
    min-width: 0;
}

.audit-dialog-summary {
    margin-bottom: var(--space-12);
}

.audit-dialog-section {
    margin-top: var(--space-12);
}

/* Worded field/value pairs: the field muted on the left, its value on the right. */
.audit-values {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: var(--space-16);
    row-gap: var(--space-4);
    margin: var(--space-4) 0 0;
}

.audit-values dt {
    color: var(--color-ink-muted);
}

.audit-values dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.audit-values-none {
    margin: var(--space-4) 0 0;
}

/* ---- Sign-in (UX login-form) ------------------------------------------------
   A dialog-styled panel centred on the page, no backdrop. */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    box-sizing: border-box;
    padding: 16px;
    background-color: var(--color-page);
}

.login-panel {
    width: min(520px, calc(100% - 32px));
    box-sizing: border-box;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-title {
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-ink);
}

/* The sign-in's two native fields (MudBlazor inputs do not post in static rendering), drawn like MudBlazor's outlined
   fields: hairline, rounded corners, ink on hover, a 2px primary ring on focus. */
.form-field-input {
    padding: 9px 12px;
    font: inherit;
    color: var(--color-ink);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.form-field-input:hover {
    border-color: var(--color-ink);
}

.form-field-input:focus {
    outline: var(--focus-ring-width) solid var(--color-primary);
    outline-offset: -1px;
    border-color: var(--color-primary);
}
