        body,
        html {
            margin: 0;
            padding: 0;
            height: 100%;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            background-color: #f4f4f5;
            color: #1f2937;
            overflow: hidden;
        }

        #root {
            height: 100%;
            display: flex;
            flex-direction: column;
        }

        .header {
            background-color: #1e293b;
            color: white;
            padding: 16px;
            font-size: 1.2rem;
            font-weight: bold;
            display: flex;
            align-items: center;
            justify-content: space-between;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            z-index: 10;
        }

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

        .header a {
            color: white;
            text-decoration: none;
            background: rgba(255, 255, 255, 0.1);
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 0.9rem;
        }

        .quadro-selector {
            background: rgba(255, 255, 255, 0.1);
            color: white;
            border: 1px solid rgba(255, 255, 255, 0.2);
            padding: 6px 12px;
            border-radius: 6px;
            outline: none;
            font-size: 0.9rem;
            max-width: 200px;
        }

        .quadro-selector option {
            color: black;
        }

        .content-area {
            flex: 1;
            overflow-y: auto;
            position: relative;
        }

        .bottom-nav {
            display: flex;
            background: white;
            border-top: 1px solid #e5e7eb;
            box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
            padding-bottom: env(safe-area-inset-bottom);
            z-index: 20;
        }

        .nav-item {
            flex: 1;
            text-align: center;
            padding: 12px 0;
            color: #6b7280;
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
        }

        .nav-item.active {
            color: #2563eb;
        }

        .nav-icon {
            font-size: 1.4rem;
        }

        .svg-container {
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: #f4f4f5;
            display: flex;
        }

        .simulador-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 16px;
            padding: 20px;
        }

        .btn-switch {
            background: white;
            border: 2px solid #e5e7eb;
            border-radius: 12px;
            padding: 16px;
            font-size: 1.1rem;
            font-weight: bold;
            color: #374151;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
            transition: all 0.2s;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
        }

        .btn-switch.active {
            border-color: #3b82f6;
            background: #eff6ff;
            color: #1d4ed8;
            transform: translateY(2px);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .status-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            background: #d1d5db;
        }

        .btn-switch.active .status-dot {
            background: #22c55e;
            box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
        }

        .mapping-list {
            padding: 16px;
        }

        .mapping-item {
            background: white;
            border-radius: 8px;
            padding: 16px;
            margin-bottom: 12px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            border-left: 4px solid #3b82f6;
        }

        .mapping-title {
            font-weight: bold;
            font-size: 1.1rem;
            margin-bottom: 12px;
        }

        .mapping-route {
            display: flex;
            flex-direction: column;
            gap: 8px;
            font-size: 0.9rem;
            color: #4b5563;
        }

        .route-step {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .route-arrow {
            color: #9ca3af;
        }

        /* --- ESTILOS DO LAYOUT FÍSICO / INDUSTRIAL --- */
        .layout-container {
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            background: #e2e8f0;
            min-height: 100%;
            box-sizing: border-box;
            user-select: none;
        }

        .layout-toolbar {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            max-width: 1000px;
            background: white;
            padding: 12px 18px;
            border-radius: 12px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.06);
            margin-bottom: 20px;
            box-sizing: border-box;
        }

        .layout-tabs {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .layout-tab-btn {
            background: #f1f5f9;
            border: 1px solid #cbd5e1;
            padding: 8px 14px;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            color: #475569;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .layout-tab-btn:hover {
            background: #e2e8f0;
            color: #1e293b;
        }

        .layout-tab-btn.active {
            background: #2563eb;
            color: white;
            border-color: #1d4ed8;
            box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
        }

        .layout-actions {
            display: flex;
            gap: 8px;
            align-items: center;
        }

        .layout-btn-action {
            background: #f8fafc;
            border: 1px solid #cbd5e1;
            padding: 7px 12px;
            border-radius: 8px;
            font-size: 0.82rem;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            color: #334155;
            transition: all 0.2s;
        }

        .layout-btn-action:hover {
            background: #e2e8f0;
        }

        .layout-btn-photo {
            background: #0f172a;
            color: white;
            border: 1px solid #0f172a;
        }
        .layout-btn-photo:hover {
            background: #1e293b;
            color: white;
        }

        /* PAINEL / CHASSIS FÍSICO INDUSTRIAL */
        .industrial-panel {
            background: #f8fafc;
            border: 8px solid #64748b;
            border-radius: 8px;
            padding: 22px;
            box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16), inset 0 0 0 2px #475569;
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
            box-sizing: border-box;
            margin: 0 auto 40px auto;
            max-width: 100%;
            transition: transform 0.2s ease;
        }

        .panel-badge {
            width: 100%;
            background: linear-gradient(135deg, #1e293b, #0f172a);
            color: white;
            padding: 12px 16px;
            border-radius: 6px;
            margin-bottom: 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            box-sizing: border-box;
        }

        .panel-badge h3 {
            margin: 0;
            font-size: 1.05rem;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .panel-badge .specs-tag {
            font-size: 0.75rem;
            background: rgba(255,255,255,0.15);
            padding: 4px 8px;
            border-radius: 4px;
            font-family: monospace;
        }

        /* CANALETA INDUSTRIAL SLOTTED */
        .wire-duct {
            position: relative;
            background: #94a3b8;
            border-left: 2px solid #475569;
            border-right: 2px solid #475569;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 3px;
            box-sizing: border-box;
            border-radius: 2px;
            overflow: hidden;
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
            max-width: 100%;
        }

        .wire-duct::before, .wire-duct::after {
            content: '';
            position: absolute;
            left: 0; right: 0;
            height: 4px;
            background: repeating-linear-gradient(90deg, #334155 0px, #334155 4px, transparent 4px, transparent 10px);
            opacity: 0.8;
        }
        .wire-duct::before { top: 0; }
        .wire-duct::after { bottom: 0; }

        .wire-duct-label {
            background: rgba(30, 41, 59, 0.75);
            color: #f8fafc;
            font-size: 9px;
            font-weight: 700;
            letter-spacing: 1px;
            padding: 2px 10px;
            border-radius: 3px;
            z-index: 1;
        }

        /* TRILHO DIN TS-35 REALISTA */
        .din-ts35-track {
            height: 62px;
            background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 15%, #94a3b8 40%, #e2e8f0 70%, #64748b 95%, #cbd5e1 100%);
            border-top: 3px solid #64748b;
            border-bottom: 3px solid #64748b;
            display: flex;
            align-items: center;
            padding: 0 4px;
            gap: 2px;
            position: relative;
            box-sizing: border-box;
            box-shadow: 0 3px 6px rgba(0,0,0,0.2), inset 0 1px 2px rgba(255,255,255,0.7);
            margin-bottom: 2px;
            max-width: 100%;
            overflow: hidden;
        }

        /* Furos de fixação ovalados do trilho DIN TS-35 perfurado */
        .din-ts35-track::before {
            content: '';
            position: absolute;
            top: 50%; left: 8px; right: 8px;
            height: 5px;
            transform: translateY(-50%);
            background: repeating-linear-gradient(90deg, #475569 0px, #475569 16px, transparent 16px, transparent 32px);
            opacity: 0.35;
            border-radius: 3px;
            pointer-events: none;
            z-index: 1;
        }

        /* Barra de Métricas e Ocupação do Trilho */
        .rail-metric-bar {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 0.72rem;
            color: #64748b;
            margin-bottom: 8px;
            padding: 0 4px;
            box-sizing: border-box;
        }

        .rail-progress-track {
            flex: 1;
            height: 5px;
            background: #cbd5e1;
            border-radius: 3px;
            margin: 0 8px;
            overflow: hidden;
            position: relative;
        }

        .rail-progress-fill {
            height: 100%;
            border-radius: 3px;
            transition: width 0.3s ease;
        }

        /* ELEMENTOS REALISTAS INDIVIDUAIS */
        .real-comp {
            height: 54px;
            border-radius: 3px;
            position: relative;
            z-index: 2;
            cursor: pointer;
            transition: transform 0.15s, box-shadow 0.15s;
            box-sizing: border-box;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 2px 3px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.4);
            max-width: 100%;
        }

        .real-comp:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 12px rgba(0,0,0,0.35);
        }

        .screw-terminals {
            display: flex;
            justify-content: space-around;
            width: 100%;
            height: 5px;
        }

        .screw-head {
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background: #94a3b8;
            border: 1px solid #475569;
            box-shadow: inset 0 1px 1px rgba(0,0,0,0.6);
        }

        .status-led {
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: #334155;
            transition: all 0.2s;
            display: inline-block;
        }

        .status-led.active-green {
            background: #22c55e;
            box-shadow: 0 0 8px #22c55e, 0 0 12px #4ade80;
        }

        .status-led.active-red {
            background: #ef4444;
            box-shadow: 0 0 8px #ef4444, 0 0 12px #f87171;
        }

        .status-led.active-blue {
            background: #3b82f6;
            box-shadow: 0 0 8px #3b82f6;
        }

        /* ==============================================================
           ESTILOS REALISTAS DO ESP32 EM EXPANSION BOARD DIN (60mm x 86mm)
           Suporte verde trilho DIN, réguas de bornes laterais e NodeMCU central
           ============================================================== */
        .real-comp.hw-esp32-wrap {
            padding: 1px !important;
            background: #15803d !important;
            border: 1.5px solid #14532d !important;
            box-shadow: 0 4px 8px rgba(0,0,0,0.35) !important;
        }

        .hw-esp32-pcb-carrier {
            width: 100%;
            height: 100%;
            background: #f8fafc;
            border: 1px solid #cbd5e1;
            border-radius: 2px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1px;
            box-sizing: border-box;
            position: relative;
            overflow: hidden;
        }

        .hw-esp32-side-terminals {
            width: 13px;
            height: 100%;
            background: #16a34a;
            border: 1px solid #15803d;
            border-radius: 1px;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
            align-items: center;
            padding: 1px 0;
            box-sizing: border-box;
        }

        .hw-esp32-screw-terminal {
            width: 9px;
            height: 4px;
            background: #22c55e;
            border: 0.5px solid #15803d;
            border-radius: 1px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .hw-esp32-screw-terminal::after {
            content: '';
            width: 4px;
            height: 1px;
            background: #1e293b;
        }

        .hw-esp32-nodemcu {
            width: 36px;
            height: 98%;
            background: #09090b;
            border: 1px solid #27272a;
            border-radius: 3px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            padding: 2px 1px;
            box-sizing: border-box;
            position: relative;
            box-shadow: 0 2px 5px rgba(0,0,0,0.7);
        }

        .hw-esp32-hole {
            position: absolute;
            width: 2.5px;
            height: 2.5px;
            border-radius: 50%;
            background: #cbd5e1;
            border: 0.5px solid #52525b;
        }
        .hole-tl { top: 1px; left: 1px; }
        .hole-tr { top: 1px; right: 1px; }
        .hole-bl { bottom: 1px; left: 1px; }
        .hole-br { bottom: 1px; right: 1px; }

        .hw-esp32-pcb-antenna {
            width: 26px;
            height: 5px;
            background: #18181b;
            border: 0.5px solid #3f3f46;
            border-radius: 1px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .hw-esp32-pcb-antenna::after {
            content: '';
            width: 20px;
            height: 2px;
            background: repeating-linear-gradient(90deg, #d97706, #d97706 2px, #18181b 2px, #18181b 4px);
            opacity: 0.85;
        }

        .hw-esp32-metal-shield {
            width: 28px;
            height: 16px;
            background: linear-gradient(135deg, #f1f5f9 0%, #cbd5e1 50%, #94a3b8 100%);
            border: 1px solid #64748b;
            border-radius: 2px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            box-shadow: inset 0 1px 2px rgba(255,255,255,0.9), 0 1px 2px rgba(0,0,0,0.4);
            position: relative;
        }

        .hw-esp32-shield-text {
            font-size: 3.5px;
            font-weight: 900;
            color: #0f172a;
            letter-spacing: -0.2px;
            line-height: 1;
            text-align: center;
        }

        .hw-esp32-shield-sub {
            font-size: 2.8px;
            font-weight: 700;
            color: #334155;
            letter-spacing: -0.1px;
            line-height: 1;
        }

        .hw-esp32-middle-section {
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 1px;
        }

        .hw-esp32-leds-row {
            display: flex;
            gap: 5px;
            align-items: center;
        }

        .hw-esp32-ch340-chip {
            width: 14px;
            height: 4px;
            background: #18181b;
            border: 0.5px solid #3f3f46;
            border-radius: 1px;
            position: relative;
        }

        .hw-esp32-ch340-chip::before, .hw-esp32-ch340-chip::after {
            content: '';
            position: absolute;
            width: 100%;
            height: 1px;
            background: repeating-linear-gradient(90deg, #cbd5e1, #cbd5e1 1px, transparent 1px, transparent 2px);
        }
        .hw-esp32-ch340-chip::before { top: -1px; }
        .hw-esp32-ch340-chip::after { bottom: -1px; }

        .hw-esp32-bottom-row {
            width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            padding: 0 1px;
            box-sizing: border-box;
        }

        .hw-esp32-btn {
            width: 3.5px;
            height: 3.5px;
            background: #3f3f46;
            border: 0.5px solid #71717a;
            border-radius: 1px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .hw-esp32-btn::after {
            content: '';
            width: 1.5px;
            height: 1.5px;
            background: #e4e4e7;
            border-radius: 50%;
        }

        .hw-esp32-usb-port {
            width: 8px;
            height: 4px;
            background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 100%);
            border: 0.5px solid #475569;
            border-bottom: none;
            border-radius: 1px 1px 0 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .hw-esp32-usb-port::after {
            content: '';
            width: 4px;
            height: 1.5px;
            background: #0f172a;
        }

        /* MODAL / DRAWER DE INSPEÇÃO */
        .comp-modal-overlay {
            position: fixed;
            top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(15, 23, 42, 0.7);
            backdrop-filter: blur(4px);
            z-index: 100;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .comp-modal {
            background: white;
            border-radius: 16px;
            max-width: 600px;
            width: 100%;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 20px 40px rgba(0,0,0,0.3);
            display: flex;
            flex-direction: column;
            animation: modalFadeIn 0.2s ease-out;
        }

        @keyframes modalFadeIn {
            from { opacity: 0; transform: scale(0.96); }
            to { opacity: 1; transform: scale(1); }
        }

        .comp-modal-header {
            padding: 18px 24px;
            background: #1e293b;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-top-left-radius: 16px;
            border-top-right-radius: 16px;
        }

        .comp-modal-header h3 {
            margin: 0;
            font-size: 1.15rem;
        }

        .comp-modal-close {
            background: none;
            border: none;
            color: #94a3b8;
            font-size: 1.5rem;
            cursor: pointer;
            transition: color 0.2s;
        }

        .comp-modal-close:hover {
            color: white;
        }

        .comp-modal-body {
            padding: 24px;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .comp-spec-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }

        .comp-spec-card {
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            padding: 10px 14px;
            border-radius: 8px;
        }

        .comp-spec-card .label {
            font-size: 0.75rem;
            color: #64748b;
            font-weight: 600;
            text-transform: uppercase;
        }

        .comp-spec-card .val {
            font-size: 0.95rem;
            font-weight: 700;
            color: #1e293b;
            margin-top: 2px;
        }

        /* ALERTA DE ENGENHARIA / VERIFICAÇÃO */
        .engineering-alert {
            background: #fffbeb;
            border-left: 4px solid #f59e0b;
            padding: 12px 16px;
            border-radius: 6px;
            font-size: 0.82rem;
            color: #92400e;
            margin: 10px 0;
            display: flex;
            align-items: flex-start;
            gap: 10px;
            box-sizing: border-box;
            width: 100%;
        }
