/* ===== dashboard-editor-page.css ===== */
    .dashboard-editor-page {
        display: flex;
        flex-direction: column;
        height: 100vh;
        width: 100vw;
        overflow: hidden;
        background: #0a0a14;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
    }

    .editor-main {
        display: flex;
        flex: 1;
        overflow: hidden;
    }

    /* ═══════════ DASHBOARD LOADER — AppStack coherent style ═══════════ */
    .dash-loader {
        position: fixed;
        inset: 0;
        background: var(--bs-body-bg);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
        overflow: hidden;
    }

    .dash-loader-wrap {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }

    /* Skeleton cards stile dashboard */
    .dash-loader-skeleton {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
        width: min(560px, 90vw);
    }

    .sk-card {
        background: var(--bs-card-bg, rgba(255,255,255,0.03));
        border: 1px solid var(--bs-border-color);
        border-radius: 8px;
        padding: 0;
        overflow: hidden;
        opacity: 0;
        animation: skFadeIn .5s ease-out forwards;
    }

    .sk-card-1 { animation-delay: 0s; }
    .sk-card-2 { animation-delay: .15s; }
    .sk-card-3 { animation-delay: .3s; }

    .sk-header {
        height: 18px;
        background: linear-gradient(90deg,
            color-mix(in srgb, var(--bs-primary) 18%, transparent),
            color-mix(in srgb, var(--bs-primary) 10%, transparent));
        border-bottom: 1px solid var(--bs-border-color);
        position: relative;
        overflow: hidden;
    }

    .sk-header::after,
    .sk-row::after {
        content: "";
        position: absolute;
        inset: 0;
        background: linear-gradient(90deg,
            transparent,
            color-mix(in srgb, var(--bs-body-color) 8%, transparent),
            transparent);
        animation: skShimmer 1.4s ease-in-out infinite;
    }

    .sk-row {
        height: 12px;
        margin: 10px 12px;
        background: color-mix(in srgb, var(--bs-body-color) 10%, transparent);
        border-radius: 3px;
        position: relative;
        overflow: hidden;
    }

    .sk-card-1 .sk-row:nth-child(2) { width: 85%; animation-delay: .1s; }
    .sk-card-1 .sk-row:nth-child(3) { width: 70%; animation-delay: .2s; }
    .sk-card-1 .sk-row:nth-child(4) { width: 90%; animation-delay: .3s; }

    .sk-card-2 .sk-row:nth-child(2) { width: 80%; }
    .sk-card-2 .sk-row:nth-child(3) { width: 95%; }
    .sk-card-2 .sk-row:nth-child(4) { width: 65%; }

    .sk-card-3 .sk-row:nth-child(2) { width: 75%; }
    .sk-card-3 .sk-row:nth-child(3) { width: 88%; }

    @keyframes skFadeIn {
        0%   { opacity: 0; transform: translateY(12px); }
        100% { opacity: 1; transform: translateY(0); }
    }

    @keyframes skShimmer {
        0%   { transform: translateX(-100%); }
        100% { transform: translateX(100%); }
    }

    .dash-loader-text {
        display: flex;
        align-items: center;
        gap: 12px;
        color: var(--bs-body-color);
        opacity: 0;
        animation: skFadeIn .5s ease-out .4s forwards;
    }

    .dash-loader-spinner {
        display: inline-flex;
        gap: 4px;
    }

    .dash-loader-spinner span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--bs-primary);
        animation: dashSpinnerBounce 1.2s ease-in-out infinite;
    }

    .dash-loader-spinner span:nth-child(1) { animation-delay: 0s; }
    .dash-loader-spinner span:nth-child(2) { animation-delay: .15s; }
    .dash-loader-spinner span:nth-child(3) { animation-delay: .3s; }

    @keyframes dashSpinnerBounce {
        0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
        40%           { transform: scale(1);   opacity: 1; }
    }

    .dash-loader-label {
        font-size: .85rem;
        font-weight: 500;
        color: var(--bs-body-color);
        opacity: 0.75;
        letter-spacing: .02em;
    }

    /* LEGACY loading-overlay (non più usato, kept for safety) */
    .loading-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        background: #0f172a;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        z-index: 99999;
    }

    [data-bs-theme="light"] .loading-overlay {
        background: var(--bs-body-bg);
    }

    /* Dark theme form controls */
    .modal-content.bg-dark .form-control,
    .modal-content.bg-dark .form-select {
        background-color: #1e293b;
        border-color: #334155;
        color: #fff;
    }

        .modal-content.bg-dark .form-control:focus,
        .modal-content.bg-dark .form-select:focus {
            background-color: #334155;
            border-color: #3b82f6;
            box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
            color: #fff;
        }

    .modal-content.bg-dark .nav-tabs .nav-link {
        color: #94a3b8;
        border: none;
        border-bottom: 2px solid transparent;
    }

        .modal-content.bg-dark .nav-tabs .nav-link.active {
            color: #fff;
            background: transparent;
            border-bottom-color: #3b82f6;
        }

    .modal-content.bg-dark .table-dark {
        --bs-table-bg: transparent;
    }



/* ===== editor-canvas.css ===== */
    /* ========================================
               CANVAS STRUCTURE - QUESTA È LA PARTE CRITICA
               ======================================== */

    /* Wrapper esterno - centra il canvas con aspect-ratio dinamico */
    .canvas-wrapper {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        background: #0a0a14;
        height: 100%;
    }

    /* Frame canvas - aspect-ratio dinamico dal viewer */
    .canvas-scroll-area {
        position: relative;
        width: 100%;
        max-height: 100%;
        /* aspect-ratio settato inline da JS per matchare il viewer */
    }

    /* Canvas vero - DEVE essere absolute con inset 0! */
    .dashboard-canvas {
        position: absolute; /* CRITICO! */
        inset: 0; /* CRITICO! */
        background: #0f172a;
        border-radius: 8px;
        overflow: hidden;
    }

        .dashboard-canvas.show-grid {
            background-image: linear-gradient(rgba(59, 130, 246, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(59, 130, 246, 0.08) 1px, transparent 1px);
            background-size: 1% 2%;
        }

    .canvas-background {
        position: absolute;
        inset: 0;
        pointer-events: none;
        background-position: center;
        background-repeat: no-repeat;
    }

    .canvas-background-img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        object-position: center;
    }


    .canvas-element {
        position: absolute;
        cursor: move;
        outline: 2px solid transparent;
        outline-offset: -2px;
        transition: outline-color 0.15s, box-shadow 0.15s;
        user-select: none;
    }

        .canvas-element:hover {
            outline-color: rgba(59, 130, 246, 0.5);
        }

        .canvas-element.selected {
            outline-color: #3b82f6;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
        }

        .canvas-element.multi-selected {
            outline-color: #f59e0b;
            box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
        }

        .canvas-element.is-locked {
            cursor: default !important;
        }

            .canvas-element.is-locked .resize-handle {
                pointer-events: none !important;
                opacity: 0.25;
            }

            .canvas-element.is-locked .element-toolbar {
                opacity: 0.85;
            }

            .canvas-element.is-locked::after {
                content: "";
                position: absolute;
                inset: 0;
                pointer-events: none;
                background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(245, 158, 11, 0.06) 6px 8px);
            }

        .canvas-element.is-locked.selected {
            outline-color: #f59e0b;
            box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
        }

        .canvas-element.dragging {
            opacity: 0.85;
            cursor: grabbing;
        }

        /* Container */
        .canvas-element.is-container {
            outline: 2px dashed rgba(59, 130, 246, 0.3) !important;
            outline-offset: -2px !important;
            background: rgba(59, 130, 246, 0.05);
        }

        /* Circle elements */
        .canvas-element.is-circle-element {
            aspect-ratio: 1 / 1;
            min-width: 0 !important;
            min-height: 0 !important;
            outline-width: 1px !important;
        }

            .canvas-element.is-circle-element.selected {
                outline-width: 0px !important;
                box-shadow: 0 0 0 2px #3b82f6, 0 0 0 5px rgba(59, 130, 246, 0.3) !important;
            }

            .canvas-element.is-circle-element .element-content {
                width: 100%;
                height: 100%;
                aspect-ratio: 1 / 1;
                box-sizing: border-box;
            }

            .canvas-element.is-circle-element[style*="width: 1%"],
            .canvas-element.is-circle-element[style*="width: 2%"],
            .canvas-element.is-circle-element[style*="width: 3%"],
            .canvas-element.is-circle-element[style*="width: 4%"] {
                outline-width: 0px !important;
                box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.3) !important;
            }

            .canvas-element.is-circle-element .resize-handle {
                z-index: 100;
            }

            .canvas-element.is-circle-element .resize-se {
                bottom: -5px;
                right: -5px;
            }

        .canvas-element.element-circle {
            min-width: 3px;
            min-height: 3px;
        }


    .element-content {
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }


    .element-label {
        position: absolute;
        bottom: -20px;
        left: 0;
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 0.65rem;
        white-space: nowrap;
        opacity: 0;
        transition: opacity 0.2s ease;
    }

    .canvas-element:hover .element-label,
    .canvas-element.selected .element-label,
    .canvas-element.dragging .element-label {
        opacity: 1;
    }

    .element-label .badge {
        padding: 2px 6px;
        font-weight: 600;
    }

    .element-id {
        color: #64748b;
    }

    .parent-indicator {
        color: #f59e0b;
        font-size: 0.6rem;
        margin-left: 4px;
    }

    /* Badge classes */
    .badge-cmp {
        background: #3b82f6;
        color: #fff;
    }

    .badge-gauge {
        background: #22c55e;
        color: #fff;
    }

    .badge-vtag {
        background: #f59e0b;
        color: #fff;
    }

    .badge-img {
        background: #8b5cf6;
        color: #fff;
    }

    .badge-ifr {
        background: #ec4899;
        color: #fff;
    }


    .element-toolbar {
        position: absolute;
        top: -44px;
        right: 0;
        display: flex;
        gap: 4px;
        opacity: 1;
        z-index: 10000;
        background: rgba(30, 41, 59, 0.98);
        padding: 4px 6px;
        border-radius: 6px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
        pointer-events: auto;
        border: 1px solid rgba(59, 130, 246, 0.3);
    }

    .canvas-element.is-locked .element-toolbar {
        border-color: rgba(245, 158, 11, 0.4);
    }

    .lock-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        background: rgba(245, 158, 11, 0.85);
        color: #0f172a;
        border-radius: 4px;
        padding: 1px 5px;
        font-size: 0.65rem;
        z-index: 5;
        pointer-events: none;
    }

    /* Toolbar sotto per elementi in alto */
    .canvas-element[style*="top: 0"] .element-toolbar,
    .canvas-element[style*="top: 1"] .element-toolbar,
    .canvas-element[style*="top: 2"] .element-toolbar,
    .canvas-element[style*="top: 3"] .element-toolbar,
    .canvas-element[style*="top: 4"] .element-toolbar,
    .canvas-element[style*="top: 5%"] .element-toolbar,
    .canvas-element[style*="top: 6%"] .element-toolbar {
        top: auto;
        bottom: -44px;
    }

    .element-toolbar .btn {
        font-size: 0.75rem;
        padding: 4px 8px;
        min-width: 28px;
        transition: all 0.15s ease;
    }

        .element-toolbar .btn:hover {
            transform: scale(1.1);
        }

    .element-toolbar .btn-outline-light:hover {
        background: #3b82f6;
        border-color: #3b82f6;
    }

    .element-toolbar .btn-outline-danger:hover {
        background: #ef4444;
        border-color: #ef4444;
    }

    .element-toolbar .btn-outline-warning:hover {
        background: #f59e0b;
        border-color: #f59e0b;
        color: #000;
    }

    .element-toolbar .btn-outline-primary:hover {
        background: #3b82f6;
        border-color: #3b82f6;
    }

    .btn-outline-cyan {
        color: #22d3ee;
        border-color: #22d3ee;
    }

        .btn-outline-cyan:hover {
            background: #06b6d4;
            border-color: #06b6d4;
            color: #fff;
        }

    .rotate-handle {
        position: absolute;
        top: 4px;
        right: 4px;
        width: 22px;
        height: 22px;
        background: rgba(139, 92, 246, 0.85);
        border: 2px solid #fff;
        border-radius: 50%;
        cursor: crosshair;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-size: 0.6rem;
        z-index: 9999;
        transition: background 0.15s;
        backdrop-filter: blur(2px);
    }

        .rotate-handle:hover {
            background: #7c3aed;
        }

    .resize-handle {
        position: absolute;
        width: 10px;
        height: 10px;
        background: #3b82f6;
        border: 2px solid #fff;
        border-radius: 2px;
    }

    .resize-nw { top: -5px; left: -5px; cursor: nw-resize; }
    .resize-n  { top: -5px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
    .resize-ne { top: -5px; right: -5px; cursor: ne-resize; }
    .resize-w  { top: 50%; left: -5px; transform: translateY(-50%); cursor: w-resize; }
    .resize-e  { top: 50%; right: -5px; transform: translateY(-50%); cursor: e-resize; }
    .resize-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
    .resize-s  { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
    .resize-se { bottom: -5px; right: -5px; cursor: se-resize; }


    /* === ALIGNMENT GUIDES === */
    .alignment-guide {
        position: absolute;
        pointer-events: none;
        z-index: 8000;
    }

    .alignment-guide-v {
        top: 0;
        bottom: 0;
        width: 0;
        border-left: 1px dashed rgba(236, 72, 153, 0.7);
        box-shadow: 0 0 4px rgba(236, 72, 153, 0.3);
    }

    .alignment-guide-h {
        left: 0;
        right: 0;
        height: 0;
        border-top: 1px dashed rgba(236, 72, 153, 0.7);
        box-shadow: 0 0 4px rgba(236, 72, 153, 0.3);
    }

    /* === DROP INDICATOR === */
    .drop-indicator {
        position: absolute;
        padding: 8px 16px;
        background: rgba(59, 130, 246, 0.15);
        border: 2px dashed #3b82f6;
        border-radius: 6px;
        color: #3b82f6;
        font-size: 0.8rem;
        pointer-events: none;
        animation: pulse 1.5s ease-in-out infinite;
    }


    .binding-hint-overlay {
        position: absolute;
        border: 3px solid #22c55e;
        background: rgba(34, 197, 94, 0.1);
        pointer-events: none;
        display: flex;
        align-items: center;
        justify-content: center;
        animation: binding-pulse 1s ease-in-out infinite;
        border-radius: 4px;
        z-index: 5000;
    }

    .binding-hint-text {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        color: #22c55e;
        font-size: 0.9rem;
        font-weight: 700;
        background: transparent;
        padding: 10px 16px;
        border-radius: 8px;
        border: 2px solid #22c55e;
    }


    .draw-rectangle {
        position: absolute;
        border: 3px dashed #f59e0b;
        background: rgba(245, 158, 11, 0.08);
        pointer-events: none;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
    }

    .draw-rectangle.too-small {
        border-color: #ef4444;
        background: rgba(239, 68, 68, 0.12);
    }

    .draw-rectangle.too-small .draw-hint {
        color: #ef4444;
    }

    .draw-hint {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        color: #f59e0b;
        font-size: 0.85rem;
        font-weight: 600;
        background: rgba(15, 23, 42, 0.9);
        padding: 8px 12px;
        border-radius: 6px;
    }

    .empty-canvas {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        color: #64748b;
        pointer-events: none;
    }

        .empty-canvas h5 {
            color: #94a3b8;
        }


    .element-missing {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        background: rgba(239, 68, 68, 0.1);
        border: 1px dashed #ef4444;
        border-radius: 6px;
        color: #ef4444;
        font-size: 0.75rem;
    }

        .element-missing i {
            font-size: 1.2rem;
            margin-bottom: 4px;
        }

    /* ========================================
               ANIMATIONS
               ======================================== */

    @keyframes pulse {
        0%, 100% {
            opacity: 1;
        }

        50% {
            opacity: 0.6;
        }
    }

    @keyframes binding-pulse {
        0%, 100% {
            border-color: #22c55e;
        }

        50% {
            border-color: #4ade80;
        }
    }

    /* === CONTEXT MENU === */
    .ctx-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 99998;
    }

    .ctx-menu {
        position: fixed;
        z-index: 99999;
        background: #1e293b;
        border: 1px solid #334155;
        border-radius: 8px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.6);
        padding: 4px 0;
        min-width: 180px;
        max-height: 400px;
        overflow-y: auto;
    }

    .ctx-item {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 6px 14px;
        border: none;
        background: none;
        color: #e2e8f0;
        font-size: .82rem;
        text-align: left;
        cursor: pointer;
        transition: background 0.12s;
        white-space: nowrap;
    }

        .ctx-item:hover {
            background: rgba(59, 130, 246, 0.18);
        }

        .ctx-item i {
            width: 16px;
            text-align: center;
            color: #94a3b8;
            flex-shrink: 0;
        }

    .ctx-item-danger:hover {
        background: rgba(239, 68, 68, 0.18);
    }

        .ctx-item-danger:hover i {
            color: #ef4444;
        }

    .ctx-item-pick {
        font-size: .78rem;
        padding: 5px 14px;
    }

    .ctx-item-active {
        background: rgba(59, 130, 246, 0.12);
        font-weight: 600;
    }

    .ctx-separator {
        height: 1px;
        background: #334155;
        margin: 4px 8px;
    }

    .ctx-label {
        padding: 4px 14px 2px;
        font-size: .68rem;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: .04em;
        font-weight: 600;
    }

    /* Light mode */
    [data-bs-theme="light"] .ctx-menu {
        background: #fff;
        border-color: var(--bs-border-color);
        box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    }

    [data-bs-theme="light"] .ctx-item {
        color: var(--bs-body-color);
    }

        [data-bs-theme="light"] .ctx-item:hover {
            background: rgba(59, 130, 246, 0.08);
        }

        [data-bs-theme="light"] .ctx-item i {
            color: #6b7280;
        }

    [data-bs-theme="light"] .ctx-separator {
        background: var(--bs-border-color);
    }

    [data-bs-theme="light"] .ctx-label {
        color: #9ca3af;
    }



/* ===== editor-toolbar.css ===== */
    .editor-toolbar {
        height: 56px;
        border-bottom: 1px solid #334155;
        background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%) !important;
        flex-shrink: 0;
    }

    .editor-toolbar .btn-outline-light {
        border-color: rgba(255,255,255,0.25);
        color: #e2e8f0;
    }

    .editor-toolbar .btn-outline-light:hover {
        background: rgba(255,255,255,0.1);
        border-color: rgba(255,255,255,0.4);
        color: #fff;
    }

    .editor-toolbar .btn-success {
        background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
        border: none;
    }

    .editor-toolbar .btn-success:hover:not(:disabled) {
        background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    }

    /* === LIGHT MODE === */
    [data-bs-theme="light"] .editor-toolbar {
        background: linear-gradient(135deg, #e2e8f0 0%, #f1f5f9 100%) !important;
        border-bottom-color: var(--bs-border-color);
        color: var(--bs-body-color) !important;
    }

    [data-bs-theme="light"] .editor-toolbar .btn-link {
        color: var(--bs-secondary-color) !important;
    }

    [data-bs-theme="light"] .editor-toolbar .btn-link:hover {
        color: var(--bs-emphasis-color) !important;
    }

    [data-bs-theme="light"] .editor-toolbar .btn-outline-light {
        border-color: rgba(0,0,0,0.25);
        color: var(--bs-body-color);
    }

    [data-bs-theme="light"] .editor-toolbar .btn-outline-light:hover {
        background: rgba(0,0,0,0.06);
        border-color: rgba(0,0,0,0.4);
        color: var(--bs-body-color);
    }

    [data-bs-theme="light"] .editor-toolbar .btn-outline-light.btn-primary {
        background: var(--bs-primary);
        border-color: var(--bs-primary);
        color: #fff;
    }

    [data-bs-theme="light"] .editor-toolbar .vr {
        background-color: var(--bs-border-color) !important;
        opacity: 1;
    }



/* ===== editor-panels.css ===== */
/* ============================================================
   Editor side panels — TagsPanel, GaugesPanel, ImagesPanel,
   ElementsPanel, CameraPanel
   ============================================================ */

/* === Common panel chrome (shared layout) === */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
    color: #e2e8f0;
    flex-shrink: 0;
    font-weight: 600;
}

.panel-search {
    padding: 12px;
    border-bottom: 1px solid #334155;
}

.panel-search .form-control {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

.panel-search .form-control::placeholder {
    color: #64748b;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.panel-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.panel-footer {
    padding: 10px 16px;
    background: #0f172a;
    border-top: 1px solid #334155;
    text-align: center;
}

.panel-actions {
    padding: 10px 12px;
    border-bottom: 1px solid #334155;
}

.panel-filter {
    background: #0f172a;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #64748b;
}

/* Scrollbar (shared) */
.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 3px;
}

/* Drag handle / used badge / groups (shared) */
.drag-handle {
    color: #475569;
    flex-shrink: 0;
}

.used-indicator {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #22c55e;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #0f172a;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.group-header:hover {
    background: #1e3a5f;
    color: #fff;
}

.group-body {
    padding: 4px 8px;
}

/* === TagsPanel === */
.tags-panel {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.tags-panel.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    border-right: none;
    overflow: hidden;
}

.tag-group {
    margin-bottom: 2px;
}

.tag-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin: 3px 0;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s ease;
}

.tag-item:hover {
    border-color: #3b82f6;
    background: #1e3a5f;
    transform: translateX(4px);
}

.tag-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.tag-info {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.tag-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tag-id-desc {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-separator {
    color: #64748b;
}

.tag-desc {
    color: #94a3b8;
    font-size: 0.7rem;
}

.tag-live-value {
    font-family: monospace;
    font-size: 0.7rem;
    color: #4ade80;
    margin-top: 2px;
}

.tag-type-badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-left: 6px;
}

.badge-tag    { background: #475569; color: #e2e8f0; }
.badge-calc   { background: #0ea5e9; color: #fff; }
.badge-step   { background: #f59e0b; color: #000; }
.badge-map    { background: #a855f7; color: #fff; }
.badge-manual { background: #22c55e; color: #fff; }

/* TagsPanel light theme */
[data-bs-theme="light"] .tags-panel {
    background: var(--bs-secondary-bg);
    border-right-color: var(--bs-border-color);
}

[data-bs-theme="light"] .panel-header {
    background: var(--bs-tertiary-bg);
    border-bottom-color: var(--bs-border-color);
    color: var(--bs-emphasis-color);
}

[data-bs-theme="light"] .panel-search {
    border-bottom-color: var(--bs-border-color);
}

[data-bs-theme="light"] .panel-search .form-control {
    background: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

[data-bs-theme="light"] .panel-search .form-control::placeholder {
    color: var(--bs-secondary-color);
}

[data-bs-theme="light"] .panel-footer {
    background: var(--bs-tertiary-bg);
    border-top-color: var(--bs-border-color);
}

[data-bs-theme="light"] .empty-state {
    color: var(--bs-secondary-color);
}

[data-bs-theme="light"] .group-header {
    background: var(--bs-tertiary-bg);
    color: var(--bs-secondary-color);
}

[data-bs-theme="light"] .group-header:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--bs-emphasis-color);
}

[data-bs-theme="light"] .tag-item {
    background: var(--bs-body-bg);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-bs-theme="light"] .tag-item:hover {
    background: rgba(59, 130, 246, 0.08);
    border-color: #3b82f6;
}

[data-bs-theme="light"] .drag-handle {
    color: var(--bs-secondary-color);
}

[data-bs-theme="light"] .tag-separator {
    color: var(--bs-secondary-color);
}

[data-bs-theme="light"] .tag-desc {
    color: var(--bs-secondary-color);
}

[data-bs-theme="light"] .badge-tag {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

[data-bs-theme="light"] .panel-content::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
}

/* === GaugesPanel === */
.gauges-panel {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.gauges-panel.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    border-right: none;
    overflow: hidden;
}

.gauge-group {
    margin-bottom: 2px;
}

.gauge-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin: 3px 0;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
}

.gauge-item:hover {
    border-color: #22c55e;
    background: #1e3a5f;
    transform: translateX(4px);
}

.gauge-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.gauge-item.is-used {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.gauge-item.is-used:hover {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
}

.gauge-item.is-used .gauge-id {
    color: #4ade80;
}

.gauge-info {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
}

.gauge-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gauge-id {
    color: #22c55e;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gauge-desc {
    color: #94a3b8;
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gauge-range {
    color: #64748b;
    font-size: 0.6rem;
}

/* === ImagesPanel === */
.images-panel {
    width: 0;
    min-width: 0;
    max-width: 0;
    background: #1e293b;
    border-left: 1px solid #334155;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
}

.images-panel.visible {
    width: 320px;
    min-width: 320px;
    max-width: 320px;
}

.tab-selector {
    display: flex;
    gap: 4px;
    background: #0f172a;
    padding: 4px;
    border-radius: 8px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.tab-btn:hover {
    background: #1e293b;
    color: #fff;
}

.tab-btn.active {
    background: #8b5cf6;
    color: #fff;
}

.tab-btn .badge {
    font-size: 0.65rem;
    padding: 2px 6px;
}

.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    pointer-events: none;
}

.search-box input {
    padding-left: 36px;
    font-size: 0.875rem;
}

.panel-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.panel-stats .badge {
    font-size: 0.7rem;
    padding: 4px 8px;
}

.category-section {
    margin-bottom: 20px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #0f172a;
    border-radius: 6px;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #fff;
}

.images-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    cursor: move;
    transition: all 0.2s;
    position: relative;
}

.image-item:hover {
    background: #334155;
    border-color: #8b5cf6;
    transform: translateX(-2px);
}

.image-item.selected {
    background: rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
}

.image-item.is-used {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
}

.image-item.is-used:hover {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.2);
}

.image-item.is-used .image-item-name {
    color: #4ade80;
}

.image-item.predefined-item {
    border-color: rgba(139, 92, 246, 0.3);
}

.image-item.predefined-item:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.15);
}

/* Image card thumbnail — fixed compact size so previews don't blow up to
   their natural resolution (cards were rendering full-size before). */
.image-item-preview {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-item-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}
.image-item-icon {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
}
.image-item-info {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}
.image-item-name {
    font-size: .82rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.image-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: .7rem;
}
.image-item-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
}
.image-item .used-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    color: #22c55e;
    font-size: .85rem;
    pointer-events: none;
}

/* === ElementsPanel === */
.elements-panel {
    width: 0;
    min-width: 0;
    max-width: 0;
    background: #1e293b;
    border-left: 1px solid #334155;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
}

.elements-panel.visible {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
}

.elements-panel.hidden {
    width: 0;
    min-width: 0;
    border-left: none;
}

.elements-panel-header {
    padding: 12px 16px;
    background: #0f172a;
    border-bottom: 1px solid #334155;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.elements-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.elements-panel-footer {
    padding: 10px 16px;
    background: #0f172a;
    border-top: 1px solid #334155;
    text-align: center;
}

.element-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 6px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.element-card:hover {
    border-color: #3b82f6;
    background: #1e3a5f;
}

.element-card.selected {
    border-color: #3b82f6;
    background: #1e3a5f;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.element-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.element-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.element-info {
    flex: 1;
    min-width: 0;
}

.element-name {
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.element-meta {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.element-type {
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.element-pos {
    color: #64748b;
    font-size: 0.65rem;
    font-family: monospace;
}

.element-id-label {
    color: #64748b;
    font-size: 0.6rem;
    font-family: monospace;
}

.element-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.z-badge {
    background: #334155;
    color: #94a3b8;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: monospace;
}

.z-buttons {
    display: flex;
    gap: 2px;
}

.z-btn {
    background: #334155;
    border: none;
    color: #94a3b8;
    width: 32px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.z-btn:hover:not(:disabled) {
    background: #3b82f6;
    color: white;
}

.z-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.elements-panel-content::-webkit-scrollbar {
    width: 6px;
}

.elements-panel-content::-webkit-scrollbar-track {
    background: #1e293b;
}

/* === CameraPanel === */
.camera-panel {
    width: 0;
    min-width: 0;
    max-width: 0;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease;
    background: #0f172a;
    border-right: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.camera-panel.visible {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
}

.camera-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
    background: transparent;
}

.camera-panel .panel-title {
    color: #e2e8f0;
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
}

.camera-panel .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.camera-item-editor {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: grab;
    color: #cbd5e1;
    font-size: .82em;
    transition: background 0.15s;
    margin-bottom: 2px;
}

.camera-item-editor:hover {
    background: rgba(59, 130, 246, 0.12);
}

.camera-item-editor .cam-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.btn-xs {
    padding: 1px 5px;
    font-size: .7rem;
}

[data-bs-theme="light"] .camera-panel {
    background: var(--bs-secondary-bg);
    border-right-color: var(--bs-border-color);
}

[data-bs-theme="light"] .camera-panel .panel-header {
    border-bottom-color: var(--bs-border-color);
    background: var(--bs-tertiary-bg);
}

[data-bs-theme="light"] .camera-panel .panel-title {
    color: var(--bs-emphasis-color);
}

[data-bs-theme="light"] .camera-item-editor {
    color: var(--bs-body-color);
}

/* === TagSelectComponent === */
.tag-option {
    padding: 2px 0;
}

.tag-option .tag-id {
    color: var(--bs-primary, #3b82f6);
    font-size: 0.85rem;
}

.tag-option .tag-desc {
    color: var(--bs-body-color, #94a3b8);
    font-size: 0.75rem;
    line-height: 1.3;
}

.tag-option .tag-category,
.selected-tag .tag-category {
    font-size: 0.6rem;
    padding: 2px 6px;
    background: var(--bs-secondary-bg, #334155);
    color: var(--bs-body-color, #94a3b8);
    border-radius: 3px;
}

.selected-tag .tag-id {
    color: var(--bs-heading-color, #e2e8f0);
}

.selected-tag .tag-desc {
    color: var(--bs-body-color, #94a3b8);
}


/* ===== gauge-renderer.css ===== */
    .gauge-container {
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        overflow: hidden;
    }

        .gauge-container canvas,
        .gauge-container svg {
            max-width: 100%;
            max-height: 100%;
        }

    .mode-editor .gauge-container,
    .mode-editor {
        pointer-events: none;
    }



/* ===== dashboard-chart.css ===== */
    /* ─────────────────────────────────────────────────────────────
               CHART WIDGET — stile "home automation card"
               ───────────────────────────────────────────────────────────── */
    .chart-widget {
        position: relative;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        background: linear-gradient(160deg, #1a2235 0%, #111827 100%);
        border-radius: 10px;
        border: 1px solid rgba(255,255,255,0.07);
        overflow: hidden;
        transition: border-color 0.25s, box-shadow 0.25s;
    }

    .mode-viewer.chart-widget:hover {
        border-color: rgba(255,255,255,0.10);
        box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    }

    /* ── Header ── */
    .cw-header {
        display: flex;
        align-items: center;
        gap: 7px;
        padding: 8px 10px 4px;
        flex-shrink: 0;
    }

    .cw-icon-wrap {
        width: 28px;
        height: 28px;
        border-radius: 7px;
        border: 1px solid;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 0.72rem;
    }

    .cw-title-block {
        display: flex;
        flex-direction: column;
        min-width: 0;
        flex: 1;
        gap: 1px;
    }

    .cw-name {
        font-size: 0.72rem;
        font-weight: 600;
        color: #e2e8f0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    .cw-series-count {
        font-size: 0.58rem;
        color: #475569;
    }

    /* Badge valore live top-right */
    .cw-live-badge {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
    }

    .cw-live-dot {
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: #22c55e;
        box-shadow: 0 0 6px #22c55e;
        animation: pulse-dot 2.2s ease-in-out infinite;
    }

    @keyframes pulse-dot {
        0%, 100% {
            opacity: 1;
        }

        50% {
            opacity: 0.35;
        }
    }

    .cw-live-num {
        font-size: 0.68rem;
        font-weight: 600;
        color: #94a3b8;
        font-family: 'Roboto Mono', 'Courier New', monospace;
    }

    .cw-live-spinner {
        width: 8px;
        height: 8px;
        border: 1.5px solid rgba(255,255,255,0.15);
        border-top-color: #64748b;
        border-radius: 50%;
        animation: spin-s 0.8s linear infinite;
    }

    @keyframes spin-s {
        to {
            transform: rotate(360deg);
        }
    }

    /* ── Valore grande ── */
    .cw-value-area {
        padding: 0 12px 4px;
        flex-shrink: 0;
    }

    .cw-big-value {
        font-size: clamp(1.05rem, 2.8vw, 1.65rem);
        font-weight: 700;
        font-family: 'Roboto Mono', 'Courier New', monospace;
        letter-spacing: -0.5px;
        line-height: 1;
        transition: color 0.4s;
    }

    .cw-value-skeleton {
        display: inline-block;
        width: 80px;
        height: 1.3rem;
        background: linear-gradient(90deg, #1e293b 25%, #263348 50%, #1e293b 75%);
        background-size: 200% 100%;
        animation: shimmer-s 1.5s infinite;
        border-radius: 4px;
    }

    @keyframes shimmer-s {
        0% {
            background-position: 200% 0;
        }

        100% {
            background-position: -200% 0;
        }
    }

    .cw-value-error,
    .cw-no-data {
        font-size: 0.75rem;
        color: #475569;
    }

    .cw-editor-hint {
        padding: 0 12px 4px;
        font-size: 0.62rem;
        color: #475569;
        flex-shrink: 0;
    }

    /* ── Sparkline area ── */
    .cw-sparkline-area {
        flex: 1;
        position: relative;
        min-height: 0;
        overflow: hidden;
    }

    /* Il div di Highcharts riempie tutta l'area — NESSUN figlio Blazor mai qui dentro */
    .cw-chart-canvas {
        width: 100%;
        height: 100%;
        transition: opacity 0.3s;
    }

    .cw-overlay-msg {
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #475569;
        font-size: 0.62rem;
        pointer-events: none;
        z-index: 2;
    }

    /* ── Footer ── */
    .cw-footer {
        padding: 1px 10px 4px;
        font-size: 0.54rem;
        color: #2d3f55;
        flex-shrink: 0;
        text-align: right;
    }

    /* ── Editor ── */
    /* ── Expand button ── */
    .cw-expand-btn {
        width: 22px;
        height: 22px;
        padding: 0;
        border: none;
        background: transparent;
        color: #334155;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 4px;
        cursor: pointer;
        flex-shrink: 0;
        font-size: 0.6rem;
        opacity: 0;
        transition: opacity 0.2s, color 0.2s, background 0.2s;
    }

    .chart-widget:hover .cw-expand-btn {
        opacity: 1;
    }

    .cw-expand-btn:hover {
        color: #94a3b8;
        background: rgba(255,255,255,0.07);
    }

    /* ── Editor ── */
    .mode-editor.chart-widget {
        border: 1px dashed #2d3f55;
        background: linear-gradient(160deg, #151e2d 0%, #0f172a 100%);
    }

    .mode-editor .cw-header {
        padding: 4px 6px 2px;
    }

    .mode-editor .cw-icon-wrap {
        width: 20px;
        height: 20px;
        font-size: 0.55rem;
    }

    .mode-editor .cw-name {
        font-size: 0.58rem;
    }

    /* ── Preview ── */
    .mode-preview .cw-big-value {
        font-size: 0.95rem;
    }

    .mode-preview .cw-header {
        padding: 4px 8px 2px;
    }

    /* ── Error ── */
    .has-error .cw-sparkline-area {
        background: rgba(239, 68, 68, 0.03);
    }

    /* ═══════════════════════════════════════════════════════════
       DISPLAY MODE: FULL — grafico pieno, header sottilissimo
       ═══════════════════════════════════════════════════════════ */
    .display-full.chart-widget {
        background: transparent;
        border: 1px solid rgba(255,255,255,0.06);
    }

    .cw-header-full {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 10px 2px;
        flex-shrink: 0;
    }

    .cw-full-title {
        font-size: 0.68rem;
        font-weight: 600;
        color: rgba(226,232,240,0.7);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }

    .cw-full-live {
        font-size: 0.65rem;
        font-weight: 700;
        color: #38bdf8;
        font-family: 'Roboto Mono', monospace;
        flex-shrink: 0;
    }

    .display-full .cw-sparkline-area {
        flex: 1;
    }

    /* ═══════════════════════════════════════════════════════════
       DISPLAY MODE: MINIMAL — solo grafico, nessun chrome
       ═══════════════════════════════════════════════════════════ */
    .display-minimal.chart-widget {
        background: transparent;
        border: none;
        border-radius: 0;
    }

    .display-minimal .cw-sparkline-area {
        flex: 1;
    }

    .cw-expand-minimal {
        position: absolute;
        top: 4px;
        right: 4px;
        z-index: 5;
    }

    .display-minimal .cw-editor-hint {
        position: absolute;
        top: 4px;
        left: 6px;
        z-index: 5;
    }

    /* ═══════════════════════════════════════════════════════════
       DISPLAY MODE: NEON — glass + glow effects
       ═══════════════════════════════════════════════════════════ */
    .display-neon.chart-widget {
        background: rgba(6, 10, 22, 0.92);
        border: 1px solid rgba(255,255,255,0.06);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        box-shadow: 0 4px 24px rgba(0,0,0,0.35);
        overflow: hidden;
    }

    .display-neon.chart-widget:hover {
        border-color: rgba(255,255,255,0.1);
    }

    .neon-glow-top {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 1.5px;
        z-index: 2;
        opacity: 0.85;
    }

    .neon-glow-top::after {
        content: '';
        position: absolute;
        top: 0;
        left: 10%;
        right: 10%;
        height: 12px;
        background: inherit;
        filter: blur(8px);
        opacity: 0.35;
    }

    .neon-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px 2px;
        flex-shrink: 0;
        z-index: 3;
        position: relative;
    }

    .neon-title {
        font-size: 0.68rem;
        font-weight: 500;
        color: rgba(255,255,255,0.4);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .neon-live {
        font-size: 0.85rem;
        font-weight: 700;
        font-family: 'Roboto Mono', monospace;
        flex-shrink: 0;
    }

    .display-neon .cw-sparkline-area {
        flex: 1;
    }

    .neon-footer {
        color: rgba(255,255,255,0.15) !important;
    }

    .display-neon .cw-expand-btn {
        color: rgba(255,255,255,0.2);
    }
    .display-neon .cw-expand-btn:hover {
        color: rgba(255,255,255,0.5);
        background: rgba(255,255,255,0.06);
    }



/* ===== dashboard-popup.css ===== */
    /* === OVERLAY === */
    .dashboard-popup-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.85);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9000;
        animation: fadeIn 0.2s ease;
        backdrop-filter: blur(4px);
    }

    /* === CONTAINER === */
    .dashboard-popup-container {
        background: #1e293b;
        border-radius: 12px;
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        animation: slideUp 0.3s ease;
        max-width: 95vw;
        max-height: 95vh;
    }

    /* Size variants */
    .dashboard-popup-container.size-small {
        width: 40%;
        height: 50%;
    }

    .dashboard-popup-container.size-medium {
        width: 60%;
        height: 70%;
    }

    .dashboard-popup-container.size-large {
        width: 80%;
        height: 85%;
    }

    .dashboard-popup-container.size-full {
        width: 95%;
        height: 95%;
    }

    /* === HEADER === */
    .popup-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        background: #0f172a;
        border-bottom: 1px solid #334155;
        flex-shrink: 0;
    }

    .popup-title {
        font-weight: 600;
        color: white;
        font-size: 1rem;
    }

    .popup-actions {
        display: flex;
        gap: 8px;
    }

    .popup-actions .btn {
        padding: 4px 8px;
    }

    /* === CONTENT === */
    .popup-content {
        flex: 1;
        position: relative;
        overflow: hidden;
        background: #0f172a;
    }

    .popup-iframe {
        width: 100%;
        height: 100%;
        border: none;
    }

    /* === MINI DASHBOARD === */
    .mini-dashboard {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
        container-type: inline-size;
        /* Base font-size scala col container. --rpx em-relative:
           cambiare font-size su figli scala automaticamente i loro calc(N * --rpx). */
        font-size: calc(12 * min(0.0521cqi, 0.0926vh));
        --rpx: calc(1em / 12);
    }

    .mini-dash-background {
        position: absolute;
        inset: 0;
        background-position: center;
        background-repeat: no-repeat;
        pointer-events: none;
    }

    .mini-dash-element {
        position: absolute;
    }

    .mini-dash-empty {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        color: #64748b;
    }

    /* === FOOTER === */
    .popup-footer {
        padding: 8px 16px;
        background: #0f172a;
        border-top: 1px solid #334155;
        text-align: right;
        flex-shrink: 0;
    }

    /* === ANIMATIONS === */
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    @keyframes slideUp {
        from {
            transform: translateY(30px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* === RESPONSIVE === */
    @media (max-width: 768px) {
        .dashboard-popup-container.size-small,
        .dashboard-popup-container.size-medium {
            width: 95%;
            height: 80%;
        }
    }



/* ===== dashboard-viewer.css ===== */
    /* === OUTER CONTAINER - Riempie tutto lo schermo === */
    .viewer-outer {
        flex: 1;
        min-height: 0;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #000;
        overflow: hidden;
    }

        .viewer-outer.fullscreen {
            position: fixed;
            inset: 0;
            padding: 0;
            z-index: 9999;
        }

    /* === VIEWER CONTAINER === */
    .viewer-container {
        position: relative;
        width: 100%;
        height: 100%;
    }

    /* === DASHBOARD VIEWER ===
       Riempie tutto lo spazio. Font e spacing scalano via --rpx (cqi-based).
       Nessun transform:scale — stessa strategia del vecchio progetto. */
    .dashboard-viewer {
        position: relative;
        width: 100%;
        height: 100%;
        overflow: hidden;
        container-type: inline-size;
        /* Base font-size scala col container; user-zoom override via toolbar.
           --rpx em-relative (1rpx = 1em/12): qualsiasi elemento che cambia
           font-size ridimensiona figli che usano calc(N * var(--rpx)). */
        font-size: calc(12 * min(0.0521cqi, 0.0926vh) * var(--user-zoom, 1));
        --rpx: calc(1em / 12);
    }

    /* Background come IMG */
    .viewer-background-img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        object-position: center;
    }

    /* === ELEMENTI === */
    .viewer-element {
        position: absolute;
        transition: transform 0.1s ease;
    }

        .viewer-element.clickable {
            cursor: pointer;
        }

            .viewer-element.clickable:hover {
                transform: scale(1.02);
                z-index: 100;
            }

    /* === CAMERA BUTTON (Button mode) - same as editor === */
    .dash-camera-btn {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: calc(8 * var(--rpx));             /* 8px */
        padding: calc(4 * var(--rpx)) calc(8 * var(--rpx));  /* 4px 8px */
        font-size: calc(12 * var(--rpx));   /* base per em dei figli */
        overflow: hidden;
        cursor: pointer;
    }

    /* === TOOLBAR === */
    .viewer-toolbar {
        position: absolute;
        top: 12px;
        right: 12px;
        display: flex;
        gap: 8px;
        opacity: 0.3;
        transition: opacity 0.3s;
        z-index: 1000;
    }

    .dashboard-viewer:hover .viewer-toolbar {
        opacity: 1;
    }

    .viewer-toolbar .btn {
        backdrop-filter: blur(8px);
        background: rgba(0,0,0,0.6);
        color: #e2e8f0;
        border-color: rgba(226,232,240,0.4);
    }

    .viewer-toolbar .btn:hover {
        background: rgba(59,130,246,0.5);
        color: #fff;
        border-color: rgba(255,255,255,0.7);
    }

    .viewer-toolbar .btn i,
    .viewer-toolbar .btn-group .btn {
        color: #e2e8f0;
    }

    /* === INFO === */
    .viewer-info {
        position: absolute;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 8px 16px;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(8px);
        border-radius: 20px;
        font-size: 0.8rem;
        color: #94a3b8;
        opacity: 0.5;
        transition: opacity 0.3s;
        z-index: 1000;
    }

    .dashboard-viewer:hover .viewer-info {
        opacity: 1;
    }

    .dashboard-name {
        color: #e2e8f0;
        font-weight: 600;
    }

    .last-update {
        font-family: 'Roboto Mono', monospace;
        color: #22c55e;
    }

    .snapshot-badge {
        background: #f59e0b;
        color: #fff;
        padding: 4px 12px;
        border-radius: 12px;
        font-weight: 600;
        font-size: 0.75rem;
        letter-spacing: 0.5px;
    }

    /* === SNAPSHOT PLAYER === */
    .snapshot-player {
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 14px;
        background: rgba(0,0,0,0.65);
        backdrop-filter: blur(8px);
        border-radius: 20px;
        font-size: 0.8rem;
        color: #e2e8f0;
        opacity: 0.4;
        transition: opacity 0.3s;
        z-index: 1001;
        white-space: nowrap;
    }

    .dashboard-viewer:hover .snapshot-player {
        opacity: 1;
    }

    .snapshot-player .btn {
        backdrop-filter: none;
        background: rgba(255,255,255,0.15);
        border-color: rgba(255,255,255,0.4);
        padding: 2px 8px;
    }

    .snapshot-slider {
        width: 140px;
        accent-color: #f59e0b;
        cursor: pointer;
    }

    .snapshot-frame-label {
        font-family: 'Roboto Mono', monospace;
        color: #f59e0b;
        font-size: 0.75rem;
        min-width: 90px;
    }

    /* === LOADING === */
    .viewer-loading {
        position: fixed;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: #0f172a;
        color: #94a3b8;
    }

    /* === ERROR === */
    .viewer-error {
        position: fixed;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: #0f172a;
        color: #ef4444;
    }



/* ===== tag-write-modal.css ===== */
    .twm-feedback {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 0.85rem;
        font-weight: 600;
        margin-bottom: 12px;
        animation: twm-fade-in 0.2s ease;
    }
    .twm-feedback--ok {
        background: rgba(34,197,94,.15);
        color: #4ade80;
        border: 1px solid rgba(34,197,94,.3);
    }
    .twm-feedback--err {
        background: rgba(239,68,68,.15);
        color: #f87171;
        border: 1px solid rgba(239,68,68,.3);
    }
    .twm-feedback i { font-size: 1.1rem; }

    @keyframes twm-fade-in {
        from { opacity: 0; transform: translateY(-4px); }
        to   { opacity: 1; transform: translateY(0); }
    }



/* ===== image-settings-modal.css ===== */
    /* Image-specific: origin picker grid */
    .csm-origin-picker {
        display: grid;
        grid-template-columns: repeat(3, 32px);
        gap: 4px;
    }

    .csm-origin-btn {
        width: 32px;
        height: 32px;
        padding: 0;
        background: rgba(71, 85, 105, 0.3);
        border: 1px solid #475569;
        border-radius: 4px;
        color: #94a3b8;
        font-size: 0.85rem;
        cursor: pointer;
        transition: all 0.15s;
    }

    .csm-origin-btn:hover {
        background: rgba(71, 85, 105, 0.7);
        color: white;
    }

    .csm-origin-btn.active {
        background: #3b82f6;
        border-color: #60a5fa;
        color: white;
    }



/* ===== component-detail-modal.css ===== */
    .cmp-detail-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1050;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(4px);
        display: flex;
        align-items: center;
        justify-content: center;
        animation: cdm-fade-in 0.15s ease-out;
    }

    .cmp-detail-panel {
        background: #0f172a;
        border: 1px solid rgba(56, 189, 248, 0.15);
        border-radius: 12px;
        width: 90%;
        max-width: 480px;
        max-height: 80vh;
        display: flex;
        flex-direction: column;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03);
        animation: cdm-slide-up 0.2s ease-out;
    }

    .cmp-detail-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .cmp-detail-header-info {
        min-width: 0;
    }

    .cmp-detail-title {
        font-size: 1rem;
        font-weight: 600;
        color: #e2e8f0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cmp-detail-subtitle {
        font-size: 0.72rem;
        color: #64748b;
        margin-top: 2px;
    }

    .cmp-detail-close {
        background: none;
        border: none;
        color: #64748b;
        font-size: 1rem;
        cursor: pointer;
        padding: 4px 8px;
        border-radius: 6px;
        transition: all 0.15s;
        flex-shrink: 0;
    }

    .cmp-detail-close:hover {
        color: #e2e8f0;
        background: rgba(255, 255, 255, 0.06);
    }

    .cmp-detail-body {
        overflow-y: auto;
        padding: 8px 12px 12px;
    }

    .cmp-detail-empty {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 40px 20px;
        color: #475569;
        font-size: 0.85rem;
    }

    .cmp-detail-empty i {
        font-size: 1.5rem;
    }

    .cmp-detail-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        border-radius: 8px;
        transition: background 0.12s;
    }

    .cmp-detail-row:hover {
        background: rgba(255, 255, 255, 0.03);
    }

    .cmp-detail-row + .cmp-detail-row {
        border-top: 1px solid rgba(255, 255, 255, 0.04);
    }

    .cmp-detail-row-label {
        display: flex;
        align-items: baseline;
        gap: 6px;
        min-width: 0;
        flex: 1;
    }

    .cmp-detail-tag-name {
        font-size: 0.82rem;
        font-weight: 500;
        color: #94a3b8;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cmp-detail-tag-unit {
        font-size: 0.68rem;
        color: #475569;
        flex-shrink: 0;
    }

    .cmp-detail-row-value {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
        margin-left: 16px;
    }

    .cmp-detail-val {
        font-family: 'Roboto Mono', 'Cascadia Code', monospace;
        font-size: 0.9rem;
        font-weight: 600;
        color: #38bdf8;
    }

    .cmp-detail-bit {
        font-family: 'Roboto Mono', monospace;
        font-size: 0.72rem;
        font-weight: 700;
        padding: 2px 10px;
        border-radius: 4px;
        letter-spacing: 0.5px;
    }

    .cmp-detail-bit.on {
        background: rgba(34, 197, 94, 0.15);
        color: #4ade80;
    }

    .cmp-detail-bit.off {
        background: rgba(100, 116, 139, 0.15);
        color: #64748b;
    }

    .cmp-detail-write-btn {
        background: none;
        border: none;
        color: #475569;
        font-size: 0.7rem;
        cursor: pointer;
        padding: 4px 6px;
        border-radius: 4px;
        transition: all 0.15s;
    }

    .cmp-detail-write-btn:hover {
        color: #38bdf8;
        background: rgba(56, 189, 248, 0.1);
    }

    .cmp-detail-cmd-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: none;
        border-radius: 4px;
        padding: 4px 12px;
        color: #e2e8f0;
        font-size: 0.78rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        cursor: pointer;
        transition: filter 0.15s;
        white-space: nowrap;
    }

    .cmp-detail-cmd-btn:hover {
        filter: brightness(1.15);
    }

    .cmp-detail-bit-toggle {
        display: inline-flex;
        align-items: center;
        font-size: 0.85rem;
        font-weight: 600;
        padding: 3px 10px;
        border-radius: 4px;
        transition: all 0.15s;
    }

    .cmp-detail-bit-toggle.on {
        color: #4ade80;
        background: rgba(34,197,94,.15);
    }

    .cmp-detail-bit-toggle.off {
        color: #94a3b8;
        background: rgba(148,163,184,.1);
    }

    .cmp-detail-bit-toggle:hover {
        filter: brightness(1.2);
    }

    @keyframes cdm-fade-in {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    @keyframes cdm-slide-up {
        from { opacity: 0; transform: translateY(12px) scale(0.97); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }



/* ===== chart-expand-modal.css ===== */
    .cem-backdrop {
        background-color: rgba(0, 0, 0, 0.72);
        z-index: 1060;
    }

    .cem-dialog {
        max-width: 1100px;
    }

    .cem-content {
        background: #0f172a;
        border: 1px solid #1e293b;
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 25px 60px rgba(0,0,0,0.6);
    }

    /* ── Header ── */
    .cem-header {
        background: #0f172a;
        border-bottom: 1px solid #1e293b;
    }

    .cem-icon-wrap {
        width: 36px;
        height: 36px;
        border-radius: 9px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        font-size: 0.85rem;
    }

    .cem-close {
        filter: invert(0.5) brightness(0.7);
        transition: filter 0.2s;
    }

    .cem-close:hover {
        filter: invert(0.7) brightness(0.9);
    }

    /* ── Series badges ── */
    .cem-series-badge {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        font-size: 0.65rem;
        color: #64748b;
        background: rgba(255,255,255,0.04);
        border: 1px solid #1e293b;
        border-radius: 4px;
        padding: 2px 7px;
    }

    .cem-series-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .cem-series-unit {
        color: #334155;
        font-size: 0.58rem;
    }

    /* ── Time range pills ── */
    .cem-range-btn {
        padding: 4px 10px;
        border: 1px solid #1e293b;
        background: transparent;
        color: #475569;
        border-radius: 6px;
        font-size: 0.72rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.15s;
        line-height: 1.3;
    }

    .cem-range-btn:hover {
        border-color: #334155;
        color: #94a3b8;
        background: rgba(255,255,255,0.04);
    }

    .cem-range-btn.active {
        border-color: #3b82f6;
        background: rgba(59,130,246,0.15);
        color: #60a5fa;
    }

    /* ── Body ── */
    .cem-body {
        height: 480px;
        padding: 0;
        background: #0b1120;
        overflow: hidden;
    }

    .cem-body .chart-widget {
        border-radius: 0;
        border: none;
        background: transparent;
    }



/* ===== camera-inline-thumb.css ===== */
.cam-inline-thumb {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    cursor: pointer;
}

.cam-inline-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
}

.cam-inline-error {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #ef4444;
    font-size: 0.75em;
    text-align: center;
    padding: 8px;
    background: rgba(0, 0, 0, 0.85);
}

.cam-inline-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #e2e8f0;
    font-size: 0.72em;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.cam-inline-thumb:hover .cam-inline-overlay {
    opacity: 1;
}

.cam-inline-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.cam-inline-expand {
    font-size: 1.1em;
    margin-left: 6px;
    flex-shrink: 0;
}


