/* same theme as before, condensed for brevity */
:root{--bg:#f7f9fc;--panel:#fff;--muted:#7a8492;--text:#0f172a;--brand:#3b82f6;--border:#e5e7eb;--shadow:0 10px 30px rgba(2,6,23,.06);--radius:14px}
*{box-sizing:border-box}body.ui-light{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;color:var(--text);background:var(--bg)}
.sidebar{position:fixed;left:0;top:0;bottom:0;width:240px;background:var(--panel);border-right:1px solid var(--border);padding:18px;box-shadow:var(--shadow)}
.brand{font-weight:700;font-size:20px}.brand span{color:var(--brand)}.sidebar nav{margin-top:14px;display:flex;flex-direction:column;gap:8px}
.sidebar nav a{padding:10px 12px;border-radius:10px;color:var(--text);text-decoration:none}.sidebar nav a:hover{background:#f1f5f9}
.topbar{position:fixed;left:240px;right:0;top:0;height:64px;background:var(--panel);border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;padding:0 20px;box-shadow:var(--shadow)}
.topbar-user{display:flex;align-items:center;gap:10px;color:var(--muted)}.avatar{width:28px;height:28px;border-radius:50%;background:#e2e8f0;display:inline-flex;align-items:center;justify-content:center;font-weight:700}
.content{margin-left:240px;padding:90px 24px 24px;min-height:calc(100vh - 64px)}.foot{margin-left:240px;color:var(--muted);padding:14px 24px}
.cards-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px}.card{background:var(--panel);border:1px solid var(--border);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow)}
.page-title{margin:0 0 14px 0}.toolbar{display:flex;gap:8px;margin-bottom:12px}.input{padding:10px 12px;border:1px solid var(--border);border-radius:10px;background:#fff;width:320px}
.btn{padding:10px 14px;border-radius:10px;border:1px solid var(--border);background:#fff;cursor:pointer}.btn:hover{border-color:var(--brand)}.btn.primary{background:var(--brand);color:#fff;border-color:#2563eb}
.tag{display:inline-block;padding:4px 8px;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:12px}
.list{display:flex;flex-direction:column;gap:8px}.list-header,.item{display:grid;grid-template-columns:1.2fr 1fr 0.6fr;gap:12px;align-items:center;background:var(--panel);border:1px solid var(--border);padding:10px 12px;border-radius:12px}
.list-header{font-weight:600;color:var(--muted)}
.login-screen{display:grid;place-items:center;min-height:100vh;background:linear-gradient(180deg,#f9fbff 0,#f3f6fc 100%)}
.auth-card{width:360px;background:var(--panel);border:1px solid var(--border);border-radius:16px;padding:22px;box-shadow:var(--shadow)}.auth-brand{text-align:center;font-weight:800;margin-bottom:4px;font-size:22px}.auth-brand span{color:var(--brand)}.auth-card h1{text-align:center;margin:10px 0 18px}
.form{display:flex;flex-direction:column;gap:10px}.form input{padding:10px 12px;border:1px solid var(--border);border-radius:10px}
.alert{margin-top:10px;color:#b91c1c;background:#fee2e2;border:1px solid #fecaca;padding:8px 10px;border-radius:10px;display:block}

.table-leads {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

    .table-leads th, .table-leads td {
        padding: 10px 14px;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }

    .table-leads thead {
        background: #f1f5f9;
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .table-leads tr:hover {
        background: #f9fafb;
    }

    .table-leads .btn.small {
        padding: 6px 8px;
        font-size: 13px;
        border-radius: 8px;
        border: 1px solid var(--border);
    }

        .table-leads .btn.small.danger {
            background: #fee2e2;
            color: #b91c1c;
            border-color: #fecaca;
        }

    .table-leads .empty-row {
        text-align: center;
        color: var(--muted);
        padding: 18px;
    }


/* =========================
   TABELLE GENERICHE (tutte)
   ========================= */

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

    .table th,
    .table td {
        padding: 10px 14px;
        text-align: left;
        border-bottom: 1px solid var(--border);
    }

    .table thead {
        background: #f1f5f9;
        position: sticky;
        top: 0;
        z-index: 2;
    }

    .table tr:hover {
        background: #f9fafb;
    }

    .table .btn.small {
        padding: 6px 8px;
        font-size: 13px;
        border-radius: 8px;
        border: 1px solid var(--border);
    }

        .table .btn.small.danger {
            background: #fee2e2;
            color: #b91c1c;
            border-color: #fecaca;
        }

    .table .empty-row {
        text-align: center;
        color: var(--muted);
        padding: 18px;
    }


.status-badge {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    text-transform: capitalize;
}

.status-new {
    background: #e0f2fe;
    color: #0369a1;
}

.status-contacted {
    background: #fef3c7;
    color: #92400e;
}

.status-qualified {
    background: #dcfce7;
    color: #166534;
}

.status-won {
    background: #d1fae5;
    color: #065f46;
}

.status-lost {
    background: #fee2e2;
    color: #b91c1c;
}

/* === MODALE LEADS === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

    .modal form {
        background: var(--panel);
        padding: 24px;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        max-width: 720px;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .modal label {
        font-weight: 600;
        color: var(--muted);
        font-size: 14px;
    }

    .modal input, .modal textarea, .modal select {
        padding: 8px 10px;
        border: 1px solid var(--border);
        border-radius: 8px;
        width: 100%;
    }

    .modal .toolbar {
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        margin-top: 10px;
    }

.grid2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

#current-attachments {
    margin-top: 6px;
}

    #current-attachments a {
        display: inline-block;
        margin-right: 6px;
        font-size: 13px;
        color: var(--brand);
    }

.readonly-field {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}


.pipeline-section {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.pipeline-history {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.pipeline-note {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
}

    .pipeline-note small {
        color: var(--muted);
        display: block;
        margin-top: 3px;
    }

/* === PIPELINE TIMELINE === */
.pipeline-history {
    position: relative;
    padding-left: 24px;
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

    .pipeline-history::before {
        content: "";
        position: absolute;
        left: 8px;
        top: 0;
        bottom: 0;
        width: 2px;
        background: var(--border);
    }

.pipeline-note {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

    .pipeline-note::before {
        content: "";
        position: absolute;
        left: -17px;
        top: 14px;
        width: 10px;
        height: 10px;
        background: var(--brand);
        border-radius: 50%;
        border: 2px solid #fff;
        box-shadow: 0 0 0 2px var(--border);
    }

    .pipeline-note strong {
        display: block;
        color: var(--brand);
        font-weight: 600;
        margin-bottom: 4px;
    }

    .pipeline-note small {
        display: block;
        margin-top: 6px;
        color: var(--muted);
        font-size: 12px;
    }

#new-pipeline-note {
    width: 100%;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    min-height: 60px;
}

/* === MODALE DIVISA IN DUE COLONNE === */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-content {
    display: grid;
    grid-template-columns: 55% 45%;
    gap: 0;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 95%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: hidden;
}

/* --- COLONNA SINISTRA: DETTAGLI LEAD --- */
.lead-details {
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: #fff;
}

/* --- COLONNA DESTRA: PIPELINE --- */
.lead-pipeline {
    background: #fff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px); /*  colonna alta come lo schermo */
    overflow: hidden; /* impedisce al form di spingere fuori tutto */
}

    .lead-pipeline h3 {
        margin-top: 0;
        margin-bottom: 10px;
    }

.pipeline-history {
    flex-grow: 1;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-right: 6px;
    max-height: unset;
}

.pipeline-note {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}

.pipeline-form {
    background: #fafafa;
    padding: 12px;
    border-radius: 8px;
    box-shadow: inset 0 0 0 1px #e5e7eb;
    flex-shrink: 0; /* impedisce al form di ridursi o sparire */
}


    .pipeline-note strong {
        color: var(--brand);
        display: block;
        margin-bottom: 4px;
    }

    .pipeline-note small {
        color: var(--muted);
        font-size: 12px;
    }

#new-pipeline-note {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 8px;
}

/* Responsive: una colonna sola su schermi piccoli */
@media (max-width: 900px) {
    .modal-content {
        grid-template-columns: 1fr;
    }

    .lead-details {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}


select#status option[value="IN VALUTAZIONE"],
select#status option[value="APPROVATO"],
select#status option[value="BOCCIATO"],
select#status option[value="ATTESA DOCUMENTI"],
select#status option[value="ORDINE"] {
    color: #b91c1c; /* rosso */
    font-weight: 600;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-top {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

    .card h2 {
        margin-bottom: 8px;
    }

.alerts {
    padding: 28px;
}

.alert-title {
    margin-bottom: 20px;
}

.alert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}



.filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.input.small {
    width: 180px;
    padding: 8px 10px;
    font-size: 14px;
}

.pipeline-note.note-operator {
    border-left: 4px solid #007bff; /* blu o colore attuale */
    background: #f8f9fa;
}

.pipeline-note.note-master {
    border-left: 4px solid #dc3545; /* rosso */
    background: #fff5f5;
}


.pipeline-history {
    max-height: 400px; /* puoi regolare a piacere, es. 50vh se vuoi proporzionale */
    overflow-y: auto; /* abilita lo scroll verticale */
    padding-right: 5px; /* evita che la scrollbar sovrapponga il testo */
    scrollbar-width: thin; /* scrollbar pių sottile su Firefox */
}

    .pipeline-history::-webkit-scrollbar {
        width: 6px;
    }

    .pipeline-history::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.2);
        border-radius: 4px;
    }

        .pipeline-history::-webkit-scrollbar-thumb:hover {
            background-color: rgba(0, 0, 0, 0.35);
        }

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
}

.dot-red {
    background-color: #dc3545; /* rosso */
}


.status-insert {
    background: #28a745;
    color: #fff;
}

.status-update {
    background: #ffc107;
    color: #000;
}

.status-delete {
    background: #dc3545;
    color: #fff;
}

.status-error {
    background: #6c757d;
    color: #fff;
}
/* Stile base */
.alert-card {
    border: 2px solid #e5e7eb; /* grigio chiaro */
    border-radius: 10px;
    padding: 14px 18px;
    text-align: center;
    background: #f9fafb;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

    .alert-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .alert-card h3 {
        margin: 0;
        font-size: 15px;
        font-weight: 600;
    }

    .alert-card .count {
        font-size: 22px;
        font-weight: bold;
        margin-top: 4px;
    }

    /* Stato: NUOVO */
    .alert-card.status-nuovo {
        background: #e0f2fe; /* azzurro chiaro */
        border-color: #38bdf8;
    }

        .alert-card.status-nuovo h3 {
            color: #0369a1;
        }

    /* Stato: IN VALUTAZIONE */
    .alert-card.status-in-valutazione {
        background: #fef9c3; /* giallo pastello */
        border-color: #facc15;
    }

        .alert-card.status-in-valutazione h3 {
            color: #854d0e;
        }

    /* Stato: APPROVATO */
    .alert-card.status-approvato {
        background: #dcfce7; /* verde chiaro */
        border-color: #22c55e;
    }

        .alert-card.status-approvato h3 {
            color: #166534;
        }

    /* Stato: BOCCIATO */
    .alert-card.status-bocciato {
        background: #fee2e2; /* rosso chiaro */
        border-color: #ef4444;
    }

        .alert-card.status-bocciato h3 {
            color: #991b1b;
        }

    /* Stato: ATTESA DOCUMENTI */
    .alert-card.status-attesa-documenti {
        background: #fef3c7; /* arancio tenue */
        border-color: #f59e0b;
    }

        .alert-card.status-attesa-documenti h3 {
            color: #92400e;
        }

    /* Stato: ORDINE */
    .alert-card.status-ordine {
        background: #ede9fe; /* viola chiaro */
        border-color: #8b5cf6;
    }

        .alert-card.status-ordine h3 {
            color: #5b21b6;
        }

    /* Stato: DA RICONTATTARE OGGI */
    .alert-card.status-da-ricontattare-oggi {
        background: #cffafe; /* azzurro chiaro brillante */
        border-color: #06b6d4;
    }

        .alert-card.status-da-ricontattare-oggi h3 {
            color: #0e7490;
        }

    /* Quando c'č un alert attivo */
    .alert-card.has-alert {
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
        transform: scale(1.02);
    }


.check-box-modal {
    width: auto!important;
}


#important-notes-box {
    cursor: pointer;
    background: #fff3cd;
    border-left: 4px solid #ffb300;
}

.important-lead {
    background: #fff8e1;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}












.lead-practices-box {
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fafafa;
    padding: 12px;
}

.lead-practices-toolbar {
    margin-bottom: 10px;
}

.lead-practices-summary-item {
    padding: 8px 10px;
    border-bottom: 1px solid #ececec;
    font-size: 14px;
}

    .lead-practices-summary-item:last-child {
        border-bottom: 0;
    }

.practices-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99999;
    padding: 20px;
    align-items: center;
    justify-content: center;
}

.practices-modal-box {
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(0,0,0,.22);
    padding: 20px;
}

.practice-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.practice-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

    .practice-table th,
    .practice-table td {
        border: 1px solid #e5e5e5;
        padding: 8px;
        text-align: left;
        vertical-align: middle;
        font-size: 14px;
    }

.practice-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .practice-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.legacy-tasks-box {
    margin-top: 12px;
    padding: 12px;
    border: 1px dashed #cfcfcf;
    border-radius: 8px;
    background: #fffdf5;
}

.legacy-tasks-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #8a6d3b;
}

.legacy-tasks-content {
    white-space: pre-wrap;
    color: #444;
    font-size: 14px;
}

.nav-section {
    margin: 18px 0 4px;
    padding: 0 16px;
    font-size: 11px;
    font-weight: 700;
    color: #8b97a8;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.table-responsive {
    overflow-x: auto;
}

#conte-profile-table input {
    width: 100px;
    min-width: 90px;
}







.profile-modal-content {
    width: 92vw !important;
    max-width: 1500px !important;
    max-height: 88vh;
    overflow: auto;
    box-sizing: border-box;
}

    .profile-modal-content form,
    #profile-form {
        width: 100% !important;
        max-width: none !important;
    }

    .profile-modal-content .profile-fields-grid {
        width: 100%;
        display: grid;
        grid-template-columns: 1.4fr 0.8fr 0.8fr 1fr;
        gap: 14px 16px;
        align-items: end;
    }

        .profile-modal-content .profile-fields-grid .field-wide {
            grid-column: span 2;
        }

    .profile-modal-content .table-responsive {
        width: 100% !important;
        max-width: none !important;
        overflow-x: auto;
    }

#conte-profile-table {
    width: 100%;
    min-width: 1250px;
    table-layout: fixed;
}

    #conte-profile-table th,
    #conte-profile-table td {
        white-space: nowrap;
        padding: 10px 12px;
    }

    #conte-profile-table input {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

#profile-modal .modal-content {
    display: block !important;
    grid-template-columns: none !important;
    width: 92vw !important;
    max-width: 1500px !important;
    max-height: 88vh;
    overflow: auto;
}

#profile-modal #profile-form {
    width: 100%;
    max-width: none;
}


#conte-profile-table,
#compass-profile-table,
#fidiline-profile-table {
    width: 100%;
    min-width: 1350px;
    table-layout: fixed;
}

    #conte-profile-table input,
    #compass-profile-table input,
    #fidiline-profile-table input {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }


.brands-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.brand-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.brand-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.brand-panel h2 {
    margin: 0;
    font-size: 22px;
}

.brand-code {
    display: inline-block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.brand-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #14532d;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
}

.brand-panel[data-brand="fidiline"] .brand-status {
    color: #854d0e;
    background: #fef3c7;
    border-color: #fde68a;
}

.brand-description {
    color: var(--text);
    margin: 0 0 18px;
    line-height: 1.45;
}

.brand-section {
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 14px;
}

    .brand-section h3 {
        margin: 0 0 10px;
        font-size: 15px;
    }

    .brand-section ul {
        margin: 0;
        padding-left: 18px;
        color: var(--text);
    }

    .brand-section li {
        margin: 5px 0;
    }

.template-list,
.field-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

    .template-list span,
    .field-list span {
        display: inline-flex;
        align-items: center;
        border: 1px solid var(--border);
        background: #f8fafc;
        color: #0f172a;
        border-radius: 999px;
        padding: 6px 10px;
        font-size: 13px;
        line-height: 1.2;
    }

    .template-list.muted span {
        color: #64748b;
        background: #f8fafc;
    }

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

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

#practice-modal .modal-content {
    display: block !important;
    grid-template-columns: none !important;
    width: 92vw !important;
    max-width: 1500px !important;
    max-height: 88vh;
    overflow: auto;
}

#practice-modal #practice-form {
    width: 100%;
    max-width: none;
}
.brand-table-scroll {
    width: 100%;
    overflow-x: auto;
}

.brand-company-table {
    min-width: 980px;
    font-size: 13px;
}

.brand-company-table th,
.brand-company-table td {
    white-space: nowrap;
    text-align: right;
}

.brand-company-table th:first-child,
.brand-company-table td:first-child {
    text-align: left;
}


.commission-preview-detail {
    margin-top: 10px;
    max-width: 680px;
}

.commission-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

    .commission-detail-table th,
    .commission-detail-table td {
        border: 1px solid var(--border);
        padding: 8px 10px;
        text-align: right;
    }

        .commission-detail-table th:first-child,
        .commission-detail-table td:first-child {
            text-align: left;
        }

    .commission-detail-table th {
        background: #f1f5f9;
        font-weight: 700;
    }
.commission-tree-box {
    margin-top: 18px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.commission-tree-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

    .commission-tree-head h3 {
        margin: 0;
    }

.commission-tree-add {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .commission-tree-add select {
        min-width: 260px;
    }

.commission-tree-table {
    min-width: 1120px;
    font-size: 13px;
}

    .commission-tree-table th,
    .commission-tree-table td {
        white-space: nowrap;
        text-align: right;
    }

        .commission-tree-table th:first-child,
        .commission-tree-table td:first-child,
        .commission-tree-table th:nth-child(2),
        .commission-tree-table td:nth-child(2) {
            text-align: left;
        }

.commission-tree-margin-row {
    font-weight: 700;
    background: #fff7cc;
}

.commission-tree-warning-row td {
    background: #fff1f2;
}

.commission-tree-warning {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 13px solid #dc2626;
    margin-right: 8px;
    vertical-align: middle;
    cursor: help;
}

/* === MODALE UTENTI === */
.modal .user-modal-form {
    width: min(1500px, calc(100vw - 80px));
    max-width: 1500px;
    max-height: 88vh;
    gap: 18px;
}

.user-modal-form h2,
.user-modal-form h3 {
    margin: 0;
    color: var(--text);
}

.user-modal-form h2 {
    font-size: 24px;
}

.user-modal-form h3 {
    font-size: 17px;
    margin-bottom: 12px;
}

.user-form-section {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.user-form-section:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.user-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 14px 16px;
}

.user-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-form-grid .user-check {
    justify-content: end;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
}

.user-form-grid .user-check input {
    width: auto;
}

.user-modal-form textarea {
    min-height: 90px;
    resize: vertical;
}

.user-modal-form .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: sticky;
    bottom: -24px;
    background: var(--panel);
    padding-top: 12px;
}

@media (max-width: 1200px) {
    .user-form-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }
}

@media (max-width: 720px) {
    .modal .user-modal-form {
        width: calc(100vw - 28px);
    }

    .user-form-grid {
        grid-template-columns: 1fr;
    }
}

.practice-lead-picker {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.practice-lead-search-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.practice-lead-search-row input {
    flex: 1;
}

.practice-selected-lead {
    margin-top: 8px;
    font-size: 13px;
    color: #0f766e;
}

.practice-lead-results {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.practice-lead-result {
    display: grid;
    grid-template-columns: 1.5fr 1.4fr auto;
    gap: 10px;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    text-align: left;
    background: #fff;
    cursor: pointer;
}

.practice-lead-result:hover {
    background: #eef6ff;
}

.practice-lead-result:last-child {
    border-bottom: 0;
}

.practice-lead-status {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
}

.practice-lead-empty {
    padding: 10px;
    font-size: 13px;
    color: #64748b;
}

.commission-detail-input,
.commission-tree-input {
    width: 120px;
    max-width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: right;
    font: inherit;
    background: #fff;
}

.commission-detail-input:focus,
.commission-tree-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.commission-manual-row td,
.commission-tree-table tr:has(.manual-badge) td {
    background: #fffaf0;
}

.manual-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #fde68a;
    color: #92400e;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
}

.commission-tree-no-spese .js-tree-rate-1,
.commission-tree-no-spese .js-tree-amount-1 {
    display: none;
}
