:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-muted: #eef2f7;
    --text: #172033;
    --text-soft: #667085;
    --text-faint: #98a2b3;
    --border: #e4e9f0;
    --border-strong: #d3dbe7;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --navy: #0f172a;
    --navy-soft: #1e293b;
    --success: #15803d;
    --success-soft: #ecfdf3;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --danger: #b42318;
    --danger-soft: #fff1f2;
    --pink: #db2777;
    --pink-soft: #fdf2f8;
    --blue-soft: #eff6ff;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-md: 0 10px 30px rgba(16, 24, 40, .07);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .055), transparent 28rem),
        var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

.container {
    width: min(100% - 32px, 1320px);
    margin: 28px auto 48px;
}

.header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    padding: 22px 24px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--navy) 0%, #18243a 100%);
    box-shadow: 0 18px 45px rgba(15, 23, 42, .13);
}

.header-bar h1 {
    margin: 0;
    color: #fff;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.15;
    letter-spacing: -.035em;
    font-weight: 760;
}

.header-bar .muted {
    color: #b8c2d3;
}

.user-bar,
.top-actions,
.table-actions,
.actions,
.message-template-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}

.box {
    margin-bottom: 20px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.form-box {
    max-width: 680px;
}

h2 {
    color: var(--text);
    letter-spacing: -.02em;
}

label {
    display: block;
    margin: 16px 0 6px;
    color: #344054;
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    outline: none;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(16,24,40,.02);
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #b9c4d3;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #7aa7f8;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .10);
}

button,
.btn,
.btn-secondary,
.btn-danger {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    text-decoration: none;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease;
}

button,
.btn {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(37, 99, 235, .16);
}

button:hover,
.btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 7px 16px rgba(37, 99, 235, .22);
    transform: translateY(-1px);
}

.btn-secondary {
    border-color: #d7dee8;
    background: #fff;
    color: #344054;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.btn-secondary:hover {
    border-color: #bdc7d5;
    background: #f8fafc;
    color: #101828;
    transform: translateY(-1px);
}

.header-bar .btn-secondary,
.planner-hero .btn-secondary {
    border-color: rgba(255,255,255,.16);
    background: rgba(255,255,255,.08);
    color: #f8fafc;
    box-shadow: none;
}

.header-bar .btn-secondary:hover,
.planner-hero .btn-secondary:hover {
    border-color: rgba(255,255,255,.25);
    background: rgba(255,255,255,.14);
    color: #fff;
}

.btn-danger {
    border-color: #fecaca;
    background: #fff5f5;
    color: #b42318;
    box-shadow: none;
}

.btn-danger:hover {
    border-color: #fda4af;
    background: #ffe4e6;
    color: #9f1239;
}

.actions {
    margin-top: 22px;
}

.success-box,
.error-box,
.planner-info-box {
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 11px;
    font-size: 13px;
    line-height: 1.5;
}

.success-box {
    border: 1px solid #abefc6;
    background: var(--success-soft);
    color: #166534;
}

.error-box {
    border: 1px solid #fecdd3;
    background: var(--danger-soft);
    color: #9f1239;
}

.planner-info-box {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
}

.hint,
.muted {
    color: var(--text-soft);
    font-size: 13px;
}

.success-text {
    color: #166534;
    font-weight: 700;
}

.error-text {
    color: #b42318;
    font-weight: 700;
}

/* Tabelle */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    scrollbar-color: #c5ceda transparent;
    scrollbar-width: thin;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

thead {
    background: #f8fafc;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

th {
    color: #475467;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .055em;
}

tbody tr:last-child td {
    border-bottom: 0;
}

tbody tr:not(.planner-row):hover > td {
    background-color: #f9fbfd;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.row-inviato > td {
    background-color: #f0fdf4;
}

.row-da-inviare > td {
    background-color: #fffaf0;
}

.row-urgente > td {
    background-color: #fff1f2;
}

.row-inviato:hover > td { background-color: #e6f9ec; }
.row-da-inviare:hover > td { background-color: #fff4d8; }
.row-urgente:hover > td { background-color: #ffe4e6; }

.preview {
    max-width: 300px;
    color: #475467;
    font-size: 12px;
    line-height: 1.45;
}

.azioni-col {
    width: 180px;
    min-width: 180px;
}

.azioni-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.icon-btn {
    width: 34px;
    height: 34px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    text-decoration: none;
    font-size: 15px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.icon-btn:hover {
    border-color: #b8c3d2;
    box-shadow: 0 4px 10px rgba(16,24,40,.08);
    transform: translateY(-1px);
}

.icon-send { background: #eff6ff; }
.icon-ok { background: #ecfdf3; }
.icon-back { background: #fffbeb; }
.icon-edit { background: #f5f3ff; }
.icon-delete { background: #fff1f2; }

/* Autocomplete */
.autocomplete-wrapper,
.planner-contact-field {
    position: relative;
}

.autocomplete-list {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 1000;
    display: none;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fff;
    box-shadow: var(--shadow-md);
}

.autocomplete-item {
    padding: 10px 12px;
    color: #344054;
    cursor: pointer;
    font-size: 13px;
}

.autocomplete-item + .autocomplete-item {
    border-top: 1px solid #f0f2f5;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--primary-soft);
    color: #1d4ed8;
}

/* Calendario */
.calendar-filter,
.month-filter {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.calendar-filter label,
.month-filter label {
    margin-top: 0;
}

.calendar-filter select,
.calendar-filter input {
    width: auto;
    min-width: 145px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.calendar-header div {
    padding: 10px;
    border-radius: 9px;
    background: var(--navy);
    color: #fff;
    text-align: center;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.calendar-day {
    min-height: 142px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #fbfcfe;
}

.calendar-day.empty {
    border: 0;
    background: transparent;
}

.calendar-day.today {
    border-color: #93b4f7;
    box-shadow: inset 0 0 0 1px #93b4f7;
}

.day-number {
    margin-bottom: 7px;
    color: #344054;
    font-size: 13px;
    font-weight: 800;
}

.calendar-event {
    margin-bottom: 6px;
    padding: 7px 8px;
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.4;
}

.event-sent {
    border: 1px solid #bbf7d0;
    background: #ecfdf3;
    color: #166534;
}

.event-pending {
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.calendar-person {
    margin-top: 3px;
    font-size: 11px;
}

/* Contatti */
.contacts-table tbody tr.contact-row-male > td,
.contacts-table tbody tr.riga-maschio > td {
    background-color: #eff6ff !important;
}

.contacts-table tbody tr.contact-row-male:hover > td,
.contacts-table tbody tr.riga-maschio:hover > td {
    background-color: #dbeafe !important;
}

.contacts-table tbody tr.contact-row-female > td,
.contacts-table tbody tr.riga-femmina > td {
    background-color: #fdf2f8 !important;
}

.contacts-table tbody tr.contact-row-female:hover > td,
.contacts-table tbody tr.riga-femmina:hover > td {
    background-color: #fce7f3 !important;
}

.legenda-contatti {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    color: #475467;
    font-size: 12px;
    font-weight: 650;
}

.legenda-elemento {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.legenda-colore {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(15,23,42,.1);
    border-radius: 4px;
}

.legenda-maschio { background: #dbeafe; }
.legenda-femmina { background: #fce7f3; }

/* Gestione mensile */
.top-actions {
    margin-bottom: 18px;
}

.month-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.month-nav-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.month-nav-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 18px;
}

.month-title {
    min-width: 200px;
    text-align: center;
}

.month-title span,
.month-title strong {
    display: block;
}

.month-title span {
    margin-bottom: 2px;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.month-title strong {
    color: #101828;
    font-size: 21px;
    letter-spacing: -.02em;
}

.month-filter select { min-width: 155px; }
.month-filter input { width: 108px; }
.month-filter button,
.month-filter .btn-secondary { min-height: 42px; }

.empty-month {
    padding: 34px 16px !important;
    color: var(--text-soft);
    text-align: center;
}

/* Messaggio base */
.message-template-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, .9fr);
    gap: 22px;
    align-items: start;
}

.message-template-editor h2,
.message-variables-card h2 {
    margin-bottom: 6px;
    font-size: 19px;
}

.message-template-editor textarea {
    min-height: 300px;
    line-height: 1.6;
}

.message-variables-card {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: #fbfcfe;
}

.variable-list {
    display: grid;
    gap: 8px;
    margin-top: 15px;
}

.variable-list > div {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    gap: 10px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
}

.variable-list code {
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
}

.variable-list span {
    color: var(--text-soft);
    font-size: 12px;
}

/* Pianificazione mensile */
.planner-container {
    width: min(100% - 32px, 1580px);
}

.planner-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 26px;
    margin-bottom: 20px;
    padding: 27px 28px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 20px;
    background:
        radial-gradient(circle at 10% 0%, rgba(59,130,246,.26), transparent 34%),
        linear-gradient(135deg, #0f172a 0%, #18243a 72%, #1e293b 100%);
    color: #fff;
    box-shadow: 0 20px 50px rgba(15,23,42,.16);
}

.planner-hero-copy {
    max-width: 670px;
}

.page-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 8px;
    color: #9fc0ff;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .095em;
}

.page-eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96,165,250,.13);
}

.planner-hero h1 {
    margin: 0;
    font-size: clamp(28px, 3vw, 38px);
    line-height: 1.12;
    letter-spacing: -.04em;
}

.planner-subtitle {
    max-width: 620px;
    margin-top: 8px;
    color: #bdc8da;
    font-size: 14px;
}

.planner-hero-actions {
    max-width: 620px;
    justify-content: flex-end;
}

.planner-toolbar {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 22px;
    flex-wrap: wrap;
    padding: 18px 20px;
}

.planner-month-filter {
    flex: 1;
    justify-content: flex-end;
}

.planner-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.planner-stat {
    position: relative;
    min-height: 100px;
    overflow: hidden;
    padding: 17px 18px 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.planner-stat::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: #64748b;
}

.planner-stat strong,
.planner-stat span {
    display: block;
}

.planner-stat strong {
    color: #101828;
    font-size: 29px;
    line-height: 1.1;
    letter-spacing: -.03em;
}

.planner-stat span {
    margin-top: 7px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 650;
}

.planner-stat-complete::after { background: #16a34a; }
.planner-stat-partial::after { background: #f59e0b; }
.planner-stat-empty::after { background: #e11d48; }

.planner-progress-card {
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.planner-progress-copy {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.planner-progress-copy strong {
    color: #344054;
    font-size: 12px;
}

.planner-progress-copy span {
    color: var(--text-soft);
    font-size: 11px;
}

.planner-progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #edf1f5;
}

.planner-progress-track > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #16a34a);
    transition: width .25s ease;
}

.planner-progress-value {
    min-width: 44px;
    color: #101828;
    text-align: right;
    font-size: 13px;
    font-weight: 800;
}

.planner-actionbar {
    position: sticky;
    top: 8px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-color: #d9e0ea;
    border-radius: 13px;
    box-shadow: 0 9px 26px rgba(16,24,40,.08);
}

.planner-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: #344054;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.planner-checkbox input {
    width: 17px;
    min-height: 17px;
    height: 17px;
    accent-color: var(--primary);
}

.planner-actionbar-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#saveAllButton {
    min-width: 132px;
}

.planner-table-box {
    padding: 0;
    overflow: hidden;
}

.planner-table {
    min-width: 1260px;
}

.planner-table thead {
    position: sticky;
    top: 0;
    z-index: 8;
}

.planner-table th {
    padding: 12px 11px;
    background: #f6f8fb;
    color: #475467;
}

.planner-table td {
    padding: 10px 11px;
    background: #fff;
    transition: background-color .15s ease;
}

.planner-row > td:first-child {
    position: relative;
    padding-left: 15px;
}

.planner-row > td:first-child::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: #94a3b8;
}

.planner-row-complete > td { background: #fbfffc; }
.planner-row-partial > td { background: #fffdf8; }
.planner-row-empty > td { background: #fffafb; }
.planner-row-duplicate > td { background: #fff1f2; }
.planner-row-complete > td:first-child::before { background: #16a34a; }
.planner-row-partial > td:first-child::before { background: #f59e0b; }
.planner-row-empty > td:first-child::before,
.planner-row-duplicate > td:first-child::before { background: #e11d48; }
.planner-row:hover > td { background: #f7faff; }

.planner-date-cell,
.planner-shift-cell {
    min-width: 150px;
}

.planner-date-cell strong,
.planner-date-cell span,
.planner-date-cell small,
.planner-shift-cell strong,
.planner-shift-cell span,
.planner-shift-cell small,
.planner-status-cell small {
    display: block;
}

.planner-date-cell strong,
.planner-shift-cell strong {
    color: #101828;
    font-size: 13px;
}

.planner-date-cell span,
.planner-shift-cell span {
    margin-top: 3px;
    color: var(--text-soft);
    font-size: 11px;
}

.planner-origin-badge,
.planner-copy-badge,
.planner-sent-warning {
    width: fit-content;
    margin-top: 7px;
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.1;
}

.planner-origin-badge {
    background: #eef2f6;
    color: #475467;
}

.planner-copy-badge {
    background: #eaf2ff;
    color: #1d4ed8;
}

.planner-sent-warning {
    background: #eaf8ef;
    color: #166534;
}

.planner-person-cell {
    min-width: 250px;
}

.planner-contact-input {
    min-height: 39px;
    padding-right: 34px;
    background: #fff;
}

.planner-contact-input.selected-male {
    border-color: #93c5fd;
    background: #f5f9ff;
}

.planner-contact-input.selected-female {
    border-color: #f9a8d4;
    background: #fff7fb;
}

.planner-contact-input.invalid-contact {
    border-color: #f43f5e;
    background: #fff5f6;
    box-shadow: 0 0 0 3px rgba(244,63,94,.08);
}

.planner-clear-person {
    position: absolute;
    top: 50%;
    right: 7px;
    width: 24px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #eef2f6;
    color: #667085;
    box-shadow: none;
    font-size: 17px;
    font-weight: 500;
    transform: translateY(-50%);
}

.planner-clear-person:hover {
    background: #dfe5ec;
    color: #101828;
    box-shadow: none;
    transform: translateY(-50%);
}

.planner-status-cell {
    min-width: 138px;
}

.planner-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    border-radius: 999px;
    background: #eef2f6;
    color: #475467;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}

.planner-status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.planner-row-complete .planner-status-badge {
    background: #eaf8ef;
    color: #15803d;
}

.planner-row-partial .planner-status-badge {
    background: #fff7df;
    color: #a16207;
}

.planner-row-empty .planner-status-badge,
.planner-row-duplicate .planner-status-badge {
    background: #fff0f2;
    color: #be123c;
}

.planner-status-cell small {
    margin-top: 5px;
    color: var(--text-faint);
    font-size: 9px;
}

.planner-row-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 235px;
}

.planner-mini-button {
    min-height: 31px;
    padding: 6px 9px;
    border: 1px solid #dbe2ea;
    border-radius: 8px;
    background: #fff;
    color: #475467;
    box-shadow: none;
    font-size: 10px;
    font-weight: 750;
}

.planner-mini-button:hover {
    border-color: #bdc7d5;
    background: #f7f9fc;
    color: #101828;
    box-shadow: none;
}

.planner-note {
    color: #475467;
    font-size: 12px;
    line-height: 1.6;
}

.planner-note strong {
    display: block;
    margin-bottom: 4px;
    color: #101828;
    font-size: 13px;
}

/* Piccoli helper Bootstrap usati dal login */
.w-100 { width: 100% !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.mb-2 { margin-bottom: .5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.p-4 { padding: 1.5rem !important; }
.py-5 { padding-top: 3rem !important; padding-bottom: 3rem !important; }
.position-relative { position: relative !important; }

@media (max-width: 1040px) {
    .header-bar,
    .planner-hero,
    .planner-toolbar,
    .planner-actionbar {
        align-items: stretch;
        flex-direction: column;
    }

    .user-bar,
    .planner-hero-actions {
        justify-content: flex-start;
    }

    .planner-month-filter,
    .planner-actionbar-buttons {
        width: 100%;
        justify-content: flex-start;
    }

    .planner-stats {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .message-template-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .calendar-grid {
        grid-template-columns: 1fr;
    }

    .calendar-header,
    .calendar-day.empty {
        display: none;
    }

    .calendar-day {
        min-height: auto;
    }

    .month-toolbar {
        align-items: stretch;
    }

    .month-nav-group,
    .month-filter {
        width: 100%;
    }

    .month-nav-group {
        justify-content: center;
    }

    .month-filter > div {
        flex: 1;
        min-width: 130px;
    }

    .month-filter select,
    .month-filter input {
        width: 100%;
    }
}

@media (max-width: 680px) {
    .container,
    .planner-container {
        width: min(100% - 20px, 100%);
        margin-top: 10px;
    }

    .header-bar,
    .planner-hero {
        padding: 20px;
        border-radius: 15px;
    }

    .box {
        padding: 16px;
        border-radius: 14px;
    }

    .user-bar > a,
    .planner-hero-actions > a {
        flex: 1 1 auto;
    }

    .planner-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .planner-stat {
        min-height: 86px;
        padding: 14px;
    }

    .planner-stat strong {
        font-size: 24px;
    }

    .planner-progress-card {
        grid-template-columns: 1fr auto;
    }

    .planner-progress-track {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .planner-actionbar-buttons button,
    .planner-actionbar-buttons .btn-secondary {
        flex: 1 1 100%;
    }

    th,
    td {
        font-size: 12px;
    }
}

/* Login */
.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(37,99,235,.12), transparent 28rem),
        linear-gradient(180deg, #f8fafc 0%, #eef3f9 100%) !important;
}

.login-page .row {
    min-height: calc(100vh - 6rem);
    align-items: center;
}

.login-card {
    overflow: hidden;
    border: 1px solid var(--border) !important;
    border-radius: 18px !important;
    background: rgba(255,255,255,.96) !important;
    box-shadow: 0 24px 60px rgba(15,23,42,.12) !important;
}

.login-card::before {
    content: "";
    display: block;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
}

.login-heading h1 {
    margin: 5px 0 6px;
    color: #101828;
    font-weight: 760;
    letter-spacing: -.03em;
}

.login-heading p {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
}

.login-eyebrow {
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.login-page .form-label {
    margin: 0 0 6px;
    color: #344054;
    font-size: 12px;
    font-weight: 700;
}

.login-page .form-control {
    min-height: 44px;
    border-color: var(--border-strong);
    border-radius: 10px;
}

.login-page .btn-primary {
    min-height: 44px;
    border-color: var(--primary);
    background: var(--primary);
}

.login-page .btn-outline-secondary {
    min-height: 34px;
    border-color: var(--border-strong);
    background: #fff;
    color: #475467;
}

/* =========================================================
   MENU LATERALE PROFESSIONALE
   ========================================================= */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 82px;
    --sidebar-gap: 28px;
}

body.has-sidebar {
    overflow-x: hidden;
}

body.has-sidebar .container,
body.has-sidebar .planner-container {
    width: auto;
    max-width: 1580px;
    margin-left: calc(var(--sidebar-width) + var(--sidebar-gap));
    margin-right: var(--sidebar-gap);
    transition: margin-left .22s ease, max-width .22s ease;
}

.app-sidebar {
    position: fixed;
    z-index: 1100;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 18px 14px 14px;
    background:
        radial-gradient(circle at 0 0, rgba(59, 130, 246, .16), transparent 19rem),
        linear-gradient(180deg, #0f172a 0%, #111b2e 100%);
    border-right: 1px solid rgba(255,255,255,.07);
    box-shadow: 12px 0 35px rgba(15, 23, 42, .10);
    color: #e8eef8;
    transition: width .22s ease, transform .22s ease;
}

.sidebar-top {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 2px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 11px;
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    box-shadow: 0 8px 20px rgba(37, 99, 235, .26);
    color: #fff;
    font-size: 12px;
    font-weight: 850;
    letter-spacing: .06em;
}

.sidebar-brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.12;
    white-space: nowrap;
}

.sidebar-brand-copy strong {
    font-size: 14px;
    letter-spacing: -.01em;
}

.sidebar-brand-copy small {
    margin-top: 3px;
    color: #91a0b8;
    font-size: 10px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.sidebar-collapse-button {
    width: 32px;
    min-height: 32px;
    flex: 0 0 32px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 9px;
    background: rgba(255,255,255,.055);
    box-shadow: none;
    color: #aebad0;
}

.sidebar-collapse-button:hover {
    border-color: rgba(255,255,255,.19);
    background: rgba(255,255,255,.10);
    box-shadow: none;
    color: #fff;
    transform: none;
}

.sidebar-collapse-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .22s ease;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 0 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}

.sidebar-section-label {
    margin: 15px 10px 6px;
    color: #728098;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    white-space: nowrap;
}

.sidebar-section-label:first-child {
    margin-top: 2px;
}

.sidebar-link {
    position: relative;
    min-height: 43px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 3px 0;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #b9c5d8;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 680;
    white-space: nowrap;
    transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.sidebar-link:hover {
    border-color: rgba(255,255,255,.07);
    background: rgba(255,255,255,.055);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-link.is-active {
    border-color: rgba(96, 165, 250, .20);
    background: linear-gradient(90deg, rgba(37, 99, 235, .23), rgba(37, 99, 235, .10));
    color: #fff;
    box-shadow: inset 3px 0 0 #60a5fa;
}

.sidebar-link.is-active::after {
    content: "";
    position: absolute;
    right: 10px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #60a5fa;
    box-shadow: 0 0 0 4px rgba(96,165,250,.10);
}

.sidebar-footer {
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px 10px;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 9px;
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

.sidebar-user-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-user-copy strong {
    max-width: 155px;
    overflow: hidden;
    color: #f8fafc;
    font-size: 11.5px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-copy small {
    margin-top: 3px;
    color: #8492aa;
    font-size: 10px;
}

.sidebar-logout {
    color: #f0a6ad;
}

.sidebar-logout:hover {
    border-color: rgba(244,63,94,.14);
    background: rgba(244,63,94,.08);
    color: #fecdd3;
}

.sidebar-mobile-toggle,
.sidebar-overlay {
    display: none;
}

.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    flex-wrap: wrap;
}

.header-bar .header-actions .btn-secondary,
.header-bar .header-actions .btn {
    min-height: 38px;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .container,
body.sidebar-collapsed .planner-container {
    margin-left: calc(var(--sidebar-collapsed-width) + var(--sidebar-gap));
}

body.sidebar-collapsed .sidebar-brand-copy,
body.sidebar-collapsed .sidebar-link-label,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-user-copy {
    display: none;
}

body.sidebar-collapsed .sidebar-top {
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}

body.sidebar-collapsed .sidebar-collapse-button svg {
    transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding-inline: 8px;
}

body.sidebar-collapsed .sidebar-link.is-active::after {
    right: 5px;
}

body.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding-inline: 0;
}

body.sidebar-collapsed .sidebar-link:hover {
    transform: none;
}

@media (max-width: 980px) {
    body.has-sidebar .container,
    body.has-sidebar .planner-container,
    body.sidebar-collapsed .container,
    body.sidebar-collapsed .planner-container {
        width: min(100% - 24px, 1580px);
        margin: 74px auto 38px;
    }

    .app-sidebar,
    body.sidebar-collapsed .app-sidebar {
        width: min(286px, calc(100vw - 48px));
        transform: translateX(-102%);
        box-shadow: 18px 0 50px rgba(15,23,42,.28);
    }

    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar-brand-copy,
    body.sidebar-collapsed .sidebar-link-label,
    body.sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-user-copy {
        display: flex;
    }

    body.sidebar-collapsed .sidebar-section-label {
        display: block;
    }

    body.sidebar-collapsed .sidebar-top {
        justify-content: space-between;
        flex-direction: row;
        gap: 10px;
    }

    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
        padding-inline: 11px;
    }

    body.sidebar-collapsed .sidebar-user {
        justify-content: flex-start;
        padding-inline: 10px;
    }

    .sidebar-collapse-button {
        display: none;
    }

    .sidebar-mobile-toggle {
        position: fixed;
        z-index: 1050;
        top: 16px;
        left: 16px;
        width: 43px;
        min-height: 43px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 0;
        border: 1px solid rgba(15,23,42,.10);
        border-radius: 11px;
        background: rgba(255,255,255,.94);
        box-shadow: 0 8px 24px rgba(15,23,42,.12);
        color: #0f172a;
        backdrop-filter: blur(10px);
    }

    .sidebar-mobile-toggle:hover {
        background: #fff;
        box-shadow: 0 10px 28px rgba(15,23,42,.16);
        transform: none;
    }

    .sidebar-mobile-toggle span {
        width: 18px;
        height: 2px;
        border-radius: 999px;
        background: currentColor;
        transition: transform .18s ease, opacity .18s ease;
    }

    body.sidebar-mobile-open .sidebar-mobile-toggle span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    body.sidebar-mobile-open .sidebar-mobile-toggle span:nth-child(2) {
        opacity: 0;
    }

    body.sidebar-mobile-open .sidebar-mobile-toggle span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .sidebar-overlay {
        position: fixed;
        z-index: 1090;
        inset: 0;
        display: block;
        pointer-events: none;
        opacity: 0;
        background: rgba(15,23,42,.48);
        backdrop-filter: blur(2px);
        transition: opacity .2s ease;
    }

    body.sidebar-mobile-open .sidebar-overlay {
        pointer-events: auto;
        opacity: 1;
    }

    .header-bar,
    .planner-hero {
        margin-top: 0;
    }
}

@media (max-width: 680px) {
    body.has-sidebar .container,
    body.has-sidebar .planner-container,
    body.sidebar-collapsed .container,
    body.sidebar-collapsed .planner-container {
        width: min(100% - 20px, 100%);
        margin-top: 70px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .header-actions > a,
    .header-actions > button {
        flex: 1 1 auto;
    }
}

/* =========================================================
   Sostituzioni
   ========================================================= */
.page-kicker,
.section-eyebrow {
    display: block;
    margin-bottom: 5px;
    color: #8eb5ff;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.section-eyebrow {
    color: var(--primary);
}

.substitution-header .muted {
    max-width: 720px;
    margin-top: 8px;
}

.substitution-config-warning a {
    margin-left: 6px;
    color: inherit;
    font-weight: 800;
}

.recipient-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 15px;
    border: 1px solid #bbf7d0;
    border-radius: 13px;
    background: linear-gradient(135deg, #f0fdf4, #ffffff);
    box-shadow: var(--shadow-sm);
}

.recipient-strip-icon,
.whatsapp-send-icon {
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #16a34a;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .02em;
}

.recipient-strip-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
}

.recipient-strip > span:nth-child(2) {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.recipient-strip small {
    color: #667085;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .055em;
}

.recipient-strip strong {
    margin-top: 2px;
    color: #14532d;
    font-size: 13px;
}

.recipient-strip-number {
    margin-left: auto;
    padding: 5px 9px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 12px;
    font-weight: 800;
}

.substitution-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(340px, .75fr);
    align-items: start;
    gap: 20px;
}

.substitution-turns {
    min-width: 0;
}

.section-heading-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 13px;
    padding: 0 2px;
}

.section-heading-row h2,
.composer-head h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.turn-count {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border: 1px solid #dbe3ee;
    border-radius: 999px;
    background: #fff;
    color: #667085;
    font-size: 11px;
    font-weight: 800;
}

.shift-card-list {
    display: grid;
    gap: 12px;
}

.shift-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.shift-card:hover {
    border-color: #d5deea;
    box-shadow: 0 8px 24px rgba(16,24,40,.07);
}

.shift-card-main {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 15px 16px 12px;
}

.shift-date-badge {
    width: 52px;
    min-height: 52px;
    flex: 0 0 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border: 1px solid #dbeafe;
    border-radius: 12px;
    background: #eff6ff;
    color: #1d4ed8;
    line-height: 1;
}

.shift-date-badge strong {
    font-size: 19px;
    letter-spacing: -.04em;
}

.shift-date-badge span {
    margin-top: 4px;
    font-size: 9px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.shift-info {
    min-width: 0;
}

.shift-info h3 {
    margin: 0 0 5px;
    color: #101828;
    font-size: 15px;
    letter-spacing: -.015em;
}

.shift-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    color: #667085;
    font-size: 12px;
}

.shift-meta strong {
    color: #344054;
}

.shift-meta-dot {
    color: #c3cad5;
}

.replacement-person-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #eef2f6;
    background: #fbfcfe;
}

.replacement-person {
    min-height: 64px;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 11px;
    box-shadow: none;
    text-align: left;
    transform: none;
}

.replacement-person:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(16,24,40,.08);
}

.replacement-person.is-male {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
}

.replacement-person.is-male:hover,
.replacement-person.is-male.is-selected {
    border-color: #60a5fa;
    background: #dbeafe;
}

.replacement-person.is-female {
    border-color: #fbcfe8;
    background: #fdf2f8;
    color: #831843;
}

.replacement-person.is-female:hover,
.replacement-person.is-female.is-selected {
    border-color: #f472b6;
    background: #fce7f3;
}

.replacement-person.is-selected {
    box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}

.replacement-person:disabled {
    opacity: .48;
    cursor: not-allowed;
    filter: grayscale(.25);
}

.replacement-person:disabled:hover {
    transform: none;
    box-shadow: none;
}

.replacement-person-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: rgba(255,255,255,.78);
    color: inherit;
    font-size: 12px;
    font-weight: 900;
}

.replacement-person-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.replacement-person-copy small {
    opacity: .72;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.replacement-person-copy strong {
    margin-top: 2px;
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.replacement-person-action {
    opacity: .72;
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
}

.replacement-composer {
    position: sticky;
    top: 22px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 12px 32px rgba(16,24,40,.08);
}

.composer-head {
    padding: 17px 18px 14px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff, #fbfcfe);
}

.composer-placeholder {
    min-height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 30px 24px;
    color: #667085;
    text-align: center;
}

.composer-placeholder-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    margin-bottom: 13px;
    border: 1px solid #dbe3ee;
    border-radius: 13px;
    background: #f8fafc;
    color: #667085;
    font-size: 21px;
}

.composer-placeholder strong {
    color: #344054;
    font-size: 14px;
}

.composer-placeholder p {
    max-width: 300px;
    margin-top: 7px;
    font-size: 12px;
    line-height: 1.55;
}

.replacement-form {
    padding: 16px 18px 18px;
}

.replacement-form[hidden],
.composer-placeholder[hidden] {
    display: none !important;
}

.selected-replacement {
    display: flex;
    flex-direction: column;
    padding: 12px 13px;
    border: 1px solid #dbeafe;
    border-radius: 11px;
    background: #f8fbff;
}

.selected-replacement small {
    color: #667085;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.selected-replacement strong {
    margin-top: 3px;
    color: #1d4ed8;
    font-size: 14px;
}

.selected-replacement span {
    margin-top: 3px;
    color: #667085;
    font-size: 11px;
}

.replacement-form textarea {
    min-height: 205px;
    line-height: 1.55;
}

.message-counter {
    margin-top: 5px;
    color: #98a2b3;
    font-size: 10px;
    text-align: right;
}

.replacement-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.whatsapp-send-button {
    flex: 1 1 auto;
    background: #16a34a;
    box-shadow: 0 4px 10px rgba(22,163,74,.18);
}

.whatsapp-send-button:hover {
    background: #15803d;
    box-shadow: 0 7px 16px rgba(22,163,74,.23);
}

.whatsapp-send-icon {
    width: 23px;
    height: 23px;
    background: rgba(255,255,255,.16);
    font-size: 8px;
}

.composer-note {
    margin-top: 12px;
    color: #98a2b3;
    font-size: 10.5px;
    line-height: 1.5;
}

.substitution-empty {
    display: flex;
    min-height: 260px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
}

.substitution-empty-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border-radius: 12px;
    background: #f2f4f7;
    color: #98a2b3;
    font-weight: 900;
}

.substitution-empty h3 {
    font-size: 15px;
}

.substitution-empty p {
    margin-top: 5px;
    color: #667085;
    font-size: 12px;
}

/* Impostazioni messaggio sostituzione */
.substitution-settings-grid {
    display: grid;
    grid-template-columns: minmax(300px, .7fr) minmax(0, 1.3fr);
    align-items: start;
    gap: 20px;
}

.settings-card {
    margin-bottom: 0;
}

.settings-card-head {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 7px;
}

.settings-step {
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    font-weight: 900;
}

.settings-card-head h2 {
    margin: 0;
    font-size: 18px;
}

.settings-card-head p {
    margin-top: 3px;
    color: #667085;
    font-size: 12px;
}

.message-settings-card textarea {
    min-height: 230px;
    line-height: 1.55;
}

.template-token-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.template-token-grid code,
.template-help code {
    padding: 4px 7px;
    border: 1px solid #dbe3ee;
    border-radius: 7px;
    background: #f8fafc;
    color: #344054;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10.5px;
}

.template-help {
    margin-top: 14px;
    padding: 11px 12px;
    border: 1px solid #e4e9f0;
    border-radius: 10px;
    background: #fbfcfe;
}

.template-help strong {
    color: #344054;
    font-size: 11px;
}

.template-help p {
    margin-top: 4px;
    color: #667085;
    font-size: 11px;
    line-height: 1.55;
}

@media (max-width: 1120px) {
    .substitution-layout {
        grid-template-columns: 1fr;
    }

    .replacement-composer {
        position: static;
    }

    .composer-placeholder {
        min-height: 220px;
    }
}

@media (max-width: 820px) {
    .substitution-settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .recipient-strip {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .recipient-strip-number {
        width: 100%;
        margin-left: 48px;
    }

    .replacement-person-list {
        grid-template-columns: 1fr;
    }

    .replacement-person-action {
        display: none;
    }

    .shift-card-main {
        align-items: flex-start;
    }

    .replacement-form-actions {
        flex-direction: column;
    }

    .replacement-form-actions > * {
        width: 100%;
    }
}

/* =========================================================
   Sostituzioni da posto vuoto
   ========================================================= */
.vacancy-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 190px));
    gap: 10px;
    margin: 0 0 18px;
}

.vacancy-summary-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.vacancy-summary-card span {
    color: #667085;
    font-size: 11px;
    font-weight: 750;
}

.vacancy-summary-card strong {
    color: #344054;
    font-size: 20px;
    letter-spacing: -.04em;
}

.vacancy-summary-card.is-alert {
    border-color: #fed7aa;
    background: #fffaf5;
}

.vacancy-summary-card.is-alert strong {
    color: #c2410c;
}

.vacancy-card {
    border-left: 4px solid #f59e0b;
}

.vacancy-card.is-empty {
    border-left-color: #ef4444;
}

.vacancy-card-main {
    position: relative;
}

.vacancy-badge {
    margin-left: auto;
    padding: 6px 9px;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    background: #fff7ed;
    color: #c2410c;
    font-size: 10px;
    font-weight: 850;
    white-space: nowrap;
}

.vacancy-badge.is-empty {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.vacancy-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 12px 12px;
    border-top: 1px solid #eef2f6;
    background: #fbfcfe;
}

.assigned-people {
    min-width: 0;
}

.assigned-people > small {
    display: block;
    margin-bottom: 6px;
    color: #98a2b3;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.assigned-chip-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.assigned-chip {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 4px 8px;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1e40af;
    font-size: 10.5px;
    font-weight: 750;
}

.assigned-chip.is-female {
    border-color: #fbcfe8;
    background: #fdf2f8;
    color: #9d174d;
}

.assigned-empty {
    color: #98a2b3;
    font-size: 11px;
    font-style: italic;
}

.vacancy-select-button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 9px;
    background: #2563eb;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(37,99,235,.16);
}

.vacancy-select-button:hover,
.vacancy-select-button.is-selected {
    background: #1d4ed8;
    box-shadow: 0 7px 16px rgba(37,99,235,.22);
}

.vacancy-select-button.is-selected {
    box-shadow: 0 0 0 3px rgba(37,99,235,.12), 0 7px 16px rgba(37,99,235,.18);
}

.vacancy-select-button:disabled {
    opacity: .48;
    cursor: not-allowed;
}

.vacancy-selected-turn strong {
    color: #c2410c;
}

.vacancy-all-covered .substitution-empty-icon {
    background: #ecfdf3;
    color: #15803d;
}

@media (max-width: 680px) {
    .vacancy-summary {
        grid-template-columns: 1fr 1fr;
    }

    .vacancy-card-bottom {
        align-items: stretch;
        flex-direction: column;
    }

    .vacancy-select-button {
        width: 100%;
    }

    .vacancy-badge {
        position: absolute;
        top: 11px;
        right: 11px;
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .vacancy-card .shift-info {
        padding-right: 92px;
    }
}

/* =========================================================
   Account collegati ai contatti / Area personale
   ========================================================= */
.badge-contact{border:1px solid #bfdbfe;background:#eff6ff;color:#1d4ed8}
.linked-contact-chip{display:inline-flex;align-items:center;min-height:27px;padding:4px 9px;border:1px solid #dbeafe;border-radius:999px;background:#eff6ff;color:#1e40af;font-size:11px;font-weight:750}
.contact-account-field{margin-top:14px;padding:15px;border:1px solid #dbeafe;border-radius:12px;background:#f8fbff}
.contact-account-field[hidden]{display:none!important}.field-help{margin:7px 0 0;color:#667085;font-size:11px}
.contact-sidebar-note{margin:14px 10px;padding:11px;border:1px solid rgba(255,255,255,.08);border-radius:10px;background:rgba(255,255,255,.04);display:flex;flex-direction:column;gap:3px;color:#cbd5e1}.contact-sidebar-note strong{font-size:10px;text-transform:uppercase;letter-spacing:.06em}.contact-sidebar-note span{font-size:10px;line-height:1.45;color:#94a3b8}.sidebar-collapsed .contact-sidebar-note{display:none}
.contact-area-page{max-width:1240px}.contact-welcome{position:relative;overflow:hidden;margin-bottom:18px;padding:28px 30px;border:1px solid #dbeafe;border-radius:18px;background:linear-gradient(135deg,#eff6ff 0%,#fff 60%,#f8fafc 100%);display:flex;align-items:center;justify-content:space-between;gap:20px;box-shadow:var(--shadow-sm)}.contact-welcome-kicker{display:block;margin-bottom:5px;color:#2563eb;font-size:10px;font-weight:850;letter-spacing:.09em;text-transform:uppercase}.contact-welcome h1{margin:0;color:#101828;font-size:32px;letter-spacing:-.04em}.contact-welcome p{margin:8px 0 0;color:#667085;max-width:620px}.contact-welcome-badge{width:66px;height:66px;flex:0 0 66px;border-radius:18px;background:#2563eb;display:grid;place-items:center;color:#fff;font-size:22px;font-weight:850;box-shadow:0 12px 25px rgba(37,99,235,.2)}
.contact-stat-grid{display:grid;grid-template-columns:repeat(2,minmax(0,220px));gap:12px;margin-bottom:22px}.contact-stat-card{padding:16px 18px;border:1px solid #e4e7ec;border-radius:14px;background:#fff;box-shadow:var(--shadow-sm);display:flex;align-items:center;justify-content:space-between;gap:14px}.contact-stat-card span{color:#667085;font-size:11px;font-weight:750}.contact-stat-card strong{font-size:25px;color:#344054}.contact-stat-card.is-alert{border-color:#fed7aa;background:#fffaf5}.contact-stat-card.is-alert strong{color:#c2410c}
.contact-section{margin-top:24px}.contact-shift-list{display:grid;gap:12px}.contact-shift-card{display:grid;grid-template-columns:72px minmax(0,1fr) auto;align-items:center;gap:16px;padding:15px;border:1px solid #e4e7ec;border-radius:15px;background:#fff;box-shadow:var(--shadow-sm)}.contact-shift-card.has-replacement-request{border-color:#fed7aa;background:#fffaf5}.contact-shift-date{width:64px;height:64px;border:1px solid #dbeafe;border-radius:13px;background:#eff6ff;display:flex;flex-direction:column;align-items:center;justify-content:center}.contact-shift-date strong{font-size:23px;line-height:1;color:#1d4ed8}.contact-shift-date span{margin-top:5px;font-size:9px;font-weight:850;color:#3b82f6;text-transform:uppercase}.contact-shift-info h3{margin:0 0 5px;font-size:17px;color:#101828}.contact-shift-info p{margin:0;color:#667085;font-size:11.5px}.contact-companion{display:inline-block;margin-top:7px;color:#475467;font-size:11px;font-weight:700}.contact-shift-action{display:flex;align-items:flex-end;flex-direction:column;gap:8px}.contact-shift-action form{margin:0}.contact-replacement-button{min-height:38px;padding:9px 12px;border:0;border-radius:9px;background:#fff1f2;color:#be123c;font-size:11px;font-weight:800;cursor:pointer}.contact-replacement-button:hover{background:#ffe4e6}.contact-action-button{min-height:34px!important;font-size:10.5px!important}.replacement-status-chip{display:inline-flex;align-items:center;padding:5px 8px;border:1px solid #fed7aa;border-radius:999px;background:#fff7ed;color:#c2410c;font-size:9.5px;font-weight:850;white-space:nowrap}.contact-empty-state{text-align:center;padding:28px}.contact-empty-state strong{display:block;margin-bottom:5px}.contact-empty-state p{margin:0;color:#667085}.contact-month-toolbar{margin-bottom:12px}.contact-month-list{display:grid;gap:8px}.contact-month-row{display:grid;grid-template-columns:100px minmax(0,1fr) auto;align-items:center;gap:14px;padding:12px 14px;border:1px solid #e4e7ec;border-radius:11px;background:#fff}.contact-month-date{display:flex;align-items:baseline;gap:8px}.contact-month-date strong{font-size:19px;color:#344054}.contact-month-date span{color:#667085;font-size:10px;font-weight:750}.contact-month-row>div:nth-child(2){display:flex;flex-direction:column;gap:3px}.contact-month-row>div:nth-child(2)>strong{font-size:12px}.contact-month-row>div:nth-child(2)>span{font-size:10.5px;color:#667085}

/* Sostituzioni generate dagli account Contatto */
.replacement-summary-three{grid-template-columns:repeat(3,minmax(0,190px))}.vacancy-summary-card.is-request{border-color:#bfdbfe;background:#eff6ff}.vacancy-summary-card.is-request strong{color:#1d4ed8}.shift-card.has-personal-request{border-left-color:#2563eb}.coverage-reasons{display:flex;gap:7px;flex-wrap:wrap;padding:0 12px 10px}.coverage-reason{display:inline-flex;padding:4px 7px;border-radius:999px;font-size:9.5px;font-weight:800}.coverage-reason.is-vacancy{background:#fff7ed;color:#c2410c;border:1px solid #fed7aa}.coverage-reason.is-request{background:#eff6ff;color:#1d4ed8;border:1px solid #bfdbfe}.assigned-chip.is-replacement-requested{position:relative;border-color:#fb7185;background:#fff1f2;color:#9f1239}.assigned-chip em{margin-left:5px;font-size:8px;font-style:normal;font-weight:850;text-transform:uppercase;letter-spacing:.03em}.replacement-card-bottom{align-items:flex-end}.replacement-card-actions{display:flex;flex-direction:column;align-items:flex-end;gap:7px}.assign-replacement-button{display:inline-flex;align-items:center;justify-content:center;min-height:31px;padding:6px 9px;border:1px solid #bfdbfe;border-radius:8px;background:#eff6ff;color:#1d4ed8;text-decoration:none;font-size:9.5px;font-weight:850}.assign-replacement-button:hover{background:#dbeafe}.replacement-assignment-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;align-items:start}.replacement-request-detail h2{margin:6px 0 20px}.replacement-detail-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:10px 0;border-top:1px solid #eef2f6}.replacement-detail-row span{color:#667085;font-size:11px}.replacement-detail-row strong{text-align:right;font-size:11.5px}

@media(max-width:760px){.contact-welcome{padding:22px 20px}.contact-welcome h1{font-size:27px}.contact-welcome-badge{width:54px;height:54px;flex-basis:54px;font-size:18px}.contact-stat-grid{grid-template-columns:1fr 1fr}.contact-shift-card{grid-template-columns:58px minmax(0,1fr);gap:12px}.contact-shift-date{width:54px;height:54px}.contact-shift-action{grid-column:1/-1;align-items:stretch}.contact-shift-action form,.contact-replacement-button,.contact-action-button{width:100%}.replacement-status-chip{align-self:flex-start}.contact-month-row{grid-template-columns:72px minmax(0,1fr)}.contact-month-row>.replacement-status-chip{grid-column:2}.replacement-summary-three{grid-template-columns:1fr 1fr}.replacement-summary-three .is-request{grid-column:1/-1}.replacement-card-actions{width:100%;align-items:stretch}.assign-replacement-button,.replacement-card-actions .vacancy-select-button{width:100%}.replacement-assignment-grid{grid-template-columns:1fr}}

/* =========================================================
   Cambio password - account Contatto
   ========================================================= */
.password-page-grid{display:grid;grid-template-columns:minmax(0,1.55fr) minmax(260px,.75fr);gap:18px;align-items:start;max-width:980px}
.password-card{padding:24px}.password-card-heading{display:flex;align-items:flex-start;gap:14px;padding-bottom:19px;margin-bottom:20px;border-bottom:1px solid #eef2f6}.password-card-heading h2{margin:3px 0 6px;color:#101828;font-size:21px;letter-spacing:-.025em}.password-card-heading p{margin:0;color:#667085;font-size:12px;line-height:1.55}.password-card-icon{width:44px;height:44px;flex:0 0 44px;border-radius:12px;background:#eff6ff;display:grid;place-items:center;font-size:20px}
.password-form{display:grid;gap:17px}.password-field-wrap{display:grid;gap:7px}.password-field-wrap>label{color:#344054;font-size:11px;font-weight:800}.password-input-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px}.password-input-row input{width:100%}.password-toggle{min-width:76px;padding:0 11px;border:1px solid #d0d5dd;border-radius:9px;background:#fff;color:#475467;font-size:10.5px;font-weight:800;cursor:pointer}.password-toggle:hover{background:#f8fafc;color:#1d4ed8;border-color:#bfdbfe}.password-actions{margin-top:2px}.password-actions button{min-width:180px}
.password-strength{display:grid;gap:7px}.password-strength-bar{height:6px;overflow:hidden;border-radius:999px;background:#eef2f6}.password-strength-bar i{display:block;width:0;height:100%;border-radius:999px;background:#94a3b8;transition:width .2s ease,background .2s ease}.password-strength small{color:#667085;font-size:10px}.password-strength[data-level="1"] .password-strength-bar i{background:#dc2626}.password-strength[data-level="2"] .password-strength-bar i{background:#ea580c}.password-strength[data-level="3"] .password-strength-bar i{background:#d97706}.password-strength[data-level="4"] .password-strength-bar i{background:#16a34a}.password-strength[data-level="5"] .password-strength-bar i{background:#15803d}
.password-info-card{padding:22px}.password-info-card h3{margin:5px 0 9px;color:#101828;font-size:17px}.password-info-card>p{margin:0;color:#667085;font-size:11.5px;line-height:1.65}.password-account-info{margin-top:20px;padding-top:15px;border-top:1px solid #eef2f6;display:flex;justify-content:space-between;gap:12px;align-items:center}.password-account-info span{color:#98a2b3;font-size:10px;font-weight:750}.password-account-info strong{color:#344054;font-size:11.5px}
@media(max-width:760px){.password-page-grid{grid-template-columns:1fr}.password-card{padding:19px}.password-card-heading{gap:11px}.password-card-icon{width:40px;height:40px;flex-basis:40px}.password-input-row{grid-template-columns:1fr}.password-toggle{min-height:36px}.password-actions button{width:100%}.password-info-card{order:-1}}

/* Gestione appuntamenti: coda dinamica invii */
.appointment-progress{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:16px;
}
.appointment-stat{
  min-width:120px;
  padding:10px 14px;
  border:1px solid var(--line, #e5e7eb);
  border-radius:12px;
  background:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}
.appointment-stat span{font-size:12px;color:var(--muted, #667085);font-weight:700}
.appointment-stat strong{font-size:20px;line-height:1}
.appointment-stat.stat-pending strong{color:#b45309}
.appointment-stat.stat-sent strong{color:#15803d}
.sent-toggle{margin-left:auto}
.sent-divider-row td{padding:8px 12px!important;background:#f8fafc!important;border-top:2px solid #e5e7eb}
.sent-divider{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px;font-weight:800;text-transform:uppercase;letter-spacing:.04em;color:#667085}
.sent-section-hidden tr:not(.sent-divider-row){display:none}
.sent-section-hidden .sent-divider-row{display:table-row}
.row-just-sent td{animation:sentFlash .9s ease}
.next-to-send-highlight td{animation:nextFlash 1.2s ease}
.action-loading{opacity:.55;pointer-events:none}
@keyframes sentFlash{0%{box-shadow:inset 0 0 0 999px rgba(34,197,94,.18)}100%{box-shadow:inset 0 0 0 999px rgba(34,197,94,0)}}
@keyframes nextFlash{0%,100%{box-shadow:none}40%{box-shadow:inset 0 0 0 999px rgba(59,130,246,.09)}}
@media(max-width:720px){.sent-toggle{margin-left:0;width:100%}.appointment-stat{flex:1;min-width:100px}}
