:root {
	--graphite-shell-main-padding-top: calc(var(--mud-appbar-height, 64px) + 1.25rem);
	--graphite-shell-main-padding-x: 1.25rem;
	--graphite-shell-main-padding-bottom: 1.25rem;
	--graphite-shell-content-padding: 1.5rem;
	--graphite-shell-frame-radius: 1.5rem;
	--graphite-shell-bg:
		radial-gradient(circle at top left, var(--mud-palette-primary-hover), transparent 28%),
		radial-gradient(circle at top right, var(--mud-palette-secondary-hover), transparent 22%),
		linear-gradient(180deg, var(--mud-palette-background) 0%, var(--mud-palette-background-gray) 100%);
	--graphite-shell-bg-dark:
		radial-gradient(circle at top left, var(--mud-palette-primary-hover), transparent 28%),
		radial-gradient(circle at top right, var(--mud-palette-secondary-hover), transparent 22%),
		linear-gradient(180deg, var(--mud-palette-background) 0%, var(--mud-palette-background-gray) 100%);
	--graphite-auth-bg:
		radial-gradient(circle at top left, var(--mud-palette-primary-hover), transparent 28%),
		radial-gradient(circle at bottom right, var(--mud-palette-secondary-hover), transparent 22%),
		linear-gradient(145deg, var(--mud-palette-background) 0%, var(--mud-palette-background-gray) 45%, var(--mud-palette-background) 100%);
	--graphite-auth-bg-dark:
		radial-gradient(circle at top left, var(--mud-palette-primary-hover), transparent 28%),
		radial-gradient(circle at bottom right, var(--mud-palette-secondary-hover), transparent 22%),
		linear-gradient(145deg, var(--mud-palette-background) 0%, var(--mud-palette-background-gray) 45%, var(--mud-palette-background) 100%);
	--graphite-panel-border: var(--mud-palette-lines-default);
	--graphite-panel-bg: var(--mud-palette-surface);
	--graphite-panel-bg-dark: var(--mud-palette-surface);
	--graphite-brand-shadow: 0 14px 34px rgba(10, 37, 77, 0.16);
	--graphite-logo-filter: drop-shadow(0 10px 24px rgba(18, 76, 169, 0.16));

	/* ── Layout standard tokens (gx-*) ── */
	/* 4pt spacing scale */
	--gx-space-0: 0;
	--gx-space-1: 0.25rem;
	--gx-space-2: 0.5rem;
	--gx-space-3: 0.75rem;
	--gx-space-4: 1rem;
	--gx-space-5: 1.25rem;
	--gx-space-6: 1.5rem;
	--gx-space-8: 2rem;
	/* Page chrome */
	--gx-page-header-h: 4.5rem;
	--gx-page-header-h-compact: 3.75rem;
	/* Filter bar: max 2 righe operative + 1 riga chip filtri attivi */
	--gx-filterbar-max-h: clamp(3.5rem, 22vh, 8.5rem);
	--gx-filterbar-chips-h: 2.5rem;
	--gx-filterbar-row-h: 3.25rem;
	/* Surfaces */
	--gx-surface-radius: 1rem;
	--gx-surface-border: 1px solid var(--mud-palette-lines-default);
	--gx-surface-bg: var(--mud-palette-surface);
	/* Bounded tables: tetti per MudTable embedded in card master-detail.
	   Uso: <MudTable Height="var(--gx-table-bounded-sm)" FixedHeader="true" />
	   Evita magic heights tipo Height="220px" e si adatta al viewport. */
	--gx-table-bounded-sm: clamp(12rem, 28vh, 18rem);
	--gx-table-bounded-md: clamp(14rem, 34vh, 22rem);
	--gx-table-bounded-lg: clamp(18rem, 42vh, 28rem);
}

/* ── Layout standard utilities (gx-*) ── */

/* gx-fill: container flex column che riempie il padre senza calc magici.
   Uso: applicare al wrapper diretto della griglia/contenuto principale.
   Garantisce che i figli con flex:1 possano effettivamente espandersi. */
.gx-fill {
	display: flex;
	flex-direction: column;
	flex: 1 1 0;
	min-height: 0;
}

.gx-fill > * {
	min-width: 0;
}

/* gx-fill-grow: figlio che deve riempire lo spazio residuo dentro un .gx-fill */
.gx-fill > .gx-fill-grow,
.gx-fill-grow {
	flex: 1 1 0;
	min-height: 0;
}

/* Catena fill standard per pagine operative con MudTabs + griglie.
   Evita il collasso dei pannelli quando la griglia usa Height="100%". */
.graphite-main-content > .mud-tabs,
.gx-fill > .mud-tabs,
.graphite-filter-layout__content > .mud-tabs {
	display: flex;
	flex-direction: column;
	flex: 1 1 0;
	min-height: 0;
}

.graphite-main-content > .mud-tabs > .mud-tabs-panels,
.gx-fill > .mud-tabs > .mud-tabs-panels,
.graphite-filter-layout__content > .mud-tabs > .mud-tabs-panels {
	display: flex;
	flex-direction: column;
	flex: 1 1 0;
	min-height: 0;
}

.graphite-main-content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel,
.gx-fill > .mud-tabs > .mud-tabs-panels > .mud-tab-panel,
.graphite-filter-layout__content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel {
	display: flex;
	flex-direction: column;
	flex: 1 1 0;
	min-height: 0;
}

.graphite-main-content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid,
.gx-fill > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid,
.graphite-filter-layout__content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid {
	display: flex;
	flex-direction: column;
	flex: 1 1 0;
	min-height: 0;
}

.graphite-main-content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid > .mud-table-container,
.gx-fill > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid > .mud-table-container,
.graphite-filter-layout__content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid > .mud-table-container {
	flex: 1 1 0;
	min-height: 0;
	overflow: auto;
}

.graphite-main-content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid > .mud-table-pagination,
.gx-fill > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid > .mud-table-pagination,
.graphite-filter-layout__content > .mud-tabs > .mud-tabs-panels > .mud-tab-panel > .mud-table.mud-data-grid > .mud-table-pagination {
	flex: 0 0 auto;
}

html,
body {
	min-height: 100%;
	margin: 0;
}

.graphite-shell {
	min-height: 100dvh;
	height: 100dvh;
	background: var(--graphite-shell-bg);
	overflow: hidden;
}

.graphite-shell.graphite-dark {
	background: var(--graphite-shell-bg-dark);
}

.graphite-appbar {
	backdrop-filter: blur(14px);
	border-bottom: 1px solid var(--mud-palette-lines-default);
}

.graphite-appbar-global-search {
	width: min(44vw, 42rem);
	min-width: 18rem;
	max-width: 42rem;
}

.graphite-appbar-global-search .mud-input-root {
	background: color-mix(in srgb, var(--mud-palette-surface) 92%, transparent);
}

@media (max-width: 1280px) {
	.graphite-appbar-global-search {
		width: min(38vw, 28rem);
		min-width: 14rem;
	}
}

.graphite-shell-rail {
	position: fixed;
	top: 0.8rem;
	right: 0.9rem;
	z-index: 1250;
	border-radius: 999px;
	padding: 0.2rem;
	backdrop-filter: blur(14px);
	background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent);
	border: 1px solid var(--mud-palette-lines-default);
	box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

.graphite-dark .graphite-shell-rail {
	box-shadow: 0 14px 30px rgba(2, 6, 23, 0.30);
}

.graphite-header-menu-panel {
	min-width: 22rem;
	max-width: 24rem;
}

.graphite-header-menu-action {
	justify-content: flex-start;
	padding: 0.75rem 0.25rem;
	text-transform: none;
}

.graphite-header-menu-action .mud-button-label {
	width: 100%;
}

.graphite-brand-mark {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 9rem;
	height: 2.6rem;
	border-radius: 1rem;
	padding: 0.45rem 0.85rem;
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(237, 243, 251, 0.92) 100%);
	box-shadow: var(--graphite-brand-shadow);
}

.graphite-brand-logo {
	width: 100%;
	height: auto;
	filter: var(--graphite-logo-filter);
}

.graphite-nav-brand {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 0.9rem 1rem;
	border-radius: 1.1rem;
	background: var(--mud-palette-surface);
	border: 1px solid var(--mud-palette-lines-default);
	box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.graphite-dark .graphite-nav-brand {
	background: var(--mud-palette-surface);
	border-color: var(--mud-palette-lines-default);
	box-shadow: 0 14px 34px rgba(2, 6, 23, 0.24);
}

.graphite-nav-brand-logo {
	width: 7.75rem;
	max-width: 100%;
	height: auto;
	filter: var(--graphite-logo-filter);
}

.graphite-drawer-head {
	border-radius: 1rem;
	background: var(--mud-palette-surface);
	border: 1px solid var(--mud-palette-lines-default);
}

.graphite-dark .graphite-drawer-head {
	background: var(--mud-palette-surface);
	border-color: var(--mud-palette-lines-default);
}

.graphite-main {
	padding: var(--graphite-shell-main-padding-top) var(--graphite-shell-main-padding-x) var(--graphite-shell-main-padding-bottom);
	height: 100%;
	max-height: 100dvh;
	overflow: hidden;
	box-sizing: border-box;
}

.graphite-main-frame {
	min-height: 0;
	height: 100%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border-radius: var(--graphite-shell-frame-radius);
	background: var(--graphite-panel-bg);
	border: 1px solid var(--graphite-panel-border);
	box-shadow: 0 18px 48px rgba(15, 23, 42, 0.06);
}

.graphite-dark .graphite-main-frame {
	background: var(--graphite-panel-bg-dark);
	border-color: var(--mud-palette-lines-default);
	box-shadow: 0 18px 48px rgba(2, 6, 23, 0.28);
}

.graphite-main-content {
	padding: var(--graphite-shell-content-padding);
	flex: 1 1 auto;
	min-height: 0;
	overflow: auto;
	display: flex;
	flex-direction: column;
	container-type: inline-size;
	container-name: gx-page;
}

/* Auto-compact su altezza ridotta del page-frame (es. zoom utente, monitor bassi).
   Sostituisce le vecchie media-query @media (max-height) per i token di pagina. */
@container gx-page (max-height: 720px) {
	:root {
		--gx-page-header-h: var(--gx-page-header-h-compact);
		--gx-filterbar-max-h: clamp(3rem, 16vh, 6.5rem);
	}
}

.graphite-responsive-data-view {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.graphite-responsive-data-view--fill {
	flex: 1 1 0;
	min-height: 0;
}

.graphite-responsive-data-view--fill > .mud-table.mud-data-grid {
	flex: 1 1 0;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

.graphite-responsive-data-view--fill > .mud-table.mud-data-grid > .mud-table-container {
	flex: 1 1 0;
	min-height: 0;
	height: auto !important;
}

.graphite-responsive-data-view--fill > .mud-table.mud-data-grid > .mud-table-pagination {
	flex: 0 0 auto;
}

.graphite-grid-height-host {
	width: 100%;
	min-height: 0;
	position: relative;
}

.graphite-grid-height-page {
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	min-height: 0;
}

.graphite-grid-height-scope {
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	min-height: 0;
}

.graphite-grid-height-host > * {
	min-height: 0;
}

.graphite-responsive-data-view-list {
	padding: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	max-height: calc(100dvh - 20rem);
}

.graphite-responsive-data-view--fill .graphite-responsive-data-view-list {
	max-height: none;
	flex: 1 1 0;
	min-height: 0;
}

@media (max-width: 959.98px) {
	.graphite-responsive-data-view--fill .graphite-responsive-data-view-list {
		flex: none;
		max-height: calc(100dvh - 20rem);
	}
}

.graphite-responsive-data-view-list-item {
	display: block;
	padding: 0;
	margin-bottom: 0.85rem;
}

.graphite-responsive-data-view-mobile-pager {
	position: sticky;
	bottom: 0;
	z-index: 1;
	background: color-mix(in srgb, var(--mud-palette-surface) 94%, transparent);
	backdrop-filter: blur(10px);
}

.graphite-responsive-filter-trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
}

.graphite-responsive-filter-trigger-button {
	border: 1px solid var(--mud-palette-lines-default);
	background: color-mix(in srgb, var(--mud-palette-surface) 92%, transparent);
	backdrop-filter: blur(10px);
}

.graphite-responsive-filter-drawer {
	width: var(--mud-drawer-width-right, var(--mud-drawer-width, min(92vw, 24rem))) !important;
	max-width: min(92vw, 24rem);
}



.graphite-shell.graphite-shell-compact-height {
	--graphite-shell-main-padding-top: calc(var(--mud-appbar-height, 64px) + 0.85rem);
	--graphite-shell-main-padding-x: 1rem;
	--graphite-shell-main-padding-bottom: 1rem;
	--graphite-shell-content-padding: 1rem;
	--graphite-shell-frame-radius: 1.05rem;
}

.graphite-shell.graphite-shell-16x10:not(.graphite-shell-compact-height) {
	--graphite-shell-main-padding-top: calc(var(--mud-appbar-height, 64px) + 1rem);
	--graphite-shell-content-padding: 1.15rem;
}

.graphite-shell.graphite-shell-standalone:not(.graphite-shell-compact-width) {
	--graphite-shell-main-padding-x: 0.9rem;
	--graphite-shell-main-padding-bottom: 0.9rem;
	--graphite-shell-content-padding: 0.9rem;
	--graphite-shell-frame-radius: 1rem;
}

.graphite-shell.graphite-shell-standalone.graphite-shell-no-appbar:not(.graphite-shell-compact-width) {
	--graphite-shell-main-padding-top: 3.25rem;
}

.graphite-shell.graphite-shell-widescreen.graphite-shell-compact-height {
	--graphite-shell-main-padding-x: 0.85rem;
	--graphite-shell-main-padding-bottom: 0.85rem;
	--graphite-shell-content-padding: 0.85rem;
}

.graphite-shell.graphite-shell-standalone.graphite-shell-no-appbar:not(.graphite-shell-compact-width) .mud-drawer {
	top: 0 !important;
	height: 100dvh !important;
}

@media (max-width: 1279px) {
	.graphite-responsive-filter-trigger--desktop-only {
		display: none !important;
	}
}

@media (min-width: 1280px) {
	.graphite-responsive-filter-trigger--mobile-only {
		display: none !important;
	}


}

.graphite-shell.graphite-shell-standalone.graphite-shell-no-appbar:not(.graphite-shell-compact-width) .mud-drawer-content {
	margin-top: 0 !important;
}

.graphite-auth-shell {
	min-height: 100vh;
	background: var(--graphite-auth-bg);
}

.graphite-auth-shell.graphite-dark {
	background: var(--graphite-auth-bg-dark);
}

.graphite-auth-panel {
	border-radius: 1.75rem;
	background: var(--mud-palette-surface);
	border: 1px solid var(--mud-palette-lines-default);
	box-shadow: 0 24px 60px rgba(15, 23, 42, 0.10);
}

.graphite-dark .graphite-auth-panel {
	background: var(--mud-palette-surface);
	border-color: var(--mud-palette-lines-default);
	box-shadow: 0 24px 60px rgba(2, 6, 23, 0.30);
}

.graphite-auth-brand {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 10rem;
	max-width: 100%;
	min-height: 3.5rem;
	border-radius: 1.2rem;
	padding: 0.7rem 1rem;
	background: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(237, 243, 251, 0.92) 100%);
	box-shadow: var(--graphite-brand-shadow);
}

.graphite-auth-logo {
	width: 100%;
	height: auto;
	filter: var(--graphite-logo-filter);
}

.graphite-auth-shell .mud-main-content {
	padding-top: 0 !important;
}

.graphite-route-loader {
	min-height: calc(100vh - 2rem);
	color: var(--mud-palette-text-secondary);
}

.graphite-route-loader .mud-progress-circular {
	color: var(--mud-palette-primary);
}

.graphite-density-compact .mud-table-root .mud-table-cell,
.graphite-density-compact .mud-simple-table table * tr > td,
.graphite-density-compact .mud-simple-table table * tr > th {
	padding-top: 0.45rem !important;
	padding-bottom: 0.45rem !important;
}

.graphite-density-compact .mud-list-item {
	min-height: 2.25rem;
	padding-top: 0.2rem;
	padding-bottom: 0.2rem;
}

.graphite-density-compact .mud-button-root {
	min-height: 2.1rem;
}

.graphite-density-comfortable .mud-table-root .mud-table-cell,
.graphite-density-comfortable .mud-simple-table table * tr > td,
.graphite-density-comfortable .mud-simple-table table * tr > th {
	padding-top: 0.8rem !important;
	padding-bottom: 0.8rem !important;
}

.graphite-density-comfortable .mud-list-item {
	min-height: 2.75rem;
}

.graphite-text-compact {
	--mud-typography-default-size: 0.875rem;
	--mud-typography-body1-size: 0.9375rem;
	--mud-typography-body2-size: 0.8125rem;
	--mud-typography-button-size: 0.8125rem;
	--mud-typography-subtitle1-size: 0.9375rem;
	--mud-typography-subtitle2-size: 0.8125rem;
	--mud-typography-caption-size: 0.75rem;
	--mud-typography-h6-size: 1rem;
}

.graphite-text-standard {
	--mud-typography-default-size: 0.9375rem;
	--mud-typography-body1-size: 1rem;
	--mud-typography-body2-size: 0.875rem;
	--mud-typography-button-size: 0.875rem;
	--mud-typography-subtitle1-size: 1rem;
	--mud-typography-subtitle2-size: 0.875rem;
	--mud-typography-caption-size: 0.75rem;
	--mud-typography-h6-size: 1.1rem;
}

.graphite-text-comfortable {
	--mud-typography-default-size: 1rem;
	--mud-typography-body1-size: 1.0625rem;
	--mud-typography-body2-size: 0.9375rem;
	--mud-typography-button-size: 0.9375rem;
	--mud-typography-subtitle1-size: 1.0625rem;
	--mud-typography-subtitle2-size: 0.9375rem;
	--mud-typography-caption-size: 0.8125rem;
	--mud-typography-h6-size: 1.18rem;
}

@media (max-width: 959.95px) {
	.graphite-main {
		--graphite-shell-main-padding-top: 0.75rem;
		--graphite-shell-main-padding-x: 0.75rem;
		--graphite-shell-main-padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 0.75rem);
	}

	.graphite-main-frame {
		border-radius: 1rem;
	}

	.graphite-main-content {
		--graphite-shell-content-padding: 1rem;
	}
}

@media (max-height: 940px) {
	.graphite-shell {
		--graphite-shell-main-padding-top: calc(var(--mud-appbar-height, 64px) + 0.8rem);
		--graphite-shell-main-padding-x: 0.95rem;
		--graphite-shell-main-padding-bottom: 0.95rem;
		--graphite-shell-content-padding: 0.95rem;
		--graphite-shell-frame-radius: 1rem;
	}
}

@media (min-aspect-ratio: 16/9) and (max-height: 980px) {
	.graphite-shell {
		--graphite-shell-main-padding-x: 0.9rem;
		--graphite-shell-main-padding-bottom: 0.9rem;
		--graphite-shell-content-padding: 0.9rem;
	}
}


@media (max-width: 640px) {
	.graphite-shell-rail {
		top: 0.65rem;
		right: 0.65rem;
	}

	.graphite-brand-mark {
		width: 7.5rem;
		height: 2.35rem;
		padding: 0.4rem 0.7rem;
	}

	.graphite-nav-brand {
		padding: 0.8rem 0.85rem;
		gap: 0.7rem;
	}

	.graphite-nav-brand-logo {
		width: 6.75rem;
	}

	.graphite-auth-brand {
		width: 8.5rem;
	}
}

/* ── Validation ── */

.graphite-validation-message {
	display: block;
	margin-top: 0.35rem;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--mud-palette-error);
}


