/* ==============================================
   GIGASOLAR PLANNER - Design System v2.0
   Tema CHIARO professionale
   ============================================== */

:root {
    /* Primary - Verde GigaSolar */
    --gs-primary: #059669;
    --gs-primary-dark: #047857;
    --gs-primary-light: #10b981;
    
    /* Secondary - Blu scuro */
    --gs-secondary: #1e3a5f;
    --gs-secondary-dark: #152a45;
    
    /* Accent - Giallo/Arancio */
    --gs-accent: #f59e0b;
    --gs-accent-dark: #d97706;
    
    /* Layer Colors */
    --layer-elettrico: #f59e0b;
    --layer-illuminazione: #eab308;
    --layer-termico: #ef4444;
    --layer-idraulico: #3b82f6;
    --layer-dati: #06b6d4;
    --layer-sicurezza: #a855f7;
    --layer-citofonia: #8b5cf6;
    --layer-scatole: #64748b;
    --layer-fotovoltaico: #22c55e;
    --layer-quadri: #f97316;
    --layer-annotazioni: #6b7280;
    
    /* Light Theme */
    --bg-body: #f8fafc;
    --bg-panel: #ffffff;
    --bg-panel-alt: #f1f5f9;
    --bg-hover: #e2e8f0;
    --bg-selected: rgba(5, 150, 105, 0.1);
    --bg-canvas: #e2e8f0;
    
    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Borders */
    --border-light: #e2e8f0;
    --border-medium: #cbd5e1;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    
    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 
    background: var(--bg-body); 
    color: var(--text-primary); 
    height: 100vh; 
    overflow: hidden; 
}

.app { 
    display: grid; 
    grid-template-columns: 240px 1fr 300px; 
    grid-template-rows: 56px 1fr 36px; 
    height: 100vh; 
}

/* ==============================================
   HEADER
   ============================================== */
.header { 
    grid-column: 1/-1; 
    background: var(--gs-secondary); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 16px; 
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo img {
    height: 36px;
    width: auto;
}
.logo-text {
    font-size: 20px;
    font-weight: 600;
    color: #fbbf24
}
.logo-text span {
    color: var(--gs-accent);
}

.header-center { 
    display: flex; 
    align-items: center; 
    gap: 20px; 
}

.undo-redo { 
    display: flex; 
    gap: 6px; 
}

.btn-undo, .btn-redo { 
    width: 36px; 
    height: 36px; 
    border-radius: var(--radius-sm); 
    border: none; 
    background: rgba(255,255,255,0.1); 
    color: white; 
    font-size: 18px; 
    cursor: pointer; 
    transition: all 0.2s; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.btn-undo:hover:not(:disabled), .btn-redo:hover:not(:disabled) { 
    background: var(--gs-primary); 
}

.btn-undo:disabled, .btn-redo:disabled { 
    opacity: 0.3; 
    cursor: not-allowed; 
}

.project-name-wrapper { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    background: rgba(255,255,255,0.1); 
    border: 1px solid rgba(255,255,255,0.2); 
    border-radius: var(--radius-md); 
    padding: 6px 14px; 
    cursor: text; 
    transition: all 0.2s; 
}

.project-name-wrapper:hover { 
    background: rgba(255,255,255,0.15); 
}

.project-name-wrapper:focus-within { 
    border-color: var(--gs-accent); 
    box-shadow: 0 0 0 3px rgba(245,158,11,0.2); 
}

.project-icon { 
    font-size: 16px; 
}

.project-name { 
    background: transparent; 
    border: none; 
    color: white; 
    font-family: inherit; 
    font-size: 14px; 
    font-weight: 600; 
    width: 200px; 
    outline: none; 
}

.project-edit-icon { 
    font-size: 12px; 
    opacity: 0.5; 
}

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

.btn { 
    padding: 8px 16px; 
    border-radius: var(--radius-md); 
    font-family: inherit; 
    font-weight: 600; 
    font-size: 12px; 
    cursor: pointer; 
    border: none; 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    transition: all 0.2s; 
}

.btn-primary { 
    background: var(--gs-accent); 
    color: var(--gs-secondary); 
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}

.btn-primary:hover { 
    background: var(--gs-accent-dark); 
    transform: translateY(-1px);
}

.btn-secondary { 
    background: rgba(255,255,255,0.1); 
    color: white; 
}

.btn-secondary:hover { 
    background: rgba(255,255,255,0.2); 
}

.btn-accent { 
    background: var(--gs-primary); 
    color: white; 
    box-shadow: 0 2px 8px rgba(34,197,94,0.3);
}

.btn-accent:hover { 
    background: #16a34a; 
    transform: translateY(-1px);
}

/* ==============================================
   LEFT PANEL - TOOLS
   ============================================== */
.tools-panel { 
    background: var(--bg-panel); 
    border-right: 1px solid var(--border-light); 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

.panel-section { 
    padding: 14px; 
    border-bottom: 1px solid var(--border-light); 
}

.panel-title { 
    font-size: 10px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    color: var(--text-muted); 
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-auto-all {
    font-size: 9px;
    padding: 3px 8px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--gs-primary) 0%, #16a34a 100%);
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}
.btn-auto-all:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(34,197,94,0.4);
}

.upload-zone { 
    border: 2px dashed var(--border-medium); 
    border-radius: var(--radius-md); 
    padding: 16px; 
    text-align: center; 
    cursor: pointer; 
    transition: all 0.3s;
    background: var(--bg-panel-alt);
}

.upload-zone:hover { 
    border-color: var(--gs-primary); 
    background: var(--bg-selected);
}

.upload-zone.has-image { 
    border-style: solid; 
    border-color: var(--gs-primary); 
}

.upload-icon { 
    font-size: 28px; 
    margin-bottom: 4px;
}

.upload-text { 
    font-size: 11px; 
    color: var(--text-muted); 
}

/* Tools Accordion */
.tools-accordion { 
    flex: 1; 
    overflow-y: auto; 
    padding: 8px; 
}

.tool-category { 
    margin-bottom: 4px; 
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tool-category-header { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 10px 12px; 
    background: var(--bg-panel-alt); 
    cursor: pointer; 
    border-radius: var(--radius-sm); 
    transition: all 0.2s;
    border: 1px solid transparent;
}

.tool-category-header:hover { 
    background: var(--bg-hover); 
}

.tool-category.active .tool-category-header { 
    background: var(--gs-secondary); 
    color: white;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0; 
}

.tool-category-icon { 
    width: 24px; 
    height: 24px; 
    border-radius: var(--radius-sm); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 14px;
    background: white;
    box-shadow: var(--shadow-sm);
}

.tool-category.active .tool-category-icon {
    box-shadow: none;
}

.tool-category-name { 
    flex: 1; 
    font-size: 12px; 
    font-weight: 600; 
}

.tool-category-arrow { 
    font-size: 10px; 
    color: var(--text-muted); 
    transition: transform 0.2s; 
}

.tool-category.active .tool-category-arrow { 
    transform: rotate(180deg);
    color: white;
}

.tool-subcategories { 
    display: none; 
    background: var(--bg-panel-alt); 
    border-radius: 0 0 var(--radius-sm) var(--radius-sm); 
    padding: 8px;
    border: 1px solid var(--border-light);
    border-top: none;
}

.tool-category.active .tool-subcategories { 
    display: block; 
}

.tool-subcategory-header { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 6px 8px; 
    cursor: pointer; 
    font-size: 11px; 
    color: var(--text-secondary); 
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.tool-subcategory-header:hover { 
    background: var(--bg-hover); 
    color: var(--text-primary); 
}

.tool-items { 
    display: none; 
    padding: 6px 0 6px 20px; 
}

.tool-subcategory.active .tool-items { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 4px; 
}

.tool-item { 
    background: white; 
    border: 2px solid var(--border-light); 
    border-radius: var(--radius-sm); 
    padding: 8px 4px; 
    text-align: center; 
    cursor: pointer; 
    transition: all 0.2s;
}

.tool-item:hover { 
    border-color: var(--gs-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.tool-item.selected { 
    border-color: var(--gs-primary); 
    background: var(--bg-selected); 
    box-shadow: 0 0 0 3px rgba(5,150,105,0.15); 
}

.tool-item-symbol { 
    font-size: 16px; 
    display: block; 
    font-family: 'JetBrains Mono', monospace; 
    font-weight: 600;
    margin-bottom: 2px;
}

.tool-item-name { 
    font-size: 8px; 
    color: var(--text-muted); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* ==============================================
   CANVAS AREA
   ============================================== */
.canvas-area { 
    background: var(--bg-canvas); 
    position: relative; 
    display: flex; 
    flex-direction: column; 
}

.canvas-toolbar { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 8px 14px; 
    background: var(--bg-panel); 
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.draw-tools { 
    display: flex; 
    gap: 4px; 
}

.draw-tool { 
    width: 34px; 
    height: 34px; 
    border-radius: var(--radius-sm); 
    border: 2px solid var(--border-light); 
    background: white; 
    color: var(--text-secondary); 
    cursor: pointer; 
    font-size: 14px;
    transition: all 0.2s;
}

.draw-tool:hover { 
    border-color: var(--gs-primary);
    color: var(--gs-primary);
}

.draw-tool.active { 
    background: var(--gs-primary); 
    border-color: var(--gs-primary); 
    color: white;
}

.canvas-container { 
    flex: 1; 
    position: relative; 
    overflow: auto;
    transition: all 0.5s ease;
}

/* v24: EFFETTO 3D ISOMETRICO GLOBALE */
.canvas-container.view-3d {
    perspective: 2000px;
    perspective-origin: 50% 20%;
}

/* Wrapper per trasformare tutto insieme */
.canvas-container.view-3d #mainCanvas,
.canvas-container.view-3d .elements-layer,
.canvas-container.view-3d .snap-guides-layer,
.canvas-container.view-3d .link-lines-layer {
    transform: translate(-50%, -50%) rotateX(55deg) rotateZ(-5deg) scale(0.75);
    transform-style: preserve-3d;
}

.canvas-container.view-3d #mainCanvas {
    box-shadow: 
        0 80px 150px rgba(0,0,0,0.4),
        0 30px 80px rgba(0,0,0,0.25);
}

/* Elementi "sollevati" dal piano */
.canvas-container.view-3d .canvas-element {
    transform-style: preserve-3d;
    filter: drop-shadow(2px 4px 6px rgba(0,0,0,0.3));
}

/* Toggle 3D Button - VERDE=ON, GRIGIO=OFF */
.btn-3d-toggle {
    background: #d1d5db;
    color: #6b7280;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-3d-toggle:hover {
    background: #9ca3af;
    color: white;
    transform: scale(1.05);
}

.btn-3d-toggle.active {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.5);
}

#mainCanvas { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%,-50%); 
    background: white; 
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    transition: all 0.5s ease;
}

.elements-layer { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%,-50%); 
    pointer-events: none; 
}

.elements-layer > * { 
    pointer-events: all; 
}

/* Smart Guides / Snap Lines */
.snap-guides-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    pointer-events: none;
    z-index: 999;
}
.snap-guide {
    stroke: #3b82f6;
    stroke-width: 1;
    stroke-dasharray: 4 3;
    opacity: 0.9;
}
.snap-dot {
    fill: #3b82f6;
}
.snap-label {
    font-size: 9px;
    fill: #3b82f6;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Layers Panel (floating) */
/* Floating Panels - Shared Styles */
.floating-panel {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    z-index: 100;
    box-shadow: var(--shadow-lg);
    transition: box-shadow 0.2s;
    min-width: 160px;
}
.floating-panel:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.floating-panel.dragging {
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    opacity: 0.95;
}
.floating-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: linear-gradient(135deg, var(--gs-secondary) 0%, #2d4a6f 100%);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: move;
    user-select: none;
}
.floating-panel-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}
.floating-panel-controls {
    display: flex;
    gap: 4px;
}
.floating-panel-btn {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.floating-panel-btn:hover {
    background: rgba(255,255,255,0.3);
}
.floating-panel-body {
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}
.floating-panel.collapsed .floating-panel-body {
    display: none;
}
.floating-panel.collapsed {
    min-width: auto;
}

/* Layers Panel */
.layers-panel { 
    position: absolute; 
    top: 12px; 
    right: 12px; 
    background: var(--bg-panel); 
    border: 1px solid var(--border-light); 
    border-radius: var(--radius-md); 
    width: 180px; 
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.layers-panel.collapsed .layers-body { display: none; }
.layers-panel.collapsed { width: auto; min-width: 100px; }
.layers-panel.hidden { display: none; }
.layers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: linear-gradient(135deg, var(--gs-secondary) 0%, #2d4a6f 100%);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: move;
    user-select: none;
}
.layers-title { 
    font-size: 10px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    color: white; 
    display: flex;
    align-items: center;
    gap: 6px;
}
.layers-body { padding: 8px; }

/* Quote Panel - Floating */
.quote-panel-float {
    top: 12px;
    right: 200px;
    width: 220px;
}
.quote-panel-float .floating-panel-body {
    padding: 0;
    max-height: 350px;
}
.quote-panel-float .quote-list {
    padding: 8px;
}
.quote-panel-float .quote-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    font-size: 11px;
}
.quote-panel-float .quote-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}
.quote-panel-float .quote-item.active {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.1) 0%, rgba(16, 185, 129, 0.1) 100%);
    border-color: var(--gs-primary);
}
.quote-panel-float .quote-item-icon { font-size: 14px; width: 20px; text-align: center; }
.quote-panel-float .quote-item-height { 
    font-weight: 700; 
    color: var(--gs-secondary); 
    min-width: 35px;
    font-size: 11px;
}
.quote-panel-float .quote-item-name { font-weight: 600; color: var(--text-primary); }
.quote-panel-float .quote-item-desc { 
    font-size: 9px; 
    color: var(--text-muted); 
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.quote-panel-float .quote-item-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gs-primary);
}
.quote-active-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Checklist Panel - Floating */
.checklist-panel-float {
    width: 280px;
}
.checklist-panel-float .floating-panel-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.checklist-hint {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
}
.checklist-zone-title {
    font-size: 11px;
    font-weight: 700;
    padding: 8px 12px;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border-light);
    color: var(--gs-secondary);
}
.checklist-items {
    padding: 8px;
}
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 11px;
    border: 1px solid transparent;
}
.checklist-item:hover {
    background: var(--bg-hover);
}
.checklist-item.done {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--gs-primary);
}
.checklist-item.done .checklist-label {
    text-decoration: line-through;
    color: var(--text-muted);
}
.checklist-check {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-medium);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.checklist-item.done .checklist-check {
    background: var(--gs-primary);
    border-color: var(--gs-primary);
    color: white;
}
.checklist-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
}
.checklist-label {
    flex: 1;
    font-weight: 500;
}
.checklist-count {
    font-size: 10px;
    font-weight: 700;
    color: var(--gs-primary);
    background: rgba(5,150,105,0.1);
    padding: 2px 6px;
    border-radius: 10px;
}
.checklist-progress {
    padding: 10px 12px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-panel-alt);
}
.checklist-progress-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}
.checklist-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 3px;
    transition: width 0.3s;
}
.checklist-progress-text {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* Data Panel - Floating */
.data-panel-float {
    top: 12px;
    left: 12px;
    width: 220px;
}
.data-panel-float .data-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}
.data-panel-float .data-card {
    background: var(--bg-panel-alt);
    border-radius: var(--radius-sm);
    padding: 6px 4px;
    text-align: center;
    border: 1px solid var(--border-light);
}
.data-panel-float .data-card-icon { font-size: 14px; }
.data-panel-float .data-card-value {
    font-size: 14px;
    font-weight: 800;
    color: var(--gs-secondary);
    line-height: 1.2;
}
.data-panel-float .data-card-label {
    font-size: 7px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.data-panel-float .data-totale {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--gs-primary) 0%, #16a34a 100%);
    border: none;
}
.data-panel-float .data-totale .data-card-value {
    color: white;
    font-size: 18px;
}
.data-panel-float .data-totale .data-card-label { color: rgba(255,255,255,0.8); }
.data-panel-float .data-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}
.data-panel-float .data-actions button {
    flex: 1;
    padding: 5px;
    font-size: 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}
.data-panel-float .data-actions button:hover {
    background: var(--gs-primary);
    color: white;
    border-color: var(--gs-primary);
}
.autosave-badge {
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    color: white;
}
.autosave-badge.saved { background: rgba(34,197,94,0.3); }
.autosave-badge.saving { background: rgba(245,158,11,0.3); animation: pulse 1s infinite; }

/* Sezioni del pannello conteggi */
.data-section {
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 8px;
}
.data-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
}
.data-section-body {
    padding: 8px;
    background: white;
}
.data-section.collapsed .data-section-body { display: none; }
.data-section.collapsed .section-toggle { transform: rotate(-90deg); }
.section-toggle {
    font-size: 10px;
    transition: transform 0.2s;
}
.section-subtotal {
    font-weight: 700;
}

/* Sezione Elettrico */
.data-section.elettrico .data-section-header {
    background: linear-gradient(135deg, #fcd34d 0%, #f59e0b 100%);
    color: #78350f;
}
/* Sezione Idraulico */
.data-section.idraulico .data-section-header {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
}
/* Sezione Climatizzazione */
.data-section.clima .data-section-header {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    color: white;
}
/* Sezione Servizi */
.data-section.servizi .data-section-header {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    color: white;
}
/* Sezione nascosta se vuota */
.data-section.hidden { display: none; }

/* ============================================
   PANNELLO SERVIZI - Floating
   ============================================ */
.servizi-panel-float {
    width: 380px;
    max-height: 85vh;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-panel);
    overflow: hidden;
    z-index: 1100;
}
.servizi-panel-float .floating-panel-header {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    color: white;
}
.servizi-tabs {
    display: flex;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-light);
}
.servizi-tab {
    flex: 1;
    padding: 8px 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}
.servizi-tab:hover {
    background: white;
    color: var(--text-primary);
}
.servizi-tab.active {
    background: white;
    color: var(--gs-primary);
    border-bottom-color: var(--gs-primary);
}
.servizi-tab-icon {
    display: block;
    font-size: 16px;
    margin-bottom: 2px;
}
.servizi-content {
    max-height: 55vh;
    overflow-y: auto;
    padding: 8px;
}
.servizi-area {
    display: none;
}
.servizi-area.active {
    display: block;
}
.servizi-group {
    margin-bottom: 12px;
}
.servizi-group-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 4px 8px;
    background: var(--bg-light);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}
.servizi-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    transition: all 0.2s;
}
.servizi-item:hover {
    background: var(--bg-hover);
}
.servizi-item-check {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-medium);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.servizi-item-check.checked {
    background: var(--gs-primary);
    border-color: var(--gs-primary);
    color: white;
}
.servizi-item-desc {
    flex: 1;
    color: var(--text-primary);
}
.servizi-item-price {
    font-weight: 600;
    color: var(--gs-primary);
    white-space: nowrap;
}
.servizi-item-qty {
    width: 40px;
    padding: 3px 6px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 11px;
}
.servizi-item-subtotal {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 60px;
    text-align: right;
}
.servizi-summary {
    padding: 12px;
    background: var(--bg-light);
    border-top: 1px solid var(--border-light);
}
.servizi-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 4px;
}
.servizi-summary-row.total {
    font-size: 13px;
    font-weight: 700;
    color: var(--gs-primary);
    padding-top: 8px;
    border-top: 1px solid var(--border-medium);
    margin-top: 8px;
}
.servizi-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-light);
}
.servizi-actions button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.servizi-actions .btn-primary {
    background: var(--gs-primary);
    color: white;
}
.servizi-actions .btn-primary:hover {
    background: var(--gs-hover);
}
.servizi-actions .btn-secondary {
    background: var(--bg-light);
    color: var(--text-secondary);
}
.servizi-actions .btn-secondary:hover {
    background: var(--bg-hover);
}

/* Totale generale */
.data-total-section {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}
.data-total-section .data-totale {
    border-radius: var(--radius-sm);
    padding: 10px;
}

.layer-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 6px 8px; 
    border-radius: var(--radius-sm); 
    cursor: pointer; 
    font-size: 11px;
    transition: all 0.2s;
}

.layer-item:hover { 
    background: var(--bg-hover); 
}

.layer-checkbox { 
    width: 16px; 
    height: 16px; 
    border-radius: 4px; 
    border: 2px solid var(--border-medium); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-size: 10px;
    transition: all 0.2s;
}

.layer-item.active .layer-checkbox { 
    background: var(--gs-primary); 
    border-color: var(--gs-primary);
    color: white;
}

.layer-color { 
    width: 10px; 
    height: 10px; 
    border-radius: 3px; 
}

.layer-count { 
    font-size: 9px; 
    color: var(--text-muted); 
    background: var(--bg-panel-alt); 
    padding: 2px 6px; 
    border-radius: 10px; 
    margin-left: auto; 
}

/* Zoom Controls */
.zoom-controls { 
    position: absolute; 
    bottom: 14px; 
    left: 50%; 
    transform: translateX(-50%); 
    display: flex; 
    gap: 4px; 
    background: var(--bg-panel); 
    padding: 6px; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
}

.zoom-btn { 
    width: 32px; 
    height: 32px; 
    border-radius: var(--radius-sm); 
    border: none; 
    background: var(--bg-panel-alt); 
    color: var(--text-secondary); 
    cursor: pointer; 
    font-size: 16px;
    transition: all 0.2s;
}

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

.zoom-level { 
    padding: 0 12px; 
    display: flex; 
    align-items: center; 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 11px; 
    color: var(--text-secondary);
    font-weight: 600;
}

/* ==============================================
   RIGHT PANEL
   ============================================== */
.right-panel { 
    background: var(--bg-panel); 
    border-left: 1px solid var(--border-light); 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

.zone-section { 
    padding: 14px; 
    border-bottom: 1px solid var(--border-light); 
}

.zone-select-row { 
    display: flex; 
    gap: 8px; 
}

.zone-select { 
    flex: 1; 
    padding: 10px 12px; 
    border-radius: var(--radius-sm); 
    border: 2px solid var(--border-light); 
    background: white; 
    color: var(--text-primary); 
    font-size: 12px;
    font-family: inherit;
}

.zone-select:focus {
    outline: none;
    border-color: var(--gs-primary);
}

/* v23: Bottone NUOVA ZONA nella sidebar sinistra */
.btn-nuova-zona {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--gs-primary) 0%, var(--gs-primary-light) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 10px;
}

.btn-nuova-zona:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.4);
}

/* v23: Lista zone nella sidebar sinistra */
.zone-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.zone-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-panel);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.zone-list-item:hover {
    border-color: var(--gs-primary);
    background: rgba(5, 150, 105, 0.05);
}

.zone-list-item.active {
    border-color: var(--gs-primary);
    background: rgba(5, 150, 105, 0.1);
}

.zone-list-item .zone-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.zone-list-item .zone-info {
    flex: 1;
    min-width: 0;
}

.zone-list-item .zone-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zone-list-item .zone-area {
    font-size: 9px;
    color: var(--text-muted);
}

.zone-list-item .zone-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.zone-list-item:hover .zone-actions {
    opacity: 1;
}

.zone-list-item .zone-action-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 10px;
    border-radius: 4px;
    transition: all 0.15s;
}

.zone-list-item .zone-action-btn:hover {
    background: var(--bg-hover);
}

.zone-list-item .zone-action-btn.delete:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* v23: Zona Generale/Default */
.zone-list-item.default-zone {
    background: var(--bg-panel-alt);
    border-style: dashed;
}

.zone-list-item.default-zone .zone-name {
    font-style: italic;
}

.zone-btn { 
    width: 38px; 
    height: 38px; 
    border-radius: var(--radius-sm); 
    border: 2px solid var(--gs-primary); 
    background: white; 
    color: var(--gs-primary); 
    cursor: pointer; 
    font-size: 18px;
    font-weight: 700;
    transition: all 0.2s;
}

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

.zone-chips { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px; 
    margin-top: 10px; 
}

.zone-chip { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 6px 12px; 
    background: var(--bg-panel-alt); 
    border: 2px solid var(--border-light); 
    border-radius: 20px; 
    font-size: 11px; 
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.zone-chip:hover { 
    border-color: var(--gs-primary);
    background: rgba(5, 150, 105, 0.1);
}

.zone-chip.active { 
    background: var(--gs-primary); 
    border-color: var(--gs-primary);
    color: white;
}

.zone-chip.active:hover {
    background: var(--gs-secondary);
    border-color: var(--gs-secondary);
}

.zone-chip-actions { 
    display: none; 
    gap: 2px; 
}

.zone-chip:hover .zone-chip-actions { 
    display: flex; 
}

.zone-chip-btn { 
    background: none; 
    border: none; 
    cursor: pointer; 
    font-size: 10px; 
    padding: 0 2px; 
    opacity: 0.7; 
}

.zone-chip-btn:hover { 
    opacity: 1; 
}

/* Zone suggestion chips */
.zone-suggestion-chip {
    background: transparent;
    border: 2px dashed var(--gs-primary);
    color: var(--gs-primary);
    cursor: pointer;
}

.zone-suggestion-chip:hover {
    background: var(--bg-selected);
    border-style: solid;
}

/* Quota Chips */
.quota-chip {
    padding: 4px 8px;
    background: white;
    border: 2px solid var(--border-light);
    border-radius: 12px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 2px;
}
.quota-chip:hover {
    border-color: var(--gs-primary);
    background: var(--bg-selected);
}
.quota-chip.active {
    background: var(--gs-secondary);
    border-color: var(--gs-secondary);
    color: white;
}

/* ==============================================
   PANNELLO QUOTE IMPIANTO ELEGANTE
   ============================================== */
.quote-panel {
    background: var(--bg-panel-alt);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-bottom: 12px;
}

.quote-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.quote-panel-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quote-panel-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--gs-primary);
    background: rgba(34, 197, 94, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
}

.quote-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.quote-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 11px;
}

.quote-item:hover {
    background: var(--bg-hover);
}

.quote-item.active {
    background: rgba(34, 197, 94, 0.1);
}

.quote-item-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.quote-item-height {
    font-weight: 700;
    font-size: 12px;
    color: var(--gs-secondary);
    min-width: 32px;
}

.quote-item-name {
    font-weight: 600;
    color: var(--text-primary);
}

.quote-item-desc {
    flex: 1;
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quote-item-active-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    margin-left: auto;
    flex-shrink: 0;
}

.quote-panel-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border-light);
    font-size: 9px;
    color: var(--text-muted);
}

.quote-panel-footer span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Tree Section */
.tree-section { 
    flex: 1; 
    overflow-y: auto; 
    padding: 10px; 
}

.tree-zone { 
    margin-bottom: 6px;
    background: var(--bg-panel-alt);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tree-zone-header { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 10px 12px; 
    cursor: pointer; 
    font-size: 12px; 
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-panel-alt);
    transition: all 0.2s;
}

.tree-zone-header:hover { 
    background: var(--bg-hover); 
}

/* ===== SEZIONI SPECIALI (QUADRI, PREDISPOSIZIONI) NEL TREE ===== */
.tree-special-section {
    margin-bottom: 6px;
    background: var(--bg-panel-alt);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tree-special-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    transition: all 0.2s;
}

.tree-special-section-header:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

.tree-special-section.collapsed .tree-special-section-items {
    display: none;
}

.tree-special-section-items {
    padding: 4px 8px 8px 8px;
}

/* Sottosezioni (Carichi Diretti, Predisposizioni) */
.tree-subsection {
    margin: 4px 0;
    background: rgba(255,255,255,0.8);
    border-radius: var(--radius-sm);
    border-left: 3px solid #94a3b8;
}

.tree-subsection.collapsed > .tree-subsection-items {
    display: none;
}

.tree-subsection-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 10px;
    transition: background 0.15s;
}

.tree-subsection-header:hover {
    background: rgba(0,0,0,0.05);
}

.tree-subsection-header .toggle-arrow {
    font-size: 8px;
    color: var(--text-muted);
    transition: transform 0.2s;
    width: 10px;
}

.tree-subsection.collapsed .tree-subsection-header .toggle-arrow {
    transform: rotate(-90deg);
}

.subsection-name {
    flex: 1;
    font-weight: 600;
    color: #475569;
}

.subsection-count {
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #94a3b8;
    color: white;
    font-weight: 600;
}

.tree-subsection-items {
    padding: 4px 8px 6px 12px;
}

/* Carichi diretti - colore diverso */
.tree-predisposizione.diretta {
    border-left: 2px solid #f59e0b;
    background: #fffbeb;
}

.tree-predisposizione.diretta:hover {
    background: #fef3c7;
    border-color: #d97706;
}

.tree-quadro {
    margin-bottom: 4px;
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.tree-quadro-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    background: white;
    transition: all 0.2s;
}

.tree-quadro-header:hover {
    background: var(--bg-hover);
}

.tree-quadro-header.selected {
    background: var(--bg-selected);
    border-left: 3px solid #f59e0b;
}

.tree-quadro.collapsed .tree-quadro-items {
    display: none;
}

.tree-quadro-items {
    padding: 4px 8px 8px 8px;
    background: var(--bg-panel-alt);
}

.quadro-icon {
    font-size: 14px;
}

.quadro-code {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.quadro-name {
    flex: 1;
    font-size: 10px;
    color: var(--text-muted);
}

.quadro-modules-badge {
    font-size: 9px;
    background: #3b82f6;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.tree-protection {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 3px;
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 10px;
    border-left: 2px solid var(--border);
    transition: all 0.15s;
}

.tree-protection:hover {
    background: var(--bg-hover);
    border-left-color: #f59e0b;
}

.prot-tree-symbol {
    font-size: 12px;
    width: 20px;
    text-align: center;
}

.prot-tree-label {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prot-tree-ampere {
    font-size: 8px;
    background: #f59e0b;
    color: white;
    padding: 1px 4px;
    border-radius: 6px;
    font-weight: 600;
}

.prot-tree-modules {
    font-size: 8px;
    background: #3b82f6;
    color: white;
    padding: 1px 4px;
    border-radius: 6px;
    font-weight: 600;
}

.prot-tree-circuits {
    font-size: 8px;
    background: var(--gs-primary);
    color: white;
    padding: 1px 4px;
    border-radius: 6px;
    font-weight: 600;
}

/* ===== SEZIONE PREDISPOSIZIONI NEL TREE ===== */
.predisposizioni-section .tree-special-section-header {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.predisposizioni-section .tree-special-section-header:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.tree-predisposizione {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 3px;
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 10px;
    border-left: 2px solid var(--border);
    transition: all 0.15s;
}

.tree-predisposizione:hover {
    background: var(--bg-hover);
    border-left-color: #22c55e;
}

.tree-predisposizione.selected {
    background: var(--bg-selected);
    border-left-color: #16a34a;
}

.pred-symbol {
    font-size: 12px;
    width: 20px;
    text-align: center;
}

.pred-code {
    font-family: 'DM Mono', monospace;
    font-size: 9px;
    background: #0ea5e9;
    color: white;
    padding: 1px 5px;
    border-radius: 4px;
}

.pred-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pred-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
}

.tree-predisposizione:hover .pred-actions {
    opacity: 1;
}

.pred-btn {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.pred-btn.plus {
    background: #22c55e;
    color: white;
}

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

.pred-btn.minus {
    background: #ef4444;
    color: white;
}

.pred-btn.minus:hover {
    background: #dc2626;
}

.pred-zone {
    font-size: 8px;
    background: #e2e8f0;
    color: #64748b;
    padding: 1px 5px;
    border-radius: 6px;
}

/* ===== SERVIZI TECNICI (contenitori predisposizioni) ===== */
.tree-servizio {
    margin-bottom: 4px;
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.tree-servizio-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    background: white;
    transition: all 0.2s;
}

.tree-servizio-header:hover {
    background: var(--bg-hover);
}

.tree-servizio-header.selected {
    background: var(--bg-selected);
    border-left: 3px solid #0ea5e9;
}

.tree-servizio.collapsed .tree-servizio-items {
    display: none;
}

.tree-servizio-items {
    padding: 4px 8px 8px 8px;
    background: var(--bg-panel-alt);
}

.servizio-icon {
    font-size: 14px;
}

.servizio-code {
    font-family: 'DM Mono', monospace;
    font-size: 10px;
    background: #0ea5e9;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.servizio-name {
    flex: 1;
    font-size: 10px;
    color: var(--text-muted);
}

.servizio-slots-badge {
    font-size: 9px;
    background: #64748b;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.tree-servizio-fruit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    margin-bottom: 2px;
    background: white;
    border-radius: var(--radius-sm);
    border-left: 2px solid var(--border);
}

.tree-zone.collapsed .tree-items { 
    display: none; 
}

.tree-items { 
    padding: 4px 8px 8px 8px;
}

.tree-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 8px 10px; 
    border-radius: var(--radius-sm); 
    cursor: pointer; 
    font-size: 11px; 
    border-left: 3px solid transparent;
    background: white;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.tree-item:hover { 
    background: var(--bg-hover); 
}

.tree-item.selected { 
    background: var(--bg-selected); 
    border-left-color: var(--gs-primary);
}

.tree-item.blink { 
    animation: blink 0.5s ease infinite; 
}

@keyframes blink { 
    0%,100% { background: var(--bg-selected); } 
    50% { background: rgba(5,150,105,0.3); } 
}

.tree-item-code { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 10px; 
    font-weight: 700; 
    color: var(--gs-primary); 
    min-width: 36px;
    background: rgba(5,150,105,0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.tree-item-symbol { 
    font-size: 14px; 
}

.tree-item-label { 
    flex: 1; 
    color: var(--text-secondary); 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.tree-item-scatola {
    background: rgba(100,116,139,0.08);
    border: 1px solid var(--border-light);
}

.tree-item-frutto {
    margin-left: 16px;
    border-left: 2px solid var(--layer-scatole);
    background: white;
}

.tree-item-luce {
    background: rgba(234,179,8,0.08);
    border: 1px solid rgba(234,179,8,0.2);
}

/* Edit Section - FLOATING DRAGGABLE RESIZABLE */
.edit-section { 
    position: fixed;
    width: 300px;
    min-width: 260px;
    max-width: 450px;
    min-height: 200px;
    max-height: 90vh;
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.25), 0 2px 8px rgba(0,0,0,0.15);
    z-index: 2000;
    background: white;
    border: 2px solid var(--gs-primary);
    resize: both;
    display: flex;
    flex-direction: column;
}

.edit-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--gs-primary) 0%, var(--gs-secondary) 100%);
    cursor: move;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    user-select: none;
    flex-shrink: 0;
}

.edit-section-header .edit-title {
    margin: 0;
    color: white;
    font-size: 12px;
}

.edit-section-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.edit-section-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.edit-section-btn:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.1);
}

.edit-section-btn.fit {
    font-size: 10px;
}

.edit-section-body {
    padding: 14px;
    background: var(--bg-panel-alt);
    overflow-y: auto;
    flex: 1;
}

/* Resize handle visivo */
.edit-section::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, transparent 50%, var(--gs-primary) 50%);
    border-radius: 0 0 var(--radius-lg) 0;
    opacity: 0.5;
    pointer-events: none;
}

.edit-title { 
    font-size: 11px; 
    font-weight: 700; 
    text-transform: uppercase; 
    color: var(--text-muted); 
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Inline edit per nomi nel tree */
.tree-name-editable {
    cursor: text;
    padding: 1px 4px;
    border-radius: 3px;
    transition: all 0.15s;
    min-width: 40px;
}

.tree-name-editable:hover {
    background: rgba(30, 58, 95, 0.1);
}

.tree-name-input {
    background: white;
    border: 2px solid var(--gs-primary);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    min-width: 80px;
    max-width: 140px;
    outline: none;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.2);
}

.edit-row { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 10px; 
}

.edit-label { 
    font-size: 11px; 
    color: var(--text-secondary); 
    width: 55px;
    font-weight: 500;
}

.edit-input { 
    flex: 1; 
    padding: 8px 12px; 
    border-radius: var(--radius-sm); 
    border: 2px solid var(--border-light); 
    background: white; 
    color: var(--text-primary); 
    font-size: 12px;
    font-family: inherit;
}

.edit-input:focus { 
    outline: none; 
    border-color: var(--gs-primary); 
}

.edit-input.mono { 
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--gs-primary);
}

.box-editor { 
    margin-top: 12px; 
    padding: 12px; 
    background: white; 
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.box-slots { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 12px; 
    flex-wrap: wrap; 
}

.box-slot { 
    flex: 1; 
    min-width: 54px; 
    max-width: 70px;
    height: 68px; 
    border: 2px dashed var(--border-medium); 
    border-radius: var(--radius-md); 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    font-size: 14px; 
    cursor: pointer; 
    position: relative; 
    transition: all 0.25s ease;
    background: linear-gradient(135deg, var(--bg-panel-alt) 0%, #f1f5f9 100%);
}

.box-slot::before {
    content: attr(data-slot);
    position: absolute;
    top: 3px;
    left: 6px;
    font-size: 8px;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.6;
}

.box-slot .slot-add-icon {
    font-size: 20px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.box-slot .slot-hint {
    font-size: 7px;
    color: var(--text-muted);
    margin-top: 2px;
    text-align: center;
    line-height: 1.1;
}

.box-slot:hover { 
    border-color: var(--gs-primary); 
    border-style: solid;
    background: linear-gradient(135deg, rgba(5,150,105,0.08) 0%, rgba(5,150,105,0.15) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5,150,105,0.2);
}

.box-slot:hover .slot-add-icon {
    color: var(--gs-primary);
    transform: scale(1.2);
}

.box-slot.filled { 
    border-style: solid; 
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: var(--gs-accent);
    box-shadow: 0 2px 8px rgba(245,158,11,0.15);
}

.box-slot.filled:hover { 
    border-color: var(--gs-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5,150,105,0.25);
}

/* Frutto che occupa 2 posti (es. Schuko, Bipasso) */
.box-slot.double-slot {
    flex: 0 0 calc(50% - 6px); /* Occupa il doppio della larghezza */
    min-width: 100px;
}

.box-slot.filled .fruit-symbol {
    font-size: 18px;
    line-height: 1;
}

.box-slot.filled .fruit-code {
    font-size: 8px;
    font-weight: 700;
    color: var(--gs-secondary);
    margin-top: 2px;
    font-family: 'DM Mono', monospace;
}

.box-slot.filled .fruit-link-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 10px;
    animation: pulse 1.5s infinite;
}

/* Badge numerico per contare punti luce abbinati */
.fruit-link-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    background: #94a3b8;
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.fruit-link-count.has-count {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    animation: badgePulse 2s ease infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.box-slot.filled:hover .fruit-link-count {
    transform: scale(1.15);
}

/* Pulsanti azione sul frutto (rimuovi e cambia tipo) */
.fruit-actions {
    position: absolute;
    top: -8px;
    left: -8px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.box-slot.filled:hover .fruit-actions {
    opacity: 1;
}

.fruit-action-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: all 0.15s;
}

.fruit-action-btn.remove {
    background: #ef4444;
    color: white;
}

.fruit-action-btn.remove:hover {
    background: #dc2626;
    transform: scale(1.15);
}

.fruit-action-btn.edit {
    background: #f59e0b;
    color: white;
    font-size: 10px;
}

.fruit-action-btn.edit:hover {
    background: #d97706;
    transform: scale(1.15);
}

.fruit-action-btn.change {
    background: #3b82f6;
    color: white;
}

.fruit-action-btn.change:hover {
    background: #2563eb;
    transform: scale(1.15);
}

.box-slot.filled.has-links {
    border-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

/* Hint abbinamento */
.box-slots-hint {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    background: #fef9c3;
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: #854d0e;
}

.box-slot.filled.is-command {
    border-color: #facc15;
    background: linear-gradient(135deg, #fefce8 0%, #fef08a 100%);
}

.box-slot.filled.is-command::after {
    content: '⚡';
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 8px;
    opacity: 0.6;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== QUADRO ELETTRICO STYLES ========== */
.quadro-editor {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
    border-color: #f59e0b !important;
    max-height: 50vh;
    overflow-y: auto;
}

.quadro-modules {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: white;
    border-radius: var(--radius-sm);
    min-height: 60px;
    border: 2px dashed #d1d5db;
}

.quadro-module {
    width: 18px;
    height: 50px;
    background: linear-gradient(180deg, #e5e7eb 0%, #d1d5db 100%);
    border: 1px solid #9ca3af;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s;
}

.quadro-module:hover {
    background: linear-gradient(180deg, #dbeafe 0%, #93c5fd 100%);
    border-color: #3b82f6;
}

.quadro-module.occupied {
    background: linear-gradient(180deg, #fef3c7 0%, #fcd34d 100%);
    border-color: #f59e0b;
    cursor: pointer;
    position: relative;
}

.quadro-module.occupied:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(245,158,11,0.5);
    border-color: #d97706;
}

.quadro-module.blink-highlight {
    animation: moduleBlink 0.4s ease infinite;
    z-index: 10;
}

@keyframes moduleBlink {
    0%, 100% { transform: scale(1); box-shadow: 0 0 4px currentColor; }
    50% { transform: scale(1.3); box-shadow: 0 0 12px #f59e0b, 0 0 20px #f59e0b; }
}

/* Card tooltip protezione */
.protection-card-tooltip {
    position: fixed;
    z-index: 9999;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    min-width: 180px;
    transform: translate(-50%, -100%);
    pointer-events: none;
    animation: cardAppear 0.15s ease;
}

@keyframes cardAppear {
    from { opacity: 0; transform: translate(-50%, -90%); }
    to { opacity: 1; transform: translate(-50%, -100%); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

.pct-header {
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pct-symbol {
    font-size: 18px;
}

.pct-label {
    font-weight: 600;
    font-size: 12px;
    color: #1f2937;
}

.pct-body {
    padding: 8px 12px;
}

.pct-row {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    padding: 2px 0;
    border-bottom: 1px solid #f3f4f6;
}

.pct-row:last-child {
    border-bottom: none;
}

.pct-key {
    color: #6b7280;
}

.pct-val {
    font-weight: 600;
    color: #1f2937;
}

.pct-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 0 0 8px 8px;
}

.pct-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.pct-btn.edit {
    background: #f59e0b;
    color: white;
}

.pct-btn.edit:hover {
    background: #d97706;
}

.pct-btn.delete {
    background: #ef4444;
    color: white;
}

.pct-btn.delete:hover {
    background: #dc2626;
}

.protection-card-tooltip {
    pointer-events: auto;
}

.quadro-module.occupied-start {
    border-radius: 2px 2px 0 0;
    border-bottom: none;
}

.quadro-module.occupied-middle {
    border-radius: 0;
    border-top: none;
    border-bottom: none;
}

.quadro-module.occupied-end {
    border-radius: 0 0 2px 2px;
    border-top: none;
}

/* Protezione nel quadro */
.quadro-protection {
    display: flex;
    flex-direction: column;
    background: white;
    border: 2px solid #f59e0b;
    border-radius: var(--radius-sm);
    padding: 2px;
    position: relative;
    cursor: pointer;
    transition: all 0.15s;
}

.quadro-protection:hover {
    border-color: var(--gs-primary);
    box-shadow: 0 2px 8px rgba(5,150,105,0.25);
    transform: translateY(-1px);
}

.quadro-protection .protection-symbol {
    font-size: 14px;
    text-align: center;
    padding: 4px 0;
}

.quadro-protection .protection-label {
    font-size: 6px;
    text-align: center;
    background: #f59e0b;
    color: white;
    padding: 1px 2px;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quadro-protection .protection-ampere {
    font-size: 7px;
    font-weight: 700;
    text-align: center;
    color: #92400e;
}

.quadro-protection .protection-modules {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 14px;
    height: 14px;
    background: #3b82f6;
    color: white;
    font-size: 8px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quadro-protection .protection-actions {
    position: absolute;
    top: -8px;
    left: -8px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.quadro-protection:hover .protection-actions {
    opacity: 1;
}

/* Visualizzazione compatta delle protezioni */
.quadro-protections-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 4px;
}

.quadro-protections-list::-webkit-scrollbar {
    width: 6px;
}

.quadro-protections-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.quadro-protections-list::-webkit-scrollbar-thumb {
    background: #f59e0b;
    border-radius: 3px;
}

.quadro-protections-list::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

.quadro-editor::-webkit-scrollbar {
    width: 6px;
}

.quadro-editor::-webkit-scrollbar-track {
    background: #fef3c7;
    border-radius: 3px;
}

.quadro-editor::-webkit-scrollbar-thumb {
    background: #f59e0b;
    border-radius: 3px;
}

.quadro-editor::-webkit-scrollbar-thumb:hover {
    background: #d97706;
}

.protection-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-sm);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.protection-row:hover {
    border-color: var(--gs-primary);
    background: #f0fdf4;
}

.protection-row .prot-symbol {
    font-size: 16px;
    width: 28px;
    text-align: center;
}

.protection-row .prot-info {
    flex: 1;
}

.protection-row .prot-name {
    font-weight: 600;
    color: var(--text-primary);
}

.protection-row .prot-details {
    font-size: 9px;
    color: var(--text-muted);
}

.protection-row .prot-modules-badge {
    background: #3b82f6;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
}

.protection-row .prot-ampere-badge {
    background: #f59e0b;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
}

.protection-row .prot-circuits-badge {
    background: var(--gs-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
}

/* Box Editor Header and Actions */
.box-editor {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.box-editor-header {
    margin-bottom: 12px;
}

.box-editor-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.box-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 9px;
    font-weight: 600;
}

.box-badge-type {
    background: var(--gs-secondary);
    color: white;
}

.box-badge-ip {
    background: #3b82f6;
    color: white;
}

.box-badge-ip.ip40 {
    background: #64748b;
}

.box-badge-count {
    background: var(--gs-accent);
    color: var(--gs-secondary);
}

.box-editor-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

/* Selettore modello pozzetto */
.box-model-select {
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    border: 2px solid var(--gs-primary);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--gs-primary);
    cursor: pointer;
    transition: all 0.2s;
}
.box-model-select:hover {
    background: var(--gs-primary);
    color: white;
}
.box-model-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

/* Links Editor - Editor Collegamenti */
.links-editor {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border-radius: var(--radius-md);
    border: 1px solid #bfdbfe;
}
.links-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.links-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    background: #3b82f6;
    color: white;
}
.links-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}
.link-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    transition: all 0.15s;
}
.link-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}
.link-card-icon {
    font-size: 16px;
    width: 24px;
    text-align: center;
}
.link-card-info {
    flex: 1;
    min-width: 0;
}
.link-card-code {
    font-weight: 700;
    font-size: 11px;
    color: var(--gs-secondary);
    font-family: 'SF Mono', 'Monaco', monospace;
}
.link-card-name {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.link-card-zone {
    font-size: 9px;
    color: var(--text-muted);
    background: var(--bg-panel-alt);
    padding: 2px 6px;
    border-radius: 8px;
}
.link-card-remove {
    width: 22px;
    height: 22px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.link-card-remove:hover {
    background: #dc2626;
    color: white;
}
.links-editor-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}
.links-editor-tip {
    margin-top: 8px;
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
}
.links-empty {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 11px;
}
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

/* Modal Close Button */
.modal-close-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-panel-alt);
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.modal-close-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.1);
}

/* Fruit Type Selector (230V vs Signal) */
.fruit-type-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--bg-panel-alt);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.fruit-type-btn:hover {
    border-color: var(--gs-primary);
    background: rgba(5,150,105,0.05);
}

.fruit-type-btn.selected {
    border-color: var(--gs-primary);
    background: rgba(5,150,105,0.1);
    color: var(--gs-primary);
}

.fruit-type-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Fruit Category Headers in Modal */
.fruit-category-header {
    grid-column: 1 / -1;
    padding: 8px 12px;
    background: var(--gs-secondary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fruit-category-header:first-child {
    margin-top: 0;
}

/* Danger button */
.btn-danger {
    background: #ef4444 !important;
    color: white !important;
}

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

/* ==============================================
   STATUS BAR
   ============================================== */
.status-bar { 
    grid-column: 1/-1; 
    background: var(--bg-panel); 
    border-top: 1px solid var(--border-light); 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 16px; 
    font-size: 11px; 
    color: var(--text-secondary); 
}

.status-left, .status-right { 
    display: flex; 
    align-items: center; 
    gap: 16px; 
}

.status-item { 
    display: flex; 
    align-items: center; 
    gap: 4px; 
}

/* ==============================================
   CANVAS ELEMENTS
   ============================================== */
.canvas-element { 
    position: absolute; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    cursor: move; 
    transform: translate(-50%,-50%); 
    z-index: 10; 
}

.canvas-element-symbol { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 20px; 
    font-weight: 700; 
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: all 0.2s ease-out; 
}

.canvas-element:hover .canvas-element-symbol { 
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px currentColor);
}

.canvas-element.selected .canvas-element-symbol { 
    filter: drop-shadow(0 0 10px currentColor) drop-shadow(0 0 20px currentColor); 
    transform: scale(1.25); 
}

.canvas-element.blink .canvas-element-symbol { 
    animation: elBlink 0.5s ease infinite; 
}

.canvas-element.highlight-quota {
    z-index: 50 !important;
}

.canvas-element.highlight-quota .canvas-element-symbol {
    color: #06b6d4 !important;
    filter: drop-shadow(0 0 12px #06b6d4) drop-shadow(0 0 24px #06b6d4);
}

@keyframes elBlink { 
    0%,100% { filter: drop-shadow(0 0 6px currentColor); transform: scale(1); } 
    50% { filter: drop-shadow(0 0 18px currentColor); transform: scale(1.15); } 
}

.canvas-element-code { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 9px; 
    font-weight: 700; 
    color: var(--gs-secondary);
    background: rgba(255,255,255,0.95);
    padding: 2px 6px; 
    border-radius: 4px; 
    margin-top: 2px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    backdrop-filter: blur(4px);
}

.canvas-element.selected .canvas-element-code { 
    background: var(--gs-accent); 
    color: var(--gs-secondary);
    box-shadow: 0 2px 8px rgba(245,158,11,0.4);
}

/* Scatola/Pozzetto - design minimal */
.canvas-element-scatola {
    background: none;
    border: none;
    padding: 0;
    min-width: auto;
    box-shadow: none;
    transition: all 0.2s ease-out;
}

.canvas-element-scatola:hover {
    transform: translate(-50%,-50%) scale(1.1);
}

.canvas-element-scatola.selected {
    /* Selezione con glow giallo */
}

.canvas-element-scatola .canvas-element-symbol {
    font-size: 14px;
    letter-spacing: -2px;
    color: #64748b;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.canvas-element-scatola:hover .canvas-element-symbol {
    color: var(--gs-primary);
    text-shadow: 0 0 8px rgba(5,150,105,0.4);
}

.canvas-element-scatola.selected .canvas-element-symbol {
    color: var(--gs-accent);
    text-shadow: 0 0 12px rgba(245,158,11,0.5);
}

.canvas-element-scatola .canvas-element-code {
    margin-top: 2px;
    background: var(--gs-secondary);
    color: white;
    font-size: 8px;
    padding: 1px 4px;
}

/* Highlight linked elements on scatola hover */
.canvas-element.highlight-linked .canvas-element-symbol,
.canvas-text-element.highlight-linked {
    animation: pulseHighlight 0.6s ease infinite;
}

@keyframes pulseHighlight {
    0%, 100% { 
        filter: drop-shadow(0 0 10px var(--gs-accent));
        transform: scale(1);
    }
    50% { 
        filter: drop-shadow(0 0 20px var(--gs-accent));
        transform: scale(1.15);
    }
}

/* Highlight da tree */
.canvas-element.highlight-from-tree .canvas-element-symbol {
    animation: treeHighlight 0.8s ease infinite;
}

.canvas-element-scatola.highlight-from-tree {
    /* Highlight con glow blu sui quadratini */
}

.canvas-element-scatola.highlight-from-tree .canvas-element-symbol {
    color: #3b82f6 !important;
    text-shadow: 0 0 12px rgba(59,130,246,0.8), 0 0 24px rgba(59,130,246,0.5) !important;
    animation: scatolaHighlight 0.8s ease infinite;
}

@keyframes scatolaHighlight {
    0%, 100% { 
        text-shadow: 0 0 12px rgba(59,130,246,0.8), 0 0 24px rgba(59,130,246,0.5);
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 20px rgba(59,130,246,1), 0 0 40px rgba(59,130,246,0.8);
        transform: scale(1.1);
    }
}

@keyframes treeHighlight {
    0%, 100% { 
        filter: drop-shadow(0 0 8px #3b82f6) drop-shadow(0 0 16px #3b82f6);
        transform: scale(1.1);
    }
    50% { 
        filter: drop-shadow(0 0 16px #3b82f6) drop-shadow(0 0 32px #3b82f6);
        transform: scale(1.25);
    }
}

/* Highlight multi-colore per gruppi */
.canvas-element.highlight-group {
    z-index: 200 !important;
}
.canvas-element.highlight-group .canvas-element-symbol {
    animation: groupPulse 0.6s ease infinite;
    filter: drop-shadow(0 0 12px var(--group-color, #f59e0b)) drop-shadow(0 0 24px var(--group-color, #f59e0b));
}
.canvas-element.highlight-group .canvas-element-code {
    background: var(--group-color, #f59e0b) !important;
    color: white !important;
    transform: scale(1.1);
}

@keyframes groupPulse {
    0%, 100% { 
        transform: scale(1.1);
    }
    50% { 
        transform: scale(1.4);
    }
}

/* Layer per linee di connessione gruppo */
.group-lines-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 150;
    overflow: visible;
}

.group-connection-line {
    animation: lineGlow 1.2s ease-in-out infinite;
}

@keyframes lineGlow {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Link Lines Layer - SVG per linee di collegamento */
.link-lines-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: top left;
    pointer-events: none;
    z-index: 90;
    overflow: visible;
}

.link-line {
    stroke: var(--gs-accent);
    stroke-width: 2;
    stroke-dasharray: 8, 4;
    fill: none;
    opacity: 0.8;
    animation: dashMove 0.5s linear infinite;
}

.link-line-highlight {
    stroke: var(--gs-primary);
    stroke-width: 3;
    stroke-dasharray: 12, 6;
    animation: dashMove 0.3s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -12; }
}

.link-dot {
    fill: var(--gs-accent);
    r: 4;
}

.canvas-text-element { 
    position: absolute; 
    cursor: move; 
    transform: translate(-50%,-50%); 
    z-index: 100; 
    font-family: 'Inter', sans-serif; 
    font-weight: 600; 
    color: var(--gs-secondary); 
    text-shadow: 1px 1px 2px rgba(255,255,255,0.9), -1px -1px 2px rgba(255,255,255,0.9); 
    white-space: nowrap; 
    padding: 4px 10px; 
    border-radius: var(--radius-sm); 
    transition: all 0.2s; 
}

.canvas-text-element:hover { 
    background: rgba(5,150,105,0.1); 
}

.canvas-text-element.selected { 
    background: rgba(5,150,105,0.15); 
    outline: 2px solid var(--gs-primary); 
}

/* ==============================================
   MODALS
   ============================================== */
.modal-overlay { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background: rgba(0,0,0,0.5); 
    z-index: 1000; 
    align-items: center; 
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { 
    display: flex; 
}

.modal { 
    background: white; 
    border-radius: var(--radius-lg); 
    padding: 24px; 
    max-width: 400px; 
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-title { 
    font-size: 18px; 
    font-weight: 700; 
    margin-bottom: 16px;
    color: var(--gs-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-input { 
    width: 100%; 
    padding: 12px 16px; 
    border-radius: var(--radius-md); 
    border: 2px solid var(--border-light); 
    background: white; 
    color: var(--text-primary); 
    font-size: 14px; 
    margin-bottom: 16px;
    font-family: inherit;
}

.modal-input:focus { 
    outline: none; 
    border-color: var(--gs-primary); 
}

.modal-actions { 
    display: flex; 
    gap: 10px; 
    margin-top: 20px; 
}

.modal-actions .btn { 
    flex: 1; 
    justify-content: center; 
    padding: 12px; 
}

.scatola-options { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 10px; 
    margin-bottom: 16px; 
}

.scatola-option { 
    padding: 16px; 
    border: 2px solid var(--border-light); 
    border-radius: var(--radius-md); 
    text-align: center; 
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-panel-alt);
}

.scatola-option:hover { 
    border-color: var(--gs-primary); 
}

.scatola-option.selected { 
    border-color: var(--gs-primary); 
    background: var(--bg-selected);
    box-shadow: 0 0 0 3px rgba(5,150,105,0.15);
}

.scatola-preview { 
    display: flex; 
    justify-content: center; 
    gap: 4px; 
    margin-bottom: 8px; 
}

.scatola-slot-preview { 
    width: 16px; 
    height: 22px; 
    border: 2px solid var(--text-muted); 
    border-radius: 3px; 
}

.scatola-label { 
    font-size: 11px; 
    color: var(--text-secondary);
    font-weight: 600;
}

.scatola-type-title { 
    font-size: 11px; 
    font-weight: 600; 
    color: var(--text-muted); 
    margin-bottom: 10px; 
    text-transform: uppercase; 
}

.scatola-ip-toggle { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 16px; 
}

.scatola-ip-btn { 
    flex: 1; 
    padding: 14px; 
    border: 2px solid var(--border-light); 
    border-radius: var(--radius-md); 
    background: white; 
    color: var(--text-primary); 
    cursor: pointer; 
    font-size: 12px; 
    text-align: center; 
    transition: all 0.2s; 
}

.scatola-ip-btn:hover { 
    border-color: var(--gs-primary); 
}

.scatola-ip-btn.selected { 
    border-color: var(--gs-primary); 
    background: var(--bg-selected); 
}

.scatola-ip-btn .ip-label { 
    font-weight: 700; 
    display: block;
    font-size: 14px;
    color: var(--gs-secondary);
}

.scatola-ip-btn .ip-desc { 
    font-size: 10px; 
    color: var(--text-muted); 
}

/* ==============================================
   TOOLTIP
   ============================================== */
.element-tooltip { 
    position: fixed; 
    background: white; 
    border: 1px solid var(--border-light); 
    border-radius: var(--radius-md); 
    padding: 14px 16px; 
    z-index: 1000; 
    pointer-events: none; 
    box-shadow: var(--shadow-lg); 
    min-width: 180px; 
    max-width: 280px; 
    display: none; 
}

.element-tooltip.visible { 
    display: block; 
}

.element-tooltip.interactive { 
    pointer-events: auto; 
}

.tooltip-header { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 10px; 
    padding-bottom: 10px; 
    border-bottom: 1px solid var(--border-light); 
}

.tooltip-code { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 12px; 
    font-weight: 700; 
    color: var(--gs-primary); 
    background: rgba(5,150,105,0.1); 
    padding: 4px 8px; 
    border-radius: var(--radius-sm); 
}

.tooltip-symbol { 
    font-size: 20px; 
}

.tooltip-name { 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--text-primary); 
}

.tooltip-row { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 11px; 
    color: var(--text-secondary); 
    margin-top: 6px; 
}

.tooltip-row strong { 
    color: var(--text-primary); 
}

.tooltip-row.clickable { 
    cursor: pointer; 
    padding: 6px 8px; 
    margin: 4px -8px; 
    border-radius: var(--radius-sm); 
    transition: background 0.2s; 
}

.tooltip-row.clickable:hover { 
    background: var(--bg-hover); 
}

.tooltip-group { 
    background: var(--gs-primary); 
    color: white; 
    padding: 2px 8px; 
    border-radius: 10px; 
    font-size: 10px; 
}

/* ==============================================
   MISC
   ============================================== */
.empty-state { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%,-50%); 
    text-align: center; 
    color: var(--text-muted); 
}

.empty-state-icon { 
    font-size: 48px; 
    margin-bottom: 12px; 
    opacity: 0.4; 
}

#fileInput { 
    display: none; 
}

.font-size-control { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    margin-bottom: 16px; 
}

.font-btn { 
    width: 34px; 
    height: 34px; 
    border-radius: var(--radius-sm); 
    border: 2px solid var(--border-light); 
    background: white; 
    color: var(--text-primary); 
    cursor: pointer; 
    font-size: 18px;
    transition: all 0.2s;
}

.font-btn:hover { 
    border-color: var(--gs-primary);
    color: var(--gs-primary);
}

#fontSizeSlider { 
    flex: 1; 
    height: 8px; 
    -webkit-appearance: none; 
    background: var(--border-light); 
    border-radius: 4px; 
}

#fontSizeSlider::-webkit-slider-thumb { 
    -webkit-appearance: none; 
    width: 18px; 
    height: 18px; 
    background: var(--gs-primary); 
    border-radius: 50%; 
    cursor: pointer; 
}

#fontSizeDisplay { 
    min-width: 32px; 
    text-align: center; 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 13px;
    font-weight: 600;
}

.inline-text-input { 
    position: absolute; 
    background: white; 
    border: 2px solid var(--gs-primary); 
    border-radius: var(--radius-sm); 
    padding: 8px 12px; 
    font-family: 'Inter', sans-serif; 
    font-size: 16px; 
    font-weight: 600; 
    color: var(--gs-secondary); 
    outline: none; 
    min-width: 120px; 
    z-index: 200; 
    box-shadow: var(--shadow-md); 
}

.inline-text-hint { 
    position: absolute; 
    font-size: 10px; 
    color: var(--text-muted); 
    background: white; 
    padding: 4px 8px; 
    border-radius: var(--radius-sm); 
    white-space: nowrap; 
    z-index: 201;
    box-shadow: var(--shadow-sm);
}

/* ==============================================
   SISTEMA ABBINAMENTO COMANDI → PUNTI LUCE
   ============================================== */

.link-selector-card {
    position: fixed;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    border: none;
    min-width: 300px;
    max-width: 340px;
    max-height: 500px;
    z-index: 500;
    overflow: hidden;
    transition: box-shadow 0.2s;
}
.link-selector-card.dragging {
    box-shadow: 0 25px 60px rgba(0,0,0,0.35);
    opacity: 0.95;
}

.link-selector-header {
    background: linear-gradient(135deg, var(--gs-primary) 0%, var(--gs-primary-dark) 100%);
    color: white;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: move;
    user-select: none;
}

.link-selector-header-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.link-selector-header-text {
    flex: 1;
}

.link-selector-header-text h4 { 
    margin: 0; 
    font-size: 14px; 
    font-weight: 700; 
}

.link-selector-header-sub {
    font-size: 11px;
    opacity: 0.8;
}

.link-selector-close { 
    background: rgba(255,255,255,0.15); 
    border: none; 
    color: white; 
    font-size: 16px; 
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.link-selector-close:hover { 
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.link-selector-body { 
    padding: 12px; 
    max-height: 380px; 
    overflow-y: auto; 
}

.link-selector-section { 
    margin-bottom: 16px; 
}

.link-selector-section.linked-section .link-selector-section-title {
    color: #10b981;
    border-bottom-color: #10b981;
}

.link-selector-section.available-section .link-selector-section-title {
    color: var(--gs-primary);
}

.link-selector-section.blocked-section .link-selector-section-title {
    color: #94a3b8;
}

.link-selector-section-title { 
    font-size: 10px; 
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    margin-bottom: 8px; 
    border-bottom: 2px solid var(--border-light); 
    padding-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.link-selector-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin: 4px 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid var(--border-light);
    background: white;
}

.link-selector-item:hover { 
    background: var(--bg-selected); 
    border-color: var(--gs-primary);
    transform: translateX(4px);
}

.link-selector-item.linked { 
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(16, 185, 129, 0.15) 100%);
    border-color: #10b981;
}

.link-selector-item.linked:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.15) 100%);
    border-color: #ef4444;
}

.link-selector-item.blocked { 
    opacity: 0.6; 
    cursor: not-allowed; 
    background: var(--bg-panel-alt);
    border-color: transparent;
}

.link-selector-item.blocked:hover {
    transform: none;
    background: var(--bg-panel-alt);
}

.link-selector-item-info { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    flex: 1;
}

.link-selector-item-symbol { 
    font-size: 18px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef9c3;
    border-radius: 8px;
}

.link-selector-item-symbol.blocked {
    background: #e2e8f0;
    opacity: 0.5;
}

.link-selector-item-code { 
    font-family: 'JetBrains Mono', monospace; 
    font-size: 12px; 
    font-weight: 700; 
    color: var(--gs-secondary);
    background: var(--bg-panel-alt);
    padding: 2px 8px;
    border-radius: 6px;
}

.link-selector-item-name { 
    font-size: 11px; 
    color: var(--text-secondary); 
}

.link-selector-item-zone { 
    font-size: 9px; 
    color: var(--text-muted); 
    margin-left: auto;
}

.link-selector-item-action { 
    font-size: 11px; 
    font-weight: 600;
    color: var(--gs-primary);
    padding: 4px 10px;
    background: rgba(5,150,105,0.1);
    border-radius: 12px;
}

.link-selector-item-action.linked {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

.link-selector-item-blocked-by {
    font-size: 10px;
    color: #94a3b8;
    font-style: italic;
}

/* Sezione DEVIATORI - Punti luce da altri pozzetti (selezionabili!) */
.deviator-section {
    background: rgba(59, 130, 246, 0.05);
    border: 1px dashed rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-top: 8px;
}

.deviator-section .link-selector-section-title {
    color: #3b82f6;
}

.link-selector-item.deviator {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.link-selector-item.deviator:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
}

.link-selector-item-other {
    font-size: 9px;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
    margin-right: 8px;
}

.link-selector-item-other-badge {
    font-size: 9px;
    color: #6b7280;
    background: rgba(107, 114, 128, 0.1);
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: auto;
    flex-shrink: 0;
}

.link-selector-item.has-other {
    background: rgba(107, 114, 128, 0.03);
}

.link-selector-item-action.deviator {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
}

.link-selector-info {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f0f9ff;
    border-radius: var(--radius-sm);
    font-size: 10px;
    color: #0369a1;
    line-height: 1.5;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.link-selector-info i {
    font-size: 14px;
    margin-top: 2px;
}

/* Highlight elementi sulla mappa */
.element-box.highlight-from-list {
    transform: scale(1.5) !important;
    z-index: 100 !important;
    filter: drop-shadow(0 0 12px var(--gs-primary)) drop-shadow(0 0 24px var(--gs-primary));
    animation: pulse-highlight 0.6s ease-in-out infinite;
}
@keyframes pulse-highlight {
    0%, 100% { filter: drop-shadow(0 0 12px var(--gs-primary)) drop-shadow(0 0 24px var(--gs-primary)); }
    50% { filter: drop-shadow(0 0 20px var(--gs-primary)) drop-shadow(0 0 40px var(--gs-primary)); }
}

.element-box.highlight-from-tree {
    transform: scale(1.4) !important;
    z-index: 100 !important;
    filter: drop-shadow(0 0 10px #3b82f6) drop-shadow(0 0 20px #3b82f6);
}

.element-box.highlight-linked { filter: drop-shadow(0 0 8px #f59e0b) drop-shadow(0 0 16px #f59e0b); }

/* Linee di collegamento SVG */
.link-lines-layer { position: absolute; top: 50%; left: 50%; width: 100%; height: 100%; pointer-events: none; z-index: 5; overflow: visible; }
.link-line { fill: none; stroke: #f59e0b; stroke-width: 2; stroke-dasharray: 6,4; stroke-linecap: round; animation: dash-flow 1s linear infinite; }
@keyframes dash-flow { to { stroke-dashoffset: -10; } }
.link-dot { fill: #f59e0b; stroke: white; stroke-width: 2; }

/* Badge abbinamento */
.fruit-link-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 10px; font-weight: 600; color: white; background: var(--gs-primary); cursor: pointer; transition: all 0.2s; }
.fruit-link-badge:hover { transform: scale(1.1); background: var(--gs-primary-dark); }
.fruit-link-badge.empty { background: var(--text-muted); }

/* ==============================================
   TREE COLLASSABILE GERARCHICO
   ============================================== */

.tree-zone { margin-bottom: 8px; background: var(--bg-panel); border-radius: var(--radius-md); overflow: hidden; }
.tree-zone.collapsed > .tree-items { display: none; }

.tree-zone-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--gs-secondary) 0%, #1e3a5f 100%);
    color: white;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
}
.tree-zone-header:hover { 
    background: linear-gradient(135deg, #1e4a6f 0%, #2d5a7f 100%);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.3);
}

/* Zone speciali - colori distintivi */
.tree-zone.zona-tecnica .tree-zone-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.tree-zone.zona-tecnica .tree-zone-header:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}
.tree-zone.zona-garage .tree-zone-header {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}
.tree-zone.zona-garage .tree-zone-header:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}
.tree-zone.zona-esterno .tree-zone-header {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.tree-zone.zona-esterno .tree-zone-header:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}
.tree-zone.zona-predisposizioni .tree-zone-header {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}
.tree-zone.zona-predisposizioni .tree-zone-header:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

/* ========== SEZIONE ELEMENTI IBRIDI (v24) ========== */
.tree-ibridi-section {
    margin-top: 8px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(59, 130, 246, 0.1) 100%);
    border: 1px dashed #3b82f6;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.tree-ibridi-section.collapsed .tree-ibridi-items { display: none; }
.tree-ibridi-section.collapsed .toggle-arrow { transform: rotate(-90deg); }

.tree-ibridi-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.tree-ibridi-header:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
.tree-ibridi-header .toggle-arrow { font-size: 10px; opacity: 0.8; transition: transform 0.2s; }

.tree-ibridi-items { padding: 8px; }

.tree-ibridi-zona {
    margin-bottom: 8px;
    background: white;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.tree-ibridi-zona-header {
    padding: 6px 10px;
    background: var(--bg-panel-alt);
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}
.tree-ibridi-zona-header .ibridi-count {
    font-size: 9px;
    background: #3b82f6;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.tree-ibrido-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 1px solid var(--border-light);
}
.tree-ibrido-item:last-child { border-bottom: none; }
.tree-ibrido-item:hover { background: var(--bg-hover); }
.tree-ibrido-item.selected { background: var(--bg-selected); }

.tree-ibrido-item .ibrido-symbol { font-size: 14px; width: 20px; text-align: center; }
.tree-ibrido-item .ibrido-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}
.tree-ibrido-item .ibrido-name {
    flex: 1;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== PALLINI FISSAGGIO (v24) ========== */
.fixed-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
}
.fixed-toggle.hybrid {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.1);
}
.fixed-toggle.hybrid:hover {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
    transform: scale(1.2);
}
.fixed-toggle.fixed {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
}
.fixed-toggle.fixed:hover {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.2);
    transform: scale(1.2);
}
.fixed-toggle.zone-toggle {
    background: rgba(255,255,255,0.2);
    color: white;
}
.fixed-toggle.zone-toggle:hover {
    background: rgba(255,255,255,0.4);
    transform: scale(1.2);
}

.tree-zone-header .toggle-arrow { font-size: 10px; opacity: 0.8; transition: transform 0.2s; width: 14px; cursor: pointer; }
.tree-zone.collapsed .tree-zone-header .toggle-arrow { transform: rotate(-90deg); }

.tree-zone-header .tree-zone-count {
    font-size: 10px;
    background: rgba(255,255,255,0.2);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: auto;
}

.tree-zone-btn {
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 4px;
}
.tree-zone-header:hover .tree-zone-btn { opacity: 0.7; }
.tree-zone-btn:hover { opacity: 1 !important; background: rgba(255,255,255,0.2); }
.tree-zone-btn.delete:hover { background: rgba(239,68,68,0.3); }
.tree-zone-btn.auto { 
    opacity: 1 !important; 
    background: rgba(34,197,94,0.3); 
    animation: pulse-auto 2s ease-in-out infinite;
}
.tree-zone-btn.auto:hover { background: rgba(34,197,94,0.5); }

@keyframes pulse-auto {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50% { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

/* v23: Pallini fissaggio IBRIDO/FISSATO */
.fixed-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 50%;
    margin: 0 4px;
    transition: all 0.2s;
}

.fixed-toggle.hybrid {
    color: #94a3b8;
    border: 1px solid #94a3b8;
}

.fixed-toggle.fixed {
    color: #22c55e;
    background: rgba(34,197,94,0.2);
}

.fixed-toggle:hover {
    transform: scale(1.2);
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
}

/* ===== SEZIONE SERVIZI (Tab Viola) ===== */
.services-tree-section {
    margin-top: 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.services-tree-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.services-tree-header:hover {
    background: rgba(255,255,255,0.1);
}

.services-tree-header .toggle-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    width: 14px;
}

.services-tree-section.collapsed .services-tree-header .toggle-arrow {
    transform: rotate(-90deg);
}

.services-tree-section.collapsed .services-tree-items {
    display: none;
}

.services-tree-icon {
    font-size: 14px;
}

.services-tree-title {
    flex: 1;
}

.services-tree-count {
    font-size: 10px;
    background: rgba(255,255,255,0.2);
    padding: 1px 6px;
    border-radius: 8px;
}

.services-tree-total {
    font-size: 10px;
    background: rgba(255,255,255,0.3);
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 700;
}

.services-tree-items {
    background: rgba(139,92,246,0.1);
    border-top: 1px solid rgba(255,255,255,0.2);
}

.service-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(139,92,246,0.15);
    background: white;
    font-size: 11px;
}

.service-item:last-child {
    border-bottom: none;
}

.service-item:hover {
    background: #faf5ff;
}

.service-item-symbol {
    font-size: 14px;
    width: 24px;
    text-align: center;
}

.service-item-info {
    flex: 1;
}

.service-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.service-item-price {
    color: var(--text-muted);
    font-size: 10px;
}

.service-item-qty {
    display: flex;
    align-items: center;
    gap: 4px;
}

.service-item-qty input {
    width: 40px;
    text-align: center;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 2px;
    font-size: 11px;
}

.service-item-total {
    font-weight: 600;
    color: #8b5cf6;
    min-width: 50px;
    text-align: right;
}

.service-item-remove {
    width: 20px;
    height: 20px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: all 0.2s;
}

.service-item-remove:hover {
    opacity: 1;
    background: #fecaca;
}

.fixed-toggle.zone-toggle {
    font-size: 10px;
    width: 14px;
    height: 14px;
}

.tree-items { padding: 6px; }

/* === APPARECCHI LEVEL === */
.tree-apparecchi {
    margin: 4px 0;
    background: rgba(14, 165, 233, 0.08);
    border-radius: var(--radius-sm);
    border-left: 3px solid #0ea5e9;
}

/* Liberi - elementi non abbinati a pozzetti */
.tree-apparecchi.liberi {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid #f59e0b;
}

.tree-apparecchi.liberi .apparecchi-name {
    color: #d97706;
}

.tree-apparecchi.liberi .apparecchi-count {
    background: #f59e0b;
}

.tree-apparecchio.libero {
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.tree-apparecchio.libero:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}

.tree-apparecchio.libero.selected {
    background: #fde68a;
    border-color: #d97706;
}

.tree-apparecchi.collapsed > .tree-apparecchi-items { display: none; }

.tree-apparecchi-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s;
}
.tree-apparecchi-header:hover { background: rgba(14, 165, 233, 0.15); }
.tree-apparecchi-header .toggle-arrow { font-size: 9px; color: var(--text-muted); transition: transform 0.2s; width: 12px; }
.tree-apparecchi.collapsed .tree-apparecchi-header .toggle-arrow { transform: rotate(-90deg); }

.apparecchi-icon { font-size: 14px; }
.apparecchi-name { flex: 1; font-weight: 600; color: #0ea5e9; }
.apparecchi-count {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #0ea5e9;
    color: white;
    font-weight: 600;
}

.tree-apparecchi-items { padding: 4px 8px 8px 8px; }

.tree-apparecchio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 2px 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 11px;
    background: white;
    border: 1px solid #e0f2fe;
    transition: all 0.15s;
}
.tree-apparecchio:hover {
    background: #e0f2fe;
    border-color: #0ea5e9;
}
.tree-apparecchio.selected {
    background: #bae6fd;
    border-color: #0ea5e9;
}
.apparecchio-symbol { font-size: 14px; }
.apparecchio-code { font-family: monospace; font-size: 10px; font-weight: 600; color: #0369a1; }
.apparecchio-name { flex: 1; color: var(--text-primary); }

/* Pulsanti +/- inline */
.tree-item-actions { display: none; gap: 2px; margin-left: auto; }
.tree-apparecchio:hover .tree-item-actions { display: flex; }
.tree-item-btn {
    width: 18px; height: 18px; border: none; border-radius: 3px;
    cursor: pointer; font-size: 14px; font-weight: bold;
    display: flex; align-items: center; justify-content: center;
}
.tree-item-btn.add { background: #10b981; color: white; }
.tree-item-btn.add:hover { background: #059669; }
.tree-item-btn.remove { background: #ef4444; color: white; }
.tree-item-btn.remove:hover { background: #dc2626; }

/* === QUOTA LEVEL === */
.tree-quota { 
    margin: 4px 0; 
    background: rgba(100,116,139,0.06); 
    border-radius: var(--radius-sm); 
    border-left: 3px solid var(--gs-primary);
}
.tree-quota.collapsed > .tree-quota-items { display: none; }

.tree-quota-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.15s;
}
.tree-quota-header:hover { background: rgba(100,116,139,0.1); }
.tree-quota-header .toggle-arrow { font-size: 9px; color: var(--text-muted); transition: transform 0.2s; width: 12px; }
.tree-quota.collapsed .tree-quota-header .toggle-arrow { transform: rotate(-90deg); }

.tree-quota.force-visible .tree-quota-header {
    background: rgba(34, 197, 94, 0.15);
    border-left: 3px solid #22c55e;
}

.tree-quota.force-visible .quota-name {
    color: #16a34a;
    font-weight: 600;
}

.tree-quota-header .quota-icon { font-size: 14px; }
.tree-quota-header .quota-height { 
    font-weight: 700; 
    font-size: 11px; 
    color: var(--gs-primary); 
    background: rgba(34, 197, 94, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 50px;
    text-align: center;
}
.tree-quota-header .quota-name { 
    flex: 1; 
    font-weight: 500; 
    color: var(--text-primary); 
}
.tree-quota-header .quota-count { 
    font-size: 9px; 
    padding: 2px 6px; 
    border-radius: 10px; 
    background: var(--gs-primary); 
    color: white; 
    font-weight: 600;
}

.tree-quota-items { padding: 4px 8px 8px 8px; }

/* === POZZETTO LEVEL === */
.tree-pozzetto { margin: 2px 0; }
.tree-pozzetto.collapsed > .tree-pozzetto-items { display: none; }

.tree-pozzetto-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 11px;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(100,116,139,0.15);
    transition: all 0.15s;
}
.tree-pozzetto-header:hover { background: rgba(255,255,255,0.9); border-color: var(--gs-primary); }
.tree-pozzetto-header.selected { background: rgba(34, 197, 94, 0.1); border-color: var(--gs-primary); border-left: 3px solid var(--gs-primary); }
.tree-pozzetto-header .toggle-arrow { font-size: 8px; color: var(--text-muted); transition: transform 0.2s; width: 10px; }
.tree-pozzetto.collapsed .tree-pozzetto-header .toggle-arrow { transform: rotate(-90deg); }

.tree-pozzetto-header .pozzetto-code { 
    font-family: monospace; 
    font-weight: 700; 
    font-size: 11px; 
    color: var(--gs-secondary);
    background: rgba(30, 58, 95, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
}
.tree-pozzetto-header .pozzetto-symbol { font-size: 14px; }
.tree-pozzetto-header .pozzetto-type { font-size: 10px; color: var(--text-muted); }
.tree-pozzetto-header .pozzetto-fruit-count { 
    margin-left: auto; 
    font-size: 9px; 
    padding: 2px 6px; 
    border-radius: 10px; 
    background: var(--gs-secondary); 
    color: white;
    font-weight: 600;
}

.tree-pozzetto-items { padding: 4px 0 4px 16px; }

/* === FRUIT ITEMS === */
.tree-fruit-item { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 5px 8px; 
    margin: 2px 0;
    font-size: 10px; 
    cursor: pointer; 
    border-radius: var(--radius-sm); 
    transition: all 0.15s; 
}
.tree-fruit-item:hover { background: rgba(245, 158, 11, 0.1); }
.tree-fruit-item.is-command { border-left: 2px solid #ca8a04; }
.tree-fruit-item.has-links { background: rgba(34, 197, 94, 0.08); }

.tree-fruit-item .fruit-slot { font-size: 8px; color: var(--text-muted); min-width: 20px; }
.tree-fruit-item .fruit-symbol { font-size: 12px; }
.tree-fruit-item .fruit-name { flex: 1; }
.tree-fruit-item .fruit-link-badge { 
    margin-left: auto; 
    font-size: 9px; 
    font-weight: 600;
}
.tree-fruit-item .fruit-link-badge.has-count { color: var(--gs-primary); }
.tree-fruit-item .fruit-link-badge.empty { color: var(--text-muted); }

/* === LINKED LIGHTS === */
.tree-linked-light { 
    display: flex; 
    align-items: center; 
    gap: 6px; 
    padding: 4px 8px 4px 28px; 
    font-size: 9px; 
    color: var(--text-secondary); 
    cursor: pointer; 
    transition: all 0.15s; 
    border-radius: var(--radius-sm);
}
.tree-linked-light:hover { background: rgba(245, 158, 11, 0.1); }

.tree-linked-light .linked-prefix { color: var(--text-muted); font-size: 10px; }
.tree-linked-light .linked-code { 
    font-family: monospace; 
    font-weight: 600; 
    color: var(--gs-primary);
    background: rgba(34, 197, 94, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
}
.tree-linked-light .linked-icon { font-size: 10px; }
.tree-linked-light .linked-name { flex: 1; }
.tree-linked-light .linked-remove { 
    color: #ef4444; 
    font-size: 10px; 
    opacity: 0;
    transition: opacity 0.15s;
}
.tree-linked-light:hover .linked-remove { opacity: 1; }

/* === LIGHT ITEMS (direttamente sotto quota soffitto) === */
.tree-light-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    margin: 2px 0;
    font-size: 10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(100,116,139,0.1);
    transition: all 0.15s;
}
.tree-light-item:hover { background: rgba(255,255,255,0.9); border-color: var(--gs-accent); }
.tree-light-item.selected { background: rgba(250, 204, 21, 0.15); border-color: var(--gs-accent); }
.tree-light-item.unlinked { border-left: 3px solid var(--gs-accent); }
.tree-light-item.linked { border-left: 3px solid var(--gs-primary); opacity: 0.8; }

.tree-light-item .light-code {
    font-family: monospace;
    font-weight: 700;
    font-size: 10px;
    color: var(--gs-primary);
    background: rgba(34, 197, 94, 0.15);
    padding: 1px 5px;
    border-radius: 3px;
}
.tree-light-item .light-icon { font-size: 12px; }
.tree-light-item .light-name { flex: 1; }
.tree-light-item .light-status {
    font-size: 8px;
    padding: 2px 6px;
    border-radius: 8px;
}
.tree-light-item .light-status.unlinked {
    background: rgba(250, 204, 21, 0.2);
    color: #b45309;
}
.tree-light-item .light-status.linked {
    background: rgba(34, 197, 94, 0.15);
    color: var(--gs-primary);
    font-size: 9px;
}

/* === GENERIC TREE ITEM === */
.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    margin: 2px 0;
    font-size: 10px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.tree-item:hover { background: var(--bg-hover); }
.tree-item.selected { background: var(--bg-selected); }

.tree-item .item-code { font-family: monospace; font-weight: 600; }
.tree-item .item-icon { font-size: 12px; }
.tree-item .item-name { flex: 1; }

/* === PREVENTIVO MODAL === */
.preventivo-modal {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* MODAL CLIENTE */
.cliente-modal {
    max-width: 700px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.cliente-form {
    padding: 16px;
    overflow-y: auto;
    max-height: 60vh;
}

.form-section {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-panel-alt);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.form-section h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: var(--gs-primary);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.full {
    flex: 1 1 100%;
}

.form-group label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    transition: border-color 0.2s;
}

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

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

.preventivo-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--gs-secondary) 0%, #1e3a5f 100%);
    color: white;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    position: relative;
}

.preventivo-header h2 {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.preventivo-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preventivo-logo .logo-icon {
    font-size: 24px;
}

.preventivo-logo .logo-text {
    font-weight: 700;
    font-size: 14px;
}

.preventivo-header .modal-close-btn {
    position: absolute;
    right: 12px;
    top: 12px;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
}

.preventivo-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border-light);
}

.preventivo-info-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preventivo-info-row label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.preventivo-info-row input {
    padding: 8px 10px;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.preventivo-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    max-height: 400px;
}

.preventivo-zone {
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.preventivo-zone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--gs-primary) 0%, #16a34a 100%);
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.preventivo-zone-total {
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
}

.preventivo-zone-body {
    padding: 12px 14px;
}

.preventivo-section {
    margin-bottom: 10px;
}

.preventivo-section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed var(--border-light);
}

.preventivo-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 11px;
}

.preventivo-line-desc {
    flex: 1;
}

.preventivo-line-qty {
    width: 40px;
    text-align: center;
    color: var(--text-muted);
}

.preventivo-line-price {
    width: 60px;
    text-align: right;
    color: var(--text-muted);
}

.preventivo-line-total {
    width: 80px;
    text-align: right;
    font-weight: 600;
    color: var(--gs-secondary);
}

.preventivo-line.discount {
    color: var(--gs-primary);
    font-size: 10px;
}

.preventivo-line.discount .preventivo-line-desc {
    padding-left: 12px;
    font-style: italic;
}

.preventivo-footer {
    padding: 16px 20px;
    background: var(--bg-panel-alt);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.preventivo-totals {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 12px;
}

.preventivo-totals .total-row {
    display: contents;
}

.preventivo-totals .total-label {
    text-align: right;
    padding-right: 20px;
}

.preventivo-totals .total-value {
    font-weight: 600;
    text-align: right;
    min-width: 100px;
}

.preventivo-totals .total-row.grand {
    font-size: 16px;
    color: var(--gs-primary);
}

.preventivo-totals .total-row.grand .total-value {
    font-weight: 700;
}

.preventivo-totals .total-row.detail {
    font-size: 11px;
    color: var(--text-muted);
}

.preventivo-totals .total-row.detail .total-label {
    font-weight: 400;
}

.preventivo-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ============================================== */
/* QUADRO WINDOW - Finestra Flottante            */
/* ============================================== */
.quadro-window {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 720px;
    min-width: 500px;
    max-width: 95vw;
    height: 520px;
    min-height: 350px;
    max-height: 90vh;
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0,0,0,0.15), 0 0 0 1px var(--border-light);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.quadro-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gs-secondary);
    cursor: move;
    user-select: none;
}

.quadro-window-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.quadro-window-icon { font-size: 18px; }

.quadro-window-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quadro-model-select {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius-sm);
    color: white;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
}

.quadro-model-select option { background: var(--gs-secondary); color: white; }

.quadro-window-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quadro-window-btn.minimize { background: rgba(255,255,255,0.15); color: white; }
.quadro-window-btn.minimize:hover { background: var(--gs-accent); color: var(--gs-secondary); }
.quadro-window-btn.close { background: rgba(239,68,68,0.3); color: white; }
.quadro-window-btn.close:hover { background: #ef4444; }

.quadro-window-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border-light);
}

.quadro-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
}

.quadro-stat-badge.modules { background: #dbeafe; color: #1d4ed8; }
.quadro-stat-badge.free { background: #dcfce7; color: #16a34a; }
.quadro-stat-badge.protections { background: #fef3c7; color: #d97706; }
.quadro-stat-badge.ampere { background: #ede9fe; color: #7c3aed; }
.quadro-stat-badge.kc { background: #cffafe; color: #0891b2; }
.quadro-stat-badge.installed { background: var(--bg-hover); color: var(--text-secondary); }
.quadro-stat-badge.warning { background: #fee2e2; color: #dc2626; }

.quadro-window-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1px;
    background: var(--border-light);
}

.quadro-protections-panel {
    flex: 1;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
}

.quadro-protections-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border-light);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.quadro-add-btn {
    background: var(--gs-primary);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    padding: 6px 12px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
}

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

.quadro-protections-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.quadro-prot-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}

.quadro-prot-item:hover {
    background: var(--bg-selected);
    border-color: var(--gs-primary);
    transform: translateX(3px);
}

.quadro-prot-symbol {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gs-accent), var(--gs-accent-dark));
    border-radius: var(--radius-sm);
    font-size: 16px;
    color: var(--gs-secondary);
    font-weight: bold;
}

.quadro-prot-info { flex: 1; min-width: 0; }
.quadro-prot-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.quadro-prot-details { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.quadro-prot-badges { display: flex; gap: 4px; }
.quadro-prot-badge { padding: 3px 8px; border-radius: 4px; font-size: 9px; font-weight: 600; }
.quadro-prot-badge.modules { background: #dbeafe; color: #1d4ed8; }
.quadro-prot-badge.circuits { background: #dcfce7; color: #16a34a; }

.quadro-prot-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.quadro-prot-item:hover .quadro-prot-actions { opacity: 1; }

.quadro-prot-action {
    width: 26px; height: 26px; border: none; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.quadro-prot-action.edit { background: #dbeafe; color: #1d4ed8; }
.quadro-prot-action.remove { background: #fee2e2; color: #dc2626; }

.quadro-visual-panel {
    flex: 1;
    min-width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel-alt);
}

.quadro-visual-header {
    padding: 10px 14px;
    background: var(--bg-panel-alt);
    border-bottom: 1px solid var(--border-light);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.quadro-modules-grid {
    flex: 1;
    padding: 16px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.quadro-row {
    display: flex;
    gap: 3px;
    padding: 8px 12px;
    background: var(--bg-panel);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.quadro-window-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-panel-alt);
    border-top: 1px solid var(--border-light);
}

.quadro-footer-btn {
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.quadro-footer-btn.danger { background: #fee2e2; color: #dc2626; }
.quadro-footer-tip { font-size: 10px; color: var(--text-muted); }

.quadro-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    background: 
        linear-gradient(135deg, transparent 30%, var(--border-medium) 30%, var(--border-medium) 40%, transparent 40%),
        linear-gradient(135deg, transparent 50%, var(--border-medium) 50%, var(--border-medium) 60%, transparent 60%),
        linear-gradient(135deg, transparent 70%, var(--border-medium) 70%, var(--border-medium) 80%, transparent 80%);
    border-radius: 0 0 var(--radius-lg) 0;
}

.quadro-window.minimized { height: auto !important; min-height: auto; }
.quadro-window.minimized .quadro-window-body,
.quadro-window.minimized .quadro-window-footer,
.quadro-window.minimized .quadro-window-stats { display: none; }
.quadro-window.minimized .quadro-resize-handle { display: none; }
.quadro-window.dragging { opacity: 0.9; box-shadow: 0 30px 70px rgba(0,0,0,0.2); }

.quadro-empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 20px; color: var(--text-muted); text-align: center;
}
.quadro-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.quadro-empty-text { font-size: 12px; line-height: 1.5; }

/* ==============================================
   AUTH & PROTECTED BUTTONS / TOOLBAR
   ============================================== */
.auth-disabled {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

.toolbar-btn {
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}
.toolbar-btn.btn-primary { background: var(--gs-accent); color: var(--gs-secondary); border-color: var(--gs-accent); }
.toolbar-btn.btn-primary:hover { background: var(--gs-accent-dark); color: var(--gs-secondary); }
.toolbar-btn.btn-warning { background: #d97706; color: #fff; border-color: #b45309; }
.toolbar-btn.btn-warning:hover { background: #b45309; color: #fff; }
.toolbar-btn.btn-info { background: #0ea5e9; color: #fff; border-color: #0284c7; }
.toolbar-btn.btn-info:hover { background: #0284c7; color: #fff; }
.toolbar-btn.btn-success { background: var(--gs-primary); color: #fff; border-color: var(--gs-primary-dark); }
.toolbar-btn.btn-success:hover { background: var(--gs-primary-dark); color: #fff; }

.btn-user {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn-user:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}
.btn-user .user-icon { font-size: 14px; }

.toolbar-spacer {
    flex: 1;
    min-width: 16px;
}

.toolbar-dropdown {
    position: relative;
    display: inline-flex;
}
.toolbar-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 180px;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    padding: 6px 0;
}
.toolbar-dropdown.open .dropdown-menu {
    display: block;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}
.dropdown-item:hover {
    background: var(--bg-hover);
}
.dropdown-arrow {
    font-size: 10px;
    opacity: 0.8;
    margin-left: 4px;
}

/* ==============================================
   GS MODAL (Login required, etc.)
   ============================================== */
.gs-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.gs-modal-content {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 380px;
    max-width: 90vw;
}
.gs-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}
.gs-modal-header h3 { margin: 0; font-size: 18px; color: var(--text-primary); }
.gs-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}
.gs-modal-close:hover { color: var(--text-primary); }
.gs-modal-body {
    padding: 20px;
    color: var(--text-secondary);
}
.gs-modal-body p { margin: 0 0 16px; line-height: 1.5; }
.gs-modal-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.gs-btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.gs-btn-primary {
    background: var(--gs-primary);
    color: #fff;
}
.gs-btn-primary:hover { background: var(--gs-primary-dark); }
.gs-btn-secondary {
    background: var(--gs-secondary);
    color: #fff;
}
.gs-btn-secondary:hover { background: var(--gs-secondary-dark); }
.gs-btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}
.gs-btn-outline:hover { background: var(--bg-hover); }


/* Fix altezza icone toolbar */
.btn-icon, .user-icon {
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* ==============================================
   REDESIGN ELEGANTE - HEADER MINIMALE
   ============================================== */

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.project-name-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.08);
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.project-name-display:hover {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.2);
}

.project-name-display .project-icon {
    font-size: 16px;
}

.project-name-input-pill {
    background: transparent;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: #f8fafc;
    max-width: 200px;
    outline: none;
}

.header .project-name-input-pill::placeholder {
    color: rgba(248, 250, 252, 0.6);
}

.project-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 12px;
    color: inherit;
}

.project-edit-btn:hover {
    opacity: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gs-accent) 0%, #f59e0b 100%);
    border: 2px solid rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
    border-color: var(--gs-accent);
}

#userInitials {
    font-size: 14px;
    font-weight: 700;
    color: var(--gs-secondary);
}

/* ==============================================
   FLOATING ACTION BAR
   ============================================== */

.floating-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    animation: floatBarIn 0.5s ease-out;
}

@keyframes floatBarIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.floating-bar-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 8px 12px;
    box-shadow:
        0 4px 24px rgba(0,0,0,0.3),
        0 0 0 1px rgba(255,255,255,0.05) inset;
}

.fab-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fab-divider {
    width: 1px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
}

.fab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.fab-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.fab-btn:active {
    transform: scale(0.95);
}

.fab-btn.fab-btn-accent {
    background: linear-gradient(135deg, var(--gs-accent) 0%, #f59e0b 100%);
    color: var(--gs-secondary);
}

.fab-btn.fab-btn-accent:hover {
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4);
    transform: translateY(-2px);
}

.fab-btn[data-auth-required].auth-disabled {
    opacity: 0.5;
}

.fab-icon {
    width: 20px;
    height: 20px;
}

.fab-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fab-dropdown {
    position: relative;
}

.fab-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background: rgba(30, 41, 59, 0.98);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 8px;
    min-width: 120px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.fab-dropdown:hover .fab-dropdown-menu {
    opacity: 1;
    visibility: visible;
}

.fab-dropdown-menu button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.fab-dropdown-menu button:hover {
    background: rgba(255,255,255,0.1);
}

/* ==============================================
   WELCOME SCREEN
   ============================================== */

.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--gs-secondary) 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.welcome-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
    padding: 40px;
    animation: welcomeFadeIn 0.8s ease-out;
}

@keyframes welcomeFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-logo {
    margin-bottom: 24px;
}

.welcome-logo-icon {
    font-size: 64px;
    display: inline-block;
    animation: welcomeLogoPulse 2s ease-in-out infinite;
}

@keyframes welcomeLogoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.welcome-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 40px;
}

.welcome-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 40px;
}

.welcome-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 28px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.welcome-btn-primary {
    background: linear-gradient(135deg, var(--gs-accent) 0%, #f59e0b 100%);
    color: var(--gs-secondary);
}

.welcome-btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(251, 191, 36, 0.4);
}

.welcome-btn-secondary {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
}

.welcome-btn-secondary:hover {
    background: rgba(255,255,255,0.12);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

.welcome-btn-icon {
    font-size: 28px;
}

.welcome-btn-text {
    display: flex;
    flex-direction: column;
}

.welcome-btn-text strong {
    font-size: 16px;
    font-weight: 600;
}

.welcome-btn-text small {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 2px;
}

.welcome-recent {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.welcome-recent-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.welcome-recent-list {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-recent-item {
    padding: 12px 20px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    font-size: 13px;
}

.welcome-recent-item:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--gs-accent);
}

/* ==============================================
   AVATAR - STATI GUEST/LOGGATO
   ============================================== */

.user-avatar-guest {
    background: rgba(255,255,255,0.1) !important;
    border: 2px dashed rgba(255,255,255,0.3) !important;
}

.user-avatar-guest:hover {
    background: rgba(255,255,255,0.15) !important;
    border-color: var(--gs-accent) !important;
}

.user-avatar-guest .lock-icon {
    color: var(--text-muted);
    transition: color 0.2s;
}

.user-avatar-guest:hover .lock-icon {
    color: var(--gs-accent);
}

.user-avatar-logged {
    background: linear-gradient(135deg, var(--gs-accent) 0%, #f59e0b 100%) !important;
    border: 2px solid rgba(255,255,255,0.3) !important;
}

.user-avatar-logged:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
}

/* ==============================================
   USER DROPDOWN MENU
   ============================================== */

.user-menu-container {
    position: relative;
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: rgba(30, 41, 59, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 9999;
    overflow: hidden;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255,255,255,0.03);
}

.user-dropdown-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gs-accent) 0%, #f59e0b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--gs-secondary);
}

.user-dropdown-info {
    flex: 1;
    min-width: 0;
}

.user-dropdown-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.user-dropdown-plan {
    margin-top: 6px;
}

.plan-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-badge.plan-free {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.plan-badge.plan-pro {
    background: rgba(251, 191, 36, 0.2);
    color: var(--gs-accent);
}

.plan-badge.plan-operator {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.plan-badge.plan-admin {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

.user-dropdown-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 4px 0;
}

.user-dropdown-items {
    padding: 4px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.user-dropdown-item:hover {
    background: rgba(255,255,255,0.05);
}

.user-dropdown-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.user-dropdown-item:hover svg {
    color: var(--text-primary);
}

.user-dropdown-item-upgrade {
    color: var(--gs-accent);
}

.user-dropdown-item-upgrade svg {
    color: var(--gs-accent);
}

.user-dropdown-item-upgrade:hover {
    background: rgba(251, 191, 36, 0.1);
}

.user-dropdown-item-logout {
    color: #ef4444;
}

.user-dropdown-item-logout svg {
    color: #ef4444;
}

.user-dropdown-item-logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Pulsanti che richiedono PRO */
.fab-btn.pro-disabled {
    opacity: 0.5;
    position: relative;
}

.fab-btn.pro-disabled::after {
    content: 'PRO';
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--gs-accent);
    color: var(--gs-secondary);
    font-size: 8px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 4px;
}

.fab-btn.pro-disabled:hover::before {
    content: 'Passa a PRO per sbloccare';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 8px;
}