        /* ========================================
           CSS VARIABLES - TEMA CHIARO (default)
           ======================================== */
        :root {
            /* Colori principali */
            --bg-primary: #fafafa;
            --bg-secondary: #ffffff;
            --bg-gradient-start: #e8f5e9;
            --bg-gradient-mid: #c8e6c9;
            --bg-gradient-end: #a5d6a7;
            
            /* Testo */
            --text-primary: #212121;
            --text-secondary: #616161;
            --text-inverse: #ffffff;
            
            /* Accenti - Default (verde, si aggiornano con portale) */
            --accent-primary: #2e7d32;
            --accent-secondary: #388e3c;
            --accent-tertiary: #43a047;
            --accent-light: #66bb6a;
            
            /* Colori portali - Default (NL verde) */
            --portal-primary: #2e7d32;
            --portal-secondary: #388e3c;
            --portal-tertiary: #43a047;
            
            /* UI Elements */
            --border-color: #e0e0e0;
            --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
            --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.15);
            
            /* Tabelle */
            --table-row-even: #f1f8f4;
            --table-row-odd: #ffffff;
            --table-hover: #e8f5e9;
            --table-header-bg: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-secondary) 100%);
            
            /* Color Coding - Light Mode */
            --color-mastercard: #c5e1a5;
            --color-visa: #b3e5fc;
            --color-bonifico: #fff9c4;
            --color-estate: #fff9c4;
            --color-inverno: #bbdefb;
            --color-hotel-nl: #c8e6c9;
            --color-hotel-hp: #e1bee7;
            --color-hotel-she: #ffe0b2;
            --color-sig-sergio-done: #ffe0b2;
            --color-totale-bg: #e3f2fd;
            --color-totale-text: #000000;
            --color-error: #ffebee;
            --color-error-text: #c62828;
            --color-selected: #fff176;
            --color-selected-border: #fbc02d;
            --color-editable-hover: #fff3cd;
            
            /* Stati */
            --status-success-bg: #d4edda;
            --status-success-text: #155724;
            --status-error-bg: #f8d7da;
            --status-error-text: #721c24;
            --status-loading-bg: #d1ecf1;
            --status-loading-text: #0c5460;
        }
        
        /* ========================================
           CSS VARIABLES - TEMA SCURO (Budget Dashboard Style)
           Ispirato alle immagini: Nero + Lime Neon
           ======================================== */
        [data-theme="dark"] {
            /* Colori principali - VERDE MONOCROMATICO */
            --bg-primary: #1a2a1a;          /* Verde-grigio scuro esterno */
            --bg-secondary: #2a3a2a;        /* Verde-grigio medio - cards/tabella */
            --bg-gradient-start: #1a2a1a;
            --bg-gradient-mid: #202820;
            --bg-gradient-end: #2a3a2a;
            
            /* Testo - Tonalità verde */
            --text-primary: #b8d4b8;        /* Verde chiaro - leggibile */
            --text-secondary: #889888;      /* Verde-grigio medio */
            --text-inverse: #0a1a0a;        /* Verde scurissimo per testo su verde chiaro */
            
            /* Accenti - VERDE NATURALE (come immagini) */
            --accent-primary: #4CAF50;      /* Verde medio naturale */
            --accent-secondary: #5cb85c;    /* Verde chiaro */
            --accent-tertiary: #66bb6a;     /* Verde chiaro hover */
            --accent-light: #3d8b40;        /* Verde scuro */
            
            /* UI Elements */
            --border-color: #b8d4b8;        /* Verde chiaro (stesso header) */
            --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.5);
            --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.6);
            --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.8);
            
            /* Tabelle - Verde monocromatico */
            --table-row-even: #2d402d;      /* Verde-grigio medio */
            --table-row-odd: #2a3a2a;       /* Verde-grigio base */
            --table-hover: #344a34;         /* Verde più chiaro hover */
            --table-header-bg: #4CAF50;     /* Verde medio come INCOME! */
            
            /* Color Coding - Tonalità verdi differenziate */
            --color-mastercard: #3a4a35;    /* Verde oliva medio */
            --color-visa: #354045;          /* Verde-blu scuro */
            --color-bonifico: #4a4a35;      /* Verde-giallo scuro */
            --color-estate: #4a4a35;        /* Verde-giallo scuro */
            --color-inverno: #354045;       /* Verde-azzurro scuro */
            --color-hotel-nl: #3d5040;      /* Verde foresta */
            --color-hotel-hp: #404040;      /* Verde-grigio neutro */
            --color-hotel-she: #4a4035;     /* Verde-marrone */
            --color-sig-sergio-done: #4a4035; /* Verde-marrone completato */
            --color-totale-bg: #3d5545;     /* Verde-blu medio */
            --color-totale-text: #88dd88;   /* Verde chiaro */
            --color-error: #4a3535;         /* Verde-rosso scuro */
            --color-error-text: #dd8888;    /* Rosso-rosa chiaro */
            --color-selected: #4a5a35;      /* Verde-giallo selezione */
            --color-selected-border: #66bb6a; /* Verde chiaro bordo */
            --color-editable-hover: #344434; /* Verde scuro hover */
            
            /* Stati */
            --status-success-bg: #2a4a2a;   /* Verde medio */
            --status-success-text: #88dd88; /* Verde chiaro */
            --status-error-bg: #4a2a2a;     /* Verde-rosso scuro */
            --status-error-text: #dd8888;   /* Rosso chiaro */
            --status-loading-bg: #2a3a4a;   /* Verde-blu */
            --status-loading-text: #88ccdd; /* Azzurro chiaro */
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
            color: var(--text-primary);
            min-height: 100vh;
            padding: 20px;
            transition: background 0.3s ease, color 0.3s ease;
            /* Zoom predefinito 90% per miglior visualizzazione */
            font-size: 90%;
        }

        .container {
            max-width: 100%;
            margin: 0 auto;
            background: var(--bg-secondary);
            border-radius: 20px;
            box-shadow: var(--shadow-lg);
            overflow: visible; /* necessario per far funzionare position: sticky dei filtri */
            transition: background 0.3s ease, box-shadow 0.3s ease;
        }

        .header {
            background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-secondary) 50%, var(--portal-tertiary) 100%);
            color: var(--text-inverse);
            padding: 30px 40px;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.2);
            position: relative;
            overflow: hidden;
            transition: all 0.3s ease;
        }
        
        /* Colori portali dinamici */
        body[data-portal="nl"] {
            --portal-primary: #2e7d32;
            --portal-secondary: #388e3c;
            --portal-tertiary: #43a047;
            --accent-primary: #2e7d32;
            --accent-secondary: #388e3c;
            --accent-tertiary: #43a047;
            --accent-light: #66bb6a;
        }
        
        body[data-portal="she"] {
            --portal-primary: #2563eb;
            --portal-secondary: #3876da;
            --portal-tertiary: #4a90e2;
            --accent-primary: #2563eb;
            --accent-secondary: #3876da;
            --accent-tertiary: #4a90e2;
            --accent-light: #5ba0f5;
        }
        
        body[data-portal="hp"] {
            --portal-primary: #6b1a0a;
            --portal-secondary: #85200c;
            --portal-tertiary: #a0260f;
            --accent-primary: #6b1a0a;
            --accent-secondary: #85200c;
            --accent-tertiary: #a0260f;
            --accent-light: #b8321a;
        }
        
        /* Badge portale */
        .portal-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 0.75em;
            font-weight: 600;
            margin-left: 8px;
            background: rgba(255, 255, 255, 0.25);
            border: 1px solid rgba(255, 255, 255, 0.4);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        /* Header in dark mode: sfondo verde-grigio scuro con bordo verde */
        [data-theme="dark"] .header {
            background: #1a2a1a;
            border-bottom: 3px solid #4CAF50;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8), 0 0 30px rgba(76, 175, 80, 0.2);
        }
        
        [data-theme="dark"] .header h1,
        [data-theme="dark"] .header p {
            color: #b8d4b8;
        }
        
        .header-content {
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: relative;
            z-index: 2;
        }
        
        .header-title {
            text-align: left;
        }

        .header h1 {
            font-size: 2em;
            margin-bottom: 5px;
            font-weight: 600;
            letter-spacing: -0.5px;
        }

        .header p {
            font-size: 0.95em;
            opacity: 0.85;
            font-weight: 400;
        }
        
        .header-actions {
            display: flex;
            gap: 12px;
            align-items: center;
            margin-right: 80px; /* Spazio per il toggle button */
        }
        
        .btn-header {
            background: rgba(255, 255, 255, 0.2);
            color: var(--text-inverse);
            border: 1.5px solid rgba(255, 255, 255, 0.3);
            padding: 10px 20px;
            font-size: 0.9em;
            font-weight: 500;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.25s ease;
            backdrop-filter: blur(10px);
            white-space: nowrap;
        }
        
        .btn-header:hover {
            background: rgba(255, 255, 255, 0.3);
            border-color: rgba(255, 255, 255, 0.5);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
        
        .btn-header-secondary {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.2);
        }
        
        /* Pulsanti header in dark mode: verde chiaro come upload */
        [data-theme="dark"] .btn-header {
            background: #b8d4b8;
            color: #1a2a1a;
            border: 1.5px solid #b8d4b8;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        [data-theme="dark"] .btn-header:hover {
            background: #c8e4c8;
            border-color: #c8e4c8;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
        }
        
        [data-theme="dark"] .btn-header-secondary {
            background: #b8d4b8;
            color: #1a2a1a;
            border-color: #b8d4b8;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        [data-theme="dark"] .btn-header-secondary:hover {
            background: #c8e4c8;
            border-color: #c8e4c8;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
        }
        
        /* Toggle tema button */
        .theme-toggle {
            position: absolute;
            top: 20px;
            right: 30px;
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 50px;
            padding: 8px 20px;
            cursor: pointer;
            font-size: 1.2em;
            transition: all 0.3s ease;
            z-index: 10;
            backdrop-filter: blur(10px);
        }
        
        .theme-toggle:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.05);
        }

        .content {
            padding: 24px;
        }

        /* Upload Section - Sottile ed Elegante */
        .upload-section {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 16px 24px;
            margin-bottom: 20px;
            transition: all 0.25s ease;
            box-shadow: var(--shadow-sm);
        }

        .upload-section:hover {
            border-color: var(--accent-light);
            box-shadow: var(--shadow-md);
        }

        .upload-section.dragover {
            border-color: var(--accent-primary);
            border-width: 2px;
            background: var(--table-hover);
        }
        
        .upload-content {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            gap: 15px;
        }
        
        .upload-info {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .upload-arrow {
            font-size: 1.2em;
            color: var(--text-secondary);
            opacity: 0.7;
        }
        
        .upload-icon-small {
            font-size: 1.5em;
        }
        
        /* Spring controls in upload section */
        .spring-controls-upload {
            display: flex;
            gap: 12px;
            align-items: center;
            margin-left: auto;
        }
        
        .spring-file-select-upload {
            background: var(--bg-secondary);
            color: var(--text-primary);
            border: 1.5px solid var(--border-color);
            padding: 8px 12px;
            border-radius: 8px;
            font-size: 0.9em;
            cursor: pointer;
            transition: all 0.25s ease;
        }
        
        .spring-file-select-upload:hover {
            border-color: var(--accent-primary);
        }
        
        .btn-spring-upload {
            background: var(--accent-primary);
            color: var(--text-inverse);
            border: none;
            padding: 8px 20px;
            font-size: 0.9em;
            font-weight: 500;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.25s ease;
            white-space: nowrap;
        }
        
        .btn-spring-upload:hover {
            background: var(--accent-secondary);
            transform: translateY(-1px);
        }
        
        /* Spring button in dark mode */
        [data-theme="dark"] .btn-spring-upload {
            background: #b8d4b8;
            color: #1a2a1a;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        [data-theme="dark"] .btn-spring-upload:hover {
            background: #c8e4c8;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
            transform: translateY(-2px);
        }
        
        .upload-label {
            font-size: 0.95em;
            font-weight: 500;
            color: var(--text-primary);
        }
        
        .btn-upload {
            background: var(--accent-primary);
            color: var(--text-inverse);
            border: none;
            padding: 12px 32px;
            font-size: 0.95em;
            font-weight: 600;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.25s ease;
            white-space: nowrap;
            min-height: 44px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        
        .btn-upload:hover {
            background: var(--accent-secondary);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
        
        /* Upload button in dark mode - Verde chiaro come header */
        [data-theme="dark"] .btn-upload {
            background: #b8d4b8;
            color: #1a2a1a;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        [data-theme="dark"] .btn-upload:hover {
            background: #c8e4c8;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
            transform: translateY(-2px);
        }

        .file-input-wrapper {
            position: relative;
            display: inline-block;
            padding: 4px;
        }

        .file-input {
            position: absolute;
            opacity: 0;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            cursor: pointer;
            z-index: 1;
        }

        .btn {
            background: var(--accent-primary);
            color: var(--text-inverse);
            border: none;
            padding: 12px 24px;
            font-size: 0.95em;
            font-weight: 600;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.25s ease;
            display: inline-block;
            text-decoration: none;
            box-shadow: 0 0 20px rgba(0, 255, 65, 0.3);
        }

        .btn:hover {
            background: var(--accent-secondary);
            transform: translateY(-2px);
            box-shadow: 0 0 30px rgba(0, 255, 65, 0.5), var(--shadow-md);
        }

        .btn:disabled,
        .btn.disabled {
            background: #ccc;
            cursor: not-allowed;
            transform: none;
            opacity: 0.6;
            pointer-events: none;
        }
        
        /* Focus states per accessibilità */
        .btn:focus-visible,
        button:focus-visible,
        input:focus-visible,
        select:focus-visible,
        textarea:focus-visible {
            outline: 3px solid var(--accent-primary);
            outline-offset: 2px;
            box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.2);
        }
        
        /* Loading state per bottoni */
        .btn.loading {
            position: relative;
            color: transparent !important;
            pointer-events: none;
        }
        
        .btn.loading::after {
            content: '';
            position: absolute;
            width: 16px;
            height: 16px;
            top: 50%;
            left: 50%;
            margin-left: -8px;
            margin-top: -8px;
            border: 2px solid #ffffff;
            border-radius: 50%;
            border-top-color: transparent;
            animation: spinner 0.6s linear infinite;
        }
        
        @keyframes spinner {
            to { transform: rotate(360deg); }
        }
        
        /* Tooltip base */
        [data-tooltip] {
            position: relative;
        }
        
        [data-tooltip]:hover::before {
            content: attr(data-tooltip);
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            padding: 6px 10px;
            background: #333;
            color: #fff;
            border-radius: 4px;
            font-size: 0.85em;
            white-space: nowrap;
            z-index: 1000;
            margin-bottom: 5px;
            pointer-events: none;
        }
        
        [data-tooltip]:hover::after {
            content: '';
            position: absolute;
            bottom: 100%;
            left: 50%;
            transform: translateX(-50%);
            border: 5px solid transparent;
            border-top-color: #333;
            margin-bottom: -5px;
            z-index: 1000;
            pointer-events: none;
        }

        .btn-secondary {
            background: transparent;
            border: 1.5px solid var(--accent-primary);
            color: var(--accent-primary);
        }

        .btn-secondary:hover {
            background: var(--accent-primary);
            color: var(--text-inverse);
        }
        
        /* Pulsanti in dark mode: verde chiaro come upload */
        [data-theme="dark"] .btn {
            background: #b8d4b8;
            color: #1a2a1a;
            border: 1.5px solid #b8d4b8;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        [data-theme="dark"] .btn:hover {
            background: #c8e4c8;
            border-color: #c8e4c8;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
        }
        
        [data-theme="dark"] .btn-secondary {
            background: #b8d4b8;
            color: #1a2a1a;
            border-color: #b8d4b8;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        [data-theme="dark"] .btn-secondary:hover {
            background: #c8e4c8;
            border-color: #c8e4c8;
            color: #1a2a1a;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
        }

        .status {
            margin-top: 20px;
            padding: 15px;
            border-radius: 8px;
            display: none;
        }

        .status.success {
            background: var(--status-success-bg);
            color: var(--status-success-text);
            border: 1px solid var(--accent-primary);
            display: block;
        }

        .status.error {
            background: var(--status-error-bg);
            color: var(--status-error-text);
            border: 1px solid var(--color-error-text);
            display: block;
        }

        .status.loading {
            background: var(--status-loading-bg);
            color: var(--status-loading-text);
            border: 1px solid var(--color-totale-text);
            display: block;
        }

        .tabs {
            display: flex;
            border-bottom: 2px solid var(--accent-light);
            margin-bottom: 20px;
            background: var(--bg-secondary);
            border-radius: 12px 12px 0 0;
            padding: 0 10px;
        }

        .tab {
            padding: 15px 30px;
            cursor: pointer;
            background: transparent;
            border: none;
            font-size: 1.1em;
            transition: all 0.3s;
            color: var(--text-secondary);
            border-radius: 8px 8px 0 0;
        }

        .tab:hover {
            background: var(--table-hover);
        }

        .tab.active {
            background: linear-gradient(135deg, var(--accent-tertiary) 0%, var(--accent-secondary) 100%);
            color: var(--text-inverse);
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        /* Stili per tab PAREGGI */
        .pareggi-container {
            padding: 20px;
        }

        .pareggi-pronti-section {
            margin-bottom: 40px;
        }

        .pareggi-pronti-section h2 {
            margin-bottom: 20px;
            color: var(--text-primary);
            font-size: 1.8em;
        }

        .status-card {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 15px;
            padding: 25px;
            box-shadow: var(--shadow-md);
        }

        .status-header {
            display: flex;
            align-items: center;
            gap: 15px;
            margin-bottom: 20px;
            font-size: 1.3em;
            font-weight: bold;
        }

        .status-header #statusIcon {
            font-size: 1.5em;
        }

        .status-header #statusText {
            flex: 1;
        }

        .btn-refresh {
            background: transparent;
            border: 2px solid var(--border-color);
            border-radius: 8px;
            padding: 8px 12px;
            font-size: 1.2em;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-refresh:hover {
            background: var(--table-hover);
            transform: rotate(180deg);
        }

        .status-details {
            display: grid;
            gap: 15px;
            margin-top: 20px;
            padding-top: 20px;
            border-top: 1px solid var(--border-color);
        }

        .status-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px;
            background: var(--bg-primary);
            border-radius: 8px;
        }

        .badge {
            display: inline-block;
            padding: 5px 12px;
            background: var(--accent-primary);
            color: var(--text-inverse);
            border-radius: 20px;
            font-weight: bold;
            font-size: 1.1em;
        }

        .status-in-corso {
            border-left: 5px solid #ff9800;
        }

        .status-completato {
            border-left: 5px solid #4caf50;
        }

        .status-errore {
            border-left: 5px solid #f44336;
        }

        .status-no-calcolo {
            border-left: 5px solid #9e9e9e;
        }

        /* Puzzle View Styles */
        .puzzle-container {
            padding: 20px;
        }

        .puzzle-header {
            margin-bottom: 30px;
        }

        .puzzle-stats {
            display: flex;
            gap: 20px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        .puzzle-stat-card {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 15px 20px;
            min-width: 180px;
            text-align: center;
            box-shadow: var(--shadow-sm);
        }

        .puzzle-stat-card.highlight {
            border-color: var(--accent-primary);
            background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(46, 125, 50, 0.1) 100%);
        }

        .puzzle-stat-label {
            font-size: 0.85em;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }

        .puzzle-stat-value {
            font-size: 1.8em;
            font-weight: bold;
            color: var(--accent-primary);
        }

        .puzzle-layout {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

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

        .puzzle-column {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 20px;
            box-shadow: var(--shadow-sm);
        }

        .puzzle-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .puzzle-item {
            background: var(--bg-primary);
            border: 2px solid var(--border-color);
            border-radius: 8px;
            padding: 15px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }

        .puzzle-item:hover {
            border-color: var(--accent-primary);
            box-shadow: var(--shadow-md);
            transform: translateY(-2px);
        }

        .puzzle-item.selected {
            border-color: var(--accent-primary);
            background: rgba(46, 125, 50, 0.1);
            box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
        }

        .puzzle-item input[type="checkbox"] {
            width: 20px;
            height: 20px;
            cursor: pointer;
            margin-top: 2px;
        }

        .puzzle-item-content {
            flex: 1;
        }

        .puzzle-item-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }

        .puzzle-item-name {
            font-weight: bold;
            color: var(--text-primary);
            font-size: 1.05em;
            display: flex;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .puzzle-code-link {
            color: var(--portal-primary) !important;
            text-decoration: none !important;
            font-weight: 600 !important;
            margin-left: 6px;
            padding: 2px 6px;
            border-radius: 4px;
            transition: all 0.2s ease;
            display: inline-block;
            cursor: pointer;
            border: 1px solid transparent;
        }
        
        .puzzle-code-link:hover {
            background: var(--table-hover) !important;
            text-decoration: underline !important;
            border-color: var(--portal-primary);
            transform: scale(1.05);
        }
        
        [data-theme="dark"] .puzzle-code-link {
            color: #88dd88 !important;
        }
        
        [data-theme="dark"] .puzzle-code-link:hover {
            background: rgba(136, 221, 136, 0.2) !important;
            border-color: #88dd88;
        }

        .puzzle-item-amount {
            font-size: 1.2em;
            font-weight: bold;
            color: var(--accent-primary);
        }

        .puzzle-item-details {
            font-size: 0.9em;
            color: var(--text-secondary);
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
        }

        .puzzle-item-detail {
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .puzzle-item-actions {
            display: flex;
            gap: 5px;
        }

        .puzzle-item-btn {
            background: transparent;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            padding: 4px 8px;
            cursor: pointer;
            font-size: 0.85em;
            transition: all 0.2s ease;
        }

        .puzzle-item-btn:hover {
            background: var(--accent-primary);
            color: white;
            border-color: var(--accent-primary);
        }

        .puzzle-actions {
            background: var(--bg-secondary);
            padding: 20px;
            border-radius: 12px;
            border: 2px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 15px;
        }

        .puzzle-selection-info {
            font-size: 1.05em;
            color: var(--text-primary);
        }

        .puzzle-actions button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        [data-theme="dark"] .puzzle-item {
            background: var(--bg-primary);
            border-color: var(--border-color);
        }

        [data-theme="dark"] .puzzle-item.selected {
            background: rgba(76, 175, 80, 0.15);
            border-color: var(--accent-primary);
        }

        /* Color coding per GIR FEST e FE: solo importo */
        .puzzle-item[data-tipo-gir="FEST"] .puzzle-item-amount {
            background: rgba(255, 152, 0, 0.2) !important; /* Arancione per FEST */
            padding: 4px 8px;
            border-radius: 4px;
            border-left: 3px solid #ff9800;
            font-weight: 600;
        }

        .puzzle-item[data-tipo-gir="FE"] .puzzle-item-amount {
            background: rgba(156, 39, 176, 0.2) !important; /* Viola per FE */
            padding: 4px 8px;
            border-radius: 4px;
            border-left: 3px solid #9c27b0;
            font-weight: 600;
        }

        [data-theme="dark"] .puzzle-item[data-tipo-gir="FEST"] .puzzle-item-amount {
            background: rgba(255, 152, 0, 0.3) !important;
        }

        [data-theme="dark"] .puzzle-item[data-tipo-gir="FE"] .puzzle-item-amount {
            background: rgba(156, 39, 176, 0.3) !important;
        }

        /* Color coding per RESTITUZIONE CAPARRA: solo importo rosso */
        .puzzle-item[data-restituzione="true"] .puzzle-item-amount {
            background: rgba(244, 67, 54, 0.2) !important; /* Rosso chiaro */
            color: #c62828 !important; /* Rosso scuro */
            padding: 4px 8px;
            border-radius: 4px;
            border-left: 3px solid #d32f2f;
            font-weight: 600;
        }

        [data-theme="dark"] .puzzle-item[data-restituzione="true"] .puzzle-item-amount {
            background: rgba(244, 67, 54, 0.3) !important;
            color: #ef5350 !important;
        }

        .pareggi-list, .unmatched-section, .duplicates-section {
            margin-top: 40px;
        }

        .pareggi-list h3, .unmatched-section h3, .duplicates-section h3 {
            margin-bottom: 20px;
            color: var(--text-primary);
            font-size: 1.5em;
        }

        .pareggi-table {
            display: grid;
            gap: 15px;
        }

        /* Stili per visualizzazione compatta gruppi */
        .pareggio-group-summary {
            padding: 8px 0;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 8px;
        }
        
        .pareggio-group-details {
            padding: 8px 0;
            border-top: 1px solid var(--border-color);
            margin-top: 8px;
        }
        
        .group-toggle-btn {
            transition: all 0.2s ease;
        }
        
        .group-toggle-btn:hover {
            opacity: 0.9;
            transform: scale(1.05);
        }
        
        .pareggio-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            padding: 20px;
            background: var(--bg-secondary);
            border-radius: 10px;
            border: 2px solid var(--border-color);
            box-shadow: var(--shadow-sm);
        }

        .pareggio-dare, .pareggio-avere {
            padding: 15px;
            border-radius: 8px;
        }

        .pareggio-dare {
            background: #ffebee;
            border-left: 4px solid #c62828;
        }

        [data-theme="dark"] .pareggio-dare {
            background: #4a2a2a;
            border-left-color: #dd8888;
        }

        .pareggio-avere {
            background: #e8f5e9;
            border-left: 4px solid var(--portal-primary);
        }
        
        /* Pareggi avere con colori portale dinamici */
        body[data-portal="she"] .pareggio-avere {
            background: #e3f2fd;
            border-left-color: var(--portal-primary);
        }
        
        body[data-portal="hp"] .pareggio-avere {
            background: #ffebee;
            border-left-color: var(--portal-primary);
        }
        
        [data-theme="dark"] .pareggio-avere {
            background: #2a4a2a;
            border-left-color: var(--portal-tertiary);
        }
        
        [data-theme="dark"] body[data-portal="she"] .pareggio-avere {
            background: #2a3a4a;
            border-left-color: var(--portal-tertiary);
        }
        
        [data-theme="dark"] body[data-portal="hp"] .pareggio-avere {
            background: #4a2a2a;
            border-left-color: var(--portal-tertiary);
        }

        .pareggio-header {
            font-weight: bold;
            margin-bottom: 10px;
            color: var(--text-primary);
        }

        .pareggio-item {
            margin: 5px 0;
            color: var(--text-secondary);
        }

        .pareggio-amount {
            font-size: 1.2em;
            font-weight: bold;
            margin-top: 10px;
            color: var(--text-primary);
        }

        .pareggio-confidence {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 5px;
            font-size: 0.85em;
            margin-top: 5px;
        }

        .confidence-high {
            background: rgba(var(--portal-primary-rgb), 0.2);
            color: var(--portal-primary);
        }
        
        /* Confidence high con colori portale dinamici */
        body[data-portal="she"] .confidence-high {
            background: rgba(37, 99, 235, 0.2);
            color: var(--portal-primary);
        }
        
        body[data-portal="hp"] .confidence-high {
            background: rgba(107, 26, 10, 0.2);
            color: var(--portal-primary);
        }

        .confidence-medium {
            background: #fff9c4;
            color: #f57f17;
        }

        .confidence-low {
            background: #ffccbc;
            color: #d84315;
        }

        .unmatched-tabs, .duplicates-tabs {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
        }

        .unmatched-tab, .duplicates-tab {
            padding: 10px 20px;
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .unmatched-tab.active, .duplicates-tab.active {
            background: var(--accent-primary);
            color: var(--text-inverse);
            border-color: var(--accent-primary);
        }

        .unmatched-list, .duplicates-list {
            display: grid;
            gap: 10px;
        }

        .unmatched-item, .duplicate-item {
            padding: 15px;
            background: var(--bg-secondary);
            border-radius: 8px;
            border: 1px solid var(--border-color);
        }

        .badge-small {
            display: inline-block;
            background: var(--accent-primary);
            color: var(--text-inverse);
            border-radius: 10px;
            padding: 2px 8px;
            font-size: 0.8em;
            font-weight: bold;
            margin-left: 5px;
        }



        /* Leggera compattazione di alcune colonne nel corpo tabella */
        td[data-field="canale"],
        td[data-field="circuito"] {
        
        /* Colonne non editabili ma clickabili (ID e ⛳️) */
        .non-editable-link,
        .pareggio-cell {
            cursor: pointer;
            user-select: none;
        }
        
        .non-editable-link:hover,
        .pareggio-cell:hover {
            opacity: 0.8;
        }
        
        /* Previeni edit su colonne ID e ⛳️ */
        .non-editable-link.editing,
        .pareggio-cell.editing {
            pointer-events: none;
        }
            font-size: 0.95em;
        }
        /* Icona orologio/clock della prima colonna più piccola */
        td:first-child .clock-icon,
        .clock-icon {
            transform: scale(0.8);
        }

        .table-container {
            overflow-x: auto;
            margin-top: 0; /* Rimosso per eliminare spazio verde */
        }

        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.95em;
        }

        thead {
            background: var(--table-header-bg);
            color: var(--text-inverse);
        }

        th {
            padding: 15px;
            text-align: left;
            font-weight: 600;
            position: static; /* default: non sticky */
            background: var(--table-header-bg);
            color: inherit;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
            border-bottom: 1px solid var(--border-color);
            border-right: 1px solid var(--border-color);
        }


        
        /* Header tabella: testo bianco in light mode */
        :root thead th,
        thead th {
            color: var(--text-inverse);
        }
        
        /* Header tabella in dark mode: VERDE CHIARO sfondo, VERDE SCURO testo */
        [data-theme="dark"] thead {
            background: #b8d4b8;
            color: #1a2a1a !important;
        }
        
        [data-theme="dark"] th {
            background: #b8d4b8 !important;
            color: #1a2a1a !important;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            font-size: 0.85em;
        }
        
        /* Forza colore verde scuro anche per thead th in dark mode */
        [data-theme="dark"] thead th {
            color: #1a2a1a !important;
        }

        td {
            padding: 12px 15px;
            border-bottom: 1px solid var(--border-color);
            color: var(--text-primary);
        }

        /* NOTE: rendi la colonna Note avvolgibile e pulita */
        td[data-field="note"] {
            white-space: normal;
            word-break: break-word;
            line-height: 1.35;
        }

        /* Nascondi colonna Data Conferma (senza rompere gli indici delle colonne) */
        th.col-data-conferma,
        td[data-field="data_conferma_bonifici"] {
            display: none;
        }
        
        /* Nascondi colonna Numero (senza rompere gli indici delle colonne) */
        th.col-numero,
        td.col-numero {
            display: none;
        }

        /* Riduci margini/padding su schermi piccoli e usa tutta la larghezza */
        @media (max-width: 1280px) {
            body { padding: 12px; }
            .content { padding: 16px; }
            .header { padding: 20px 24px; }
            .header-actions { margin-right: 40px; }
            table { font-size: 0.9em; }
            th, td { padding: 10px 12px; }
        }
        
        /* Bordi verde chiaro in dark mode (stesso del header) */
        [data-theme="dark"] td {
            border-bottom: 1px solid #b8d4b8;
        }

        tbody tr:nth-child(even) {
            background: var(--table-row-even);
        }

        tbody tr:nth-child(odd) {
            background: var(--table-row-odd);
        }

        tbody tr:hover {
            background: var(--table-hover);
        }

        /* Colonna TOTALE: sempre blu, non cambia colore per canale */

        /* Color coding per CIRCUITO */
        tbody tr[data-circuito="MASTERCARD"] td:nth-child(8) {
            background: var(--color-mastercard) !important;
            font-weight: 500;
        }

        tbody tr[data-circuito="VISA"] td:nth-child(8) {
            background: var(--color-visa) !important;
            font-weight: 500;
        }

        tbody tr[data-circuito="BONIFICO"] td:nth-child(8) {
            background: var(--color-bonifico) !important;
            font-weight: 500;
        }

        /* Color coding per STAGIONE */
        tbody tr[data-stagione*="ESTATE"] td:nth-child(10) {
            background: var(--color-estate) !important;
            font-weight: 500;
        }

        tbody tr[data-stagione*="INVERNO"] td:nth-child(10) {
            background: var(--color-inverno) !important;
            font-weight: 500;
        }

        /* Color coding per HOTEL */
        tbody tr[data-hotel="NL"] td:nth-child(11) {
            background: var(--color-hotel-nl) !important;
            font-weight: 500;
            color: var(--text-primary);
        }

        tbody tr[data-hotel="HP"] td:nth-child(11) {
            background: var(--color-hotel-hp) !important;
            font-weight: 500;
        }

        tbody tr[data-hotel="SHE"] td:nth-child(11) {
            background: var(--color-hotel-she) !important;
            font-weight: 500;
        }

        /* Evidenziazione temporanea per navigazione */
        .element-highlight {
            background: rgba(255, 235, 59, 0.3) !important; /* Giallo chiaro */
            animation: highlight-pulse 1s ease-in-out 3;
            border-left: 4px solid #FFC107 !important;
        }
        
        @keyframes highlight-pulse {
            0%, 100% { background: rgba(255, 235, 59, 0.3) !important; }
            50% { background: rgba(255, 235, 59, 0.5) !important; }
        }
        
        /* Color coding per RESTITUZIONE CAPARRA: colonna Totale rossa */
        tbody tr[data-restituzione="true"] td:nth-child(8) { /* Colonna Totale */
            background: rgba(244, 67, 54, 0.15) !important; /* Rosso chiaro */
            color: #c62828 !important; /* Rosso scuro */
            font-weight: 600;
            border-left: 3px solid #d32f2f;
        }

        [data-theme="dark"] tbody tr[data-restituzione="true"] td:nth-child(8) {
            background: rgba(244, 67, 54, 0.25) !important;
            color: #ef5350 !important;
        }

        /* Rimosso: usiamo evidenziazione arancione più sotto */

        .stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }

        .stat-card {
            background: linear-gradient(135deg, #81c784 0%, #66bb6a 100%);
            color: white;
            padding: 20px;
            border-radius: 12px;
            text-align: center;
            box-shadow: 0 4px 12px rgba(129, 199, 132, 0.3);
        }

        .stat-card h3 {
            font-size: 2em;
            margin-bottom: 5px;
        }

        .stat-card p {
            opacity: 0.9;
        }

        /* Statistiche Quadratura */
        .quadratura-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }

        .stat-card-quadratura {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 20px;
            text-align: center;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }

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

        .stat-card-quadratura.highlight {
            border-color: var(--accent-primary);
            background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(0, 97, 0, 0.1) 100%);
        }

        .stat-card-quadratura .stat-label {
            font-size: 0.85em;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 10px;
            font-weight: 600;
        }

        .stat-card-quadratura .stat-value {
            font-size: 2em;
            font-weight: bold;
            color: var(--accent-primary);
            margin-bottom: 5px;
        }

        .stat-card-quadratura .stat-value.error {
            color: #d9534f;
        }

        .stat-card-quadratura .stat-total {
            font-size: 0.85em;
            margin-top: 8px;
        }
        
        .stat-card-quadratura .stat-details {
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid var(--border-color);
            font-size: 0.8em;
            color: var(--text-secondary);
            line-height: 1.6;
        }
        
        .stat-card-quadratura .stat-details-item {
            margin: 4px 0;
        }
        
        .stat-card-quadratura .stat-details-item strong {
            color: var(--text-primary);
            font-weight: 600;
        }

        .stat-card-quadratura .stat-percent {
            font-size: 1.2em;
            font-weight: bold;
            color: var(--accent-primary);
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid var(--border-color);
        }

        [data-theme="dark"] .stat-card-quadratura.highlight {
            background: linear-gradient(135deg, #1a2a1a 0%, rgba(76, 175, 80, 0.2) 100%);
        }

        .actions {
            display: flex;
            gap: 15px;
            margin-top: 20px;
            flex-wrap: wrap;
        }

        .loading-spinner {
            display: inline-block;
            width: 20px;
            height: 20px;
            border: 3px solid rgba(255,255,255,.3);
            border-radius: 50%;
            border-top-color: white;
            animation: spin 1s ease-in-out infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        .filters {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            padding: 16px 20px;
            border-radius: 12px;
            margin-bottom: 8px;
            display: flex;
            gap: 16px;
            flex-wrap: wrap;
            align-items: flex-end;
            box-shadow: var(--shadow-sm);
            transition: all 0.3s ease;
            position: sticky;
            top: 12px; /* resta visibile durante lo scroll */
            z-index: 50;
        }
        
        /* Filtri in dark mode: sfondo verde chiaro */
        [data-theme="dark"] .filters {
            background: #344a34;
            border-color: #3d5040;
        }

        .filter-group {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .filter-group label {
            font-weight: 500;
            color: var(--text-secondary);
            font-size: 0.85em;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        /* Multi-select custom component */
        .multi-select-wrapper {
            position: relative;
            display: inline-block;
            width: 100%;
        }
        
        .multi-select-button {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9em;
            color: var(--text-primary);
            text-align: left;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: all 0.2s ease;
            min-height: 38px;
        }
        
        .multi-select-button:hover {
            border-color: var(--accent-primary);
            background: var(--table-hover);
        }
        
        .multi-select-button span:first-child {
            flex: 1;
            font-size: 0.9em;
            font-weight: 500;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .multi-select-button::after {
            content: '▼';
            font-size: 0.7em;
            transition: transform 0.2s ease;
            margin-left: 8px;
            flex-shrink: 0;
        }
        
        .multi-select-wrapper.open .multi-select-button::after {
            transform: rotate(180deg);
        }
        
        .multi-select-dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            min-width: 200px;
            width: max-content;
            max-width: 300px;
            margin-top: 4px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 6px;
            box-shadow: var(--shadow-md);
            z-index: 1000;
            max-height: 200px;
            overflow-y: auto;
            display: none;
        }
        
        .multi-select-wrapper.open .multi-select-dropdown {
            display: block;
        }
        
        .multi-select-option {
            padding: 10px 14px;
            display: flex;
            align-items: center;
            gap: 10px;
            cursor: pointer;
            transition: background 0.2s ease;
            min-height: 38px;
            white-space: nowrap;
        }
        
        .multi-select-option:hover {
            background: var(--table-hover);
        }
        
        .multi-select-option input[type="checkbox"] {
            cursor: pointer;
            width: 18px;
            height: 18px;
            flex-shrink: 0;
        }
        
        .multi-select-option label {
            cursor: pointer;
            flex: 1;
            font-weight: normal;
            text-transform: none;
            letter-spacing: normal;
            font-size: 0.9em;
            margin: 0;
            line-height: 1.4;
            white-space: nowrap;
        }
        
        .multi-select-selected-count {
            font-size: 0.8em;
            color: var(--accent-primary);
            font-weight: 600;
            margin-left: 8px;
            flex-shrink: 0;
        }

        .filter-group select,
        .filter-group input {
            padding: 8px 12px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 0.9em;
            background: var(--bg-secondary);
            color: var(--text-primary);
            transition: all 0.2s ease;
        }
        
        .filter-group select:focus,
        .filter-group input:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 3px rgba(var(--accent-primary), 0.1);
        }

        .editable {
            cursor: pointer;
            position: relative;
        }
        
        /* Colonna Hotel bloccata (non modificabile) */
        .hotel-cell {
            cursor: not-allowed;
            background: var(--bg-secondary);
            opacity: 0.7;
            user-select: none;
            pointer-events: none;
            font-weight: 500;
            color: var(--text-secondary);
        }
        
        .hotel-cell:hover {
            background: var(--bg-secondary);
            opacity: 0.8;
        }
        
        [data-theme="dark"] .hotel-cell {
            background: rgba(184, 212, 184, 0.1);
            opacity: 0.8;
        }

        .editable:hover {
            background: var(--color-editable-hover) !important;
        }

        .editable.editing {
            padding: 0 !important;
        }

        .editable input,
        .editable textarea {
            width: 100%;
            border: 2px solid #006100;
            padding: 8px;
            font-size: inherit;
            font-family: inherit;
            border-radius: 4px;
            user-select: text;
            -webkit-user-select: text;
            -moz-user-select: text;
            -ms-user-select: text;
        }

        .editable textarea {
            min-height: 60px;
            resize: vertical;
        }

        /* Azioni riga */
        .row-action {
            text-align: center;
            white-space: nowrap;
        }
        /* Stile per righe selezionate per cancellazione */
        tr.row-selected-for-deletion {
            background-color: rgba(217, 83, 79, 0.15) !important;
            outline: 2px solid #d9534f;
            outline-offset: -2px;
        }
        
        [data-theme="dark"] tr.row-selected-for-deletion {
            background-color: rgba(217, 83, 79, 0.25) !important;
            outline-color: #ff6b6b;
        }
        
        .btn-row-delete,
        .btn-row-history {
            background: transparent;
            color: #888;
            padding: 4px 8px;
            border: none;
            cursor: pointer;
            font-size: 1em;
            opacity: 0.6;
            transition: opacity 0.2s ease;
        }
        .btn-row-delete:hover {
            opacity: 1;
            color: #666;
        }
        .btn-row-history { 
            background: #1f6f8b;
            color: #fff;
            border-radius: 6px;
            border: 1px solid rgba(255,255,255,0.18);
        }
        .btn-row-history:hover {
            filter: brightness(1.07);
        }
        
        /* Stile per colonna Pareggio */
        .pareggio-cell {
            text-align: center !important;
            vertical-align: middle;
            min-width: 80px;
            padding: 8px !important;
        }
        
        .pareggio-link {
            cursor: pointer;
            color: var(--portal-primary);
            font-weight: bold;
            font-size: 1.1em;
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            transition: all 0.2s ease;
            text-decoration: none;
        }
        
        .pareggio-link:hover {
            background-color: var(--table-hover);
            transform: scale(1.1);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        }
        
        .pareggio-empty {
            color: var(--text-secondary);
            opacity: 0.3;
            font-size: 0.9em;
        }
        
        /* Pareggi numero (⛳️ #X) usa colori portale */
        .pareggio-numero {
            color: var(--portal-primary);
        }
        
        [data-theme="dark"] .pareggio-link {
            color: var(--portal-tertiary);
        }
        
        [data-theme="dark"] .pareggio-link:hover {
            background-color: var(--table-hover);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        }
        
        [data-theme="dark"] .pareggio-empty {
            color: #889888;
        }
        
        /* Stile per ID link (element-id-link) */
        .element-id-link {
            cursor: pointer;
            color: var(--portal-primary);
            font-weight: bold;
            font-size: 0.9em;
            display: inline-block;
            padding: 2px 6px;
            margin-left: 6px;
            border-radius: 4px;
            transition: all 0.2s ease;
            text-decoration: none;
            background: rgba(var(--portal-primary-rgb, 46, 125, 50), 0.1);
        }
        
        .element-id-link:hover {
            background-color: var(--table-hover);
            transform: scale(1.05);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        }
        
        [data-theme="dark"] .element-id-link {
            color: var(--portal-tertiary);
            background: rgba(var(--portal-tertiary-rgb, 67, 160, 71), 0.15);
        }
        
        [data-theme="dark"] .element-id-link:hover {
            background-color: var(--table-hover);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        }
        
        /* Highlight temporaneo per righe quando si clicca su ID */
        .element-highlight {
            animation: highlightPulse 3s ease-out;
            outline: 3px solid var(--portal-primary);
            outline-offset: -3px;
        }
        
        @keyframes highlightPulse {
            0% {
                outline-color: var(--portal-primary);
                background-color: rgba(var(--portal-primary-rgb, 46, 125, 50), 0.2);
            }
            50% {
                outline-color: var(--portal-secondary);
                background-color: rgba(var(--portal-secondary-rgb, 56, 142, 60), 0.15);
            }
            100% {
                outline-color: transparent;
                background-color: transparent;
            }
        }
        
        [data-theme="dark"] .element-highlight {
            animation: highlightPulseDark 3s ease-out;
        }
        
        @keyframes highlightPulseDark {
            0% {
                outline-color: var(--portal-tertiary);
                background-color: rgba(var(--portal-tertiary-rgb, 67, 160, 71), 0.25);
            }
            50% {
                outline-color: var(--portal-secondary);
                background-color: rgba(var(--portal-secondary-rgb, 56, 142, 60), 0.2);
            }
            100% {
                outline-color: transparent;
                background-color: transparent;
            }
        }
        
        /* Stile per celle Sig. Sergio selezionate - SOLO la cella, non tutta la riga */
        /* Stile per celle Fatto selezionate - SOLO la cella, non tutta la riga */
        .fatto-cell.selected {
            background: var(--color-editable-hover) !important;
            border: 2px solid var(--accent-primary) !important;
            position: relative;
            z-index: 10;
        }
        
        .sig-sergio-cell.selected {
            background: var(--color-editable-hover) !important;
            border: 2px solid var(--accent-primary) !important;
            position: relative;
            z-index: 10;
        }
        
        /* Previeni selezione testo durante drag su celle Fatto e Sig. Sergio */
        /* Previeni selezione testo su righe con celle Sig. Sergio selezionate (JavaScript gestisce questo) */
        .prevent-text-selection {
            user-select: none !important;
            -webkit-user-select: none !important;
            -moz-user-select: none !important;
            -ms-user-select: none !important;
        }
        
        /* Riga evidenziata quando Sig. Sergio = "sì" - escludi Stagione, Hotel, Note, Pareggio */
        /* Colore cella Fatto quando contiene "sì" (solo cella, non riga) */
        tbody tr td.fatto-cell[data-fatto="sì"],
        tbody tr[data-fatto="sì"] td.fatto-cell {
            background: var(--color-sig-sergio-done) !important;
        }
        
        /* CAPARRA: evidenzia TUTTA LA RIGA quando Sig. Sergio = "sì" */
        tbody tr[data-sig-sergio="sì"] td:nth-child(1),  /* Data Conferma */
        tbody tr[data-sig-sergio="sì"] td:nth-child(2),  /* Data Inserimento */
        tbody tr[data-sig-sergio="sì"] td:nth-child(4),  /* Nome (dopo Pareggio) */
        tbody tr[data-sig-sergio="sì"] td:nth-child(5),  /* Check Out */
        tbody tr[data-sig-sergio="sì"] td:nth-child(6),  /* Canale */
        tbody tr[data-sig-sergio="sì"] td:nth-child(7),  /* Totale */
        tbody tr[data-sig-sergio="sì"] td:nth-child(8),  /* Circuito */
        tbody tr[data-sig-sergio="sì"] td:nth-child(9),  /* Numero */
        tbody tr[data-sig-sergio="sì"] td:nth-child(10) { /* Sig. Sergio */
            background: var(--color-sig-sergio-done) !important;
        }
        
        /* GIR: evidenzia TUTTA LA RIGA quando Sig. Sergio = "sì" */
        #girTable tbody tr[data-sig-sergio="sì"] td:nth-child(1),  /* Data */
        #girTable tbody tr[data-sig-sergio="sì"] td:nth-child(3),  /* Nome (dopo Pareggio) */
        #girTable tbody tr[data-sig-sergio="sì"] td:nth-child(4),  /* Totale */
        #girTable tbody tr[data-sig-sergio="sì"] td:nth-child(5),  /* Somma */
        #girTable tbody tr[data-sig-sergio="sì"] td:nth-child(6) { /* Sig. Sergio */
            background: var(--color-sig-sergio-done) !important;
        }

        /* Color coding per GIR FEST e FE: solo colonna Totale */
        #girTable tbody tr[data-tipo-gir="FEST"] td:nth-child(4) { /* Colonna Totale */
            background: rgba(255, 152, 0, 0.2) !important; /* Arancione per FEST */
            font-weight: 600;
            border-left: 3px solid #ff9800;
        }

        #girTable tbody tr[data-tipo-gir="FE"] td:nth-child(4) { /* Colonna Totale */
            background: rgba(156, 39, 176, 0.2) !important; /* Viola per FE */
            font-weight: 600;
            border-left: 3px solid #9c27b0;
        }

        [data-theme="dark"] #girTable tbody tr[data-tipo-gir="FEST"] td:nth-child(4) {
            background: rgba(255, 152, 0, 0.3) !important;
        }

        [data-theme="dark"] #girTable tbody tr[data-tipo-gir="FE"] td:nth-child(4) {
            background: rgba(156, 39, 176, 0.3) !important;
        }

        /* Selezione e somma totale */
        .table-container {
            position: relative;
        }

        .total-summary {
            position: fixed;
            bottom: 100px;  /* Più in alto, sopra il footer */
            right: 40px;    /* Leggermente più a sinistra */
            background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
            color: white;
            padding: 15px 25px;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(67, 160, 71, 0.4);
            font-size: 1.1em;
            font-weight: 600;
            z-index: 1000;
            display: none;
            min-width: 200px;
            text-align: center;
        }

        .total-summary.visible {
            display: block;
        }

        .total-summary .label {
            font-size: 0.9em;
            opacity: 0.9;
            margin-bottom: 5px;
        }

        .total-summary .value {
            font-size: 1.3em;
        }

        /* Selezione celle */
        td.selectable {
            cursor: pointer;
        }

        /* Selezione celle Totale - deve sovrascrivere il blu fisso */
        tbody tr td.selectable.selected,
        #girTable tbody tr td.selectable.selected {
            background: var(--color-selected) !important;
            font-weight: bold !important;
            border: 2px solid var(--color-selected-border) !important;
        }
        
        /* Evidenziazione celle Data quando corrispondente Totale è selezionato */
        tbody tr td.date-highlighted {
            background: var(--color-selected) !important;
            font-weight: bold !important;
            border: 2px solid var(--color-selected-border) !important;
        }

        td.selectable:hover {
            background: var(--color-editable-hover) !important;
        }
        
        /* Colonna Totale sempre evidenziata - SEMPRE, non cambia per canale */
        tbody tr td:nth-child(6) {
            background: var(--color-totale-bg) !important;
            color: var(--color-totale-text) !important;
            font-weight: 500;
        }
        
        /* Evidenzia celle con virgola (errore) */
        tbody tr td:nth-child(6)[data-has-comma="true"] {
            background: var(--color-error) !important;
            color: var(--color-error-text) !important;
        }
        
        /* Colonna Totale GIR sempre evidenziata */
        #girTable tbody tr td:nth-child(3) {
            background: var(--color-totale-bg) !important;
            color: var(--color-totale-text) !important;
            font-weight: 500;
        }
        
        /* ========================================
           FOOTER FISSO - Tabs e Stats
           ======================================== */
        .footer-fixed {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--bg-secondary);
            border-top: 1px solid var(--border-color);
            box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            transition: all 0.3s ease;
            display: none; /* Hidden initially */
        }
        
        .footer-content {
            max-width: 1600px;
            margin: 0 auto;
            padding: 14px 40px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 30px;
        }
        
        .footer-tabs {
            display: flex;
            gap: 6px;
            flex-wrap: wrap;
            flex: 1;
            min-width: 0;
        }
        
        .footer-tab {
            background: transparent;
            color: var(--text-secondary);
            border: none;
            padding: 10px 18px;
            font-size: 0.9em;
            font-weight: 500;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            white-space: nowrap;
            flex-shrink: 0;
        }
        
        .footer-tab:hover {
            background: var(--table-hover);
            color: var(--text-primary);
            transform: translateY(-1px);
        }
        
        .footer-tab.active {
            background: var(--portal-primary);
            color: var(--text-inverse);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        }
        
        /* Footer in dark mode: verde monocromatico */
        [data-theme="dark"] .footer-fixed {
            background: #1a2a1a;
            border-top: 2px solid #4CAF50;
            box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.8), 0 0 20px rgba(76, 175, 80, 0.15);
        }
        
        [data-theme="dark"] .footer-tab {
            color: #889888;
        }
        
        [data-theme="dark"] .footer-tab:hover {
            background: #c8e4c8;
            color: #1a2a1a;
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.6);
        }
        
        [data-theme="dark"] .footer-tab.active {
            background: #b8d4b8;
            color: #1a2a1a;
            box-shadow: 0 0 15px rgba(184, 212, 184, 0.4);
        }
        
        .footer-stats {
            display: flex;
            gap: 28px;
            align-items: center;
            flex-shrink: 0;
        }
        
        .footer-stat {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            min-width: 60px;
        }
        
        .stat-value {
            font-size: 1.4em;
            font-weight: 700;
            color: var(--portal-primary);
            line-height: 1;
            letter-spacing: -0.5px;
        }
        
        .stat-label {
            font-size: 0.75em;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.8px;
            margin-top: 4px;
            font-weight: 500;
        }
        
        /* Ticket button nelle stats - stile migliorato */
        .footer-stats .footer-tab {
            margin-left: 32px;
            padding: 10px 22px;
            font-weight: 600;
            border-left: 2px solid var(--border-color);
            padding-left: 28px;
        }
        
        .footer-stats .footer-tab:hover {
            border-left-color: var(--portal-primary);
        }
        
        .footer-stats .footer-tab.active {
            border-left-color: var(--portal-primary);
        }
        
        /* Stats in dark mode: verde chiaro */
        [data-theme="dark"] .stat-value {
            color: #88dd88;
            text-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
        }
        
        [data-theme="dark"] .stat-label {
            color: #889888;
        }
        
        [data-theme="dark"] .footer-stats .footer-tab {
            border-left-color: #4CAF50;
        }
        
        [data-theme="dark"] .footer-stats .footer-tab:hover {
            border-left-color: #b8d4b8;
        }
        
        [data-theme="dark"] .footer-stats .footer-tab.active {
            border-left-color: #b8d4b8;
        }
        
        /* Aggiungi padding al body per il footer */
        body {
            padding-bottom: 70px;
        }
        
        /* ========================================
           STILI PAREGGI PARKING
           ======================================== */
        .pareggi-container {
            padding: 20px;
            max-width: 1400px;
            margin: 0 auto;
        }
        
        .pareggi-pronti-section {
            margin-bottom: 30px;
        }
        
        .pareggi-pronti-section h2 {
            color: var(--text-primary);
            margin-bottom: 10px;
        }
        
        .pareggi-list {
            margin-top: 20px;
        }
        
        .pareggi-list h3 {
            color: var(--text-primary);
            margin-bottom: 15px;
        }
        
        .pareggi-table {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .pareggio-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 12px 15px;
            transition: all 0.3s ease;
        }
        
        .pareggio-row:hover {
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        }
        
        .pareggio-row.parking-row {
            border-left: 3px solid #ff9800;
        }
        
        .pareggio-dare,
        .pareggio-avere {
            padding: 10px;
            background: var(--bg-primary);
            border-radius: 6px;
        }
        
        .pareggio-header {
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 8px;
            font-size: 0.9em;
        }
        
        .pareggio-numero {
            font-size: 0.9em;
            font-weight: 600;
            color: var(--portal-primary);
            margin-left: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: inline-block;
            padding: 2px 4px;
            border-radius: 4px;
        }
        
        .pareggio-numero:hover {
            background: var(--table-hover);
            transform: scale(1.05);
        }
        
        .pareggio-link-icon {
            cursor: pointer !important;
            font-size: 0.95em;
            color: var(--accent-primary);
            transition: all 0.2s ease;
            padding: 2px 4px;
            border-radius: 4px;
            text-decoration: none;
            font-weight: 600;
            display: inline-block;
            user-select: none !important;
            -webkit-user-select: none !important;
            -moz-user-select: none !important;
            -ms-user-select: none !important;
        }
        
        .pareggio-link-icon:hover {
            background: var(--table-hover);
            transform: scale(1.05);
            cursor: pointer !important;
        }
        
        .pareggio-item {
            color: var(--text-primary);
            font-size: 0.9em;
            line-height: 1.4;
        }
        
        .pareggio-item strong {
            display: block;
            margin-bottom: 4px;
        }
        
        .pareggio-item strong {
            display: block;
            margin-bottom: 5px;
        }
        
        .pareggio-amount {
            font-weight: 600;
            font-size: 1.1em;
        }
        
        .pareggio-confidence {
            margin-top: 10px;
            padding: 8px 12px;
            border-radius: 6px;
            font-size: 0.85em;
            font-weight: 500;
            text-align: center;
        }
        
        .pareggio-confidence.parking-confidence {
            background: rgba(255, 152, 0, 0.1);
            color: #ff9800;
            border: 1px solid rgba(255, 152, 0, 0.3);
        }
        
        .parking-actions {
            margin-top: 10px;
            display: flex;
            gap: 8px;
        }
        
        .parking-actions button {
            flex: 1;
            transition: all 0.2s ease;
        }
        
        .parking-actions button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }
        
        .status-card {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
        }
        
        .status-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 15px;
        }
        
        .status-details {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        
        .status-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid var(--border-color);
        }
        
        .status-item:last-child {
            border-bottom: none;
        }
        
        .badge {
            background: var(--accent-primary);
            color: white;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.85em;
            font-weight: 600;
        }
        
        .badge-small {
            background: rgba(255, 255, 255, 0.2);
            color: inherit;
            padding: 2px 6px;
            border-radius: 8px;
            font-size: 0.75em;
            margin-left: 6px;
        }
        
        .status-card.status-in-corso {
            border-color: #ff9800;
            background: rgba(255, 152, 0, 0.05);
        }
        
        .status-card.status-completato {
            border-color: #4caf50;
            background: rgba(76, 175, 80, 0.05);
        }
        
        .status-card.status-errore {
            border-color: #d32f2f;
            background: rgba(211, 47, 47, 0.05);
        }
        
        .btn-refresh,
        .btn-export {
            background: transparent;
            border: 1px solid var(--border-color);
            padding: 6px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.9em;
            transition: all 0.2s ease;
        }
        
        .btn-refresh:hover,
        .btn-export:hover {
            background: var(--table-hover);
        }
        
        /* ========================================
           NOTIFICHE TOAST - USER FRIENDLY
           ======================================== */
        .notification {
            position: fixed;
            top: 80px;
            right: 30px;
            background: white;
            padding: 16px 24px;
            border-radius: 12px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
            display: flex;
            align-items: center;
            gap: 12px;
            z-index: 10000;
            opacity: 0;
            transform: translateX(400px);
            transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
            max-width: 400px;
            border-left: 4px solid #4CAF50;
        }
        
        .notification.show {
            opacity: 1;
            transform: translateX(0);
        }
        
        .notification-content {
            display: flex;
            align-items: center;
            gap: 12px;
        }
        
        .notification-icon {
            font-size: 1.5em;
            flex-shrink: 0;
        }
        
        .notification-message {
            font-size: 0.95em;
            color: #212121;
            line-height: 1.4;
        }
        
        .notification-success {
            border-left-color: #4CAF50;
        }
        
        .notification-info {
            border-left-color: #2196F3;
        }
        
        .notification-warning {
            border-left-color: #FF9800;
        }
        
        /* Dark mode notifiche - Migliorato contrasto */
        [data-theme="dark"] .notification {
            background: rgba(30, 30, 30, 0.98);
            border-left-color: var(--accent-primary, #4CAF50);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px rgba(76, 175, 80, 0.2);
        }
        
        [data-theme="dark"] .notification-message {
            color: #f0f0f0;
            font-weight: 500;
        }
        
        /* Migliora contrasto notifiche per tutti i tipi */
        .notification-success {
            background: #e8f5e9;
            border-left-color: #4caf50;
        }
        
        .notification-success .notification-message {
            color: #1b5e20;
            font-weight: 500;
        }
        
        [data-theme="dark"] .notification-success {
            background: rgba(76, 175, 80, 0.25);
            border-left-color: #4caf50;
        }
        
        [data-theme="dark"] .notification-success .notification-message {
            color: #a5d6a7;
        }
        
        .notification-info {
            background: #e3f2fd;
            border-left-color: #2196f3;
        }
        
        .notification-info .notification-message {
            color: #0d47a1;
            font-weight: 500;
        }
        
        [data-theme="dark"] .notification-info {
            background: rgba(33, 150, 243, 0.25);
            border-left-color: #2196f3;
        }
        
        [data-theme="dark"] .notification-info .notification-message {
            color: #90caf9;
        }
        
        .notification-warning {
            background: #fff3e0;
            border-left-color: #ff9800;
        }
        
        .notification-warning .notification-message {
            color: #e65100;
            font-weight: 500;
        }
        
        [data-theme="dark"] .notification-warning {
            background: rgba(255, 152, 0, 0.25);
            border-left-color: #ff9800;
        }
        
        [data-theme="dark"] .notification-warning .notification-message {
            color: #ffcc80;
        }
        
        .notification-error {
            background: #ffebee;
            border-left-color: #f44336;
        }
        
        .notification-error .notification-message {
            color: #b71c1c;
            font-weight: 500;
        }
        
        [data-theme="dark"] .notification-error {
            background: rgba(244, 67, 54, 0.25);
            border-left-color: #f44336;
        }
        
        [data-theme="dark"] .notification-error .notification-message {
            color: #ef9a9a;
        }
        
        /* Pulsante Ricarica Dati - Meno visibile (Opzione B) */
        .btn-header-secondary {
            opacity: 0.6;
            font-size: 0.85em;
        }
        
        .btn-header-secondary:hover {
            opacity: 1;
        }
        
        /* ========================================
           MODALITÀ EDITORE
           ======================================== */
        .btn-editor {
            position: relative;
            padding-right: 18px;
        }
        
        .btn-editor .editor-status {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            margin-left: 8px;
            padding: 3px 8px;
            border-radius: 999px;
            font-size: 0.75em;
            background: rgba(255, 255, 255, 0.2);
        }
        
        .btn-editor.active {
            background: rgba(255, 255, 255, 0.35);
            color: #0a1a0a;
            border-color: rgba(255, 255, 255, 0.6);
            box-shadow: 0 0 20px rgba(184, 212, 184, 0.5);
        }
        
        [data-theme="dark"] .btn-editor.active {
            background: #b8d4b8;
        }
        
        .editor-indicator {
            display: none;
            margin: 0 0 16px 0;
            padding: 10px 16px;
            border-radius: 10px;
            background: rgba(76, 175, 80, 0.15);
            color: var(--text-primary);
            border: 1px solid rgba(76, 175, 80, 0.35);
            font-size: 0.9em;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        body.editor-mode-active .editor-indicator {
            display: flex;
        }
        
        body.editor-mode-active .table-container {
            box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
        }
        
        body.editor-mode-active .editable:not(.editing) {
            cursor: text;
            transition: box-shadow 0.2s ease, background 0.2s ease;
        }
        
        body.editor-mode-active .editable:not(.editing):hover {
            box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.6);
            background: rgba(76, 175, 80, 0.1);
        }
        
        body:not(.editor-mode-active) .editable {
            cursor: default;
        }
        
        .editable {
            position: relative;
        }
        
        .editor-input {
            width: 100%;
            font: inherit;
            color: inherit;
            background: rgba(255, 255, 255, 0.15);
            border: 1px solid rgba(76, 175, 80, 0.4);
            border-radius: 6px;
            padding: 6px 8px;
            box-sizing: border-box;
        }
        
        [data-theme="dark"] .editor-input {
            background: rgba(40, 60, 40, 0.6);
            border-color: rgba(184, 212, 184, 0.5);
        }
        
        .editor-input:focus {
            outline: 2px solid rgba(76, 175, 80, 0.6);
        }
        
        .editor-input.input-error {
            border-color: #d9534f;
            outline-color: #d9534f;
        }
        
        .editable.saving::after {
            content: '';
            position: absolute;
            top: 50%;
            right: 10px;
            width: 12px;
            height: 12px;
            border: 2px solid rgba(76, 175, 80, 0.6);
            border-top-color: transparent;
            border-radius: 50%;
            animation: editor-spin 0.8s linear infinite;
            transform: translateY(-50%);
        }
        
        @keyframes editor-spin {
            to {
                transform: translateY(-50%) rotate(360deg);
            }
        }
        
        .edit-success {
            animation: edit-success-pulse 1.2s ease;
        }
        
        .edit-error {
            animation: edit-error-pulse 1.2s ease;
        }
        
        @keyframes edit-success-pulse {
            0% { background: rgba(76, 175, 80, 0.25); }
            100% { background: transparent; }
        }
        
        @keyframes edit-error-pulse {
            0% { background: rgba(217, 83, 79, 0.25); }
            100% { background: transparent; }
        }

        /* Selezione e feedback bulk stile Excel */
        .editable-selected {
            outline: 2px solid #4caf50;
            outline-offset: -2px;
            background: rgba(76, 175, 80, 0.12);
        }
        .bulk-applied {
            animation: edit-success-pulse 0.9s ease;
        }

        /* Modale cronologia */
        .history-modal,
        .modal {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 10000;
        }
        
        .modal-content {
            background: var(--bg-secondary, #ffffff);
            color: var(--text-primary, #212121);
            border-radius: 12px;
            box-shadow: var(--shadow-lg);
            max-width: 90vw;
            max-height: 90vh;
            overflow: auto;
            display: flex;
            flex-direction: column;
        }
        
        /* Migliora contrasto per dark mode */
        [data-theme="dark"] .modal-content {
            background: #1e1e1e;
            color: #e0e0e0;
        }
        
        .modal-header {
            padding: 20px;
            border-bottom: 1px solid var(--border-color, #e0e0e0);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .modal-header h2 {
            margin: 0;
            color: var(--portal-primary, #2e7d32);
            font-weight: 600;
        }
        
        /* Migliora contrasto titolo in dark mode */
        [data-theme="dark"] .modal-header h2 {
            color: #4caf50;
        }
        
        .modal-close {
            font-size: 28px;
            font-weight: bold;
            color: var(--text-secondary, #757575);
            cursor: pointer;
            line-height: 1;
            transition: color 0.2s ease;
        }
        
        .modal-close:hover {
            color: var(--text-primary, #212121);
        }
        
        /* Migliora contrasto close button in dark mode */
        [data-theme="dark"] .modal-close {
            color: #b0b0b0;
        }
        
        [data-theme="dark"] .modal-close:hover {
            color: #ffffff;
        }
        
        .modal-body {
            padding: 20px;
            flex: 1;
            overflow-y: auto;
            color: var(--text-primary, #212121);
        }
        
        /* Migliora contrasto body in dark mode */
        [data-theme="dark"] .modal-body {
            color: #e8f5e9; /* Verde chiaro per leggibilità */
            background: #1e1e1e;
        }
        
        .modal-body p {
            color: inherit;
            margin: 0 0 12px 0;
            line-height: 1.6;
        }
        
        /* Migliora contrasto per popup contabilizzazione in dark mode */
        [data-theme="dark"] #contabilizzataConfirmModal .modal-body {
            color: #e8f5e9;
        }
        
        [data-theme="dark"] #contabilizzataConfirmModal .modal-body p {
            color: #e8f5e9;
            font-weight: 500;
        }
        
        [data-theme="dark"] #contabilizzataConfirmModal .modal-body div[style*="background"] {
            background: rgba(255, 193, 7, 0.2) !important;
            border-left-color: #ffc107 !important;
        }
        
        [data-theme="dark"] #contabilizzataConfirmModal .modal-body div[style*="background"] p {
            color: #fff9c4 !important; /* Giallo chiaro per leggibilità */
            font-weight: 600;
        }
        
        .modal-footer {
            padding: 15px 20px;
            border-top: 1px solid var(--border-color, #e0e0e0);
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }
        
        /* Stili bottoni modal */
        .modal-footer .btn {
            padding: 10px 20px;
            border-radius: 6px;
            border: none;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.2s ease;
        }
        
        .modal-footer .btn-primary {
            background: var(--portal-primary, #2e7d32);
            color: white;
        }
        
        .modal-footer .btn-primary:hover {
            background: var(--portal-secondary, #388e3c);
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        
        .modal-footer .btn-secondary {
            background: #757575;
            color: white;
        }
        
        .modal-footer .btn-secondary:hover {
            background: #616161;
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        .history-modal .panel {
            width: 680px;
            max-height: 80vh;
            overflow: auto;
            background: var(--card-bg, #112416);
            color: var(--text, #e7f5ec);
            border-radius: 10px;
            box-shadow: 0 10px 24px rgba(0,0,0,0.35);
            padding: 16px;
        }
        .history-modal .panel h3 {
            margin: 0 0 8px 0;
        }
        .history-list {
            display: grid;
            grid-template-columns: 1fr auto auto;
            gap: 8px;
            align-items: center;
        }
        .history-item {
            padding: 8px;
            border-radius: 8px;
            background: rgba(255,255,255,0.06);
        }
        .btn-restore {
            padding: 6px 10px;
            border-radius: 6px;
            background: #2b8a3e;
            color: white;
            cursor: pointer;
            border: none;
        }
        .btn-restore:hover { filter: brightness(1.05); }
        .btn-close-modal {
            float: right;
            background: transparent;
            border: none;
            color: inherit;
            font-size: 18px;
            cursor: pointer;
        }
        
        /* Stili Modal Suggerimenti */
        .suggestion-item {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 10px;
            padding: 15px;
            transition: all 0.2s ease;
        }
        
        .suggestion-item:hover {
            border-color: var(--accent-primary);
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .suggestion-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }
        
        .suggestion-score {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.9em;
        }
        
        .score-high {
            background: rgba(76, 175, 80, 0.2);
            color: #4caf50;
        }
        
        .score-medium {
            background: rgba(255, 152, 0, 0.2);
            color: #ff9800;
        }
        
        .score-low {
            background: rgba(244, 67, 54, 0.2);
            color: #f44336;
        }
        
        .suggestion-details {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-bottom: 12px;
        }
        
        .suggestion-caparra,
        .suggestion-gir {
            padding: 12px;
            background: rgba(0,0,0,0.05);
            border-radius: 8px;
            border-left: 3px solid var(--accent-primary);
        }
        
        .suggestion-caparra {
            border-left-color: #c62828;
        }
        
        .suggestion-gir {
            border-left-color: var(--portal-primary);
        }
        
        .suggestion-item-name {
            font-weight: 600;
            margin-bottom: 4px;
            color: #1a2a1a;
        }
        
        .suggestion-item-details {
            font-size: 0.85em;
            color: #1a2a1a;
            margin-top: 4px;
        }
        
        .suggestion-item-details strong {
            color: #1a2a1a;
        }
        
        .suggestion-metrics {
            display: flex;
            gap: 12px;
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid var(--border-color);
            font-size: 0.85em;
            color: #1a2a1a;
        }
        
        .suggestion-metric {
            display: flex;
            align-items: center;
            gap: 4px;
            color: #1a2a1a;
        }
        
        .suggestion-metric strong {
            color: #1a2a1a;
            font-weight: 600;
        }
        
        .suggestion-actions {
            display: flex;
            gap: 8px;
            justify-content: flex-end;
            margin-top: 12px;
        }

        /* Stili Modal Magic Match - Sovrascrive history-modal per avere sfondo chiaro */
        #magicMatchModal .panel,
        #magicMatchModal .magic-match-panel {
            background: var(--bg-secondary) !important;
            color: var(--text-primary) !important;
        }
        
        #magicMatchModal .panel h3,
        #magicMatchModal .magic-match-panel h3 {
            color: var(--text-primary) !important;
        }
        
        #magicMatchModal .btn-close-modal {
            color: var(--text-primary) !important;
        }
        
        .magic-match-item {
            background: var(--bg-secondary);
            border: 2px solid var(--border-color);
            border-radius: 10px;
            padding: 15px;
            margin-bottom: 15px;
            transition: all 0.2s ease;
        }
        
        .magic-match-item:hover {
            border-color: var(--accent-primary);
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        
        .magic-match-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
        }
        
        .magic-match-pareggio {
            font-weight: 600;
            color: var(--text-primary);
            font-size: 1em;
        }
        
        .magic-match-score {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            border-radius: 20px;
            font-weight: 600;
            font-size: 0.9em;
            background: rgba(76, 175, 80, 0.2);
            color: #2e7d32;
        }
        
        .magic-match-details {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 15px;
            margin-bottom: 12px;
        }
        
        .magic-match-caparra,
        .magic-match-gir {
            padding: 12px;
            background: rgba(0,0,0,0.05);
            border-radius: 8px;
            border-left: 3px solid var(--accent-primary);
        }
        
        .magic-match-caparra {
            border-left-color: #c62828;
        }
        
        .magic-match-gir {
            border-left-color: var(--portal-primary);
        }
        
        .magic-match-item-name {
            font-weight: 600;
            margin-bottom: 4px;
            color: var(--text-primary);
        }
        
        .magic-match-item-details {
            font-size: 0.85em;
            color: var(--text-primary);
            margin-top: 4px;
        }
        
        .magic-match-item-details strong {
            color: var(--text-primary);
        }
        
        .magic-match-amount {
            font-weight: 600;
            font-size: 1em;
            color: var(--text-primary);
            margin-top: 8px;
        }
        
        .magic-match-summary {
            color: var(--text-primary) !important;
            font-size: 0.95em;
            line-height: 1.6;
        }
        
        .magic-match-summary strong {
            color: var(--text-primary) !important;
            font-weight: 600;
        }
        
        .magic-match-summary .summary-success {
            color: #2e7d32;
            font-weight: 600;
        }
        
        .magic-match-summary .summary-warning {
            color: #e65100;
            font-weight: 600;
        }
        
        /* Assicura che tutti i testi nel modal Magic Match siano leggibili */
        #magicMatchModal .magic-match-pareggio,
        #magicMatchModal .magic-match-item-name,
        #magicMatchModal .magic-match-item-details,
        #magicMatchModal .magic-match-item-details strong,
        #magicMatchModal .magic-match-amount {
            color: var(--text-primary) !important;
        }

        /* Stili Modal Login */
        #loginModal .login-panel {
            background: var(--bg-secondary) !important;
            color: var(--text-primary) !important;
        }
        
        #loginModal .login-panel h3 {
            color: var(--text-primary) !important;
        }
        
        #loginModal #loginCodeInput:focus {
            outline: none;
            border-color: var(--accent-primary);
            box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
        }
        
        .btn-suggestion {
            padding: 8px 16px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 500;
            font-size: 0.9em;
            transition: all 0.2s ease;
        }
        
        .btn-approve {
            background: #4caf50;
            color: white;
        }
        
        .btn-approve:hover {
            background: #45a049;
        }
        
        .btn-dismiss {
            background: #666;
            color: white;
        }
        
        .btn-dismiss:hover {
            background: #555;
        }
