        :root {
            --bg: #030712;
            --panel: rgba(7, 12, 24, 0.9);
            --panel-strong: rgba(11, 18, 36, 0.95);
            --line: rgba(255, 255, 255, 0.08);
            --line-strong: rgba(96, 165, 250, 0.28);
            --text: #f8fafc;
            --muted: #94a3b8;
            --accent: #60a5fa;
            --accent-2: #38bdf8;
            --success: #22c55e;
            --cursor-glow: radial-gradient(circle at 50% 50%, rgba(96, 165, 250, 0) 0%, transparent 0%);
        }

        html {
            scroll-behavior: smooth;
        }

        body {
            font-family: 'Plus Jakarta Sans', sans-serif;
            background:
                var(--cursor-glow),
                radial-gradient(circle at 18% 14%, rgba(59, 130, 246, 0.16) 0%, transparent 28%),
                radial-gradient(circle at 82% 18%, rgba(14, 165, 233, 0.14) 0%, transparent 22%),
                radial-gradient(circle at 50% 55%, rgba(59, 130, 246, 0.08) 0%, transparent 48%),
                linear-gradient(180deg, #020617 0%, #030712 100%);
            color: white;
            margin: 0;
            overflow-x: hidden;
        }

        .grid-presence {
            position: fixed;
            inset: 0;
            background-image:
                linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
            background-size: 60px 60px;
            pointer-events: none;
            z-index: 1;
            mask-image: radial-gradient(circle at center, black 18%, transparent 100%);
        }

        .orb {
            position: fixed;
            pointer-events: none;
            border-radius: 9999px;
            filter: blur(22px);
            z-index: 0;
        }

        .orb-a {
            width: 24rem;
            height: 24rem;
            top: -8rem;
            right: -6rem;
            background: radial-gradient(circle, rgba(56, 189, 248, 0.18) 0%, rgba(59, 130, 246, 0.05) 42%, transparent 72%);
        }

        .orb-b {
            width: 20rem;
            height: 20rem;
            left: -7rem;
            bottom: -7rem;
            background: radial-gradient(circle, rgba(34, 197, 94, 0.12) 0%, rgba(59, 130, 246, 0.04) 45%, transparent 72%);
        }

        .glass-panel {
            background: var(--panel);
            backdrop-filter: blur(28px);
            border: 1px solid rgba(255, 255, 255, 0.12);
            box-shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
        }

        .agent-card,
        .tool-card,
        .step-card,
        .status-card {
            background: rgba(9, 14, 28, 0.84);
            border: 1px solid var(--line);
            transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
            position: relative;
            overflow: hidden;
        }

        .agent-card:hover,
        .tool-card:hover,
        .step-card:hover,
        .status-card:hover {
            transform: translateY(-3px);
            border-color: var(--line-strong);
            background: rgba(11, 18, 36, 0.95);
        }

        .text-glow { text-shadow: 0 2px 20px rgba(0,0,0,0.75); }
        .text-setup { color: #86efac; text-shadow: 0 0 15px rgba(34, 197, 94, 0.35); }

        .nav-item {
            border: 1px solid transparent;
            background: rgba(255, 255, 255, 0.03);
            color: #cbd5e1;
            transition: all 0.2s ease;
            text-transform: uppercase;
            letter-spacing: 0.14em;
        }

        .nav-item:hover {
            color: white;
            background: rgba(255, 255, 255, 0.06);
        }

        .nav-item.active {
            background: linear-gradient(135deg, rgba(37, 99, 235, 0.95) 0%, rgba(14, 165, 233, 0.95) 100%);
            color: white;
            border: 1px solid rgba(255, 255, 255, 0.18);
            box-shadow: 0 18px 40px rgba(37, 99, 235, 0.24);
        }

        .page-section { display: none; }
        .page-section.active { display: block; animation: fadeIn 0.5s ease-out; }
        #page-dash > h1,
        #page-dash > .agent-card,
        #page-dash > .grid {
            display: none;
        }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
        
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
        ::-webkit-scrollbar-thumb { background: rgba(96, 165, 250, 0.42); border-radius: 4px; }

        /* --- NUEVOS ESTILOS PARA LOGS AVANZADOS --- */
        .log-filters {
            display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; padding: 1rem;
            background: rgba(10, 15, 30, 0.72); border-radius: 1.5rem; border: 1px solid rgba(255, 255, 255, 0.1);
        }
        .log-filter { display: flex; align-items: center; gap: 0.5rem; }
        .log-filter label { font-size: 0.75rem; text-transform: uppercase; color: #94a3b8; font-weight: 800; }
        .log-filter select, .log-filter input {
            background: rgba(0, 0, 0, 0.3); color: white; border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 0.5rem; padding: 0.5rem; font-size: 0.875rem; outline: none;
        }
        .log-filter select:focus, .log-filter input:focus { border-color: #3b82f6; }

        /* ── Dark dropdown popup — all selects ─────────────────────────── */
        select {
            color-scheme: dark;
        }
        select option {
            background-color: #0d1117;
            color: #f1f5f9;
        }
        select option:checked,
        select option:hover {
            background-color: #1e3a5f;
            color: #ffffff;
        }

        .log-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
        .log-stat-card {
            background: rgba(10, 15, 30, 0.7); border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 1rem; padding: 1rem; text-align: center;
        }
        .log-stat-value { font-size: 1.8rem; font-weight: 900; color: #60a5fa; text-shadow: 0 0 10px rgba(96, 165, 250, 0.3); }
        .log-stat-label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 5px; }

        .whatsapp-fab {
            position: fixed;
            right: 0.9rem;
            bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
            z-index: 60;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 3.15rem;
            height: 3.15rem;
            border-radius: 9999px;
            background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
            color: white;
            font-weight: 900;
            box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
            transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
            animation: whatsappPulse 2.4s ease-in-out infinite;
        }
        .whatsapp-fab:hover {
            transform: translateY(-2px) scale(1.02);
            box-shadow: 0 22px 46px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.24) inset;
        }
        .whatsapp-fab .fab-icon {
            width: 100%;
            height: 100%;
            border-radius: 9999px;
            background: rgba(255, 255, 255, 0.16);
            display: grid;
            place-items: center;
            flex: 0 0 auto;
        }
        .whatsapp-fab .fab-icon svg {
            width: 1.55rem;
            height: 1.55rem;
            fill: currentColor;
            display: block;
        }
        .ai-assist-fab {
            position: fixed;
            right: 0.9rem;
            bottom: calc(4.45rem + env(safe-area-inset-bottom, 0px));
            z-index: 60;
            display: inline-flex;
            align-items: center;
            gap: 0.55rem;
            padding: 0.85rem 1rem;
            border-radius: 9999px;
            background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
            color: white;
            font-weight: 900;
            box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
            transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
        }
        .ai-assist-fab:hover {
            transform: translateY(-2px);
            box-shadow: 0 22px 46px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.24) inset;
        }
        .ai-assist-fab .ai-dot {
            width: 0.65rem;
            height: 0.65rem;
            border-radius: 9999px;
            background: #dbeafe;
            box-shadow: 0 0 12px rgba(255, 255, 255, 0.55);
        }
        .ai-assistant-panel {
            position: fixed;
            right: 0.9rem;
            bottom: calc(8.15rem + env(safe-area-inset-bottom, 0px));
            width: min(26rem, calc(100vw - 1.8rem));
            max-height: min(78vh, 44rem);
            z-index: 70;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            border-radius: 1.75rem;
            background: rgba(6, 10, 20, 0.96);
            border: 1px solid rgba(96, 165, 250, 0.22);
            backdrop-filter: blur(26px);
            box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
        }
        .ai-assistant-panel.hidden { display: none; }
        @media (max-width: 768px) {
            .whatsapp-fab,
            .ai-assist-fab {
                right: 0.75rem;
            }
            .ai-assistant-panel {
                right: 0.75rem;
                left: 0.75rem;
                width: auto;
                max-height: min(72vh, 38rem);
            }
        }
        .ai-assistant-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            padding: 1rem 1.05rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            background: rgba(255, 255, 255, 0.02);
        }
        .ai-assistant-title {
            display: flex;
            flex-direction: column;
            gap: 0.15rem;
        }
        .ai-assistant-title strong {
            font-size: 0.95rem;
            font-weight: 900;
            color: white;
        }
        .ai-assistant-title span {
            font-size: 0.72rem;
            font-weight: 700;
            letter-spacing: 0.12em;
            text-transform: uppercase;
            color: #93c5fd;
        }
        .ai-assistant-close {
            width: 2.2rem;
            height: 2.2rem;
            border-radius: 9999px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: #cbd5e1;
            background: rgba(255, 255, 255, 0.04);
        }
        .ai-assistant-log {
            flex: 1 1 auto;
            overflow-y: auto;
            padding: 1rem 1rem 0.5rem;
        }
        .ai-message {
            margin-bottom: 0.85rem;
            display: flex;
        }
        .ai-message.user { justify-content: flex-end; }
        .ai-bubble {
            max-width: 100%;
            border-radius: 1.2rem;
            padding: 0.85rem 0.95rem;
            font-size: 0.92rem;
            line-height: 1.65;
            border: 1px solid rgba(255, 255, 255, 0.08);
            white-space: pre-wrap;
        }
        .ai-message.user .ai-bubble {
            background: linear-gradient(135deg, rgba(37, 99, 235, 0.92) 0%, rgba(14, 165, 233, 0.92) 100%);
            color: white;
        }
        .ai-message.assistant .ai-bubble {
            background: rgba(255, 255, 255, 0.04);
            color: #e2e8f0;
        }
        .ai-actions {
            display: flex;
            gap: 0.5rem;
            flex-wrap: wrap;
            padding: 0 1rem 0.9rem;
        }
        .ai-chip {
            border-radius: 9999px;
            padding: 0.55rem 0.75rem;
            font-size: 0.68rem;
            font-weight: 900;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(255, 255, 255, 0.04);
            color: #cbd5e1;
        }
        .ai-assistant-input-wrap {
            padding: 0 1rem 1rem;
        }
        .ai-assistant-input {
            width: 100%;
            min-height: 4.4rem;
            resize: vertical;
            border-radius: 1rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(255, 255, 255, 0.03);
            color: white;
            padding: 0.85rem 0.95rem;
            outline: none;
            font-size: 0.92rem;
        }
        .ai-assistant-footer {
            display: flex;
            gap: 0.65rem;
            padding: 0 1rem 1rem;
        }
        .ai-send-btn {
            flex: 1 1 auto;
            border-radius: 9999px;
            padding: 0.85rem 1rem;
            border: 0;
            background: linear-gradient(135deg, #2563eb 0%, #38bdf8 100%);
            color: white;
            font-size: 0.72rem;
            font-weight: 900;
            letter-spacing: 0.16em;
            text-transform: uppercase;
        }
        .ai-prompt-card {
            margin: 0 1rem 1rem;
            border-radius: 1rem;
            padding: 0.9rem;
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.08);
        }
        .ai-prompt-card strong {
            display: block;
            margin-bottom: 0.5rem;
            font-size: 0.72rem;
            text-transform: uppercase;
            letter-spacing: 0.16em;
            color: #93c5fd;
        }
        .ai-prompt-card pre {
            margin: 0;
            white-space: pre-wrap;
            color: #e2e8f0;
            font-size: 0.82rem;
            line-height: 1.6;
        }
        .consent-banner {
            position: fixed;
            left: 1rem;
            right: 1rem;
            bottom: 1rem;
            z-index: 70;
            max-width: 46rem;
            margin: 0 auto;
            display: flex;
            gap: 1rem;
            align-items: center;
            justify-content: space-between;
            padding: 1rem 1.1rem;
            border-radius: 1.5rem;
            background: rgba(3, 7, 18, 0.94);
            border: 1px solid rgba(96, 165, 250, 0.28);
            box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
            backdrop-filter: blur(24px);
        }
        .consent-banner.hidden { display: none; }
        .consent-copy {
            color: #e5e7eb;
            font-size: 0.9rem;
            line-height: 1.55;
        }
        .consent-copy strong {
            display: block;
            color: #fff;
            margin-bottom: 0.25rem;
        }
        .consent-actions {
            display: flex;
            gap: 0.65rem;
            flex-wrap: wrap;
            flex-shrink: 0;
        }
        .consent-btn {
            padding: 0.8rem 1rem;
            border-radius: 9999px;
            font-size: 0.72rem;
            font-weight: 900;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            transition: all 0.2s ease;
            border: 1px solid rgba(255, 255, 255, 0.12);
        }
        .consent-btn.primary {
            background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
            color: white;
        }
        .consent-btn.secondary {
            background: rgba(255, 255, 255, 0.04);
            color: #cbd5e1;
        }
        .consent-btn:hover { transform: translateY(-1px); }
        .step-card {
            border-radius: 1.5rem;
            padding: 1.2rem;
        }
        .step-badge {
            width: 2rem;
            height: 2rem;
            display: grid;
            place-items: center;
            border-radius: 9999px;
            background: rgba(59, 130, 246, 0.16);
            color: #93c5fd;
            font-weight: 900;
            font-size: 0.8rem;
            margin-bottom: 0.8rem;
        }
        .status-pill {
            display: inline-flex;
            align-items: center;
            gap: 0.45rem;
            padding: 0.45rem 0.8rem;
            border-radius: 9999px;
            font-size: 0.68rem;
            font-weight: 900;
            letter-spacing: 0.16em;
            text-transform: uppercase;
            border: 1px solid rgba(255, 255, 255, 0.12);
            background: rgba(255, 255, 255, 0.04);
        }
        .status-dot {
            width: 0.5rem;
            height: 0.5rem;
            border-radius: 9999px;
            background: #94a3b8;
            box-shadow: 0 0 12px currentColor;
        }
        .status-pill.connected {
            color: #86efac;
            border-color: rgba(34, 197, 94, 0.35);
            background: rgba(34, 197, 94, 0.12);
        }
        .status-pill.connected .status-dot { background: #22c55e; color: #22c55e; }
        .status-pill.pending {
            color: #fcd34d;
            border-color: rgba(250, 204, 21, 0.35);
            background: rgba(250, 204, 21, 0.12);
        }
        .status-pill.pending .status-dot { background: #f59e0b; color: #f59e0b; }
        .status-pill.idle {
            color: #cbd5e1;
            border-color: rgba(148, 163, 184, 0.25);
            background: rgba(148, 163, 184, 0.08);
        }
        .status-pill.idle .status-dot { background: #94a3b8; color: #94a3b8; }
        .status-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 0.6rem;
        }
        .mini-btn {
            padding: 0.75rem 1rem;
            border-radius: 9999px;
            font-size: 0.7rem;
            font-weight: 900;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            border: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.2s ease;
        }
        .mini-btn:hover { transform: translateY(-1px); }
        @keyframes whatsappPulse {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-4px); }
        }
