/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: white;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-storico {
    background: var(--gray-100);
}

.nav-back {
    color: var(--primary);
}

/* User section (CS page) */
.user-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-section label {
    font-weight: 500;
    color: var(--gray-700);
}

.operator-input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.9rem;
    width: 200px;
}

/* Stats section */
.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-card.stat-success .stat-number {
    color: var(--success);
}

.stat-card.stat-card-clickable {
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card.stat-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231,76,60,0.25);
    border: 2px solid #e74c3c;
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* Form section */
.form-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.form-section h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Filters */
.filters-section {
    margin-bottom: 24px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.filters select,
.filters input {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
}

/* Tasks section */
.tasks-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.tasks-section h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--gray-900);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.loading {
    text-align: center;
    color: var(--gray-500);
    padding: 40px;
}

/* Task card */
.task-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 16px;
    transition: all 0.2s;
}

.task-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.task-card.priority-alta {
    border-left: 4px solid var(--danger);
}

.task-card.priority-media {
    border-left: 4px solid var(--warning);
}

.task-card.priority-bassa {
    border-left: 4px solid var(--success);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}

.task-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--gray-900);
}

.task-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-stato {
    background: var(--gray-200);
    color: var(--gray-700);
}

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

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

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

.badge-priorita {
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-priorita.alta {
    background: var(--danger);
    color: white;
}

.badge-priorita.media {
    background: var(--warning);
    color: white;
}

.badge-priorita.bassa {
    background: var(--success);
    color: white;
}

.task-description {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.task-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

/* Storico list */
.storico-list .task-card {
    background: white;
}

.task-completion-info {
    background: var(--gray-100);
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
    font-size: 0.9rem;
}

.task-completion-info strong {
    color: var(--success);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-content.modal-small {
    max-width: 400px;
    text-align: center;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-500);
}

.close:hover {
    color: var(--gray-900);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.task-title-confirm {
    font-weight: 600;
    color: var(--primary);
    margin: 16px 0;
}

/* Comments */
.comments-list {
    margin-top: 24px;
    border-top: 1px solid var(--gray-200);
    padding-top: 16px;
}

.comments-list h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--gray-700);
}

.comment {
    background: var(--gray-50);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.comment-author {
    font-weight: 600;
    color: var(--gray-900);
}

.comment-date {
    color: var(--gray-500);
}

.comment-text {
    color: var(--gray-700);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

.empty-state p {
    font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .task-header {
        flex-direction: column;
    }

    .task-badges {
        align-self: flex-start;
    }

    .filters {
        flex-direction: column;
    }

    .filters select,
    .filters input {
        width: 100%;
    }

    .user-section {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }

    .operator-input {
        width: 100%;
    }
}

/* Animazioni */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.task-card {
    animation: fadeIn 0.3s ease;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========================================
   SEZIONE REPORT OSSEOTOUCH
   ======================================== */

.report-motto {
    font-size: 0.95rem;
    color: var(--gray-500);
    margin-top: 4px;
}

.report-latest-section {
    margin-bottom: 32px;
}

.report-marketing-section {
    margin-bottom: 32px;
}

.report-latest-section h2,
.report-marketing-section h2,
.report-archive-section h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--gray-900);
}

/* Badge filtri campagna */
.campagna-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-600, #4b5563);
    margin-right: 4px;
}
.campagna-badge-no {
    background: #fef2f2;
    color: #991b1b;
}
.campagna-badge-ha {
    background: #f0fdf4;
    color: #166534;
}

/* Card report recenti */
.report-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.report-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 5px solid var(--gray-300);
}

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

.report-card-vendite_giornaliero { border-left-color: var(--primary); }
.report-card-trend_mensile { border-left-color: var(--danger); }
.report-card-finanziario { border-left-color: var(--success); }
.report-card-trend_progressivo { border-left-color: var(--warning, #f59e0b); }

.report-card-tipo {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 8px;
}

.report-card-vendite_giornaliero .report-card-tipo { color: var(--primary); }
.report-card-trend_mensile .report-card-tipo { color: var(--danger); }
.report-card-finanziario .report-card-tipo { color: var(--success); }
.report-card-trend_progressivo .report-card-tipo { color: var(--warning, #f59e0b); }

.report-card-titolo {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.report-card-data {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.report-card-size {
    font-size: 0.75rem;
    color: var(--gray-300);
    margin-top: 10px;
}

/* Card cartella archivio */
.report-folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.report-folder {
    background: white;
    border-radius: 12px;
    padding: 32px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    display: block;
    border-top: 4px solid var(--gray-300);
    text-align: center;
}

.report-folder:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.report-folder-vendite_giornaliero { border-top-color: var(--primary); }
.report-folder-trend_mensile { border-top-color: var(--danger); }
.report-folder-finanziario { border-top-color: var(--success); }
.report-folder-trend_progressivo { border-top-color: var(--warning, #f59e0b); }

.report-folder-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.report-folder-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.report-folder-desc {
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Pagine cartella: sezioni per mese */
.report-folder-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.report-month-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.report-month-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-100);
}

.report-month-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Riga report nella cartella */
.report-history-item {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    padding: 14px 18px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.report-history-item:hover {
    background: white;
    border-color: var(--primary);
}

.report-item-titolo {
    font-weight: 500;
    color: var(--gray-900);
}

.report-item-data {
    color: var(--gray-500);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Nav link Report */
.nav-report {
    background: var(--gray-100);
}

/* Responsive report */
@media (max-width: 768px) {
    .report-cards-grid,
    .report-folders-grid {
        grid-template-columns: 1fr;
    }

    .report-history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ========================================
   SEZIONE REPORT KIM/MASSIMO (ANTONIA)
   ======================================== */

.reports-section {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.reports-section h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: var(--gray-900);
}

/* Colori card report Kim/Massimo */
.report-card-crediti_kim,
.report-card-crediti_massimo { border-left-color: #e74c3c; }
.report-card-crediti_kim .report-card-tipo,
.report-card-crediti_massimo .report-card-tipo { color: #e74c3c; }

.report-card-vendite_kim,
.report-card-vendite_massimo { border-left-color: #9b59b6; }
.report-card-vendite_kim .report-card-tipo,
.report-card-vendite_massimo .report-card-tipo { color: #9b59b6; }

.report-card-attenzionare { border-left-color: #e74c3c; background: linear-gradient(135deg, #fff5f5, #ffffff); }
.report-card-attenzionare .report-card-tipo { color: #e74c3c; }

/* ========================================
   SEZIONE FATTURE (PDF)
   ======================================== */

.fattura-upload-form {
    background: var(--gray-50);
    padding: 16px;
    border-radius: 10px;
    border: 1px dashed var(--gray-300);
    margin-bottom: 16px;
}

.fattura-file-input {
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: white;
    width: 100%;
    font-size: 0.9rem;
}

.fatture-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fattura-item {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-left: 4px solid #e67e22;
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.fattura-item:hover {
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.fattura-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.fattura-nome {
    font-weight: 600;
    color: var(--gray-900);
}

.fattura-data {
    color: var(--gray-500);
    font-size: 0.85rem;
}

.fattura-size {
    color: var(--gray-400);
    font-size: 0.75rem;
}

.fattura-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .fattura-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .fattura-actions {
        width: 100%;
    }

    .fattura-actions .btn {
        flex: 1;
        text-align: center;
    }
}

/* Dashboard Agente - stile header */
.report-motto {
    color: var(--gray-600);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ========================================
   SEZIONE CRM LIGURIA
   ======================================== */

.crm-container {
    max-width: 1600px;
}

.crm-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.crm-toolbar input,
.crm-toolbar select {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
}

.crm-toolbar input {
    flex: 1;
    min-width: 250px;
}

.crm-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

#crm-table {
    border-collapse: collapse;
    width: 100%;
}

#crm-table th {
    background: #2c3e50;
    color: white;
    padding: 8px 6px;
    font-size: 11px;
    position: sticky;
    top: 0;
    z-index: 10;
}

#crm-table th.prod {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: nowrap;
    padding: 8px 3px;
    min-width: 22px;
    font-size: 10px;
}

#crm-table td {
    padding: 5px 6px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 12px;
    white-space: nowrap;
}

/* Bordi verticali sulle colonne prodotto (colonne 8-22) */
#crm-table th:nth-child(n+8):nth-child(-n+22),
#crm-table td:nth-child(n+8):nth-child(-n+22) {
    border-left: 1px solid #d5dadf;
}
/* Bordo destro sull'ultima colonna prodotto per chiudere la griglia */
#crm-table th:nth-child(22),
#crm-table td:nth-child(22) {
    border-right: 1px solid #d5dadf;
}

/* Colonne prodotto pari (9,11,13,15,17,19,21) con sfondo alternato */
#crm-table td:nth-child(9),
#crm-table td:nth-child(11),
#crm-table td:nth-child(13),
#crm-table td:nth-child(15),
#crm-table td:nth-child(17),
#crm-table td:nth-child(19),
#crm-table td:nth-child(21) {
    background: #f4f6f8;
}
/* Header prodotto pari: leggermente diverso per distinguere */
#crm-table th:nth-child(9),
#crm-table th:nth-child(11),
#crm-table th:nth-child(13),
#crm-table th:nth-child(15),
#crm-table th:nth-child(17),
#crm-table th:nth-child(19),
#crm-table th:nth-child(21) {
    background: #34495e;
}

#crm-table tr.crm-row:nth-child(even) td:not(:nth-child(n+8):nth-child(-n+22)) { background: #fafafa; }
#crm-table tr.crm-row:nth-child(even) td:nth-child(9),
#crm-table tr.crm-row:nth-child(even) td:nth-child(11),
#crm-table tr.crm-row:nth-child(even) td:nth-child(13),
#crm-table tr.crm-row:nth-child(even) td:nth-child(15),
#crm-table tr.crm-row:nth-child(even) td:nth-child(17),
#crm-table tr.crm-row:nth-child(even) td:nth-child(19),
#crm-table tr.crm-row:nth-child(even) td:nth-child(21) {
    background: #ebeff3;
}
#crm-table tr.crm-row:hover td { background: #f0f7ff !important; }
#crm-table tr.crm-row-nuovo td { background: #e8f8f0 !important; }
#crm-table tr.crm-row-nuovo td:nth-child(9),
#crm-table tr.crm-row-nuovo td:nth-child(11),
#crm-table tr.crm-row-nuovo td:nth-child(13),
#crm-table tr.crm-row-nuovo td:nth-child(15),
#crm-table tr.crm-row-nuovo td:nth-child(17),
#crm-table tr.crm-row-nuovo td:nth-child(19),
#crm-table tr.crm-row-nuovo td:nth-child(21) {
    background: #dcf2e6 !important;
}

#crm-table td.crm-x {
    text-align: center;
    font-weight: bold;
    color: #27ae60;
}

#crm-table td.crm-x-new {
    text-align: center;
    font-weight: bold;
    color: white;
    background: #27ae60 !important;
    border-radius: 3px;
}

#crm-table td.crm-x-no-storico {
    text-align: center;
    font-weight: bold;
    color: #e74c3c;
}

/* Ricorrente con storico acquisti: sfondo verde chiaro + barra inferiore verde */
#crm-table td.crm-x-ricorrente {
    cursor: pointer;
    border-bottom: 3px solid #27ae60;
    background: #eaf7ef !important;
}
#crm-table td.crm-x-ricorrente:hover {
    background: #c8f0d8 !important;
}

/* Ricorrente Odoo (badge verde pieno prevale, barra inferiore piu' scura per distinguere) */
#crm-table td.crm-x-new.crm-x-ricorrente {
    background: #27ae60 !important;
    color: white !important;
    border-bottom: 3px solid #1e8449;
}
#crm-table td.crm-x-new.crm-x-ricorrente:hover {
    background: #229954 !important;
}

/* Ricorrente SENZA storico: reset (X rossa, nessun indicatore speciale) */
#crm-table td.crm-x-no-storico.crm-x-ricorrente {
    border-bottom: 1px solid #ecf0f1;
    background: transparent !important;
}
#crm-table td.crm-x-no-storico.crm-x-ricorrente:hover {
    background: #fdd !important;
}

/* Alert riordino su prodotto Odoo: alert prevale sul badge verde */
#crm-table td.crm-x-new.crm-reorder-alert-cell {
    background: #fff0e0 !important;
    color: #e67e22 !important;
    border-left: 4px solid #e74c3c;
    border-bottom: 3px solid #e67e22;
}

/* Alert riordino: X arancione + sfondo caldo + barra laterale rossa */
#crm-table td.crm-reorder-alert-cell {
    background: #fff0e0 !important;
    border-left: 4px solid #e74c3c;
    border-bottom: 3px solid #e67e22;
    color: #e67e22 !important;
    animation: pulse-cell 2s infinite;
}
#crm-table tr.crm-row:hover td.crm-reorder-alert-cell {
    background: #ffe0c0 !important;
}
@keyframes pulse-cell {
    0%, 100% { background-color: #fff0e0; }
    50% { background-color: #ffe8d0; }
}

/* Header alert riordini */
.header-alert-box {
    flex: 1;
    min-width: 0;
}
.header-alert-title {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin: 0 0 4px 0;
    color: #2c3e50;
}
.header-alert-msg {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    line-height: 1.4;
}
.header-alert-red .header-alert-msg {
    color: #c0392b;
    background: #fdecea;
    border-left: 5px solid #e74c3c;
}
.header-alert-yellow .header-alert-msg {
    color: #856404;
    background: #fff8e1;
    border-left: 5px solid #f0c040;
}
.header-alert-green .header-alert-msg {
    color: #1e7e34;
    background: #e8f8f0;
    border-left: 5px solid #27ae60;
}

/* Inline edit celle contatto */
#crm-table td.crm-editable {
    cursor: default;
    position: relative;
}
#crm-table td.crm-editable:hover {
    background: #eef6ff !important;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px #a0c4e8;
}
#crm-table td.crm-editing {
    padding: 2px 3px !important;
    background: white !important;
}
.crm-inline-input {
    border: 2px solid #3498db;
    border-radius: 3px;
    padding: 3px 5px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}
.crm-inline-input:focus {
    border-color: #2980b9;
    box-shadow: 0 0 4px rgba(52,152,219,0.3);
}
.crm-citta-regione-form {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.crm-citta-regione-form .crm-inline-input {
    width: 100% !important;
}
.crm-inline-select {
    border: 2px solid #3498db;
    border-radius: 3px;
    padding: 2px 3px;
    font-size: 11px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    background: white;
    cursor: pointer;
}
.crm-inline-select:focus {
    border-color: #2980b9;
    box-shadow: 0 0 4px rgba(52,152,219,0.3);
}

#crm-table td.crm-score {
    text-align: center;
    font-weight: bold;
}

#crm-table td.crm-empty {
    color: #ccc;
}

/* Riga dettaglio acquisti espandibile */
.crm-detail-row td.crm-detail-cell {
    padding: 0;
    border-bottom: 2px solid #3498db;
}

.crm-detail-content {
    padding: 12px 20px;
    background: #f8f9fa;
    border-left: 4px solid #3498db;
}

.crm-detail-content strong {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
}

.crm-detail-content p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.crm-acquisti-table {
    width: auto;
    margin: 8px 0;
    border-collapse: collapse;
    border-radius: 6px;
    overflow: hidden;
}

.crm-acquisti-table th {
    background: #34495e;
    position: static;
    cursor: default;
    padding: 6px 12px;
    font-size: 11px;
}

.crm-acquisti-table td {
    padding: 6px 12px;
    font-size: 12px;
    background: white;
    border-bottom: 1px solid #ecf0f1;
}

.crm-delete-acq {
    cursor: pointer;
    color: #e74c3c;
    font-size: 16px;
    font-weight: bold;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.crm-delete-acq:hover {
    opacity: 1;
}

/* Legenda CRM */
.crm-legenda {
    padding: 15px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    font-size: 12px;
    margin-bottom: 24px;
}

.crm-legenda h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.crm-legenda ul {
    padding-left: 20px;
}

.crm-legenda li {
    margin-bottom: 4px;
}

/* Legenda compatta inline */
.crm-legenda-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 8px 16px;
    margin-bottom: 16px;
    align-items: center;
}
.crm-leg-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #555;
    white-space: nowrap;
}

/* Card CRM in dashboard */
.report-card-crm { border-left-color: #3498db; }
.report-card-crm .report-card-tipo { color: #3498db; }

/* === INTERATTIVITA CRM === */

/* Celle vuote cliccabili */
.crm-cell-empty {
    cursor: pointer;
    transition: background 0.15s;
}
.crm-cell-empty:hover {
    background: #ebf5fb !important;
}

/* Hot Opportunity: fiamma su cella vuota con score >= 40 */
.crm-hot-opportunity {
    text-align: center;
    font-size: 14px;
    background: #fff5f5 !important;
    animation: pulse-fire 2s infinite;
}
.crm-hot-opportunity:hover {
    background: #ffe0e0 !important;
}
@keyframes pulse-fire {
    0%, 100% { background-color: #fff5f5; }
    50% { background-color: #ffe8e0; }
}

/* X manuale (aggiunta da dashboard) */
.crm-x-manual {
    color: #2980b9;
    font-weight: bold;
}

/* Popup conferma inline */
.crm-confirm-popup {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    font-size: 13px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.crm-confirm-popup span {
    font-weight: 600;
    color: #2c3e50;
}

/* Bottoni conferma */
.crm-btn-si {
    background: #27ae60;
    color: white;
    border: none;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.crm-btn-si:hover { background: #219a52; }

.crm-btn-no {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.crm-btn-no:hover { background: #7f8c8d; }

.crm-btn-danger {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}
.crm-btn-danger:hover { background: #c0392b; }

/* Form acquisti inline */
.crm-add-acquisto-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-top: 1px solid #ecf0f1;
    border-radius: 0 0 8px 8px;
    flex-wrap: wrap;
}
.crm-add-acquisto-form label {
    font-size: 11px;
    font-weight: 600;
    color: #7f8c8d;
}
.crm-input-small {
    padding: 4px 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 12px;
    width: 140px;
}
.crm-input-small:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}
.crm-input-qty {
    width: 50px;
}

/* Colonna Note */
.crm-note-icon {
    cursor: pointer;
    font-size: 28px;
    text-align: center;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.crm-note-icon:hover {
    opacity: 1;
}
.crm-note-has {
    opacity: 1;
    color: #e67e22;
}

/* Pannello Note (slide-in da destra) */
.crm-notes-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}
.crm-notes-panel.open {
    right: 0;
}
.crm-notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #ecf0f1;
    background: #2c3e50;
    color: white;
}
.crm-notes-header h3 {
    margin: 0;
    font-size: 15px;
}
.crm-notes-close {
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    line-height: 1;
}
.crm-notes-close:hover { opacity: 1; }

.crm-notes-lista {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}
.crm-nota-entry {
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.crm-nota-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.crm-nota-data {
    font-size: 10px;
    color: #95a5a6;
}
.crm-nota-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}
.crm-nota-entry:hover .crm-nota-actions {
    opacity: 1;
}
.crm-nota-btn {
    cursor: pointer;
    font-size: 14px;
    color: #7f8c8d;
    padding: 0 2px;
}
.crm-nota-btn:hover { color: #2c3e50; }
.crm-nota-btn-del:hover { color: #e74c3c; }
.crm-nota-testo {
    color: #2c3e50;
    white-space: pre-wrap;
    margin: 0;
}
.crm-nota-edit {
    margin-top: 6px;
}
.crm-nota-edit-textarea {
    width: 100%;
    border: 1px solid #3498db;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}
.crm-nota-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.crm-notes-empty {
    color: #bdc3c7;
    text-align: center;
    padding: 30px 0;
    font-style: italic;
}

.crm-notes-input {
    border-top: 1px solid #ecf0f1;
    padding: 12px 16px;
}
.crm-notes-input textarea {
    width: 100%;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.crm-notes-input textarea:focus {
    border-color: #3498db;
    outline: none;
}
.crm-notes-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* Bottone microfono */
.crm-mic-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #ecf0f1;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.crm-mic-btn:hover {
    background: #d5dbdb;
}
.crm-mic-btn.recording {
    background: #e74c3c;
    animation: pulse-mic 1s infinite;
}
@keyframes pulse-mic {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
    50% { box-shadow: 0 0 0 10px rgba(231,76,60,0); }
}
.crm-mic-status {
    font-size: 11px;
    color: #e74c3c;
    font-weight: 600;
}

/* ==================== OPPORTUNITA DI VENDITA ==================== */

/* Icona lampeggiante rossa per opportunita scadute */
.crm-note-opp-scaduta {
    opacity: 1 !important;
    color: #e74c3c !important;
    animation: blink-opp 1s ease-in-out infinite;
}
@keyframes blink-opp {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.15; }
}

/* Pannello body scrollabile con 2 sezioni */
.crm-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.crm-panel-section {
    display: flex;
    flex-direction: column;
}

.crm-panel-section-header {
    padding: 10px 16px 6px;
    background: #f8f9fa;
    border-bottom: 1px solid #ecf0f1;
    position: sticky;
    top: 0;
    z-index: 1;
}
.crm-panel-section-header h4 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7f8c8d;
}

/* Sezione opportunita: header arancione + separatore */
.crm-panel-section-opp {
    border-top: 3px solid #e67e22;
}
.crm-opp-section-header {
    background: #fff8f0;
    border-bottom: 2px solid #e67e22;
}
.crm-opp-section-header h4 {
    color: #e67e22 !important;
}

/* Card opportunita */
.crm-opp-entry {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.5;
    border-left: 3px solid #e67e22;
    background: #fffdf8;
}
.crm-opp-entry.crm-opp-scaduta {
    border-left-color: #e74c3c;
    background: #fff5f5;
}
.crm-opp-entry.crm-opp-futura {
    border-left-color: #27ae60;
    background: #f5fff8;
}

.crm-opp-scadenza {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
}
.crm-opp-scadenza.crm-opp-scaduta {
    color: #e74c3c;
}
.crm-opp-scadenza.crm-opp-futura {
    color: #27ae60;
}
.crm-opp-scadenza-label {
    margin-right: 4px;
}

/* Input opportunita */
.crm-opp-input {
    border-top: 1px solid #ecf0f1;
    padding: 12px 16px;
}
.crm-opp-input textarea {
    width: 100%;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.crm-opp-input textarea:focus {
    border-color: #e67e22;
    outline: none;
}
.crm-opp-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
}
.crm-opp-date-row label {
    font-size: 12px;
    color: #7f8c8d;
    white-space: nowrap;
}
.crm-date-picker {
    padding: 6px 10px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.crm-date-picker:focus {
    border-color: #e67e22;
    outline: none;
}
.crm-btn-opp {
    background: #e67e22 !important;
}
.crm-btn-opp:hover {
    background: #d35400 !important;
}

/* Testo empty state nelle sezioni */
.crm-notes-empty {
    color: #999;
    font-size: 12px;
    margin: 0;
    padding: 4px 0;
}

/* Alert opportunita sulla dashboard */
.crm-opp-alert-badge {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    margin-top: 8px;
    animation: blink-opp 1.2s ease-in-out infinite;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.crm-toast {
    background: #2c3e50;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateX(40px);
    animation: toast-in 0.3s ease forwards;
    max-width: 340px;
}
.crm-toast.toast-success { background: #27ae60; }
.crm-toast.toast-error { background: #e74c3c; }
.crm-toast.toast-info { background: #2980b9; }
@keyframes toast-in {
    to { opacity: 1; transform: translateX(0); }
}
.crm-toast.toast-out {
    animation: toast-out 0.3s ease forwards;
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(40px); }
}

/* Responsive */
@media (max-width: 768px) {
    .crm-toolbar {
        flex-direction: column;
    }
    .crm-toolbar input {
        min-width: auto;
        width: 100%;
    }
    .crm-notes-panel {
        width: 100vw;
        right: -100vw;
    }
    .crm-add-acquisto-form {
        flex-direction: column;
        align-items: flex-start;
    }
    /* Bottone microfono piu grande su mobile (Apple min 44x44) */
    .crm-mic-btn {
        width: 48px;
        height: 48px;
        font-size: 22px;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
        touch-action: manipulation;
    }
}

/* ==================== CRM SCORE PAGE ==================== */

.score-header-box {
    background: #2c3e50;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    flex: 1;
}

.score-header-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

.score-header-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: #bdc3c7;
}

.score-back-btn {
    background: #27ae60 !important;
    color: white !important;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    font-size: 15px !important;
    text-decoration: none !important;
    white-space: nowrap;
}

.score-back-btn:hover {
    background: #219a52 !important;
}

.score-table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

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

.score-table thead th {
    background: #2c3e50;
    color: white;
    padding: 10px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

.score-table thead th:nth-child(1) { width: 40px; }
.score-table thead th:nth-child(2) { text-align: left; min-width: 200px; }

.score-table tbody tr {
    border-bottom: 1px solid #ecf0f1;
}

.score-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.score-table tbody tr:hover {
    background: #eef6ff;
}

.score-table td {
    padding: 8px 12px;
}

.score-table td:nth-child(2) {
    text-align: left;
    font-weight: 500;
}

.score-cell {
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.score-cell.score-empty {
    color: transparent;
}

.score-cell.score-hot {
    background: #e74c3c;
    color: white;
    border-radius: 4px;
    font-weight: 700;
}

.score-prod-col {
    min-width: 70px;
}

/* Score page mobile */
@media (max-width: 768px) {
    .score-header-box {
        padding: 12px 16px;
    }
    .score-header-title {
        font-size: 16px;
    }
    .score-table {
        font-size: 12px;
    }
    .score-cell {
        font-size: 12px;
        padding: 6px 4px;
    }
    .score-back-btn {
        padding: 8px 14px !important;
        font-size: 13px !important;
    }
}

/* ==========================================
   NUOVO CONTATTO - Modal & Form
   ========================================== */

/* WhatsApp icon + filter */
.crm-wa-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 5px;
    vertical-align: middle;
}
.crm-wa-icon svg {
    width: 100%;
    height: 100%;
}
.crm-wa-active svg {
    fill: #25D366;
    opacity: 0.85;
}
.crm-wa-toggle {
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.2s;
}
.crm-wa-toggle svg {
    fill: #999;
}
.crm-wa-toggle:hover {
    opacity: 0.7;
}
.crm-wa-toggle:hover svg {
    fill: #25D366;
}
.crm-btn-filter-whatsapp {
    padding: 6px 12px;
    border: 1px solid #25D366;
    background: white;
    color: #25D366;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}
.crm-btn-filter-whatsapp:hover {
    background: #e8fdf0;
}
.crm-btn-filter-whatsapp.active {
    background: #25D366;
    color: white;
}

/* Toggle colonne dettaglio (Nome, Email, Telefono, Cellulare) */
.crm-btn-toggle-cols {
    padding: 6px 12px;
    border: 1px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}
.crm-btn-toggle-cols:hover {
    background: #eaf2fb;
}

/* Nascondi colonne dettaglio quando la tabella ha crm-cols-hidden */
.crm-table.crm-cols-hidden .crm-col-detail {
    display: none;
}

.crm-btn-nuovo-contatto {
    padding: 8px 16px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.crm-btn-nuovo-contatto:hover {
    background: #219a52;
}

.crm-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.crm-modal-overlay.show {
    display: flex;
}

.crm-modal-nuovo {
    background: white;
    padding: 28px;
    border-radius: 12px;
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.crm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.crm-modal-header h2 {
    margin: 0;
    font-size: 1.3rem;
    color: #2c3e50;
}
.crm-modal-close {
    font-size: 28px;
    cursor: pointer;
    color: #95a5a6;
    line-height: 1;
    transition: color 0.2s;
}
.crm-modal-close:hover {
    color: #e74c3c;
}

.crm-form-tipo {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}
.crm-tipo-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: border-color 0.2s, background 0.2s;
}
.crm-tipo-toggle:has(input:checked) {
    border-color: #3498db;
    background: rgba(52, 152, 219, 0.06);
}
.crm-tipo-toggle input[type="radio"] {
    accent-color: #3498db;
}

.crm-form-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.crm-form-row {
    display: flex;
    gap: 12px;
}
.crm-form-row .crm-form-group {
    flex: 1;
}
.crm-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.crm-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
}
.crm-form-group input[type="text"],
.crm-form-group input[type="email"],
.crm-form-group input[type="tel"] {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.crm-form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.12);
}
.crm-form-group input[readonly] {
    background: #f5f5f5;
    color: #999;
}

.crm-form-hint {
    font-weight: 400;
    color: #999;
    font-size: 11px;
}

.crm-form-error {
    font-size: 12px;
    color: #e74c3c;
    min-height: 1.2em;
}

.crm-form-prodotti {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}
.crm-form-prodotti > label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    margin-bottom: 8px;
    display: block;
}

.crm-prodotti-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px 12px;
}
.crm-prodotto-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
}
.crm-prodotto-check input[type="checkbox"] {
    accent-color: #27ae60;
}

.crm-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    justify-content: flex-end;
}
.crm-form-actions .crm-btn-si {
    padding: 10px 24px;
    font-size: 14px;
}
.crm-form-actions .crm-btn-no {
    padding: 10px 20px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .crm-form-row {
        flex-direction: column;
    }
    .crm-prodotti-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .crm-modal-nuovo {
        max-width: 95%;
        padding: 20px;
    }
}

/* ==================== SEZIONE LEAD ==================== */

.stat-card.stat-lead {
    border-left: 4px solid #8e44ad;
}
.stat-card.stat-lead .stat-number {
    color: #8e44ad;
}

.crm-lead-section {
    margin-top: 40px;
}

.crm-lead-section-title {
    font-size: 1.3rem;
    color: #8e44ad;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #8e44ad;
}

.crm-lead-count {
    font-weight: 400;
    font-size: 0.9rem;
    color: #999;
}

#crm-lead-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
#crm-lead-table th {
    background: #f3e8f9;
    color: #6c3483;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid #8e44ad;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}
#crm-lead-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}
.crm-lead-row:hover {
    background: #f9f0ff;
}

/* Bottone Promuovi nella riga lead */
.crm-btn-promuovi {
    background: #8e44ad;
    color: white;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.crm-btn-promuovi:hover {
    background: #6c3483;
}

/* Modal Promuovi */
.crm-modal-promuovi .crm-promuovi-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    padding: 10px 14px;
    background: #f3e8f9;
    border-radius: 8px;
    border-left: 4px solid #8e44ad;
}

/* Bottone Retrocedi nella riga account (piccolo come le X, arancione) */
.crm-btn-retrocedi {
    background: #e67e22;
    color: white;
    border: none;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    line-height: 1.2;
}
.crm-btn-retrocedi:hover {
    background: #d35400;
}

/* Bottone elimina contatto (X accanto al numero progressivo) */
.crm-btn-elimina {
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    margin-right: 4px;
    transition: color 0.2s;
}
.crm-btn-elimina:hover {
    color: #e74c3c;
}

/* Modal Retrocedi */
.crm-modal-retrocedi .crm-retrocedi-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
    padding: 10px 14px;
    background: #fef3e6;
    border-radius: 8px;
    border-left: 4px solid #e67e22;
}
.crm-retrocedi-warn {
    color: #e74c3c;
    font-weight: 600;
    margin: 10px 0;
}

/* Score page: titoli sezione Account/Lead */
.score-section-title {
    font-size: 1.2rem;
    color: #2c3e50;
    margin: 24px 0 4px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid #2c3e50;
}
.score-section-title-lead {
    color: #8e44ad;
    border-bottom-color: #8e44ad;
    margin-top: 40px;
}
.score-table-lead thead th {
    background: #6c3483 !important;
}

/* ==================== SCORE MANUALE ==================== */
.crm-btn-score {
    background: #f39c12;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    margin-right: 3px;
    line-height: 1;
}
.crm-btn-score:hover {
    background: #e67e22;
}

/* Modal Score */
.crm-modal-score .crm-score-info {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 16px 0;
    padding: 10px 14px;
    background: #fef9e7;
    border-radius: 8px;
    border-left: 4px solid #f39c12;
}
.crm-form-select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    width: 100%;
    background: white;
}
.crm-form-select:focus {
    border-color: #f39c12;
    outline: none;
    box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.15);
}

/* Bottone Storico Score (✎ accanto alla ★) */
.crm-btn-storico-score {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 2px 5px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    margin-right: 3px;
    line-height: 1;
}
.crm-btn-storico-score:hover {
    background: #7f8c8d;
}

/* Modal Storico Score */
.crm-modal-storico-score {
    max-width: 620px;
}
.crm-storico-score-title {
    margin: 0 0 16px 0;
    font-size: 1.15rem;
    color: #2c3e50;
}
.crm-storico-score-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.crm-storico-score-table th {
    background: #34495e;
    color: white;
    padding: 8px 10px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: static;
}
.crm-storico-score-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #ecf0f1;
}
.crm-storico-score-table tr:hover {
    background: #f8f9fa;
}
.crm-storico-score-empty {
    color: #999;
    text-align: center;
    padding: 20px;
    font-style: italic;
}
.crm-btn-elimina-score {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: background 0.15s;
}
.crm-btn-elimina-score:hover {
    background: #c0392b;
}
