/* wwwroot/css/backoffice.css
   Stile pannello di controllo staff Studio Medico
   ---------------------------------------------------------------- */

/* ── LAYOUT ───────────────────────────────────────────────────── */
.bo-layout {
    display: flex;
    min-height: 100vh;
    background: #f0f2f8;
}

.bo-sidebar {
    width: 220px;
    min-width: 220px;
    background: linear-gradient(180deg, #052767 0%, #3a0647 100%);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.bo-sidebar-logo {
    padding: 1.4rem 1.2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.bo-sidebar-logo-text {
    color: #fff;
    font-weight: 800;
    font-size: 1.1rem;
    font-family: 'Nunito', sans-serif;
}

.bo-nav {
    flex: 1;
    padding: 1rem 0;
}

.bo-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.2rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.97rem;
    font-weight: 600;
    transition: background 0.12s, color 0.12s;
    border-left: 3px solid transparent;
}

    .bo-nav-link:hover,
    .bo-nav-link.active {
        background: rgba(255,255,255,0.12);
        color: #fff;
        border-left-color: #fff;
    }

.bo-nav-icon {
    font-size: 1.1rem;
}

.bo-sidebar-footer {
    padding: 1rem 1.2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.bo-user-email {
    display: block;
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.bo-logout {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

    .bo-logout:hover {
        color: #fff;
    }
/* Layout per il blocco composto */
.bo-kpi--composite {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-left: 4px solid #475569; /* Grigio scuro di base */
    position: relative;
}

.bo-kpi__main {
    display: flex;
    flex-direction: column;
}

/* Sottosezione per le scadute */
.bo-kpi__sub {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 5px;
}

.bo-kpi__sub-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: lowercase;
}

.bo-kpi__sub-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ef4444; /* Rosso per attirare l'attenzione */
    background: #fef2f2;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Se ci sono scadute, cambiamo il bordo dell'intera card per dare enfasi */
.bo-kpi--composite:has(.bo-kpi__sub-num) {
    border-left-color: #ef4444;
}
/* ══════════════════════════════════════════════════════════════
   SIDEBAR LOGO — Stile Moderno
   ══════════════════════════════════════════════════════════════ */

.bo-sidebar-logo {
    padding: 1.5rem 1.25rem; /* Aumentiamo lo spazio verticale */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08); /* Linea di divisione sottile */
    margin-bottom: 1rem;
    gap: 12px; /* Spazio tra icona e testo */
}

/* Container per l'icona del logo */
.bo-logo-icon-container {
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.06); /* Sfondo scuro trasparente */
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* L'icona vera e propria */
.bo-logo-icon {
    font-size: 1.4rem;
    color: #a5b4fc; /* Un colore d'accento chiaro (es. indaco chiaro) */
}

/* Container del testo */
.bo-logo-text {
    display: flex;
    flex-direction: column; /* Testo su due righe */
    line-height: 1.2;
}

/* Prima riga: Nome dello Studio */
.bo-logo-brand {
    font-size: 1.1rem;
    font-weight: 700; /* Bold */
    color: #ffffff;
    letter-spacing: -0.5px; /* Compattiamo leggermente */
}

/* Seconda riga: Area (Backoffice) */
.bo-logo-area {
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8; /* Grigio/bluastro spento */
    text-transform: uppercase; /* Tutto maiuscolo */
    letter-spacing: 1px; /* Spaziamo le lettere per stile */
    margin-top: 1px;
}

/* ── MAIN ─────────────────────────────────────────────────────── */
.bo-main {
    flex: 1;
    padding: 1.8rem 2rem;
    overflow-y: auto;
}

.bo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.8rem;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.bo-title {
    font-family: 'Nunito', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: #052767;
    margin: 0;
}

.bo-date {
    color: #6b7490;
    font-size: 0.95rem;
    text-transform: capitalize;
}

.bo-loading {
    color: #6b7490;
    padding: 2rem 0;
}

.bo-empty {
    color: #6b7490;
    padding: 1.5rem 0;
    font-style: italic;
}

/* ── KPI ──────────────────────────────────────────────────────── */
.bo-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.2rem;
    margin-bottom: 2rem;
}

.bo-kpi {
    background: #fff;
    border-radius: 12px;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 2px 12px rgba(5,39,103,0.08);
    border-top: 4px solid;
}

a.bo-kpi {
    text-decoration: none;
}

.bo-kpi--blue {
    border-color: #1b6ec2;
}

.bo-kpi--orange {
    border-color: #d97706;
}

.bo-kpi--green {
    border-color: #1a7a4a;
}

.bo-kpi--purple {
    border-color: #7c3aed;
}

.bo-kpi__num {
    font-size: 2.4rem;
    font-weight: 800;
    font-family: 'Nunito', sans-serif;
    color: #052767;
    line-height: 1;
}

.bo-kpi__label {
    font-size: 0.9rem;
    color: #6b7490;
    margin-top: 0.3rem;
}

/* ── TABELLA ──────────────────────────────────────────────────── */
.bo-table-wrap {
    overflow-x: auto;
}

.bo-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(5,39,103,0.06);
}

    .bo-table th {
        background: #f7f9fd;
        padding: 0.75rem 1rem;
        text-align: left;
        font-size: 0.85rem;
        font-weight: 700;
        color: #6b7490;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-bottom: 1px solid #e8ecf4;
    }

    .bo-table td {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid #f0f2f8;
        font-size: 0.97rem;
    }

    .bo-table tr:last-child td {
        border-bottom: none;
    }

.bo-td-ora {
    font-weight: 800;
    font-size: 1.05rem;
    color: #052767;
}

/* ── BADGE ────────────────────────────────────────────────────── */
.bo-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bo-badge--confermata {
    background: #dcfce7;
    color: #166534;
}

.bo-badge--annullata {
    background: #fee2e2;
    color: #991b1b;
}

.bo-badge--inattesa {
    background: #fef3c7;
    color: #92400e;
}

.bo-badge--inlavorazione {
    background: #dbeafe;
    color: #1e40af;
}

.bo-badge--pronta {
    background: #d1fae5;
    color: #065f46;
}

.bo-badge--consegnata {
    background: #f3f4f6;
    color: #374151;
}

.bo-badge--notificata {
    background: #f3f4f6;
    color: #374151;
}
.badge-motivo {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background-color: #e0f2fe; /* Azzurro tenue */
    color: #0369a1; /* Blu scuro */
    margin-left: 8px;
}
/* ── AGENDA — SETTIMANA ───────────────────────────────────────── */
.bo-week-nav {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.bo-week-label {
    font-weight: 700;
    font-size: 1rem;
    color: #052767;
    text-transform: capitalize;
}

.bo-week-btn, .bo-week-btn-today {
    background: #fff;
    border: 1.5px solid #d8dde8;
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1b6ec2;
    cursor: pointer;
    transition: background 0.12s;
}

    .bo-week-btn:hover, .bo-week-btn-today:hover {
        background: #e8f0fa;
    }

.bo-week-btn-today {
    color: #052767;
}

.bo-week-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.6rem;
}

.bo-day-col {
    background: #fff;
    border-radius: 10px;
    padding: 0.7rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.12s;
    min-height: 120px;
}

    .bo-day-col:hover {
        border-color: #d8dde8;
    }

.bo-day-col--oggi {
    background: #f0f6ff;
}

.bo-day-col--selected {
    border-color: #1b6ec2 !important;
}

.bo-day-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 0.5rem;
}

.bo-day-nome {
    font-size: 0.75rem;
    color: #6b7490;
    text-transform: uppercase;
}

.bo-day-num {
    font-size: 1.3rem;
    font-weight: 800;
    color: #052767;
    font-family: 'Nunito', sans-serif;
}

.bo-slot-pill {
    font-size: 0.72rem;
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.bo-slot-confermata {
    background: #dbeafe;
    color: #1e40af;
}

.bo-slot-jolly {
    background: #ffffee;
    color: #991b1b;
}

.bo-slot-empty {
    font-size: 0.72rem;
    color: #d1d5db;
    font-style: italic;
}

/* ── TIMELINE GIORNO ──────────────────────────────────────────── */
.bo-day-detail {
    background: #fff;
    border-radius: 12px;
    padding: 1.4rem 1.6rem;
    box-shadow: 0 2px 12px rgba(5,39,103,0.06);
}

.bo-day-detail-title {
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: #052767;
    margin-bottom: 1.2rem;
    text-transform: capitalize;
}

.bo-timeline {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.bo-timeline-row {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 0.8rem;
    align-items: start;
}

.bo-timeline-ora {
    font-weight: 800;
    font-size: 0.95rem;
    color: #6b7490;
    padding-top: 0.6rem;
    text-align: right;
}

.bo-timeline-card {
    border-radius: 10px;
    padding: 0.8rem 1rem;
    border-left: 4px solid;
}

.bo-timeline-card--confermata {
    background: #f0f6ff;
    border-color: #1b6ec2;
}

.bo-timeline-card--annullata {
    background: #fff5f5;
    border-color: #ef4444;
}

.bo-timeline-card--free {
    background: #f9fafb;
    border-color: #d1d5db;
}

.bo-tc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
}

.bo-tc-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.9rem;
    color: #374151;
}

.bo-tc-note {
    color: #6b7490;
    font-style: italic;
}

.bo-tc-note-staff {
    color: #7c3aed;
    font-style: italic;
}

.bo-tc-staff-tag {
    font-size: 0.75rem;
    background: #ede9fe;
    color: #7c3aed;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    width: fit-content;
}

.bo-tc-free {
    color: #9ca3af;
    font-style: italic;
}

.bo-tc-actions {
    margin-top: 0.6rem;
    display: flex;
    gap: 0.5rem;
}

/* ── RICETTE ──────────────────────────────────────────────────── */
.bo-filtri {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
}

.bo-filtro-btn {
    background: #fff;
    border: 1.5px solid #d8dde8;
    border-radius: 20px;
    padding: 0.35rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7490;
    cursor: pointer;
}

.bo-filtro-btn--active {
    background: #052767;
    color: #fff;
    border-color: #052767;
}

.bo-ricette-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.bo-ricetta-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(5,39,103,0.06);
    overflow: hidden;
    border: 1.5px solid #e8ecf4;
}

.bo-ricetta-card--open {
    border-color: #1b6ec2;
}

.bo-rc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    cursor: pointer;
    gap: 1rem;
    flex-wrap: wrap;
}

    .bo-rc-header:hover {
        background: #f7f9fd;
    }

.bo-rc-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.bo-rc-cf {
    font-size: 0.82rem;
    color: #6b7490;
}

.bo-rc-data {
    font-size: 0.82rem;
    color: #6b7490;
}

.bo-rc-meta {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.bo-rc-farmaci {
    font-size: 0.85rem;
    color: #6b7490;
}

.bo-rc-allegati {
    font-size: 0.85rem;
    color: #1a7a4a;
}

.bo-rc-chevron {
    color: #6b7490;
    font-size: 0.9rem;
}

.bo-rc-body {
    border-top: 1px solid #e8ecf4;
    padding: 1.2rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bo-rc-section {
}

.bo-rc-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #6b7490;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.bo-rc-grid {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.9rem;
}

.bo-farmaci-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

    .bo-farmaci-list li {
        padding: 0.4rem 0.8rem;
        background: #f7f9fd;
        border-radius: 6px;
        margin-bottom: 0.3rem;
        font-size: 0.9rem;
    }

.bo-stato-btns {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bo-stato-btn {
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    border: 1.5px solid;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
}

.bo-stato-btn--inattesa {
    border-color: #d97706;
    color: #d97706;
}

.bo-stato-btn--inlavorazione {
    border-color: #1b6ec2;
    color: #1b6ec2;
}

.bo-stato-btn--pronta {
    border-color: #1a7a4a;
    color: #1a7a4a;
}

.bo-stato-btn--consegnata {
    border-color: #6b7490;
    color: #6b7490;
}

.bo-allegati-staff {
    margin-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bo-allegato-staff-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    background: #f0fdf4;
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
}

.bo-token-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.bo-token-input {
    font-size: 0.8rem !important;
    flex: 1;
    min-width: 200px;
    background: #f7f9fd;
}

.bo-commenti {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.bo-commento {
    background: #f7f9fd;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
}

.bo-commento-meta {
    display: flex;
    gap: 0.8rem;
    font-size: 0.8rem;
    color: #6b7490;
    margin-bottom: 0.3rem;
}

.bo-commento-testo {
    font-size: 0.9rem;
}

.bo-commento-form {
    margin-top: 0.5rem;
}

/* ── BOTTONI ──────────────────────────────────────────────────── */
.bo-btn-primary {
    background: linear-gradient(135deg, #052767, #1b6ec2);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

    .bo-btn-primary:hover {
        opacity: 0.88;
    }

.bo-btn-secondary {
    background: #fff;
    color: #052767;
    border: 1.5px solid #d8dde8;
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

    .bo-btn-secondary:hover {
        background: #f7f9fd;
    }

.bo-btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
}

.bo-btn-danger-sm {
    background: #fee2e2;
    color: #991b1b;
    border: 1.5px solid #fecaca;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.bo-btn-sm {
    background: #e8f0fa;
    color: #1b6ec2;
    border: 1.5px solid #c5d5ee;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.bo-btn-token {
    background: #ede9fe;
    color: #7c3aed;
    border: 1.5px solid #ddd6fe;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.bo-link {
    color: #1b6ec2;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

    .bo-link:hover {
        text-decoration: underline;
    }

.bo-link-btn {
    background: none;
    border: none;
    color: #1b6ec2;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: block;
    margin-bottom: 0.3rem;
}

.bo-section-title {
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #052767;
    margin: 1.4rem 0 0.8rem;
}

/* ── MODALE ───────────────────────────────────────────────────── */
.bo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.bo-modal {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.bo-modal--wide {
    max-width: 680px;
}

.bo-modal-title {
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: #052767;
    margin-bottom: 1rem;
}

.bo-modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
    margin-top: 1.2rem;
    flex-wrap: wrap;
}

/* ── TOAST ────────────────────────────────────────────────────── */
.bo-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #052767;
    color: #fff;
    padding: 0.8rem 1.4rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 20px rgba(5,39,103,0.3);
    z-index: 2000;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ── LOGIN ────────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #052767 0%, #3a0647 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    color: #052767;
    margin-bottom: 1rem;
}

.login-title {
    font-family: 'Nunito', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: #052767;
    margin-bottom: 0.3rem;
}

.login-subtitle {
    color: #6b7490;
    font-size: 0.95rem;
    margin-bottom: 1.8rem;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    color: #374151;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    padding: 0.85rem 1.6rem;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none;
    transition: box-shadow 0.12s, border-color 0.12s;
    width: 100%;
    justify-content: center;
    margin-bottom: 1.2rem;
}

    .btn-google:hover {
        box-shadow: 0 4px 16px rgba(0,0,0,0.12);
        border-color: #9ca3af;
        color: #374151;
    }

.login-error {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.login-note {
    color: #6b7490;
    font-size: 0.82rem;
    line-height: 1.5;
}

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 768px) {
    .bo-week-grid {
        grid-template-columns: repeat(5, minmax(60px, 1fr));
        overflow-x: auto;
    }

    .bo-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── SIDEBAR MOBILE ───────────────────────────────────────────── */
.bo-hamburger {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1100;
    background: #052767;
    border: none;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    line-height: 1;
}

.bo-sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1000; /* Deve essere sotto la sidebar (1100) ma sopra il resto */
}

.bo-sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* ── MOBILE ───────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Mostra hamburger */
    .bo-hamburger {
        display: flex;
    }

    /* Sidebar: nascosta a sinistra, scorre dentro */
    .bo-sidebar {
        position: fixed;
        top: 0;
        left: -250px;
        height: 100vh;
        width: 240px;
        z-index: 1100;
        transition: left 0.22s cubic-bezier(.4,0,.2,1);
        /* mantiene lo stile gradiente già definito */
    }

    .bo-sidebar--open {
        left: 0;
    }

    /* Contenuto principale: padding alto per l'hamburger */
    .bo-main {
        padding: 1rem 0.9rem;
        padding-top: 2rem;
    }

    /* Griglia settimana scrollabile */
    .bo-week-grid {
        grid-template-columns: repeat(5, minmax(65px, 1fr));
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.1rem;
        padding-bottom: 0.3rem;
    }

    .bo-day-col {
        min-width: 50px;
    }

    /* Tabella scrollabile */
    .bo-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}


/* ── SLOT LIBERI COUNTER ──────────────────────────────────────── */
.bo-day-liberi {
    font-size: 0.68rem;
    font-weight: 700;
    text-align: center;
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    margin-top: 0.3rem;
    background: #dcfce7;
    color: #166534;
}

.bo-day-liberi--pochi {
    background: #fef3c7;
    color: #92400e;
}

.bo-day-liberi--zero {
    background: #fee2e2;
    color: #991b1b;
}

/* ── DETTAGLIO GIORNO — BADGE DISPONIBILI ─────────────────────── */
.bo-day-detail-liberi {
    display: inline-block;
    margin-left: 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: #dcfce7;
    color: #166534;
    border-radius: 20px;
    padding: 0.15rem 0.7rem;
    vertical-align: middle;
}

/* ── ORA STAFF (fuori orario pubblico) ────────────────────────── */
.bo-timeline-ora--staff {
    color: #7c3aed;
}

.bo-ora-staff-tag {
    font-size: 0.65rem;
    color: #7c3aed;
    margin-left: 2px;
    vertical-align: super;
}
/* ── BOTTONE STAMPA ───────────────────────────────────────────── */
.bo-day-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

    .bo-day-detail-header .bo-day-detail-title {
        margin-bottom: 0;
    }

.bo-btn-print {
    background: #fff;
    border: 1.5px solid #d8dde8;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    font-size: 0.92rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

    .bo-btn-print:hover {
        background: #f0f6ff;
        border-color: #1b6ec2;
        color: #1b6ec2;
    }

/* ── BOTTONE LINK ANNULLAMENTO ────────────────────────────────── */
.bo-btn-link-annulla {
    background: #fffbf0;
    border: 1.5px solid #d97706;
    color: #92400e;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.12s;
}

    .bo-btn-link-annulla:hover {
        background: #fef3c7;
    }

/* Pulsante di chiusura interno alla sidebar (solo mobile) */
.bo-close-btn {
    display: none; /* Nascosto di default su desktop */
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    margin: 1rem 1.2rem 0 auto; /* Allinea a destra con margine */
    transition: background 0.2s;
}

    .bo-close-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }

/* Visualizzazione su Mobile */
@media (max-width: 768px) {
    .bo-close-btn {
        display: block; /* Appare solo su schermi piccoli */
    }

    /* Opzionale: aggiusta il logo per far spazio alla X se necessario */
    .bo-sidebar-logo {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}

/* ── PWA BACKOFFICE: BOTTONE INSTALLA NELLA SIDEBAR ──────────── */
.bo-pwa-install-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: calc(100% - 2.4rem);
    margin: 0.5rem 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

    .bo-pwa-install-btn:hover {
        background: rgba(255, 255, 255, 0.18);
        color: #fff;
    }

/* ── SLOT LIBERO CON STORICO ANNULLAMENTO ─────────────────────── */
.bo-tc-annullata-storico {
    display: block;
    font-size: 0.75rem;
    color: #9ca3af;
    font-style: italic;
    margin-top: 0.3rem;
    text-decoration: line-through;
    opacity: 0.7;
}

/* ── BOTTONE SPOSTA ───────────────────────────────────────────── */
.bo-btn-sposta {
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    color: #1d4ed8;
}

    .bo-btn-sposta:hover {
        background: #dbeafe;
    }

/* ── DOPPIO SLOT ──────────────────────────────────────────────── */
.bo-doppio-slot-box {
    background: #faf5ff;
    border: 1.5px solid #e9d5ff;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-top: 0.5rem;
    transition: background 0.12s, border-color 0.12s;
}

.bo-doppio-slot-box--active {
    background: #f5f3ff;
    border-color: #7c3aed;
}

.bo-doppio-slot-label {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.bo-doppio-slot-check {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-top: 2px;
    accent-color: #7c3aed;
    cursor: pointer;
}

/* ── BADGE DOPPIO SLOT ────────────────────────────────────────── */
.bo-badge-doppio {
    display: inline-block;
    background: #ede9fe;
    color: #7c3aed;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
}

/* ── CARD DOPPIO SLOT ─────────────────────────────────────────── */
.bo-timeline-card--doppio {
    border-left-color: #7c3aed !important;
    background: #faf5ff !important;
}

/* ── SLOT EXTRA (fuori orario) ───────────────────────────────── */
.bo-slot-extra-toggle {
    margin: 0.5rem 0 0.2rem;
    padding: 0 0 0 50px; /* allineato alla colonna ora */
}

.bo-btn-ghost {
    background: none;
    border: 1.5px dashed #cbd5e1;
    border-radius: 8px;
    padding: 0.45rem 1rem;
    font-size: 0.88rem;
    color: #64748b;
    cursor: pointer;
    transition: border-color 0.12s, color 0.12s;
    width: 100%;
    text-align: left;
}

    .bo-btn-ghost:hover {
        border-color: #94a3b8;
        color: #374151;
    }

.bo-slot-extra-section {
    margin-top: 0.4rem;
    border-top: 2px dashed #e2e8f0;
    padding-top: 0.5rem;
}

.bo-slot-extra-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 0.4rem 76px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bo-btn-ghost-sm {
    background: none;
    border: none;
    font-size: 0.8rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 0;
}

    .bo-btn-ghost-sm:hover {
        color: #374151;
    }

/* ── BOTTONE SPOSTA ───────────────────────────────────────────── */
.bo-btn-sposta {
    background: #eff6ff;
    border: 1.5px solid #bfdbfe;
    color: #1d4ed8;
}

    .bo-btn-sposta:hover {
        background: #dbeafe;
    }

/* ── DOPPIO SLOT ──────────────────────────────────────────────── */
.bo-doppio-slot-box {
    background: #faf5ff;
    border: 1.5px solid #e9d5ff;
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-top: 0.6rem;
    transition: background 0.12s, border-color 0.12s;
}

.bo-doppio-slot-box--active {
    background: #f5f3ff;
    border-color: #7c3aed;
}

.bo-doppio-slot-label {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.bo-doppio-slot-check {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-top: 2px;
    accent-color: #7c3aed;
    cursor: pointer;
}

/* ── BADGE E CARD DOPPIO ──────────────────────────────────────── */
.bo-badge-doppio {
    display: inline-block;
    background: #ede9fe;
    color: #7c3aed;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
}

.bo-timeline-card--doppio {
    border-left-color: #7c3aed !important;
    background: #faf5ff !important;
}

/* ── SYNC INDICATOR ───────────────────────────────────────────── */
.bo-sync-indicator {
    font-size: 0.78rem;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.bo-sync-indicator--ok {
    color: #22c55e;
}

/* ── MODALE COMPATTA (mobile-first) ───────────────────────────── */
.bo-modal--compact {
    padding: 1rem 1rem 0.8rem;
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.bo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

    .bo-modal-header .bo-modal-title {
        margin-bottom: 0;
        font-size: 1rem;
    }

.bo-modal-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

    .bo-modal-close:hover {
        background: #f3f4f6;
        color: #374151;
    }

.bo-modal-subtitle {
    font-size: 0.9rem;
    color: #6b7490;
    margin-bottom: 0.8rem;
}

/* Form compatto dentro la modale */
.form-row-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-group-compact {
    margin-bottom: 0.5rem;
}

.form-label-sm {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Doppio slot: versione compatta */
.bo-doppio-slot-compact {
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.6rem;
}

.bo-jolly-compact {
    background: #ffffee;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.6rem;
}

.bo-doppio-slot-label-compact {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
}

.bo-doppio-warning {
    font-size: 0.8rem;
    color: #92400e;
    background: #fef3c7;
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    margin-top: 0.4rem;
}

.alert-sm {
    font-size: 0.85rem;
    padding: 0.4rem 0.7rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 480px) {
    .bo-modal--compact {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        /* Su mobile molto piccolo, si ancora in basso */
    }

    .form-row-compact {
        grid-template-columns: 1fr 1fr;
    }
}

/* ══════════════════════════════════════════════════════════════
   CRM — PAZIENTI
   ══════════════════════════════════════════════════════════════ */

/* ── Barra ricerca lista ──────────────────────────────────── */
.crm-search-bar {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

    .crm-search-bar .form-control {
        flex: 1;
    }

/* ── Lista pazienti ───────────────────────────────────────── */
.crm-lista {
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    overflow: hidden;
}

.crm-lista-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #f0f2f7;
    cursor: pointer;
    transition: background 0.1s;
}

    .crm-lista-row:last-child {
        border-bottom: none;
    }

    .crm-lista-row:hover {
        background: #f7f9fd;
    }

.crm-lista-nome {
    font-size: 1rem;
}

.crm-lista-dn {
    font-size: 0.85rem;
}

.crm-lista-contatti {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.crm-lista-contatto {
    font-size: 0.82rem;
    color: #6b7490;
}

/* ── Dettaglio griglia ────────────────────────────────────── */
.crm-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.2rem;
}

.crm-detail-section {
    background: #f7f9fd;
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    padding: 1rem 1.1rem;
}

.crm-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6b7490;
    margin-bottom: 0.7rem;
}

.crm-field-row {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid #eef0f5;
    font-size: 0.92rem;
}

    .crm-field-row:last-child {
        border-bottom: none;
    }

.crm-field-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #9ca3af;
    min-width: 90px;
    flex-shrink: 0;
}

.crm-field-row--note {
    align-items: flex-start;
}

.crm-note-text {
    white-space: pre-wrap;
    font-size: 0.9rem;
}

.crm-cf {
    font-family: monospace;
    letter-spacing: 0.05em;
}

/* ── Badge ────────────────────────────────────────────────── */
.crm-badge-principale {
    font-size: 0.7rem;
    font-weight: 700;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 10px;
    padding: 0.1rem 0.45rem;
}

.crm-badge-ruolo {
    font-size: 0.78rem;
    font-weight: 700;
    background: #f3e8ff;
    color: #7c3aed;
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
    flex-shrink: 0;
}

.crm-contatto-tipo-badge {
    font-size: 0.78rem;
    font-weight: 700;
    color: #374151;
    min-width: 80px;
}

.crm-link {
    color: #052767;
    font-weight: 600;
    text-decoration: none;
}

    .crm-link:hover {
        text-decoration: underline;
    }

/* ── Ricerca risultati ────────────────────────────────────── */
.crm-search-box {
    display: flex;
    align-items: center;
    margin: 0.5rem 0;
}

.crm-risultati {
    border: 1px solid #e8ecf4;
    border-radius: 8px;
    overflow-y: auto;
    max-height: 220px;
    margin-top: 0.4rem;
}

.crm-risultato {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid #f0f2f7;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s;
}

    .crm-risultato:last-child {
        border-bottom: none;
    }

    .crm-risultato:hover {
        background: #f0f6ff;
    }

.crm-risultato-contatto {
    font-size: 0.8rem;
    color: #6b7490;
}

.crm-no-results {
    font-size: 0.9rem;
    color: #6b7490;
    padding: 0.6rem 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* ── Widget PazienteCard ──────────────────────────────────── */
.crm-card {
    border: 1.5px solid #e8ecf4;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.crm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.7rem 1rem;
    flex-wrap: wrap;
}

.crm-card-header--linked {
    background: #f0fdf4;
    border-color: #86efac;
}

.crm-card-header--unlinked {
    background: #f7f9fd;
}

.crm-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.crm-card-nome {
    font-weight: 700;
    color: #052767;
    text-decoration: none;
    font-size: 0.85rem;
}

    .crm-card-nome:hover {
        text-decoration: underline;
    }

.crm-card-detail {
    font-size: 0.82rem;
    color: #6b7490;
}

.crm-card-placeholder {
    font-size: 0.9rem;
    color: #9ca3af;
}

.crm-card-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

/* ── Form contatti inline ─────────────────────────────────── */
.crm-contatti-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.crm-contatto-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.crm-contatto-tipo {
    width: 110px;
    flex-shrink: 0;
}

.crm-contatto-principale {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
    color: #6b7490;
    white-space: nowrap;
    cursor: pointer;
}

.crm-principale-label {
    display: none;
}

@media (min-width: 500px) {
    .crm-principale-label {
        display: inline;
    }
}

/* ── Form registrazione (dentro PazienteCard) ─────────────── */
.crm-registra-form {
    padding: 1rem;
    background: #f7f9fd;
    border-top: 1px solid #e8ecf4;
}

/* ── Relazioni ────────────────────────────────────────────── */
.crm-relazione-form {
    margin-top: 0.6rem;
    padding: 0.7rem;
    background: #faf5ff;
    border-radius: 8px;
}

/* ── Comunicazioni ────────────────────────────────────────── */
.crm-comunicazioni-section {
    margin-top: 1.2rem;
}

.crm-nuova-comunicazione {
    background: #f7f9fd;
    border: 1px solid #e8ecf4;
    border-radius: 8px;
    padding: 0.8rem;
    margin: 0.5rem 0;
}

.crm-comunicazioni-lista {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.crm-comunicazione {
    background: #f7f9fd;
    border: 1px solid #e8ecf4;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
}

.crm-comunicazione-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.crm-comunicazione-data {
    font-size: 0.82rem;
    color: #6b7490;
}

.crm-comunicazione-testo {
    font-size: 0.9rem;
    color: #1a1f2e;
    line-height: 1.5;
}

/* Badge tipo comunicazione */
.crm-badge-tipo {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    flex-shrink: 0;
}

.crm-badge-tipo--Whatsapp {
    background: #dcfce7;
    color: #166534;
}

.crm-badge-tipo--email {
    background: #dbeafe;
    color: #1e40af;
}

.crm-badge-tipo--telefono {
    background: #fef3c7;
    color: #92400e;
}

.crm-badge-tipo--visita {
    background: #ede9fe;
    color: #7c3aed;
}

.crm-badge-tipo--altro {
    background: #f3f4f6;
    color: #374151;
}

/* ══════════════════════════════════════════════════════════════
   TAB BAR INFERIORE
   ══════════════════════════════════════════════════════════════ */

.bo-tabbar {
    display: flex;
    justify-content: space-around;
    background: #fff;
    border-top: 1px solid #eee;
    padding: 10px 0;
    position: fixed;
    z-index: 999; /* Forza il menu a stare SOPRA tutto il resto */
    bottom: 0;
    width: 100%;
}

.bo-tab {
    text-decoration: none;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
}


.bo-tab-icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
}


.bo-tab:hover,
.bo-tab.active,
.bo-tab[href].active {
    color: #0d6efd;
}

/* Blazor NavLink aggiunge la classe .active automaticamente */
.bo-tab ::deep .active,
.bo-tab.active {
    color: #0d6efd;
}



    /* Dot indicator sull'icona attiva */
    .bo-tab.active::before {
        content: '';
        position: absolute;
        top: 6px;
        width: 4px;
        height: 4px;
        background: #052767;
        border-radius: 50%;
    }

/* ══════════════════════════════════════════════════════════════
   FAB — Floating Action Button (agenda mobile)
   ══════════════════════════════════════════════════════════════ */
.bo-fab {
    display: none; /* mostrato solo su mobile via media query */
}

@media (max-width: 768px) {
    .bo-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        right: 1.2rem;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #052767, #1b6ec2);
        border: none;
        box-shadow: 0 4px 16px rgba(5,39,103,0.35);
        cursor: pointer;
        z-index: 999;
        transition: transform 0.15s, box-shadow 0.15s;
        -webkit-tap-highlight-color: transparent;
    }

        .bo-fab:active {
            transform: scale(0.93);
            box-shadow: 0 2px 8px rgba(5,39,103,0.25);
        }

    /* Bottone desktop nascosto su mobile */
    .bo-btn-desktop-only {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .bo-fab {
        display: none !important;
    }

    .bo-btn-desktop-only {
        display: inline-flex !important;
    }

    /* Main: niente padding top extra, ma padding bottom per la tab bar */
    .bo-main {
        padding: 0.9rem 0.9rem;
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
    /* Griglia settimana scrollabile */
    .bo-week-grid {
        grid-template-columns: repeat(5, minmax(62px, 1fr));
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 0.25rem;
        padding-bottom: 0.3rem;
    }

    .bo-day-col {
        min-width: 62px;
    }

    /* Tabella scrollabile */
    .bo-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Layout: la sidebar non c'è, il main occupa tutto */
    .bo-layout {
        grid-template-columns: 1fr !important;
    }
    /* Tab bar nascosta su desktop */
    .bo-tabbar {
        display: none !important;
    }
}

/* ══════════════════════════════════════════════════════════════
   HEADER AGENDA RIVISITATO
   ══════════════════════════════════════════════════════════════ */
.bo-header--agenda {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}

.bo-header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* Sync pill: piccolo, inline con il titolo */
.bo-sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: #94a3b8;
    background: #f1f5f9;
    border-radius: 20px;
    padding: 0.15rem 0.55rem;
}

.bo-sync-pill--ok {
    color: #16a34a;
    background: #f0fdf4;
}

/* ══════════════════════════════════════════════════════════════
   WEEK NAV — tutto su una riga
   ══════════════════════════════════════════════════════════════ */
.bo-week-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
    flex-wrap: nowrap; /* MAI a capo */
}

.bo-week-btn {
    background: #fff;
    border: 1.5px solid #e8ecf4;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s;
    white-space: nowrap;
}

    .bo-week-btn:hover {
        background: #f0f6ff;
        border-color: #1b6ec2;
        color: #1b6ec2;
    }

.bo-week-label {
    flex: 1; /* occupa lo spazio disponibile */
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* permette shrink */
}

.bo-week-btn-today {
    background: #f1f5f9;
    border: 1.5px solid #e8ecf4;
    border-radius: 8px;
    padding: 0.4rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    transition: background 0.12s;
}

    .bo-week-btn-today:hover {
        background: #e2e8f0;
    }

@media (max-width: 400px) {
    .bo-week-label {
        font-size: 0.72rem;
    }

    .bo-week-btn {
        padding: 0.35rem 0.45rem;
        font-size: 0.78rem;
    }

    .bo-week-btn-today {
        padding: 0.35rem 0.45rem;
        font-size: 0.75rem;
    }
    /* .bo-day-detail-liberi{display:none;}*/
    .bo-btn-print {
        display: none;
    }

    .bo-day-col {
        padding: 0.3rem;
    }
}

/* --- AGGIORNAMENTI PER AGENDA RESPONSIVA --- */

/* La riga della timeline */
.bo-timeline-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

/* Card Appuntamento Ottimizzata */
.bo-appointment-card {
    transition: all 0.2s ease-in-out;
    background: #fff;
    border-left: 5px solid #1b6ec2 !important;
    width: 100%;
}

.bo-appointment-card-blocker {
    transition: all 0.2s ease-in-out;
    background: #ffffee;
    border-left: 5px solid #1b6ec2 !important;
    width: 100%;
}

.bo-appointment-card:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.08) !important;
}

.bo-appointment-card-blocker:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.08) !important;
}

/* Badge Stati (usando i tuoi nomi file) */
.bo-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.bo-badge--confermata {
    background: #e0f2fe;
    color: #0369a1;
}

.bo-badge--annullata {
    background: #fee2e2;
    color: #991b1b;
    text-decoration: none !important;
}

.bo-badge--inviatowa {
    background: #dcfce7;
    color: #166534;
}

/* Slot Libero Tratteggiato */
.border-dashed {
    border: 2px dashed #e5e7eb !important;
    transition: border-color 0.2s;
}

    .border-dashed:hover {
        border-color: #1b6ec2 !important;
        background-color: #f8fafc !important;
    }

/* Dropdown (i tre puntini) */
.dropdown-item {
    cursor: pointer;
    transition: background 0.1s;
}

    .dropdown-item:active {
        background-color: #1b6ec2;
    }

/* Ottimizzazione Mobile (sotto i 768px) */
@media (max-width: 767.98px) {
    .bo-timeline-row {
        gap: 0.5rem;
    }

    .bo-timeline-ora {
        /*min-width: 55px !important;*/
        font-size: 0.8rem;
    }

    .bo-appointment-card .p-3 {
        padding: 0.75rem !important; /* Meno spazio interno su cellulare */
    }
}

/* Container info paziente */
.bo-info-container {
    flex: 1;
    padding-right: 1rem;
}

/* Nome Paziente */
.bo-patient-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1f2937;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.bo-patient-name--annullata {
    text-decoration: line-through;
    opacity: 0.5;
}

/* Riga sotto il nome (Badge doppio/staff) */
.bo-meta-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    align-items: center;
}

.bo-tag-doppio {
    font-size: 0.65rem;
    padding: 1px 6px;
    background: #fff;
    color: #1b6ec2;
    border: 1px solid #1b6ec2;
    border-radius: 50px;
}

.bo-tag-staff {
    font-size: 0.7rem;
    color: #6b7280;
}

/* TAG NOTIFICA (Spostato a destra, discreto) */
.bo-notifica-tag {
    font-size: 0.6rem;
    font-weight: 800;
    color: #10b981; /* Verde discreto */
    /*background: #f0fdf4;*/
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.bo-staff-tag {
    font-size: 0.6rem;
    font-weight: 800;
    background: #f3f4f6;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.bo-notifica-tag--danger {
    color: #ef4444;
    background: #fef2f2;
}

.bo-notifica-tag i {
    font-size: 0.7rem;
    margin-right: 2px;
}

/* Bottone Tre Puntini */
.bo-more-btn {
    padding: 0;
    color: #9ca3af;
    background: transparent;
    border: none;
    transition: color 0.2s;
}

    .bo-more-btn:hover {
        color: #1b6ec2;
    }
/* --- Pulizia e Posizionamento Card --- */

/* Applica Flexbox all'intera card per separare sinistra e destra */
.bo-appointment-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}

/* Blocchi di contenuto */
.bo-patient-info-block {
    flex: 1; /* Prende tutto lo spazio disponibile a sinistra */
    padding-right: 1.5rem;
}

.bo-metadata-actions-block {
    display: flex;
    align-items: center; /* Allinea orizzontalmente tag, icona e menu */
    gap: 0.6rem; /* Spazio tra gli elementi */
    margin-top: -3px; /* Leggero aggiustamento verticale per allineare con la prima riga di testo */
    flex-shrink: 0; /* Impedisce che questo blocco venga compresso */
}

/* --- Metadati Micro a Destra --- */

/* Tag NOTIFICATA Micro (Verde discreto) */
.bo-notifica-tag-micro {
    font-size: 0.62rem;
    font-weight: 800;
    color: #0d9488; /* Verde più spento per non trarre in inganno */
    /*background-color: #f0fdfa;*/
    padding: 2px 5px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* Icona Staff Micro (Discreta, colore testo secondario) */
.bo-staff-icon-micro {
    font-size: 0.8rem;
    color: #9ca3af; /* Grigio chiaro per non distrarre */
}

/* --- Pulizia Tasto Tre Puntini --- */
.bo-more-btn {
    padding: 0;
    margin: 0;
    color: #9ca3af;
    background-color: transparent;
    border: none;
    line-height: 1;
    transition: color 0.1s;
}

    .bo-more-btn:hover {
        color: #1b6ec2;
        background-color: transparent;
    }

/* ══════════════════════════════════════════════════════════════
   CRM — LISTA PAZIENTI (card grid + paginazione)
   ══════════════════════════════════════════════════════════════ */

/* ── Search bar ───────────────────────────────────────────────── */
.crm-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.crm-search-icon {
    position: absolute;
    left: 0.75rem;
    width: 16px;
    height: 16px;
    stroke: #9ca3af;
    pointer-events: none;
    flex-shrink: 0;
}

.crm-search-input {
    padding-left: 2.4rem !important;
    padding-right: 2.2rem !important;
    border-radius: 10px !important;
}

.crm-search-clear {
    position: absolute;
    right: 0.6rem;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

    .crm-search-clear:hover {
        color: #374151;
        background: #f3f4f6;
    }

/* ── Stati lista ──────────────────────────────────────────────── */
.crm-loading-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.crm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem 1rem;
    color: #9ca3af;
    text-align: center;
}

    .crm-empty-state svg {
        width: 64px;
        height: 64px;
        opacity: .4;
    }

    .crm-empty-state p {
        font-size: 1rem;
        margin: 0;
    }

/* ── Card grid ────────────────────────────────────────────────── */
.crm-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.crm-paziente-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}

    .crm-paziente-card:hover {
        border-color: #93c5fd;
        box-shadow: 0 4px 16px rgba(5,39,103,0.08);
        transform: translateY(-1px);
    }

    .crm-paziente-card:active {
        transform: translateY(0);
    }

.crm-paziente-card-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #052767, #1b6ec2);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.crm-paziente-card-body {
    flex: 1;
    min-width: 0;
}

.crm-paziente-card-nome {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1a1f2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crm-paziente-card-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: #6b7490;
    margin-top: 0.2rem;
}

.crm-meta-sep {
    opacity: .4;
}

.crm-paziente-card-cf {
    font-family: monospace;
    font-size: 0.72rem;
    color: #9ca3af;
    margin-top: 0.15rem;
    letter-spacing: .04em;
}

.crm-paziente-card-arrow {
    width: 16px;
    height: 16px;
    stroke: #d1d5db;
    flex-shrink: 0;
    transition: stroke 0.15s;
}

.crm-paziente-card:hover .crm-paziente-card-arrow {
    stroke: #1b6ec2;
}

/* ── Paginazione ──────────────────────────────────────────────── */
.crm-paginazione {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin: 0.5rem 0 1.5rem;
}

.crm-pag-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border: 1.5px solid #e8ecf4;
    border-radius: 8px;
    background: #fff;
    color: #374151;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}

    .crm-pag-btn:hover:not(:disabled) {
        background: #f0f6ff;
        border-color: #1b6ec2;
        color: #1b6ec2;
    }

.crm-pag-btn--active {
    background: #052767;
    border-color: #052767;
    color: #fff;
}

.crm-pag-btn:disabled {
    opacity: .35;
    cursor: default;
}

.crm-pag-info {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-left: 0.5rem;
}

/* ══════════════════════════════════════════════════════════════
   CRM — DETTAGLIO PAZIENTE
   ══════════════════════════════════════════════════════════════ */

/* ── Hero header ──────────────────────────────────────────────── */
.crm-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: none;
    color: #6b7490;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-bottom: 0.8rem;
    transition: color 0.12s;
}

    .crm-back-btn:hover {
        color: #052767;
    }

.crm-detail-hero {
    margin-bottom: 1.2rem;
}

.crm-hero-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.crm-hero-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #052767, #3a0647);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.crm-hero-nome {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1a1f2e;
    margin: 0;
    line-height: 1.2;
}

.crm-hero-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.crm-hero-tag {
    font-size: 0.78rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #374151;
    border-radius: 20px;
    padding: 0.15rem 0.6rem;
}

.crm-hero-tag--cf {
    font-family: monospace;
    background: #ede9fe;
    color: #7c3aed;
    letter-spacing: .04em;
}

/* ── Layout due colonne ───────────────────────────────────────── */
.crm-detail-cols {
    display: grid;
    /* SOSTITUISCI 1fr CON minmax(0, 1fr) */
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

/* Aggiungi questa classe per blindare la colonna di destra */
.crm-detail-col-right {
    min-width: 0;
}

@media (max-width: 900px) {
    .crm-detail-cols {
        /* SOSTITUISCI 1fr CON minmax(0, 1fr) ANCHE QUI */
        grid-template-columns: minmax(0, 1fr);
    }

    .crm-card-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Section card ─────────────────────────────────────────────── */
.crm-section-card {
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 12px;
    padding: 1rem 1.1rem;
    margin-bottom: 0.8rem;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.crm-section-card-title {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crm-count-badge {
    font-size: 0.7rem;
    background: #f1f5f9;
    color: #374151;
    border-radius: 10px;
    padding: 0.1rem 0.45rem;
}

.crm-section-card--comunicazioni {
    margin-bottom: 0;
}

/* ── Contatti nel dettaglio ───────────────────────────────────── */
.crm-contatto-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
}

    .crm-contatto-item:last-child {
        border-bottom: none;
    }

.crm-contatto-icona {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.crm-contatto-body {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    flex: 1;
    min-width: 0;
}

.crm-contatto-tipo {
    font-size: 0.7rem;
    color: #9ca3af;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-contatto-valore {
    font-size: 0.9rem;
    color: #052767;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .crm-contatto-valore:hover {
        text-decoration: underline;
    }

/* ── Relazioni nel dettaglio ──────────────────────────────────── */
.crm-relazione-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f3f4f6;
}

    .crm-relazione-item:last-of-type {
        border-bottom: none;
    }

/* ── Prenotazioni nel dettaglio ───────────────────────────────── */
.crm-pren-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 280px;
    overflow-y: auto;
}

.crm-pren-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem 0.8rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.88rem;
}

    .crm-pren-item:last-child {
        border-bottom: none;
    }

.crm-pren-data {
    display: flex;
    align-items: baseline;
}

.crm-pren-motivo {
    flex: 1;
    min-width: 100px;
    color: #6b7490;
}

/* ── Edit panel ───────────────────────────────────────────────── */
.crm-edit-panel {
    background: #f7f9fd;
    border: 1px solid #e8ecf4;
    border-radius: 12px;
    padding: 1.2rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .crm-hero-avatar {
        width: 48px;
        height: 48px;
        font-size: 1rem;
    }

    .crm-hero-nome {
        font-size: 1.1rem;
    }
}

/* Dropdown suggerimenti */
.crm-ac-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    z-index: 2000;
    background: #fff;
    border: 1.5px solid #e8ecf4;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(5,39,103,0.12);
    overflow: hidden;
    max-height: 220px;
    overflow-y: auto;
}

.crm-ac-item {
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

    .crm-ac-item:last-child {
        border-bottom: none;
    }

    .crm-ac-item:hover {
        background: #f0f6ff;
    }

.crm-ac-item-nome {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1a1f2e;
}

.crm-ac-item-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: #6b7490;
    margin-top: 0.1rem;
}

.crm-ac-item-sep {
    opacity: .4;
}

/* ══════════════════════════════════════════════════════════════
   CONFIGURAZIONE SLOT
   ══════════════════════════════════════════════════════════════ */

/* ── Tab ─────────────────────────────────────────────────────── */
.cfg-tabs {
    display: flex;
    gap: 0.3rem;
    border-bottom: 2px solid #e8ecf4;
    margin-bottom: 1.2rem;
}

.cfg-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.55rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7490;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    border-radius: 6px 6px 0 0;
}

    .cfg-tab:hover {
        color: #374151;
    }

.cfg-tab--active {
    color: #052767;
    border-bottom-color: #052767;
}

/* ── Section ─────────────────────────────────────────────────── */
.cfg-section {
}

.cfg-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
    margin-bottom: 0.8rem;
}

/* ── Form card ───────────────────────────────────────────────── */
.cfg-form-card {
    background: #f7f9fd;
    border: 1px solid #e8ecf4;
    border-radius: 12px;
    padding: 1.1rem;
    margin-bottom: 1rem;
}

/* ── Anteprima slot ──────────────────────────────────────────── */
.cfg-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.7rem;
    padding: 0.6rem 0.8rem;
    background: #eff6ff;
    border-radius: 8px;
    font-size: 0.8rem;
}

.cfg-preview-label {
    font-weight: 700;
    color: #1d4ed8;
    margin-right: 0.3rem;
}

.cfg-preview-slot {
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 6px;
    padding: 0.1rem 0.45rem;
    font-family: monospace;
    font-size: 0.78rem;
}

/* ── Day group ───────────────────────────────────────────────── */
.cfg-day-group {
    margin-bottom: 1rem;
}

.cfg-day-title {
    font-size: 0.82rem;
    font-weight: 800;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.4rem;
    padding-left: 0.2rem;
}

/* ── Fascia row ──────────────────────────────────────────────── */
.cfg-fascia-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    padding: 0.65rem 0.9rem;
    margin-bottom: 0.35rem;
    transition: opacity 0.12s;
}

.cfg-fascia-row--disattiva {
    opacity: .5;
}

.cfg-fascia-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.cfg-fascia-actions {
    display: flex;
    gap: 0.4rem;
}

.cfg-badge-tipo {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
}

.cfg-badge-tipo--pubblico {
    background: #dcfce7;
    color: #166534;
}

.cfg-badge-tipo--staff {
    background: #ede9fe;
    color: #7c3aed;
}

.cfg-from-badge {
    font-size: 0.75rem;
    color: #9ca3af;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 0.1rem 0.5rem;
}

/* ── Festività grid ──────────────────────────────────────────── */
.cfg-festivita-grid {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

.cfg-festivita-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    font-size: 0.88rem;
}

.cfg-festivita-item--past {
    opacity: .55;
}

.cfg-festivita-item--fixed {
    background: #f8fafc;
}

.cfg-festivita-data {
    font-weight: 700;
    min-width: 110px;
    flex-shrink: 0;
}

.cfg-festivita-desc {
    flex: 1;
    color: #374151;
}

.cfg-badge-fixed {
    font-size: 0.68rem;
    font-weight: 700;
    background: #f1f5f9;
    color: #9ca3af;
    border-radius: 8px;
    padding: 0.1rem 0.45rem;
}

/* ── Motivi visita (tab configurazione) ─────────────────────── */
.cfg-motivi-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
}

.cfg-motivo-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: #fff;
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
    transition: opacity 0.12s;
}

.cfg-motivo-ordine {
    font-size: 0.72rem;
    font-weight: 800;
    color: #9ca3af;
    min-width: 28px;
    text-align: right;
    flex-shrink: 0;
}

.cfg-motivo-testo {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: #1a1f2e;
}

.cfg-motivi-note {
    font-size: 0.78rem;
    color: #9ca3af;
    padding: 0.5rem 0.2rem;
}

/* Container per centrare su PC e allargare su Mobile */
.cfg-segmented-wrapper {
    display: flex;
    justify-content: flex-start; /* Allinea a sinistra su PC */
}

.segmented-control {
    display: flex;
    background-color: #f1f3f5; /* Grigio chiarissimo di fondo */
    padding: 4px;
    border-radius: 12px;
    width: 100%; /* Default mobile: tutta larghezza */
    max-width: 500px; /* Su PC: non oltre i 500px per non sformarsi */
    border: 1px solid #e9ecef;
}

    .segmented-control button {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border: none;
        background: transparent;
        padding: 10px 12px;
        font-size: 0.88rem;
        font-weight: 500;
        color: #6c757d;
        border-radius: 9px;
        transition: all 0.2s ease-in-out;
        white-space: nowrap;
    }

        /* Stato Attivo (l'effetto "pillola" bianca che si solleva) */
        .segmented-control button.active {
            background-color: white;
            color: #0d6efd; /* Colore primary */
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
        }

        .segmented-control button i {
            font-size: 1rem;
        }

/* Adattamenti per Mobile Stretto */
@media (max-width: 400px) {
    .segmented-control button {
        font-size: 0.8rem;
        padding: 8px 4px;
        gap: 4px;
    }

        .segmented-control button i {
            font-size: 0.9rem;
        }
}
/* Container per il posizionamento del FAB */
.cfg-mobile-fab-container {
    position: fixed;
    bottom: calc(var(--bo-tabbar-height, 60px) + 20px); /* Sopra la tabbar esistente + margine */
    right: 20px;
    z-index: 1000;
}

/* Stile del FAB */
.cfg-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #0d6efd; /* Colore primary */
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.35); /* Shadow colorata e diffusa */
    transition: all 0.3s ease-in-out;
    border: none;
    padding: 0;
}

    .cfg-fab:hover, .cfg-fab:focus {
        background-color: #0056b3; /* Primary più scuro */
        color: white;
        box-shadow: 0 8px 24px rgba(13, 110, 253, 0.45);
        transform: translateY(-2px);
    }

    /* Stato attivo/X quando il form è aperto */
    .cfg-fab.active {
        background-color: #6c757d; /* Grigio per chiudere */
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transform: rotate(0deg); /* Se vuoi ruotare la X */
    }

        .cfg-fab.active:hover {
            background-color: #5a6268;
        }

    /* Icona dentro il FAB */
    .cfg-fab i {
        line-height: 1;
    }

/* --- GESTIONE PC (Nascondi FAB, Mostra nell'Header) --- */
@media (min-width: 992px) {
    /* Nascondi il FAB su PC */
    .cfg-mobile-fab-container {
        display: none;
    }

    /* Su PC rimettiamo il pulsante nell'header della card. 
       Dovrai ripristinare il markup nell'header della card (come nella versione precedente) 
       ma avvolgerlo in una classe d-none d-lg-block. 
       Ecco il CSS per far funzionare l'header della card con il pulsante ripristinato solo su PC. */
    .card-header .btn-primary.d-lg-block {
        display: block !important;
    }
}

/* ══════════════════════════════════════════════════════════════
   ANALISI AI
   ══════════════════════════════════════════════════════════════ */

/* ── Bottone trigger ─────────────────────────────────────────── */
.ai-analizza-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-color: #c4b5fd;
    color: #7c3aed;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

    .ai-analizza-btn:hover:not(:disabled) {
        background: #f5f3ff;
        border-color: #7c3aed;
        color: #6d28d9;
    }

    .ai-analizza-btn:disabled {
        opacity: .4;
        cursor: default;
    }

.ai-analizza-icon {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

/* ── Modale AI ───────────────────────────────────────────────── */
.ai-overlay {
    z-index: 1100;
}

.ai-modal {
    width: 95%;
    max-width: 650px;
    max-height: 90vh; /* Altezza massima 90% della finestra */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.ai-risultato-scroll-area {
    overflow-y: auto;
    flex-grow: 1; /* Prende lo spazio disponibile */
    margin: 1rem 0;
    padding: 1rem;
    /*background-color: #f8f9fa;  Grigio molto chiaro per staccare dal fondo bianco */
    border-radius: 8px;
}

.ai-modal-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.ai-modal-icon {
    width: 18px;
    height: 18px;
    stroke: #7c3aed;
    flex-shrink: 0;
}

.ai-provider-badge {
    font-size: 0.7rem;
    font-weight: 700;
    background: #ede9fe;
    color: #7c3aed;
    border-radius: 20px;
    padding: 0.1rem 0.55rem;
    white-space: nowrap;
}

/* ── Loading ──────────────────────────────────────────────────── */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem 1rem;
    text-align: center;
}

.ai-loading-spinner {
    width: 48px;
    height: 48px;
}

.ai-spinner-svg {
    width: 100%;
    height: 100%;
    animation: ai-spin 1.2s linear infinite;
}

    .ai-spinner-svg circle {
        stroke: #7c3aed;
        stroke-dasharray: 80;
        stroke-dashoffset: 60;
        stroke-linecap: round;
    }

@keyframes ai-spin {
    to {
        transform: rotate(360deg);
    }
}

.ai-loading-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

    .ai-loading-text span {
        font-weight: 600;
        color: #374151;
    }

.ai-loading-sub {
    font-size: 0.82rem;
    color: #9ca3af;
    font-weight: 400;
}

/* ── Errore ───────────────────────────────────────────────────── */
.ai-errore {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.ai-errore-icon {
    width: 22px;
    height: 22px;
    stroke: #dc2626;
    flex-shrink: 0;
    margin-top: 2px;
}

.ai-errore-titolo {
    font-weight: 700;
    color: #991b1b;
    margin-bottom: 0.25rem;
}

.ai-errore-msg {
    font-size: 0.88rem;
    color: #7f1d1d;
}

/* ── Risultato ────────────────────────────────────────────────── */
.ai-risultato {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fafafa;
    border: 1px solid #e8ecf4;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 0.8rem;
}

.ai-risultato-testo {
    line-height: 1.6; /* Aumenta l'interlinea per far respirare il testo */
    font-size: 0.9rem;
    color: #343a40;
    text-align: left;
}

    .ai-risultato-testo h1, div.crm-comunicazione-testo h1 {
        font-size: 1.7rem;
    }

    .ai-risultato-testo h2, div.crm-comunicazione-testo h2 {
        font-size: 1.4rem;
    }

    .ai-risultato-testo h3, div.crm-comunicazione-testo h3 {
        font-size: 1.2rem;
    }

    .ai-risultato-testo h4, div.crm-comunicazione-testo h4 {
        font-size: 1.0rem;
    }

    .ai-risultato-testo p,, div.crm-comunicazione-testo p {
        font-size: 0.8rem;
    }

.ai-meta {
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap; /* Su mobile va a capo se serve */
}

.ai-meta-sep {
    opacity: .4;
}

.ai-saved-badge {
    font-size: 0.72rem;
    font-weight: 700;
    background: #dcfce7;
    color: #166534;
    border-radius: 10px;
    padding: 0.1rem 0.5rem;
}

/* ── Intro ────────────────────────────────────────────────────── */
.ai-intro {
    margin-bottom: 1rem;
    font-size: 0.92rem;
    color: #374151;
}

.ai-intro-note {
    font-size: 0.8rem;
    color: #9ca3af;
    border-left: 3px solid #e8ecf4;
    padding-left: 0.7rem;
    margin-top: 0.5rem;
}

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ai-modal {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }

    .ai-risultato {
        max-height: 50vh;
    }
}

/* ══════════════════════════════════════════════════════════════
   ALLEGATI UNIFICATI — UI REFRESH
   ══════════════════════════════════════════════════════════════ */

.crm-section-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #edf2f7;
    /* CRITICO: senza questo il testo sborda su mobile */
    overflow-x: hidden;
    min-width: 0;
    box-sizing: border-box;
}

.crm-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}

/* --- Badge & Bottoni Header --- */
.crm-count-badge {
    background: #f1f5f9;
    color: #64748b;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-action-pill {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    transition: all 0.2s;
}

    .btn-action-pill:hover {
        background: #f1f5f9;
        border-color: #cbd5e1;
    }

.btn-action-pill--danger:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* --- Contenitore allegati --- */
.crm-allegati-container {
    min-width: 0;
    overflow-x: hidden;
    width: 100%;
}

/* --- Chips Filtri --- */
.crm-filter-scroll-wrapper {
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.crm-allegati-filtro {
    display: flex;
    flex-wrap: nowrap; /* Obbliga i filtri su una sola riga */
    overflow-x: auto; /* Attiva lo scorrimento orizzontale */
    overflow-y: hidden; /* Evita scroll verticale parassita */
    gap: 10px;
    padding: 5px 2px 10px 2px; /* Padding inferiore per non tagliare l'ombra del tasto attivo */
    width: 100%;
    scrollbar-width: none; /* Nasconde la barra su Firefox */
    -ms-overflow-style: none; /* Nasconde la barra su IE/Edge */
    -webkit-overflow-scrolling: touch; /* Rende lo scroll fluido su iOS */
}

    /* Nasconde la barra dello scroll su Chrome, Safari e Opera */
    .crm-allegati-filtro::-webkit-scrollbar {
        display: none;
    }

.crm-chip {
    white-space: nowrap;
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 30px;
    padding: 5px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s;
}

    .crm-chip.active {
        background: #4f46e5;
        border-color: #4f46e5;
        color: #ffffff;
        box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
    }

.chip-count {
    margin-left: 6px;
    font-size: 0.7rem;
    opacity: 0.8;
}

/* --- File Row Layout --- */
.crm-list-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.crm-file-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    background: #fdfdfd;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    transition: transform 0.1s, box-shadow 0.1s;
    min-width: 0;
    width: 100%;
    max-width: 100%; /* Impedisce alla riga di allargarsi */
    overflow: hidden; /* Taglia tutto ciò che esce */
    box-sizing: border-box;
}

    .crm-file-row:hover {
        border-color: #e2e8f0;
        background: #ffffff;
        box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    }

/* Icone tipizzate */
.crm-file-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    margin-right: 14px;
    flex-shrink: 0;
}

    .crm-file-icon-box.pdf {
        background: #fef2f2;
        color: #dc2626;
        border: 1px solid #fee2e2;
    }

    .crm-file-icon-box.img {
        background: #f0fdf4;
        color: #16a34a;
        border: 1px solid #dcfce7;
    }

    .crm-file-icon-box.doc {
        background: #eff6ff;
        color: #2563eb;
        border: 1px solid #dbeafe;
    }

.crm-file-info {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.crm-file-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 100%;
    width: 100%; /* Occupa tutto lo spazio del padre */
}

.crm-file-meta {
    font-size: 0.72rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.meta-tag {
    background: #f1f5f9;
    color: #475569;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.crm-file-notes {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #64748b;
    font-style: italic;
    margin-top: 4px;
}

/* --- Azioni --- */
.crm-file-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    margin-left: 10px;
}

.btn-circle-action {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f8fafc;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
}

    .btn-circle-action:hover {
        background: #e2e8f0;
        color: #1e293b;
    }

.btn-circle-action--danger:hover {
    background: #fee2e2;
    color: #dc2626;
}

.btn-restore {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Mobile Adjustments */
@media (max-width: 576px) {
    .crm-file-meta span:nth-child(n+3) {
        display: none;
    }
    /* Nasconde data e tag su schermi mini */
    .crm-file-actions {
        flex-direction: row;
    }
}

/* ── Bottone AI paziente ──────────────────────────────────────── */
.ai-analizza-btn-paziente {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    transition: opacity 0.12s, transform 0.1s;
    white-space: nowrap;
}

    .ai-analizza-btn-paziente:hover:not(:disabled) {
        opacity: .9;
        transform: translateY(-1px);
    }

    .ai-analizza-btn-paziente:disabled {
        opacity: .4;
        cursor: default;
    }

/* ── Bottone allega ───────────────────────────────────────────── */
.btn-action-pill--primary {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

    .btn-action-pill--primary:hover {
        background: #dbeafe;
    }

/* ── Upload preview ───────────────────────────────────────────── */
.crm-upload-preview {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
}

.crm-upload-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    flex-wrap: wrap;
}

.crm-upload-file-name {
    font-weight: 600;
    color: #374151;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   AI CHAT — modale con conversazione multi-turn
   ══════════════════════════════════════════════════════════════ */

/* ── Modale: più alta per la chat ───────────────────────────── */
.ai-modal {
    max-width: 620px;
    width: calc(100vw - 2rem);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* lo scroll è solo dentro ai-chat-history */
}

/* ── Badge turni ─────────────────────────────────────────────── */
.ai-chat-turns-badge {
    font-size: 0.68rem;
    font-weight: 700;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 20px;
    padding: 0.1rem 0.5rem;
}

/* ── Storico conversazione ───────────────────────────────────── */
.ai-chat-history {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0.5rem 0.2rem;
    scroll-behavior: smooth;
    min-height: 120px;
}

/* ── Bolle ───────────────────────────────────────────────────── */
.ai-chat-bubble {
    display: flex;
    max-width: 92%;
}

.ai-chat-bubble--model {
    align-self: flex-start;
}

.ai-chat-bubble--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chat-bubble-body {
    padding: 0.65rem 0.9rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.65;
    word-break: break-word;
}

.ai-chat-bubble--model .ai-chat-bubble-body {
    background: #f1f5f9;
    color: #1a1f2e;
    border-bottom-left-radius: 4px;
}

.ai-chat-bubble--user .ai-chat-bubble-body {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────── */
.ai-chat-bubble--typing .ai-chat-bubble-body {
    padding: 0.7rem 1rem;
}

.ai-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 18px;
}

    .ai-typing-dots span {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #94a3b8;
        animation: ai-bounce 1.2s infinite ease-in-out;
    }

        .ai-typing-dots span:nth-child(1) {
            animation-delay: 0s;
        }

        .ai-typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .ai-typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes ai-bounce {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: .5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ── Errore inline ───────────────────────────────────────────── */
.ai-errore--inline {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    margin: 0.4rem 0;
}

    .ai-errore--inline .ai-errore-msg {
        font-size: 0.83rem;
        color: #7f1d1d;
    }

/* ── Input chat ──────────────────────────────────────────────── */
.ai-chat-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #e8ecf4;
}

.ai-chat-input {
    flex: 1;
    resize: none;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #1a1f2e;
    background: #fff;
    transition: border-color 0.12s;
    font-family: inherit;
    min-height: 44px;
    max-height: 120px;
    overflow-y: auto;
}

    .ai-chat-input:focus {
        outline: none;
        border-color: #7c3aed;
        box-shadow: 0 0 0 3px rgba(124,58,237,.12);
    }

    .ai-chat-input:disabled {
        background: #f8fafc;
    }

.ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.12s, transform 0.1s;
    color: #fff;
}

    .ai-chat-send:hover:not(:disabled) {
        opacity: .9;
        transform: scale(1.05);
    }

    .ai-chat-send:disabled {
        opacity: .4;
        cursor: default;
    }

/* ── Suggerimenti rapidi ─────────────────────────────────────── */
.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.ai-chat-suggestion-chip {
    background: #f5f3ff;
    border: 1.5px solid #ddd6fe;
    color: #6d28d9;
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.77rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

    .ai-chat-suggestion-chip:hover {
        background: #ede9fe;
        border-color: #7c3aed;
    }

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ai-modal {
        max-height: 95vh;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }

    .ai-chat-history {
        max-height: 40vh;
    }

    .ai-chat-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: .3rem;
    }

    .ai-chat-suggestion-chip {
        flex-shrink: 0;
    }
}
/* ── Bottone Genera Certificato ──────────────────────────────── */
.ai-analizza-btn-certificato {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    background: linear-gradient(135deg, #0369a1, #0284c7);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    transition: opacity 0.12s, transform 0.1s;
    white-space: nowrap;
}

    .ai-analizza-btn-certificato:hover:not(:disabled) {
        opacity: .9;
        transform: translateY(-1px);
    }

    .ai-analizza-btn-certificato:disabled {
        opacity: .4;
        cursor: default;
    }

/* ── Bottone Salva nella scheda ──────────────────────────────── */
.ai-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 700;
    background: #dcfce7;
    color: #166534;
    border: 1.5px solid #86efac;
    border-radius: 20px;
    padding: 0.15rem 0.6rem;
    cursor: pointer;
    transition: background 0.1s;
}

    .ai-save-btn:hover:not(:disabled) {
        background: #bbf7d0;
    }

    .ai-save-btn:disabled {
        opacity: .5;
        cursor: default;
    }
/* ══════════════════════════════════════════════════════════════
   ANTEPRIMA IMMAGINE — modale fullscreen
   ══════════════════════════════════════════════════════════════ */

.img-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000; /* sopra tutto, incluse altre modali */
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: img-preview-fadein 0.15s ease;
    cursor: zoom-out;
    outline: none; /* per il tabindex */
}

@keyframes img-preview-fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Toolbar in alto */
.img-preview-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
    z-index: 9001;
    gap: 1rem;
}

.img-preview-nome {
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 120px);
}

.img-preview-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.12s;
    flex-shrink: 0;
}

    .img-preview-btn:hover {
        background: rgba(255,255,255,0.28);
    }

.img-preview-btn--close {
    background: rgba(220,38,38,0.5);
}

    .img-preview-btn--close:hover {
        background: rgba(220,38,38,0.8);
    }

/* Area immagine — scrollabile se più grande dello schermo */
.img-preview-body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 56px 16px 36px; /* spazio toolbar + hint */
    box-sizing: border-box;
    cursor: default; /* dentro l'immagine non mostra zoom-out */
    overflow: auto;
}

.img-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    animation: img-preview-scalein 0.15s ease;
    user-select: none;
}

@keyframes img-preview-scalein {
    from {
        transform: scale(0.94);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Hint in basso */
.img-preview-hint {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0.6rem;
    font-size: 0.72rem;
    color: rgba(255,255,255,0.4);
    background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
    pointer-events: none;
}

/* Bottone occhio nella card documento */
.btn-circle-action--preview {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

    .btn-circle-action--preview:hover {
        background: #dbeafe;
        border-color: #93c5fd;
    }

@media (max-width: 768px) {
    .img-preview-img {
        border-radius: 0;
    }

    .img-preview-body {
        padding: 52px 0 32px;
    }
}

/* ── ATTIVITÀ: LAYOUT E FILTRI ───────────────────────────────── */
.att-filtri {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
}

.att-filtri-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Chip per i filtri (stile moderno, arrotondato) */
.crm-allegati-chip {
    background: #f1f5f9;
    border: 1px solid transparent;
    color: #64748b;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .crm-allegati-chip:hover {
        background: #e2e8f0;
        color: #0f172a;
    }

.crm-allegati-chip--active {
    background: #0f172a;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.att-chiuse-toggle {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin-left: auto; /* Spinge il toggle a destra */
}

/* ── ATTIVITÀ: CARD ──────────────────────────────────────────── */
.att-lista {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.att-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}

    .att-card:hover {
        border-color: #cbd5e1;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        transform: translateY(-2px);
        transition: all 0.2s ease;
    }

    /* Accenti di stato (bordo sinistro elegante) */
    .att-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 4px;
        background: transparent;
    }

.att-card--scaduta::before {
    background: #ef4444;
}

.att-card--in-scadenza::before {
    background: #f59e0b;
}

.att-card--chiusa {
    opacity: 0.75;
    background: #f8fafc;
    box-shadow: none;
}

    .att-card--chiusa::before {
        background: #94a3b8;
    }

/* Header Card */
.att-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.att-paziente-link {
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
}

    .att-paziente-link:hover {
        color: #2563eb;
    }

.att-tel {
    display: block;
    font-size: 0.85rem;
    color: #64748b;
    text-decoration: none;
    margin-top: 0.25rem;
}

/* Badge Categoria e Scadenza */
.att-card-meta {
    display: flex;
    flex-direction: row; /* Allinea i badge uno a fianco all'altro */
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.att-categoria-badge {
    background: #f1f5f9; /* Grigio molto più neutro e tenue */
    color: #475569;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    border: 1px solid #e2e8f0;
}

.att-scadenza {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

.att-scadenza--warn {
    color: #d97706;
}

.att-scadenza--late {
    color: #dc2626;
    font-weight: 600;
}

/* Nota (Corpo della card) */
.att-card-nota {
    font-size: 0.95rem;
    color: #1e293b; /* Testo leggermente più scuro per leggibilità */
    line-height: 1.5;
    padding: 0; /* Rimosso il padding interno */
    background: transparent; /* Rimosso lo sfondo grigio! */
    border: none; /* Rimosso il bordo */
    margin-top: 0.2rem;
    margin-bottom: 0.5rem;
}

/* Footer Card (Azioni e Stato) */
.att-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end; /* Allinea in basso */
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px dotted #e2e8f0; /* Linea tratteggiata più leggera */
}

.att-stato-select-wrap {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 1px solid transparent; /* Rimosso il bordo evidente */
    border-radius: 6px;
    padding: 2px 4px 2px 0;
    transition: all 0.2s;
}

    .att-stato-select-wrap:hover {
        background: #f8fafc;
        border-color: #e2e8f0;
    }

.att-stato-select {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    outline: none;
    padding-left: 6px;
    appearance: none; /* Rimuove la freccina standard su alcuni browser se vuoi super pulizia */
}

.att-stato-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.att-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Scadenza inline editabile */
.att-scadenza-btn {
    display: inline-flex;
    align-items: center;
    background: none;
    border: 1px dashed transparent;
    border-radius: 4px;
    padding: .1rem .35rem;
    cursor: pointer;
    font-size: .8rem;
    transition: border-color .15s;
}

    .att-scadenza-btn:hover {
        border-color: #c4c9d8;
    }

    .att-scadenza-btn.att-scadenza--late {
        color: #b91c1c;
    }

    .att-scadenza-btn.att-scadenza--warn {
        color: #92400e;
    }

.att-scadenza-placeholder {
    color: #9ca3af;
    font-style: italic;
}

.att-scadenza-input {
    width: 140px;
    display: inline-block;
    padding: .1rem .3rem;
    font-size: .8rem !important;
}

/* Filtri categorie (riga secondaria) */
.att-filtri--categorie {
    margin-top: -.25rem;
    margin-bottom: .5rem;
}

/* Container del toggle */
.att-chiuse-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #64748b;
    user-select: none;
}

    /* Nascondiamo il checkbox originale */
    .att-chiuse-toggle input {
        display: none;
    }

/* Lo "switch" (lo sfondo dell'interruttore) */
.switch-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #e2e8f0; /* Grigio spento */
    border-radius: 20px;
    transition: all 0.3s ease;
}

    /* Il "pallino" dello switch */
    .switch-slider:before {
        content: "";
        position: absolute;
        height: 14px;
        width: 14px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        border-radius: 50%;
        transition: all 0.3s ease;
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

/* Stato quando è selezionato (Checked) */
.att-chiuse-toggle input:checked + .switch-slider {
    background-color: #2563eb; /* Blu moderno (o il tuo colore primario) */
}

    .att-chiuse-toggle input:checked + .switch-slider:before {
        transform: translateX(16px);
    }

/* Hover per feedback */
.att-chiuse-toggle:hover .switch-slider {
    background-color: #cbd5e1;
}

.att-chiuse-toggle input:checked:hover + .switch-slider {
    background-color: #1d4ed8;
}

/* Attività card dentro anagrafica — stile coerente con section-card */
.crm-section-card--attivita .crm-section-card-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .4rem;
}

.att-lista-inline {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: .5rem;
}

.att-card--compact {
    background: #f8f9fc;
    border: 1px solid #e8ebf4;
    border-radius: 8px;
    padding: .65rem .9rem;
}

    .att-card--compact .att-card-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: .5rem;
        flex-wrap: wrap;
    }

    .att-card--compact .att-card-header {
        display: flex;
        align-items: center;
        gap: .4rem;
        flex-wrap: wrap;
    }

    .att-card--compact .att-card-nota {
        margin-top: .4rem;
        font-size: .875rem;
        color: #374151;
    }

    .att-card--compact .att-card-footer {
        margin-top: .35rem;
        font-size: .72rem;
        color: #8892a4;
    }

.att-card--scaduta {
    border-left: 3px solid #ef4444;
}

.att-card--in-scadenza {
    border-left: 3px solid #f59e0b;
}

.att-card--chiusa {
    opacity: .6;
}

.att-chiusa-badge {
    font-size: .7rem;
    background: #e5e7eb;
    color: #6b7280;
    border-radius: 4px;
    padding: 0 .35rem;
}

/* Form inline attività */
.att-form-card--inline {
    background: #f1f3fa;
    border: 1px solid #dde2f0;
    border-radius: 8px;
    padding: .85rem 1rem;
    margin: .6rem 0;
}
/* ── 1. BARRA FILTRI E TOGGLE ───────────────────────────────── */
.bo-filters-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    background: #ffffff;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid #eef2f6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.bo-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Chip per gli stati */
.crm-allegati-chip {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .crm-allegati-chip:hover {
        background: #f1f5f9;
        color: #0f172a;
    }

.crm-allegati-chip--active {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

/* Toggle Switch Elegante */
.bo-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    user-select: none;
    margin-left: auto; /* Lo spinge a destra */
}

    .bo-toggle input {
        display: none;
    }

.bo-toggle-slider {
    width: 36px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 20px;
    position: relative;
    transition: 0.3s;
}

    .bo-toggle-slider:before {
        content: "";
        position: absolute;
        width: 16px;
        height: 16px;
        left: 2px;
        bottom: 2px;
        background: white;
        border-radius: 50%;
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }

.bo-toggle input:checked + .bo-toggle-slider {
    background: #2563eb;
}

    .bo-toggle input:checked + .bo-toggle-slider:before {
        transform: translateX(16px);
    }

/* ── 2. CARDS DELLE ATTIVITÀ ────────────────────────────────── */
.att-lista {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.att-card {
    background: #ffffff;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem; /* Spaziatura ottimizzata */
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.03), 0 2px 4px -1px rgba(0,0,0,0.02);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

    .att-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
        border-color: #cbd5e1;
    }

    /* Accenti laterali per scadenze */
    .att-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 4px;
        background: transparent;
    }

.att-card--scaduta::before {
    background: #ef4444;
}

.att-card--in-scadenza::before {
    background: #f59e0b;
}

.att-card--chiusa {
    opacity: 0.75;
    box-shadow: none;
}

    .att-card--chiusa::before {
        background: #cbd5e1;
    }

/* Header Card */
.att-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.att-paziente-link {
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
}

.att-tel {
    display: block;
    font-size: 0.82rem;
    color: #64748b;
    text-decoration: none;
    margin-top: 0.2rem;
}

/* Meta Data (Badge e Data allineati orizzontalmente) */
.att-card-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.att-categoria-badge {
    background: #f1f5f9;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    border: 1px solid #e2e8f0;
}

.att-scadenza {
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

.att-scadenza--warn {
    color: #d97706;
}

.att-scadenza--late {
    color: #dc2626;
    font-weight: 600;
}

/* Corpo della Nota */
.att-card-nota {
    font-size: 0.95rem;
    color: #1e293b;
    line-height: 1.5;
    padding: 0;
    background: transparent;
    border: none;
    margin-top: 0.2rem;
    margin-bottom: 0.5rem;
}

/* Footer Card */
.att-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px dotted #e2e8f0;
}

.att-stato-select-wrap {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 2px 4px 2px 0;
    transition: all 0.2s;
}

    .att-stato-select-wrap:hover {
        background: #f8fafc;
        border-color: #e2e8f0;
    }

.att-stato-select {
    border: none;
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    outline: none;
    padding-left: 6px;
    appearance: none;
}
/* ── ATT-CARD ──────────────────────────────────────────────── */
.att-card {
    background: #fff;
    border: 1px solid #e8ebf4;
    border-radius: 10px;
    padding: 1rem 1.1rem .85rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.att-card--scaduta {
    border-left: 3px solid #ef4444;
}

.att-card--in-scadenza {
    border-left: 3px solid #f59e0b;
}

.att-card--chiusa {
    opacity: .55;
}

/* Riga 1: nome (sx) + categoria/scadenza (dx) */
.att-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.att-card-soggetto {
    flex: 1;
    min-width: 0;
}

.att-paziente-nome {
    font-weight: 700;
    font-size: .95rem;
    color: #1a1f36;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

a.att-paziente-nome:hover {
    color: #4f46e5;
    text-decoration: underline;
}

.att-card-top-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

/* Categoria badge */
.att-categoria-badge {
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    border: 1px solid #c4c9d8;
    color: #6b7490;
    border-radius: 4px;
    padding: .15rem .45rem;
    white-space: nowrap;
}

/* Scadenza */
.att-scadenza-btn {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    padding: .1rem .2rem;
    cursor: pointer;
    font-size: .82rem;
    color: #6b7490;
    border-radius: 4px;
    transition: background .15s;
    white-space: nowrap;
}

    .att-scadenza-btn:hover {
        background: #f1f3fa;
    }

    .att-scadenza-btn.att-scadenza--late {
        color: #b91c1c;
    }

    .att-scadenza-btn.att-scadenza--warn {
        color: #92400e;
    }

.att-scadenza-placeholder {
    font-style: italic;
    color: #9ca3af;
}

.att-scadenza-input {
    width: 130px;
    font-size: .8rem;
    padding: .15rem .4rem;
}

/* Chiusa badge */
.att-chiusa-badge {
    font-size: .7rem;
    background: #e5e7eb;
    color: #6b7280;
    border-radius: 4px;
    padding: .1rem .4rem;
}

/* Nota */
.att-card-nota {
    font-size: .88rem;
    color: #374151;
    line-height: 1.5;
}

/* Separatore */
.att-card-divider {
    height: 1px;
    background: #eef0f6;
    margin: .1rem 0;
}

/* Footer */
.att-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.att-stato-select-wrap {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.att-stato-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}

.att-stato-select {
    border: none;
    background: none;
    font-size: .82rem;
    color: #374151;
    font-weight: 500;
    padding: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

    .att-stato-select:focus {
        outline: none;
    }

.att-card-footer-right {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.att-card-data {
    font-size: .78rem;
    color: #9ca3af;
}

.att-elimina-btn {
    background: none;
    border: none;
    padding: .2rem .3rem;
    cursor: pointer;
    color: #ef4444;
    border-radius: 4px;
    font-size: .85rem;
    line-height: 1;
    transition: background .15s;
}

    .att-elimina-btn:hover {
        background: #fee2e2;
    }

/* Variante compatta per l'anagrafica */
.att-card--compact {
    padding: .75rem .9rem .65rem;
    gap: .4rem;
}

    .att-card--compact .att-card-nota {
        font-size: .84rem;
    }
/* ── Dropdown stato custom ──────────────────────────────────── */
.att-stato-wrap {
    position: relative;
}

.att-stato-trigger {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: none;
    border: none;
    padding: .2rem .3rem;
    border-radius: 5px;
    cursor: pointer;
    font-size: .82rem;
    font-weight: 500;
    color: #374151;
    transition: background .15s;
}

    .att-stato-trigger:hover {
        background: #f1f3fa;
    }

.att-stato-label {
    line-height: 1;
}

.att-stato-chevron {
    font-size: .65rem;
    color: #9ca3af;
    transition: transform .15s;
}

.att-stato-chevron--open {
    transform: rotate(180deg);
}

.att-stato-dropdown {
    position: absolute;
    bottom: calc(100% + 4px); /* apre verso l'alto */
    left: 0;
    z-index: 200;
    background: #fff;
    border: 1px solid #e0e4ef;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.10);
    padding: .3rem;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.att-stato-option {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    background: none;
    border: none;
    border-radius: 5px;
    padding: .2rem .6rem;
    font-size: .82rem;
    color: #374151;
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}

    .att-stato-option:hover {
        background: #f1f3fa;
    }

.att-stato-option--active {
    background: #eef0fb;
    font-weight: 600;
    color: #1a1f36;
}