/* PANTHEON COMMON — mobile first, con estensioni per tablet e desktop. */

/* 1. Colori e misure condivise */
:root {
    color-scheme: light;
    --font-sans-serif: "Asap Condensed", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --page-bg: #f4f6fa;
    --header-bg: #ffffff;
    --panel-bg: #ffffff;
    --text: #182232;
    --muted: #627084;
    --muted-hover: #435168;
    --border: #dfe5ee;
    --primary: #245fd4;
    --primary-hover: #194bac;
    --warning: #a65b08;
    --warning-hover: #874703;
    --danger: #bf333b;
    --danger-hover: #a1242c;
    --success: #14804c;
    --lightblue: #3572d6;
    --lightblue-hover: #2458ae;
    --golden: #b98111;
    --golden-hover: #94670b;
    --a-color: #294e89;
    --a-hover-color: #163d79;
    --border-radius: 0.75rem;
    --dropdown-a-hover-bg: #edf2f9;
    --shadow-color: rgb(23 39 63 / 8%);
    --focus-ring: rgb(55 117 225 / 24%);
    --surface-hover: #f7f9fc;
    --field-bg: #fbfcfe;
    --disabled-bg: #edf0f4;
    --on-primary: #ffffff;
}

[data-theme="dark"] {
    color-scheme: dark;
    --page-bg: #10141b;
    --header-bg: #151b24;
    --panel-bg: #1b2029;
    --text: #e8edf5;
    --muted: #a0adbf;
    --muted-hover: #687a94;
    --border: #344154;
    --primary: #3573dc;
    --primary-hover: #4684ee;
    --warning: #e6a447;
    --warning-hover: #c48830;
    --danger: #d84752;
    --danger-hover: #ed5964;
    --success: #3bbd82;
    --lightblue: #91b7f5;
    --lightblue-hover: #b0ccfa;
    --golden: #f1c263;
    --golden-hover: #ffda8e;
    --a-color: #adc9f5;
    --a-hover-color: #d1e2ff;
    --dropdown-a-hover-bg: #243247;
    --shadow-color: rgb(0 0 0 / 22%);
    --focus-ring: rgb(100 159 255 / 32%);
    --surface-hover: #202c3c;
    --field-bg: #131922;
    --disabled-bg: #232c39;
}

/* 2. Reset, testo e focus */
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; -webkit-text-size-adjust: 100%; }
body {
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-sans-serif);
    font-size: 1rem;
    line-height: 1.55;
}
:where(button, input, select, textarea) { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
img, svg { max-width: 100%; vertical-align: middle; }
img { height: auto; }
h1, h2, h3, h4, h5 { line-height: 1.2; font-weight: 650; letter-spacing: -0.025em; }
h1 { font-size: clamp(1.75rem, 3vw, 2.4rem); }
h2 { font-size: clamp(1.5rem, 2.5vw, 2rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }
:where(h1, h2, h3, p, label, small) { overflow-wrap: anywhere; }
small { font-size: 0.85rem; }
a { color: var(--a-color); text-decoration: none; text-underline-offset: 0.2em; }
a:hover { color: var(--a-hover-color); }
hr { height: 0; margin: 0.75rem 0; border: 0; border-top: 1px solid var(--border); }
:focus-visible { outline: 3px solid var(--lightblue); outline-offset: 3px; }
[hidden], input[type="hidden"] { display: none !important; }

/* 3. Struttura e navigazione */
.container { width: min(100%, 1160px); min-width: 0; margin-inline: auto; padding: 1.1rem 0.85rem 1.5rem; flex: 1; }
.page-header { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 0.5rem; margin-bottom: 1.1rem; }
.page-header > .btn { width: 100%; }
.page-header .btn { align-self: center; }
.page-header h2 { margin: 0; }
.page-header h5, .page-header p { margin: 0; color: var(--muted); font-weight: 400; }
.page-header > .btn-back { grid-column: 1 / -1; justify-self: start; margin-bottom: 0.25rem; }
.context-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.35rem 1rem; padding: 0.5rem 0.85rem; border-bottom: 1px solid var(--border); background: var(--panel-bg); font-size: 0.9rem; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.stat-card { min-width: 0; padding: 0.85rem; border: 1px solid var(--border); border-radius: var(--border-radius); background: var(--panel-bg); }
.stat-card strong { display: block; font-size: 1.75rem; line-height: 1.2; }
.stat-card span { color: var(--muted); font-size: 0.9rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
.col { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.col.center { justify-content: center; }
.col.end { justify-content: flex-end; margin-left: auto; }
body > header[data-theme] {
    --header-bg: #080808;
    --panel-bg: #111214;
    --text: #f5f6fa;
    --muted: #a7afbe;
    --border: #2c2e34;
    --surface-hover: #1d2027;
    --dropdown-a-hover-bg: #1d2027;
    --a-color: #e1e8f5;
    --a-hover-color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 200;
    padding: 0.45rem 0.85rem;
    background: #080808;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 3px 16px rgb(0 0 0 / 12%);
}
header > .row { max-width: 1160px; margin-inline: auto; }
header nav { display: none; }
header .nav-brand { display: inline-flex; align-items: center; min-height: 36px; width: 44px; }
header .nav-brand img { width: 100%; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 36px; padding: 0; border: 0; border-radius: 0.65rem; background: transparent; color: inherit; font-size: 1.1rem; }
.theme-toggle:hover { background: var(--dropdown-a-hover-bg); }
.header-actions { position: relative; gap: 0.25rem; }
#greetings { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; min-width: 0; min-height: 36px; padding: 0.3rem 0.4rem; border-radius: 0.65rem; }
#greetings:hover { background: var(--dropdown-a-hover-bg); }
.greeting-name { display: block; min-width: 0; max-width: 10rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 0.85rem; }
.greeting-arrow { flex-shrink: 0; }
.nav-brand { flex-shrink: 0; }
nav ul { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; list-style: none; padding: 0; margin: 0; }
header nav a { display: block; padding: 0.5rem 0.8rem; border-radius: 0.4rem; color: var(--muted); font-weight: 550; }
header nav a:hover, header nav a.active { color: var(--text); background: var(--dropdown-a-hover-bg); }
.nav-dropdown { position: relative; }
.nav-dropdown > a { display: flex; align-items: center; gap: 0.4rem; }
.nav-dropdown > a i { font-size: 0.7em; }
.nav-submenu, [data-dropdown] {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    min-width: 12rem;
    max-width: calc(100vw - 2rem);
    margin: 0;
    padding: 0.4rem;
    list-style: none;
    background: var(--panel-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: 0 12px 32px var(--shadow-color);
    z-index: 150;
}
[data-dropdown] { right: 0; }
.nav-submenu { left: 0; top: 100%; }
.nav-submenu a, [data-dropdown] a { display: block; padding: 0.55rem 0.8rem; border-radius: 0.3rem; }
[data-dropdown] form { margin: 0; }
[data-dropdown] button { display: block; width: 100%; padding: 0.55rem 0.8rem; border: 0; border-radius: 0.3rem; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.nav-submenu a:hover, [data-dropdown] a:hover, [data-dropdown] button:hover { background: var(--dropdown-a-hover-bg); }
[data-dropdown].open, .nav-dropdown:hover .nav-submenu, .nav-dropdown:focus-within .nav-submenu { display: block; }
.fa-moon { color: var(--lightblue); }
.fa-lightbulb { color: var(--golden); }

/* 4. Form: i campi di testo non stilizzano checkbox e radio */
.form { max-width: 640px; width: 100%; margin: 0 auto; text-align: left; }
.form-wide { max-width: 860px; padding: 0.85rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--panel-bg); box-shadow: 0 4px 20px var(--shadow-color); }
.form-section { padding-block: 0.15rem 0.9rem; }
.form-section + .form-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.form-section h3 { margin: 0 0 0.75rem; }
.form fieldset { min-width: 0; margin: 0.75rem 0 0; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--border-radius); }
.form fieldset:disabled { opacity: 0.6; }
.form legend { padding-inline: 0.3rem; color: var(--muted); font-size: 0.85rem; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.form-group { min-width: 0; margin-bottom: 0.9rem; }
.form-group label:not(.switch) { display: block; margin-bottom: 0.45rem; color: var(--text); font-size: 0.9rem; font-weight: 600; }
:where(input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], input[type="url"], input[type="search"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"], input[type="week"], select, textarea) {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 2.5rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    padding: 0.5rem 0.7rem;
    color: var(--text);
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
:where(input, select, textarea)::placeholder { color: var(--muted); opacity: 0.8; }
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
    border-color: var(--lightblue);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}
textarea { min-height: 7rem; resize: vertical; }
select { padding-right: 1.75rem; cursor: pointer; }
select:not([multiple]):not([size]), select[size="1"]:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    height: calc(1.5em + 1rem + 2px);
    padding-right: 2.25rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: right 1.05rem center, right 0.75rem center;
    background-size: 0.3rem 0.3rem;
    background-repeat: no-repeat;
}
select[multiple] { min-height: 7rem; }
input[type="file"] { width: 100%; color: var(--muted); }
input[type="file"]::file-selector-button { margin-right: 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 0.4rem; background: var(--panel-bg); color: var(--text); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
input[type="color"] { width: 3rem; height: 2.8rem; border: 1px solid var(--border); border-radius: 0.4rem; background: var(--field-bg); }
:where(input, select, textarea):disabled { cursor: not-allowed; opacity: 0.6; }
:where(input, textarea)[readonly] { background: var(--disabled-bg); }
.form-hint { display: block; margin-top: 0.4rem; color: var(--muted); font-size: 0.83rem; line-height: 1.5; font-weight: 400; }
.form-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.65rem; margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.form-actions > .btn { flex: 1; }
.form-actions.sticky-actions { margin-top: 0.75rem; }

/* Campo con icona: il bordo e il focus appartengono al gruppo. */
.input-group { display: flex; align-items: stretch; overflow: hidden; border: 1px solid var(--border); border-radius: var(--border-radius); background: var(--field-bg); transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.input-group:focus-within { border-color: var(--lightblue); box-shadow: 0 0 0 3px var(--focus-ring); }
.input-group input { flex: 1; min-height: 42px; padding: 0.55rem 0.7rem; border: 0; background: transparent; outline: none; }
.input-group input:focus { box-shadow: none; }
.input-group-icon { display: flex; align-items: center; justify-content: center; min-width: 44px; color: var(--muted); cursor: pointer; transition: color 0.2s ease; }
.input-group-icon:hover { color: var(--lightblue); }

/* Controlli nativi: stato selezionato, focus, disabilitato e tastiera. */
input[type="checkbox"], input[type="radio"] {
    appearance: auto;
    -webkit-appearance: auto;
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    margin: 0;
    flex: 0 0 1.25rem;
    vertical-align: -0.18em;
    accent-color: var(--primary);
    cursor: pointer;
}
.form-group label:not(.switch):has(> input[type="checkbox"]),
.form-group label:has(> input[type="radio"]), .checkbox-simple {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    line-height: 1.5;
    cursor: pointer;
}
.checkbox-simple span { flex: 1; }
.checkbox-simple strong, .checkbox-simple small { display: block; }
.checkbox-simple small { color: var(--muted); }
.radio-group { display: grid; gap: 0.75rem; }
.radio-option { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--border-radius); cursor: pointer; }
.radio-option input { margin-top: 0.25rem; }
.radio-option span { display: grid; gap: 0.25rem; }
.radio-option small { color: var(--muted); }
.radio-option:has(:checked) { border-color: var(--lightblue); background: var(--surface-hover); }
.radio-option:focus-within { outline: 3px solid var(--focus-ring); }

/* Switch: solo il suo input e trasparente, l'area resta raggiungibile. */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: 0 0 48px; margin: 0 0.25rem; vertical-align: middle; }
.switch input[type="checkbox"] { position: absolute; inset: -8px 0; width: 100%; height: 44px; opacity: 0; margin: 0; z-index: 1; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--muted-hover); transition: background 150ms ease; pointer-events: none; }
.slider::before { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 18%); transition: transform 150ms ease; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--lightblue); outline-offset: 3px; }
.switch:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

/* 5. Pulsanti, badge e messaggi */
.btn, .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 38px;
    padding: 0.45rem 0.8rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    white-space: normal;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-warning { background: var(--warning); color: var(--page-bg); }
.btn-warning:hover { background: var(--warning-hover); color: var(--page-bg); }
.btn-secondary { background: var(--panel-bg); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--muted); color: var(--text); }
.btn-sm { min-height: 32px; padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn:disabled, .btn-icon:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 0.25rem; }
.btn-icon { width: 36px; min-height: 36px; padding: 0.35rem; color: var(--a-color); background: transparent; }
.btn-icon:hover { background: var(--surface-hover); }
.btn-icon.danger:hover { color: var(--danger); }
.btn-back { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.badge { display: inline-block; padding: 0.25rem 0.65rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-success { color: var(--success); border-color: currentColor; }
.badge-danger { color: var(--danger); border-color: currentColor; }
.alert { padding: 1rem; border: 1px solid var(--border); border-radius: var(--border-radius); }
.alert-warning { background: rgba(235, 139, 16, 0.1); border-color: var(--warning); color: var(--warning); }
.alert-warning i { margin-right: 0.5rem; }
.alert-warning strong { display: block; margin-bottom: 0.5rem; }
.empty-state { padding: 3rem 1.25rem !important; text-align: center; color: var(--muted) !important; }
.empty-state i { font-size: 2rem; }
.empty-state p { margin-top: 0.75rem; }

/* 6. Tabelle: lo scroll orizzontale rimane dentro il contenitore */
.table-container { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; margin-block: 1.25rem; border: 1px solid var(--border); border-radius: 0.9rem; background: var(--panel-bg); box-shadow: 0 3px 18px var(--shadow-color); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; text-align: left; }
.table th, .table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); background: var(--header-bg); font-size: 0.75rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table td a:not(.btn) { color: var(--a-color); text-decoration: underline; }
.table .actions { text-align: right; white-space: nowrap; }
.table-sort { display: inline-flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; text-transform: inherit; letter-spacing: inherit; }
.sort-indicator { flex-shrink: 0; color: var(--muted); }
.sort-indicator::before { content: "↕"; }
th[aria-sort="ascending"] .sort-indicator::before { content: "↑"; }
th[aria-sort="descending"] .sort-indicator::before { content: "↓"; }
th[aria-sort] .sort-indicator { color: var(--lightblue); }
.table-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.4rem; }
.table-summary { color: var(--muted); font-size: 0.9rem; }
.table-search { display: grid; gap: 0.25rem; flex: 1 1 16rem; }
.table-search label { color: var(--muted); font-size: 0.85rem; }
.table-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; }
.page-size { display: inline-flex; align-items: center; gap: 0.5rem; }
.page-size select { width: auto; }
.table-filter { display: grid; gap: 0.25rem; flex: 1 1 8rem; min-width: 0; color: var(--muted); font-size: 0.85rem; }
.table-filter select { min-width: 0; width: 100%; }
.mobile-label { display: none; }
.row-actions-toggle { min-width: 2rem; }
.row-actions-toggle [aria-hidden] { font-size: 1.15rem; line-height: 1; }
.row-actions-menu { position: fixed; z-index: 400; display: grid; min-width: 10rem; max-width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); overflow-y: auto; padding: 0.3rem; border: 1px solid var(--border); border-radius: var(--border-radius); background: var(--panel-bg); box-shadow: 0 8px 32px var(--shadow-color); text-align: left; white-space: normal; }
.row-actions-menu a, .row-actions-menu button { display: block; width: 100%; padding: 0.5rem 0.7rem; border: 0; border-radius: 0.3rem; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.table td .row-actions-menu a { color: var(--text); text-decoration: none; }
.row-actions-menu a:hover, .row-actions-menu button:hover { background: var(--surface-hover); }

@media (max-width: 639px) {
    .responsive-table, .responsive-table tbody { display: block; }
    .responsive-table thead { display: none; }
    .responsive-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0.35rem 0.65rem; padding: 0.75rem; border-bottom: 1px solid var(--border); }
    .responsive-table tbody tr:last-child { border-bottom: 0; }
    .responsive-table td { display: block; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
    .responsive-table .record-identity { grid-column: 1 / span 2; grid-row: 1; font-weight: 600; }
    .responsive-table .record-code { grid-column: 1 / span 2; grid-row: 2; color: var(--muted); font-size: 0.85rem; }
    .responsive-table .actions { grid-column: 3; grid-row: 1 / span 2; align-self: start; white-space: normal; }
    .responsive-table .empty-state { grid-column: 1 / -1; }
    .responsive-table .mobile-label { display: inline; color: var(--muted); }
    .table-search { flex-basis: 100%; }
}

/* Stato condiviso per pagina, tabelle e operazioni asincrone. */
html.is-loading { cursor: progress; }
html.is-loading body::after { content: ""; position: fixed; inset: 0; z-index: 1100; background: rgb(0 0 0 / 8%); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); pointer-events: none; }
.loader-spinner { display: inline-block; flex: 0 0 1rem; width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: loaderSpin 0.7s linear infinite; }
.loading-message { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.page-loader { position: fixed; top: 0.6rem; left: 50%; z-index: 1200; display: flex; align-items: center; gap: 0.5rem; max-width: calc(100% - 1.5rem); padding: 0.45rem 0.8rem; border: 1px solid var(--border); border-radius: var(--border-radius); background: var(--panel-bg); color: var(--text); box-shadow: 0 4px 24px var(--shadow-color); transform: translateX(-50%); pointer-events: none; font-size: 0.9rem; }
@keyframes loaderSpin { to { transform: rotate(360deg); } }

/* 7. Modal: dimensioni, contenuto scrollabile e chiusura sempre accessibile */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; padding: 0; background: rgb(0 0 0 / 62%); backdrop-filter: blur(5px); overscroll-behavior: contain; }
.modal.show { display: flex; align-items: flex-end; justify-content: center; }
.modal-content { width: 100%; max-width: 100%; max-height: calc(100vh - 1rem); max-height: calc(100dvh - 1rem); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-bottom: 0; border-radius: 1.25rem 1.25rem 0 0; background: var(--panel-bg); box-shadow: 0 -12px 64px rgb(0 0 0 / 24%); animation: dialogIn 150ms ease-out; }
.modal-content:focus { outline: none; }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); background: var(--panel-bg); }
.modal-header h3 { margin: 0; font-size: 1.15rem; }
.modal-close { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 0.4rem; background: transparent; color: var(--muted); font-size: 1.6rem; line-height: 1; }
.modal-close:hover { color: var(--text); background: var(--surface-hover); }
.modal .form { max-width: none; padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom)); }
.modal .form-actions { margin-top: 1rem; }
.modal-loading, .modal-error { padding: 2.5rem 1.5rem; text-align: center; color: var(--muted); }
.modal-error { color: var(--danger); }
.no-scroll { overflow: hidden; }

/* 8. Filtri, footer e utility condivise */
.filter-section { padding: 0.9rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--border-radius); background: var(--panel-bg); }
.filter-bar { display: flex; justify-content: flex-start; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: 0.85rem; background: var(--panel-bg); }
.status-filter { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.status-filter [aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.toggle-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.toggle-label { font-size: 0.95rem; color: var(--muted); transition: color 0.2s ease; }
.toggle-label.active { color: var(--text); font-weight: 600; }
footer { margin-top: auto; }
.footer-copyright { display: none; padding: 1.25rem 2rem; color: var(--muted); font-size: 0.8rem; text-align: right; }
body:has(.bottom-nav) { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px)); }
.bottom-nav { position: fixed; inset: auto 0 0; z-index: 150; display: flex; padding: 0.25rem 0.5rem calc(0.25rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); background: var(--panel-bg); box-shadow: 0 -4px 24px var(--shadow-color); }
.bottom-nav-item { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem; min-height: 3.25rem; padding: 0.5rem; border-radius: 0.75rem; color: var(--muted); font-size: 0.75rem; }
.bottom-nav-item.active { background: var(--surface-hover); color: var(--lightblue); }
.bottom-nav-item i { font-size: 1.2rem; }
.bottom-nav-more { position: relative; }
.bottom-nav-menu { display: none; position: absolute; right: 0; bottom: 100%; min-width: 12rem; padding: 0.4rem; border: 1px solid var(--border); border-radius: var(--border-radius); background: var(--panel-bg); box-shadow: 0 8px 32px var(--shadow-color); }
.bottom-nav-menu.open { display: block; }
.bottom-nav-menu-item { display: flex; gap: 0.7rem; padding: 0.65rem 0.8rem; white-space: nowrap; }
.pointer { cursor: pointer; }
.text-center { text-align: center !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-secondary { color: var(--muted) !important; }
.underline { text-decoration: underline !important; }
.lowercase { text-transform: lowercase; }
.disabled { opacity: 0.55; cursor: not-allowed; }

/* 9. Si parte dal telefono: colonne e spazi si ampliano quando c'e posto. */
@media (min-width: 640px) {
    .mobile-sort { display: none; }
    .table-filter { flex: 0 1 12rem; }
    .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .container { padding: 1.6rem 1.25rem; }
    .page-header { grid-template-columns: minmax(0, 1fr) auto; gap: 0.45rem 1.25rem; }
    .page-header > .btn { width: auto; }
    .page-header h2, .page-header h5, .page-header p { grid-column: 1; }
    .page-header:has(> h5) > .btn { grid-column: 2; grid-row: 1 / span 2; }
    .header-actions { gap: 0.5rem; }
    .form-wide { padding: 1.25rem; }
    .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    .form-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
    .modal { padding: 2rem; }
    .modal.show { align-items: center; }
    .modal-content { max-width: 560px; max-height: calc(100vh - 4rem); max-height: calc(100dvh - 4rem); border: 1px solid var(--border); border-radius: 1rem; box-shadow: 0 24px 80px rgb(0 0 0 / 30%); }
    .modal-header { padding: 0.8rem 1.1rem; }
    .modal .form { padding: 1.1rem; }
    .table th, .table td { padding: 0.75rem 0.9rem; }
}
@media (min-width: 960px) {
    .container { padding: 2rem 1.5rem; }
    body > header[data-theme] { padding: 0.55rem 1.5rem; }
    header .row { gap: 2rem; }
    header .col { gap: 1.25rem; }
    header .nav-brand { width: 55px; }
    header nav { display: block; }
    body:has(.bottom-nav) { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .footer-copyright { display: block; }
}
@media (prefers-reduced-motion: reduce) {
    .loader-spinner { animation: none !important; }
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
