        :root {
            --bg-primary: #0a0a0f; --bg-secondary: #12121a; --bg-card: #1a1a24; --bg-hover: #252532;
            --bg-tertiary: #22222e;
            --text-primary: #ffffff; --text-secondary: #a0a0b0; --text-muted: #6b6b7b;
            --border-color: #2a2a3a; --accent-green: #22c55e; --accent-blue: #3b82f6;
            --accent-red: #ef4444; --accent-orange: #f59e0b; --accent-purple: #8b5cf6;
            --accent-cyan: #06b6d4; --accent-yellow: #eab308; --radius-sm: 8px; --radius-md: 12px;
        }
        
        /* Tema Chiaro */
        [data-theme="light"] {
            --bg-primary: #f5f5f7; --bg-secondary: #ffffff; --bg-card: #ffffff; --bg-hover: #f0f0f5;
            --bg-tertiary: #e8e8ed;
            --text-primary: #1a1a2e; --text-secondary: #4a4a5a; --text-muted: #7a7a8a;
            --border-color: #d0d0da;
        }
        [data-theme="light"] .header { background: #ffffff; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
        [data-theme="light"] .stat-card { box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
        [data-theme="light"] .modal { box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
        [data-theme="light"] input, [data-theme="light"] select:not(.modal-stato-select), [data-theme="light"] textarea { 
            background: #ffffff; border-color: #d0d0da; color: #1a1a2e; 
        }
        [data-theme="light"] input:focus, [data-theme="light"] select:not(.modal-stato-select):focus, [data-theme="light"] textarea:focus { 
            border-color: var(--accent-blue); 
        }
        [data-theme="light"] .table-container { background: #ffffff; }
        [data-theme="light"] .table-container tr:hover { background: #f8f8fc; }
        [data-theme="light"] .tabs-container { background: #ffffff; }
        [data-theme="light"] .tab-btn { background: #f0f0f5; color: #4a4a5a; }
        [data-theme="light"] .tab-btn.active { background: var(--accent-blue); color: white; }
        
        /* Flatpickr custom styles */
        .flatpickr-calendar {
            background: var(--bg-card) !important;
            border: 1px solid var(--border-color) !important;
            box-shadow: 0 8px 32px rgba(0,0,0,0.3) !important;
        }
        .flatpickr-day {
            color: var(--text-primary) !important;
        }
        .flatpickr-day:hover {
            background: var(--bg-hover) !important;
        }
        .flatpickr-day.selected {
            background: var(--accent-blue) !important;
            border-color: var(--accent-blue) !important;
        }
        .flatpickr-day.today {
            border-color: var(--accent-green) !important;
        }
        .flatpickr-months .flatpickr-month {
            background: var(--bg-secondary) !important;
            color: var(--text-primary) !important;
        }
        .flatpickr-current-month .flatpickr-monthDropdown-months {
            background: var(--bg-card) !important;
            color: var(--text-primary) !important;
        }
        .flatpickr-weekdays {
            background: var(--bg-secondary) !important;
        }
        .flatpickr-weekday {
            color: var(--text-muted) !important;
        }
        .flatpickr-time {
            background: var(--bg-card) !important;
            border-top: 1px solid var(--border-color) !important;
        }
        .flatpickr-time input {
            background: var(--bg-secondary) !important;
            color: var(--text-primary) !important;
        }
        .numInputWrapper span {
            border-color: var(--border-color) !important;
        }
        .numInputWrapper span:hover {
            background: var(--bg-hover) !important;
        }
        .flatpickr-prev-month, .flatpickr-next-month {
            fill: var(--text-primary) !important;
        }
        .flatpickr-prev-month:hover svg, .flatpickr-next-month:hover svg {
            fill: var(--accent-blue) !important;
        }
        
        /* ==================== STILI UNIFICATI DOCUMENTI ==================== */
        
        /* Nascondi frecce input number */
        input[type="number"]::-webkit-outer-spin-button,
        input[type="number"]::-webkit-inner-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        input[type="number"] {
            -moz-appearance: textfield;
        }
        
        /* Input numerici compatti */
        .input-num {
            text-align: right;
            font-family: 'JetBrains Mono', monospace;
            font-size: 0.8rem !important;
        }
        
        /* Input orario */
        .time-input {
            font-family: 'JetBrains Mono', monospace;
            font-size: 0.9rem;
            letter-spacing: 1px;
        }
        
        /* Pulsanti spostamento righe */
        .btn-move {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            color: var(--text-muted);
            padding: 0.1rem 0.25rem;
            font-size: 0.6rem;
            cursor: pointer;
            border-radius: 3px;
            line-height: 1;
        }
        .btn-move:hover:not(:disabled) {
            background: var(--accent-blue);
            color: white;
            border-color: var(--accent-blue);
        }
        .btn-move:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }
        
        /* Card Cliente Unificata */
        .cliente-card-unified {
            background: var(--bg-card);
            border: 2px solid var(--accent-blue);
            border-radius: var(--radius-md);
            padding: 1rem;
            margin-bottom: 1rem;
        }
        .cliente-card-unified .cliente-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.75rem;
            padding-bottom: 0.5rem;
            border-bottom: 1px solid var(--border-color);
        }
        .cliente-card-unified .cliente-nome {
            font-size: 1.1rem;
            font-weight: 700;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .cliente-card-unified .cliente-actions {
            display: flex;
            gap: 0.35rem;
        }
        .cliente-card-unified .cliente-actions .btn {
            padding: 0.3rem 0.5rem;
            font-size: 0.85rem;
        }
        .cliente-card-unified .cliente-dati {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.4rem 1.5rem;
            font-size: 0.85rem;
        }
        .cliente-card-unified .cliente-dati .dato-item {
            display: flex;
            align-items: center;
            gap: 0.4rem;
        }
        .cliente-card-unified .cliente-dati .dato-label {
            color: var(--text-muted);
            min-width: 50px;
        }
        .cliente-card-unified .cliente-dati .dato-value {
            font-weight: 600;
            color: var(--text-primary);
        }
        .cliente-card-unified .cliente-dati .dato-value.mancante {
            color: var(--accent-orange);
        }
        .cliente-card-unified .cliente-dati .dato-full {
            grid-column: 1 / -1;
        }
        .cliente-card-unified .cliente-warning {
            margin-top: 0.75rem;
            padding: 0.6rem 0.75rem;
            background: rgba(245, 158, 11, 0.15);
            border: 1px solid var(--accent-orange);
            border-radius: var(--radius-sm);
            font-size: 0.8rem;
            color: var(--accent-orange);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
        }
        
        /* Layout 2 colonne per interventi (desktop) */
        .int-layout-desktop {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }
        @media (min-width: 900px) {
            .int-layout-desktop {
                display: grid;
                grid-template-columns: 1fr 1fr;
                gap: 1.5rem;
                align-items: start;
            }
        }
        .int-col-cliente, .int-col-destra {
            min-width: 0;
        }
        .int-col-destra {
            background: var(--bg-tertiary);
            padding: 1rem;
            border-radius: var(--radius-md);
            border: 1px solid var(--border-color);
        }
        /* Grid data/ora intervento: 4 col desktop, 2 col mobile */
        .int-grid-datetime {
            grid-template-columns: 1fr 1fr 1fr 1fr !important;
        }
        @media (max-width: 768px) {
            .int-grid-datetime {
                grid-template-columns: 1fr 1fr !important;
            }
        }
        /* Customer results dropdown z-index per mobile */
        .customer-results {
            position: relative;
            z-index: 10;
        }
        
        /* Card indirizzo intervento */
        .indirizzo-card-int {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            padding: 0.6rem 0.75rem;
            cursor: pointer;
            transition: all 0.15s;
            position: relative;
        }
        .indirizzo-card-int:hover {
            border-color: var(--accent-blue);
            background: var(--bg-hover);
        }
        .indirizzo-card-int.selected {
            border-color: var(--accent-green);
            border-width: 2px;
            background: rgba(34, 197, 94, 0.05);
        }
        .indirizzo-card-int .ind-tipo {
            font-size: 0.7rem;
            font-weight: 600;
            text-transform: uppercase;
            margin-bottom: 0.2rem;
        }
        .indirizzo-card-int .ind-tipo.sede_operativa { color: var(--accent-purple); }
        .indirizzo-card-int .ind-tipo.cantiere { color: #ef4444; }
        .indirizzo-card-int .ind-tipo.abitazione { color: var(--accent-green); }
        .indirizzo-card-int .ind-tipo.magazzino { color: #f59e0b; }
        .indirizzo-card-int .ind-tipo.consegna { color: #0ea5e9; }
        .indirizzo-card-int .ind-tipo.altro { color: #64748b; }
        .indirizzo-card-int .ind-nome {
            font-weight: 600;
            font-size: 0.85rem;
            color: var(--text-primary);
        }
        .indirizzo-card-int .ind-indirizzo {
            font-size: 0.8rem;
            color: var(--text-secondary);
            margin-top: 0.15rem;
        }
        .indirizzo-card-int .ind-rif {
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-top: 0.15rem;
        }
        .indirizzo-card-int .badge-default {
            position: absolute;
            top: 0.3rem;
            right: 0.3rem;
            font-size: 0.65rem;
            background: var(--accent-green);
            color: white;
            padding: 0.1rem 0.3rem;
            border-radius: 3px;
        }
        
        /* Badge tecnici condivisi */
        .tecnico-badge {
            display: inline-flex;
            align-items: center;
            gap: 0.3rem;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 0.3rem 0.6rem 0.3rem 0.4rem;
            font-size: 0.85rem;
        }
        .tecnico-badge .tecnico-icona {
            font-size: 1.1rem;
        }
        .tecnico-badge .tecnico-nome {
            color: var(--text-primary);
            font-weight: 500;
        }
        .tecnico-badge .tecnico-remove {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0 0.2rem;
            font-size: 1rem;
            line-height: 1;
        }
        .tecnico-badge .tecnico-remove:hover {
            color: var(--accent-red);
        }
        .tecnico-badge.readonly .tecnico-remove {
            display: none;
        }
        .tecnico-badge.owner {
            background: rgba(59, 130, 246, 0.15);
            border-color: var(--accent-blue);
        }
        
        /* Avviso intervento condiviso */
        .intervento-condiviso-banner {
            background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(168, 85, 247, 0.05) 100%);
            border: 1px solid var(--accent-purple);
            border-radius: var(--radius-sm);
            padding: 0.6rem 1rem;
            margin-bottom: 1rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.85rem;
            color: var(--accent-purple);
        }
        
        /* Empty state indirizzi */
        .indirizzi-empty {
            text-align: center;
            padding: 1rem;
            color: var(--text-muted);
            font-size: 0.85rem;
            background: var(--bg-secondary);
            border-radius: var(--radius-sm);
            border: 1px dashed var(--border-color);
        }
        
        /* Riferimento Documento */
        .riferimento-box {
            background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
            border-left: 4px solid var(--accent-green);
            border-radius: var(--radius-sm);
            padding: 0.75rem 1rem;
            margin-bottom: 1rem;
        }
        .riferimento-box .riferimento-label {
            font-size: 0.75rem;
            color: var(--accent-green);
            font-weight: 600;
            text-transform: uppercase;
            margin-bottom: 0.25rem;
        }
        .riferimento-box .riferimento-text {
            font-size: 0.95rem;
            color: var(--text-primary);
            font-weight: 500;
        }
        
        /* Tabella Righe Unificata */
        .righe-table-unified {
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            overflow: hidden;
            margin-bottom: 1rem;
        }
        .righe-table-unified .righe-header {
            display: grid;
            grid-template-columns: 1fr 90px 110px 100px 45px;
            gap: 0.25rem;
            padding: 0.4rem 0.5rem;
            background: var(--bg-tertiary);
            font-size: 0.65rem;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .righe-table-unified .righe-header span:nth-child(2),
        .righe-table-unified .righe-header span:nth-child(3),
        .righe-table-unified .righe-header span:nth-child(4) {
            text-align: center;
        }
        .righe-table-unified .righe-body {
            max-height: 350px;
            overflow-y: auto;
        }
        
        /* === Fix dropdown nelle righe documento === */
        .righe-table-unified .riga-item,
        .righe-table td,
        .riga-item,
        .riga-item-wrapper,
        .fornitore-search-wrapper,
        .categoria-search-wrapper,
        .autocomplete-wrapper,
        td[style*="position"] {
            position: relative;
        }
        /* Autocomplete dropdown - nascosto di default, visibile con .active */
        .autocomplete-dropdown {
            display: none;
            position: fixed !important;
            z-index: 99999 !important;
            background: var(--bg-card) !important;
            border: 1px solid var(--accent-blue) !important;
            border-radius: 8px !important;
            box-shadow: 0 8px 24px rgba(0,0,0,0.6) !important;
            max-height: 280px !important;
            overflow-y: auto !important;
            min-width: 220px;
            font-size: 0.8rem;
        }
        .autocomplete-dropdown.active {
            display: block !important;
        }
        /* Items dentro dropdown */
        .autocomplete-dropdown > div,
        .autocomplete-dropdown .autocomplete-item {
            padding: 0.45rem 0.65rem;
            cursor: pointer;
            border-bottom: 1px solid rgba(255,255,255,0.05);
            font-size: 0.78rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .autocomplete-dropdown > div:hover,
        .autocomplete-dropdown .autocomplete-item:hover {
            background: var(--accent-blue) !important;
            color: white !important;
        }
        /* Fornitore dropdown - extra width */
        .fornitore-dropdown.active {
            min-width: 250px !important;
        }
        /* Categoria dropdown */
        .categoria-dropdown.active {
            min-width: 230px !important;
        }
        .righe-table-unified .riga-item {
            display: grid;
            grid-template-columns: 1fr 90px 110px 100px 45px;
            gap: 0.2rem;
            padding: 0.3rem 0.4rem;
            align-items: center;
            border-bottom: 1px solid var(--border-color);
            transition: background 0.15s;
        }
        .righe-table-unified .riga-item:last-child {
            border-bottom: none;
        }
        .righe-table-unified .riga-item:nth-child(even) {
            background: rgba(255,255,255,0.02);
        }
        .righe-table-unified .riga-item:hover {
            background: var(--bg-hover);
        }
        .righe-table-unified .riga-item input {
            padding: 0.25rem 0.35rem;
            font-size: 0.8rem;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
        }
        .righe-table-unified .riga-item input:focus {
            border-color: var(--accent-blue);
            outline: none;
        }
        .righe-table-unified .riga-item input[type="number"] {
            text-align: right;
        }
        .righe-table-unified .riga-item .riga-totale {
            text-align: right;
            font-weight: 600;
            font-size: 0.8rem;
            color: var(--text-primary);
            padding-right: 0.15rem;
        }
        .righe-table-unified .riga-item .btn-delete {
            padding: 0.2rem 0.4rem;
            background: var(--accent-red);
            border: none;
            border-radius: var(--radius-sm);
            color: white;
            cursor: pointer;
            font-size: 0.75rem;
            transition: all 0.15s;
        }
        .righe-table-unified .riga-item .btn-delete:hover {
            background: #dc2626;
            transform: scale(1.05);
        }
        .righe-table-unified .righe-empty {
            padding: 1.5rem;
            text-align: center;
            color: var(--text-muted);
            font-style: italic;
        }
        
        /* ========== RIGHE DOCUMENTO MOBILE - SOLO SCROLL ORIZZONTALE ========== */
        @media (max-width: 768px) {
            /* Container con scroll orizzontale */
            .righe-scroll-container {
                overflow-x: auto !important;
                -webkit-overflow-scrolling: touch;
            }
            
            /* Larghezza minima per forzare scroll */
            .righe-table-unified,
            .righe-table-unified .righe-body {
                min-width: 700px;
            }
            
            /* IMPORTANTE: Forza display grid per header e righe */
            .righe-table-unified .righe-header {
                display: grid !important;
                flex-direction: unset !important;
                font-size: 0.55rem !important;
            }
            .righe-table-unified .riga-item {
                display: grid !important;
                flex-direction: unset !important;
                font-size: 0.65rem !important;
            }
            
            /* Input compatti */
            .righe-table-unified .riga-item input,
            .righe-table-unified .riga-item select {
                font-size: 12px !important;
                padding: 0.2rem !important;
                min-height: 28px !important;
            }
        }
        
        /* ================================================================
           MOBILE: Layout semplificato per righe documento
           Nascondi colonne meno importanti, più spazio a descrizione
           ================================================================ */
        @media (max-width: 600px) {
            /* Container scroll con hint */
            .righe-scroll-container {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                padding-bottom: 10px;
            }
            
            /* Layout più compatto - nascondi colonne secondarie */
            .righe-table-unified .righe-header,
            .righe-table-unified .riga-item {
                /* Codice | Descrizione | Qtà | P.Netto | P.Ivato | Tot | ✕ */
                grid-template-columns: 50px minmax(180px, 1fr) 45px 60px 60px 65px 30px !important;
                min-width: 550px !important;
            }
            
            /* Nascondi colonne su mobile piccolo:
               - Categoria (3)
               - Fornitore (4)  
               - Costo (6)
               - IVA select (9)
               - Tot Netto (10)
               - Margine (12)
               - Stato ordine (13)
               - Impegno (14)
            */
            .righe-table-unified .righe-header > span:nth-child(3),
            .righe-table-unified .righe-header > span:nth-child(4),
            .righe-table-unified .righe-header > span:nth-child(6),
            .righe-table-unified .righe-header > span:nth-child(9),
            .righe-table-unified .righe-header > span:nth-child(10),
            .righe-table-unified .righe-header > span:nth-child(12),
            .righe-table-unified .righe-header > span:nth-child(13),
            .righe-table-unified .righe-header > span:nth-child(14) {
                display: none !important;
            }
            
            .righe-table-unified .riga-item > *:nth-child(3),
            .righe-table-unified .riga-item > *:nth-child(4),
            .righe-table-unified .riga-item > *:nth-child(6),
            .righe-table-unified .riga-item > *:nth-child(9),
            .righe-table-unified .riga-item > *:nth-child(10),
            .righe-table-unified .riga-item > *:nth-child(12),
            .righe-table-unified .riga-item > *:nth-child(13),
            .righe-table-unified .riga-item > *:nth-child(14) {
                display: none !important;
            }
            
            /* Descrizione input più grande */
            .righe-table-unified .riga-item .autocomplete-wrapper input {
                font-size: 14px !important;
                padding: 0.4rem !important;
            }
            
            /* Header compatto */
            .righe-table-unified .righe-header {
                font-size: 0.6rem !important;
                padding: 0.3rem !important;
            }
            
            /* Riga compatta */
            .righe-table-unified .riga-item {
                padding: 0.4rem 0.2rem !important;
                gap: 0.2rem !important;
            }
        }
        
        /* Totali Box Unificato */
        .totali-box-unified {
            display: flex;
            justify-content: flex-end;
            margin-bottom: 1rem;
        }
        .totali-box-unified .totali-content {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            padding: 1rem 1.25rem;
            min-width: 280px;
        }
        .totali-box-unified .totale-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.4rem 0;
        }
        .totali-box-unified .totale-row:not(:last-child) {
            border-bottom: 1px solid var(--border-color);
        }
        .totali-box-unified .totale-row .totale-label {
            color: var(--text-muted);
            font-size: 0.85rem;
        }
        .totali-box-unified .totale-row .totale-value {
            font-weight: 600;
            font-size: 1rem;
        }
        .totali-box-unified .totale-row.totale-finale {
            padding-top: 0.6rem;
            margin-top: 0.25rem;
        }
        .totali-box-unified .totale-row.totale-finale .totale-label {
            font-weight: 700;
            font-size: 1rem;
            color: var(--text-primary);
        }
        .totali-box-unified .totale-row.totale-finale .totale-value {
            font-size: 1.3rem;
            font-weight: 700;
            color: var(--accent-green);
        }
        
        /* Form Section Title */
        .section-title-unified {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--accent-blue);
            margin-bottom: 0.75rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        
        /* Input migliorati */
        .input-unified {
            width: 100%;
            padding: 0.6rem 0.75rem;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-sm);
            color: var(--text-primary);
            font-size: 0.9rem;
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        .input-unified:focus {
            border-color: var(--accent-blue);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
            outline: none;
        }
        .input-unified::placeholder {
            color: var(--text-muted);
        }
        
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; }
        .header { background: var(--bg-secondary); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 100; }
        .header-left { display: flex; align-items: center; gap: 1.5rem; }
        .back-btn { color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; }
        .back-btn:hover { color: var(--accent-blue); }
        .logo { font-size: 1.5rem; font-weight: 700; }
        .header-actions { display: flex; gap: 0.75rem; }
        .main-container { max-width: 100%; margin: 0 auto; padding: 0.5rem 1rem; }
        /* Calendario full-width quando attivo */
        .main-container.calendario-fullwidth { max-width: 100%; padding: 0.5rem 1rem; }
        .main-container.calendario-fullwidth .tabs-container { margin-bottom: 0.5rem; }
        .main-container.calendario-fullwidth #panelCalendario .calendar-container { padding: 0.5rem 0; }
        .main-container.calendario-fullwidth #fullcalendar { padding: 0.5rem; }
        /* Calendario mobile - padding minimo */
        @media (max-width: 768px) {
            .main-container.calendario-fullwidth { padding: 0.25rem !important; }
            .main-container.calendario-fullwidth #fullcalendar { padding: 0.25rem !important; }
            .main-container.calendario-fullwidth .calendar-filters { 
                flex-wrap: wrap; 
                gap: 0.25rem !important;
                padding: 0.25rem !important;
            }
            .main-container.calendario-fullwidth .calendar-filters select,
            .main-container.calendario-fullwidth .calendar-filters button {
                font-size: 0.75rem !important;
                padding: 0.3rem 0.5rem !important;
            }
            /* Calendar toolbar mobile */
            .calendar-toolbar {
                flex-direction: column !important;
                gap: 0.5rem !important;
                padding: 0.5rem !important;
            }
            .calendar-toolbar > div,
            .calendar-toolbar > select,
            .calendar-toolbar > button {
                width: 100% !important;
                justify-content: center;
            }
            .calendar-toolbar .tecnici-dropdown {
                width: 100%;
            }
            .calendar-toolbar .tecnici-dropdown button {
                width: 100%;
                justify-content: center;
            }
            /* Checkbox tipi più compatti */
            .calendar-toolbar > div:first-child {
                flex-wrap: wrap !important;
                justify-content: center !important;
                font-size: 0.75rem !important;
            }
            .calendar-toolbar > div:first-child label {
                font-size: 0.75rem !important;
            }
            /* Legend compatta */
            .calendar-legend {
                flex-wrap: wrap !important;
                gap: 0.5rem !important;
                font-size: 0.7rem !important;
            }
            .calendar-legend .legend-item {
                font-size: 0.7rem !important;
            }
            /* Container calendario senza padding */
            .calendar-container {
                padding: 0.25rem !important;
            }
        }
        .stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
        .stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; transition: all 0.2s; }
        .stat-card:hover { border-color: var(--accent-blue); }
        .stat-card.active { border-color: var(--accent-blue); background: rgba(59, 130, 246, 0.1); }
        .stat-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
        .stat-icon.green { background: rgba(34, 197, 94, 0.15); }
        .stat-icon.blue { background: rgba(59, 130, 246, 0.15); }
        .stat-icon.orange { background: rgba(245, 158, 11, 0.15); }
        .stat-icon.red { background: rgba(239, 68, 68, 0.15); }
        .stat-icon.cyan { background: rgba(6, 182, 212, 0.15); }
        .stat-icon.purple { background: rgba(139, 92, 246, 0.15); }
        .stat-icon.yellow { background: rgba(234, 179, 8, 0.15); }
        .stat-info h3 { font-size: 1.4rem; font-weight: 700; }
        .stat-info p { color: var(--text-muted); font-size: 0.7rem; }
        /* Toolbar con filtri collassabili */
        .toolbar-mobile { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.75rem; margin-bottom: 1rem; }
        .toolbar-main { display: flex; gap: 0.5rem; align-items: center; }
        .toolbar-main .search-box { flex: 1; }
        .toolbar-filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border-color); }
        .filter-toggle { display: none; }
        .filter-icon { transition: transform 0.3s; }
        .filter-toggle.active .filter-icon { transform: rotate(180deg); }
        .toolbar { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1rem; margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
        .search-box { flex: 1; min-width: 150px; position: relative; }
        .search-box input { width: 100%; padding: 0.6rem 1rem; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem; }
        .filter-group { display: flex; gap: 0.5rem; align-items: center; }
        .filter-group label { color: var(--text-muted); font-size: 0.8rem; white-space: nowrap; }
        .filter-select { padding: 0.5rem 0.75rem; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.85rem; }
        .btn { padding: 0.6rem 1rem; border: none; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; gap: 0.4rem; }
        .btn-primary { background: var(--accent-blue); color: white; }
        .btn-primary:hover { background: #2563eb; }
        .btn-success { background: var(--accent-green); color: white; }
        .btn-success:hover { background: #16a34a; }
        .btn-danger { background: var(--accent-red); color: white; }
        .btn-danger:hover { background: #dc2626; }
        .btn-warning { background: var(--accent-orange); color: white; }
        .btn-secondary { background: var(--bg-hover); color: var(--text-primary); }
        .btn-purple { background: var(--accent-purple); color: white; }
        .btn-sm { padding: 0.35rem 0.6rem; font-size: 0.75rem; }
        .btn-icon { padding: 0.4rem 0.5rem; }
        .table-container { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
        .table-container .scroll-hint-main { display: none; text-align: center; font-size: 0.7rem; color: var(--text-muted); padding: 0.25rem; background: var(--bg-secondary); }
        @media (max-width: 768px) { .table-container .scroll-hint-main { display: block; } }
        .table-scroll { overflow-x: auto; max-height: calc(100vh - 380px); overflow-y: auto; }
        @media (max-width: 768px) {
            .table-scroll { max-height: calc(100vh - 280px); min-height: 200px; }
        }
        table { width: 100%; border-collapse: collapse; font-size: 0.8rem; table-layout: auto; }
        thead { background: var(--bg-secondary); position: sticky; top: 0; z-index: 10; }
        th { padding: 0.75rem; text-align: left; font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); white-space: nowrap; position: relative; }
        th.resizable { resize: horizontal; overflow: auto; min-width: 50px; }
        th.sortable { cursor: pointer; }
        th.sortable:hover { color: var(--accent-blue); }
        td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
        /* Hover solo per tabelle dati, non per anteprime */
        .table-container tr:hover { background: var(--bg-hover); }
        
        /* === ISOLAMENTO ANTEPRIMA (iframe per email, container per PDF) === */
        /* L'anteprima email ora usa un iframe, quindi è automaticamente isolata.
           Manteniamo regole per altri container preview che potrebbero non usare iframe */
        .pdf-preview-container *:hover,
        .document-preview *:hover {
            background-color: transparent !important;
        }
        
        .cell-clickable { cursor: pointer; position: relative; }
        .cell-clickable:hover { background: rgba(59, 130, 246, 0.1); }
        
        /* Dropdown inline per cambio rapido */
        .inline-dropdown {
            position: absolute;
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.4);
            z-index: 1000;
            min-width: 180px;
            max-height: 300px;
            overflow-y: auto;
        }
        .inline-dropdown-item {
            padding: 0.5rem 0.75rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.85rem;
            border-bottom: 1px solid var(--border-color);
        }
        .inline-dropdown-item:last-child { border-bottom: none; }
        .inline-dropdown-item:hover { background: var(--bg-hover); }
        .inline-dropdown-item.selected { background: rgba(59, 130, 246, 0.2); }
        .inline-dropdown-header {
            padding: 0.5rem 0.75rem;
            font-size: 0.7rem;
            font-weight: 600;
            color: var(--text-muted);
            text-transform: uppercase;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
        }
        
        .badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
        .badge-da_fare { background: rgba(239, 68, 68, 0.2); color: var(--accent-red); }
        .badge-in_lavorazione { background: rgba(245, 158, 11, 0.2); color: var(--accent-orange); }
        .badge-pronto_consegna { background: rgba(34, 197, 94, 0.2); color: var(--accent-green); }
        .badge-finito_da_fatturare { background: rgba(234, 179, 8, 0.2); color: #ca8a04; }
        .badge-fatturato_finito { background: rgba(6, 182, 212, 0.2); color: var(--accent-cyan); }
        .badge-concluso { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
        .badge-da_ordinare { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }
        .badge-ordinato { background: rgba(234, 179, 8, 0.2); color: var(--accent-yellow); }
        .badge-annullato { background: rgba(100, 100, 100, 0.2); color: #888; }
        .table-footer { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; background: var(--bg-secondary); border-top: 1px solid var(--border-color); }
        .pagination-info { color: var(--text-muted); font-size: 0.85rem; }
        .pagination { display: flex; gap: 0.25rem; }
        .pagination button { padding: 0.4rem 0.75rem; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); cursor: pointer; font-size: 0.8rem; }
        .pagination button:hover { background: var(--bg-hover); }
        .pagination button.active { background: var(--accent-blue); border-color: var(--accent-blue); }
        .pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
        .modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); z-index: 1000; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; }
        .modal-overlay.active { display: flex; }
        .modal { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); width: 100%; max-width: 1300px; max-height: 95vh; margin: 1rem 0; display: flex; flex-direction: column; overflow: hidden; }
        .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); background: var(--bg-secondary); flex-shrink: 0; }
        .modal-header h2 { font-size: 1.2rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; }
        .modal-close:hover { color: var(--accent-red); }
        .modal-body { padding: 1.5rem; flex: 1; overflow-y: auto; overflow-x: hidden; }
        .modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); background: var(--bg-secondary); flex-shrink: 0; flex-wrap: wrap; }
        .modal-footer-left { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
        .modal-footer-right { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
        .modal-footer .btn { white-space: nowrap; }
        
        /* Dropdown azioni per pulsanti raggruppati */
        .btn-dropdown-container { position: relative; display: inline-block; }
        .btn-dropdown-menu { 
            display: none; 
            position: absolute; 
            bottom: 100%; 
            left: 0; 
            background: var(--bg-card); 
            border: 1px solid var(--border-color); 
            border-radius: var(--radius-sm); 
            box-shadow: 0 -4px 12px rgba(0,0,0,0.3); 
            min-width: 180px; 
            z-index: 1000;
            margin-bottom: 4px;
        }
        .btn-dropdown-menu.show { display: block; }
        .btn-dropdown-menu .dropdown-item {
            display: block;
            width: 100%;
            padding: 0.6rem 1rem;
            text-align: left;
            border: none;
            background: transparent;
            color: var(--text-primary);
            cursor: pointer;
            font-size: 0.9rem;
            transition: background 0.2s;
        }
        .btn-dropdown-menu .dropdown-item:hover {
            background: var(--bg-secondary);
        }
        .btn-dropdown-menu .dropdown-item:first-child {
            border-radius: var(--radius-sm) var(--radius-sm) 0 0;
        }
        .btn-dropdown-menu .dropdown-item:last-child {
            border-radius: 0 0 var(--radius-sm) var(--radius-sm);
        }
        .form-section { margin-bottom: 1.5rem; }
        .form-section h3 { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 0.5rem; }
        .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
        .form-group { display: flex; flex-direction: column; gap: 0.4rem; }
        .form-group.full-width { grid-column: 1 / -1; }
        .form-group.half-width { grid-column: span 2; }
        .form-group label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
        .form-group label .required { color: var(--accent-red); }
        .form-group input, .form-group select, .form-group textarea { padding: 0.6rem 0.75rem; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem; }
        .form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent-blue); }
        .form-group textarea { resize: vertical; min-height: 70px; }
        .easy-search-container { background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 1rem; }
        .easy-search-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 0.75rem; }
        .easy-search-input { display: flex; flex-direction: column; gap: 0.25rem; }
        .easy-search-input label { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }
        .easy-search-input input { width: 100%; padding: 0.5rem 0.6rem; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary); font-size: 0.85rem; }
        .easy-search-input input.highlight { background: rgba(234, 179, 8, 0.2); border-color: var(--accent-yellow); }
        .easy-search-results { max-height: 180px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: 4px; display: none; }
        .easy-search-results.active { display: block; }
        .easy-search-result-item { padding: 0.5rem 0.75rem; cursor: pointer; border-bottom: 1px solid var(--border-color); }
        .easy-search-result-item:hover { background: var(--bg-hover); }
        .easy-search-result-item:last-child { border-bottom: none; }
        .easy-search-result-item .name { font-weight: 600; }
        .easy-search-result-item .details { font-size: 0.75rem; color: var(--text-muted); }
        .selected-customer-card { background: rgba(34, 197, 94, 0.1); border: 1px solid var(--accent-green); border-radius: var(--radius-sm); padding: 0.75rem 1rem; display: none; margin-top: 0.5rem; }
        .selected-customer-card.active { display: block; }
        .selected-customer-header { display: flex; justify-content: space-between; align-items: center; }
        .selected-customer-header .name { font-size: 1rem; font-weight: 700; color: var(--accent-green); }
        .selected-customer-info { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }
        .new-customer-form { background: rgba(59, 130, 246, 0.1); border: 1px dashed var(--accent-blue); border-radius: var(--radius-sm); padding: 1rem; margin-top: 0.75rem; display: none; }
        .new-customer-form.active { display: block; }
        .new-customer-form h4 { font-size: 0.85rem; color: var(--accent-blue); margin-bottom: 0.75rem; }
        .device-box { background: rgba(139, 92, 246, 0.1); border: 1px solid var(--accent-purple); border-radius: var(--radius-sm); padding: 1rem; overflow: hidden; }
        .device-id-display { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
        .accessory-checkboxes { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }
        .accessory-checkboxes label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; cursor: pointer; }
        .accessory-checkboxes input[type="checkbox"] { width: 16px; height: 16px; }
        .rows-section { background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 1rem; }
        .rows-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: 0.5rem; flex-wrap: wrap; }
        .rows-header h4 { font-size: 0.9rem; color: var(--text-secondary); }
        .rows-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
        .rows-table { width: 100%; font-size: 0.7rem; border-collapse: collapse; }
        .rows-table th { padding: 0.2rem 0.15rem; background: var(--bg-secondary); font-size: 0.65rem; text-align: center; white-space: nowrap; }
        .rows-table td { padding: 0.15rem 0.1rem; vertical-align: middle; }
        .rows-table input, .rows-table select { width: 100%; padding: 0.2rem 0.15rem; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 3px; color: var(--text-primary); font-size: 0.7rem; min-width: 35px; }
        .rows-table input[type="checkbox"] { width: 14px; height: 14px; min-width: 14px; }
        .row-type-badge { display: inline-block; padding: 0.15rem 0.35rem; border-radius: 3px; font-size: 0.6rem; font-weight: 600; text-transform: uppercase; }
        .row-type-manual { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }
        .row-type-product { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
        .row-type-order { background: rgba(245, 158, 11, 0.2); color: var(--accent-orange); }
        .row-delete-btn { background: var(--accent-red); color: white; border: none; padding: 0.25rem 0.4rem; border-radius: 4px; cursor: pointer; font-size: 0.7rem; }
        .rows-total { display: flex; justify-content: flex-end; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); gap: 1rem; }
        .rows-total-box { background: var(--bg-secondary); padding: 0.5rem 1rem; border-radius: var(--radius-sm); text-align: right; }
        .rows-total-box .label { font-size: 0.7rem; color: var(--text-muted); }
        .rows-total-box .value { font-size: 1.1rem; font-weight: 700; color: var(--accent-green); }
        .rows-total-box.warning .value { color: var(--accent-orange); }
        .product-search-input { width: 100%; padding: 0.75rem; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 1rem; margin-bottom: 1rem; }
        .product-list { max-height: 400px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
        .product-item { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
        .product-item:hover { background: var(--bg-hover); }
        .product-item-name { font-weight: 600; }
        .product-item-sku { font-size: 0.75rem; color: var(--text-muted); }
        .product-item-price { font-weight: 700; color: var(--accent-green); }
        .order-list-container { margin-top: 1rem; }
        .order-group { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-bottom: 1rem; overflow: hidden; }
        .order-group-header { padding: 0.75rem 1rem; background: var(--accent-purple); color: white; display: flex; justify-content: space-between; align-items: center; }
        .order-group-header h4 { font-size: 0.9rem; }
        .order-group-items { padding: 0.5rem; }
        .order-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; border-bottom: 1px solid var(--border-color); font-size: 0.85rem; }
        .order-item:last-child { border-bottom: none; }
        .toast { position: fixed; bottom: 2rem; right: 2rem; padding: 1rem 1.5rem; border-radius: var(--radius-sm); color: white; font-weight: 500; z-index: 2000; }
        .toast.success { background: var(--accent-green); }
        .toast.error { background: var(--accent-red); }
        .toast.warning { background: var(--accent-orange); }
        .loading { display: flex; justify-content: center; align-items: center; padding: 3rem; color: var(--text-muted); }
        .spinner { width: 40px; height: 40px; border: 3px solid var(--border-color); border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 1rem; }
        @keyframes spin { to { transform: rotate(360deg); } }
        /* Global Loading Overlay */
        .global-loading-overlay { 
            position: fixed; top: 0; left: 0; right: 0; bottom: 0; 
            background: rgba(0,0,0,0.5); 
            display: flex; flex-direction: column; justify-content: center; align-items: center; 
            z-index: 10000; 
            opacity: 0; visibility: hidden;
            transition: opacity 0.15s, visibility 0.15s;
        }
        .global-loading-overlay.active { opacity: 1; visibility: visible; }
        .global-loading-overlay .loading-box {
            background: var(--bg-card); border-radius: var(--radius-md);
            padding: 1.5rem 2.5rem; display: flex; flex-direction: column; align-items: center;
            box-shadow: 0 8px 32px rgba(0,0,0,0.3);
        }
        .global-loading-overlay .spinner { width: 40px; height: 40px; border-width: 3px; margin: 0 0 0.75rem 0; }
        .global-loading-overlay .loading-text { color: var(--text-primary); font-size: 0.9rem; font-weight: 500; }
        /* Modal Loading Overlay */
        .modal-loading-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 100; border-radius: var(--radius-lg); }
        .modal-loading-overlay .spinner { width: 50px; height: 50px; border-width: 4px; margin: 0 0 1rem 0; }
        .modal-loading-overlay span { color: white; font-size: 1rem; font-weight: 500; }
        .modal-content { position: relative; }
        .empty-state { text-align: center; padding: 3rem 2rem; color: var(--text-muted); }
        .empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
        .customer-link { color: var(--accent-blue); text-decoration: none; cursor: pointer; }
        .customer-link:hover { text-decoration: underline; }
        /* Tabs */
        .tabs-container { display: flex; align-items: center; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 2px solid var(--border-color); padding-bottom: 0.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex: 1; }
        .tabs-container::-webkit-scrollbar { display: none; }
        .tabs-scroll { display: flex; gap: 0.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex: 1; }
        .tabs-scroll::-webkit-scrollbar { display: none; }
        .tabs-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
        .tab-btn { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 0.6rem 1rem; color: var(--text-secondary); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; flex-shrink: 0; }
        .tab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
        .tab-btn.active { background: var(--accent-blue); border-color: var(--accent-blue); color: white; }
        .tab-badge { background: var(--accent-red); color: white; font-size: 0.7rem; padding: 0.15rem 0.4rem; border-radius: 10px; font-weight: 700; }
        .tab-btn.active .tab-badge { background: rgba(255,255,255,0.3); }
        .tab-panel { display: none; }
        .tab-panel.active { display: block; }
        
        /* Zone colorate tab (sezione uscita) */
        .tab-zona { display: flex; align-items: center; gap: 0.25rem; padding: 0.35rem 0.5rem; border-radius: var(--radius-sm); position: relative; }
        .tab-zona-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 0.2rem 0.5rem; border-radius: 4px; white-space: nowrap; margin-right: 0.25rem; }
        .tab-zona-lavoro { background: rgba(251, 146, 60, 0.08); border: 1px solid rgba(251, 146, 60, 0.2); }
        .tab-zona-lavoro .tab-zona-label { color: #ea580c; background: rgba(251, 146, 60, 0.15); }
        .tab-zona-lavoro .tab-btn.active { background: #ea580c; border-color: #ea580c; color: white; }
        .tab-zona-commerciale { background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.2); }
        .tab-zona-commerciale .tab-zona-label { color: #2563eb; background: rgba(59, 130, 246, 0.15); }
        .tab-zona-commerciale .tab-btn.active { background: #2563eb; border-color: #2563eb; color: white; }
        .tab-zona-separator { width: 2px; height: 28px; background: var(--border-color); margin: 0 0.25rem; flex-shrink: 0; border-radius: 1px; }
        /* Tab icona sola (es. calendario) */
        .tab-btn-icon-only { padding: 0.5rem 0.65rem; font-size: 1.1rem; border-radius: var(--radius-sm); min-width: auto; }
        .tab-btn-icon-only .tab-label { display: none; }
        [data-theme="light"] .tab-zona-lavoro { background: rgba(251, 146, 60, 0.06); border-color: rgba(251, 146, 60, 0.25); }
        [data-theme="light"] .tab-zona-commerciale { background: rgba(59, 130, 246, 0.06); border-color: rgba(59, 130, 246, 0.25); }
        /* Quick Day Buttons */
        .btn-quick-day { background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); padding: 0.35rem 0.6rem; border-radius: 4px; cursor: pointer; font-size: 0.75rem; font-weight: 600; transition: all 0.2s; }
        .btn-quick-day:hover { background: var(--accent-blue); border-color: var(--accent-blue); color: white; }
        .btn-quick-day.active { background: var(--accent-green); border-color: var(--accent-green); color: white; }
        .btn-quick-hour { background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); padding: 0.3rem 0.5rem; border-radius: 4px; cursor: pointer; font-size: 0.7rem; font-weight: 600; transition: all 0.2s; min-width: 28px; }
        .btn-quick-hour:hover { background: var(--accent-purple); border-color: var(--accent-purple); color: white; }
        .btn-quick-hour.active { background: var(--accent-purple); border-color: var(--accent-purple); color: white; }
        /* Nota Color Buttons */
        .nota-color-btn { width: 36px; height: 36px; border: 2px solid transparent; border-radius: 8px; cursor: pointer; font-size: 1rem; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
        .nota-color-btn:hover { transform: scale(1.1); }
        .nota-color-btn.selected { border-color: #1f2937; box-shadow: 0 0 0 2px white, 0 0 0 4px #1f2937; }
        /* Nota Calendar Event */
        .calendar-event.type-nota { background: #fbbf24 !important; color: #1f2937 !important; font-weight: 600; }
        .day-event-block.type-nota { color: #1f2937 !important; }
        /* Checkbox filter */
        .checkbox-label { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; }
        .checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
        /* Rich Text Editor */
        .rich-editor-container { border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; }
        .rich-editor-toolbar { background: var(--bg-secondary); padding: 0.4rem; display: flex; gap: 0.25rem; flex-wrap: wrap; border-bottom: 1px solid var(--border-color); }
        .rich-editor-toolbar button { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary); padding: 0.3rem 0.5rem; border-radius: 4px; cursor: pointer; font-size: 0.8rem; }
        .rich-editor-toolbar button:hover { background: var(--accent-blue); border-color: var(--accent-blue); }
        .rich-editor-content { background: var(--bg-primary); color: var(--text-primary); min-height: 80px; padding: 0.75rem; font-size: 0.9rem; outline: none; overflow-y: auto; max-height: 200px; }
        .rich-editor-content:focus { box-shadow: inset 0 0 0 2px var(--accent-blue); }
        .rich-editor-content ul, .rich-editor-content ol { margin-left: 1.5rem; }
        .rich-editor-content a { color: var(--accent-blue); }
        /* Order Form */
        .order-form-container { background: var(--bg-card); border: 1px solid var(--accent-green); border-radius: var(--radius-sm); padding: 1rem; margin-top: 1rem; }
        .order-form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
        .order-form-header h4 { color: var(--accent-green); font-size: 1rem; }
        .order-form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
        .order-form-fields .form-group { margin: 0; }
        .order-form-fields label { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.25rem; display: block; }
        .order-form-fields input { width: 100%; padding: 0.5rem; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 4px; color: var(--text-primary); }
        .order-selected-items { background: var(--bg-secondary); padding: 0.5rem; border-radius: 4px; margin-bottom: 1rem; max-height: 150px; overflow-y: auto; font-size: 0.85rem; }
        .order-selected-item { display: flex; justify-content: space-between; padding: 0.25rem 0; border-bottom: 1px solid var(--border-color); }
        .order-selected-item:last-child { border-bottom: none; }
        /* Note Banner Dashboard */
        .dashboard-notes-banner { background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(251, 191, 36, 0.05)); border: 2px solid #fbbf24; border-radius: var(--radius-md); margin-bottom: 1rem; overflow: hidden; }
        .notes-banner-header { background: rgba(251, 191, 36, 0.2); padding: 0.5rem 1rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(251, 191, 36, 0.3); }
        .notes-banner-header span { font-weight: 600; color: #fbbf24; display: flex; align-items: center; gap: 0.5rem; }
        .notes-banner-content { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem; }
        .note-card-mini { background: var(--bg-card); border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 0.5rem; border-left: 3px solid; min-width: 200px; flex: 1; max-width: 350px; }
        .note-card-mini:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
        .note-card-mini .note-time { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
        .note-card-mini .note-title { font-size: 0.85rem; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .note-card-mini .note-actions { display: flex; gap: 0.25rem; }
        .note-card-mini.is-scaduta { animation: pulse-warning 2s infinite; }
        @keyframes pulse-warning { 0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); } }
        /* Storico Dispositivo */
        .storico-device-container { background: var(--bg-secondary); border: 1px solid var(--accent-cyan); border-radius: var(--radius-sm); overflow: hidden; }
        .storico-device-header { background: var(--accent-cyan); color: white; padding: 0.5rem 0.75rem; display: flex; justify-content: space-between; align-items: center; }
        .storico-device-header h4 { font-size: 0.9rem; margin: 0; }
        .storico-device-list { max-height: 200px; overflow-y: auto; }
        .storico-device-item { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-color); font-size: 0.85rem; cursor: pointer; transition: background 0.2s; }
        .storico-device-item:hover { background: var(--bg-hover); }
        .storico-device-item:last-child { border-bottom: none; }
        .storico-device-item .doc-info { display: flex; justify-content: space-between; align-items: center; }
        .storico-device-item .doc-num { font-weight: 600; color: var(--accent-blue); }
        .storico-device-item .doc-date { color: var(--text-muted); font-size: 0.75rem; }
        .storico-device-item .doc-problem { color: var(--text-secondary); font-size: 0.8rem; margin-top: 0.25rem; }
        .btn-info { background: var(--accent-cyan); color: white; }
        .btn-info:hover { background: #0891b2; }
        /* Customer Devices List */
        .customer-devices-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
        .customer-device-card { background: var(--bg-secondary); border: 2px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.75rem; cursor: pointer; transition: all 0.2s; }
        .customer-device-card:hover { border-color: var(--accent-blue); background: var(--bg-hover); transform: translateY(-2px); }
        .customer-device-card.selected { border-color: var(--accent-green); background: rgba(34, 197, 94, 0.1); }
        .customer-device-card .device-icon { font-size: 1.5rem; margin-bottom: 0.25rem; }
        .customer-device-card .device-name { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
        .customer-device-card .device-serial { font-size: 0.75rem; color: var(--text-muted); font-family: monospace; }
        .customer-device-card .device-repairs { font-size: 0.7rem; color: var(--accent-purple); margin-top: 0.25rem; }
        .customer-device-card .device-id-badge { font-size: 0.7rem; background: var(--accent-purple); color: white; padding: 0.1rem 0.4rem; border-radius: 3px; display: inline-block; margin-top: 0.25rem; }
        /* Orders Panel */
        .orders-panel { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 1.5rem; }
        .supplier-group { margin-bottom: 1.5rem; background: var(--bg-secondary); border-radius: var(--radius-sm); overflow: hidden; }
        .supplier-header { background: var(--accent-purple); color: white; padding: 0.75rem 1rem; display: flex; justify-content: space-between; align-items: center; }
        .supplier-header h3 { font-size: 1rem; display: flex; align-items: center; gap: 0.5rem; }
        .supplier-header .count { background: rgba(255,255,255,0.2); padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.8rem; }
        .supplier-items { padding: 0.5rem; }
        .order-row { display: grid; grid-template-columns: 30px 1fr 2fr 60px 80px 80px 80px; gap: 0.5rem; padding: 0.5rem; border-bottom: 1px solid var(--border-color); align-items: center; font-size: 0.85rem; }
        .order-row:last-child { border-bottom: none; }
        .order-row:hover { background: var(--bg-hover); }
        .order-row .doc-num { font-weight: 600; color: var(--accent-blue); }
        .order-row .customer { color: var(--text-secondary); }
        .order-row .piece { font-weight: 500; }
        .order-row .qty { text-align: center; }
        .order-row .price { text-align: right; color: var(--accent-orange); }
        .order-row .actions { text-align: center; }
        .order-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
        .order-header { display: grid; grid-template-columns: 30px 1fr 2fr 60px 80px 80px 80px; gap: 0.5rem; padding: 0.5rem; font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; border-bottom: 1px solid var(--border-color); }
        .no-supplier { background: rgba(239, 68, 68, 0.1); border: 1px dashed var(--accent-red); }
        .no-supplier .supplier-header { background: var(--accent-red); }
        /* Pulse animation for late orders */
        @keyframes pulse {
            0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
            50% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
        }
        /* Arrival notification list */
        .arrival-result { background: var(--bg-card); border: 1px solid var(--accent-green); border-radius: var(--radius-sm); padding: 1rem; margin-top: 1rem; }
        .arrival-result h4 { color: var(--accent-green); margin-bottom: 0.75rem; }
        .arrival-customer-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; border-bottom: 1px solid var(--border-color); }
        .arrival-customer-item:last-child { border-bottom: none; }
        .arrival-customer-item .customer-info { flex: 1; }
        .arrival-customer-item .customer-name { font-weight: 600; }
        .arrival-customer-item .customer-phone { color: var(--accent-blue); font-size: 0.9rem; }
        .arrival-customer-item .doc-num { color: var(--text-muted); font-size: 0.8rem; }
        .btn-call { background: var(--accent-green); color: white; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem; }
        /* WhatsApp */
        .btn-whatsapp { background: #25D366; color: white; padding: 0.25rem 0.4rem; border-radius: 4px; font-size: 0.75rem; border: none; cursor: pointer; min-width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }
        .btn-whatsapp:hover { background: #128C7E; }
        /* Pulsanti azione tabelle - stile unificato */
        .table-action-btn { padding: 0.3rem 0.5rem; border-radius: 4px; font-size: 0.8rem; border: none; cursor: pointer; min-width: 30px; height: 28px; display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s; }
        .table-action-btn:hover { transform: scale(1.05); filter: brightness(1.1); }
        .table-action-btn.primary { background: var(--accent-blue); color: white; }
        .table-action-btn.info { background: #06b6d4; color: white; }
        .table-action-btn.success { background: var(--accent-green); color: white; }
        .table-action-btn.warning { background: #f59e0b; color: white; }
        .table-action-btn.danger { background: var(--accent-red); color: white; }
        .table-action-btn.purple { background: #8b5cf6; color: white; }
        .table-action-btn.secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color); }
        .table-actions { display: flex; gap: 0.25rem; align-items: center; flex-wrap: nowrap; }
        .table-actions .table-action-btn,
        .table-actions .btn-whatsapp,
        .table-actions .btn { 
            min-width: 26px; 
            height: 26px; 
            padding: 0.2rem 0.35rem; 
            font-size: 0.7rem; 
        }
        .wa-template-btn { background: var(--bg-secondary); border: 2px solid var(--border-color); border-radius: var(--radius-sm); padding: 0.6rem 0.75rem; text-align: left; cursor: pointer; transition: all 0.2s; }
        .wa-template-btn:hover { border-color: #25D366; background: var(--bg-hover); }
        .wa-template-btn.selected { border-color: #25D366; background: rgba(37, 211, 102, 0.1); }
        .wa-template-btn .template-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }
        .wa-template-btn .template-preview { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        /* FullCalendar Styles - Dark Theme */
        .calendar-container { background: var(--bg-card); border-radius: var(--radius-md); }
        #fullcalendar {
            --fc-border-color: rgba(75, 85, 99, 0.4);
            --fc-button-bg-color: var(--bg-secondary);
            --fc-button-border-color: var(--border-color);
            --fc-button-text-color: var(--text-primary);
            --fc-button-hover-bg-color: var(--accent-blue);
            --fc-button-hover-border-color: var(--accent-blue);
            --fc-button-active-bg-color: var(--accent-blue);
            --fc-button-active-border-color: var(--accent-blue);
            --fc-event-border-color: transparent;
            --fc-today-bg-color: rgba(59, 130, 246, 0.1);
            --fc-neutral-bg-color: var(--bg-secondary);
            --fc-page-bg-color: var(--bg-card);
            --fc-neutral-text-color: var(--text-muted);
        }
        #fullcalendar .fc { background: var(--bg-card); color: var(--text-primary); }
        #fullcalendar .fc-toolbar-title { font-size: 1.25rem !important; color: var(--text-primary); }
        /* FIX: Toolbar responsive - wrap su mobile */
        #fullcalendar .fc-toolbar {
            flex-wrap: wrap !important;
            gap: 0.5rem;
        }
        #fullcalendar .fc-toolbar-chunk {
            display: flex;
            flex-wrap: wrap;
            gap: 0.25rem;
        }
        /* Header e giorni settimana */
        #fullcalendar .fc-col-header-cell { background: var(--bg-secondary); border-color: rgba(75, 85, 99, 0.3) !important; }
        #fullcalendar .fc-col-header-cell a { color: var(--text-primary) !important; text-decoration: none; }
        #fullcalendar .fc-col-header-cell-cushion { color: var(--text-primary) !important; padding: 8px 4px; font-weight: 600; }
        #fullcalendar .fc-scrollgrid-sync-inner { color: var(--text-primary); }
        #fullcalendar .fc-scrollgrid-sync-inner a { color: var(--text-primary) !important; }
        /* Numeri giorni */
        #fullcalendar .fc-daygrid-day-number { color: var(--text-primary) !important; padding: 4px 8px; text-decoration: none; }
        #fullcalendar .fc-daygrid-day-top a { color: var(--text-primary) !important; }
        #fullcalendar .fc-daygrid-day.fc-day-today { background: rgba(59, 130, 246, 0.15) !important; }
        #fullcalendar .fc-daygrid-day-frame { min-height: 100px; }
        /* Pulsanti toolbar */
        #fullcalendar .fc-button { background: var(--bg-secondary) !important; border-color: var(--border-color) !important; color: var(--text-primary) !important; }
        #fullcalendar .fc-button:hover { background: var(--accent-blue) !important; border-color: var(--accent-blue) !important; color: white !important; }
        #fullcalendar .fc-button-active { background: var(--accent-blue) !important; border-color: var(--accent-blue) !important; color: white !important; }
        #fullcalendar .fc-button:disabled { opacity: 0.5; }
        #fullcalendar .fc-button:focus { box-shadow: none !important; }
        /* Header giorni settimana - due righe */
        #fullcalendar .fc-col-header-cell-cushion { display: flex; flex-direction: column; align-items: center; line-height: 1.3; padding: 6px 4px !important; }
        #fullcalendar .fc-timegrid .fc-col-header-cell a { pointer-events: none; }
        /* Timegrid - linee molto più soft */
        #fullcalendar .fc-timegrid-slot { height: 40px; }
        #fullcalendar .fc-timegrid-slot-lane { border-color: rgba(75, 85, 99, 0.2) !important; }
        #fullcalendar .fc-timegrid-slot-label { color: var(--text-muted); font-size: 0.75rem; border-color: transparent !important; }
        #fullcalendar .fc-timegrid-slot-label-cushion { color: var(--text-muted) !important; }
        #fullcalendar .fc-timegrid-axis-cushion { color: var(--text-muted) !important; }
        #fullcalendar .fc-timegrid-axis { border-color: rgba(75, 85, 99, 0.2) !important; }
        #fullcalendar .fc-timegrid-now-indicator-line { border-color: #dc2626; border-width: 2px; }
        #fullcalendar .fc-timegrid-now-indicator-arrow { border-color: #dc2626; border-top-color: transparent; border-bottom-color: transparent; }
        /* Colonne timegrid */
        #fullcalendar .fc-timegrid-col { border-color: rgba(75, 85, 99, 0.25) !important; }
        #fullcalendar .fc-timegrid-col-frame { border-color: rgba(75, 85, 99, 0.25) !important; }
        /* Bordi generali molto soft */
        #fullcalendar .fc-scrollgrid { border-color: rgba(75, 85, 99, 0.3) !important; }
        #fullcalendar .fc-scrollgrid td, #fullcalendar .fc-scrollgrid th { border-color: rgba(75, 85, 99, 0.2) !important; }
        #fullcalendar .fc-scrollgrid-section > td { border-color: rgba(75, 85, 99, 0.3) !important; }
        /* Daygrid */
        #fullcalendar .fc-daygrid-day { border-color: rgba(75, 85, 99, 0.2) !important; }
        /* Eventi */
        #fullcalendar .fc-event { cursor: pointer; border-radius: 4px; font-size: 0.75rem; padding: 2px 4px; border: none !important; }
        #fullcalendar .fc-event:hover { filter: brightness(1.1); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
        #fullcalendar .fc-event-main { padding: 2px; }
        #fullcalendar .fc-event-title { color: white; }
        #fullcalendar .fc-daygrid-event { margin: 1px 2px; }
        #fullcalendar .fc-daygrid-more-link { color: var(--accent-blue); font-size: 0.7rem; }
        /* Popover */
        #fullcalendar .fc-popover { background: var(--bg-card); border-color: var(--border-color); }
        #fullcalendar .fc-popover-header { background: var(--bg-secondary); color: var(--text-primary); }
        #fullcalendar .fc-popover-body { background: var(--bg-card); }
        #fullcalendar .fc-more-popover .fc-popover-body { max-height: 300px; overflow-y: auto; }
        /* Risorse */
        #fullcalendar .fc-resource { background: var(--bg-secondary); }
        #fullcalendar .fc-resource-cell { background: var(--bg-secondary); }
        #fullcalendar .fc-license-message { display: none; }
        
        /* ========== FULLCALENDAR MOBILE FIX ========== */
        @media (max-width: 768px) {
            #fullcalendar .fc-toolbar {
                flex-direction: column;
                align-items: stretch;
                gap: 0.5rem;
                padding: 0.5rem;
            }
            #fullcalendar .fc-toolbar-chunk {
                justify-content: center;
            }
            #fullcalendar .fc-toolbar-title {
                font-size: 1rem !important;
                text-align: center;
                order: -1; /* Titolo in cima */
            }
            #fullcalendar .fc-button {
                padding: 0.4rem 0.6rem !important;
                font-size: 0.75rem !important;
            }
            #fullcalendar .fc-button-group {
                flex-wrap: wrap;
                justify-content: center;
            }
            /* Nascondi testo lungo pulsanti vista */
            #fullcalendar .fc-dayGridMonth-button,
            #fullcalendar .fc-timeGridWeek-button,
            #fullcalendar .fc-timeGridDay-button,
            #fullcalendar .fc-resourceTimeGridDay-button {
                font-size: 0.7rem !important;
                padding: 0.35rem 0.5rem !important;
            }
            /* Colonne risorse più strette */
            #fullcalendar .fc-resource-cell {
                font-size: 0.75rem !important;
                padding: 0.25rem !important;
            }
            #fullcalendar .fc-col-header-cell-cushion {
                font-size: 0.7rem !important;
                padding: 4px 2px !important;
            }
            /* Eventi più compatti */
            #fullcalendar .fc-event {
                font-size: 0.65rem !important;
                padding: 1px 3px !important;
            }
            #fullcalendar .fc-timegrid-slot {
                height: 35px !important;
            }
        }
        
        @media (max-width: 480px) {
            #fullcalendar .fc-toolbar-title {
                font-size: 0.9rem !important;
            }
            #fullcalendar .fc-button {
                padding: 0.3rem 0.4rem !important;
                font-size: 0.65rem !important;
            }
            /* Su schermi molto piccoli, abbrevia i pulsanti */
            #fullcalendar .fc-today-button {
                font-size: 0.65rem !important;
            }
        }
        
        /* ==================== MOBILE RESPONSIVE ==================== */
        /* Tabelle scrollabili orizzontalmente */
        .table-scroll-container {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            margin: 0 -0.5rem;
            padding: 0 0.5rem;
        }
        .table-scroll-container table {
            min-width: 700px;
        }
        .table-scroll-container::-webkit-scrollbar {
            height: 6px;
        }
        .table-scroll-container::-webkit-scrollbar-track {
            background: var(--bg-secondary);
            border-radius: 3px;
        }
        .table-scroll-container::-webkit-scrollbar-thumb {
            background: var(--accent-blue);
            border-radius: 3px;
        }
        
        /* Righe documento scrollabili */
        .righe-scroll-container {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        .righe-scroll-container .rows-table {
            min-width: 900px;
        }
        .righe-scroll-container .righe-table-unified {
            min-width: 700px;
        }
        
        /* Indicatore scroll su mobile */
        .scroll-hint {
            display: none;
            text-align: center;
            font-size: 0.7rem;
            color: var(--text-muted);
            padding: 0.25rem;
            background: linear-gradient(90deg, transparent, var(--bg-secondary), transparent);
        }
        
        @media (max-width: 768px) {
            .header { padding: 1rem; flex-direction: column; gap: 1rem; }
            .toolbar { flex-direction: column; }
            .search-box { min-width: 100%; }
            .form-grid { grid-template-columns: 1fr; }
            .easy-search-grid { grid-template-columns: 1fr 1fr; }
            .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
            .order-row, .order-header { grid-template-columns: 1fr 1fr; }
            .calendar-header { flex-direction: column; }
            .calendar-filters { width: 100%; justify-content: center; }
            
            /* MOBILE FULL SCREEN - come calendario */
            .main-container { padding: 0 !important; max-width: 100%; }
            
            /* TABS WRAPPER MOBILE */
            .tabs-wrapper {
                display: flex;
                align-items: center;
                gap: 0;
                margin-bottom: 0;
                min-width: 0;
                width: 100%;
                position: sticky;
                top: 60px;
                z-index: 90;
                background: var(--bg-primary);
                border-bottom: 1px solid var(--border-color);
                padding: 0.35rem 0.5rem;
                backdrop-filter: blur(10px);
                -webkit-backdrop-filter: blur(10px);
            }
            
            /* TABS COMPATTI MOBILE - STICKY FULL WIDTH */
            .tabs-container {
                display: flex;
                flex-direction: row;
                flex-wrap: nowrap;
                gap: 0.25rem;
                margin: 0;
                padding: 0;
                border-bottom: none;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
                flex: 1;
                min-width: 0;
            }
            .tabs-container::-webkit-scrollbar { display: none; }
            .tabs-scroll {
                display: flex;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
                flex: 1;
                gap: 0.25rem;
            }
            .tabs-scroll::-webkit-scrollbar { display: none; }
            .tab-btn {
                padding: 0.5rem;
                font-size: 1rem;
                min-width: auto;
                flex-shrink: 0;
                gap: 0.15rem;
            }
            .tab-btn .tab-text { display: none; }
            .tab-badge { padding: 0.1rem 0.35rem; font-size: 0.6rem; margin-left: 0.1rem; }
            /* Zone tab responsive */
            .tab-zona { padding: 0.2rem 0.3rem; gap: 0.15rem; }
            .tab-zona-label { font-size: 0.55rem; padding: 0.15rem 0.3rem; margin-right: 0.1rem; }
            .tab-zona-separator { height: 22px; margin: 0 0.15rem; }
            .tabs-actions {
                display: flex;
                gap: 0.25rem;
                flex-shrink: 0;
            }
            .tabs-actions .btn {
                padding: 0.45rem 0.5rem;
                font-size: 1rem;
            }
            .tabs-actions .btn .btn-text { display: none; }
            
            /* Stats cards scrollabili full width */
            .stats-row {
                display: flex;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
                gap: 0.5rem;
                margin: 0;
                padding: 0.5rem;
            }
            .stats-row::-webkit-scrollbar { display: none; }
            .stat-card {
                padding: 0.5rem;
                flex-shrink: 0;
                min-width: 100px;
            }
            .stat-card .stat-icon {
                width: 28px;
                height: 28px;
                font-size: 0.9rem;
            }
            .stat-card .stat-info h3 {
                font-size: 1rem;
            }
            .stat-card .stat-info p {
                font-size: 0.6rem;
            }
            
            /* Toolbar e filtri full width */
            .toolbar { 
                padding: 0.5rem; 
                margin: 0.5rem;
                flex-direction: row;
                flex-wrap: nowrap;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                scrollbar-width: none;
                gap: 0.4rem;
                align-items: center;
            }
            .toolbar::-webkit-scrollbar { display: none; }
            .toolbar .search-box { min-width: 120px; flex-shrink: 0; }
            .toolbar .search-box input { padding: 0.4rem; font-size: 0.8rem; }
            .toolbar .filter-group { flex-shrink: 0; display: flex; align-items: center; gap: 0.25rem; }
            .toolbar .filter-group label { font-size: 0.65rem; display: none; }
            .toolbar .filter-group select { padding: 0.35rem 0.25rem; font-size: 0.75rem; min-width: 70px; }
            .toolbar .btn { padding: 0.4rem; font-size: 0.9rem; white-space: nowrap; flex-shrink: 0; }
            .toolbar .btn-sm { padding: 0.35rem; }
            .filters-panel, .easy-search-panel { margin: 0.5rem; }
            
            /* Mostra indicatore scroll */
            .scroll-hint { display: block; }
            
            /* Tabelle principali scrollabili */
            .table-container { 
                overflow-x: auto; 
                -webkit-overflow-scrolling: touch;
                margin: 0;
            }
            .table-container table { 
                min-width: 800px; 
            }
            
            /* Modal più compatti */
            .modal { 
                width: 98%; 
                max-width: none; 
                margin: 0.5rem;
                max-height: 95vh;
                display: flex;
                flex-direction: column;
                overflow: hidden;
            }
            .modal-body { 
                padding: 0.75rem; 
                overflow-x: hidden;
            }
            .modal-footer {
                flex-wrap: wrap;
                gap: 0.5rem;
                padding: 0.75rem;
            }
            .modal-footer-left,
            .modal-footer-right {
                flex-wrap: wrap;
                gap: 0.5rem;
            }
            
            /* MOBILE: Modal a schermo intero con footer sempre visibile */
            .modal-overlay {
                padding: 0;
            }
            .modal {
                max-height: 100vh;
                height: 100vh;
                margin: 0;
                border-radius: 0;
                display: flex;
                flex-direction: column;
            }
            .modal-header {
                padding: 0.75rem 1rem;
                flex-shrink: 0;
            }
            .modal-body {
                flex: 1;
                overflow-y: auto;
                padding: 0.75rem;
                -webkit-overflow-scrolling: touch;
            }
            .modal-footer {
                flex-shrink: 0;
                padding: 0.5rem;
                gap: 0.3rem;
                position: relative;
                bottom: 0;
                background: var(--bg-secondary);
                border-top: 2px solid var(--border-color);
                box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
            }
            .modal-footer .btn {
                padding: 0.5rem 0.75rem;
                font-size: 0.8rem;
            }
            .modal-footer-left,
            .modal-footer-right {
                gap: 0.3rem;
            }
            /* Nascondi alcuni bottoni meno importanti su mobile */
            .modal-footer #btnRegistraDispositivi,
            .modal-footer #btnExportFattura {
                display: none !important;
            }
            
            /* Form section compatte */
            .form-section { 
                padding: 0.75rem; 
                margin-bottom: 0.75rem; 
            }
            .form-section h3 { 
                font-size: 0.9rem; 
            }
            
            /* Grid a colonna singola */
            .form-section > div[style*="grid-template-columns: 1fr 1fr"] {
                display: block !important;
            }
            .form-section > div[style*="grid-template-columns: 1fr 1fr"] > div {
                margin-bottom: 0.75rem;
            }
            
            /* Totali compatti su mobile */
            .totali-grid-mobile {
                display: block !important;
            }
            .totali-grid-mobile > div {
                padding: 0.5rem 0;
                border-bottom: 1px solid var(--border-color);
            }
            .totali-grid-mobile > div:last-child {
                border-bottom: none;
            }
            
            /* Pulsanti più grandi per touch */
            .btn { 
                min-height: 44px; 
                padding: 0.6rem 1rem;
            }
            .btn-sm { 
                min-height: 36px; 
            }
            
            /* Righe documento - tabella compatta */
            .rows-table th, .rows-table td {
                padding: 0.15rem 0.1rem;
                font-size: 0.6rem;
            }
            .rows-table input, .rows-table select {
                font-size: 0.6rem !important;
                padding: 0.15rem 0.1rem !important;
                min-width: 30px !important;
            }
            
            /* Grid righe preventivo/fattura */
            .righe-table-unified .righe-header,
            .righe-table-unified .riga-item {
                font-size: 0.55rem;
                gap: 0.15rem;
            }
            .righe-table-unified .riga-item input,
            .righe-table-unified .riga-item select {
                font-size: 0.55rem !important;
                padding: 0.1rem !important;
                min-width: 28px !important;
            }
            
            /* Badge tipo riga più piccolo */
            .row-type-badge {
                font-size: 0.55rem;
                padding: 0.05rem 0.15rem;
            }
            
            /* Pulsanti move più piccoli */
            .btn-move {
                padding: 0.05rem 0.15rem;
                font-size: 0.5rem;
            }
            
            /* Quick day buttons */
            .btn-quick-day {
                padding: 0.4rem 0.5rem;
                font-size: 0.7rem;
            }
        }
            
            /* ================================================================
               MOBILE DOCUMENT MODAL - COMPLETO REFACTORING
               ================================================================ */

        /* ========== RIGHE DOCUMENTO MOBILE - SOLO SCROLL ORIZZONTALE ========== */
        @media (max-width: 768px) {
            /* Container con scroll orizzontale */
            .righe-scroll-container {
                overflow-x: auto !important;
                -webkit-overflow-scrolling: touch;
            }
            
            /* Larghezza minima per forzare scroll */
            .righe-table-unified,
            .righe-table-unified .righe-body {
                min-width: 700px;
            }
            
            /* IMPORTANTE: Forza display grid per header e righe */
            .righe-table-unified .righe-header {
                display: grid !important;
                flex-direction: unset !important;
                font-size: 0.55rem !important;
            }
            .righe-table-unified .riga-item {
                display: grid !important;
                flex-direction: unset !important;
                font-size: 0.65rem !important;
            }
            
            /* Input compatti */
            .righe-table-unified .riga-item input,
            .righe-table-unified .riga-item select {
                font-size: 12px !important;
                padding: 0.2rem !important;
                min-height: 28px !important;
            }
        }
        

/* FullCalendar Event Colors - Tipo documento */
.fc-event.event-riparazione { background-color: #3b82f6 !important; }
.fc-event.event-intervento { background-color: #f97316 !important; }
.fc-event.event-nota { background-color: #fbbf24 !important; color: #1f2937 !important; }
.fc-event.event-nota .fc-event-title { color: #1f2937 !important; }
/* Event colors by state - border */
.fc-event.state-da_fare { border-left: 4px solid #dc2626 !important; }
.fc-event.state-in_lavorazione { border-left: 4px solid #f97316 !important; }
.fc-event.state-da_ordinare { border-left: 4px solid #8b5cf6 !important; }
.fc-event.state-ordinato { border-left: 4px solid #06b6d4 !important; }
.fc-event.state-pronto, .fc-event.state-pronto_consegna { border-left: 4px solid #22c55e !important; }
.fc-event.state-finito_da_fatturare { border-left: 4px solid #22c55e !important; background-color: #15803d !important; }
.fc-event.state-concluso, .fc-event.state-fatturato, .fc-event.state-fatturato_finito { border-left: 4px solid #166534 !important; background-color: #14532d !important; }
.fc-event.event-conclusa { opacity: 0.5 !important; text-decoration: line-through; }
.fc-event.condiviso { border-style: dashed !important; }
#fullcalendar .fc-resource { background: var(--bg-secondary); }
#fullcalendar .fc-resource-cell { background: var(--bg-secondary); }

/* ==================== DASHBOARD STYLES ==================== */
        .dashboard-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 1rem;
            margin-bottom: 1.5rem;
            padding: 1rem;
            background: var(--bg-card);
            border-radius: var(--radius-md);
            border: 1px solid var(--border-color);
        }
        .dashboard-date-nav {
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }
        .dashboard-date-nav button {
            padding: 0.5rem 0.75rem;
            border: 1px solid var(--border-color);
            background: var(--bg-secondary);
            border-radius: var(--radius-sm);
            cursor: pointer;
            font-size: 0.9rem;
        }
        .dashboard-date-nav button:hover {
            background: var(--accent-blue);
            color: white;
        }
        .dashboard-date-nav .current-date {
            font-size: 1.1rem;
            font-weight: 600;
            padding: 0.5rem 1rem;
            background: var(--accent-blue);
            color: white;
            border-radius: var(--radius-sm);
            min-width: 140px;
            text-align: center;
        }
        .dashboard-kpi-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
            gap: 1rem;
            margin-bottom: 1.5rem;
        }
        .dashboard-kpi {
            background: var(--bg-card);
            border-radius: var(--radius-md);
            padding: 1rem;
            text-align: center;
            border: 1px solid var(--border-color);
            cursor: pointer;
            transition: all 0.2s;
        }
        .dashboard-kpi:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
        .dashboard-kpi .kpi-icon {
            font-size: 1.5rem;
            margin-bottom: 0.25rem;
        }
        .dashboard-kpi .kpi-value {
            font-size: 1.75rem;
            font-weight: 700;
        }
        .dashboard-kpi .kpi-label {
            font-size: 0.75rem;
            color: var(--text-muted);
            text-transform: uppercase;
        }
        .dashboard-kpi.kpi-danger { border-left: 4px solid #ef4444; }
        .dashboard-kpi.kpi-danger .kpi-value { color: #ef4444; }
        .dashboard-kpi.kpi-warning { border-left: 4px solid #f59e0b; }
        .dashboard-kpi.kpi-warning .kpi-value { color: #f59e0b; }
        .dashboard-kpi.kpi-success { border-left: 4px solid #22c55e; }
        .dashboard-kpi.kpi-success .kpi-value { color: #22c55e; }
        .dashboard-kpi.kpi-info { border-left: 4px solid #3b82f6; }
        .dashboard-kpi.kpi-info .kpi-value { color: #3b82f6; }
        
        .dashboard-section {
            background: var(--bg-card);
            border-radius: var(--radius-md);
            border: 1px solid var(--border-color);
            margin-bottom: 1rem;
            overflow: hidden;
        }
        .dashboard-section-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0.75rem 1rem;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border-color);
            font-weight: 600;
        }
        .dashboard-section-header .badge {
            background: var(--accent-blue);
            color: white;
            padding: 0.2rem 0.6rem;
            border-radius: 12px;
            font-size: 0.8rem;
        }
        .dashboard-section-body {
            padding: 0;
            max-height: 400px;
            overflow-y: auto;
        }
        
        /* Timeline */
        .dashboard-timeline {
            position: relative;
            padding: 0.5rem 0;
        }
        .timeline-hour {
            display: flex;
            align-items: stretch;
            min-height: 50px;
            border-bottom: 1px solid var(--border-color);
        }
        .timeline-hour:last-child { border-bottom: none; }
        .timeline-hour-label {
            width: 50px;
            flex-shrink: 0;
            padding: 0.5rem;
            font-size: 0.75rem;
            color: var(--text-muted);
            text-align: right;
            border-right: 2px solid var(--border-color);
        }
        .timeline-hour-content {
            flex: 1;
            padding: 0.25rem 0.5rem;
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
        }
        .timeline-event {
            background: var(--accent-blue);
            color: white;
            padding: 0.4rem 0.6rem;
            border-radius: var(--radius-sm);
            font-size: 0.8rem;
            cursor: pointer;
        }
        .timeline-event:hover { opacity: 0.9; }
        .timeline-event.event-intervento { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
        .timeline-event.event-appuntamento { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
        .timeline-free {
            color: var(--text-muted);
            font-size: 0.75rem;
            font-style: italic;
        }
        
        /* Task List */
        .dashboard-task {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.75rem 1rem;
            border-bottom: 1px solid var(--border-color);
            transition: background 0.2s;
        }
        .dashboard-task:last-child { border-bottom: none; }
        .dashboard-task:hover { background: var(--bg-secondary); }
        .dashboard-task.task-urgent {
            background: rgba(239, 68, 68, 0.1);
            border-left: 3px solid #ef4444;
        }
        .dashboard-task.task-today {
            background: rgba(245, 158, 11, 0.1);
            border-left: 3px solid #f59e0b;
        }
        .task-priority {
            font-size: 1.25rem;
            width: 30px;
            text-align: center;
        }
        .task-info {
            flex: 1;
            min-width: 0;
        }
        .task-title {
            font-weight: 600;
            font-size: 0.9rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .task-subtitle {
            font-size: 0.75rem;
            color: var(--text-muted);
        }
        .task-meta {
            display: flex;
            gap: 0.5rem;
            font-size: 0.7rem;
            color: var(--text-muted);
            margin-top: 0.25rem;
        }
        .task-actions {
            display: flex;
            gap: 0.25rem;
        }
        .task-actions .btn {
            padding: 0.3rem 0.5rem;
            font-size: 0.75rem;
        }
        
        /* Avvisi Dashboard */
        .dashboard-alert {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.6rem 1rem;
            border-bottom: 1px solid var(--border-color);
            font-size: 0.85rem;
        }
        .dashboard-alert:last-child { border-bottom: none; }
        .dashboard-alert-icon { font-size: 1.1rem; }
        .dashboard-alert-text { flex: 1; }
        .dashboard-alert-action {
            color: var(--accent-blue);
            cursor: pointer;
            font-weight: 500;
        }
        .dashboard-alert-action:hover { text-decoration: underline; }
        
        /* Dashboard Mobile - OTTIMIZZATO */
        @media (max-width: 768px) {
            .dashboard-header {
                flex-direction: column;
                align-items: stretch;
            }
        }

        .legend-color { width: 14px; height: 14px; border-radius: 3px; }

/* ==================== CALENDAR LEGEND ==================== */
.calendar-legend { display: flex; gap: 0.75rem; padding: 0.75rem 1rem; background: var(--bg-secondary); border-radius: var(--radius-sm); flex-wrap: wrap; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; color: var(--text-secondary); }

        /* Fix tabs-wrapper per scroll orizzontale */
        .tabs-wrapper {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-bottom: 1rem;
            min-width: 0;
        }
        .tabs-wrapper .tabs-container {
            flex: 1;
            min-width: 0;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
        }
        .tabs-wrapper .tabs-container::-webkit-scrollbar { display: none; }
        .tabs-wrapper .tabs-actions {
            flex-shrink: 0;
        }

/* Drag & Drop righe */
.riga-item-wrapper.dragging {
    opacity: 0.4 !important;
}
.riga-item-wrapper.drag-over-top {
    border-top: 2px solid #8b5cf6 !important;
}
.riga-item-wrapper.drag-over-bottom {
    border-bottom: 2px solid #8b5cf6 !important;
}
.drag-handle:hover {
    background: rgba(139, 92, 246, 0.15);
    border-radius: 3px;
}
.drag-handle:active {
    cursor: grabbing !important;
}

/* ==================== REDESIGN COMPACT FORM v98 ==================== */

/* Stats row compatta - pill badges */
.stats-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.stat-card { padding: 0.4rem 0.65rem; border-radius: 20px; display: flex; align-items: center; gap: 0.4rem; cursor: pointer; transition: all 0.15s; background: var(--bg-card); border: 1px solid var(--border-color); font-size: 0.8rem; }
.stat-card:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.stat-card.active { border-color: var(--accent-blue); background: rgba(59,130,246,0.1); }
.stat-card .stat-icon { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; flex-shrink: 0; }
.stat-card .stat-info { display: flex; align-items: center; gap: 0.3rem; }
.stat-card .stat-info h3 { font-size: 0.9rem; margin: 0; line-height: 1; }
.stat-card .stat-info p { font-size: 0.7rem; margin: 0; color: var(--text-muted); line-height: 1; white-space: nowrap; }

/* Form section compatta */
.form-section { margin-bottom: 1rem; padding: 0.75rem; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.form-section h3 { font-size: 0.85rem; color: var(--text-secondary); margin: 0 0 0.6rem 0; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border-color); }
.form-group { gap: 0.25rem; }
.form-group label { font-size: 0.75rem; }
.form-group input, .form-group select, .form-group textarea { padding: 0.45rem 0.6rem; font-size: 0.85rem; }

/* Layout 2 colonne info+date su desktop */
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.form-row-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.75rem; }

/* Rich editor compatto */
.rich-editor-container { border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; }
.rich-editor-toolbar { padding: 0.2rem 0.3rem; background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); display: flex; gap: 0.15rem; flex-wrap: wrap; }
.rich-editor-toolbar button { padding: 0.15rem 0.35rem; font-size: 0.7rem; border: 1px solid transparent; border-radius: 3px; background: transparent; cursor: pointer; color: var(--text-secondary); }
.rich-editor-toolbar button:hover { background: var(--bg-primary); border-color: var(--border-color); }
.rich-editor-content { padding: 0.5rem; min-height: 50px; font-size: 0.85rem; }

/* Device box compatto */
.device-box { padding: 0.75rem; background: var(--bg-secondary); border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.device-box .form-grid { gap: 0.5rem; }

/* Accessory checkboxes inline compatto */
.accessory-checkboxes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.accessory-checkboxes label { display: flex; align-items: center; gap: 0.2rem; font-size: 0.75rem; padding: 0.2rem 0.4rem; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 12px; cursor: pointer; white-space: nowrap; }
.accessory-checkboxes label:has(input:checked) { background: rgba(59,130,246,0.1); border-color: var(--accent-blue); }
.accessory-checkboxes input[type="checkbox"] { width: 14px; height: 14px; }

/* Toolbar filtri compatta */
.toolbar-mobile { padding: 0.5rem; margin-bottom: 0.75rem; }
.toolbar-main { gap: 0.4rem; }
.toolbar-filters { gap: 0.4rem; padding-top: 0.5rem; }
.filter-group { gap: 0.15rem; }
.filter-group label { font-size: 0.7rem; }
.filter-select { padding: 0.3rem 0.4rem; font-size: 0.8rem; }
.search-box input { padding: 0.4rem 0.6rem; font-size: 0.85rem; }

/* Bulk actions bar compatto */
.bulk-actions-bar { padding: 0.5rem 0.75rem; gap: 0.4rem; }
.bulk-buttons { gap: 0.3rem; }

/* Quick day buttons compatti */
.btn-quick-day { padding: 0.2rem 0.4rem; font-size: 0.7rem; }

/* ==================== MOBILE REDESIGN v98 ==================== */
@media (max-width: 768px) {
    .stats-row { gap: 0.25rem; justify-content: center; }
    .stat-card { padding: 0.3rem 0.5rem; font-size: 0.72rem; }
    .stat-card .stat-icon { width: 18px; height: 18px; font-size: 0.6rem; }
    .stat-card .stat-info h3 { font-size: 0.8rem; }
    .stat-card .stat-info p { display: none; }
    
    .form-row-2col, .form-row-3col { grid-template-columns: 1fr; }
    
    .form-section { padding: 0.5rem; margin-bottom: 0.75rem; }
    .form-section h3 { font-size: 0.8rem; margin-bottom: 0.5rem; }
    
    .form-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .form-group input, .form-group select { font-size: 0.82rem; padding: 0.4rem 0.5rem; }
    
    /* Info riparazione: 3 col -> stack su mobile */
    .form-section > div[style*="grid-template-columns:100px"] { grid-template-columns: 1fr 1fr !important; }
    .form-section > div[style*="grid-template-columns:100px"] > .form-group:first-child { grid-column: 1 / -1; }
    
    .rich-editor-content { min-height: 40px; }
    
    .device-box { padding: 0.5rem; }
    .device-box .form-grid { grid-template-columns: 1fr 1fr; gap: 0.4rem; }
    
    .toolbar-mobile { padding: 0.5rem; }
    /* Su mobile: filtri nascosti, solo ricerca + bottone visibili */
    .toolbar-filters { display: none !important; }
    .toolbar-filters.show { 
        display: grid !important; 
        grid-template-columns: 1fr 1fr; 
        gap: 0.4rem; 
        padding-top: 0.5rem; 
        margin-top: 0.5rem; 
        border-top: 1px solid var(--border-color);
    }
    .toolbar-filters.show .filter-group { 
        min-width: 0; 
    }
    .toolbar-filters.show .filter-group select,
    .toolbar-filters.show .filter-group input { 
        width: 100%; 
        font-size: 0.8rem;
        min-width: 0;
    }
    /* Checkbox nascondi conclusi su riga intera */
    .toolbar-filters.show .filter-group:last-child {
        grid-column: 1 / -1;
    }
    .filter-toggle { display: flex !important; align-items: center; gap: 0.2rem; font-size: 0.75rem !important; padding: 0.3rem 0.5rem !important; }
    .filter-toggle.active { background: var(--accent-blue) !important; color: white !important; }
    .filter-toggle .filter-icon { transition: transform 0.2s; }
    .filter-toggle.active .filter-icon { transform: rotate(180deg); }
    
    .bulk-actions-bar { flex-direction: column; align-items: stretch; }
    .bulk-buttons { flex-wrap: wrap; justify-content: center; }
    
    /* Modal header compatto mobile */
    .modal-header h2 { font-size: 1rem; }
    
    /* Footer modal buttons wrap */
    .modal-footer .modal-footer-left,
    .modal-footer .modal-footer-right { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
    .stat-card .stat-info p { display: none; }
    .stat-card .stat-icon { display: none; }
    .stat-card { padding: 0.25rem 0.45rem; }
    .stat-card .stat-info h3 { font-size: 0.75rem; }
    
    .form-grid { grid-template-columns: 1fr; }
    .device-box .form-grid { grid-template-columns: 1fr; }
    
    .toolbar-filters.show { grid-template-columns: 1fr !important; }
}

/* ==================== DOC TAB NAV (dentro modal) ==================== */
.doc-tabs-nav { display: flex; gap: 0; border-bottom: 2px solid var(--border-color); overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.doc-tabs-nav::-webkit-scrollbar { display: none; }
.doc-tab-btn { padding: 0.45rem 0.75rem !important; font-size: 0.8rem !important; font-weight: 600 !important; border: none !important; background: none !important; color: var(--text-muted) !important; cursor: pointer; border-bottom: 2px solid transparent !important; margin-bottom: -2px; white-space: nowrap; transition: all 0.15s; }
.doc-tab-btn:hover { color: var(--text-primary) !important; background: var(--bg-secondary) !important; }
.doc-tab-btn.active { color: var(--accent-blue) !important; border-bottom-color: var(--accent-blue) !important; }
.doc-tab-panel { display: none; }
.doc-tab-panel.active { display: block; }

@media (max-width: 480px) {
    .doc-tab-btn { padding: 0.35rem 0.5rem !important; font-size: 0.72rem !important; }
}

/* ================================================================
   MOBILE v110: Footer documenti + Righe migliorati
   ================================================================ */
@media (max-width: 768px) {
    /* Footer documenti: da 2 colonne a 1 colonna su mobile */
    div[style*="grid-template-columns:1fr auto"] {
        grid-template-columns: 1fr !important;
    }
    
    /* Bottoni riga: scroll orizzontale */
    div[style*="gap:0.3rem"][style*="flex-wrap:wrap"] {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    
    /* Bottone elimina riga: compatto a destra */
    .btn-delete {
        min-width: 22px !important;
        max-width: 22px !important;
        min-height: 22px !important;
        max-height: 22px !important;
        padding: 0 !important;
        font-size: 0.6rem !important;
        line-height: 22px !important;
        text-align: center !important;
        border-radius: 4px !important;
        flex-shrink: 0 !important;
    }
    
    /* Drag handle: più compatto su mobile */
    .drag-handle {
        min-width: 16px !important;
        max-width: 16px !important;
    }
    
    /* Rich editor: altezza minima ridotta */
    .rich-editor-content {
        min-height: 40px !important;
    }
    
    /* Rich editor toolbar: compatta */
    .rich-editor-toolbar button {
        padding: 0.1rem 0.25rem !important;
        font-size: 0.65rem !important;
    }
}

@media (max-width: 480px) {
    /* Righe: min-width più piccolo per meno scroll */
    .righe-table-unified .righe-header,
    .righe-table-unified .riga-item {
        min-width: 480px !important;
    }
    
    /* Nascondi anche drag handle su mobile piccolo */
    .drag-handle {
        display: none !important;
    }
    
    /* Footer documenti: testo più piccolo */
    div[style*="min-width:280px"] {
        min-width: 240px !important;
        font-size: 0.78rem !important;
    }
}

/* ==================== SELECT STATO HEADER MODAL ==================== */
.modal-stato-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0.3rem 1.8rem 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.73rem;
    font-weight: 700;
    white-space: nowrap;
    margin-left: auto;
    margin-right: 0.5rem;
    flex-shrink: 0;
    height: 30px;
    border: 1.5px solid rgba(255,255,255,0.08);
    cursor: pointer;
    transition: all 0.15s ease;
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 8px 5px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E");
    max-width: 180px;
    text-overflow: ellipsis;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    letter-spacing: 0.2px;
}
.modal-stato-select:hover {
    filter: brightness(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transform: translateY(-1px);
}
.modal-stato-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25), 0 2px 8px rgba(0,0,0,0.2);
}

/* Colori per stato — sfondo solido semi-trasparente, testo chiaro */
.modal-stato-select.stato-da_fare { background-color: rgba(239,68,68,0.25); color: #fca5a5; }
.modal-stato-select.stato-in_lavorazione { background-color: rgba(245,158,11,0.25); color: #fcd34d; }
.modal-stato-select.stato-da_ordinare { background-color: rgba(251,191,36,0.2); color: #fde68a; }
.modal-stato-select.stato-ordinato { background-color: rgba(34,197,94,0.2); color: #86efac; }
.modal-stato-select.stato-pronto_consegna { background-color: rgba(34,197,94,0.3); color: #4ade80; }
.modal-stato-select.stato-finito_da_fatturare { background-color: rgba(234,179,8,0.3); color: #fde047; }
.modal-stato-select.stato-concluso,
.modal-stato-select.stato-fatturato_finito,
.modal-stato-select.stato-completato,
.modal-stato-select.stato-fatturato { background-color: rgba(34,197,94,0.2); color: #86efac; }
.modal-stato-select.stato-annullato { background-color: rgba(100,116,139,0.25); color: #cbd5e1; }
.modal-stato-select.stato-bozza { background-color: rgba(100,116,139,0.2); color: #cbd5e1; }
.modal-stato-select.stato-inviato { background-color: rgba(59,130,246,0.25); color: #93c5fd; }
.modal-stato-select.stato-accettato,
.modal-stato-select.stato-confermato { background-color: rgba(34,197,94,0.25); color: #86efac; }
.modal-stato-select.stato-rifiutato { background-color: rgba(239,68,68,0.2); color: #fca5a5; }
.modal-stato-select.stato-scaduto { background-color: rgba(245,158,11,0.2); color: #fcd34d; }
.modal-stato-select.stato-da_pagare { background-color: rgba(234,179,8,0.25); color: #fde047; }
.modal-stato-select.stato-pagata { background-color: rgba(34,197,94,0.25); color: #86efac; }
.modal-stato-select.stato-parziale { background-color: rgba(245,158,11,0.25); color: #fcd34d; }
.modal-stato-select.stato-in_attesa { background-color: rgba(99,102,241,0.2); color: #c7d2fe; }
.modal-stato-select.stato-consegnato,
.modal-stato-select.stato-evaso { background-color: rgba(34,197,94,0.2); color: #86efac; }
.modal-stato-select.stato-annullata { background-color: rgba(100,116,139,0.25); color: #cbd5e1; }

/* Tema chiaro */
[data-theme="light"] .modal-stato-select {
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='rgba(0,0,0,0.35)'/%3E%3C/svg%3E");
}
[data-theme="light"] .modal-stato-select.stato-da_fare { background-color: rgba(239,68,68,0.12); color: #dc2626; }
[data-theme="light"] .modal-stato-select.stato-in_lavorazione { background-color: rgba(245,158,11,0.12); color: #d97706; }
[data-theme="light"] .modal-stato-select.stato-da_ordinare { background-color: rgba(251,191,36,0.12); color: #b45309; }
[data-theme="light"] .modal-stato-select.stato-ordinato { background-color: rgba(34,197,94,0.12); color: #16a34a; }
[data-theme="light"] .modal-stato-select.stato-pronto_consegna { background-color: rgba(34,197,94,0.18); color: #15803d; }
[data-theme="light"] .modal-stato-select.stato-finito_da_fatturare { background-color: rgba(234,179,8,0.15); color: #a16207; }
[data-theme="light"] .modal-stato-select.stato-concluso,
[data-theme="light"] .modal-stato-select.stato-fatturato_finito,
[data-theme="light"] .modal-stato-select.stato-completato { background-color: rgba(34,197,94,0.12); color: #16a34a; }
[data-theme="light"] .modal-stato-select.stato-annullato { background-color: rgba(100,116,139,0.12); color: #64748b; }
[data-theme="light"] .modal-stato-select.stato-bozza { background-color: rgba(100,116,139,0.1); color: #64748b; }
[data-theme="light"] .modal-stato-select.stato-inviato { background-color: rgba(59,130,246,0.12); color: #2563eb; }
[data-theme="light"] .modal-stato-select.stato-accettato,
[data-theme="light"] .modal-stato-select.stato-confermato { background-color: rgba(34,197,94,0.12); color: #16a34a; }
[data-theme="light"] .modal-stato-select.stato-rifiutato { background-color: rgba(239,68,68,0.1); color: #dc2626; }
[data-theme="light"] .modal-stato-select.stato-da_pagare { background-color: rgba(234,179,8,0.12); color: #a16207; }
[data-theme="light"] .modal-stato-select.stato-pagata { background-color: rgba(34,197,94,0.12); color: #16a34a; }
[data-theme="light"] .modal-stato-select.stato-parziale { background-color: rgba(245,158,11,0.12); color: #d97706; }

/* Variante su header colorato (preventivi) */
.modal-stato-select-light {
    background-color: rgba(255,255,255,0.18) !important;
    color: white !important;
    border-color: rgba(255,255,255,0.25) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='white'/%3E%3C/svg%3E") !important;
}
.modal-stato-select-light:hover { background-color: rgba(255,255,255,0.28) !important; }
.modal-stato-select-light option { color: #1a1a2e; background: white; }

/* Option dropdown */
.modal-stato-select option { font-weight: 600; padding: 0.3rem 0.5rem; }

@media (max-width: 768px) {
    .modal-stato-select { font-size: 0.65rem; padding: 0.22rem 1.5rem 0.22rem 0.5rem; height: 26px; max-width: 140px; }
}

/* ==================== MOBILE IMPROVEMENTS ==================== */

/* Bottone Nuovo: solo icona su mobile */
@media (max-width: 768px) {
    .btn-nuovo-label { display: none !important; }
    #btnNuovoDocumento {
        min-width: 32px !important;
        max-width: 36px !important;
        padding: 0.3rem 0.45rem !important;
        font-size: 0.95rem !important;
        flex-shrink: 0 !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }
    .btn-nuovo-icon { font-size: 0.95rem; }
}

/* Tabs wrapper con background solido e overflow contenuto */
.tabs-wrapper {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color);
    padding: 0.35rem 0.4rem !important;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 50;
    overflow: hidden !important;
    max-width: 100% !important;
}
@media (max-width: 768px) {
    .tabs-wrapper {
        padding: 0.25rem 0.3rem !important;
        gap: 0.3rem !important;
    }
    .tabs-container {
        gap: 0.15rem !important;
    }
    .tab-btn {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.72rem !important;
        white-space: nowrap !important;
    }
    .tab-btn .tab-label { font-size: 0.68rem !important; }
}

/* Stats-row mobile: scroll orizzontale, non sovrapporre */
@media (max-width: 768px) {
    .stats-row {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 0.4rem !important;
        padding: 0 0.25rem 0.3rem 0.25rem;
        margin: 0 0.25rem 0.75rem 0.25rem !important;
        scrollbar-width: none;
        flex-wrap: nowrap !important;
    }
    .stats-row::-webkit-scrollbar { display: none; }
    .stats-row .stat-card {
        min-width: 85px !important;
        max-width: 95px !important;
        flex-shrink: 0 !important;
        padding: 0.4rem 0.5rem !important;
    }
    .stats-row .stat-card .stat-icon { width: 24px !important; height: 24px !important; font-size: 0.75rem !important; }
    .stats-row .stat-card .stat-info h3 { font-size: 0.9rem !important; }
    .stats-row .stat-card .stat-info p { font-size: 0.58rem !important; }
}

/* Toolbar filtri: contenuto nel div, mai overflow */
.toolbar-mobile {
    max-width: 100% !important;
    box-sizing: border-box !important;
}
.toolbar-main {
    max-width: 100% !important;
}
.toolbar-filters {
    max-width: 100% !important;
    box-sizing: border-box !important;
}
@media (max-width: 768px) {
    .toolbar-mobile {
        padding: 0.5rem !important;
        margin: 0 0.25rem 0.75rem 0.25rem !important;
    }
    .toolbar-filters.show {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.35rem !important;
        padding: 0.4rem 0 0 0 !important;
    }
    .toolbar-filters .filter-group {
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .toolbar-filters .filter-group:last-child {
        grid-column: 1 / -1;
    }
    .toolbar-filters select,
    .toolbar-filters input {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        text-overflow: ellipsis !important;
        font-size: 0.78rem !important;
    }
    .toolbar-filters .checkbox-label {
        font-size: 0.78rem !important;
        white-space: nowrap !important;
    }
    .filter-toggle {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 0.35rem 0.5rem !important;
        font-size: 0.72rem !important;
    }
    .search-box {
        min-width: 0 !important;
        flex: 1 !important;
    }
    .search-box input {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 0.8rem !important;
    }
}
@media (max-width: 480px) {
    .toolbar-filters.show {
        grid-template-columns: 1fr !important;
    }
}

/* Righe tabella cliccabili */
.row-clickable { cursor: pointer; }
.row-clickable:hover { background: var(--bg-hover) !important; }
