/* ==========================================================================
   XLAB — Tema applicativo su Bootstrap 5.3
   Identità storica TocTOX (blu #006790) reinterpretata in chiave moderna.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
	/* Brand — derivata dal blu storico #006790 */
	--xl-brand-50:  #eef6fb;
	--xl-brand-100: #d6eaf4;
	--xl-brand-200: #aed5e9;
	--xl-brand-300: #74b6d6;
	--xl-brand-400: #3592bd;
	--xl-brand-500: #0a7fae;
	--xl-brand-600: #006790;
	--xl-brand-700: #025a7e;
	--xl-brand-800: #024a74;
	--xl-brand-900: #023b5c;

	/* Accento verde — evoluzione del #a8d4b1 storico */
	--xl-accent-50:  #eaf7f0;
	--xl-accent-100: #cdebdb;
	--xl-accent-500: #2f9e6b;
	--xl-accent-600: #24855a;

	/* Superfici */
	--xl-bg:          #f2f5f8;
	--xl-surface:     #ffffff;
	--xl-surface-alt: #f8fafc;
	--xl-border:      #e2e8ef;
	--xl-border-soft: #eef2f6;

	/* Testo */
	--xl-text:        #1b2733;
	--xl-text-muted:  #667a8c;
	--xl-text-subtle: #8c9cad;

	/* Stati */
	--xl-success: #2f9e6b;
	--xl-warning: #d98207;
	--xl-danger:  #d64545;
	--xl-info:    #0a7fae;

	/* Elevazione */
	--xl-shadow-xs: 0 1px 2px rgba(16, 40, 64, .06);
	--xl-shadow-sm: 0 1px 3px rgba(16, 40, 64, .08), 0 1px 2px rgba(16, 40, 64, .04);
	--xl-shadow-md: 0 4px 12px rgba(16, 40, 64, .10), 0 1px 3px rgba(16, 40, 64, .05);
	--xl-shadow-lg: 0 12px 32px rgba(16, 40, 64, .14);

	/* Geometria */
	--xl-radius-sm: 6px;
	--xl-radius:    10px;
	--xl-radius-lg: 14px;

	/* Layout */
	--xl-sidebar-w:           264px;
	--xl-sidebar-w-collapsed:  74px;
	--xl-topbar-h:             60px;
	--xl-transition: 180ms cubic-bezier(.4, 0, .2, 1);

	/* Override variabili Bootstrap */
	--bs-primary:     #006790;
	--bs-primary-rgb: 0, 103, 144;
	--bs-body-bg:     var(--xl-bg);
	--bs-body-color:  var(--xl-text);
	--bs-border-color: var(--xl-border);
	--bs-border-radius: var(--xl-radius);
	--bs-font-sans-serif: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
	--bs-body-font-size: .9375rem;
	--bs-link-color: var(--xl-brand-600);
	--bs-link-hover-color: var(--xl-brand-800);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
body {
	background: var(--xl-bg);
	color: var(--xl-text);
	font-family: var(--bs-font-sans-serif);
	font-size: var(--bs-body-font-size);
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.01em; color: var(--xl-text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c6d2de; border-radius: 6px; border: 2px solid var(--xl-bg); }
::-webkit-scrollbar-thumb:hover { background: #aebdcc; }

:focus-visible { outline: 2px solid var(--xl-brand-500); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   3. Struttura applicativa (shell)
   -------------------------------------------------------------------------- */
.app-shell { min-height: 100vh; }

/* ---- Sidebar ---- */
.app-sidebar {
	position: fixed;
	inset: 0 auto 0 0;
	width: var(--xl-sidebar-w);
	background: linear-gradient(180deg, var(--xl-brand-800) 0%, var(--xl-brand-900) 100%);
	color: #dce9f2;
	display: flex;
	flex-direction: column;
	z-index: 1040;
	transition: width var(--xl-transition), transform var(--xl-transition);
	overflow: hidden;
}

.app-sidebar__brand {
	height: var(--xl-topbar-h);
	display: flex;
	align-items: center;
	gap: .65rem;
	padding: 0 1.1rem;
	border-bottom: 1px solid rgba(255, 255, 255, .09);
	flex-shrink: 0;
}
.app-sidebar__brand img { max-height: 40px; max-width: 160px; width: auto; object-fit: contain; transition: opacity var(--xl-transition); }
.app-sidebar__brand-mark { display: none; flex-shrink: 0; }
.app-sidebar__brand-mark img { max-height: 34px; width: auto; object-fit: contain; }

.app-sidebar__section {
	padding: 1.15rem 1.1rem .4rem;
	font-size: .68rem;
	font-weight: 700;
	letter-spacing: .09em;
	text-transform: uppercase;
	color: rgba(220, 233, 242, .5);
	white-space: nowrap;
}

.app-sidebar__nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 1rem; }
.app-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); border-color: transparent; }

.app-nav-link {
	display: flex;
	align-items: center;
	gap: .8rem;
	margin: 2px .6rem;
	padding: .62rem .7rem;
	border-radius: var(--xl-radius-sm);
	color: #cfe0ec;
	text-decoration: none;
	font-size: .9rem;
	font-weight: 500;
	white-space: nowrap;
	border: 0;
	background: transparent;
	width: calc(100% - 1.2rem);
	text-align: left;
	cursor: pointer;
	transition: background var(--xl-transition), color var(--xl-transition);
}
.app-nav-link i { width: 20px; text-align: center; font-size: .95rem; flex-shrink: 0; opacity: .85; }
.app-nav-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.app-nav-link.is-active { background: rgba(255, 255, 255, .15); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--xl-accent-500); }
.app-nav-link.is-active i { opacity: 1; }

.app-sidebar__footer {
	padding: .8rem 1.1rem;
	border-top: 1px solid rgba(255, 255, 255, .09);
	font-size: .72rem;
	color: rgba(220, 233, 242, .55);
	white-space: nowrap;
	flex-shrink: 0;
}

/* Stato compresso */
.app-shell.is-collapsed .app-sidebar { width: var(--xl-sidebar-w-collapsed); }
.app-shell.is-collapsed .app-sidebar__brand img,
.app-shell.is-collapsed .app-sidebar__section,
.app-shell.is-collapsed .app-nav-link span,
.app-shell.is-collapsed .app-sidebar__footer span { display: none; }
.app-shell.is-collapsed .app-sidebar__brand-mark { display: flex; }
.app-shell.is-collapsed .app-sidebar__brand { justify-content: center; padding: 0; }
.app-shell.is-collapsed .app-nav-link { justify-content: center; padding: .62rem 0; }
.app-shell.is-collapsed .app-main { margin-left: var(--xl-sidebar-w-collapsed); }

/* ---- Area principale ---- */
.app-main {
	margin-left: var(--xl-sidebar-w);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	transition: margin var(--xl-transition);
}

.app-topbar {
	position: sticky;
	top: 0;
	height: var(--xl-topbar-h);
	background: rgba(255, 255, 255, .92);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--xl-border);
	display: flex;
	align-items: center;
	gap: .5rem;
	padding: 0 1.1rem;
	z-index: 1030;
}

.app-topbar__toggle {
	width: 38px; height: 38px;
	border: 0;
	border-radius: var(--xl-radius-sm);
	background: transparent;
	color: var(--xl-text-muted);
	flex-shrink: 0;
	transition: background var(--xl-transition), color var(--xl-transition);
}
.app-topbar__toggle:hover { background: var(--xl-brand-50); color: var(--xl-brand-700); }

/* Tab di sezione (ex top menu) */
.app-sections { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.app-sections::-webkit-scrollbar { display: none; }

.app-section-tab {
	display: inline-flex;
	align-items: center;
	gap: .45rem;
	padding: .48rem .85rem;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--xl-text-muted);
	font-size: .875rem;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	transition: background var(--xl-transition), color var(--xl-transition);
}
.app-section-tab i { font-size: .85rem; opacity: .8; }
.app-section-tab:hover { background: var(--xl-brand-50); color: var(--xl-brand-700); }
.app-section-tab.is-active { background: var(--xl-brand-600); color: #fff; box-shadow: var(--xl-shadow-xs); }
.app-section-tab.is-active i { opacity: 1; }

.app-content { flex: 1; padding: 1.35rem; }

/* Badge ambiente di sviluppo */
.app-env-badge {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	padding: .25rem .6rem;
	border-radius: 999px;
	background: #fff4e0;
	color: #a35b00;
	border: 1px solid #ffd79a;
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .04em;
	text-transform: uppercase;
	white-space: nowrap;
}

/* Utente */
.app-user-btn {
	display: inline-flex;
	align-items: center;
	gap: .55rem;
	padding: .3rem .6rem .3rem .3rem;
	border: 1px solid var(--xl-border);
	border-radius: 999px;
	background: var(--xl-surface);
	color: var(--xl-text);
	font-size: .875rem;
	font-weight: 500;
	transition: border-color var(--xl-transition), box-shadow var(--xl-transition);
}
.app-user-btn:hover { border-color: var(--xl-brand-300); box-shadow: var(--xl-shadow-xs); }
.app-user-avatar {
	width: 30px; height: 30px;
	border-radius: 50%;
	background: var(--xl-brand-600);
	color: #fff;
	display: flex; align-items: center; justify-content: center;
	font-size: .78rem; font-weight: 700;
	flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   4. Intestazione pagina e card
   -------------------------------------------------------------------------- */
.page-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	margin-bottom: 1.1rem;
}
.page-header__titolo { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.page-header__titolo #appBack { flex-shrink: 0; }
.page-header__title { font-size: 1.3rem; font-weight: 600; margin: 0; }
.page-header__subtitle { color: var(--xl-text-muted); font-size: .875rem; margin: .2rem 0 0; width: 100%; }
.page-header__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.card {
	background: var(--xl-surface);
	border: 1px solid var(--xl-border);
	border-radius: var(--xl-radius);
	box-shadow: var(--xl-shadow-sm);
}
.card-header {
	background: transparent;
	border-bottom: 1px solid var(--xl-border-soft);
	padding: .9rem 1.1rem;
	font-weight: 600;
}
.card-body { padding: 1.1rem; }

/* Barra filtri */
.filter-bar {
	display: flex;
	gap: .6rem;
	flex-wrap: wrap;
	align-items: flex-end;
	padding: .9rem 1.1rem;
	background: var(--xl-surface);
	border: 1px solid var(--xl-border);
	border-radius: var(--xl-radius);
	box-shadow: var(--xl-shadow-sm);
	margin-bottom: 1rem;
}
.filter-bar .form-label {
	font-size: .72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--xl-text-subtle);
	margin-bottom: .25rem;
}
.filter-field { display: flex; flex-direction: column; min-width: 160px; }
.filter-field--grow { flex: 1 1 260px; }

/* --------------------------------------------------------------------------
   5. Form
   -------------------------------------------------------------------------- */
.form-control, .form-select {
	border-color: var(--xl-border);
	border-radius: var(--xl-radius-sm);
	font-size: .9rem;
	padding: .48rem .7rem;
	color: var(--xl-text);
	transition: border-color var(--xl-transition), box-shadow var(--xl-transition);
}
.form-control:focus, .form-select:focus {
	border-color: var(--xl-brand-400);
	box-shadow: 0 0 0 3px rgba(0, 103, 144, .13);
}
.form-control::placeholder { color: var(--xl-text-subtle); }
.form-label { font-weight: 500; font-size: .85rem; margin-bottom: .3rem; }

.input-group-text {
	background: var(--xl-surface-alt);
	border-color: var(--xl-border);
	color: var(--xl-text-muted);
	font-size: .875rem;
}

/* --------------------------------------------------------------------------
   6. Bottoni
   -------------------------------------------------------------------------- */
.btn {
	border-radius: var(--xl-radius-sm);
	font-size: .875rem;
	font-weight: 500;
	padding: .48rem .9rem;
	display: inline-flex;
	align-items: center;
	gap: .45rem;
	transition: background var(--xl-transition), border-color var(--xl-transition), box-shadow var(--xl-transition), transform var(--xl-transition);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
	background: var(--xl-brand-600);
	border-color: var(--xl-brand-600);
	box-shadow: var(--xl-shadow-xs);
}
.btn-primary:hover, .btn-primary:focus { background: var(--xl-brand-700); border-color: var(--xl-brand-700); }
.btn-primary:active { background: var(--xl-brand-800) !important; border-color: var(--xl-brand-800) !important; }

.btn-outline-primary { color: var(--xl-brand-600); border-color: var(--xl-brand-200); }
.btn-outline-primary:hover { background: var(--xl-brand-600); border-color: var(--xl-brand-600); }

.btn-light {
	background: var(--xl-surface);
	border-color: var(--xl-border);
	color: var(--xl-text);
}
.btn-light:hover { background: var(--xl-surface-alt); border-color: var(--xl-brand-200); }

.btn-success { background: var(--xl-accent-500); border-color: var(--xl-accent-500); }
.btn-success:hover { background: var(--xl-accent-600); border-color: var(--xl-accent-600); }

/* Bottoni azione dentro le tabelle */
.btn-icon {
	width: 32px; height: 32px;
	padding: 0;
	justify-content: center;
	border-radius: var(--xl-radius-sm);
	border: 1px solid transparent;
	background: transparent;
	color: var(--xl-text-muted);
	transition: background var(--xl-transition), color var(--xl-transition), border-color var(--xl-transition);
}
.btn-icon:hover { background: var(--xl-brand-50); color: var(--xl-brand-700); border-color: var(--xl-brand-100); }
.btn-icon--danger:hover { background: #fdeeee; color: var(--xl-danger); border-color: #f8d6d6; }

/* --------------------------------------------------------------------------
   7. Tabelle
   -------------------------------------------------------------------------- */
.table-card {
	background: var(--xl-surface);
	border: 1px solid var(--xl-border);
	border-radius: var(--xl-radius);
	box-shadow: var(--xl-shadow-sm);
	overflow: hidden;
}
.table-scroll { overflow: auto; max-height: calc(100vh - 320px); }

.table-modern {
	width: 100%;
	margin: 0;
	border-collapse: separate;
	border-spacing: 0;
	font-size: .875rem;
}
.table-modern thead th {
	position: sticky;
	top: 0;
	z-index: 2;
	background: var(--xl-surface-alt);
	border-bottom: 1px solid var(--xl-border);
	padding: .7rem .8rem;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--xl-text-subtle);
	white-space: nowrap;
	text-align: left;
}
.table-modern tbody td {
	padding: .6rem .8rem;
	border-bottom: 1px solid var(--xl-border-soft);
	vertical-align: middle;
	color: var(--xl-text);
}
.table-modern tbody tr { transition: background 120ms ease; }
.table-modern tbody tr:hover { background: var(--xl-brand-50); }
.table-modern tbody tr:last-child td { border-bottom: 0; }
.table-modern .td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-modern .td-actions {
	text-align: right;
	white-space: nowrap;
	width: 1%;
	/* sempre visibile: la tabella scorre in orizzontale sotto questa colonna */
	position: sticky;
	right: 0;
	background: var(--xl-surface);
	box-shadow: -7px 0 8px -7px rgba(16, 40, 64, .22);
}
.table-modern thead th.td-actions { background: var(--xl-surface-alt); z-index: 3; }
.table-modern tbody tr:hover .td-actions { background: var(--xl-brand-50); }
.table-modern .td-nowrap { white-space: nowrap; }
.table-modern .td-id { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--xl-brand-700); }
.table-modern .td-truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Densità compatta */
.table-modern.is-compact thead th { padding: .5rem .65rem; }
.table-modern.is-compact tbody td { padding: .38rem .65rem; }

/* --------------------------------------------------------------------------
   8. Badge di stato
   -------------------------------------------------------------------------- */
.status-pill {
	display: inline-flex;
	align-items: center;
	gap: .35rem;
	padding: .2rem .55rem;
	border-radius: 999px;
	font-size: .75rem;
	font-weight: 600;
	white-space: nowrap;
	border: 1px solid transparent;
}
.status-pill i { font-size: .7rem; }
.status-pill--ok      { background: var(--xl-accent-50); color: var(--xl-accent-600); border-color: var(--xl-accent-100); }
.status-pill--warn    { background: #fff6e6; color: #a35b00; border-color: #ffe2b3; }
.status-pill--danger  { background: #fdeeee; color: #b33434; border-color: #f7d4d4; }
.status-pill--neutral { background: #f1f4f8; color: var(--xl-text-muted); border-color: #e4e9f0; }
.status-pill--info    { background: var(--xl-brand-50); color: var(--xl-brand-700); border-color: var(--xl-brand-100); }

/* --------------------------------------------------------------------------
   9. Paginazione
   -------------------------------------------------------------------------- */
.app-pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	padding: .8rem 1.1rem;
	border-top: 1px solid var(--xl-border-soft);
	background: var(--xl-surface);
}
.app-pagination__info { font-size: .82rem; color: var(--xl-text-muted); }
.app-pagination__pages { display: flex; gap: .2rem; flex-wrap: wrap; }
.app-pagination__pages button {
	min-width: 34px;
	height: 34px;
	padding: 0 .5rem;
	border: 1px solid transparent;
	border-radius: var(--xl-radius-sm);
	background: transparent;
	color: var(--xl-text-muted);
	font-size: .85rem;
	font-weight: 500;
	transition: background var(--xl-transition), color var(--xl-transition);
}
.app-pagination__pages button:hover:not(:disabled) { background: var(--xl-brand-50); color: var(--xl-brand-700); }
.app-pagination__pages button.is-active { background: var(--xl-brand-600); color: #fff; }
.app-pagination__pages button:disabled { opacity: .4; cursor: default; }
.app-pagination__pages .ellipsis { color: var(--xl-text-subtle); align-self: center; padding: 0 .25rem; }

/* --------------------------------------------------------------------------
   10. Stati: caricamento, vuoto, errore
   -------------------------------------------------------------------------- */
.app-loader {
	position: fixed;
	top: var(--xl-topbar-h);
	left: 0; right: 0;
	height: 3px;
	background: transparent;
	z-index: 1050;
	overflow: hidden;
	display: none;
}
.app-loader.is-visible { display: block; }
.app-loader::after {
	content: "";
	position: absolute;
	inset: 0;
	width: 40%;
	background: linear-gradient(90deg, transparent, var(--xl-brand-500), transparent);
	animation: xl-slide 1.1s infinite ease-in-out;
}
@keyframes xl-slide {
	0%   { transform: translateX(-100%); }
	100% { transform: translateX(350%); }
}

.empty-state {
	text-align: center;
	padding: 3rem 1.5rem;
	color: var(--xl-text-muted);
}
.empty-state i { font-size: 2.4rem; color: var(--xl-brand-200); margin-bottom: .8rem; display: block; }
.empty-state h5 { color: var(--xl-text); font-size: 1rem; margin-bottom: .35rem; }
.empty-state p { font-size: .875rem; margin: 0; }

.skeleton-row {
	height: 14px;
	border-radius: 4px;
	background: linear-gradient(90deg, #eef2f6 25%, #e3e9f0 37%, #eef2f6 63%);
	background-size: 400% 100%;
	animation: xl-shimmer 1.3s ease infinite;
	margin: .6rem 0;
}
@keyframes xl-shimmer {
	0%   { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

/* --------------------------------------------------------------------------
   11. Toast e modali
   -------------------------------------------------------------------------- */
.app-toast-container {
	position: fixed;
	bottom: 1.2rem;
	right: 1.2rem;
	z-index: 1090;
	display: flex;
	flex-direction: column;
	gap: .6rem;
}
.app-toast {
	display: flex;
	align-items: flex-start;
	gap: .65rem;
	min-width: 280px;
	max-width: 400px;
	padding: .8rem .95rem;
	border-radius: var(--xl-radius);
	background: var(--xl-surface);
	border: 1px solid var(--xl-border);
	border-left: 4px solid var(--xl-brand-500);
	box-shadow: var(--xl-shadow-lg);
	font-size: .875rem;
	animation: xl-toast-in 220ms cubic-bezier(.2, .9, .3, 1.2);
}
.app-toast--success { border-left-color: var(--xl-success); }
.app-toast--error   { border-left-color: var(--xl-danger); }
.app-toast--warning { border-left-color: var(--xl-warning); }
.app-toast i { margin-top: .12rem; }
.app-toast--success i { color: var(--xl-success); }
.app-toast--error i   { color: var(--xl-danger); }
.app-toast--warning i { color: var(--xl-warning); }
.app-toast--info i    { color: var(--xl-info); }
.app-toast__close { margin-left: auto; border: 0; background: transparent; color: var(--xl-text-subtle); padding: 0 .2rem; }
@keyframes xl-toast-in {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: translateY(0); }
}

.modal-content { border: 0; border-radius: var(--xl-radius-lg); box-shadow: var(--xl-shadow-lg); }
.modal-header { border-bottom: 1px solid var(--xl-border-soft); padding: 1rem 1.2rem; }
.modal-title { font-size: 1.05rem; }
.modal-body { padding: 1.2rem; }
.modal-footer { border-top: 1px solid var(--xl-border-soft); padding: .85rem 1.2rem; }

/* --------------------------------------------------------------------------
   12. Integrazione librerie di terze parti
   -------------------------------------------------------------------------- */
.select2-container--bootstrap-5 .select2-selection { border-color: var(--xl-border); border-radius: var(--xl-radius-sm); }
.datepicker table tr td.active.active { background: var(--xl-brand-600) !important; }

div.dt-container .dt-paging .dt-paging-button.current {
	background: var(--xl-brand-600) !important;
	border-color: var(--xl-brand-600) !important;
	color: #fff !important;
}

/* --------------------------------------------------------------------------
   12b. Elenco campioni (schede con dettaglio a tendina)
   -------------------------------------------------------------------------- */
.campioni-lista {
	background: var(--xl-surface);
	border: 1px solid var(--xl-border);
	border-radius: var(--xl-radius);
	box-shadow: var(--xl-shadow-sm);
	overflow: hidden;
	margin-bottom: 1.1rem;
}

.campioni-lista__intestazione {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: .8rem 1.1rem;
	border-bottom: 1px solid var(--xl-border-soft);
	background: var(--xl-surface-alt);
}
.campioni-lista__titolo { font-weight: 600; font-size: .95rem; }
.campioni-lista__azioni { display: flex; gap: .4rem; flex-wrap: wrap; }

/* il pulsante cambia etichetta a seconda che il modulo sia aperto o chiuso */
#btnAggiungiCampione .testo-aperto { display: none; }
#btnAggiungiCampione[aria-expanded="true"] .testo-aperto { display: inline; }
#btnAggiungiCampione[aria-expanded="true"] .testo-chiuso { display: none; }
#btnAggiungiCampione[aria-expanded="true"] { background: var(--xl-surface); border-color: var(--xl-border); color: var(--xl-text-muted); }
#btnAggiungiCampione[aria-expanded="true"] i { transform: rotate(45deg); transition: transform var(--xl-transition); }

.campione-card { border-bottom: 1px solid var(--xl-border-soft); }
.campione-card:last-child { border-bottom: 0; }

.campione-card__testa {
	display: grid;
	grid-template-columns: 34px minmax(160px, 1.1fr) minmax(240px, 2fr) auto auto;
	align-items: center;
	gap: .9rem;
	padding: .7rem 1.1rem .7rem .6rem;
	transition: background 120ms ease;
}
.campione-card__testa:hover { background: var(--xl-brand-50); }
.campione-card.is-completo { box-shadow: inset 3px 0 0 var(--xl-accent-500); }

.campione-card__toggle {
	width: 30px; height: 30px;
	border: 0;
	border-radius: var(--xl-radius-sm);
	background: transparent;
	color: var(--xl-text-muted);
	transition: background var(--xl-transition), color var(--xl-transition);
}
.campione-card__toggle:hover { background: var(--xl-brand-100); color: var(--xl-brand-700); }
.campione-card__toggle i { transition: transform var(--xl-transition); }
.campione-card__toggle[aria-expanded="true"] i { transform: rotate(90deg); }

.campione-card__identita { min-width: 0; }
.campione-card__id { display: block; font-weight: 600; color: var(--xl-brand-700); font-size: .92rem; }
.campione-card__tipologia {
	display: block;
	font-size: .8rem;
	color: var(--xl-text-muted);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.campione-card__sintesi {
	display: flex;
	gap: 1.4rem;
	margin: 0;
	min-width: 0;
}
.campione-card__sintesi > div { min-width: 0; }
.campione-card__sintesi dt {
	font-size: .66rem;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--xl-text-subtle);
	margin: 0;
}
.campione-card__sintesi dd {
	margin: .1rem 0 0;
	font-size: .85rem;
	max-width: 210px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.campione-card__stato { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.campione-card__azioni { display: flex; gap: .15rem; justify-content: flex-end; }

.campione-card__dettaglio {
	padding: 0 1.1rem 1rem 3.6rem;
	background: var(--xl-surface-alt);
	border-top: 1px dashed var(--xl-border);
}
.campione-card__gruppo { padding-top: .9rem; }
.campione-card__gruppo h6 {
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--xl-brand-600);
	margin-bottom: .5rem;
}
.campione-card__campi {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
	gap: .7rem 1.4rem;
	margin: 0;
}
.campione-card__campi dt {
	font-size: .7rem;
	font-weight: 600;
	color: var(--xl-text-subtle);
	text-transform: uppercase;
	letter-spacing: .04em;
	margin: 0;
}
.campione-card__campi dd { margin: .15rem 0 0; font-size: .875rem; word-break: break-word; }

/* --------------------------------------------------------------------------
   12c. Timbratura presenze
   -------------------------------------------------------------------------- */
.presenze-box { display: flex; justify-content: center; padding-top: 1rem; }
.presenze-card { width: 100%; max-width: 480px; }
.presenze-card .card-body { padding: 2rem 1.6rem; }

.presenze-saluto { font-size: 1rem; color: var(--xl-text-muted); margin-bottom: 1.2rem; }
.presenze-saluto strong { color: var(--xl-text); }

.presenze-orologio { margin-bottom: 1.4rem; }
.presenze-orologio span {
	display: block;
	font-size: 3.2rem;
	font-weight: 600;
	letter-spacing: -.02em;
	line-height: 1.05;
	color: var(--xl-brand-700);
	font-variant-numeric: tabular-nums;
}
.presenze-orologio small {
	display: block;
	margin-top: .35rem;
	font-size: .9rem;
	color: var(--xl-text-muted);
	text-transform: capitalize;
}

.presenze-pulsanti { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.presenze-pulsanti .btn { min-width: 160px; justify-content: center; padding: .8rem 1.2rem; font-size: 1rem; }

/* --------------------------------------------------------------------------
   12d. Elenco utenti e righe di dettaglio
   -------------------------------------------------------------------------- */
.utente-nome  { display: block; font-weight: 600; font-size: .9rem; }
.utente-login { display: block; font-size: .78rem; color: var(--xl-text-muted); margin-top: .1rem; }
.utente-login i { font-size: .7rem; opacity: .7; margin-right: .2rem; }

.table-modern tr.riga-dettaglio:hover { background: transparent; }
.table-modern tr.riga-dettaglio > td { padding: 0; border-bottom: 1px solid var(--xl-border-soft); }
.table-modern tr.riga-dettaglio .collapse,
.table-modern tr.riga-dettaglio .collapsing { background: var(--xl-surface-alt); }

.dettaglio-campi {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
	gap: .7rem 1.4rem;
	margin: 0;
	padding: 1rem 1.1rem 1rem 3.2rem;
}
.dettaglio-campi dt {
	font-size: .7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .04em;
	color: var(--xl-text-subtle);
	margin: 0;
}
.dettaglio-campi dd {
	margin: .15rem 0 0;
	font-size: .875rem;
	word-break: break-word;
	display: flex;
	align-items: center;
	gap: .3rem;
}

.password-mascherata { font-family: ui-monospace, "Courier New", monospace; letter-spacing: .06em; }

/* --------------------------------------------------------------------------
   12e. Risultati del campione
   -------------------------------------------------------------------------- */
.risultati-barra {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .8rem;
	flex-wrap: wrap;
	padding: 0 0 .9rem;
	border-bottom: 1px solid var(--xl-border-soft);
	margin-bottom: .6rem;
}
.risultati-azioni { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.risultati-date { display: flex; align-items: center; gap: .35rem; }
.risultati-date .form-label {
	font-size: .68rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--xl-text-subtle);
	margin-right: .15rem;
}
.risultati-date .form-control { width: 112px; padding-left: .45rem; padding-right: .45rem; }

.risultato-parametro { display: block; font-weight: 600; font-size: .875rem; }
.risultato-metodo {
	display: block;
	font-size: .74rem;
	color: var(--xl-text-subtle);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	max-width: 260px;
}

.risultati-periodo { display: flex; gap: .3rem; }
.risultati-periodo .form-control { width: 112px; padding-left: .45rem; padding-right: .45rem; }

/* unità di misura accanto al valore: non deve rubare spazio al campo */
.risultato-um {
	max-width: 74px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	display: inline-block;
	font-size: .75rem;
}
.riga-risultato .input-group .form-control { min-width: 68px; }

/* dentro la finestra modale scorre il corpo, non la tabella */
.modal .table-scroll { max-height: none; overflow: visible; }

/* nelle finestre la tabella ci sta tutta: la colonna azioni non deve
   restare ancorata, altrimenti mostra l'ombra di scorrimento a vuoto */
.modal .table-modern .td-actions { position: static; box-shadow: none; }

/* stato della riga */
/* con border-collapse: separate i bordi sul <tr> non vengono resi:
   lo stato va sulla prima cella */
.riga-risultato td:first-child { border-left: 3px solid transparent; }
.riga-risultato.is-compilata td:first-child { border-left-color: var(--xl-accent-500); }
.riga-risultato.is-modificata { background: #fffaf0; }
.riga-risultato.is-in-salvataggio { opacity: .6; pointer-events: none; }

.risultato-segno { color: var(--xl-warning); font-size: .5rem; opacity: 0; margin-right: .2rem; vertical-align: middle; }
.riga-risultato.is-modificata .risultato-segno { opacity: 1; }

.risultati-aiuto { font-size: .78rem; color: var(--xl-text-subtle); margin: .8rem 0 0; }
.risultati-aiuto kbd {
	background: var(--xl-surface-alt);
	border: 1px solid var(--xl-border);
	border-bottom-width: 2px;
	border-radius: 4px;
	padding: 0 .3rem;
	font-size: .72rem;
	color: var(--xl-text);
}

@media (max-width: 767.98px) {
	.risultati-barra { flex-direction: column; align-items: stretch; }
	.risultati-azioni { justify-content: space-between; }
}

/* --------------------------------------------------------------------------
   12f. Referti dell'accettazione
   -------------------------------------------------------------------------- */
.referti-barra {
	display: flex;
	align-items: center;
	gap: .5rem;
	flex-wrap: wrap;
	padding-bottom: .9rem;
	margin-bottom: .9rem;
	border-bottom: 1px solid var(--xl-border-soft);
}

.referto-file { display: inline-flex; align-items: center; gap: .35rem; font-size: .84rem; }
.referto-file i { color: #c0392b; }

.referto-motivo {
	display: flex;
	align-items: flex-start;
	gap: .45rem;
	padding: .6rem 1.1rem .7rem 2.2rem;
	background: var(--xl-surface-alt);
	font-size: .82rem;
	color: var(--xl-text-muted);
}
.referto-motivo i { margin-top: .15rem; color: var(--xl-text-subtle); }

.referti-azione .card-header { font-size: .95rem; }
.referti-nota { font-size: .8rem; color: var(--xl-text-muted); margin-bottom: .9rem; }
.form-check-label .referti-nota { margin: .1rem 0 0; font-size: .76rem; }
.referti-pulsanti { display: flex; gap: .5rem; flex-wrap: wrap; }

.form-switch .form-check-input:checked { background-color: var(--xl-brand-600); border-color: var(--xl-brand-600); }
.form-switch .form-check-input:focus { box-shadow: 0 0 0 3px rgba(0, 103, 144, .13); border-color: var(--xl-brand-400); }

/* --------------------------------------------------------------------------
   13. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
	.app-sidebar { transform: translateX(-100%); box-shadow: var(--xl-shadow-lg); }
	.app-shell.is-mobile-open .app-sidebar { transform: translateX(0); width: var(--xl-sidebar-w); }
	.app-main, .app-shell.is-collapsed .app-main { margin-left: 0; }
	.app-shell.is-collapsed .app-sidebar__brand img,
	.app-shell.is-collapsed .app-nav-link span,
	.app-shell.is-collapsed .app-sidebar__section { display: revert; }
	.app-shell.is-collapsed .app-sidebar__brand-mark { display: none; }
	.app-shell.is-collapsed .app-nav-link { justify-content: flex-start; padding: .62rem .7rem; }

	.app-backdrop {
		position: fixed;
		inset: 0;
		background: rgba(10, 25, 40, .45);
		z-index: 1035;
		display: none;
	}
	.app-shell.is-mobile-open .app-backdrop { display: block; }

	.app-content { padding: 1rem .85rem; }
	.app-sections { gap: .15rem; }
	.app-section-tab span { display: none; }
	.app-section-tab { padding: .48rem .7rem; }
	.table-scroll { max-height: none; }

	.campione-card__testa {
		grid-template-columns: 30px 1fr auto;
		grid-template-areas:
			"toggle identita azioni"
			". sintesi sintesi"
			". stato stato";
		row-gap: .5rem;
	}
	.campione-card__toggle  { grid-area: toggle; }
	.campione-card__identita{ grid-area: identita; }
	.campione-card__sintesi { grid-area: sintesi; flex-wrap: wrap; gap: .9rem; }
	.campione-card__stato   { grid-area: stato; justify-content: flex-start; }
	.campione-card__azioni  { grid-area: azioni; }
	.campione-card__dettaglio { padding-left: 1.1rem; }
}

@media (max-width: 575.98px) {
	.app-user-btn span { display: none; }
	.page-header__title { font-size: 1.1rem; }
}

/* --------------------------------------------------------------------------
   14. Stampa
   -------------------------------------------------------------------------- */
@media print {
	.app-sidebar, .app-topbar, .app-pagination, .filter-bar, .td-actions { display: none !important; }
	.app-main { margin-left: 0 !important; }
	.table-card { border: 0; box-shadow: none; }
	.table-scroll { max-height: none; overflow: visible; }
}
