:root {
            --bg-dark: #0f111a;
            --glass-bg: rgba(255, 255, 255, 0.03);
            --glass-border: rgba(255, 255, 255, 0.08);
            --accent-purple: #9d4edd;
            --accent-cyan: #00f5ff;
            --accent-gold: #f1c40f;
            --text-main: #f8f9fa;
            --text-muted: #8b949e;
            --success: #2ea043;
            --danger: #f85149;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }
        
        body {
            font-family: 'Outfit', sans-serif;
            background-color: var(--bg-dark);
            color: var(--text-main);
            min-height: 100vh;
            background-image: 
                radial-gradient(circle at 15% 50%, rgba(157, 78, 221, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 85% 30%, rgba(0, 245, 255, 0.1) 0%, transparent 50%);
            display: flex;
            flex-direction: column;
            padding: 2rem;
            position: relative;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid var(--glass-border);
        }

        h1 {
            font-weight: 800;
            font-size: 2rem;
            background: linear-gradient(90deg, #fff, var(--text-muted));
            background-clip: text;
            -webkit-background-clip: text;
            letter-spacing: -0.5px;
        }

        .status-badge {
            padding: 0.5rem 1rem;
            border-radius: 50px;
            font-size: 0.85rem;
            font-weight: 600;
            background: rgba(46, 160, 67, 0.1);
            color: var(--success);
            border: 1px solid rgba(46, 160, 67, 0.2);
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .status-badge.offline {
            background: rgba(248, 81, 73, 0.1);
            color: var(--danger);
            border-color: rgba(248, 81, 73, 0.2);
        }

        .status-badge::before {
            content: '';
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: currentColor;
            box-shadow: 0 0 8px currentColor;
        }

        /* Grid Layout */
        .dashboard-grid {
            display: grid;
            grid-template-columns: repeat(12, 1fr);
            gap: 1.5rem;
            flex: 1;
        }

        .glass-panel {
            background: var(--glass-bg);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 1.5rem;
            backdrop-filter: blur(12px) saturate(180%);
            -webkit-backdrop-filter: blur(12px) saturate(180%);
            box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            overflow: visible;
        }

        /* Console Tabs */
        .console-header-container {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        }
        .console-tabs {
            display: flex;
            gap: 4px;
            background: rgba(0, 0, 0, 0.3);
            padding: 4px;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        .console-tab {
            padding: 6px 14px;
            border-radius: 8px;
            font-size: 0.75rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
            border: none;
            color: var(--text-muted);
            background: transparent;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .console-tab.active {
            background: rgba(157, 78, 221, 0.2);
            color: var(--accent-purple);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }
        .console-tab:hover:not(.active) {
            background: rgba(255, 255, 255, 0.05);
            color: var(--text-main);
        }
        .terminal {
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.05);
            padding: 1rem;
            font-family: 'JetBrains Mono', 'Fira Code', monospace;
            box-shadow: inset 0 10px 30px rgba(0, 0, 0, 0.5);
        }
        
        .glass-panel::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
        }

        .glass-panel:hover {
            box-shadow: 0 12px 48px 0 rgba(0, 245, 255, 0.08);
            border-color: rgba(255, 255, 255, 0.15);
            transform: translateY(-2px);
        }

        /* Custom Scrollbar */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        ::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.01);
        }
        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: var(--accent-purple);
        }

        /* KPI Cards */
        .kpi-container {
            grid-column: span 12;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
        }

        .kpi-card {
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            cursor: pointer;
        }

        .kpi-title {
            font-size: 0.9rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 600;
        }

        .kpi-value {
            font-size: 2.5rem;
            font-weight: 800;
            color: var(--text-main);
        }

        .kpi-card.accent-purple .kpi-value { color: var(--accent-purple); text-shadow: 0 0 20px rgba(157, 78, 221, 0.4); }
        .kpi-card.accent-cyan .kpi-value { color: var(--accent-cyan); text-shadow: 0 0 20px rgba(0, 245, 255, 0.4); }

        /* Status LEDs */
        .status-led {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 8px;
            box-shadow: 0 0 8px rgba(0,0,0,0.5);
        }
        .led-online { background-color: #00ff88; box-shadow: 0 0 12px #00ff88; }
        .led-offline { background-color: #ffcc00; box-shadow: 0 0 12px #ffcc00; animation: pulse-led 1.5s infinite; }
        .led-error { background-color: #ff3366; box-shadow: 0 0 12px #ff3366; }
        
        @keyframes pulse-led {
            0% { opacity: 1; }
            50% { opacity: 0.4; }
            100% { opacity: 1; }
        }

        /* ── Telemetry strip: 6 equal symmetric compact cards ── */
        .telemetry-strip-6col {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 0.75rem;
            margin-bottom: 2rem;
        }
        .telemetry-card {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid var(--glass-border);
            border-radius: 12px;
            padding: 0.85rem 0.75rem;
            display: flex;
            align-items: center;
            justify-content: space-between;
            transition: transform 0.3s, background 0.3s;
        }
        .telemetry-card:hover { transform: translateY(-3px); background: rgba(255, 255, 255, 0.06); }
        /* Compact vertical card variant */
        .tc-compact {
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
            padding: 0.7rem 0.5rem;
            text-align: center;
            min-height: 80px;
        }
        .tc-icon {
            font-size: 1.25rem;
            line-height: 1;
            margin-bottom: 2px;
        }
        .tc-label {
            font-size: 0.65rem;
            color: var(--text-muted);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            white-space: nowrap;
        }
        .tc-qr-btn {
            margin-top: 4px;
            background: rgba(139, 92, 246, 0.2);
            color: var(--accent-purple);
            border: 1px solid rgba(139, 92, 246, 0.3);
            border-radius: 6px;
            padding: 2px 8px;
            font-size: 0.65rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
            white-space: nowrap;
        }
        .tc-qr-btn:hover {
            background: rgba(139, 92, 246, 0.4);
            border-color: var(--accent-purple);
            transform: scale(1.05);
        }
        .telemetry-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

        /* Client List Styles */
        .client-row {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            border: 1px solid rgba(255,255,255,0.05);
            background: rgba(255,255,255,0.02);
            border-radius: 16px;
            margin-bottom: 1rem;
        }
        .client-row:hover {
            transform: translateX(10px);
            background: rgba(255,255,255,0.07);
            border-color: rgba(0, 245, 255, 0.4);
            box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 20px rgba(0, 245, 255, 0.1);
        }
        .btn-action-outline {
            background: rgba(255,255,255,0.05);
            border: 1px solid rgba(255,255,255,0.1);
            color: var(--text-main);
            padding: 0.6rem 1.2rem;
            border-radius: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            transition: all 0.2s;
        }
        .btn-action-outline:hover {
            background: rgba(255,255,255,0.1);
            border-color: var(--accent-cyan);
            color: var(--accent-cyan);
            transform: translateY(-2px);
        }
        .btn-action-cyan {
            background: rgba(0,245,255,0.08);
            border: 1px solid rgba(0,245,255,0.2);
            color: var(--accent-cyan);
            padding: 0.6rem 1.2rem;
            border-radius: 12px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 0.85rem;
            font-weight: 600;
            transition: all 0.2s;
        }
        .btn-action-cyan:hover {
            background: rgba(0,245,255,0.15);
            border-color: var(--accent-cyan);
            transform: translateY(-2px);
            box-shadow: 0 0 15px rgba(0,245,255,0.2);
        }
        .telemetry-value { font-size: 0.9rem; color: #fff; font-weight: bold; display: flex; align-items: center; }

        /* Tabs Navigation */
        .tabs-container {
            display: flex; gap: 1rem; max-width: 1200px; margin: 0 auto 1.5rem auto;
            border-bottom: 1px solid var(--glass-border); padding-bottom: 0px;
        }
        .tab-btn {
            background: transparent; border: none; color: var(--text-muted); padding: 10px 20px;
            font-size: 1.1rem; cursor: pointer; transition: 0.3s;
            border-bottom: 3px solid transparent; border-radius: 8px 8px 0 0;
            font-weight: bold;
        }
        .tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
        .tab-btn.active { color: var(--accent-purple); border-bottom-color: var(--accent-purple); }
        
        .tab-content { display: none !important; width: 100%; }
        .tab-content.active { display: block !important; animation: fadeIn 0.3s forwards; }
        
        @keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
        
        button[onclick*="fetch"]:hover {
            transform: scale(1.05);
        }
        
        button[onclick*="fetch"] span, button[onclick*="fetch"]:not(:has(span)) {
             transition: transform 0.3s ease;
        }

        button[onclick*="fetch"]:active {
            transform: scale(0.95);
        }

        .refresh-spin {
            animation: spin 0.6s ease-in-out;
        }

        @keyframes spin {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
        }

        /* Settings UI */
        .settings-card {
            background: rgba(255, 255, 255, 0.05);
            padding: 1.5rem;
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 16px;
            margin-bottom: 1.5rem;
            backdrop-filter: blur(12px);
        }
        .settings-title { font-size: 1.2rem; font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 0.5rem; margin-bottom: 1rem; color: var(--accent-cyan); }
        .settings-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
        .settings-row label { font-size: 1rem; color: #fff; display: flex; flex-direction: column; gap: 4px; }
        .settings-desc { font-size: 0.8rem; color: var(--text-muted); font-weight: normal; }
        .switch { position: relative; display: inline-block; width: 50px; height: 26px; }
        .switch input { opacity: 0; width: 0; height: 0; }
        .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; }
        .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
        input:checked + .slider { background-color: var(--accent-purple); box-shadow: 0 0 10px var(--accent-purple); }
        input:checked + .slider:before { transform: translateX(24px); }
        /* Modo Prueba — TogglŽ ámbar */
        input:checked + .slider-test { background-color: #f59e0b; box-shadow: 0 0 12px rgba(245,158,11,0.7); }
        /* Badge de alerta de Modo Prueba */
        #test-mode-badge {
            display: none;
            align-items: center;
            gap: 6px;
            background: rgba(245,158,11,0.15);
            border: 1px solid rgba(245,158,11,0.5);
            color: #f59e0b;
            font-size: 0.75rem;
            font-weight: 700;
            padding: 4px 12px;
            border-radius: 20px;
            letter-spacing: 0.05em;
            animation: pulse-amber 2s ease-in-out infinite;
        }
        @keyframes pulse-amber {
            0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
            50% { box-shadow: 0 0 8px 3px rgba(245,158,11,0.35); }
        }

        .setting-input { background: #111; border: 1px solid var(--glass-border); color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 1rem; outline: none; }
        .setting-input:focus { border-color: var(--accent-cyan); }

        /* Drafts & Buffers Section */
        .drafts-container-grid {
            grid-column: span 12;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1.5rem;
        }

        .drafts-section, .buffers-section {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .section-header {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .draft-item {
            background: rgba(0,0,0,0.2);
            border: 1px solid var(--glass-border);
            border-radius: 12px;
            margin-bottom: 1rem;
            overflow: hidden;
        }

        .draft-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 1.25rem;
            cursor: pointer;
            background: rgba(255,255,255,0.02);
            transition: background 0.2s;
        }
        .draft-header:hover { background: rgba(255,255,255,0.05); }
        
        .draft-contact { font-weight: 600; font-size: 1.1rem; color: var(--accent-cyan); }
        .draft-time { font-size: 0.85rem; color: var(--text-muted); }

        .draft-body {
            padding: 0 1.25rem 1.25rem 1.25rem;
            border-top: 1px solid var(--glass-border);
            display: none; /* Accordion hidden by default */
        }

        .draft-textarea {
            width: 100%;
            min-height: 120px;
            background: rgba(0,0,0,0.3);
            border: 1px solid rgba(255,255,255,0.1);
            color: #d1d5db;
            font-size: 0.95rem;
            line-height: 1.5;
            padding: 1rem;
            border-radius: 8px;
            font-family: inherit;
            margin-top: 1rem;
            margin-bottom: 1rem;
            resize: vertical;
        }
        .draft-textarea:focus { outline: none; border-color: var(--accent-cyan); }

        .draft-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

        button {
            background: none;
            border: none;
            cursor: pointer;
            padding: 0.6rem 1.2rem;
            border-radius: 8px;
            font-weight: 600;
            font-size: 0.9rem;
            transition: all 0.2s;
            font-family: 'Outfit', sans-serif;
        }

        .btn-send {
            background: rgba(46, 160, 67, 0.15);
            color: #3fb950;
            border: 1px solid rgba(46, 160, 67, 0.3);
        }
        .btn-send:hover { background: rgba(46, 160, 67, 0.25); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(46, 160, 67, 0.2); }

        .btn-cancel {
            background: rgba(248, 81, 73, 0.1);
            color: var(--danger);
            border: 1px solid rgba(248, 81, 73, 0.2);
        }
        .btn-cancel:hover { background: rgba(248, 81, 73, 0.2); transform: translateY(-2px); }

        .btn-new {
            background: rgba(0, 245, 255, 0.1);
            color: var(--accent-cyan);
            border: 1px solid rgba(0, 245, 255, 0.3);
        }
        .btn-new:hover { background: rgba(0, 245, 255, 0.2); }

        .btn-ai {
            background: rgba(157, 78, 221, 0.1);
            color: var(--accent-purple);
            border: 1px solid rgba(157, 78, 221, 0.3);
        }
        .btn-ai:hover { background: rgba(157, 78, 221, 0.2); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(157, 78, 221, 0.2); }

        .empty-state {
            text-align: center;
            padding: 3rem 1rem;
            color: var(--text-muted);
            font-style: italic;
        }

        /* Terminal Console */
        .console-section {
            grid-column: span 5;
            display: flex;
            flex-direction: column;
            height: 100%;
        }

        .terminal {
            background: #0d1117;
            border-radius: 12px;
            padding: 1rem;
            font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
            font-size: 0.85rem;
            overflow-y: auto;
            flex-grow: 1;
            height: 500px;
            box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
            border: 1px solid rgba(255,255,255,0.05);
        }

        .terminal::-webkit-scrollbar { width: 6px; }
        .terminal::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

        .log-line { margin-bottom: 0.4rem; line-height: 1.4; word-wrap: break-word; color: #a5d6ff; }
        .log-time { color: #8b949e; margin-right: 0.5rem; font-size: 0.75rem; }
        .log-error { color: #ff7b72; }
        .log-info { color: #a5d6ff; }

        /* MODAL */
        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.7);
            backdrop-filter: blur(5px);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }
        .modal-content {
            background: var(--bg-dark);
            border: 1px solid var(--glass-border);
            border-radius: 16px;
            padding: 2rem;
            width: 90%;
            max-width: 500px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.5);
        }
        .modal-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 1rem; color: var(--accent-cyan); }
        .form-group { margin-bottom: 1rem; }
        .form-group label { display: block; font-size: 0.9rem; margin-bottom: 0.5rem; color: var(--text-muted); }
        .form-input {
            width: 100%; padding: 0.75rem; border-radius: 8px;
            background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border);
            color: #fff; font-family: inherit; font-size: 1rem;
        }
        .form-input:focus { outline: none; border-color: var(--accent-cyan); }
        .client-list { max-height: 300px; overflow-y: auto; margin-top: 1rem; }
        .client-list-item {
            padding: 0.75rem; border-radius: 8px; background: rgba(255,255,255,0.02);
            margin-bottom: 0.5rem; display: flex; justify-content: space-between;
        }

        @keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
        .loading { animation: pulse 1.5s infinite ease-in-out; }

        /* Burbujas de Chat Estilo WhatsApp */
        .chat-bubble {
            max-width: 80%; padding: 6px 7px 8px 9px; border-radius: 7.5px; font-size: 0.95rem; line-height: 1.3;
            word-wrap: break-word; position: relative; clear: both; display: flex; flex-direction: column;
            box-shadow: 0 1px 0.5px rgba(11,20,26,.13);
        }
        
        .chat-client {
            background: #202c33; color: #e9edef; align-self: flex-start;
            border-top-left-radius: 0; margin-left: 10px;
        }
        /* Cola de burbuja izquierda */
        .chat-client::before {
            content: ""; position: absolute; top: 0; left: -10px; width: 0; height: 0;
            border: 10px solid transparent; border-top-color: #202c33; border-right-color: #202c33; border-left: 0;
            margin-top: 0;
        }

        .chat-haidar {
            background: #005c4b; color: #e9edef; align-self: flex-end;
            border-top-right-radius: 0; margin-right: 10px;
        }
        /* Cola de burbuja derecha */
        .chat-haidar::before {
            content: ""; position: absolute; top: 0; right: -10px; width: 0; height: 0;
            border: 10px solid transparent; border-top-color: #005c4b; border-left-color: #005c4b; border-right: 0;
            margin-top: 0;
        }

        .chat-time {
            font-size: 0.68rem; color: rgba(255,255,255,0.6); margin-top: 2px; text-align: right; 
            display: inline-block; align-self: flex-end; margin-left: 10px;
        }

        /* Utilidades para Modal Historial */
        .wa-bg {
            background-color: #0b141a;
            /* Opcional: WhatsApp Doodle Background pattern here */
            background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
            background-size: 20px 20px;
        }
        
        .custom-scrollbar::-webkit-scrollbar {
            width: 6px;
        }
        .custom-scrollbar::-webkit-scrollbar-track {
            background: transparent;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.2);
            border-radius: 10px;
        }
        .custom-scrollbar::-webkit-scrollbar-thumb:hover {
            background: rgba(255,255,255,0.3);
        }

        /* ─── CALENDAR STYLES ──── */
        .calendar-layout {
            display: grid;
            grid-template-columns: 1fr 340px;
            gap: 1.5rem;
            max-width: 1200px;
            margin: 0 auto;
        }
        .cal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.25rem;
        }
        .cal-nav-btn {
            background: rgba(255,255,255,0.03);
            border: 1px solid var(--glass-border);
            color: var(--text-muted);
            width: 42px;
            height: 42px;
            border-radius: 12px;
            font-size: 1.2rem;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            padding: 0;
        }
        .cal-nav-btn:hover { 
            background: var(--glass-bg); 
            color: #fff;
            border-color: rgba(255,255,255,0.2);
            transform: scale(1.05);
        }
        .cal-nav-btn:active { transform: scale(0.95); }
        .cal-month-title {
            font-size: 2.2rem;
            font-weight: 900;
            text-transform: capitalize;
            letter-spacing: -1px;
            background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
            -webkit-background-clip: text;
            display: flex;
            align-items: center;
            gap: 16px;
        }
        .cal-grid {
            display: grid;
            grid-template-columns: repeat(7, minmax(0, 1fr));
            gap: 2px;
            width: 100%;
            background: rgba(255, 255, 255, 0.04);
            border-radius: 24px;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.08);
            box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
            padding: 2px;
        }
        .cal-day-name {
            padding: 12px 0;
            text-align: center;
            font-size: 0.75rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: var(--accent-cyan);
            background: rgba(255, 255, 255, 0.02);
            border-bottom: 1px solid var(--glass-border);
        }
        .cal-day {
            aspect-ratio: 1 / 0.9;
            min-height: 100px;
            padding: 10px;
            background: rgba(255, 255, 255, 0.01);
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }
        .cal-day:hover { 
            background: rgba(255, 255, 255, 0.05);
            z-index: 2;
        }
        .cal-day.other-month { 
            opacity: 0.15; 
            pointer-events: none; 
            background: transparent;
        }
        .cal-day.today {
            background: rgba(0, 245, 255, 0.04);
        }
        .cal-day.today .cal-day-num {
            background: var(--accent-cyan);
            color: #000 !important;
            font-weight: 800;
            box-shadow: 0 0 15px rgba(0, 245, 255, 0.3);
        }
        .cal-day.selected {
            background: rgba(157, 78, 221, 0.08);
            z-index: 5;
        }
        .cal-day.selected .cal-day-num {
            background: var(--accent-purple);
            color: #ffffff !important;
            box-shadow: 0 0 15px rgba(157, 78, 221, 0.4);
        }
        .cal-day-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            margin-bottom: 6px;
        }
        .cal-day-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 4px;
            overflow: hidden;
        }
        .cal-day-num {
            font-size: 0.85rem;
            font-weight: 700;
            color: var(--text-muted);
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .cal-day.current-month .cal-day-num { color: var(--text-main); }
        .cal-event-chip {
            font-size: 0.6rem;
            padding: 4px 6px;
            border-radius: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            font-weight: 600;
            line-height: 1;
            width: 100%;
            display: block;
        }
        .cal-event-chip.type-cita {
            background: rgba(157, 78, 221, 0.2);
            color: #d89dff;
            border-left: 2px solid var(--accent-purple);
        }
        .cal-event-chip.type-other {
            background: rgba(0, 245, 255, 0.15);
            color: var(--accent-cyan);
            border-left: 2px solid var(--accent-cyan);
        }
        .cal-event-more {
            font-size: 0.6rem;
            color: var(--text-muted);
            margin-top: 1px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            opacity: 0.7;
        }
        .cal-avail-dot {
            width: 6px;
            height: 6px;
            background: #00ff88;
            border-radius: 50%;
            flex-shrink: 0;
        }

        /* Day Detail Panel */
        .cal-detail-panel {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 24px;
            padding: 1.75rem;
            backdrop-filter: blur(20px);
            display: flex;
            flex-direction: column;
            gap: 1.25rem;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
        }
        .cal-detail-panel::-webkit-scrollbar { width: 4px; }
        .cal-detail-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
        .cal-detail-date {
            font-size: 1.4rem;
            font-weight: 800;
            color: #fff;
            text-transform: capitalize;
            letter-spacing: -0.5px;
            border-bottom: 2px solid var(--accent-cyan);
            padding-bottom: 8px;
            margin-bottom: 4px;
        }
        .cal-detail-empty {
            color: var(--text-muted);
            font-style: italic;
            font-size: 0.9rem;
            text-align: center;
            padding: 1.5rem 0;
        }
        .cal-event-card {
            padding: 0.75rem;
            border-radius: 10px;
            background: rgba(157,78,221,0.08);
            border: 1px solid rgba(157,78,221,0.2);
        }
        .cal-event-card.type-other {
            background: rgba(0,245,255,0.06);
            border-color: rgba(0,245,255,0.15);
        }
        .cal-event-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
        .cal-event-time { font-size: 0.8rem; color: var(--text-muted); }
        .cal-event-meet { color: var(--accent-cyan); font-size: 0.8rem; text-decoration: none; display: inline-block; margin-top: 4px; }
        .cal-event-meet:hover { text-decoration: underline; }
        .cal-slot {
            padding: 0.75rem 1rem;
            border-radius: 12px;
            background: rgba(46,160,67,0.06);
            border: 1px solid rgba(46,160,67,0.15);
            font-size: 0.9rem;
            color: #4ade80;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            user-select: none;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
        }
        .cal-slot:hover { 
            background: rgba(46,160,67,0.12);
            border-color: rgba(46,160,67,0.3);
            transform: scale(1.02) translateX(5px); 
            box-shadow: 0 4px 15px rgba(46,160,67,0.2);
        }
        .cal-slot-badge {
            font-size: 0.65rem;
            padding: 2px 6px;
            border-radius: 20px;
            background: rgba(46,160,67,0.2);
            color: #3fb950;
            font-weight: 700;
            letter-spacing: 0.5px;
        }
        .cal-slot.blocked {
            background: rgba(248,81,73,0.07);
            border-color: rgba(248,81,73,0.2);
            color: var(--text-muted);
            opacity: 0.75;
        }
        .cal-slot.blocked .cal-slot-badge {
            background: rgba(248,81,73,0.15);
            color: var(--danger);
        }
        .cal-slot.blocked:hover { opacity: 1; filter: brightness(1.2); transform: translateX(3px); }
        @keyframes slotToggle { 0% { transform: scale(0.97); } 100% { transform: scale(1); } }
        .cal-slot.toggling { animation: slotToggle 0.15s ease; }
        .meet-notifier-card {
            background: rgba(0,245,255,0.04);
            border: 1px solid rgba(0,245,255,0.12);
            border-radius: 10px;
            padding: 0.75rem;
            margin-top: 0.5rem;
        }
        .meet-notifier-title {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 700;
            color: var(--accent-cyan);
            margin-bottom: 0.5rem;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .meet-notif-item {
            font-size: 0.8rem;
            color: var(--text-muted);
            padding: 4px 0;
            border-bottom: 1px solid rgba(255,255,255,0.05);
            display: flex;
            align-items: center;
            gap: 6px;
        }
        .meet-notif-item:last-child { border-bottom: none; }
        .cal-section-label {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 700;
            color: var(--text-muted);
            margin-bottom: 0.4rem;
            margin-top: 0.4rem;
        }
        .cal-new-event-form {
            background: rgba(0,0,0,0.2);
            border-radius: 12px;
            padding: 1rem;
            border: 1px solid rgba(255,255,255,0.05);
            margin-top: 0.5rem;
        }
        .cal-form-title {
            font-size: 0.9rem;
            font-weight: 700;
            color: var(--accent-cyan);
            margin-bottom: 0.75rem;
        }
        .cal-input {
            width: 100%;
            padding: 7px 10px;
            border-radius: 7px;
            background: rgba(0,0,0,0.3);
            border: 1px solid var(--glass-border);
            color: #fff;
            font-family: inherit;
            font-size: 0.88rem;
            margin-bottom: 0.5rem;
        }
        .cal-input:focus { outline: none; border-color: var(--accent-cyan); }
        .cal-time-row { display: flex; gap: 0.5rem; }
        .cal-time-row .cal-input { margin-bottom: 0; }
        .btn-cal-create {
            background: rgba(157,78,221,0.15);
            color: var(--accent-purple);
            border: 1px solid rgba(157,78,221,0.3);
            width: 100%;
            margin-top: 0.75rem;
            padding: 0.6rem;
            font-size: 0.9rem;
        }
        .btn-cal-create:hover { background: rgba(157,78,221,0.25); }
        @keyframes slideInRight {
            from { opacity: 0; transform: translateX(20px); }
            to { opacity: 1; transform: translateX(0); }
        }
        .cal-detail-panel { animation: slideInRight 0.25s ease; }
        .draft-item.gemini {
            border: 1px solid var(--accent-purple);
            background: rgba(188, 71, 230, 0.05);
        }
        
        .draft-item.gemini .draft-contact {
            color: var(--accent-purple);
        }
        
        .btn-copy-gemini {
            background: var(--accent-purple);
            color: #fff;
            border: none;
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        
        .btn-copy-gemini:hover {
            background: #ab3bc9;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(188, 71, 230, 0.3);
        }

        /* ═══════════════════════════════════════════════════════════
           RESPONSIVE / OVERFLOW FIXES — Antigravity Architect Audit
           ═══════════════════════════════════════════════════════════ */

        /* Prevent flex children from blowing out their container */
        .draft-header { overflow: hidden; }
        .draft-header > div:first-child { min-width: 0; flex: 1 1 0; overflow: hidden; }
        .draft-item { overflow: hidden; min-width: 0; }
        .draft-body { min-width: 0; overflow: visible; }

        /* Contact name — both inline (borradores) and block-column (buffers) */
        .draft-contact {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: 100%;
            min-width: 0;
        }
        /* Buffer variant: the name span inside the flex column */
        .draft-contact > span:first-child {
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: 100%;
        }
        /* Phone number sub-line: always allow breaking */
        .draft-contact > span:last-child {
            white-space: normal;
            word-break: break-all;
            display: block;
        }

        /* Timestamp: never shrink, never wrap */
        .draft-time { flex-shrink: 0; white-space: nowrap; margin-left: 0.5rem; }

        /* Textarea: always box-sized and capped at container width */
        .draft-textarea { max-width: 100%; box-sizing: border-box; }

        /* Terminal: clip horizontal overflow, wrap long log lines */
        .terminal { overflow-x: hidden; word-break: break-word; }
        .log-line { overflow-wrap: break-word; word-break: break-word; white-space: pre-wrap; }

        /* Modal: cap height + internal scroll */
        .modal-content { max-height: 90vh; overflow-y: auto; }

        /* Tabs: scrollable row on overflow */
        .tabs-container {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            flex-wrap: nowrap;
        }
        .tabs-container::-webkit-scrollbar { display: none; }

        /* Chat bubbles in buffer view: constrain width */
        .horizontal-chat-view > div {
            max-width: 90%;
            word-break: break-word;
            overflow-wrap: break-word;
        }

        /* ── Body breathing room on small screens ── */
        @media (max-width: 900px) {
            body { padding: 1rem; }
            h1 { font-size: 1.4rem; }
        }

        /* ── Drafts + Buffers Grid: stack at 900px ── */
        @media (max-width: 900px) {
            .drafts-container-grid { grid-template-columns: 1fr !important; }
        }

        /* ── Buffer action buttons: 2 cols at 600px, 1 col at 380px ── */
        @media (max-width: 600px) {
            .draft-actions { grid-template-columns: 1fr 1fr !important; }
        }
        @media (max-width: 380px) {
            .draft-actions { grid-template-columns: 1fr !important; }
        }

        /* ── Calendar layout: stack at 900px ── */
        @media (max-width: 900px) {
            .calendar-layout { grid-template-columns: 1fr !important; }
        }

        /* ── Telemetry strip: 3x2 at 768px, 1×5 at 480px ── */
        @media (max-width: 900px) {
            .telemetry-strip-5col { grid-template-columns: repeat(3, 1fr) !important; }
            .telemetry-strip-6col { grid-template-columns: repeat(3, 1fr) !important; }
        }
        @media (max-width: 768px) {
            .telemetry-strip-5col { grid-template-columns: repeat(2, 1fr) !important; }
            .telemetry-strip-6col { grid-template-columns: repeat(3, 1fr) !important; }
        }
        @media (max-width: 480px) {
            .telemetry-strip-5col { grid-template-columns: 1fr !important; }
            .telemetry-strip-6col { grid-template-columns: repeat(2, 1fr) !important; }
        }

        /* ── Console header: stack on small screens ── */
        @media (max-width: 640px) {
            .console-header-container { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
            .console-tabs { width: 100%; overflow-x: auto; }
            .tab-btn { padding: 8px 12px; font-size: 0.85rem; }
        }

        /* ── Command Center (Terminal + QR): stack at 900px ── */
        @media (max-width: 900px) {
            .cmd-center-grid { grid-template-columns: 1fr !important; }
        }

        /* ── Settings span-6 columns: full width at 900px ── */
        @media (max-width: 900px) {
            #view-settings .dashboard-grid > div[style*="span 6"] { grid-column: span 1 !important; }
        }

        /* ── KPI cards: 2 cols at 640px, 1 col at 400px ── */
        @media (max-width: 640px) {
            .kpi-container { grid-template-columns: repeat(2, 1fr); }
        }
        @media (max-width: 400px) {
            .kpi-container { grid-template-columns: 1fr; }
        }

/* ── WhatsApp-style Chat Layout ── */
#view-drafts {
    height: calc(100vh - 120px);
    padding: 0 1rem 2rem 1rem;
    box-sizing: border-box;
    width: 100%;
}

.chat-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    width: 100% !important;
    max-width: 100% !important;
    height: 100%;
    gap: 0;
    overflow: hidden;
    background: #0b141a;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

/* Sidebar */
.chat-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.08);
    background: #111b21;
    overflow: hidden;
    border-radius: 12px 0 0 12px;
}
.chat-sidebar-header {
    padding: 15px 20px;
    background: #202c33;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.chat-search-container {
    padding: 10px;
    background: #111b21;
}
.chat-search-box {
    display: flex;
    align-items: center;
    background: #202c33;
    border-radius: 8px;
    padding: 5px 10px;
}
.chat-search-box input {
    background: transparent;
    border: none;
    color: #e9edef;
    width: 100%;
    padding: 8px;
    font-size: 0.95rem;
    outline: none;
}
.chat-filters {
    display: flex;
    gap: 8px;
    padding: 0 15px 10px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.chat-filter-btn {
    background: #202c33;
    color: #8696a0;
    border: none;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-filter-btn.active {
    background: rgba(0, 245, 255, 0.15);
    color: var(--accent-cyan);
}
.chat-list {
    flex: 1;
    overflow-y: auto;
}

/* Sidebar Items */
.chat-list-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: background 0.2s;
}
.chat-list-item:hover {
    background: #202c33;
}
.chat-list-item.active {
    background: rgba(0, 245, 255, 0.08);
}
.chat-list-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #4895ef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.2rem;
    margin-right: 15px;
    flex-shrink: 0;
    color: #fff;
}
.chat-list-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.chat-list-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 3px;
}
.chat-list-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: #e9edef;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-list-time {
    font-size: 0.75rem;
    color: #8696a0;
    flex-shrink: 0;
    margin-left: 10px;
}
.chat-list-preview {
    font-size: 0.85rem;
    color: #8696a0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-list-badge {
    background: #00a884;
    color: #111b21;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

/* Main Panel */
.chat-main {
    display: flex;
    flex-direction: column;
    background: #0b141a;
    border-radius: 0 12px 12px 0;
    overflow: hidden;
}
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #222e35;
    border-radius: 0 12px 12px 0;
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: #202c33;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px 40px;
    background-image: url("https://static.whatsapp.net/rsrc.php/v3/yl/r/r2_3-h_5Hw.png");
    background-color: #0b141a;
    background-blend-mode: overlay;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-input-area {
    display: flex;
    position: relative;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    background: #202c33;
    gap: 12px;
    flex-shrink: 0;
}
#chat-composer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.chat-icon-btn {
    background: transparent;
    border: none;
    color: #8696a0;
    font-size: 1.4rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px;
}
.chat-icon-btn:hover {
    color: #d1d7db;
}
.chat-input {
    flex: 1;
    background: #2a3942;
    border: none;
    color: #e9edef;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 1rem;
    resize: none;
    outline: none;
    max-height: 120px;
}
.chat-send-btn {
    background: #00a884;
    color: #111b21;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s;
}
.chat-send-btn:hover {
    background: #02c299;
}
.chat-icon-btn.recording {
    color: #e74c3c !important;
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.fin-kpis {
    grid-template-columns: repeat(5, 1fr) !important;
}
@media (max-width: 1100px) {
    .fin-kpis {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 560px) {
    .fin-kpis {
        grid-template-columns: 1fr !important;
    }
}
#chat-emoji-panel button:hover {
    background: rgba(255,255,255,0.08);
}
/* ═══════════════════════════════════════════════════════════
   RESPONSIVE MOBILE & TABLET — Haidar Dashboard
   Sobreescribe estilos inline problemáticos en pantallas pequeñas
   ═══════════════════════════════════════════════════════════ */

/* ── Breakpoints: 1200 (laptop pequeño) · 900 (tablet) · 640 (móvil) · 400 ── */

/* Botón "volver a lista" del chat: solo visible en móvil */
.chat-mobile-back {
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #e9edef;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px 10px;
    margin-right: 4px;
    border-radius: 50%;
}

/* ============ ≤ 1200px : laptops pequeños / tablets landscape ============ */
@media (max-width: 1200px) {
    .chat-layout { grid-template-columns: 320px 1fr; }
    .calendar-layout { grid-template-columns: 1fr 300px; }
}

/* ============ ≤ 900px : tablets / landscape phones ============ */
@media (max-width: 900px) {
    body { padding: 0.75rem; }

    /* Header: apilar y compactar */
    header { flex-direction: column; align-items: stretch; gap: 0.75rem; margin-bottom: 1rem; padding-bottom: 0.75rem; }
    header h1 { font-size: 1.25rem; flex-wrap: wrap; }
    header > div:first-child { width: 100%; }
    header > div:last-child { justify-content: space-between; flex-wrap: wrap; }
    header .status-badge { font-size: 0.75rem; padding: 0.35rem 0.7rem; }
    header button { font-size: 0.75rem !important; padding: 4px 9px !important; }

    /* Dashboard grids: todo a 1 columna (span inline → anulado) */
    .dashboard-grid { grid-template-columns: 1fr !important; }
    #view-welcome .dashboard-grid > div,
    #view-settings .dashboard-grid > div,
    #view-settings .cmd-center-grid,
    #view-welcome [style*="span 8"], #view-welcome [style*="span 6"], #view-welcome [style*="span 4"] {
        grid-column: span 1 !important;
    }
    .cmd-center-grid { grid-template-columns: 1fr !important; }
    #view-settings [style*="span 6"] { grid-column: span 1 !important; }

    /* Centro de Mando: los grid items y selects pueden encogerse.
       Un select width:100% con opción larga (405px min-content) estiraba
       el track → el layout viewport saltaba de 390 a 537px */
    #view-settings .dashboard-grid > div,
    #view-settings .cmd-center-grid > div {
        min-width: 0 !important;
    }
    #view-settings .setting-input,
    #view-settings select.setting-input {
        min-width: 0 !important;
        max-width: 100% !important;
    }
    #view-settings .terminal { min-width: 0 !important; }

    /* KPI cards inline: repeat(3…5, 1fr) → 3 columnas en tablet */
    #view-welcome [style*="repeat(3, 1fr)"] { grid-template-columns: repeat(3, 1fr) !important; }
    #view-finances [style*="repeat(4, 1fr)"], #view-finances [style*="repeat(4,1fr)"], #view-clients [style*="repeat(4,1fr)"] { grid-template-columns: repeat(3, 1fr) !important; }
    #view-finances [style*="repeat(5, 1fr)"], #view-finances [style*="repeat(2, 1fr)"] { grid-template-columns: repeat(3, 1fr) !important; }

    /* Finanzas: breakdown a una columna en tablet */
    #view-finances [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }

    /* Chat: lista arriba (38fr), chat debajo — ambas visibles */
    .chat-layout {
        grid-template-columns: 1fr !important;
        grid-template-rows: 38fr 62fr;
        height: 100%;
        max-height: calc(100vh - 140px);
    }
    .chat-sidebar { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.08); border-radius: 12px 12px 0 0; }
    .chat-main { border-radius: 0 0 12px 12px; min-height: 0; }
    .chat-history { padding: 16px 12px; }
    .chat-empty-state { border-radius: 0 0 12px 12px; }

    /* Calendario: celdas compactas */
    .cal-grid { gap: 1px; border-radius: 16px; }
    .cal-day { min-height: 64px; padding: 5px; aspect-ratio: auto; }
    .cal-day-num { width: 24px; height: 24px; font-size: 0.75rem; }
    .cal-day-content { gap: 2px; }
    .cal-day-title { font-size: 0.65rem; line-height: 1.1; }
    .cal-month-title { font-size: 1.6rem; }
    .calendar-layout { grid-template-columns: 1fr !important; }

    /* Terminal más corto */
    #terminal { height: 300px !important; }

    /* Buscador y controles de clientes: ancho completo */
    #view-clients [style*="width:220px"] { width: 100% !important; max-width: 100%; }
    #view-finances [style*="width: 280px"] { width: 100% !important; max-width: 100%; }
    #cli-date-controls { flex-wrap: wrap; justify-content: center; }

    /* Tabs: permiten wrap en tablet (641–900) — antes desbordaban 90px+ */
    .tabs-container { flex-wrap: wrap !important; justify-content: center; row-gap: 4px; }
    .tab-btn { white-space: nowrap; }
}

/* ============ ≤ 640px : móviles (pantalla estándar) ============ */
@media (max-width: 640px) {
    /* Título compacto */
    header h1 { font-size: 1.05rem; }
    /* Tabs: grid 2×3 en móvil — toda la navegación visible, sin cortes ni scroll */
    .tabs-container {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        margin: 0 auto 1rem auto;
        padding-bottom: 10px;
        overflow: visible;
    }
    .tab-btn {
        padding: 10px 6px;
        font-size: 0.8rem;
        text-align: center;
        white-space: nowrap;
        border-bottom: 2px solid transparent;
        border-radius: 8px;
        background: rgba(255,255,255,0.04);
    }
    .tab-btn.active {
        background: rgba(155,89,182,0.15);
        border-bottom-color: var(--accent-purple);
    }

    /* Contenido: nada desborda horizontalmente en móvil */
    body { overflow-x: hidden; }
    .tab-content { overflow-x: hidden; min-width: 0; }
    .glass-panel { overflow-wrap: break-word; }
    select { max-width: 100% !important; }
    #view-welcome h2 { font-size: 1.5rem !important; }

    /* Welcome: KPIs 2×1, luego 1 columna */
    #view-welcome [style*="repeat(3, 1fr)"] { grid-template-columns: 1fr !important; }

    /* Welcome: contenido dinámico (citas e ingresos) responsive */
    #welcome-next-appointment > div,
    #welcome-last-incomes > div {
        flex-wrap: wrap !important;
    }
    #welcome-next-appointment [style*="flex-shrink: 0"],
    #welcome-last-incomes [style*="flex-shrink: 0"] {
        flex-shrink: 1 !important;
        min-width: 0 !important;
    }
    #welcome-last-incomes [style*="min-width: 80px"] {
        min-width: 0 !important;
        width: auto !important;
    }
    #welcome-next-appointment [style*="text-align: right"],
    #welcome-last-incomes [style*="text-align: right"] {
        text-align: left !important;
        width: 100% !important;
        margin-top: 4px !important;
    }
    #welcome-next-appointment [style*="margin-right: 10px"],
    #welcome-last-incomes [style*="margin-left: 10px"] {
        margin: 0 !important;
    }
    #view-finances [style*="repeat(4, 1fr)"], #view-finances [style*="repeat(4,1fr)"], #view-clients [style*="repeat(4,1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }
    #view-finances [style*="repeat(5, 1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }

    /* Modal perfil de cliente: KPIs a una columna en móvil */
    #modal-client-profile [style*="repeat(3,1fr)"] { grid-template-columns: 1fr !important; }

    /* Chat: modo lista ↔ chat (toggle con .mobile-chat-open) */
    #view-drafts { padding: 0 0.5rem 0.5rem 0.5rem; height: calc(100vh - 120px); }
    .chat-layout { grid-template-rows: 1fr; height: 100%; max-height: none; }
    .chat-sidebar { display: flex; height: 100%; border-radius: 12px; }
    .chat-main { display: none !important; }
    .mobile-chat-open .chat-sidebar { display: none !important; }
    .mobile-chat-open .chat-main { display: flex !important; border-radius: 12px; height: 100%; }
    .chat-mobile-back {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: #e9edef;
        font-size: 1.2rem;
        cursor: pointer;
        padding: 6px 10px;
        margin-right: 4px;
        border-radius: 50%;
    }
    .chat-mobile-back:hover { background: rgba(255,255,255,0.08); }
    .chat-header { padding: 8px 10px; gap: 4px; }
    .chat-header-actions { gap: 4px; }
    .chat-input-area { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
    .chat-input { font-size: 0.95rem; padding: 10px 12px; }
    .chat-icon-btn { font-size: 1.15rem; }
    .chat-send-btn { width: 40px; height: 40px; }
    .chat-ai-tools { padding: 8px 10px; }
    .chat-bubble { max-width: 92%; }

    /* Calendario: solo números — sin contenido extra para evitar encimado */
    .cal-day { min-height: 40px; padding: 3px; }
    .cal-day-num { width: 22px; height: 22px; font-size: 0.7rem; }
    .cal-day-content { display: none; }
    .cal-day-header { margin-bottom: 0; }
    .cal-day-name { padding: 6px 0; font-size: 0.62rem; letter-spacing: 0.5px; }
    .cal-month-title { font-size: 1.3rem; }
    .cal-nav-btn { width: 34px; height: 34px; font-size: 1rem; }

    /* Panel de día del calendario */
    .cal-detail-panel { padding: 1rem; }

    /* Calendario: padding lateral para que las tarjetas no peguen al borde */
    #view-calendar { padding: 0 0.75rem 1.5rem 0.75rem !important; }

    /* Tarjeta "Próximas Citas Generales": cada cita se apila y el texto respeta el ancho */
    #upcoming-appointments > div {
        flex-wrap: wrap !important;
        gap: 0.5rem;
    }
    #upcoming-appointments > div > div:first-child {
        min-width: 0 !important;
        flex: 1 1 100% !important;
        overflow-wrap: break-word;
    }
    #upcoming-appointments > div > a { flex-shrink: 0 !important; }

    /* Cabeceras flex del calendario (título + botón/switch): permiten wrap */
    #view-calendar [style*="justify-content:space-between"] {
        flex-wrap: wrap !important;
        gap: 0.5rem;
    }

    /* Leyenda debajo del grid mensual */
    #view-calendar [style*="gap:1.5rem"] {
        flex-wrap: wrap !important;
        gap: 0.75rem !important;
    }

    /* Disponibilidad semanal: filas apiladas, selects fluidos */
    #availability-days > div { flex-wrap: wrap !important; gap: 0.5rem !important; }
    #availability-days div[style*="flex:1"] {
        flex: 1 1 100% !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    #availability-days select {
        flex: 1 1 90px !important;
        width: auto !important;
        max-width: 130px !important;
    }

    /* Panel de día: tarjetas y slots no desbordan */
    .cal-event-card { overflow-wrap: break-word; }
    .cal-slot { flex-wrap: wrap !important; row-gap: 4px; }
    .cal-slot-badge { margin-left: auto; }

    /* Notificaciones: tarjetas con wrap y bloques de control a línea completa */
    #notif-upcoming-list > div { overflow-wrap: break-word; }
    #notif-upcoming-list [style*="justify-content:space-between"] {
        flex-wrap: wrap !important;
        gap: 6px;
    }
    #notif-upcoming-list [style*="margin-left:auto"] {
        margin-left: 0 !important;
        flex: 1 1 100% !important;
        flex-wrap: wrap !important;
    }

    /* Finanzas: navegador y acciones se ajustan */
    #view-finances > div { padding: 0.75rem !important; }
    #fin-nav-row { justify-content: center; gap: 8px; }
    #fin-period-display { min-width: 120px; font-size: 0.85rem; }
    #view-finances [style*="display: flex; gap: 0.75rem"] { gap: 0.5rem; }
    #view-finances .btn-new, #view-finances .btn-ai, #btn-cloud-sync { width: 100%; justify-content: center; font-size: 0.85rem; }

    /* Finanzas: sub-tabs y pestañas de período permiten wrap en móvil */
    #view-finances > div > div[style*="display:flex; gap:12px"] { flex-wrap: wrap !important; gap: 8px; }
    #view-finances [style*="gap:6px; background:rgba(0,0,0,0.3)"] {
        flex-wrap: wrap !important;
        justify-content: center;
    }

    /* Finanzas: KPI cards internos no desbordan (emoji + texto en 2 columnas) */
    #view-finances [style*="display:flex; align-items:center; gap:0.75rem; padding:0.7rem 1rem"] {
        flex-wrap: wrap !important;
    }
    #view-finances [style*="display:flex; align-items:center; gap:0.75rem; padding:0.7rem 1rem"] > div {
        min-width: 0 !important;
        overflow-wrap: break-word;
    }

    /* Finanzas: contenido dinámico (categorías, cuentas, clientes del período) */
    #fin-categories [style*="justify-content:space-between"],
    #fin-accounts [style*="justify-content:space-between"],
    #fin-clients-list [style*="justify-content:space-between"],
    #fin-period-clients-list [style*="justify-content:space-between"] {
        flex-wrap: wrap !important;
        gap: 4px 8px !important;
    }
    #fin-categories [style*="justify-content:space-between"] > span,
    #fin-accounts [style*="justify-content:space-between"] > span,
    #fin-clients-list [style*="justify-content:space-between"] > div,
    #fin-clients-list [style*="justify-content:space-between"] > span,
    #fin-period-clients-list [style*="justify-content:space-between"] > div {
        min-width: 0 !important;
        overflow-wrap: break-word;
    }

    /* Finanzas: header de transacciones y análisis de cliente permiten wrap */
    #fin-subview-transactions [style*="justify-content:space-between"] { flex-wrap: wrap !important; gap: 8px; }
    #client-analytics-empty [style*="justify-content:space-between"] { flex-wrap: wrap !important; gap: 8px; }
    #cli-anal-insight-box { flex-wrap: wrap !important; }

    /* Finanzas: el nombre de cliente con nowrap+ellipsis no debe expandir el viewport */
    #fin-transactions [style*="white-space:nowrap"] {
        white-space: normal !important;
        overflow-wrap: break-word !important;
        min-width: 0 !important;
    }

    /* Finanzas: los canvas (Chart.js con tamaño intrínseco) nunca desbordan */
    #view-finances canvas {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    /* Finanzas: Top 5 clientes (nombre largo + teléfono + monto) */
    #analytics-top5-list [style*="justify-content:space-between"] { flex-wrap: wrap !important; gap: 4px 8px !important; }
    #analytics-top5-list [style*="justify-content:space-between"] > div {
        min-width: 0 !important;
        overflow-wrap: break-word;
    }

    /* Finanzas: Analytics — footers de period cards y métricas de referencia */
    #fin-subview-analytics [style*="justify-content:space-between"] { flex-wrap: wrap !important; gap: 4px 8px !important; }
    #fin-subview-analytics [style*="display:flex; align-items:center; gap:0.75rem; padding:0.8rem 1.1rem"] { flex-wrap: wrap !important; }
    #fin-subview-analytics [style*="display:flex; align-items:center; gap:0.75rem; padding:0.8rem 1.1rem"] > div {
        min-width: 0 !important;
        overflow-wrap: break-word;
    }

    /* Clientes: header apilado y búsqueda full width */
    #view-clients > div { padding: 0.75rem !important; }
    #view-clients [style*="justify-content:space-between"] { gap: 0.75rem; }
    #cli-search, #cli-sort { width: 100% !important; }
    #view-clients [style*="gap:0.75rem"] { gap: 0.5rem; }

    /* Clientes: KPI strip a 2 columnas (4 celdas + montos largos desbordan) */
    #cli-kpi-strip { grid-template-columns: 1fr 1fr !important; gap: 0.5rem !important; }
    #cli-kpi-strip > div { padding: 0.6rem 0.75rem !important; }
    #cli-kpi-strip [style*="font-size:1.5rem"] { font-size: 1.15rem !important; overflow-wrap: anywhere; }

    /* Clientes: fila de cliente apilada (min-content ≈950px si no se aplana) */
    #cli-list { min-width: 0; }
    #cli-list .client-row {
        flex-wrap: wrap !important;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }
    /* nombre: permitir partir */
    #cli-list .client-row [style*="font-weight:800; font-size:1.2rem"] { overflow-wrap: anywhere !important; }
    /* wrapper teléfono + estado: wrap y teléfono comprimible */
    #cli-list .client-row [style*="display:flex; gap:15px"] { flex-wrap: wrap !important; gap: 0.5rem !important; }
    #cli-list .client-row [style*="font-size:0.85rem; color:var(--text-muted); display:flex"] {
        min-width: 0 !important;
        overflow-wrap: anywhere;
    }

    /* Clientes: bloque de stats (ingreso/sesiones/%): full width sin bordes laterales */
    #cli-list .client-row > div[style*="border-left:1px solid rgba(255,255,255,0.08); padding: 0 2rem;"] {
        flex: 1 1 100% !important;
        width: 100% !important;
        border-left: none !important;
        border-top: 1px solid rgba(255,255,255,0.08);
        padding: 0.75rem 0 0.25rem 0 !important;
        gap: 0.5rem 1rem !important;
        flex-wrap: wrap !important;
        justify-content: space-between !important;
    }
    #cli-list .client-row > div[style*="border-left:1px solid rgba(255,255,255,0.08); padding: 0 2rem;"] > div {
        flex: 0 1 auto !important;
        min-width: 0 !important;
        text-align: right !important;
    }
    #cli-list .client-row > div[style*="border-left:1px solid rgba(255,255,255,0.08); padding: 0 2rem;"] > div > div {
        overflow-wrap: anywhere !important;
    }

    /* Clientes: botones Historial/Perfil a full width y stretch */
    #cli-list .client-row > div[style*="gap:10px; flex-shrink:0;"] {
        flex: 1 1 100% !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }
    #cli-list .client-row > div[style*="gap:10px; flex-shrink:0;"] > button {
        flex: 1 !important;
        justify-content: center !important;
        white-space: nowrap;
    }

    /* Settings: tarjetas a full width */
    #view-settings { padding: 0 0.5rem 1.5rem 0.5rem !important; }
    .settings-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .settings-row label { width: 100%; }
    .settings-row .setting-input { width: 100% !important; max-width: 100%; }
    #doctrine-editor { height: 180px !important; }

    /* Consola: tabs en fila compacta */
    .console-tabs { gap: 4px; }
    .console-tab { font-size: 0.75rem; padding: 5px 10px; }

    /* Modales: casi full screen */
    .modal-content {
        width: 96%;
        max-width: 96%;
        padding: 1.25rem;
        max-height: 92vh;
    }
    .modal-title { font-size: 1.2rem; }

    /* Tablas: scroll horizontal en vez de encimar */
    table { display: block; max-width: 100%; overflow-x: auto; white-space: nowrap; }
    .glass-panel { padding: 1rem; }
}

/* ============ ≤ 400px : móviles pequeños ============ */
@media (max-width: 400px) {
    body { padding: 0.5rem; }
    #view-finances [style*="repeat(4, 1fr)"], #view-finances [style*="repeat(4,1fr)"], #view-clients [style*="repeat(4,1fr)"] { grid-template-columns: 1fr !important; }
    #view-finances [style*="repeat(5, 1fr)"] { grid-template-columns: 1fr !important; }
    .cal-day { min-height: 34px; }
    .terminal { height: 220px !important; }
    .chat-ai-tools { max-height: 140px; }
    #active-chat-ai-buttons { max-height: 90px; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — PESTAÑA COBROS (Servicios y Cobros)
   Misma estética y breakpoints que Finanzas / Clientes
   ═══════════════════════════════════════════════════════════ */

/* ============ ≤ 900px : tablets / landscape phones ============ */
@media (max-width: 900px) {
    /* KPIs: 5 → 3 columnas (igual que Finanzas en tablet) */
    #view-cobros [style*="repeat(5, 1fr)"] { grid-template-columns: repeat(3, 1fr) !important; }

    /* Búsqueda full width en la fila de filtros */
    #cobros-search { width: 100% !important; max-width: 100% !important; margin-left: 0 !important; }

    /* Selector de período: ocupa todo el ancho */
    #view-cobros [style*="width:fit-content"] { width: 100% !important; }
}

/* ============ ≤ 640px : móviles ============ */
@media (max-width: 640px) {
    /* Padding interno igual que Finanzas/Clientes */
    #view-cobros > div { padding: 0.75rem !important; }

    /* KPIs: 5 → 2 columnas (igual que Finanzas en móvil) */
    #view-cobros [style*="repeat(5, 1fr)"] { grid-template-columns: repeat(2, 1fr) !important; }

    /* Header: título + botones apilados, botones full width */
    #view-cobros [style*="justify-content:space-between"] { gap: 0.75rem !important; }
    #view-cobros [style*="display:flex; gap:8px; flex-wrap:wrap"] > button { flex: 1 1 100% !important; }

    /* Búsqueda: full width debajo de los chips */
    #cobros-search { width: 100% !important; max-width: 100% !important; margin-left: 0 !important; flex: 1 1 100% !important; }

    /* Selector de período: botones repartidos en todo el ancho */
    #view-cobros [style*="width:fit-content"] > button { flex: 1 1 auto !important; justify-content: center; white-space: nowrap; }

    /* KPI cards internos: permiten wrap y no desbordan (emoji + texto) */
    #cobros-kpis [style*="display:flex; align-items:center; gap:0.75rem; padding:0.7rem 1rem"] { flex-wrap: wrap !important; }
    #cobros-kpis [style*="display:flex; align-items:center; gap:0.75rem; padding:0.7rem 1rem"] > div { min-width: 0 !important; overflow-wrap: break-word; }
}

/* ============ ≤ 400px : móviles pequeños ============ */
@media (max-width: 400px) {
    /* KPIs: 2 → 1 columna */
    #view-cobros [style*="repeat(5, 1fr)"] { grid-template-columns: 1fr !important; }
    #view-cobros [style*="display:flex; gap:8px; flex-wrap:wrap"] { gap: 0.5rem !important; }
}

/* WORKSPACE SWITCHER */
.workspace-switcher {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.15); /* More visible glass effect */
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 6px;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.ws-btn {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: #ffffff !important;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
.ws-btn:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}
.ws-btn.active {
    color: #ffffff !important;
    background: var(--accent-cyan);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0,245,255,0.4);
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* THEMES */
body.theme-maestro .ws-btn.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px rgba(241,196,64,0.4);
    color: #ffffff !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
body.theme-maestro h1 > div#socket-status {
    background: var(--accent-gold) !important;
    box-shadow: 0 0 8px var(--accent-gold) !important;
}
body.theme-maestro .tab-btn.active {
    border-bottom-color: var(--accent-gold);
    color: var(--accent-gold);
}
body.theme-maestro .btn-action-cyan {
    background: var(--accent-gold);
    color: #111; font-weight: 900;
}
body.theme-maestro .btn-action-cyan:hover {
    background: #d4ac0d;
}

/* ═══════════════════════════════════════════════════════════════════
   CFO & TESORERÍA INTELIGENTE — ESTILOS MODERNOS & RESPONSIVE MÓVIL
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Tarjeta Estratégica Copilot CFO AI ─── */
.cfo-strategy-card {
    background: linear-gradient(135deg, rgba(16, 26, 45, 0.95) 0%, rgba(26, 22, 54, 0.95) 100%);
    border: 1px solid rgba(0, 245, 255, 0.3);
    border-left: 5px solid var(--accent-cyan);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 15px rgba(0, 245, 255, 0.08);
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
}

.cfo-strategy-card.is-high-priority {
    border-left: 5px solid #ff5555;
    border-color: rgba(255, 85, 85, 0.4);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 15px rgba(255, 85, 85, 0.12);
}

.cfo-strategy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.cfo-strategy-badge-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cfo-copilot-tag {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent-cyan);
    background: rgba(0, 245, 255, 0.12);
    border: 1px solid rgba(0, 245, 255, 0.25);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.cfo-priority-pill {
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
}

.cfo-priority-pill.cfo-priority-high {
    background: rgba(255, 85, 85, 0.2);
    color: #ff5555;
    border: 1px solid rgba(255, 85, 85, 0.4);
}

.cfo-priority-pill.cfo-priority-normal {
    background: rgba(80, 250, 123, 0.15);
    color: #50fa7b;
    border: 1px solid rgba(80, 250, 123, 0.3);
}

.cfo-strategy-refresh-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cfo-strategy-refresh-btn:hover {
    background: rgba(0, 245, 255, 0.15);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.cfo-strategy-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.cfo-strategy-icon {
    font-size: 1.6rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.cfo-strategy-text-wrap {
    flex: 1;
}

.cfo-strategy-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--accent-cyan);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.cfo-strategy-order {
    font-size: 1.12rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.45;
}

.cfo-strategy-reason {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.83rem;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.45;
}

.cfo-reason-icon {
    font-size: 0.95rem;
    flex-shrink: 0;
}

.cfo-strategy-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent-cyan);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 1.2rem;
}

.cfo-strategy-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 245, 255, 0.2);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ─── Calendario de Pagos Inteligente (Grid & Agenda) ─── */
.paycal-view-toggle {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
}

.paycal-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.paycal-toggle-btn.active {
    background: rgba(162, 155, 254, 0.25);
    color: #a29bfe;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.paycal-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    margin-bottom: 1.2rem;
}

.paycal-wrapper::-webkit-scrollbar {
    height: 5px;
}

.paycal-wrapper::-webkit-scrollbar-thumb {
    background: rgba(162, 155, 254, 0.3);
    border-radius: 10px;
}

.paycal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    min-width: 100%;
}

.paycal-weekday-header {
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 2px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.paycal-day-cell {
    min-height: 95px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: pointer;
    transition: all 0.18s ease-in-out;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.paycal-day-cell:hover {
    background: rgba(162, 155, 254, 0.12) !important;
    box-shadow: inset 0 0 0 1px rgba(162, 155, 254, 0.4);
    transform: translateY(-1px);
    z-index: 2;
}

.paycal-day-cell:hover .paycal-add-btn {
    opacity: 1;
    transform: scale(1);
}

.paycal-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.paycal-day-num {
    font-size: 0.88rem;
    font-weight: 800;
}

.paycal-add-btn {
    opacity: 0.4;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.paycal-add-btn:hover {
    background: var(--accent-cyan);
    color: #000;
    opacity: 1;
    transform: scale(1.15);
}

.paycal-chip {
    padding: 3px 5px;
    border-radius: 5px;
    font-size: 0.68rem;
    margin-bottom: 3px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.12s ease, filter 0.12s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.paycal-chip:hover {
    transform: scale(1.02);
    filter: brightness(1.2);
}

/* ─── Vista Agenda Vertical para Móvil ─── */
.paycal-agenda-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.paycal-agenda-day-card {
    background: rgba(22, 22, 38, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s ease;
}

.paycal-agenda-day-card.is-today {
    border-color: rgba(0, 245, 255, 0.4);
    background: rgba(0, 245, 255, 0.05);
}

.paycal-agenda-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 6px;
}

.paycal-agenda-day-title {
    font-size: 0.92rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.paycal-agenda-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════════
   REGLAS RESPONSIVAS EXHAUSTIVAS PARA MÓVIL (<= 768px y <= 480px)
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    #view-cfo {
        padding: 0 0 1.5rem 0 !important;
    }

    #view-cfo > div {
        padding: 0.8rem 0.6rem !important;
    }

    /* Hero Banner Liquidez en Móvil */
    #cfo-total-liquid {
        font-size: clamp(1.8rem, 7vw, 2.4rem) !important;
    }

    .glass-panel {
        padding: 1rem !important;
    }

    /* Reestructuración de Grids en 1 Sola Columna */
    #cfo-overview-summary-grid,
    #cfo-expenses-grid-layout,
    #cfo-movement-goal-allocations,
    #cfo-budget-subbolsas {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Grids de Cuentas y Metas */
    #cfo-wallets-grid,
    #cfo-goals-list {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Botones de navegación subtabs */
    .cfo-subtab-btn {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }

    /* Calendario adaptado para móvil */
    .paycal-grid {
        min-width: 100% !important;
    }

    .paycal-day-cell {
        min-height: 70px !important;
        padding: 3px !important;
    }

    .paycal-day-num {
        font-size: 0.75rem !important;
    }

    .paycal-chip {
        font-size: 0.62rem !important;
        padding: 2px 3px !important;
    }

    .paycal-add-btn {
        width: 16px !important;
        height: 16px !important;
        font-size: 0.65rem !important;
    }

    .cfo-strategy-card {
        padding: 1rem !important;
    }

    .cfo-strategy-order {
        font-size: 0.98rem !important;
    }
}

@media (max-width: 480px) {
    #cfo-total-liquid {
        font-size: 1.85rem !important;
    }

    .cfo-strategy-main {
        flex-direction: column;
        gap: 6px;
    }

    .cfo-strategy-icon {
        display: none;
    }

    .paycal-weekday-header {
        font-size: 0.65rem !important;
        padding: 4px 1px !important;
    }
}

