:root {
    --cri-red: #b51f2e;
    --cri-red-dark: #861522;
    --cri-red-soft: #fff1f2;
    --ink: #17202a;
    --muted: #667085;
    --line: #e4e7ec;
    --surface: #ffffff;
    --background: #f5f7fa;
    --success: #16794b;
    --warning: #a15c00;
    --danger: #b42318;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(16, 24, 40, .08);
    --sidebar-width: 268px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--background);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: var(--cri-red); text-decoration: none; }
a:hover { color: var(--cri-red-dark); }
img { max-width: 100%; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) 1fr; grid-template-rows: 76px 1fr auto; }
.app-shell-guest { grid-template-columns: 1fr; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 76px;
    padding: 12px 26px;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.brand span, .user-chip span:last-child { display: grid; }
.brand strong { font-size: 1.05rem; letter-spacing: -.01em; }
.brand small, .user-chip small { color: var(--muted); font-size: .78rem; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: white; background: var(--cri-red); font-weight: 800; font-size: .8rem; }
.nav-toggle { display: none; border: 0; background: transparent; padding: 10px; font-size: 1.25rem; cursor: pointer; }

.sidebar {
    position: sticky;
    top: 76px;
    align-self: start;
    height: calc(100vh - 76px);
    overflow-y: auto;
    padding: 18px 14px 24px;
    background: #111827;
    color: #fff;
}
.primary-nav { display: grid; gap: 5px; }
.primary-nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 13px; border-radius: 10px; color: #d8dee9; font-weight: 650; font-size: .92rem; }
.primary-nav a i { width: 20px; text-align: center; }
.primary-nav a:hover, .primary-nav a.active { background: rgba(255,255,255,.11); color: #fff; }
.primary-nav a.active { box-shadow: inset 3px 0 0 #ff6475; }
.primary-nav .nav-danger { color: #ffb4bd; }
.nav-section { margin: 18px 12px 7px; color: #8892a6; font-size: .7rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }

.main-content { min-width: 0; padding: 28px clamp(18px, 3vw, 42px) 48px; }
.app-shell-guest .main-content { width: min(100%, 540px); margin: 0 auto; padding-top: 48px; }
.app-footer { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 20px; padding: 18px 28px; color: var(--muted); background: #fff; border-top: 1px solid var(--line); font-size: .85rem; }

h1, h2, h3, h4 { line-height: 1.2; margin-top: 0; color: #101828; letter-spacing: -.025em; }
h1 { font-size: clamp(1.8rem, 3vw, 2.5rem); margin-bottom: 10px; }
h2 { font-size: 1.45rem; margin-bottom: 16px; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1rem; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 26px; }
.page-heading p { color: var(--muted); max-width: 760px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card, .shadow-container, .no-shadow-container, fieldset {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card, .shadow-container, .no-shadow-container { padding: clamp(18px, 2.5vw, 28px); margin-bottom: 22px; }
fieldset { padding: 18px; margin: 0 0 18px; }
legend { padding: 0 8px; font-weight: 800; }
.card-muted { background: #f9fafb; box-shadow: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { position: relative; overflow: hidden; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card small { display: block; color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; margin-top: 8px; font-size: 2rem; line-height: 1; }
.stat-card i { position: absolute; right: 16px; top: 17px; color: var(--cri-red); opacity: .18; font-size: 2.2rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

form { max-width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-group { display: grid; gap: 7px; margin-bottom: 15px; }
label { font-weight: 700; color: #344054; font-size: .9rem; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #cfd4dc;
    border-radius: 9px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
select[multiple] { min-height: 130px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--cri-red); box-shadow: 0 0 0 3px rgba(181,31,46,.12); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--cri-red); }

button, .button, input[type="submit"], .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 16px;
    color: #fff;
    background: var(--cri-red);
    border: 1px solid var(--cri-red);
    border-radius: 9px;
    font-weight: 750;
    cursor: pointer;
    transition: transform .1s, background .15s, border-color .15s;
}
button:hover, .button:hover, input[type="submit"]:hover, .btn:hover { color: #fff; background: var(--cri-red-dark); border-color: var(--cri-red-dark); }
button:active, .button:active, .btn:active { transform: translateY(1px); }
.btn-secondary { color: #344054; background: #fff; border-color: #cfd4dc; }
.btn-secondary:hover { color: #101828; background: #f2f4f7; border-color: #b8c0cc; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-small { min-height: 34px; padding: 6px 10px; font-size: .82rem; }

.table-responsive { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: #475467; background: #f8fafc; font-size: .78rem; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfd; }

.alert { padding: 13px 15px; margin: 0 0 18px; border: 1px solid transparent; border-radius: 10px; font-weight: 650; }
.alert-success { color: #11623d; background: #ecfdf3; border-color: #abefc6; }
.alert-danger, .alert-error { color: #912018; background: #fef3f2; border-color: #fecdca; }
.alert-warning { color: #7a2e0e; background: #fffaeb; border-color: #fedf89; }
.alert-info { color: #1849a9; background: #eff8ff; border-color: #b2ddff; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: #f2f4f7; color: #344054; }
.badge-success { background: #dcfae6; color: #085d3a; }
.badge-warning { background: #fef0c7; color: #93370d; }
.badge-danger { background: #fee4e2; color: #912018; }
.badge-info { background: #d1e9ff; color: #1849a9; }

.login-card { padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(16,24,40,.12); }
.login-card .brand-mark { display: grid; place-items: center; margin-bottom: 18px; }
.login-card .brand-mark img { width: 92px; }
.login-card h1 { text-align: center; font-size: 1.75rem; }
.login-card > p { text-align: center; color: var(--muted); }

.warehouse-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.warehouse-nav a { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; color: #344054; background: #fff; font-weight: 700; font-size: .86rem; }
.warehouse-nav a:hover, .warehouse-nav a.active { color: #fff; background: var(--cri-red); border-color: var(--cri-red); }
.stock-positive { color: var(--success); font-weight: 800; }
.stock-zero { color: var(--danger); font-weight: 800; }

.checklist-wrapper { display: grid; gap: 16px; }
.category-wrapper fieldset { box-shadow: none; }
.category-content { display: grid; gap: 12px; }
.checklist-item { display: grid; grid-template-columns: minmax(220px, 1fr) 160px minmax(190px, .7fr); gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.checklist-item-main { display: flex; align-items: center; gap: 12px; }
.checklist-item-main img { width: 70px; height: 70px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.checklist-item-main small { display: block; color: var(--muted); }
.checklist-item-quantita { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.checklist-item-quantita .form-group { margin: 0; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state i { display: block; margin-bottom: 12px; color: #98a2b3; font-size: 2rem; }
.muted { color: var(--muted); }
.text-right { text-align: right; }

/* Compatibilità con classi preesistenti */
.home-button, .exit-button { display: inline-flex; padding: 8px 12px; margin: 3px; border-radius: 8px; background: var(--cri-red); color: white; }
.base-links-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.modal { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.7); padding: 30px; }
.modal-content { max-width: 900px; margin: auto; padding: 20px; background: #fff; border-radius: 12px; }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .topbar { padding-inline: 16px; }
    .nav-toggle { display: inline-grid; margin-left: auto; }
    .user-chip { display: none; }
    .sidebar { position: fixed; z-index: 70; top: 76px; left: 0; width: min(86vw, var(--sidebar-width)); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 14px 0 40px rgba(0,0,0,.25); }
    .sidebar.open { transform: translateX(0); }
    .main-content { grid-column: 1; }
    .app-footer { grid-column: 1; }
    .checklist-item { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .main-content { padding: 20px 13px 38px; }
    .page-heading { display: grid; }
    .stats-grid, .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
    .card, .shadow-container, .no-shadow-container { padding: 16px; border-radius: 12px; }
    .app-footer { display: grid; padding: 16px; }
    th, td { padding: 10px; }
    .checklist-item-quantita { grid-template-columns: 1fr; }
}

/* Profilo utente */
.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(330px, .85fr);
    gap: 22px;
    align-items: start;
}
.profile-data-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}
.profile-data-item {
    min-width: 0;
    padding: 14px 16px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}
.profile-data-item:nth-child(odd) { border-right: 1px solid var(--line); }
.profile-data-item:nth-last-child(-n + 2) { border-bottom: 0; }
.profile-data-item dt {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.profile-data-item dd {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    font-weight: 650;
    overflow-wrap: anywhere;
}
.profile-consent-card { position: sticky; top: 98px; }
.consent-options { display: grid; gap: 10px; }
.consent-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: start;
    width: 100%;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    cursor: pointer;
}
.consent-option:hover { border-color: #c6ccd5; background: #fcfcfd; }
.consent-option input { margin-top: 4px; }
.consent-option span { display: grid; gap: 2px; }
.consent-option small { color: var(--muted); font-weight: 500; }
.consent-actions { margin-top: 16px; }
.consent-history { margin-top: 22px; }
.consent-history summary { cursor: pointer; color: #344054; font-weight: 800; }
.consent-history .table-responsive { margin-top: 12px; }

@media (max-width: 1180px) {
    .profile-layout { grid-template-columns: 1fr; }
    .profile-consent-card { position: static; }
}

@media (max-width: 700px) {
    .profile-data-grid { grid-template-columns: 1fr; }
    .profile-data-item,
    .profile-data-item:nth-child(odd),
    .profile-data-item:nth-last-child(-n + 2) {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .profile-data-item:last-child { border-bottom: 0; }
}

/* Correzioni touch / iPadOS */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

a,
button,
input[type="submit"],
input[type="button"],
.btn,
.button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(181, 31, 46, .16);
}

a[href], button:not(:disabled) { cursor: pointer; }
.main-content { position: relative; z-index: 1; }
.primary-nav a,
a.card,
.page-actions a,
.home-button,
.exit-button {
    position: relative;
    z-index: 2;
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 76px 0 0;
    z-index: 60;
    width: 100%;
    height: calc(100dvh - 76px);
    min-height: calc(100vh - 76px);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(17, 24, 39, .38);
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 980px) {
    body.nav-open { overflow: hidden; }

    .sidebar {
        z-index: 80;
        visibility: hidden;
        pointer-events: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        will-change: transform;
    }

    .sidebar.open {
        visibility: visible;
        pointer-events: auto;
    }

    .nav-backdrop {
        display: block;
        visibility: hidden;
        transition: opacity .2s ease, visibility 0s linear .2s;
    }

    .nav-backdrop.open {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transition-delay: 0s;
    }

    .nav-toggle {
        position: relative;
        z-index: 90;
        min-width: 44px;
        min-height: 44px;
    }

    .primary-nav a {
        min-height: 48px;
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Safari/iPad può creare un layer trasparente sopra ai link con sticky + blur. */
@supports (-webkit-touch-callout: none) {
    .topbar {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        background: #fff;
    }

    .sidebar {
        transform: translateZ(0);
    }
}

@media (hover: none) and (pointer: coarse) {
    a:hover { color: inherit; }
    .primary-nav a:hover { background: transparent; color: #d8dee9; }
    .primary-nav a.active { background: rgba(255,255,255,.11); color: #fff; }
    button:not(.nav-toggle):not(.nav-backdrop):hover, .button:hover, input[type="submit"]:hover, .btn:hover {
        background: var(--cri-red);
        border-color: var(--cri-red);
    }
    .btn-secondary:hover {
        color: #344054;
        background: #fff;
        border-color: #cfd4dc;
    }
}

/* Navigazione mobile v6: pulsante visibile anche senza Font Awesome. */
.nav-toggle-icon {
    display: grid;
    width: 22px;
    gap: 4px;
}
.nav-toggle-icon > span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}
.nav-toggle-label {
    font-size: .88rem;
    font-weight: 800;
}

@media (max-width: 980px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-width: 86px;
        min-height: 44px;
        padding: 8px 12px;
        color: #17202a;
        background: #fff;
        border: 1px solid #cfd4dc;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(16, 24, 40, .08);
    }
    .nav-toggle:hover,
    .nav-toggle:active,
    .nav-toggle:focus-visible {
        color: #17202a;
        background: #f8fafc;
        border-color: #98a2b3;
    }
}

/* Tabelle e anagrafica responsive v7 */
.breakable,
td,
dd {
    overflow-wrap: anywhere;
    word-break: normal;
}

.text-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    letter-spacing: .02em;
}

.text-uppercase { text-transform: uppercase; }

.table-responsive {
    position: relative;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    background: #fff;
}

.table-responsive > table,
table.data-table {
    width: 100%;
    min-width: 640px;
    margin: 0;
    border: 0 !important;
    table-layout: auto;
}

.data-table th,
.data-table td {
    max-width: 360px;
    border-left: 0 !important;
    border-right: 0 !important;
}

.data-table td form {
    margin: 0;
}

.data-table td img {
    display: block;
    width: auto;
    max-width: 100px;
    height: auto;
    max-height: 100px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.table-scroll-hint {
    display: none;
    align-items: center;
    gap: 7px;
    margin: 0 0 8px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.table-actions,
.data-table td:last-child {
    min-width: 116px;
}

.data-table td:last-child form,
.data-table td:last-child .button,
.data-table td:last-child .btn,
.data-table td:last-child > a {
    margin: 2px;
}

.data-table input[type="submit"],
.data-table button,
.data-table .button,
.data-table .btn {
    min-height: 36px;
    padding: 7px 10px;
    font-size: .82rem;
    white-space: normal;
}

/* Elenco anagrafico a schede: evita una tabella da 26 colonne. */
.directory-toolbar {
    display: grid;
    gap: 10px;
}

.search-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.search-toolbar-field { margin: 0; }
.search-toolbar-actions { margin: 0; flex-wrap: nowrap; }
.directory-count { margin: 0; font-weight: 700; }

.people-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.person-card {
    min-width: 0;
    display: grid;
    align-content: start;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 15px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.person-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(180deg, #fff 0%, #fcfcfd 100%);
    border-bottom: 1px solid var(--line);
}

.person-card-header h2 {
    margin: 2px 0 8px;
    font-size: 1.22rem;
    line-height: 1.25;
}

.person-card-id {
    color: var(--muted);
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.person-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    color: #fff;
    background: var(--cri-red);
    font-size: .8rem;
    font-weight: 850;
}

.person-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 4px 18px 14px;
}

.person-summary > div {
    min-width: 0;
    padding: 12px 10px 10px 0;
    border-bottom: 1px solid var(--line);
}

.person-summary > div:nth-child(even) {
    padding-left: 14px;
    border-left: 1px solid var(--line);
}

.person-summary .person-summary-wide {
    grid-column: 1 / -1;
    padding-left: 0;
    border-left: 0;
}

.person-summary dt,
.record-data-grid dt {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.person-summary dd,
.record-data-grid dd {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    font-weight: 650;
}

.record-details {
    margin: 0 18px 16px;
    border: 1px solid var(--line);
    border-radius: 11px;
    overflow: hidden;
}

.record-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 10px 13px;
    color: #344054;
    background: #f8fafc;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.record-details > summary::-webkit-details-marker { display: none; }
.record-details > summary i { transition: transform .18s ease; }
.record-details[open] > summary i { transform: rotate(180deg); }

.record-details-content {
    display: grid;
    gap: 18px;
    padding: 16px;
    border-top: 1px solid var(--line);
}

.record-detail-group h3 {
    margin: 0 0 10px;
    color: var(--cri-red-dark);
    font-size: .92rem;
}

.record-data-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    margin: 0;
}

.record-data-grid > div {
    min-width: 0;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--line);
}

.person-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 14px 18px 18px;
    margin-top: auto;
}

.person-card-actions form { margin: 0; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 24px 0;
}

.pagination-link {
    display: inline-grid;
    place-items: center;
    min-width: 40px;
    min-height: 40px;
    padding: 7px 10px;
    color: #344054;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-weight: 800;
}

.pagination-link:hover,
.pagination-link.current {
    color: #fff;
    background: var(--cri-red);
    border-color: var(--cri-red);
}

.pagination-link.disabled {
    opacity: .45;
    pointer-events: none;
}

.pagination-ellipsis { padding: 0 4px; color: var(--muted); }

.stacked-form {
    display: grid;
    gap: 18px;
}

.form-section {
    margin: 0;
}

.form-section legend {
    padding: 0 8px;
    color: var(--cri-red-dark);
    font-size: 1rem;
    font-weight: 850;
}

.form-grid-adaptive {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-group-wide { grid-column: span 2; }
.field-help { color: var(--muted); font-size: .8rem; }
.form-submit-bar {
    position: sticky;
    bottom: 12px;
    z-index: 15;
    padding: 12px;
    margin: 0;
    background: rgba(255,255,255,.96);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(16,24,40,.12);
    backdrop-filter: blur(10px);
}

.alert-list { margin: 8px 0 0; padding-left: 20px; }

/* Correzione della griglia del profilo quando il numero di campi è dispari. */
.profile-data-item:nth-last-child(-n + 2) { border-bottom: 1px solid var(--line); }
.profile-data-item:nth-last-child(2):nth-child(odd),
.profile-data-item:last-child { border-bottom: 0; }

@media (max-width: 1180px) {
    .people-grid { grid-template-columns: 1fr; }
    .form-grid-adaptive { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .search-toolbar { grid-template-columns: 1fr; }
    .search-toolbar-actions { flex-wrap: wrap; }

    .table-scroll-hint { display: flex; }

    .table-responsive:not(.table-cards) {
        margin-inline: -2px;
        border-radius: 10px;
    }

    .table-responsive:not(.table-cards) > table {
        min-width: 760px;
    }

    /* Le tabelle semplici diventano schede leggibili sul telefono. */
    .table-responsive.table-cards {
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
    }

    .table-responsive.table-cards .table-scroll-hint { display: none; }

    .data-table.is-card-table {
        min-width: 0;
        background: transparent;
    }

    .data-table.is-card-table,
    .data-table.is-card-table tbody,
    .data-table.is-card-table tr,
    .data-table.is-card-table td {
        display: block;
        width: 100%;
    }

    .data-table.is-card-table .table-header-row,
    .data-table.is-card-table thead {
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        padding: 0 !important;
        margin: -1px !important;
        overflow: hidden !important;
        clip: rect(0, 0, 0, 0) !important;
        white-space: nowrap !important;
        border: 0 !important;
    }

    .data-table.is-card-table tbody tr {
        margin-bottom: 14px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
        box-shadow: 0 4px 14px rgba(16,24,40,.06);
        overflow: hidden;
    }

    .data-table.is-card-table tbody tr:last-child { margin-bottom: 0; }

    .data-table.is-card-table td {
        display: grid;
        grid-template-columns: minmax(105px, 38%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        max-width: none;
        min-height: 44px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
        background: #fff;
        text-align: left !important;
    }

    .data-table.is-card-table td:last-child { border-bottom: 0; }

    .data-table.is-card-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .72rem;
        font-weight: 850;
        letter-spacing: .035em;
        text-transform: uppercase;
    }

    .data-table.is-card-table td[data-label=""],
    .data-table.is-card-table td[colspan] {
        grid-template-columns: 1fr;
    }

    .data-table.is-card-table td[data-label=""]::before,
    .data-table.is-card-table td[colspan]::before {
        display: none;
    }

    .data-table.is-card-table td form,
    .data-table.is-card-table td:last-child {
        min-width: 0;
    }

    .data-table.is-card-table td:last-child .button,
    .data-table.is-card-table td:last-child .btn,
    .data-table.is-card-table td:last-child button,
    .data-table.is-card-table td:last-child input[type="submit"] {
        width: 100%;
        margin: 3px 0;
    }

    .person-summary,
    .record-data-grid,
    .form-grid-adaptive {
        grid-template-columns: 1fr;
    }

    .person-summary > div,
    .person-summary > div:nth-child(even),
    .person-summary .person-summary-wide {
        grid-column: auto;
        padding: 11px 0;
        border-left: 0;
    }

    .form-group-wide { grid-column: auto; }
    .form-submit-bar { bottom: 6px; }
}

@media (max-width: 460px) {
    .person-card-header { padding: 15px; }
    .person-summary { padding-inline: 15px; }
    .record-details { margin-inline: 15px; }
    .person-card-actions { padding-inline: 15px; }
    .person-card-actions .btn,
    .person-card-actions form,
    .person-card-actions form button { width: 100%; }
    .page-actions > .btn,
    .page-actions > button { width: 100%; }
}

/* Tabelle moderne v8: sempre tabelle, con comportamento distinto desktop/mobile. */
.table-card {
    padding: 0;
    overflow: hidden;
}

.table-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid var(--line);
}

.table-card-heading h2 { margin-bottom: 5px; }
.table-card-heading p { margin: 0; }

.modern-table-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    scrollbar-width: thin;
    scrollbar-color: #98a2b3 #f2f4f7;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.table-card > .modern-table-wrapper {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.modern-table-wrapper::-webkit-scrollbar { height: 11px; }
.modern-table-wrapper::-webkit-scrollbar-track { background: #f2f4f7; }
.modern-table-wrapper::-webkit-scrollbar-thumb {
    background: #98a2b3;
    border: 3px solid #f2f4f7;
    border-radius: 999px;
}

.modern-table-wrapper:focus-visible {
    outline: 3px solid rgba(181, 31, 46, .18);
    outline-offset: 2px;
}

.modern-table-wrapper.is-scrollable:not(.is-at-start) {
    box-shadow: inset 14px 0 14px -16px rgba(16, 24, 40, .55), 0 1px 2px rgba(16, 24, 40, .04);
}

.modern-table-wrapper.is-scrollable:not(.is-at-end) {
    border-right-color: #cbd5e1;
}

.table-scroll-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 750;
}

.table-scroll-hint[hidden] { display: none !important; }
.table-scroll-hint-icon {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    color: #344054;
    background: #eef2f6;
    font-size: .9rem;
}

.table-card .table-scroll-hint {
    margin: 10px 22px;
}

.modern-table-wrapper table.modern-table,
table.modern-table {
    width: max-content;
    min-width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    background: #fff;
}

table.modern-table.table-compact { min-width: max(100%, 620px); }
table.modern-table.table-medium { min-width: max(100%, 900px); }
table.modern-table.table-wide { min-width: max(100%, 1240px); }
table.modern-table.table-ultra-wide { min-width: max(100%, 1780px); }

table.modern-table th,
table.modern-table td {
    max-width: 420px;
    padding: 12px 14px;
    border: 0 !important;
    border-bottom: 1px solid var(--line) !important;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

table.modern-table th {
    position: sticky;
    top: 0;
    z-index: 4;
    color: #344054;
    background: #f8fafc;
    box-shadow: inset 0 -1px 0 var(--line);
    font-size: .76rem;
    font-weight: 850;
    letter-spacing: .045em;
    line-height: 1.25;
    text-transform: uppercase;
    white-space: nowrap;
}

table.modern-table tbody tr:nth-child(even):not(.table-detail-row) td { background: #fcfdff; }
table.modern-table tbody tr:hover:not(.table-detail-row) td { background: #f8fafc; }
table.modern-table tbody tr:last-child td { border-bottom: 0 !important; }

table.modern-table td > p:last-child,
table.modern-table td > div:last-child { margin-bottom: 0; }

table.modern-table td img {
    display: block;
    max-width: 92px;
    max-height: 82px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table.modern-table .table-action-column,
table.modern-table .column-actions {
    min-width: 132px;
    width: 1%;
    background: #fff;
    white-space: nowrap;
}

table.modern-table th.table-action-column,
table.modern-table th.column-actions { background: #f8fafc; }

table.modern-table tbody tr:nth-child(even) .table-action-column,
table.modern-table tbody tr:nth-child(even) .column-actions { background: #fcfdff; }

table.modern-table tbody tr:hover .table-action-column,
table.modern-table tbody tr:hover .column-actions { background: #f8fafc; }

table.modern-table .table-action-column form,
table.modern-table .column-actions form {
    display: inline-block;
    margin: 2px;
}

table.modern-table .table-action-column .btn,
table.modern-table .table-action-column .button,
table.modern-table .table-action-column button,
table.modern-table .table-action-column input[type="submit"],
table.modern-table .column-actions .btn,
table.modern-table .column-actions .button,
table.modern-table .column-actions button,
table.modern-table .column-actions input[type="submit"] {
    min-height: 34px;
    margin: 2px;
    padding: 6px 9px;
    font-size: .78rem;
    white-space: nowrap;
}

.table-id {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .8rem;
    font-weight: 800;
}

.table-cell-subtitle {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 550;
    line-height: 1.35;
}

.table-contact-link {
    display: inline-block;
    max-width: 260px;
    overflow-wrap: anywhere;
}

.table-empty {
    padding: 28px !important;
    color: var(--muted);
    text-align: center !important;
}

.table-detail-row td {
    padding: 0 !important;
    background: #f8fafc !important;
}

.table-detail-row[hidden] { display: none; }

.table-record-details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding: 18px;
    border-top: 3px solid rgba(181, 31, 46, .14);
}

.table-record-details > section {
    min-width: 0;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.table-record-details h3 {
    margin-bottom: 12px;
    font-size: .95rem;
}

.directory-table .column-person { min-width: 210px; }
.directory-table .column-tax-code { min-width: 160px; }
.directory-table .column-birth { min-width: 170px; }
.directory-table .column-contact { min-width: 220px; }
.directory-table .column-residence { min-width: 260px; }
.directory-table .column-cri { min-width: 160px; }
.directory-table .column-actions { min-width: 250px; }

/* Annulla definitivamente la precedente trasformazione a schede. */
@media (max-width: 720px) {
    .data-table.is-card-table,
    .data-table.is-card-table tbody,
    .data-table.is-card-table tr,
    .data-table.is-card-table td {
        display: table-row-group;
        width: auto;
    }

    .data-table.is-card-table { display: table; }
    .data-table.is-card-table tr { display: table-row; }
    .data-table.is-card-table th,
    .data-table.is-card-table td { display: table-cell; }
    .data-table.is-card-table thead { position: static !important; width: auto !important; height: auto !important; margin: 0 !important; clip: auto !important; overflow: visible !important; }
    .data-table.is-card-table td::before { display: none !important; content: none !important; }
}

@media (max-width: 1100px) {
    table.modern-table th,
    table.modern-table td {
        padding: 10px 11px;
        font-size: .88rem;
    }

    .table-record-details { grid-template-columns: 1fr; }

    .directory-table .column-id,
    .directory-table .column-cri { display: none; }
}

@media (max-width: 720px) {
    .table-card-heading { padding: 16px; }
    .table-card .table-scroll-hint { margin: 9px 16px; }

    .modern-table-wrapper {
        border-radius: 10px;
        max-width: calc(100vw - 28px);
    }

    table.modern-table.table-compact { min-width: 620px; }
    table.modern-table.table-medium { min-width: 860px; }
    table.modern-table.table-wide { min-width: 1120px; }
    table.modern-table.table-ultra-wide { min-width: 1540px; }

    table.modern-table th,
    table.modern-table td {
        padding: 9px 10px;
        font-size: .82rem;
        line-height: 1.35;
    }

    table.modern-table th { font-size: .69rem; }

    table.modern-table .table-action-column,
    table.modern-table .column-actions {
        position: sticky;
        right: 0;
        z-index: 3;
        box-shadow: -8px 0 14px -12px rgba(16, 24, 40, .75);
    }

    table.modern-table th.table-action-column,
    table.modern-table th.column-actions { z-index: 6; }

    .directory-table {
        min-width: 690px !important;
    }

    .directory-table .column-person {
        position: sticky;
        left: 0;
        z-index: 3;
        min-width: 180px;
        max-width: 200px;
        background: #fff;
        box-shadow: 8px 0 14px -12px rgba(16, 24, 40, .75);
    }

    .directory-table th.column-person {
        z-index: 6;
        background: #f8fafc;
    }

    .directory-table tbody tr:nth-child(even) .column-person { background: #fcfdff; }
    .directory-table tbody tr:hover .column-person { background: #f8fafc; }

    .directory-table .column-id,
    .directory-table .column-tax-code,
    .directory-table .column-birth,
    .directory-table .column-residence,
    .directory-table .column-cri { display: none; }

    .directory-table .column-contact { min-width: 210px; }
    .directory-table .column-actions { min-width: 250px; }

    .table-record-details { padding: 12px; }
    .table-record-details > section { padding: 13px; }
    .record-data-grid { grid-template-columns: 1fr; }
}

/* ========================================================================== 
   Interfaccia v9 - moduli più visuali e colonne importanti sempre raggiungibili
   ========================================================================== */
:root {
    --cri-red-bright: #d52b3f;
    --surface-soft: #fbfcfe;
    --surface-accent: #fff7f8;
    --focus-ring: 0 0 0 4px rgba(181, 31, 46, .13);
    --control-shadow: 0 1px 2px rgba(16, 24, 40, .05), inset 0 1px 0 rgba(255,255,255,.8);
}

body {
    background:
        radial-gradient(circle at 100% 0, rgba(181,31,46,.055), transparent 28rem),
        radial-gradient(circle at 0 35%, rgba(37,99,235,.035), transparent 30rem),
        var(--background);
}

.topbar {
    border-bottom-color: #dde2ea;
    box-shadow: 0 3px 16px rgba(16, 24, 40, .055);
}

.brand img {
    padding: 3px;
    background: #fff;
    border: 1px solid #edf0f4;
    border-radius: 11px;
    box-shadow: 0 3px 10px rgba(16,24,40,.08);
}

.sidebar {
    background:
        radial-gradient(circle at 20% 0, rgba(213,43,63,.22), transparent 17rem),
        linear-gradient(180deg, #182132 0%, #101624 100%);
    border-right: 1px solid rgba(255,255,255,.07);
}

.primary-nav a {
    border: 1px solid transparent;
    transition: background .16s ease, border-color .16s ease, transform .12s ease;
}
.primary-nav a:hover {
    border-color: rgba(255,255,255,.08);
    transform: translateX(2px);
}
.primary-nav a.active {
    background: linear-gradient(90deg, rgba(213,43,63,.30), rgba(255,255,255,.08));
    border-color: rgba(255,255,255,.10);
    box-shadow: inset 3px 0 0 #ff7b8b, 0 5px 18px rgba(0,0,0,.12);
}
.primary-nav a i {
    display: inline-grid;
    place-items: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    color: #fff;
    background: rgba(255,255,255,.09);
}

/* Fallback locale: le icone restano visibili anche se la CDN Font Awesome è bloccata. */
i[class*="fa-"]::before { font-family: inherit; font-style: normal; font-weight: 900; }
.fa-house::before { content: "⌂"; }
.fa-truck-medical::before { content: "+"; }
.fa-display::before { content: "▤"; }
.fa-list-check::before, .fa-clipboard-check::before { content: "✓"; }
.fa-gas-pump::before { content: "◉"; }
.fa-route::before { content: "↝"; }
.fa-boxes-stacked::before { content: "▦"; }
.fa-user-plus::before { content: "+"; }
.fa-magnifying-glass::before { content: "⌕"; }
.fa-arrow-left::before { content: "←"; }
.fa-angle-right::before { content: "›"; }
.fa-book-open::before { content: "▤"; }
.fa-shield-halved::before { content: "◇"; }
.fa-arrow-right-from-bracket::before { content: "→"; }
.fa-van-shuttle::before { content: "▭"; }
.fa-newspaper::before { content: "▤"; }
.fa-circle::before { content: "•"; }

.main-content { padding-top: 30px; }

.page-heading {
    position: relative;
    align-items: center;
    padding: clamp(18px, 2.4vw, 28px);
    margin-bottom: 24px;
    overflow: hidden;
    background:
        linear-gradient(115deg, rgba(255,255,255,.98), rgba(255,247,248,.96)),
        #fff;
    border: 1px solid #eadfe2;
    border-radius: 18px;
    box-shadow: 0 12px 34px rgba(16,24,40,.07);
}
.page-heading::after {
    content: "";
    position: absolute;
    top: -70px;
    right: -50px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(181,31,46,.11), rgba(181,31,46,0) 70%);
    pointer-events: none;
}
.page-heading > * { position: relative; z-index: 1; }
.page-heading h1 {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 8px;
}
.page-heading-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    color: #fff;
    background: linear-gradient(145deg, var(--cri-red-bright), var(--cri-red-dark));
    border: 1px solid rgba(134,21,34,.4);
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(181,31,46,.22);
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: 0;
}

.card, .shadow-container, .no-shadow-container, fieldset {
    border-color: #dfe4eb;
}
.card {
    box-shadow: 0 8px 26px rgba(16,24,40,.065);
}
a.card {
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
a.card:hover {
    color: inherit;
    transform: translateY(-3px);
    border-color: #d6b8be;
    box-shadow: 0 15px 36px rgba(16,24,40,.10);
}
.card-muted {
    background: linear-gradient(145deg, #fff, #f8fafc);
}
.card-muted h3 i {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-right: 7px;
    color: var(--cri-red);
    background: var(--cri-red-soft);
    border-radius: 11px;
}

.stat-card {
    min-height: 122px;
    background: linear-gradient(145deg, #fff, #fbfcfe);
    transition: transform .16s ease, box-shadow .16s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 13px 32px rgba(16,24,40,.10); }
.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--cri-red-bright), var(--cri-red-dark));
}
.stat-card i {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    right: 14px;
    top: 14px;
    border-radius: 18px;
    background: var(--cri-red-soft);
    opacity: 1;
    font-size: 1.7rem;
}

button, .button, input[type="submit"], .btn {
    min-height: 44px;
    background: linear-gradient(145deg, var(--cri-red-bright), var(--cri-red-dark));
    border-color: var(--cri-red-dark);
    box-shadow: 0 5px 14px rgba(181,31,46,.16);
}
button:hover, .button:hover, input[type="submit"]:hover, .btn:hover {
    background: linear-gradient(145deg, #c42135, #76111d);
    box-shadow: 0 8px 18px rgba(181,31,46,.22);
}
.btn-secondary {
    color: #344054;
    background: linear-gradient(180deg, #fff, #f8fafc);
    border-color: #cbd2dc;
    box-shadow: 0 3px 9px rgba(16,24,40,.06);
}
.btn-secondary:hover {
    color: #101828;
    background: #f2f4f7;
    border-color: #aab3c0;
}

/* Moduli */
.form-modern { position: relative; }
.form-modern .fieldset-modern,
fieldset.fieldset-modern {
    position: relative;
    padding: clamp(18px, 2vw, 24px);
    background: linear-gradient(160deg, #fff, #fbfcfe);
    border: 1px solid #dde3eb;
    border-left: 4px solid rgba(181,31,46,.70);
    border-radius: 15px;
    box-shadow: 0 7px 22px rgba(16,24,40,.055);
}
fieldset.fieldset-modern legend {
    padding: 7px 12px;
    color: var(--cri-red-dark);
    background: #fff;
    border: 1px solid #ead9dc;
    border-radius: 999px;
    box-shadow: 0 3px 10px rgba(16,24,40,.05);
    font-size: .94rem;
    font-weight: 850;
}
.form-group-enhanced { gap: 8px; }
.form-group-enhanced label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    color: #273548;
}
.field-label-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    color: var(--cri-red-dark);
    background: var(--cri-red-soft);
    border: 1px solid #f4cfd5;
    border-radius: 8px;
    font-size: .76rem;
    font-weight: 900;
    line-height: 1;
}
.field-required label::after {
    content: "obbligatorio";
    margin-left: auto;
    color: #b42318;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .035em;
    text-transform: uppercase;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="search"], input[type="tel"], input[type="url"], input[type="file"], select, textarea {
    min-height: 48px;
    padding: 11px 13px;
    color: #17202a;
    background-color: var(--surface-soft);
    border: 1.5px solid #cbd3de;
    border-radius: 11px;
    box-shadow: var(--control-shadow);
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease, transform .12s ease;
}
textarea { min-height: 126px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #98a2b3; opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #aeb8c6; background-color: #fff; }
input:focus, select:focus, textarea:focus {
    border-color: var(--cri-red);
    background-color: #fff;
    box-shadow: var(--focus-ring), var(--control-shadow);
}
input:disabled, select:disabled, textarea:disabled {
    color: #667085;
    background: #eef1f5;
    cursor: not-allowed;
}
select:not([multiple]) {
    padding-right: 42px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
}
input[type="file"] { padding: 6px; }
input[type="file"]::file-selector-button {
    min-height: 34px;
    margin-right: 10px;
    padding: 7px 11px;
    color: var(--cri-red-dark);
    background: var(--cri-red-soft);
    border: 1px solid #efc7ce;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}
input[type="checkbox"], input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0 6px 0 0;
    accent-color: var(--cri-red);
}
.field-help {
    display: block;
    padding-left: 35px;
    color: #667085;
    line-height: 1.4;
}
.form-submit-bar {
    bottom: max(8px, env(safe-area-inset-bottom));
    padding: 13px;
    background: rgba(255,255,255,.96);
    border-color: #d8dee7;
    box-shadow: 0 14px 38px rgba(16,24,40,.14);
}

.alert {
    position: relative;
    padding-left: 46px;
    box-shadow: 0 5px 16px rgba(16,24,40,.045);
}
.alert::before {
    content: "i";
    position: absolute;
    left: 14px;
    top: 12px;
    display: grid;
    place-items: center;
    width: 23px;
    height: 23px;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-size: .75rem;
    font-weight: 900;
}
.alert-success::before { content: "✓"; }
.alert-warning::before { content: "!"; }
.alert-danger::before, .alert-error::before { content: "×"; }

/* Tabelle: intestazione, colonne principali a sinistra e azioni a destra. */
.modern-table-wrapper {
    background: linear-gradient(180deg, #fff, #fcfdff);
    border-color: #d9e0e8;
    box-shadow: 0 8px 24px rgba(16,24,40,.06);
}
.modern-table-wrapper.is-scrollable {
    background-image: linear-gradient(90deg, rgba(181,31,46,.025), transparent 12%, transparent 88%, rgba(181,31,46,.025));
}
table.modern-table th {
    height: 46px;
    color: #344054;
    background: linear-gradient(180deg, #fbfcfe, #f2f5f8);
    border-bottom-color: #ccd4df !important;
    box-shadow: inset 0 -1px 0 #ccd4df;
}
table.modern-table tbody tr { transition: background .12s ease; }
table.modern-table tbody tr:hover:not(.table-detail-row) td { background: #f6f9fc; }

table.modern-table .table-sticky-left {
    position: sticky;
    left: var(--sticky-left, 0px);
    z-index: 5;
    min-width: 155px;
    max-width: 270px;
    background: #fff;
    box-shadow: 9px 0 16px -15px rgba(16,24,40,.95);
}
table.modern-table th.table-sticky-left {
    top: 0;
    z-index: 9;
    background: linear-gradient(180deg, #fbfcfe, #eef2f6);
}
table.modern-table tbody tr:nth-child(even):not(.table-detail-row) .table-sticky-left { background: #fcfdff; }
table.modern-table tbody tr:hover:not(.table-detail-row) .table-sticky-left { background: #f6f9fc; }

table.modern-table .table-action-column,
table.modern-table .column-actions {
    position: sticky;
    right: 0;
    z-index: 5;
    min-width: 124px;
    background: #fff;
    box-shadow: -9px 0 16px -15px rgba(16,24,40,.95);
}
table.modern-table th.table-action-column,
table.modern-table th.column-actions {
    top: 0;
    z-index: 9;
    background: linear-gradient(180deg, #fbfcfe, #eef2f6);
}
table.modern-table tbody tr:nth-child(even):not(.table-detail-row) .table-action-column,
table.modern-table tbody tr:nth-child(even):not(.table-detail-row) .column-actions { background: #fcfdff; }
table.modern-table tbody tr:hover:not(.table-detail-row) .table-action-column,
table.modern-table tbody tr:hover:not(.table-detail-row) .column-actions { background: #f6f9fc; }

.table-scroll-hint {
    width: fit-content;
    padding: 7px 10px;
    color: #475467;
    background: #f5f7fa;
    border: 1px solid #e0e5ec;
    border-radius: 999px;
}
.table-scroll-hint-icon {
    color: #fff;
    background: var(--cri-red);
}

.directory-table .column-person,
.directory-table .column-contact { min-width: 205px; }

@media (max-width: 980px) {
    .main-content { padding-top: 20px; }
    .page-heading { align-items: flex-start; border-radius: 15px; }
    .page-heading-icon { width: 42px; height: 42px; border-radius: 12px; }
}

@media (max-width: 720px) {
    .page-heading {
        padding: 16px;
        gap: 14px;
    }
    .page-heading h1 { font-size: 1.65rem; }
    .page-actions { width: 100%; }
    .page-actions > .btn,
    .page-actions > button,
    .page-actions > input[type="submit"] { flex: 1 1 150px; }

    .form-modern .fieldset-modern,
    fieldset.fieldset-modern { padding: 16px 13px; border-left-width: 3px; }
    .field-required label::after { display: none; }
    .field-help { padding-left: 0; }

    table.modern-table th,
    table.modern-table td { padding: 9px 9px; }
    table.modern-table .table-sticky-left {
        min-width: 145px;
        max-width: 175px;
    }
    /* Su smartphone si fissa una sola colonna a sinistra per non coprire i dati centrali. */
    table.modern-table .table-sticky-left[data-sticky-priority="2"] {
        position: static;
        min-width: 190px;
        max-width: 260px;
        box-shadow: none;
    }
    table.modern-table .table-action-column,
    table.modern-table .column-actions {
        min-width: 108px;
        max-width: 126px;
    }
    table.modern-table .table-action-column .btn,
    table.modern-table .table-action-column .button,
    table.modern-table .table-action-column button,
    table.modern-table .table-action-column input[type="submit"],
    table.modern-table .column-actions .btn,
    table.modern-table .column-actions .button,
    table.modern-table .column-actions button,
    table.modern-table .column-actions input[type="submit"] {
        min-width: 91px;
        white-space: normal;
    }
    .table-scroll-hint { border-radius: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}


/* Role editor */
.role-editor-card {
    max-width: 1080px;
}
.role-editor-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}
.role-editor-heading h2 {
    margin: 4px 0 0;
}
.role-editor-heading .eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 800;
    font-size: .78rem;
    color: var(--cri-red);
}
.role-editor-user {
    margin: 8px 0 0;
    color: var(--muted);
    font-weight: 600;
    word-break: break-word;
}
.role-editor-meta {
    min-width: 280px;
}
.role-editor-meta__label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
}
.role-editor-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.role-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(196, 30, 58, .08);
    border: 1px solid rgba(196, 30, 58, .16);
    color: var(--cri-red-dark);
    font-size: .88rem;
    font-weight: 700;
}
.role-badge.is-muted {
    background: #f5f6f8;
    color: #475467;
    border-color: #e2e8f0;
}
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}
.role-option {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-height: 92px;
    padding: 14px 14px 14px 48px;
    border-radius: 16px;
    border: 1px solid #d7dde5;
    background: #fff;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background .18s ease;
}
.role-option:hover {
    border-color: rgba(196, 30, 58, .34);
    box-shadow: 0 8px 22px rgba(16,24,40,.08);
    transform: translateY(-1px);
}
.role-option input[type="checkbox"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
.role-option__control {
    position: absolute;
    top: 16px;
    left: 14px;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    border: 1.5px solid #c5cfda;
    background: #fff;
    box-shadow: inset 0 1px 1px rgba(16,24,40,.04);
}
.role-option__content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.role-option__name {
    font-weight: 800;
    color: #182230;
    line-height: 1.3;
}
.role-option__slug {
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.35;
    word-break: break-word;
}
.role-option.is-selected {
    border-color: rgba(196, 30, 58, .42);
    background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(196,30,58,.05) 100%);
    box-shadow: 0 10px 26px rgba(196,30,58,.10);
}
.role-option.is-selected .role-option__control {
    background: var(--cri-red);
    border-color: var(--cri-red);
}
.role-option.is-selected .role-option__control::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.role-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}
@media (max-width: 860px) {
    .role-editor-heading {
        flex-direction: column;
    }
    .role-editor-meta {
        min-width: 0;
        width: 100%;
    }
}
@media (max-width: 640px) {
    .role-grid {
        grid-template-columns: 1fr;
    }
    .role-option {
        min-height: 82px;
    }
    .role-editor-actions > * {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}

/* Person picker v15 */
.person-picker-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    border: 0 !important;
}

.person-picker {
    position: relative;
}

.person-picker-trigger {
    width: 100%;
    min-height: 48px;
    padding: 10px 42px 10px 12px;
    color: #17202a;
    background: var(--surface-soft);
    border: 1.5px solid #cbd3de;
    border-radius: 11px;
    box-shadow: var(--control-shadow);
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.person-picker-trigger:hover {
    border-color: #aeb8c6;
    background: #fff;
}

.person-picker.is-open .person-picker-trigger {
    border-color: var(--cri-red);
    background: #fff;
    box-shadow: var(--focus-ring), var(--control-shadow);
}

.person-picker-value {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.person-picker-placeholder {
    color: #98a2b3;
}

.person-picker-tag,
.person-picker-single {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    color: #7a1320;
    background: #fff3f5;
    border: 1px solid #f2c8cf;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 700;
}

.person-picker-caret {
    flex: 0 0 auto;
    color: #667085;
    font-size: .95rem;
}

.person-picker-dropdown {
    position: absolute;
    z-index: 35;
    inset: calc(100% + 8px) 0 auto;
    display: none;
    background: #fff;
    border: 1px solid #d8dee7;
    border-radius: 14px;
    box-shadow: 0 18px 36px rgba(16,24,40,.16);
    overflow: hidden;
}

.person-picker.is-open .person-picker-dropdown {
    display: block;
}

.person-picker-search {
    padding: 10px;
    border-bottom: 1px solid #edf1f5;
}

.person-picker-search-input {
    min-height: 42px !important;
}

.person-picker-list {
    max-height: 280px;
    overflow: auto;
    padding: 8px;
    display: grid;
    gap: 6px;
}

.person-picker-option {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #fff;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    box-shadow: none;
    color: #17202a;
}

.person-picker-option:hover {
    background: #f8fafc;
    border-color: #d0d7e2;
}

.person-picker-option.is-selected {
    border-color: #efc6cd;
    background: #fff6f7;
}

.person-picker-option.is-disabled,
.person-picker-option:disabled {
    opacity: .5;
    cursor: not-allowed;
    background: #f5f6f8;
}

.person-picker-option-main {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    width: 100%;
}

.person-picker-option-check {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    color: #fff;
    background: #d0d5dd;
    border-radius: 7px;
    font-size: .78rem;
    font-weight: 900;
}

.person-picker-option.is-selected .person-picker-option-check {
    background: var(--cri-red);
}

.person-picker-option-text {
    text-align: left;
    font-size: .92rem;
    line-height: 1.3;
}

.person-picker-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-top: 1px solid #edf1f5;
    background: #fafbfc;
    font-size: .85rem;
    color: #667085;
}

.person-picker-clear {
    min-height: 34px;
    padding: 6px 10px;
    color: #7a1320;
    background: #fff;
    border: 1px solid #efc6cd;
    border-radius: 9px;
    font-weight: 700;
    box-shadow: none;
}

.person-picker-empty {
    padding: 14px 12px;
    color: #667085;
    text-align: center;
}

@media (max-width: 760px) {
    .person-picker-list {
        max-height: 240px;
    }

    .person-picker-footer {
        flex-direction: column;
        align-items: stretch;
    }
}
/* Dashboard v13 */
.dashboard-shell {
    display: grid;
    gap: 22px;
}

.dashboard-hero {
    position: relative;
    overflow: hidden;
    padding: 28px 28px 24px;
    background: linear-gradient(145deg, #ffffff 0%, #fff7f8 100%);
    border: 1px solid #e8dde1;
    border-radius: 24px;
    box-shadow: 0 14px 36px rgba(16,24,40,.08);
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    top: -80px;
    right: -40px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(181,31,46,.12), rgba(181,31,46,0) 70%);
}

.dashboard-hero-copy {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 14px;
}

.dashboard-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    padding: 7px 12px;
    color: #233248;
    background: rgba(255,255,255,.88);
    border: 1px solid #e5d6d9;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 800;
}

.dashboard-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.03;
}

.dashboard-subtitle {
    margin: 0;
    color: #233248;
    font-size: 1.08rem;
}

.dashboard-primary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.dashboard-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    color: #b42318;
    background: #fff;
    border: 1px solid #ecd3d7;
    border-radius: 999px;
    font-size: .92rem;
    line-height: 1.1;
}

.dashboard-chip strong {
    color: #9f1239;
    font-weight: 900;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card--dashboard {
    min-height: 138px;
}

.stat-card--dashboard .stat-note {
    display: block;
    margin-top: 10px;
    color: #667085;
    font-size: .88rem;
    line-height: 1.35;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: 1.25fr .85fr;
    gap: 22px;
}

.dashboard-panel {
    padding: 22px;
}

.dashboard-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.dashboard-section-head h2 {
    margin: 0;
}

.dashboard-section-kicker {
    margin: 0 0 5px;
    color: #667085;
    font-size: .78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.dashboard-section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    color: #344054;
    background: #f4f6f8;
    border: 1px solid #dde3eb;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 800;
    white-space: nowrap;
}

.dashboard-section-badge.is-success {
    color: #11623d;
    background: #ecfdf3;
    border-color: #abefc6;
}

.dashboard-section-badge.is-warning {
    color: #9a3412;
    background: #fffbeb;
    border-color: #fcd34d;
}

.dashboard-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.dashboard-quick-card {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 16px;
    color: inherit;
    background: linear-gradient(145deg, #fff, #f8fafc);
    border: 1px solid #dee4ec;
    border-radius: 18px;
    text-decoration: none;
    box-shadow: 0 7px 22px rgba(16,24,40,.05);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.dashboard-quick-card:hover {
    color: inherit;
    transform: translateY(-2px);
    border-color: #dcb7be;
    box-shadow: 0 14px 30px rgba(16,24,40,.08);
}

.dashboard-quick-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    color: var(--cri-red-dark);
    background: var(--cri-red-soft);
    border-radius: 16px;
    font-size: 1.15rem;
}

.dashboard-quick-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.dashboard-quick-copy strong {
    color: #101828;
    font-size: 1rem;
}

.dashboard-quick-copy small {
    color: #667085;
    font-size: .86rem;
    line-height: 1.35;
}

.dashboard-quick-arrow {
    color: #98a2b3;
    font-size: 1rem;
}

.dashboard-empty-state,
.dashboard-task-item {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    background: linear-gradient(145deg, #fff, #fafcff);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
}

.dashboard-empty-state i,
.dashboard-task-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: var(--cri-red-dark);
    background: var(--cri-red-soft);
    border-radius: 14px;
    font-size: 1rem;
}

.dashboard-empty-state strong,
.dashboard-task-item strong {
    display: block;
    margin-bottom: 4px;
}

.dashboard-empty-state p,
.dashboard-task-item p {
    margin: 0;
    color: #667085;
    line-height: 1.4;
}

.dashboard-task-list {
    display: grid;
    gap: 12px;
}

.dashboard-news-panel {
    padding-bottom: 10px;
}

.dashboard-news-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.dashboard-news-item {
    padding: 16px;
    background: linear-gradient(145deg, #fff, #fafcff);
    border: 1px solid #e0e6ee;
    border-radius: 16px;
}

.dashboard-news-item h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.dashboard-news-item p {
    margin: 0;
    color: #475467;
    line-height: 1.45;
}

.dashboard-news-meta {
    margin-bottom: 10px;
    color: #667085;
    font-size: .78rem;
    font-weight: 700;
}

.dashboard-alert {
    margin-bottom: 0;
}

@media (max-width: 1180px) {
    .dashboard-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .dashboard-hero {
        padding: 20px 18px;
        border-radius: 18px;
    }

    .dashboard-subtitle {
        font-size: .98rem;
    }

    .dashboard-stats-grid,
    .dashboard-quick-grid,
    .dashboard-news-list {
        grid-template-columns: 1fr;
    }

    .dashboard-section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-quick-card {
        grid-template-columns: 46px minmax(0, 1fr) auto;
        padding: 14px;
    }

    .dashboard-panel {
        padding: 18px 16px;
    }
}

/* Turni volontari v23 */
.shift-layout,
.shift-admin-grid {
    align-items: start;
}

.shift-admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
    gap: 22px;
    margin-bottom: 22px;
}

.shift-list,
.shift-availability-list {
    display: grid;
    gap: 10px;
}

.shift-item {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 13px;
    background: linear-gradient(145deg, #fff, #fafcff);
    border: 1px solid #e0e6ee;
    border-radius: 14px;
}

.shift-date-box {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    align-content: center;
    color: #8f1724;
    background: #fff2f4;
    border: 1px solid #efc9cf;
    border-radius: 14px;
    line-height: 1;
}

.shift-date-box strong { font-size: 1.35rem; }
.shift-date-box small { margin-top: 4px; font-size: .68rem; font-weight: 850; }

.shift-item-copy {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.shift-item-copy span,
.shift-item-copy small {
    color: #667085;
}

.shift-availability-card {
    position: sticky;
    top: 94px;
}

.shift-availability-list {
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
}

.shift-availability-list article {
    display: grid;
    gap: 4px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.shift-availability-list span {
    color: #667085;
    font-size: .86rem;
}

.shift-availability-preview {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    margin-top: 14px;
    padding: 13px;
    color: #344054;
    background: #f8fafc;
    border: 1px solid #dfe5ec;
    border-radius: 12px;
}

.shift-availability-preview i {
    margin-top: 2px;
}

.shift-availability-preview.is-success {
    color: #11623d;
    background: #ecfdf3;
    border-color: #abefc6;
}

.shift-availability-preview.is-warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

.shift-inline-filter,
.shift-filter {
    align-items: end;
}

.shift-inline-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.shift-inline-filter input {
    min-height: 38px;
    width: auto;
}

.shift-status {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 850;
}

.shift-status--bozza { color: #475467; background: #f2f4f7; }
.shift-status--assegnato { color: #1849a9; background: #eff8ff; }
.shift-status--confermato { color: #11623d; background: #ecfdf3; }
.shift-status--rifiutato,
.shift-status--annullato { color: #912018; background: #fef3f2; }
.shift-status--completato { color: #6941c6; background: #f4f3ff; }

.inline-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin: 0;
}

@media (max-width: 980px) {
    .shift-admin-grid {
        grid-template-columns: 1fr;
    }

    .shift-availability-card {
        position: static;
    }
}

@media (max-width: 640px) {
    .shift-item {
        grid-template-columns: 50px minmax(0, 1fr);
    }

    .shift-item > form {
        grid-column: 1 / -1;
    }

    .shift-date-box {
        width: 50px;
        height: 50px;
    }

    .shift-inline-filter {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .shift-inline-filter input,
    .shift-inline-filter button {
        width: 100%;
    }
}

/* Comunicazioni v23 */
.communication-layout {
    display: grid;
    grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr);
    gap: 22px;
    align-items: start;
}
.communication-list { display: grid; gap: 14px; }
.communication-item {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e1e6ed;
    border-radius: 16px;
}
.communication-item.is-archived { opacity: .72; background: #f8fafc; }
.communication-item > img {
    width: 120px;
    height: 96px;
    object-fit: cover;
    border-radius: 12px;
    background: #f2f4f7;
}
.communication-item-copy { min-width: 0; }
.communication-item-copy h3 { margin: 4px 0 8px; }
.communication-item-copy p { margin: 0 0 12px; color: #475467; line-height: 1.45; }
.communication-item-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; color: #667085; font-size: .8rem; }
.communication-current-image { display: grid; gap: 10px; margin: 12px 0; }
.communication-current-image img { width: min(100%, 320px); max-height: 220px; object-fit: contain; border: 1px solid #e1e6ed; border-radius: 14px; }
@media (max-width: 980px) { .communication-layout { grid-template-columns: 1fr; } }
@media (max-width: 620px) {
    .communication-item { grid-template-columns: 1fr; }
    .communication-item > img { width: 100%; height: 180px; }
}

/* Menu organizzato v24 */
.primary-nav {
    gap: 0;
    padding-bottom: 18px;
}

.nav-group {
    position: relative;
    padding: 0 8px 12px;
}

.nav-group + .nav-group {
    padding-top: 4px;
    border-top: 1px solid rgba(255,255,255,.065);
}

.nav-group-links {
    display: grid;
    gap: 5px;
}

.nav-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 7px 8px;
    color: #a5afc1;
    font-size: .68rem;
    font-weight: 900;
    letter-spacing: .105em;
    line-height: 1.2;
    text-transform: uppercase;
}

.nav-section::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, rgba(255,255,255,.16), transparent);
}

.primary-nav a {
    position: relative;
    min-height: 46px;
    padding: 8px 11px;
}

.primary-nav a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.primary-nav a i {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255,255,255,.055);
    background: rgba(255,255,255,.085);
    font-size: .88rem;
}

.primary-nav a:hover i,
.primary-nav a.active i {
    color: #fff;
    background: rgba(213,43,63,.42);
    border-color: rgba(255,123,139,.28);
}

.nav-group-account {
    margin-top: 5px;
    padding-bottom: 5px;
}

.primary-nav .nav-danger i {
    color: #ffc3ca;
    background: rgba(220,38,38,.18);
}

/* Fallback locali aggiuntivi per tutte le voci del menu. */
.fa-user::before { content: "●"; }
.fa-calendar-check::before { content: "✓"; }
.fa-calendar-day::before { content: "▣"; }
.fa-calendar-plus::before { content: "+"; }
.fa-bullhorn::before { content: "◖"; }
.fa-folder-tree::before { content: "⌘"; }
.fa-user-shield::before { content: "◆"; }
.fa-building::before { content: "▥"; }
.fa-file-import::before { content: "⇣"; }
.fa-address-book::before { content: "▤"; }
.fa-users::before { content: "●●"; font-size: .62rem; }
.fa-link::before { content: "↔"; }
.fa-id-card::before,
.fa-id-card-clip::before { content: "▭"; }
.fa-diagram-project::before { content: "⌘"; }
.fa-truck-arrow-right::before { content: "⇢"; }
.fa-calendar-days::before { content: "▦"; }
.fa-tags::before { content: "◇"; }
.fa-tower-broadcast::before { content: "⌁"; }
.fa-kit-medical::before { content: "+"; }
.fa-chart-column::before { content: "▥"; }
.fa-clipboard-list::before { content: "☷"; }
.fa-receipt::before { content: "▤"; }
.fa-map-location-dot::before { content: "⌖"; }
.fa-warehouse::before { content: "▦"; }
.fa-box::before { content: "□"; }
.fa-building-circle-check::before { content: "▥"; }
.fa-arrow-right-arrow-left::before { content: "⇄"; }
.fa-clock-rotate-left::before { content: "↶"; }
.fa-file-lines::before { content: "≡"; }

@media (max-width: 980px) {
    .nav-group {
        padding-inline: 7px;
    }

    .nav-section {
        margin-top: 11px;
    }

    .primary-nav a {
        min-height: 48px;
        font-size: .95rem;
    }
}

/* Menu SVG icons v25: indipendenti da librerie esterne. */
.primary-nav a .menu-svg-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    padding: 8px;
    color: #d7e0ed;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 11px;
    transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.primary-nav a:hover .menu-svg-icon,
.primary-nav a.active .menu-svg-icon {
    color: #fff;
    background: rgba(213,43,63,.42);
    border-color: rgba(255,123,139,.28);
}

.primary-nav .nav-danger .menu-svg-icon {
    color: #ffc3ca;
    background: rgba(220,38,38,.18);
}

@media (max-width: 980px) {
    .primary-nav a .menu-svg-icon {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }
}

/* Pannello impostazioni e manuali - v30 */
.settings-heading, .manual-heading { margin-bottom: 18px; }
.settings-general { margin-bottom: 24px; }
.settings-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.settings-logo-preview { display:flex; align-items:center; gap:12px; margin:14px 0; padding:12px; border:1px solid #e4e8ee; border-radius:14px; background:#fafbfc; }
.settings-logo-preview img { width:72px; height:72px; object-fit:contain; border-radius:12px; background:#fff; }
.settings-logo-preview span { color:#586575; font-size:.9rem; }
.settings-modules { display:flex; flex-wrap:wrap; gap:10px 22px; margin:18px 0; padding:15px; border:1px solid #dfe5eb; border-radius:14px; }
.settings-modules legend { padding:0 7px; font-weight:700; }
.settings-section { margin:26px 0; }
.settings-section > h2 { margin:0 0 12px; font-size:1.15rem; }
.settings-grid, .manual-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px; }
.settings-card, .manual-card { display:grid; grid-template-columns:46px minmax(0,1fr) 22px; align-items:center; gap:12px; min-height:86px; padding:15px; color:#263342; text-decoration:none; background:#fff; border:1px solid #e1e6ec; border-radius:16px; box-shadow:0 4px 14px rgba(25,40,55,.05); transition:transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.settings-card:hover, .manual-card:hover { transform:translateY(-1px); border-color:var(--brand-primary,#b51f2e); box-shadow:0 7px 20px rgba(25,40,55,.09); }
.settings-card-icon, .manual-card-icon { display:grid; place-items:center; width:44px; height:44px; color:var(--brand-primary,#b51f2e); background:color-mix(in srgb, var(--brand-primary,#b51f2e) 10%, white); border-radius:13px; }
.settings-card-icon .menu-svg-icon, .manual-card-icon .menu-svg-icon { width:24px; height:24px; }
.settings-card strong, .manual-card strong { display:block; margin-bottom:4px; }
.settings-card small, .manual-card small { display:block; color:#657283; line-height:1.35; }
.settings-card-arrow, .manual-card-arrow { font-size:1.7rem; color:#9aa5b2; }
.manual-role-note { margin-top:16px; }
@media (max-width:760px) {
  .settings-form-grid, .settings-grid, .manual-grid { grid-template-columns:1fr; }
  .settings-card, .manual-card { min-height:78px; padding:13px; }
}
