@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700&family=Assistant:wght@400;500;600;700&display=swap');

        /* =========================================
           THEME VARIABLES
           ========================================= */

        /* Global smooth transitions */
        *, *::before, *::after {
            transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
        }
        .login-spinner, .ai-spin, .mode-banner-dot {
            transition: none !important;
        }

        /* =========================================
           SETTINGS ACCORDION
           ========================================= */

        /* Prevent the global glass-panel padding rule from injecting space
           into accordion wrappers — they manage their own internal layout. */
        .settings-accordion.glass-panel {
            padding: 0 !important;
        }

        .settings-accordion .accordion-body {
            display: grid;
            grid-template-rows: 0fr;
            transition: grid-template-rows 0.3s ease;
            overflow: hidden !important;
        }
        .settings-accordion .accordion-body.open {
            grid-template-rows: 1fr;
        }
        /* Inner wrapper: hidden when body is closed, visible when open.
           opacity+visibility ensures zero visual trace even if grid still has residual height. */
        .settings-accordion .accordion-inner {
            overflow: hidden;
            min-height: 0;
            opacity: 0 !important;
            visibility: hidden !important;
            pointer-events: none;
            transition: opacity 0.2s ease, visibility 0s linear 0.2s;
        }
        .settings-accordion .accordion-body.open .accordion-inner {
            opacity: 1 !important;
            visibility: visible !important;
            pointer-events: auto;
            transition: opacity 0.3s ease, visibility 0s linear;
        }
        .settings-accordion .accordion-trigger.open .accordion-chevron {
            transform: rotate(180deg);
        }

        /* =========================================
           SERVICE ROW — LABELS + MOBILE CARD LAYOUT
           ========================================= */
        .svc-field-label {
            display: block;
            font-size: 0.65rem;
            font-weight: 600;
            color: #71717a; /* zinc-500 */
            margin-bottom: 3px;
            line-height: 1;
            letter-spacing: 0.02em;
        }
        .svc-field-label-wrapper > input,
        .svc-field-label-wrapper > select,
        .svc-field-label-wrapper > .svc-img-wrapper {
            width: 100%;
        }

        @media (max-width: 767px) {
            .svc-row {
                flex-wrap: wrap;
                align-items: flex-start;
            }
            .svc-grid {
                grid-template-columns: 1fr 1fr !important;
            }
            .svc-grid > *:first-child,
            .svc-grid > *:last-child {
                grid-column: 1 / -1;
            }
        }

        /* === DARK THEME (DEFAULT) === */
        :root,
        [data-theme="dark"] {
            --bg-app: #020617;
            --bg-base: #020617;
            --bg-surface: #0F172A;
            --bg-elevated: #1E293B;
            --bg-input: #1E293B;
            --bg-hover: #1E293B;
            --border-color: #1E293B;
            --border-input: #334155;
            --text-primary: #F8FAFC;
            --text-secondary: #94A3B8;
            --text-muted: #475569;
            --text-placeholder: #64748B;
            --accent: #60A5FA;
            --accent-hover: #93C5FD;
            --scrollbar-track: #0F172A;
            --scrollbar-thumb: #334155;
            --select-bg: #0F172A;
            --select-color: #F8FAFC;
            --overlay-bg: rgba(2, 6, 23, 0.92);
            --shadow-color: rgba(0, 0, 0, 0.5);
            --shadow-card: 0 4px 6px -1px rgb(0 0 0 / 0.5);
            --shadow-card-hover: 0 10px 25px -5px rgb(0 0 0 / 0.6);
            /* Sidebar — always dark regardless of theme */
            --sidebar-bg: #020617;
            --sidebar-border: #1E293B;
            --sidebar-text: #CBD5E1;
            --sidebar-text-muted: #64748B;
            --sidebar-item-hover-bg: rgba(255, 255, 255, 0.06);
            --sidebar-item-active-bg: rgba(96, 165, 250, 0.15);
            --sidebar-item-active-text: #93C5FD;
            --sidebar-accent: #60A5FA;
            --inbox-sidebar-bg: #111b21;
            --inbox-chat-bg: #0b141a;
            --inbox-border: #1a262c;
            --inbox-header-bg: #1f2c33;
            --inbox-search-bg: #202c33;
            --inbox-item-hover: #182229;
            --inbox-item-active: #2a3942;
            --inbox-input-area-bg: #202c33;
            --inbox-text-input-bg: #2a3942;
            --inbox-action-btn-hover: #2a3942;
            --msg-incoming-bg: #202c33;
            --msg-outgoing-bg: #005c4b;
            --msg-incoming-tail: #202c33;
            --msg-outgoing-tail: #005c4b;
            --msg-text-color: #e9edef;
            --crm-section-bg: #1d2b32;
            --crm-section-border: #2a3942;
            --add-input-bg: #202c33;
            --filter-chip-border: #2a3942;
            --filter-chip-hover-bg: #202c33;
            --msg-date-sep-bg: #182d34;
            --msg-date-sep-color: #8696a0;
            --lead-score-track: #202c33;
            --chat-header-name-color: #e9edef;
            --chat-header-status-color: #8696a0;
            --inbox-list-header-color: #e9edef;
            --chat-item-name-color: #e9edef;
            --chat-item-preview-color: #8696a0;
            --chat-item-time-color: #8696a0;
            --canvas-bg: #eef2f6;
            --canvas-border: #cbd5e1;
            --canvas-dot: #cbd5e1;
            --flow-node-bg: #ffffff;
            --flow-node-border: #e2e8f0;
            --flow-node-color: #334155;
            --mock-text-bg: #e2e8f0;
            --mock-text-color: #334155;
            --mock-btn-bg: #ffffff;
            --mock-btn-border: #e2e8f0;
            --canvas-field-bg: #f8fafc;
            --canvas-field-border: #e2e8f0;
            --canvas-input-bg: #ffffff;
            --canvas-input-color: #1e293b;
            --canvas-input-border: #cbd5e1;
            --node-header-bg: #f8fafc;
            --node-header-border: #e2e8f0;
            --node-header-color: #64748b;
            --node-root-header-color: #1e293b;
            --port-bg: #ffffff;
            --folder-card-bg: #0F172A;
            --folder-card-border: #1E293B;
            --folder-card-hover-bg: #1E293B;
            --var-btn-bg: #1E293B;
            --var-btn-border: #334155;
            --filter-tab-bg: #0F172A;
            --filter-tab-border: #1E293B;
            --filter-active-bg: #1E293B;
            --filter-active-text: #F8FAFC;
            --theme-btn-bg: rgba(15,23,42,0.6);
            --theme-btn-active-bg: rgba(96,165,250,0.2);
            --theme-btn-active-border: rgba(96,165,250,0.5);
            --theme-btn-active-color: #93C5FD;
            --theme-btn-idle-color: #64748B;
            --waveform-unplayed-color: rgba(255,255,255,0.28);
            --audio-ui-color: rgba(255,255,255,0.75);
            --audio-ui-bg: rgba(255,255,255,0.18);
            --audio-ui-bg-hover: rgba(255,255,255,0.28);
            --msg-time-color: rgba(241,241,242,0.55);
            --msg-tick-gray: rgba(241,241,242,0.65);
        }

        /* === LIGHT THEME === */
        [data-theme="light"] {
            --bg-app: #F8FAFC;
            --bg-base: #F8FAFC;
            --bg-surface: #FFFFFF;
            --bg-elevated: #F1F5F9;
            --bg-input: #FFFFFF;
            --bg-hover: #EFF6FF;
            --border-color: #E2E8F0;
            --border-input: #CBD5E1;
            --text-primary: #1E293B;
            --text-secondary: #475569;
            --text-muted: #94A3B8;
            --text-placeholder: #94A3B8;
            --accent: #3B82F6;
            --accent-hover: #2563EB;
            --scrollbar-track: #F1F5F9;
            --scrollbar-thumb: #CBD5E1;
            --select-bg: #FFFFFF;
            --select-color: #1E293B;
            --overlay-bg: rgba(0, 0, 0, 0.6);
            --shadow-color: rgba(0, 0, 0, 0.06);
            --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
            --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.10), 0 8px 24px rgba(0,0,0,0.06);
            /* Sidebar — follows theme: white in light mode */
            --sidebar-bg: #FFFFFF;
            --sidebar-border: #E2E8F0;
            --sidebar-text: #1E293B;
            --sidebar-text-muted: #475569;
            --sidebar-item-hover-bg: rgba(59, 130, 246, 0.06);
            --sidebar-item-active-bg: rgba(59, 130, 246, 0.1);
            --sidebar-item-active-text: #2563EB;
            --sidebar-accent: #3B82F6;
            --inbox-sidebar-bg: #f7f8fa;
            --inbox-chat-bg: #e5ddd5;
            --inbox-border: #dde1e7;
            --inbox-header-bg: #eff1f4;
            --inbox-search-bg: #e8eaed;
            --inbox-item-hover: #eff1f4;
            --inbox-item-active: #dde1e7;
            --inbox-input-area-bg: #f7f8fa;
            --inbox-text-input-bg: #ffffff;
            --inbox-action-btn-hover: #e8eaed;
            --msg-incoming-bg: #ffffff;
            --msg-outgoing-bg: #dcf8c6;
            --msg-incoming-tail: #ffffff;
            --msg-outgoing-tail: #dcf8c6;
            --msg-text-color: #1a1a2e;
            --crm-section-bg: #f7f8fa;
            --crm-section-border: #E2E8F0;
            --add-input-bg: #F1F5F9;
            --filter-chip-border: #CBD5E1;
            --filter-chip-hover-bg: #EFF6FF;
            --msg-date-sep-bg: #dde1e7;
            --msg-date-sep-color: #6b7280;
            --lead-score-track: #E2E8F0;
            --chat-header-name-color: #1a1a2e;
            --chat-header-status-color: #6b7280;
            --inbox-list-header-color: #1a1a2e;
            --chat-item-name-color: #1a1a2e;
            --chat-item-preview-color: #6b7280;
            --chat-item-time-color: #9ca3af;
            --canvas-bg: #eef2f6;
            --canvas-border: #cbd5e1;
            --canvas-dot: #cbd5e1;
            --flow-node-bg: #ffffff;
            --flow-node-border: #e2e8f0;
            --flow-node-color: #334155;
            --mock-text-bg: #e2e8f0;
            --mock-text-color: #334155;
            --mock-btn-bg: #ffffff;
            --mock-btn-border: #e2e8f0;
            --canvas-field-bg: #f8fafc;
            --canvas-field-border: #e2e8f0;
            --canvas-input-bg: #ffffff;
            --canvas-input-color: #1e293b;
            --canvas-input-border: #cbd5e1;
            --node-header-bg: #f8fafc;
            --node-header-border: #e2e8f0;
            --node-header-color: #64748b;
            --node-root-header-color: #1e293b;
            --port-bg: #ffffff;
            --folder-card-bg: #FFFFFF;
            --folder-card-border: #E2E8F0;
            --folder-card-hover-bg: #F1F5F9;
            --var-btn-bg: #F1F5F9;
            --var-btn-border: #CBD5E1;
            --filter-tab-bg: #F1F5F9;
            --filter-tab-border: #E2E8F0;
            --filter-active-bg: #E2E8F0;
            --filter-active-text: #1E293B;
            --theme-btn-bg: rgba(255,255,255,0.8);
            --theme-btn-active-bg: rgba(59,130,246,0.1);
            --theme-btn-active-border: rgba(59,130,246,0.4);
            --theme-btn-active-color: #3B82F6;
            --theme-btn-idle-color: #94A3B8;
            --waveform-unplayed-color: rgba(0,0,0,0.22);
            --audio-ui-color: rgba(0,0,0,0.55);
            --audio-ui-bg: rgba(0,0,0,0.10);
            --audio-ui-bg-hover: rgba(0,0,0,0.18);
            --msg-time-color: rgba(0,0,0,0.38);
            --msg-tick-gray: rgba(0,0,0,0.38);
        }

        /* === CREAM THEME === */
        [data-theme="cream"] {
            --bg-app: #fdfbf7;
            --bg-base: #fdfbf7;
            --bg-surface: #f9f5ed;
            --bg-elevated: #ede7db;
            --bg-input: #fdfbf7;
            --bg-hover: #ede7db;
            --border-color: #e8e2d7;
            --border-input: #c9b89e;
            --text-primary: #2d1d11;
            --text-secondary: #5a4b3f;
            --text-muted: #a89280;
            --text-placeholder: #b09d8a;
            --accent: #4F46E5;
            --accent-hover: #4338CA;
            --scrollbar-track: #ede7db;
            --scrollbar-thumb: #c9b89e;
            --select-bg: #fdfaf4;
            --select-color: #3b2d24;
            --shadow-card: 0 4px 6px -1px rgb(59 45 36 / 0.12);
            --shadow-card-hover: 0 10px 25px -5px rgb(59 45 36 / 0.18);
            /* Sidebar — always dark in cream mode */
            --sidebar-bg: #0F172A;
            --sidebar-border: #1E293B;
            --sidebar-text: #CBD5E1;
            --sidebar-text-muted: #64748B;
            --sidebar-item-hover-bg: rgba(255, 255, 255, 0.06);
            --sidebar-item-active-bg: rgba(79, 70, 229, 0.2);
            --sidebar-item-active-text: #A5B4FC;
            --sidebar-accent: #A5B4FC;
            --overlay-bg: rgba(59, 45, 36, 0.8);
            --shadow-color: rgba(59, 45, 36, 0.2);
            --inbox-sidebar-bg: #ede5da;
            --inbox-chat-bg: #e4d5c5;
            --inbox-border: #c9b89e;
            --inbox-header-bg: #ddd1c3;
            --inbox-search-bg: #d4c6b5;
            --inbox-item-hover: #dfd4c9;
            --inbox-item-active: #ccc4ba;
            --inbox-input-area-bg: #ddd1c3;
            --inbox-text-input-bg: #ede5da;
            --inbox-action-btn-hover: #d4c6b5;
            --msg-incoming-bg: #fdfaf4;
            --msg-outgoing-bg: #c8d9bf;
            --msg-incoming-tail: #fdfaf4;
            --msg-outgoing-tail: #c8d9bf;
            --msg-text-color: #3b2d24;
            --crm-section-bg: #fdfaf4;
            --crm-section-border: #c9b89e;
            --add-input-bg: #e4d5c5;
            --filter-chip-border: #c9b89e;
            --filter-chip-hover-bg: #d4c6b5;
            --msg-date-sep-bg: #d4c6b5;
            --msg-date-sep-color: #7d6352;
            --lead-score-track: #d4c6b5;
            --chat-header-name-color: #3b2d24;
            --chat-header-status-color: #7d6352;
            --inbox-list-header-color: #3b2d24;
            --chat-item-name-color: #3b2d24;
            --chat-item-preview-color: #7d6352;
            --chat-item-time-color: #a89280;
            --canvas-bg: #f0e9df;
            --canvas-border: #c9b89e;
            --canvas-dot: #c9b89e;
            --flow-node-bg: #fdfaf4;
            --flow-node-border: #d8c9b5;
            --flow-node-color: #3b2d24;
            --mock-text-bg: #ede7db;
            --mock-text-color: #3b2d24;
            --mock-btn-bg: #fdfaf4;
            --mock-btn-border: #d8c9b5;
            --canvas-field-bg: #fdfaf4;
            --canvas-field-border: #d8c9b5;
            --canvas-input-bg: #fdfaf4;
            --canvas-input-color: #3b2d24;
            --canvas-input-border: #c9b89e;
            --node-header-bg: #f5efe6;
            --node-header-border: #d8c9b5;
            --node-header-color: #7d6352;
            --node-root-header-color: #3b2d24;
            --port-bg: #fdfaf4;
            --folder-card-bg: #fdfaf4;
            --folder-card-border: #d8c9b5;
            --folder-card-hover-bg: #ede7db;
            --var-btn-bg: #ede7db;
            --var-btn-border: #c9b89e;
            --filter-tab-bg: #f5efe6;
            --filter-tab-border: #d8c9b5;
            --filter-active-bg: #ede7db;
            --filter-active-text: #3b2d24;
            --theme-btn-bg: rgba(253,250,244,0.7);
            --theme-btn-active-bg: rgba(79,70,229,0.1);
            --theme-btn-active-border: rgba(79,70,229,0.3);
            --theme-btn-active-color: #4f46e5;
            --theme-btn-idle-color: #a89280;
            --waveform-unplayed-color: rgba(0,0,0,0.20);
            --audio-ui-color: rgba(59,45,36,0.65);
            --audio-ui-bg: rgba(59,45,36,0.12);
            --audio-ui-bg-hover: rgba(59,45,36,0.22);
            --msg-time-color: rgba(59,45,36,0.5);
            --msg-tick-gray: rgba(59,45,36,0.5);
        }

        body {
            font-family: 'Heebo', 'Assistant', sans-serif;
            background-color: var(--bg-base);
            color: var(--text-primary);
            overflow-x: hidden;
            font-size: 15px;
            line-height: 1.5;
        }

        .glass-panel {
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            box-shadow: var(--shadow-card);
            border-radius: 12px;
            /* Override any colored top-border Tailwind classes for clean card look */
            border-top-color: var(--border-color) !important;
            border-top-width: 1px !important;
        }

        .input-dark {
            background-color: var(--bg-input);
            border: 1px solid var(--border-input);
            color: var(--text-primary);
            border-radius: 8px;
            transition: all 0.2s;
        }

        .input-dark:focus {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
            outline: none;
            background-color: var(--bg-input);
        }

        .input-dark::placeholder {
            color: var(--text-placeholder);
        }

        .btn-primary {
            background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
            color: #ffffff;
            font-weight: 600;
            transition: all 0.2s;
        }

        .btn-primary:hover {
            background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
            box-shadow: 0 8px 20px -4px rgba(59, 130, 246, 0.4);
            transform: translateY(-1px);
        }

        /* ── Design Theme Selector Cards ───────────────────────── */
        .design-theme-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            padding: 8px 6px 10px;
            border-radius: 12px;
            border: 2px solid var(--border-input);
            background: var(--bg-input);
            transition: border-color 0.18s, box-shadow 0.18s, transform 0.12s;
            user-select: none;
        }
        .design-theme-card:hover {
            border-color: var(--accent);
            transform: translateY(-1px);
        }
        .design-theme-card.selected {
            border-color: var(--accent);
            box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
        }

        /* Mini page previews inside each card */
        .theme-preview-swatch {
            width: 100%;
            height: 58px;
            border-radius: 8px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            gap: 4px;
            padding: 6px;
        }
        .tp-bar {
            height: 8px;
            border-radius: 3px;
            width: 100%;
        }
        .tp-row {
            display: flex;
            gap: 3px;
            flex: 1;
        }
        .tp-card {
            flex: 1;
            border-radius: 3px;
        }
        .tp-card-sm { flex: 0 0 40%; }

        /* Classic: light blue bg, white cards */
        .tp-classic            { background: #e8edf5; }
        .tp-classic .tp-bar    { background: #4f46e5; }
        .tp-classic .tp-card   { background: #fff; }

        /* Dark: #121212 bg, dark cards */
        .tp-dark               { background: #121212; }
        .tp-dark .tp-bar       { background: var(--accent); }
        .tp-dark .tp-card      { background: #1e1e1e; border: 1px solid #2d2d2d; }

        /* Premium: deep navy bg, gold accent bar */
        .tp-premium            { background: #09090f; }
        .tp-premium .tp-bar    { background: linear-gradient(90deg, #b8922a, #c9a84c); }
        .tp-premium .tp-card   { background: #12101d; border: 1px solid rgba(201,168,76,0.2); }

        .theme-card-label {
            font-size: 0.67rem;
            font-weight: 600;
            color: var(--text-secondary);
            text-align: center;
            line-height: 1.2;
        }
        .design-theme-card.selected .theme-card-label {
            color: var(--accent);
        }

        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }

        ::-webkit-scrollbar-track {
            background: var(--scrollbar-track);
        }

        ::-webkit-scrollbar-thumb {
            background: var(--scrollbar-thumb);
            border-radius: 10px;
        }

        .tab-btn {
            padding: 10px 20px;
            border-radius: 10px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s;
            border: 1px solid transparent;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .tab-active {
            background: #3B82F6;
            color: white;
            border-color: #2563EB;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
        }

        .tab-inactive {
            background: var(--bg-surface);
            color: var(--text-secondary);
            border-color: var(--border-color);
        }

        .tab-inactive:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        /* =========================================
           SIDEBAR NAVIGATION SYSTEM
           ========================================= */

        body { padding: 0 !important; }

        #app-shell {
            display: flex;
            height: 100vh;
            width: 100%;
            overflow: hidden;
            position: relative;
        }

        /* ---- SIDEBAR ---- */
        #sidebar {
            position: fixed;
            top: 0; right: 0;
            height: 100%;
            width: 260px;
            background: var(--sidebar-bg);
            border-left: 1px solid var(--sidebar-border);
            display: flex;
            flex-direction: column;
            z-index: 80;
            transition: width 0.3s cubic-bezier(0.4,0,0.2,1), transform 0.3s cubic-bezier(0.4,0,0.2,1);
            overflow: hidden;
        }

        #app-shell.sidebar-collapsed #sidebar { width: 64px; }
        #app-shell.sidebar-collapsed #main-wrapper { margin-right: 64px !important; }

        .sidebar-logo-area {
            display: flex; align-items: center; gap: 10px;
            padding: 20px 16px; border-bottom: 1px solid var(--sidebar-border);
            flex-shrink: 0; min-height: 64px; overflow: hidden;
        }
        .sidebar-logo-icon { font-size: 26px; color: var(--sidebar-accent); flex-shrink: 0; }
        .sidebar-logo-accent { color: var(--sidebar-accent); }
        .sidebar-logo-text {
            font-size: 16px; font-weight: 700; color: var(--sidebar-text);
            white-space: nowrap; opacity: 1;
            transition: opacity 0.15s ease;
            letter-spacing: -0.01em;
        }
        #app-shell.sidebar-collapsed .sidebar-logo-text { opacity: 0; pointer-events: none; }

        #sidebar-nav {
            flex: 1; overflow-y: auto; overflow-x: hidden;
            padding: 12px 8px; display: flex; flex-direction: column; gap: 2px;
        }

        .sidebar-nav-item {
            display: flex; align-items: center; gap: 12px;
            width: 100%; padding: 10px 14px; border-radius: 8px;
            font-size: 14px; font-weight: 500;
            color: var(--sidebar-text-muted);
            background: transparent; border: none; cursor: pointer;
            text-align: right; transition: background 0.18s, color 0.18s;
            white-space: nowrap; overflow: hidden; font-family: inherit;
            position: relative;
        }
        .sidebar-nav-item:hover { background: var(--sidebar-item-hover-bg); color: var(--sidebar-text); }
        .sidebar-nav-item.nav-active {
            background: var(--sidebar-item-active-bg);
            color: var(--sidebar-item-active-text);
            font-weight: 600;
        }
        .sidebar-nav-item.nav-active::after {
            content: ''; position: absolute; right: 0; top: 18%; height: 64%;
            width: 3px; background: var(--sidebar-item-active-text); border-radius: 0 3px 3px 0;
        }
        .sidebar-nav-icon { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
        .sidebar-nav-label {
            flex: 1; text-align: right;
            transition: opacity 0.15s ease; overflow: hidden;
        }
        #app-shell.sidebar-collapsed .sidebar-nav-label { opacity: 0; width: 0; }

        .sidebar-nav-admin { color: #34d399 !important; }
        .sidebar-nav-admin.nav-active { background: rgba(52,211,153,0.1) !important; color: #34d399 !important; }
        .sidebar-nav-admin.nav-active::after { background: #10b981 !important; }
        .sidebar-nav-inbox .sidebar-nav-icon { color: #00a884; }

        .sidebar-footer {
            padding: 12px 8px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0;
        }
        .sidebar-collapse-btn {
            display: flex; align-items: center; justify-content: flex-start; gap: 10px;
            width: 100%; padding: 9px 12px; border-radius: 8px;
            color: var(--sidebar-text-muted); background: transparent; border: none;
            cursor: pointer; font-size: 15px; transition: all 0.2s; font-family: inherit;
            white-space: nowrap; overflow: hidden;
        }
        .sidebar-collapse-btn:hover { background: var(--sidebar-item-hover-bg); color: var(--sidebar-text); }
        .sidebar-collapse-label { font-size: 12px; font-weight: 500; }
        #app-shell.sidebar-collapsed .sidebar-collapse-label { opacity: 0; width: 0; }
        #app-shell.sidebar-collapsed .sidebar-collapse-btn { justify-content: center; }

        /* ---- MOBILE OVERLAY ---- */
        #mobile-sidebar-overlay {
            display: none; position: fixed; inset: 0;
            background: rgba(0,0,0,0.55); z-index: 70;
            backdrop-filter: blur(2px);
        }
        #mobile-sidebar-overlay.active { display: block; }

        /* ---- MAIN WRAPPER ---- */
        #main-wrapper {
            flex: 1; display: flex; flex-direction: column;
            height: 100vh; overflow: hidden;
            margin-right: 260px;
            transition: margin-right 0.3s cubic-bezier(0.4,0,0.2,1);
            min-width: 0;
        }

        /* ---- TOP HEADER ---- */
        #top-header {
            height: 56px; min-height: 56px;
            display: flex; align-items: center; justify-content: space-between;
            padding: 0 24px; gap: 10px;
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border-color);
            box-shadow: 0 1px 3px 0 var(--shadow-color);
            flex-shrink: 0; z-index: 40;
        }
        .header-divider { width: 1px; height: 22px; background: var(--border-color); flex-shrink: 0; }
        .header-user-btn {
            display: flex; align-items: center; gap: 8px;
            padding: 5px 10px; border-radius: 8px; border: none;
            background: transparent; cursor: pointer; color: var(--text-secondary);
            transition: all 0.2s; font-family: inherit;
        }
        .header-user-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
        .header-logout-btn {
            display: flex; align-items: center; padding: 6px 8px;
            border-radius: 8px; border: none; background: transparent;
            cursor: pointer; color: var(--text-muted); transition: all 0.2s; font-family: inherit;
        }
        .header-logout-btn:hover { background: rgba(239,68,68,0.12); color: #f87171; }

        /* ---- APP CONTENT ---- */
        #app-content {
            flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px;
            background: var(--bg-app);
        }
        #app-content.inbox-mode { padding: 0; overflow: hidden; }

        /* ---- RESPONSIVE ---- */
        @media (max-width: 1023px) {
            #sidebar {
                transform: translateX(100%);
                width: 260px !important;
                box-shadow: -12px 0 40px rgba(0,0,0,0.45);
                z-index: 90;
            }
            #sidebar.mobile-open { transform: translateX(0); }
            #main-wrapper { margin-right: 0 !important; }
        }

        .cal-day-pill { user-select: none; text-align: center; }
        .cal-day-pill span { pointer-events: none; }

        .ai-policy-card { display: block; }

        select.bg-transparent option {
            background: var(--select-bg);
            color: var(--select-color);
        }

        .date-wrapper {
            position: relative;
            display: inline-block;
            width: 100%;
        }

        .date-wrapper input[type="date"] {
            width: 100%;
            cursor: pointer;
            position: relative;
            z-index: 2;
            background: transparent;
        }
        [data-theme="dark"] .date-wrapper input[type="date"] { color-scheme: dark; }
        [data-theme="light"] .date-wrapper input[type="date"],
        [data-theme="cream"] .date-wrapper input[type="date"] { color-scheme: light; }

        .date-wrapper input[type="date"]::-webkit-calendar-picker-indicator {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: pointer;
            z-index: 3;
        }

        .wp-bg {
            background-color: #0b141a;
            background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
            background-size: cover;
            position: relative;
        }

        .wp-bubble {
            background-color: #005c4b;
            color: #e9edef;
            border-radius: 8px;
            border-top-left-radius: 8px;
            border-top-right-radius: 0;
            padding: 6px 8px 8px 8px;
            width: 100%;
            font-size: 14.2px;
            line-height: 19px;
            position: relative;
            box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
        }

        .wp-bubble::before {
            content: '';
            position: absolute;
            top: 0;
            right: -8px;
            left: auto;
            width: 0;
            height: 0;
            border-top: 0px solid transparent;
            border-bottom: 12px solid transparent;
            border-left: 8px solid #005c4b;
            border-right: none;
        }

        .wp-button-container {
            display: flex;
            flex-direction: column;
            gap: 2px;
            margin-top: 4px;
            width: 100%;
        }

        .wp-button {
            background-color: #202c33;
            color: #53bdeb;
            font-size: 14px;
            padding: 10px;
            text-align: center;
            border-radius: 8px;
            cursor: default;
            border: none;
            box-shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
            font-weight: 500;
        }

        .wp-header {
            font-weight: 700;
            margin-bottom: 4px;
        }

        .wp-footer {
            color: #8696a0;
            font-size: 11.5px;
            margin-top: 4px;
        }

        /* =========================================
           MAGIC FLOW BUILDER — VERTICAL LAYOUT
           ========================================= */

        /* Canvas container */
        #canvas-container {
            position: relative;
            width: 100%;
            flex: 1;
            background-color: var(--canvas-bg);
            overflow: hidden;
            cursor: grab;
            user-select: none;
            touch-action: none;
            overscroll-behavior: none;
            -ms-scroll-chaining: none;
            background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px);
            background-size: 20px 20px;
        }

        #canvas-container.is-panning { cursor: grabbing; }

        /* Transform target — everything inside gets panned & scaled */
        #canvas-pan-wrapper {
            position: absolute;
            top: 0;
            left: 0;
            transform-origin: 0 0;
            will-change: transform;
            min-width: 100%;
        }

        /* Vertical flow column */
        #flow-nodes-column {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 52px 60px 160px 60px;
        }

        /* Floating zoom controls */
        .canvas-zoom-controls {
            position: absolute;
            bottom: 16px;
            right: 16px;
            display: flex;
            align-items: center;
            gap: 2px;
            z-index: 200;
            background: white;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            padding: 4px;
            box-shadow: 0 4px 16px rgba(0,0,0,0.12);
        }

        .canvas-zoom-btn {
            width: 30px; height: 30px;
            border: none; background: transparent; border-radius: 7px;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 14px; color: #64748b; transition: background 0.13s, color 0.13s;
            flex-shrink: 0;
        }
        .canvas-zoom-btn:hover { background: #f1f5f9; color: #1e293b; }

        .canvas-zoom-label {
            font-size: 11px; font-weight: 700; color: #64748b;
            min-width: 40px; text-align: center;
            cursor: pointer; border-radius: 6px; padding: 2px 4px;
            transition: background 0.13s; white-space: nowrap;
        }
        .canvas-zoom-label:hover { background: #f1f5f9; color: #1e293b; }

        .canvas-zoom-sep {
            width: 1px; height: 18px; background: #e2e8f0; margin: 0 2px; flex-shrink: 0;
        }

        /* Flow Node */
        .flow-node {
            width: 300px;
            background: #ffffff;
            border-radius: 12px;
            border: 1.5px solid #e2e8f0;
            box-shadow: 0 2px 8px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
            position: relative;
            cursor: pointer;
            transition: box-shadow 0.2s, transform 0.15s, border-color 0.15s;
            flex-shrink: 0;
        }

        .flow-node:hover {
            box-shadow: 0 6px 20px rgba(0,0,0,0.11), 0 2px 6px rgba(0,0,0,0.06);
            transform: translateY(-1px);
        }

        .flow-node.selected {
            border-color: #3B82F6 !important;
            box-shadow: 0 0 0 3px rgba(59,130,246,0.2), 0 4px 16px rgba(59,130,246,0.2) !important;
        }

        /* Node header strips */
        .node-header {
            padding: 9px 12px;
            border-radius: 11px 11px 0 0;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }

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

        .node-header-icon {
            width: 26px;
            height: 26px;
            border-radius: 7px;
            background: rgba(255,255,255,0.25);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            color: white;
            flex-shrink: 0;
        }

        .node-header-title {
            font-size: 12px;
            font-weight: 700;
            color: white;
            letter-spacing: 0.01em;
        }

        .node-header-actions { display: flex; gap: 3px; align-items: center; }

        .node-header-btn {
            width: 22px; height: 22px;
            border-radius: 6px;
            background: rgba(255,255,255,0.18);
            border: none; color: white; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 11px; transition: background 0.15s;
        }
        .node-header-btn:hover { background: rgba(255,255,255,0.35); }

        /* Node type colour schemes */
        .node-type-start   .node-header { background: linear-gradient(135deg,#10b981,#059669); }
        .node-type-ai      .node-header { background: linear-gradient(135deg,#8b5cf6,#7c3aed); }
        .node-type-message .node-header { background: linear-gradient(135deg,#3b82f6,#2563eb); }
        .node-type-condition .node-header { background: linear-gradient(135deg,#f59e0b,#d97706); }
        .node-type-jump .node-header { background: linear-gradient(135deg,#0d9488,#0f766e); }
        .node-type-end  .node-header { background: linear-gradient(135deg,#ef4444,#6b7280); }
        .node-type-list    .node-header { background: linear-gradient(135deg,#06b6d4,#0284c7); }
        .node-type-crm     .node-header { background: linear-gradient(135deg,#ec4899,#db2777); }

        /* =========================================
           CRM KANBAN BOARD
           ========================================= */
        #view-crm { min-height: 100vh; }
        .crm-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; margin-bottom:20px; }
        .crm-btn-primary { display:inline-flex; align-items:center; gap:7px; padding:9px 18px; background:linear-gradient(135deg,#3B82F6,#2563EB); color:#fff; border:none; border-radius:10px; font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; transition:all .2s; }
        .crm-btn-primary:hover { box-shadow: 0 6px 16px -3px rgba(59,130,246,0.4); transform: translateY(-1px); }
        .crm-btn-secondary { display:inline-flex; align-items:center; gap:7px; padding:8px 14px; background:var(--bg-surface); color:var(--text-secondary); border:1px solid var(--border-color); border-radius:10px; font-size:12px; font-weight:500; cursor:pointer; font-family:inherit; transition:background .15s; }
        .crm-btn-secondary:hover { background:var(--bg-hover); }
        .crm-btn-danger { display:inline-flex; align-items:center; gap:5px; padding:5px 10px; background:transparent; color:#ef4444; border:1px solid #fca5a5; border-radius:7px; font-size:11px; font-weight:600; cursor:pointer; font-family:inherit; transition:background .15s; }
        .crm-btn-danger:hover { background:#fef2f2; }

        /* Kanban */
        .kanban-board { display:flex; gap:16px; overflow-x:auto; padding-bottom:20px; min-height:60vh; align-items:flex-start; }
        .kanban-column { flex:0 0 288px; display:flex; flex-direction:column; gap:0; border-radius:12px; overflow:hidden; background:var(--bg-surface); border:1px solid var(--border-color); box-shadow:var(--shadow-card); }
        .kanban-col-header { padding:14px 16px 12px; display:flex; align-items:center; gap:8px; border-bottom:1px solid var(--border-color); }
        .kanban-col-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
        .kanban-col-name { font-size:13px; font-weight:700; color:var(--text-primary); flex:1; }
        .kanban-col-count { font-size:11px; font-weight:600; color:var(--text-secondary); background:var(--bg-elevated); padding:2px 8px; border-radius:9px; }
        .kanban-col-body { padding:12px 10px 16px; display:flex; flex-direction:column; gap:8px; min-height:80px; }

        /* Lead card */
        .lead-card { background:var(--bg-surface); border-radius:12px; padding:16px; border:1px solid var(--border-color); box-shadow:var(--shadow-card); transition:transform .15s, box-shadow .2s; cursor:pointer; }
        .lead-card:hover { transform:translateY(-2px); box-shadow:var(--shadow-card-hover); }
        .lead-card-top { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; margin-bottom:7px; }
        .lead-card-name { font-size:13px; font-weight:700; color:var(--text-primary); line-height:1.3; }
        .lead-badges { display:flex; flex-wrap:wrap; gap:4px; align-items:center; }
        .source-tag { font-size:10px; font-weight:700; padding:3px 8px; border-radius:20px; display:inline-flex; align-items:center; border-width:1px; border-style:solid; }
        .source-tag-whatsapp { background:rgba(34,197,94,0.12); color:#16a34a; border-color:rgba(34,197,94,0.25); }
        [data-theme="dark"] .source-tag-whatsapp { color:#4ade80; }
        .source-tag-instagram { background:rgba(236,72,153,0.12); color:#be185d; border-color:rgba(236,72,153,0.25); }
        [data-theme="dark"] .source-tag-instagram { color:#f472b6; }
        .source-tag-manual { background:rgba(59,130,246,0.12); color:#1d4ed8; border-color:rgba(59,130,246,0.25); }
        [data-theme="dark"] .source-tag-manual { color:#93C5FD; }
        .source-tag-other { background:rgba(100,116,139,0.12); color:#475569; border-color:rgba(100,116,139,0.2); }
        [data-theme="dark"] .source-tag-other { color:#94A3B8; }
        .duplicate-badge { font-size:10px; font-weight:700; padding:3px 8px; border-radius:20px; background:rgba(245,158,11,0.12); color:#b45309; border:1px solid rgba(245,158,11,0.3); }
        [data-theme="dark"] .duplicate-badge { color:#fbbf24; }

        /* === OPTED-OUT BADGE === */
        .opted-out-badge {
            display: inline-flex; align-items: center; gap: 3px;
            font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 5px;
            background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
            white-space: nowrap; flex-shrink: 0;
        }

        /* === OPT-OUT DRAWER SECTION === */
        .optout-drawer-section {
            border-radius: 10px; overflow: hidden;
            border: 1px solid rgba(252,165,165,0.4); margin-top: 4px;
        }
        .optout-toggle-row {
            display: flex; align-items: center; justify-content: space-between;
            padding: 10px 14px;
            background: rgba(239,68,68,0.07);
        }
        .optout-toggle-label {
            font-size: 13px; font-weight: 600; color: #ef4444;
            display: flex; align-items: center; gap: 6px;
        }
        .optout-toggle-hint {
            font-size: 11px; color: var(--text-muted);
            padding: 5px 14px 8px; background: rgba(239,68,68,0.04);
        }

        /* === TOGGLE SWITCH === */
        .toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
        .toggle-switch input { opacity: 0; width: 0; height: 0; }
        .toggle-slider {
            position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
            background: #4b5563; border-radius: 22px; transition: .3s;
        }
        .toggle-slider:before {
            position: absolute; content: ""; height: 16px; width: 16px;
            left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s;
        }
        input:checked + .toggle-slider { background: #ef4444; }
        input:checked + .toggle-slider:before { transform: translateX(18px); }
        .lead-card-phone { display:flex; align-items:center; gap:5px; font-size:11px; color:var(--text-secondary); margin-bottom:6px; }
        .lead-wa-btn { display:inline-flex; align-items:center; justify-content:center; width:20px; height:20px; border-radius:50%; background:#22c55e; color:#fff; text-decoration:none; font-size:11px; flex-shrink:0; transition:opacity .15s; }
        .lead-wa-btn:hover { opacity:.8; }
        .lead-card-footer { display:flex; align-items:center; justify-content:space-between; gap:6px; margin-top:6px; }
        .lead-score-pill { font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; background:linear-gradient(135deg,#6366f1,#4f46e5); color:#fff; }
        .lead-agent-text { font-size:10px; color:var(--text-muted); display:flex; align-items:center; gap:3px; }
        .lead-card-actions { display:flex; gap:5px; }
        .lead-action-btn { width:24px; height:24px; border-radius:6px; border:1px solid var(--border-color); background:var(--bg-surface); color:var(--text-secondary); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:12px; transition:background .15s; font-family:inherit; }
        .lead-action-btn:hover { background:var(--bg-hover); color:var(--text-primary); }

        /* Stage settings */
        .stage-row { display:flex; align-items:center; gap:8px; padding:8px 10px; background:var(--bg-elevated); border-radius:9px; border:1px solid var(--border-color); margin-bottom:7px; }
        .stage-color-dot { width:12px; height:12px; border-radius:50%; flex-shrink:0; }
        .stage-row-name { flex:1; font-size:13px; font-weight:600; color:var(--text-primary); }

        /* CRM Modal */
        .crm-modal-overlay { position:fixed; inset:0; background:var(--overlay-bg); z-index:2000; display:flex; align-items:center; justify-content:center; padding:20px; backdrop-filter: blur(4px); }
        .crm-modal { background:var(--bg-surface); border-radius:16px; padding:28px; width:100%; max-width:440px; border:1px solid var(--border-color); box-shadow:0 24px 60px rgba(0,0,0,.4); }
        .crm-modal-title { font-size:17px; font-weight:700; color:var(--text-primary); margin-bottom:20px; display:flex; align-items:center; gap:8px; }
        .crm-field { margin-bottom:14px; }
        .crm-field label { display:block; font-size:12px; font-weight:600; letter-spacing:.02em; color:var(--text-secondary); margin-bottom:6px; }
        .crm-input { width:100%; background:var(--bg-elevated); border:1px solid var(--border-input); color:var(--text-primary); border-radius:8px; padding:10px 14px; font-size:14px; font-family:inherit; outline:none; box-sizing:border-box; transition: border-color 0.2s, box-shadow 0.2s; }
        .crm-input:focus { border-color:var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
        .crm-modal-actions { display:flex; gap:10px; justify-content:flex-end; margin-top:20px; }

        /* CRM Quick Stats */
        .crm-stats-row { display:flex; gap:16px; flex-wrap:wrap; margin-bottom:8px; }
        .crm-stat-card { flex:1; min-width:120px; background:var(--bg-surface); border:1px solid var(--border-color); border-radius:12px; padding:20px 24px; box-shadow:var(--shadow-card); display:flex; flex-direction:column; gap:4px; transition: box-shadow 0.2s; }
        .crm-stat-card:hover { box-shadow: var(--shadow-card-hover); }
        .crm-stat-label { font-size:11px; font-weight:600; color:var(--text-secondary); text-transform:uppercase; letter-spacing:.06em; }
        .crm-stat-value { font-size:24px; font-weight:700; color:var(--text-primary); line-height:1.1; }
        .crm-stat-sub { font-size:11px; color:var(--text-muted); }

        /* CRM Filter chips */
        .crm-filter-chips { display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
        .crm-chip { padding:5px 14px; border-radius:20px; font-size:12px; font-weight:600; cursor:pointer; border:1.5px solid var(--border-color); transition:all .15s; white-space:nowrap; background:var(--bg-elevated); color:var(--text-secondary); }
        .crm-chip:hover { border-color:#3B82F6; color:#3B82F6; }
        .crm-chip.active { background:#3B82F6; color:#fff; border-color:#3B82F6; }

        /* CRM List view */
        .crm-table-wrap { background:var(--bg-surface); border-radius:12px; border:1px solid var(--border-color); overflow:hidden; overflow-x:auto; box-shadow:var(--shadow-card); }
        .crm-list-table { width:100%; border-collapse:collapse; }
        .crm-list-table th { text-align:right; padding:12px 16px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-secondary); border-bottom:2px solid var(--border-color); background:var(--bg-elevated); white-space:nowrap; }
        .crm-list-table td { padding:12px 16px; font-size:14px; color:var(--text-primary); border-bottom:1px solid var(--border-color); vertical-align:middle; }
        .crm-list-table tr:last-child td { border-bottom:none; }
        .crm-list-table tr:hover td { background:var(--bg-hover); transition: background 0.15s; }
        .crm-list-table tr.selected td { background:rgba(59,130,246,.08); }

        /* CRM Bulk actions bar */
        .crm-bulk-bar { display:flex; align-items:center; gap:10px; padding:12px 16px; background:rgba(59,130,246,.08); border:1.5px solid #3B82F6; border-radius:12px; flex-wrap:wrap; }
        .crm-bulk-label { font-size:13px; font-weight:600; color:#3B82F6; flex:1; min-width:80px; }

        /* CRM Search */
        .crm-search-wrap { position:relative; flex:1; min-width:200px; max-width:300px; }
        .crm-search-input { width:100%; background:var(--bg-elevated); border:1px solid var(--border-color); color:var(--text-primary); border-radius:10px; padding:10px 12px 10px 36px; font-size:14px; font-family:inherit; outline:none; box-sizing:border-box; transition: border-color 0.2s, box-shadow 0.2s; }
        .crm-search-input:focus { border-color:var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
        .crm-search-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--text-muted); font-size:15px; pointer-events:none; }

        /* Inline status select for table rows */
        .crm-status-select { background:var(--bg-elevated); border:1px solid var(--border-color); color:var(--text-primary); border-radius:7px; padding:3px 6px; font-size:11px; font-family:inherit; cursor:pointer; outline:none; }

        /* Lead Drawer */
        .lead-drawer-overlay { position:fixed; inset:0; background:var(--overlay-bg); z-index:3000; display:flex; justify-content:flex-start; backdrop-filter: blur(2px); }
        .lead-drawer { position:relative; width:440px; max-width:100vw; height:100%; background:var(--bg-surface); border-right:1px solid var(--border-color); overflow-y:auto; display:flex; flex-direction:column; box-shadow:8px 0 40px rgba(0,0,0,.35); animation:drawerIn .25s cubic-bezier(0.4,0,0.2,1); }
        @keyframes drawerIn { from{transform:translateX(-100%)} to{transform:translateX(0)} }
        .lead-drawer-header { padding:20px 20px 16px; border-bottom:1px solid var(--border-color); position:sticky; top:0; background:var(--bg-surface); z-index:1; }
        .lead-drawer-body { padding:20px; flex:1; display:flex; flex-direction:column; gap:16px; }
        .lead-drawer-section { background:var(--bg-elevated); border-radius:12px; padding:16px; border:1px solid var(--border-color); }
        .lead-drawer-section-title { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--text-secondary); margin-bottom:10px; display:flex; align-items:center; justify-content:space-between; }
        .lead-field-row { display:flex; align-items:center; gap:8px; margin-bottom:8px; }
        .lead-field-label { font-size:11px; font-weight:600; color:var(--text-secondary); width:76px; flex-shrink:0; }
        .lead-field-value { flex:1; font-size:13px; color:var(--text-primary); }
        .crm-notes-area { width:100%; min-height:90px; background:var(--bg-elevated); border:1px solid var(--border-input); color:var(--text-primary); border-radius:8px; padding:10px 14px; font-size:14px; font-family:inherit; outline:none; box-sizing:border-box; resize:vertical; transition: border-color 0.2s, box-shadow 0.2s; }
        .crm-notes-area:focus { border-color:var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
        .crm-dynamic-field-row { display:flex; align-items:center; gap:6px; margin-bottom:6px; }
        .crm-dynamic-label { font-size:11px; font-weight:600; color:var(--text-secondary); min-width:70px; }
        .crm-dynamic-value { flex:1; font-size:12px; color:var(--text-primary); background:transparent; border:none; outline:none; border-bottom:1px solid var(--border-color); padding:2px 4px; font-family:inherit; }
        .crm-dynamic-value:focus { border-bottom-color:#6366f1; }

        /* View toggle button pair */
        .crm-view-toggle { display:flex; border-radius:9px; overflow:hidden; border:1px solid var(--border-color); flex-shrink:0; }
        .crm-view-btn { padding:7px 13px; border:none; cursor:pointer; font-size:12px; font-weight:600; font-family:inherit; display:flex; align-items:center; gap:5px; transition:background .15s,color .15s; }
        .crm-view-btn.active { background:#3B82F6; color:#fff; }
        .crm-view-btn:not(.active) { background:var(--bg-surface); color:var(--text-secondary); }

        .flow-choice-pill.fallback-pill { border-color: #d1d5db; color: #6b7280; background: #f9fafb; font-style: italic; }

        /* Custom tooltip for condition help icon */
        .condition-help-wrapper { position: relative; display: inline-block; margin-right: 8px; cursor: help; vertical-align: middle; }
        .condition-help-wrapper .custom-tooltip { visibility: hidden; opacity: 0; background-color: #111b21; color: #fff; text-align: right; border-radius: 6px; padding: 10px; position: absolute; z-index: 1000; width: 220px; top: 120%; right: 50%; transform: translateX(50%); font-size: 13px; line-height: 1.5; transition: opacity 0.2s; pointer-events: none; box-shadow: 0 4px 20px rgba(0,0,0,0.4); }
        .condition-help-wrapper:hover .custom-tooltip { visibility: visible; opacity: 1; }

        /* Target-selection mode */
        #canvas-container.is-selecting-target { cursor: crosshair !important; }
        #canvas-container.is-selecting-target .flow-node { cursor: pointer !important; transition: box-shadow 0.15s, transform 0.15s; }
        #canvas-container.is-selecting-target .flow-node:hover { box-shadow: 0 0 0 4px #0d9488 !important; transform: scale(1.02); }
        #canvas-container.is-selecting-target .flow-node.is-active-jump { box-shadow: 0 0 0 4px #ef4444 !important; opacity: 0.5; cursor: not-allowed !important; }
        .btn-select-target { width:100%; margin-top:8px; padding:8px 12px; border:2px solid #0d9488; background:#f0fdfa; color:#0d9488; border-radius:8px; font-size:12px; font-weight:700; cursor:pointer; font-family:inherit; display:flex; align-items:center; justify-content:center; gap:6px; transition: all 0.15s; }
        .btn-select-target:hover { background:#ccfbf1; }
        .btn-select-target.active { background:#0d9488; color:#fff; border-color:#0f766e; animation: pulse-teal 1.2s infinite; }
        @keyframes pulse-teal { 0%,100%{box-shadow:0 0 0 0 rgba(13,148,136,.4)} 50%{box-shadow:0 0 0 6px rgba(13,148,136,0)} }

        /* Node Body */
        .node-body {
            padding: 10px 12px 12px 12px;
            background: #ffffff;
            border-radius: 0 0 12px 12px;
        }

        .node-preview-text {
            font-size: 12px;
            color: #64748b;
            line-height: 1.55;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            line-clamp: 2;
            -webkit-box-orient: vertical;
        }

        .node-meta-row {
            display: flex; align-items: center; gap: 5px;
            margin-top: 7px; flex-wrap: wrap;
        }

        .node-meta-chip {
            background: #f1f5f9; padding: 2px 7px;
            border-radius: 20px; font-size: 10px;
            font-weight: 600; color: #64748b;
        }

        .node-buttons-preview {
            display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px;
        }

        .node-btn-chip {
            background: #f1f5f9; border: 1px solid #e2e8f0;
            padding: 2px 7px; border-radius: 6px; font-size: 10px;
            color: #64748b; max-width: 90px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        }

        .node-start-badge {
            display: inline-flex; align-items: center; gap: 4px;
            background: #d1fae5; color: #059669; font-size: 10px;
            font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-bottom: 5px;
        }

        /* Connector between nodes */
        .flow-connector {
            display: flex; flex-direction: column;
            align-items: center; position: relative;
            z-index: 5; height: 54px; flex-shrink: 0; width: 300px;
        }

        .connector-line {
            width: 2px; flex: 1; background: #cbd5e1;
        }

        /* Inline Add Button */
        .add-inline-btn {
            position: absolute; top: 50%;
            transform: translateY(-50%);
            width: 26px; height: 26px; border-radius: 50%;
            background: white; border: 2px solid #cbd5e1;
            color: #94a3b8; font-size: 17px; font-weight: 400;
            cursor: pointer; display: flex;
            align-items: center; justify-content: center;
            transition: all 0.18s; z-index: 10; line-height: 1;
        }

        .add-inline-btn:hover {
            background: #3B82F6; border-color: #3B82F6;
            color: white; transform: translateY(-50%) scale(1.18);
            box-shadow: 0 2px 10px rgba(59,130,246,0.4);
        }

        /* Inline Add Dropdown */
        .add-inline-dropdown {
            position: absolute; top: 50%; left: 50%;
            transform: translate(-50%, -50%) translateY(14px);
            background: white; border: 1px solid #e2e8f0;
            border-radius: 12px;
            box-shadow: 0 8px 28px rgba(0,0,0,0.14);
            padding: 6px; z-index: 200; min-width: 176px;
            opacity: 0; pointer-events: none;
            transition: opacity 0.15s, transform 0.15s;
        }

        .add-inline-dropdown.open {
            opacity: 1; pointer-events: all;
            transform: translate(-50%, -50%) translateY(0);
        }

        .add-dropdown-item {
            display: flex; align-items: center; gap: 9px;
            padding: 8px 10px; border-radius: 8px;
            cursor: pointer; font-size: 12px; font-weight: 600;
            color: #334155; transition: background 0.12s;
            border: none; background: transparent;
            width: 100%; text-align: right; font-family: inherit;
        }

        .add-dropdown-item:hover { background: #f1f5f9; }

        .add-dropdown-icon {
            width: 26px; height: 26px; border-radius: 7px;
            display: flex; align-items: center; justify-content: center;
            color: white; font-size: 12px; flex-shrink: 0;
        }

        /* === FLOW BRANCHING === */
        .flow-branch-wrapper {
            display: flex;
            gap: 20px;
            justify-content: center;
            align-items: flex-start;
            position: relative;
            padding-top: 20px;
        }

        /* Horizontal bar connecting all branch tops */
        .flow-branch-wrapper::before {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            width: calc(100% - 80px);
            min-width: 40px;
            height: 2px;
            background: #cbd5e1;
        }

        .flow-branch-column {
            display: flex;
            flex-direction: column;
            align-items: center;
            position: relative;
            flex-shrink: 0;
        }

        /* Vertical stem from horizontal bar down to choice pill */
        .flow-branch-column::before {
            content: '';
            width: 2px;
            height: 20px;
            background: #cbd5e1;
            display: block;
        }

        .flow-choice-pill {
            background: #ffffff;
            border: 2px solid #a5b4fc;
            border-radius: 20px;
            padding: 3px 14px;
            font-size: 11px;
            font-weight: 700;
            color: #4f46e5;
            white-space: nowrap;
            box-shadow: 0 1px 6px rgba(99,102,241,0.13);
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .flow-choice-pill.yes-pill  { border-color: #86efac; color: #16a34a; }
        .flow-choice-pill.no-pill   { border-color: #fca5a5; color: #dc2626; }

        /* Property Panel (Drawer) */
        #flow-property-panel {
            position: absolute;
            top: 0; left: 0;
            width: 310px; height: 100%;
            background: white;
            border-right: 1px solid #e2e8f0;
            box-shadow: 4px 0 24px rgba(0,0,0,0.09);
            z-index: 50;
            transform: translateX(-100%);
            transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
            display: flex; flex-direction: column; overflow: hidden;
            border-radius: 0 12px 12px 0;
        }

        #flow-property-panel.open { transform: translateX(0); }

        .prop-panel-header {
            padding: 14px 16px;
            border-bottom: 1px solid #f1f5f9;
            display: flex; align-items: center; justify-content: space-between;
            flex-shrink: 0; background: #fafbfc;
        }

        .prop-panel-title {
            font-size: 13px; font-weight: 700; color: #1e293b;
            display: flex; align-items: center; gap: 7px;
        }

        .prop-panel-close {
            width: 27px; height: 27px; border-radius: 7px;
            border: 1px solid #e2e8f0; background: transparent;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 13px; color: #64748b; transition: all 0.14s;
        }
        .prop-panel-close:hover { background: #fee2e2; border-color: #fca5a5; color: #ef4444; }

        .prop-panel-body {
            flex: 1; overflow-y: auto; padding: 14px;
        }

        .prop-field { margin-bottom: 13px; }

        .prop-label {
            font-size: 10px; font-weight: 700; color: #64748b;
            text-transform: uppercase; letter-spacing: 0.05em;
            margin-bottom: 5px; display: block;
        }

        .prop-input {
            width: 100%; padding: 9px 12px;
            border: 1px solid #e2e8f0; border-radius: 8px;
            font-size: 13px; color: #334155; background: #f8fafc;
            outline: none; font-family: 'Heebo', 'Assistant', sans-serif;
            transition: border-color 0.2s, box-shadow 0.2s; resize: vertical;
        }
        .prop-input:focus {
            border-color: #3B82F6; background: white;
            box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
        }

        .prop-section {
            margin-bottom: 14px; padding: 11px 12px;
            background: #f8fafc; border-radius: 10px;
            border: 1px solid #f1f5f9;
        }

        .prop-section-title {
            font-size: 11px; font-weight: 700; color: #64748b;
            margin-bottom: 9px; display: flex; align-items: center; gap: 5px;
        }

        .var-btn {
            padding: 4px 9px; border-radius: 20px;
            border: 1px solid #c7d2fe; background: #eef2ff;
            color: #4f46e5; font-size: 11px; font-weight: 600;
            cursor: pointer; transition: all 0.13s;
            display: inline-flex; align-items: center; gap: 3px;
            font-family: inherit;
        }
        .var-btn:hover { background: #4f46e5; color: white; border-color: #4f46e5; }

        .prop-btn-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }

        .folder-card {
            background: var(--folder-card-bg);
            border: 1px solid var(--folder-card-border);
            border-radius: 12px;
            padding: 16px;
            transition: all 0.2s;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .folder-card:hover {
            border-color: #3B82F6;
            background: var(--folder-card-hover-bg);
        }

        .folder-active {
            border-color: #3B82F6 !important;
            background: rgba(59, 130, 246, 0.1) !important;
            box-shadow: inset 0 0 0 1px #3B82F6;
        }

        .selected-card {
            border-color: #3B82F6 !important;
            background-color: rgba(59, 130, 246, 0.1) !important;
        }

        /* === Toast Notifications === */
        #toast-container {
            position: fixed;
            top: 24px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 999999;
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
            align-items: center;
        }

        .toast {
            pointer-events: auto;
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 14px 18px;
            border-radius: 14px;
            font-size: 14px;
            font-weight: 600;
            min-width: 280px;
            max-width: 380px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
            animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
            backdrop-filter: blur(12px);
            border: 1px solid;
        }

        .toast.toast-success {
            background: rgba(16, 185, 129, 0.15);
            border-color: rgba(16, 185, 129, 0.4);
            color: #6ee7b7;
        }

        .toast.toast-error {
            background: rgba(239, 68, 68, 0.15);
            border-color: rgba(239, 68, 68, 0.4);
            color: #fca5a5;
        }

        .toast.toast-info {
            background: rgba(99, 102, 241, 0.15);
            border-color: rgba(99, 102, 241, 0.4);
            color: #a5b4fc;
        }

        .toast.toast-warning {
            background: rgba(245, 158, 11, 0.15);
            border-color: rgba(245, 158, 11, 0.4);
            color: #fcd34d;
        }

        .toast.toast-exit {
            animation: toastOut 0.3s ease forwards;
        }

        .toast-icon { font-size: 18px; flex-shrink: 0; }
        .toast-msg  { flex: 1; line-height: 1.4; }

        @keyframes toastIn {
            from { opacity: 0; transform: translateY(-14px) scale(0.95); }
            to   { opacity: 1; transform: translateY(0)     scale(1); }
        }

        @keyframes toastOut {
            from { opacity: 1; transform: translateY(0)     scale(1); }
            to   { opacity: 0; transform: translateY(-10px) scale(0.93); }
        }

        /* === Login Loading Overlay === */
        #login-loader {
            position: absolute;
            inset: 0;
            background: var(--overlay-bg);
            backdrop-filter: blur(6px);
            border-radius: inherit;
            z-index: 10;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 18px;
        }

        #login-loader.active { display: flex; }

        .login-spinner {
            width: 52px;
            height: 52px;
            border-radius: 50%;
            border: 3px solid rgba(59, 130, 246, 0.2);
            border-top-color: #3B82F6;
            animation: loginSpin 0.75s linear infinite;
        }

        .login-logo-pulse {
            animation: logoPulse 1.2s ease-in-out infinite;
        }

        @keyframes loginSpin  { to { transform: rotate(360deg); } }
        @keyframes logoPulse  {
            0%, 100% { opacity: 1; transform: scale(1); }
            50%       { opacity: 0.55; transform: scale(0.88); }
        }

        /* === Empty State === */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 56px 24px;
            gap: 14px;
            text-align: center;
        }

        .empty-state-icon {
            width: 72px;
            height: 72px;
            border-radius: 50%;
            background: rgba(99, 102, 241, 0.08);
            border: 1px solid rgba(99, 102, 241, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 30px;
            color: #6366f1;
            opacity: 0.75;
        }

        .empty-state-title {
            font-size: 15px;
            font-weight: 700;
            color: var(--text-secondary);
        }

        .empty-state-sub {
            font-size: 13px;
            color: var(--text-muted);
            max-width: 260px;
            line-height: 1.5;
        }

        /* =========================================
           INBOX / LIVE CHAT CRM TAB
           ========================================= */
        #view-inbox { padding: 0 !important; }

        .inbox-layout {
            display: flex;
            flex-direction: row;
            height: calc(100vh - 56px);
            overflow: hidden;
            border-radius: 1.5rem;
            border: 1px solid var(--inbox-border);
            box-shadow: 0 32px 64px -12px var(--shadow-color);
        }

        .inbox-list-col {
            width: 26%;
            min-width: 220px;
            background: var(--inbox-sidebar-bg);
            border-left: 1px solid var(--inbox-border);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            flex-shrink: 0;
        }

        .inbox-chat-col {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--inbox-chat-bg);
            overflow: hidden;
            min-width: 0;
        }

        .inbox-crm-col {
            width: 26%;
            min-width: 220px;
            background: var(--inbox-sidebar-bg);
            border-right: 1px solid var(--inbox-border);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            flex-shrink: 0;
        }

        .inbox-list-header {
            padding: 14px 16px 12px 16px;
            font-size: 17px;
            font-weight: 700;
            color: var(--inbox-list-header-color);
            background: var(--inbox-header-bg);
            border-bottom: 1px solid var(--inbox-border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-shrink: 0;
        }

        .inbox-search-wrap {
            padding: 8px 12px;
            background: var(--inbox-sidebar-bg);
            position: relative;
            flex-shrink: 0;
        }

        .inbox-search {
            background: var(--inbox-search-bg);
            border: none;
            border-radius: 8px;
            color: var(--msg-text-color);
            padding: 9px 12px 9px 36px;
            width: 100%;
            font-size: 13.5px;
            outline: none;
            font-family: 'Heebo', 'Assistant', sans-serif;
            box-sizing: border-box;
        }
        .inbox-search::placeholder { color: #8696a0; }

        .inbox-search-icon {
            position: absolute;
            left: 22px;
            top: 50%;
            transform: translateY(-50%);
            color: #8696a0;
            font-size: 15px;
            pointer-events: none;
        }

        .inbox-filter-chips {
            display: flex;
            gap: 4px;
            padding: 6px 8px;
            background: var(--inbox-sidebar-bg);
            border-bottom: 1px solid var(--inbox-border);
            flex-wrap: nowrap;
            overflow-x: auto;
            flex-shrink: 0;
        }
        .inbox-filter-chips::-webkit-scrollbar { height: 4px; }
        .inbox-filter-chips::-webkit-scrollbar-thumb { background: rgba(150,150,150,0.4); border-radius: 4px; }
        .inbox-filter-chips::-webkit-scrollbar-track { background: transparent; }

        .filter-chip {
            padding: 3px 8px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 500;
            cursor: pointer;
            border: 1px solid var(--filter-chip-border);
            background: transparent;
            color: var(--text-secondary);
            transition: all 0.2s;
            white-space: nowrap;
            font-family: 'Heebo', 'Assistant', sans-serif;
        }
        .filter-chip:hover { background: var(--filter-chip-hover-bg); color: var(--text-primary); }
        .filter-chip.active { background: #005c4b; border-color: #00a884; color: #e9edef; }

        .chat-list-scroller { flex: 1; overflow-y: auto; }

        .chat-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 11px 14px;
            cursor: pointer;
            border-bottom: 1px solid var(--inbox-border);
            transition: background 0.15s;
            position: relative;
        }
        .chat-item:hover  { background: var(--inbox-item-hover); }
        .chat-item.active { background: var(--inbox-item-active); }

        .chat-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-size: 15px;
            color: white;
        }

        .chat-item-info { flex: 1; min-width: 0; }
        .chat-item-name    { font-size: 14px; font-weight: 600; color: var(--chat-item-name-color); margin-bottom: 2px; }
        .chat-item-preview { font-size: 12px; color: var(--chat-item-preview-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .chat-item-meta    { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
        .chat-item-time    { font-size: 11px; color: var(--chat-item-time-color); }

        .unread-badge {
            background: #00a884;
            color: white;
            font-size: 10.5px;
            font-weight: 700;
            padding: 1px 6px;
            border-radius: 10px;
            min-width: 18px;
            text-align: center;
        }

        /* Chat Header */
        .inbox-chat-header {
            padding: 9px 14px;
            background: var(--inbox-input-area-bg);
            display: flex;
            align-items: center;
            gap: 10px;
            border-bottom: 1px solid var(--inbox-border);
            flex-shrink: 0;
        }
        .chat-header-info { flex: 1; min-width: 0; }
        .chat-header-name   { font-size: 15px; font-weight: 600; color: var(--chat-header-name-color); }
        .chat-header-status { font-size: 11.5px; color: var(--chat-header-status-color); }

        /* ── Chat Actions Dropdown ────────────────────────────────── */
        .inbox-chat-actions-wrap {
            position: relative;
            flex-shrink: 0;
        }
        .inbox-chat-actions-menu {
            position: fixed;
            background: var(--bg-secondary, #1e2532);
            border: 1px solid var(--border-color, rgba(255,255,255,0.08));
            border-radius: 10px;
            box-shadow: 0 8px 28px rgba(0,0,0,0.32);
            min-width: 210px;
            z-index: 9999;
            overflow: hidden;
            padding: 4px 0;
        }
        .chat-action-item {
            width: 100%;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 16px;
            border: none;
            background: transparent;
            color: var(--text-primary);
            font-size: 13.5px;
            font-family: 'Heebo', 'Assistant', sans-serif;
            cursor: pointer;
            text-align: right;
            direction: rtl;
            transition: background 0.15s;
        }
        .chat-action-item:hover { background: var(--inbox-action-btn-hover, rgba(255,255,255,0.06)); }
        .chat-action-item i { font-size: 16px; color: var(--text-secondary); flex-shrink: 0; }
        .chat-action-danger { color: #f87171 !important; }
        .chat-action-danger i { color: #f87171 !important; }
        .chat-action-danger:hover { background: rgba(248,113,113,0.1) !important; }
        .chat-action-divider { height: 1px; background: var(--border-color, rgba(255,255,255,0.08)); margin: 4px 0; }

        /* Mode Banner */
        .mode-banner {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 8px 16px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.25s;
            flex-shrink: 0;
            user-select: none;
            letter-spacing: 0.01em;
        }
        .mode-banner.bot { background: rgba(0,92,75,0.3); color: #25d366; border-bottom: 1px solid rgba(0,168,132,0.35); }
        .mode-banner.bot:hover { background: rgba(0,92,75,0.45); }
        .mode-banner.human { background: rgba(249,115,22,0.12); color: #f97316; border-bottom: 1px solid rgba(249,115,22,0.3); }
        .mode-banner.human:hover { background: rgba(249,115,22,0.22); }

        .mode-banner-dot {
            width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
        }
        .mode-banner.bot .mode-banner-dot { background: #25d366; animation: inbox-pulse 2s infinite; }
        .mode-banner.human .mode-banner-dot { background: #f97316; }
        @keyframes inbox-pulse {
            0%,100% { opacity:1; transform:scale(1); }
            50% { opacity:0.5; transform:scale(0.75); }
        }

        /* Messages Area */
        .inbox-messages-area {
            flex: 1;
            overflow-y: auto;
            padding: 12px 16px;
            display: flex;
            flex-direction: column;
            gap: 2px;
            background-color: var(--inbox-chat-bg);
            background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
            background-size: 400px;
        }

        .msg-row { display: flex; flex-direction: column; margin-bottom: 1px; }
        .msg-row.outgoing { align-items: flex-end; }
        .msg-row.incoming { align-items: flex-start; }

        .msg-bubble {
            max-width: 62%;
            padding: 6px 9px 18px 9px;
            border-radius: 7.5px;
            font-size: 13.8px;
            line-height: 19px;
            color: var(--msg-text-color);
            position: relative;
            box-shadow: 0 1px 0.5px rgba(11,20,26,.15);
            word-break: break-word;
        }
        .msg-bubble.incoming { background: var(--msg-incoming-bg); border-top-left-radius: 0; }
        .msg-bubble.outgoing { background: var(--msg-outgoing-bg); border-top-right-radius: 0; }

        /* Bubble tails */
        .msg-bubble.incoming::before {
            content: '';
            position: absolute;
            top: 0; left: -8px;
            border-right: 8px solid var(--msg-incoming-tail);
            border-bottom: 11px solid transparent;
        }
        .msg-bubble.outgoing::after {
            content: '';
            position: absolute;
            top: 0; right: -8px;
            border-left: 8px solid var(--msg-outgoing-tail);
            border-bottom: 11px solid transparent;
        }

        .msg-time {
            position: absolute;
            bottom: 4px;
            right: 7px;
            font-size: 10.5px;
            color: var(--msg-time-color);
            display: flex;
            align-items: center;
            gap: 2px;
            white-space: nowrap;
            background: none;
            border: none;
            padding: 0;
        }

        .msg-tick { font-size: 11px; line-height: 1; }
        .msg-tick--read { color: #34B7F1; }
        .msg-tick--gray { color: var(--msg-tick-gray); }

        .msg-date-sep {
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 8px 0;
        }
        .msg-date-sep span {
            background: var(--msg-date-sep-bg);
            color: var(--msg-date-sep-color);
            font-size: 11.5px;
            padding: 4px 12px;
            border-radius: 8px;
            box-shadow: 0 1px 0.5px rgba(11,20,26,.15);
        }

        /* --- Custom audio message player --- */

        /* Waveform bar mask — 32 rounded bars, variable heights, centered in 20px */
        :root {
            --waveform-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 192 20' preserveAspectRatio='none'%3E%3Crect x='0' y='7' width='2' height='6' rx='1'/%3E%3Crect x='6' y='4' width='2' height='12' rx='1'/%3E%3Crect x='12' y='1' width='2' height='18' rx='1'/%3E%3Crect x='18' y='4' width='2' height='12' rx='1'/%3E%3Crect x='24' y='6' width='2' height='8' rx='1'/%3E%3Crect x='30' y='3' width='2' height='14' rx='1'/%3E%3Crect x='36' y='5' width='2' height='10' rx='1'/%3E%3Crect x='42' y='1' width='2' height='18' rx='1'/%3E%3Crect x='48' y='7' width='2' height='6' rx='1'/%3E%3Crect x='54' y='5' width='2' height='10' rx='1'/%3E%3Crect x='60' y='2' width='2' height='16' rx='1'/%3E%3Crect x='66' y='6' width='2' height='8' rx='1'/%3E%3Crect x='72' y='3' width='2' height='14' rx='1'/%3E%3Crect x='78' y='1' width='2' height='18' rx='1'/%3E%3Crect x='84' y='5' width='2' height='10' rx='1'/%3E%3Crect x='90' y='7' width='2' height='6' rx='1'/%3E%3Crect x='96' y='4' width='2' height='12' rx='1'/%3E%3Crect x='102' y='2' width='2' height='16' rx='1'/%3E%3Crect x='108' y='6' width='2' height='8' rx='1'/%3E%3Crect x='114' y='3' width='2' height='14' rx='1'/%3E%3Crect x='120' y='1' width='2' height='18' rx='1'/%3E%3Crect x='126' y='5' width='2' height='10' rx='1'/%3E%3Crect x='132' y='7' width='2' height='6' rx='1'/%3E%3Crect x='138' y='3' width='2' height='14' rx='1'/%3E%3Crect x='144' y='5' width='2' height='10' rx='1'/%3E%3Crect x='150' y='1' width='2' height='18' rx='1'/%3E%3Crect x='156' y='6' width='2' height='8' rx='1'/%3E%3Crect x='162' y='4' width='2' height='12' rx='1'/%3E%3Crect x='168' y='7' width='2' height='6' rx='1'/%3E%3Crect x='174' y='2' width='2' height='16' rx='1'/%3E%3Crect x='180' y='5' width='2' height='10' rx='1'/%3E%3Crect x='186' y='3' width='2' height='14' rx='1'/%3E%3C/svg%3E");
        }

        .msg-bubble--audio {
            min-width: 240px;
        }

        /* === Message source tags (bot / crm / phone) === */
        .msg-source-tag {
            display: block;
            font-size: 10px;
            font-weight: 600;
            line-height: 1;
            padding: 2px 6px;
            border-radius: 10px;
            margin-bottom: 5px;
            opacity: 0.82;
            letter-spacing: 0.01em;
            width: fit-content;
        }
        .msg-source-bot {
            color: #25d366;
            background: rgba(37, 211, 102, 0.12);
        }
        .msg-source-crm {
            color: #818cf8;
            background: rgba(129, 140, 248, 0.12);
        }
        .msg-source-phone {
            color: #f59e0b;
            background: rgba(245, 158, 11, 0.12);
        }
        .msg-source-broadcast {
            color: #a855f7;
            background: rgba(168, 85, 247, 0.14);
        }
        /* Light / Cream theme overrides */
        [data-theme="light"] .msg-source-bot,
        [data-theme="cream"] .msg-source-bot  { color: #15803d; background: rgba(21,128,61,0.10); }
        [data-theme="light"] .msg-source-crm,
        [data-theme="cream"] .msg-source-crm  { color: #4f46e5; background: rgba(79,70,229,0.10); }
        [data-theme="light"] .msg-source-phone,
        [data-theme="cream"] .msg-source-phone { color: #b45309; background: rgba(180,83,9,0.10); }
        [data-theme="light"] .msg-source-broadcast,
        [data-theme="cream"] .msg-source-broadcast { color: #7c3aed; background: rgba(124,58,237,0.10); }

        /* === Template message with action buttons === */
        .msg-bubble--template {
            padding-bottom: 4px;
            overflow: hidden;
        }
        .msg-bubble--template .msg-time {
            position: relative;
            bottom: auto;
            right: auto;
            justify-content: flex-end;
            margin: 6px 0 4px 0;
        }
        .msg-template-buttons {
            margin: 0 -9px -4px -9px;
            border-top: 1px solid rgba(255, 255, 255, 0.10);
        }
        .msg-template-btn {
            text-align: center;
            padding: 9px 10px;
            font-size: 13px;
            font-weight: 500;
            color: #5bc4f4;
            cursor: default;
            border-top: 1px solid rgba(255, 255, 255, 0.07);
        }
        .msg-template-btn:first-child { border-top: none; }
        [data-theme="light"] .msg-template-buttons,
        [data-theme="cream"] .msg-template-buttons { border-top-color: rgba(0, 0, 0, 0.08); }
        [data-theme="light"] .msg-template-btn,
        [data-theme="cream"] .msg-template-btn { color: #0284c7; border-top-color: rgba(0, 0, 0, 0.06); }

        /* In-chat search highlight */
        mark.msg-highlight {
            background: rgba(255, 214, 0, 0.45);
            color: inherit;
            border-radius: 2px;
            padding: 0 1px;
        }
        [data-theme="dark"] mark.msg-highlight { background: rgba(255, 214, 0, 0.3); }
        mark.msg-highlight.active-highlight {
            background: rgba(255, 140, 0, 0.85);
            color: #fff;
            box-shadow: 0 0 0 2px rgba(255, 140, 0, 0.5);
            border-radius: 2px;
        }
        [data-theme="dark"] mark.msg-highlight.active-highlight { background: rgba(255, 160, 0, 0.9); }

        .msg-audio-wrap {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .msg-audio-src {
            display: none;
        }

        .msg-audio-ui {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 4px 0;
        }

        .msg-audio-play-btn {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            background: var(--audio-ui-bg);
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--audio-ui-color);
            font-size: 12px;
            flex-shrink: 0;
            transition: background 0.15s;
            padding: 0;
            outline: none;
        }

        .msg-audio-play-btn:hover {
            background: var(--audio-ui-bg-hover);
        }

        /* Waveform track — fills remaining row space */
        .msg-audio-track {
            flex: 1;
            position: relative;
            height: 20px;
            cursor: pointer;
            overflow: hidden;
            min-width: 0;
        }

        /* Gray unplayed bars */
        .msg-audio-track::before {
            content: '';
            position: absolute;
            inset: 0;
            background: var(--waveform-unplayed-color);
            -webkit-mask-image: var(--waveform-mask);
            mask-image: var(--waveform-mask);
            -webkit-mask-size: 100% 100%;
            mask-size: 100% 100%;
        }

        /* Blue played bars — same mask, clipped right-to-left by JS */
        .msg-audio-fill {
            position: absolute;
            inset: 0;
            background: #53bdeb;
            -webkit-mask-image: var(--waveform-mask);
            mask-image: var(--waveform-mask);
            -webkit-mask-size: 100% 100%;
            mask-size: 100% 100%;
            clip-path: inset(0 100% 0 0);
            pointer-events: none;
            z-index: 1;
        }

        /* Blue seek thumb */
        .msg-audio-thumb {
            position: absolute;
            top: 50%;
            left: calc(0% - 6px);
            transform: translateY(-50%);
            width: 12px;
            height: 12px;
            background: #53bdeb;
            border-radius: 50%;
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
            pointer-events: none;
            z-index: 2;
        }

        .msg-audio-time {
            font-size: 10.5px;
            color: var(--audio-ui-color);
            white-space: nowrap;
            line-height: 1;
            flex-shrink: 0;
            min-width: 26px;
            text-align: right;
        }

        .msg-audio-speed {
            font-size: 10px;
            font-weight: 700;
            color: var(--audio-ui-color);
            background: var(--audio-ui-bg);
            border: none;
            border-radius: 4px;
            padding: 2px 5px;
            cursor: pointer;
            outline: none;
            flex-shrink: 0;
            white-space: nowrap;
            transition: background 0.15s;
            line-height: 1.5;
        }

        .msg-audio-speed:hover {
            background: var(--audio-ui-bg-hover);
        }

        .msg-transcription {
            font-size: 11.5px;
            color: rgba(134, 150, 160, 0.9);
            font-style: italic;
            line-height: 16px;
            padding-bottom: 2px;
        }

        /* Input Area */
        .inbox-input-area {
            padding: 8px 10px;
            background: var(--inbox-input-area-bg);
            display: flex;
            align-items: flex-end;
            gap: 6px;
            border-top: 1px solid var(--inbox-border);
            flex-shrink: 0;
        }
        /* Back button: hidden on desktop, shown via mobile media query */
        .inbox-back-btn {
            display: none;
            align-items: center; justify-content: center;
            width: 36px; height: 36px;
            border-radius: 50%; border: none;
            background: transparent;
            color: var(--chat-header-name-color);
            cursor: pointer;
            flex-shrink: 0;
            transition: background 0.2s;
        }
        .inbox-back-btn:hover { background: var(--inbox-action-btn-hover); }

        /* CRM toggle button (info icon in chat header): hidden on desktop */
        .inbox-crm-toggle-btn { display: none !important; }

        /* CRM panel close button: hidden on desktop */
        .inbox-crm-close-btn {
            display: none;
            align-items: center; justify-content: center;
            width: 28px; height: 28px;
            border-radius: 50%; border: none;
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            flex-shrink: 0;
            transition: background 0.2s;
        }
        .inbox-crm-close-btn:hover { background: var(--inbox-action-btn-hover); }

        /* Mobile CRM backdrop: invisible on desktop */
        .inbox-crm-backdrop { display: none; }

        .inbox-action-btn {
            width: 38px; height: 38px;
            border-radius: 50%;
            border: none;
            background: transparent;
            color: #8696a0;
            cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 19px;
            transition: all 0.2s;
            flex-shrink: 0;
        }
        .inbox-action-btn:hover { background: var(--inbox-action-btn-hover); color: var(--msg-text-color); }
        .inbox-magic-btn {
            height: 36px;
            border: 1px solid rgba(167,139,250,0.35);
            border-radius: 8px;
            background: rgba(167,139,250,0.1);
            color: #a78bfa;
            cursor: pointer;
            display: flex; align-items: center; gap: 5px;
            padding: 0 10px;
            font-size: 12px; font-weight: 600;
            transition: all 0.2s;
            flex-shrink: 0;
            font-family: 'Heebo', 'Assistant', sans-serif;
            white-space: nowrap;
        }
        .inbox-magic-btn:hover { background: rgba(167,139,250,0.2); color: #c4b5fd; }
        .inbox-text-input {
            flex: 1;
            background: var(--inbox-text-input-bg);
            border: none; border-radius: 8px;
            color: var(--msg-text-color);
            padding: 9px 13px;
            font-size: 13.5px;
            outline: none; resize: none;
            font-family: 'Heebo', 'Assistant', sans-serif;
            line-height: 1.5;
            max-height: 120px;
            overflow-y: auto;
            min-width: 0;
        }
        .inbox-text-input::placeholder { color: #8696a0; }
        .inbox-send-btn {
            width: 42px; height: 42px; border-radius: 50%;
            border: none; background: #00a884; color: white;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 19px; transition: all 0.2s; flex-shrink: 0;
        }
        .inbox-send-btn:hover { background: #06cf9c; transform: scale(1.06); }

        /* Mic Button — visible when textarea is empty */
        .inbox-mic-btn {
            width: 42px; height: 42px; border-radius: 50%;
            border: none; background: #00a884; color: white;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 20px; transition: all 0.2s; flex-shrink: 0;
        }
        .inbox-mic-btn:hover { background: #06cf9c; transform: scale(1.06); }

        /* ── 24-Hour Window Warning Banner ────────── */
        .inbox-24h-banner {
            display: none;
            flex-direction: column;
            gap: 8px;
            padding: 10px 14px;
            background: rgba(251,191,36,0.08);
            border-top: 1px solid rgba(251,191,36,0.28);
            flex-shrink: 0;
        }
        .inbox-24h-banner-text {
            color: #fbbf24;
            font-size: 12.5px;
            line-height: 1.55;
            direction: rtl;
            text-align: right;
            display: flex;
            gap: 7px;
            align-items: flex-start;
        }
        .inbox-24h-banner-text i { flex-shrink: 0; font-size: 15px; margin-top: 1px; }
        .inbox-24h-template-btn {
            align-self: flex-end;
            padding: 6px 14px;
            border-radius: 7px;
            border: 1px solid rgba(251,191,36,0.45);
            background: rgba(251,191,36,0.13);
            color: #fbbf24;
            font-size: 12px; font-weight: 700;
            cursor: pointer;
            font-family: 'Heebo', 'Assistant', sans-serif;
            transition: all 0.2s;
        }
        .inbox-24h-template-btn:hover { background: rgba(251,191,36,0.24); color: #fde68a; }
        .inbox-input-disabled .inbox-text-input { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
        .inbox-input-disabled .inbox-mic-btn,
        .inbox-input-disabled .inbox-send-btn,
        .inbox-input-disabled .inbox-magic-btn { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

        /* ── Recording Area ───────────────────────── */
        .inbox-recording-area {
            padding: 8px 12px;
            background: var(--inbox-input-area-bg);
            display: flex;
            align-items: center;
            gap: 10px;
            border-top: 1px solid var(--inbox-border);
            flex-shrink: 0;
            min-height: 58px;
        }
        .inbox-rec-cancel-btn {
            width: 40px; height: 40px; border-radius: 50%;
            border: none; background: rgba(239,68,68,0.12); color: #f87171;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 17px; transition: all 0.2s; flex-shrink: 0;
        }
        .inbox-rec-cancel-btn:hover { background: rgba(239,68,68,0.22); color: #ef4444; }
        .inbox-rec-info {
            display: flex; align-items: center; gap: 7px; flex-shrink: 0;
        }
        .inbox-rec-dot {
            width: 9px; height: 9px; border-radius: 50%;
            background: #ef4444;
            animation: recDotBlink 1.1s ease-in-out infinite;
        }
        @keyframes recDotBlink {
            0%, 100% { opacity: 1; transform: scale(1); }
            50% { opacity: 0.25; transform: scale(0.85); }
        }
        .inbox-rec-timer {
            font-size: 14px; font-weight: 600;
            color: var(--msg-text-color);
            font-family: 'Heebo', 'Assistant', monospace;
            min-width: 36px; letter-spacing: 0.5px;
        }
        .inbox-rec-waveform {
            flex: 1;
            display: flex; align-items: center; justify-content: center; gap: 2.5px;
            height: 34px; overflow: hidden;
        }
        .inbox-rec-waveform-bar {
            width: 3px; border-radius: 3px;
            background: #00a884;
            animation: waveBarPulse 0.7s ease-in-out infinite alternate;
            transform-origin: center bottom;
        }
        @keyframes waveBarPulse {
            from { transform: scaleY(0.18); opacity: 0.6; }
            to   { transform: scaleY(1);    opacity: 1; }
        }
        .inbox-rec-send-btn {
            width: 42px; height: 42px; border-radius: 50%;
            border: none; background: #00a884; color: white;
            cursor: pointer; display: flex; align-items: center; justify-content: center;
            font-size: 19px; transition: all 0.2s; flex-shrink: 0;
        }
        .inbox-rec-send-btn:hover { background: #06cf9c; transform: scale(1.06); }

        /* ── Emoji Picker Popup ───────────────────── */
        .inbox-emoji-picker-popup {
            position: fixed;
            z-index: 600;
            border-radius: 14px;
            overflow: hidden;
            box-shadow: 0 12px 40px rgba(0,0,0,0.45);
            animation: emojiPopIn 0.15s ease;
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            width: 312px;
        }
        /* Template builder picker must clear the app header, sidebar stacking contexts,
           and any backdrop-filter ancestors that trap fixed children */
        #tpl-emoji-picker-popup {
            position: fixed !important;
            z-index: 99999 !important;
            background: var(--bg-surface) !important;
        }
        @keyframes emojiPopIn {
            from { opacity: 0; transform: scale(0.92) translateY(6px); }
            to   { opacity: 1; transform: scale(1) translateY(0); }
        }
        .inbox-emoji-grid {
            display: grid;
            grid-template-columns: repeat(8, 1fr);
            gap: 1px;
            padding: 8px;
            max-height: 320px;
            overflow-y: auto;
        }
        .inbox-emoji-grid button {
            background: none;
            border: none;
            font-size: 20px;
            cursor: pointer;
            border-radius: 6px;
            width: 34px;
            height: 34px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: background 0.1s;
            line-height: 1;
            padding: 0;
        }
        .inbox-emoji-grid button:hover { background: rgba(0,168,132,0.18); }

        /* ── Templates & Flows Modal ─────────────── */
        .itf-modal-card {
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 24px;
            width: 100%; max-width: 480px;
            margin: 16px;
            max-height: 88vh; overflow-y: auto;
            box-shadow: 0 24px 64px rgba(0,0,0,0.5);
            display: flex; flex-direction: column; gap: 18px;
        }
        .itf-modal-header {
            display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
        }
        .itf-modal-icon {
            width: 38px; height: 38px; border-radius: 50%;
            background: rgba(234,179,8,0.15);
            display: flex; align-items: center; justify-content: center;
            flex-shrink: 0;
            font-size: 18px; color: #eab308;
        }
        .itf-modal-title {
            font-size: 15px; font-weight: 700;
            color: var(--text-primary); margin: 0 0 2px 0;
        }
        .itf-modal-subtitle {
            font-size: 11px; color: var(--text-secondary); margin: 0;
        }
        .itf-close-btn {
            width: 32px; height: 32px; border-radius: 8px;
            border: none; background: var(--bg-elevated);
            color: var(--text-secondary); cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 15px; transition: all 0.2s; flex-shrink: 0;
        }
        .itf-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
        .itf-field-group { display: flex; flex-direction: column; gap: 8px; }
        .itf-label {
            font-size: 11px; font-weight: 700;
            color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
        }
        .itf-label-note {
            font-weight: 400; text-transform: none; font-size: 11px;
            color: var(--text-secondary); letter-spacing: 0;
        }
        .itf-select {
            width: 100%;
            background: var(--bg-input);
            border: 1px solid var(--border-input);
            border-radius: 10px;
            padding: 10px 12px;
            font-size: 13px; color: var(--text-primary);
            outline: none; cursor: pointer;
            font-family: 'Heebo', 'Assistant', sans-serif;
            transition: border-color 0.2s;
        }
        .itf-select:focus { border-color: #00a884; }
        .itf-var-input {
            width: 100%; box-sizing: border-box;
            background: var(--bg-input);
            border: 1px solid var(--border-input);
            border-radius: 8px;
            padding: 8px 12px;
            font-size: 13px; color: var(--text-primary);
            outline: none;
            font-family: 'Heebo', 'Assistant', sans-serif;
            transition: border-color 0.2s;
            margin-bottom: 6px;
        }
        .itf-var-input:last-child { margin-bottom: 0; }
        .itf-var-input:focus { border-color: #00a884; }
        .itf-preview-shell {
            background: var(--inbox-chat-bg);
            border-radius: 12px;
            padding: 14px 22px 14px 14px;
            min-height: 60px;
            display: flex; align-items: flex-end; justify-content: flex-end;
            overflow: visible;
        }
        .itf-actions {
            display: flex; gap: 10px; padding-top: 4px;
        }
        .itf-btn-cancel {
            flex: none; padding: 10px 20px; border-radius: 10px;
            border: 1px solid var(--border-color);
            background: transparent;
            color: var(--text-secondary);
            font-size: 13px; font-weight: 600;
            cursor: pointer; font-family: 'Heebo', 'Assistant', sans-serif;
            transition: all 0.2s;
        }
        .itf-btn-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }
        .itf-btn-send {
            flex: 1; padding: 10px 20px; border-radius: 10px;
            border: none; background: #00a884; color: white;
            font-size: 13px; font-weight: 700;
            cursor: pointer; font-family: 'Heebo', 'Assistant', sans-serif;
            transition: all 0.2s;
            display: flex; align-items: center; justify-content: center; gap: 8px;
        }
        .itf-btn-send:hover:not(:disabled) { background: #06cf9c; }
        .itf-btn-send:disabled { opacity: 0.45; cursor: not-allowed; }
        .itf-preview-buttons {
            display: flex; flex-wrap: wrap; gap: 6px;
            margin-top: 10px; justify-content: center;
        }
        .itf-preview-btn {
            border: 1.5px solid #00a884; background: transparent; color: #00a884;
            border-radius: 20px; padding: 5px 14px; font-size: 12px;
            font-family: 'Heebo', 'Assistant', sans-serif; cursor: default; white-space: nowrap;
        }
        /* Flow Steps Preview */
        .itf-flow-steps {
            background: var(--inbox-chat-bg);
            border-radius: 12px;
            padding: 12px 14px;
            display: flex; flex-direction: column; gap: 0;
        }
        .itf-flow-steps-header {
            font-size: 10px; font-weight: 700;
            color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
            margin-bottom: 10px;
            display: flex; align-items: center; gap: 5px;
        }
        .itf-flow-path {
            display: flex; flex-direction: column; gap: 4px;
            padding: 8px 0;
            border-top: 1px solid var(--border-color);
        }
        .itf-flow-path:first-of-type { border-top: none; padding-top: 0; }
        .itf-flow-bubble-in {
            align-self: flex-start;
            background: var(--bg-elevated);
            color: var(--text-primary);
            border-radius: 12px 12px 12px 2px;
            padding: 6px 10px; font-size: 12px;
            max-width: 85%; line-height: 1.4;
        }
        .itf-flow-bubble-out {
            align-self: flex-end;
            background: #005c4b;
            color: #e9edef;
            border-radius: 12px 12px 2px 12px;
            padding: 6px 10px; font-size: 12px;
            max-width: 85%; line-height: 1.4;
        }
        .itf-flow-bubble-end {
            align-self: center;
            color: var(--text-muted);
            font-size: 11px; font-style: italic;
            padding: 2px 8px;
        }
        .itf-flow-bubble-fallback { font-style: italic; opacity: 0.7; }
        /* Eye button + select row */
        .itf-flow-select-row {
            display: flex; align-items: center; gap: 8px;
        }
        .itf-flow-select-row .itf-select { flex: 1; }
        .itf-flow-eye-btn {
            width: 40px; height: 40px; flex-shrink: 0;
            border-radius: 10px;
            border: 1px solid var(--border-input);
            background: var(--bg-elevated);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 17px; transition: all 0.2s;
        }
        .itf-flow-eye-btn:hover { background: rgba(99,102,241,0.15); color: #818cf8; border-color: #818cf8; }
        /* Full Flow Tree Modal */
        .ftree-modal-card {
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 24px;
            width: 100%; max-width: 660px;
            margin: 16px;
            max-height: 90vh;
            display: flex; flex-direction: column; gap: 16px;
            box-shadow: 0 24px 64px rgba(0,0,0,0.65);
        }
        .ftree-modal-content {
            overflow-y: auto; flex: 1;
            padding-right: 2px;
            display: flex; flex-direction: column; gap: 0;
        }
        /* Tree node types */
        .ftree-node {
            border-radius: 10px; padding: 10px 14px;
            margin-bottom: 6px; font-size: 13px;
        }
        .ftree-template { background: rgba(234,179,8,0.10);  border: 1px solid rgba(234,179,8,0.28); }
        .ftree-message  { background: rgba(0,168,132,0.09);  border: 1px solid rgba(0,168,132,0.25); }
        .ftree-ai       { background: rgba(124,58,237,0.10); border: 1px solid rgba(124,58,237,0.28); }
        .ftree-crm      { background: rgba(14,165,233,0.10); border: 1px solid rgba(14,165,233,0.28); }
        .ftree-node-header {
            font-size: 10px; font-weight: 700; text-transform: uppercase;
            letter-spacing: 0.06em; color: var(--text-muted);
            margin-bottom: 5px; display: flex; align-items: center; gap: 5px;
        }
        .ftree-node-body { color: var(--text-primary); line-height: 1.55; white-space: pre-wrap; }
        .ftree-node-btns { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
        .ftree-btn-pill {
            background: rgba(255,255,255,0.07); color: var(--text-secondary);
            border: 1px solid var(--border-color); border-radius: 20px;
            padding: 3px 10px; font-size: 11px;
        }
        /* Branches */
        .ftree-branches {
            margin-right: 18px;
            border-right: 2px solid var(--border-color);
            padding-right: 14px;
            margin-top: 2px;
            display: flex; flex-direction: column; gap: 6px;
        }
        .ftree-branch { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; }
        .ftree-branch:first-child { padding-top: 4px; }
        .ftree-branch-label {
            color: #00a884; font-size: 12px; font-weight: 600;
            padding: 3px 8px; border-radius: 6px;
            background: rgba(0,168,132,0.09);
            display: inline-flex; align-items: center; gap: 5px;
            align-self: flex-start;
        }
        .ftree-branch-fallback { color: #f59e0b; background: rgba(245,158,11,0.09); }
        .ftree-arrow { opacity: 0.65; }
        /* Sequential */
        .ftree-seq { margin-right: 18px; display: flex; flex-direction: column; gap: 0; }
        .ftree-seq-arrow {
            text-align: center; color: var(--text-muted);
            font-size: 18px; margin: 2px 0;
        }
        /* Terminal / utility */
        .ftree-end-node {
            color: var(--text-muted); font-size: 11px; font-style: italic;
            padding: 3px 6px; display: flex; align-items: center; gap: 5px;
        }
        .ftree-cycle {
            color: #f59e0b; font-size: 11px; font-style: italic;
            padding: 2px 6px; display: flex; align-items: center; gap: 5px;
        }
        .ftree-empty {
            color: var(--text-muted); font-size: 13px;
            text-align: center; padding: 30px 0;
        }

        /* CRM Panel */
        .inbox-crm-header {
            padding: 14px 16px 12px 16px;
            font-size: 15px; font-weight: 700; color: var(--inbox-list-header-color);
            background: var(--inbox-header-bg);
            border-bottom: 1px solid var(--inbox-border);
            display: flex; align-items: center; justify-content: space-between;
            flex-shrink: 0;
        }
        .inbox-crm-scroller {
            flex: 1; overflow-y: auto;
            padding: 14px 13px;
            display: flex; flex-direction: column; gap: 12px;
        }
        .crm-section {
            background: var(--crm-section-bg); border-radius: 11px;
            padding: 13px; border: 1px solid var(--crm-section-border);
        }
        .crm-section-title {
            font-size: 10.5px; font-weight: 700; letter-spacing: 0.09em;
            text-transform: uppercase; color: #8696a0;
            margin-bottom: 10px;
            display: flex; align-items: center; gap: 6px;
        }

        /* Tags */
        .tags-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
        .crm-tag {
            padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
            cursor: default; display: flex; align-items: center; gap: 4px;
        }
        .crm-tag .tag-x { cursor: pointer; opacity: 0.6; font-size: 10px; }
        .crm-tag .tag-x:hover { opacity: 1; }
        .add-tag-row { display: flex; gap: 5px; }
        .add-tag-input {
            flex: 1; background: var(--add-input-bg); border: 1px solid var(--crm-section-border); border-radius: 6px;
            color: var(--msg-text-color); padding: 6px 9px; font-size: 12px; outline: none;
            font-family: 'Heebo', 'Assistant', sans-serif;
        }
        .add-tag-input:focus { border-color: #00a884; }
        .add-tag-btn {
            background: #005c4b; border: none; border-radius: 6px; color: #e9edef;
            padding: 6px 10px; font-size: 12px; cursor: pointer;
            transition: background 0.2s; font-family: 'Heebo', 'Assistant', sans-serif;
        }
        .add-tag-btn:hover { background: #00a884; }

        /* Lead Score */
        .lead-score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
        .lead-score-num { font-size: 2rem; font-weight: 800; line-height: 1; }
        .lead-score-track { background: var(--lead-score-track); border-radius: 8px; height: 7px; overflow: hidden; }
        .lead-score-fill { height: 100%; border-radius: 8px; transition: width 0.6s cubic-bezier(.4,0,.2,1); }

        /* AI Lead Profiler */
        .ai-analyze-btn {
            display: inline-flex; align-items: center; gap: 4px;
            background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
            border: none; border-radius: 7px; color: #fff;
            padding: 5px 10px; font-size: 11px; font-weight: 700;
            cursor: pointer; transition: all 0.22s; font-family: 'Heebo', 'Assistant', sans-serif;
            white-space: nowrap; box-shadow: 0 2px 8px rgba(59,130,246,0.35);
            letter-spacing: 0.01em;
        }
        .ai-analyze-btn:hover:not(:disabled) {
            box-shadow: 0 4px 16px rgba(59,130,246,0.55); transform: translateY(-1px);
        }
        .ai-analyze-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }
        @keyframes ai-spin { to { transform: rotate(360deg); } }
        .ai-spin { display: inline-block; animation: ai-spin 0.75s linear infinite; }

        /* Temperature badge */
        .temp-badge {
            display: inline-flex; align-items: center; gap: 5px;
            padding: 3px 10px; border-radius: 20px;
            font-size: 11px; font-weight: 700; margin-top: 7px;
            border-width: 1px; border-style: solid;
        }
        .temp-badge-cold   { background: rgba(56,189,248,0.12); color: #38bdf8; border-color: rgba(56,189,248,0.3); }
        .temp-badge-warm   { background: rgba(249,115,22,0.12); color: #f97316; border-color: rgba(249,115,22,0.3); }
        .temp-badge-hot    { background: rgba(239,68,68,0.13);  color: #ef4444; border-color: rgba(239,68,68,0.3); }

        /* Sticky Notes */
        .sticky-note {
            background: #fef9c3; color: #713f12;
            padding: 10px 11px; border-radius: 3px; font-size: 12.5px; line-height: 1.5;
            box-shadow: 2px 3px 6px rgba(0,0,0,0.3), inset 0 -1px 0 rgba(0,0,0,0.08);
            border-top: 3px solid #fde047; margin-bottom: 8px;
        }
        .sticky-note-meta { font-size: 10px; color: #92400e; margin-top: 5px; display: flex; justify-content: space-between; }
        .add-note-area {
            width: 100%; background: var(--add-input-bg); border: 1px solid var(--crm-section-border); border-radius: 7px;
            color: var(--msg-text-color); padding: 8px 10px; font-size: 12.5px; outline: none; resize: none;
            font-family: 'Heebo', 'Assistant', sans-serif; margin-bottom: 6px; box-sizing: border-box;
        }
        .add-note-area:focus { border-color: #fde047; }

        /* CRM Appointment */
        .crm-appt {
            display: flex; align-items: center; gap: 8px; padding: 10px 12px;
            background: var(--bg-elevated); border-radius: 8px; margin-bottom: 6px;
            border-right: 3px solid #3B82F6;
        }

        /* Inbox Empty State */
        .inbox-empty-state {
            flex: 1; display: flex; flex-direction: column;
            align-items: center; justify-content: center;
            color: #8696a0; gap: 14px;
        }

        /* =========================================
           THEME SWITCHER COMPONENT
           ========================================= */
        .theme-switcher-wrap {
            display: flex;
            align-items: center;
            gap: 2px;
            background: var(--theme-btn-bg);
            padding: 4px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            backdrop-filter: blur(8px);
        }

        .theme-btn {
            width: 32px; height: 32px;
            border-radius: 8px;
            border: 1px solid transparent;
            display: flex; align-items: center; justify-content: center;
            font-size: 15px;
            cursor: pointer;
            color: var(--theme-btn-idle-color);
            background: transparent;
            font-family: inherit;
        }

        .theme-btn:hover {
            background: var(--bg-elevated);
            color: var(--text-primary);
        }

        .theme-btn.theme-btn-active {
            background: var(--theme-btn-active-bg);
            border-color: var(--theme-btn-active-border);
            color: var(--theme-btn-active-color);
        }

        /* =========================================
           TAILWIND UTILITY OVERRIDES
           ========================================= */
        [data-theme="light"] .bg-zinc-900,
        [data-theme="cream"] .bg-zinc-900 { background-color: var(--bg-base) !important; }

        [data-theme="light"] .bg-zinc-800,
        [data-theme="cream"] .bg-zinc-800 { background-color: var(--bg-elevated) !important; }

        [data-theme="light"] .bg-zinc-700,
        [data-theme="cream"] .bg-zinc-700 { background-color: var(--bg-hover) !important; }

        [data-theme="light"] .bg-slate-900,
        [data-theme="cream"] .bg-slate-900 { background-color: var(--bg-base) !important; }

        [data-theme="light"] .bg-slate-800,
        [data-theme="cream"] .bg-slate-800 { background-color: var(--bg-surface) !important; }

        [data-theme="light"] .bg-slate-700,
        [data-theme="cream"] .bg-slate-700 { background-color: var(--bg-hover) !important; }

        [data-theme="light"] .text-white,
        [data-theme="cream"] .text-white { color: var(--text-primary) !important; }

        [data-theme="light"] .text-zinc-100,
        [data-theme="cream"] .text-zinc-100 { color: var(--text-primary) !important; }

        [data-theme="light"] .text-zinc-200,
        [data-theme="cream"] .text-zinc-200 { color: var(--text-primary) !important; }

        [data-theme="light"] .text-zinc-300,
        [data-theme="cream"] .text-zinc-300 { color: var(--text-primary) !important; }

        [data-theme="light"] .text-zinc-400,
        [data-theme="cream"] .text-zinc-400 { color: var(--text-secondary) !important; }

        [data-theme="light"] .text-zinc-500,
        [data-theme="cream"] .text-zinc-500 { color: var(--text-muted) !important; }

        [data-theme="light"] .text-slate-100,
        [data-theme="cream"] .text-slate-100 { color: var(--text-primary) !important; }

        [data-theme="light"] .text-slate-200,
        [data-theme="cream"] .text-slate-200 { color: var(--text-primary) !important; }

        [data-theme="light"] .text-slate-300,
        [data-theme="cream"] .text-slate-300 { color: var(--text-primary) !important; }

        [data-theme="light"] .text-slate-400,
        [data-theme="cream"] .text-slate-400 { color: var(--text-secondary) !important; }

        [data-theme="light"] .text-slate-500,
        [data-theme="cream"] .text-slate-500 { color: var(--text-muted) !important; }

        [data-theme="light"] .border-zinc-800,
        [data-theme="cream"] .border-zinc-800 { border-color: var(--border-color) !important; }

        [data-theme="light"] .border-zinc-700,
        [data-theme="cream"] .border-zinc-700 { border-color: var(--border-color) !important; }

        [data-theme="light"] .border-slate-700,
        [data-theme="cream"] .border-slate-700 { border-color: var(--border-color) !important; }

        [data-theme="light"] .border-slate-600,
        [data-theme="cream"] .border-slate-600 { border-color: var(--border-color) !important; }

        /* Theme utility classes — use these on elements that must adapt to all three themes */
        .text-theme-text-primary  { color: var(--text-primary)  !important; }
        .text-theme-text-secondary { color: var(--text-secondary) !important; }
        .text-theme-muted         { color: var(--text-muted) !important; }
        .bg-theme-surface-1       { background-color: var(--bg-surface) !important; }
        .bg-theme-elevated        { background-color: var(--bg-elevated) !important; }

        /* Keep sidebar text light in cream mode (sidebar is always dark) */
        [data-theme="cream"] #sidebar .text-zinc-400 { color: var(--sidebar-text-muted) !important; }
        [data-theme="cream"] #sidebar .text-white { color: var(--sidebar-text) !important; }

        /* Light mode sidebar: ensure proper dark text on white background */
        [data-theme="light"] #sidebar .text-zinc-400 { color: var(--sidebar-text-muted) !important; }
        [data-theme="light"] #sidebar .text-white { color: var(--sidebar-text) !important; }

        /* ---- TEST FLOW PREVIEW ---- */
        .btn-preview-flow {
            background: rgba(99, 102, 241, 0.10);
            border: 1px solid rgba(99, 102, 241, 0.35);
            color: #a5b4fc;
            transition: all 0.2s;
        }
        .btn-preview-flow:hover {
            background: rgba(99, 102, 241, 0.22);
            border-color: rgba(99, 102, 241, 0.65);
            color: #c7d2fe;
            transform: translateY(-1px);
        }
        #test-flow-modal .modal-card {
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            padding: 28px 26px 24px;
            width: 100%;
            max-width: 370px;
            box-shadow: 0 24px 64px rgba(0,0,0,0.45);
            direction: rtl;
        }
        #test-flow-phone-input {
            direction: ltr;
            text-align: left;
            letter-spacing: 0.04em;
        }
        @keyframes ph-spin { to { transform: rotate(360deg); } }

        /* =========================================
           ACCOUNT HEALTH — QUALITY BADGE
           ========================================= */
        .quality-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 3px 10px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 700;
        }
        .quality-badge-green  { background: rgba(52,211,153,.15); color: #34d399; border: 1px solid rgba(52,211,153,.3); }
        .quality-badge-yellow { background: rgba(251,191,36,.12); color: #fbbf24; border: 1px solid rgba(251,191,36,.3); }
        .quality-badge-red    { background: rgba(239,68,68,.12);  color: #f87171; border: 1px solid rgba(239,68,68,.3); }
        .quality-badge-gray   { background: rgba(113,113,122,.12); color: #a1a1aa; border: 1px solid rgba(113,113,122,.3); }

        /* =========================================
           ACCOUNT HEALTH — TIER STEPPER
           ========================================= */
        .tier-stepper-wrap {
            overflow-x: auto;
            padding-bottom: 4px;
        }
        .tier-stepper {
            display: flex;
            align-items: center;
            gap: 0;
            min-width: max-content;
        }
        .tier-step {
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            padding: 7px 14px;
            border-radius: 10px;
            border: 1.5px solid #3f3f46;
            background: #18181b;
            color: #71717a;
            font-size: 11px;
            font-weight: 700;
            transition: all 0.25s;
            min-width: 76px;
            text-align: center;
        }
        .tier-step-passed {
            border-color: rgba(99,102,241,.4);
            background: rgba(99,102,241,.08);
            color: #a5b4fc;
        }
        .tier-step-active {
            border-color: #6366f1;
            background: rgba(99,102,241,.18);
            color: #e0e7ff;
            box-shadow: 0 0 0 3px rgba(99,102,241,.22), 0 4px 16px rgba(99,102,241,.25);
            transform: translateY(-2px);
        }
        .tier-step-dot {
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: #6366f1;
            animation: tier-pulse 1.6s infinite;
        }
        .tier-arrow {
            width: 20px;
            height: 2px;
            background: linear-gradient(90deg, #3f3f46, #52525b);
            flex-shrink: 0;
            position: relative;
        }
        .tier-arrow::after {
            content: '';
            position: absolute;
            left: -4px;
            top: -3px;
            border-right: 5px solid #52525b;
            border-top: 4px solid transparent;
            border-bottom: 4px solid transparent;
        }

        @keyframes tier-pulse {
            0%, 100% { opacity: 1; transform: scale(1); }
            50%       { opacity: .5; transform: scale(1.4); }
        }

        /* =========================================
           TIER UPGRADE CELEBRATION MODAL
           ========================================= */
        .tier-upgrade-glow {
            position: absolute;
            inset: 0;
            border-radius: inherit;
            background: radial-gradient(ellipse at 50% 0%, rgba(52,211,153,.18) 0%, transparent 70%);
            pointer-events: none;
        }
        .tier-upgrade-badge {
            display: inline-block;
            background: linear-gradient(135deg, rgba(52,211,153,.15), rgba(52,211,153,.05));
            border: 2px solid rgba(52,211,153,.35);
            border-radius: 16px;
            padding: 14px 28px;
            min-width: 140px;
        }

        /* confetti dots */
        .confetti-dot {
            position: absolute;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            animation: confetti-fall linear forwards;
        }
        @keyframes confetti-fall {
            0%   { transform: translateY(-20px) scale(0); opacity: 1; }
            60%  { opacity: 1; }
            100% { transform: translateY(120px) scale(1.2); opacity: 0; }
        }

        /* one-shot spin for refresh icon */
        @keyframes spin-once {
            from { transform: rotate(0deg); }
            to   { transform: rotate(360deg); }
        }
        .animate-spin-once { animation: spin-once 0.6s linear; }
        .ph-spin { display: inline-block; animation: ph-spin 0.75s linear infinite; }

        /* =========================================
           MOBILE — max-width: 767px
           ========================================= */
        @media (max-width: 767px) {

            /* ── Fix 1: Unlock global mobile scroll ──
               Remove the 100vh + overflow:hidden cage so non-inbox tabs
               can scroll naturally on the page body.              */
            #app-shell {
                height: auto !important;
                min-height: 100svh !important;
                overflow: visible !important;
            }
            #main-wrapper {
                height: auto !important;
                min-height: 0 !important;
                overflow: visible !important;
            }
            #app-content {
                flex: unset !important;
                overflow: visible !important;
                height: auto !important;
                min-height: calc(100svh - 56px) !important;
            }

            /* ── Fix 2: Inbox mobile layout ──
               The inbox uses position:fixed panels so it gets its own
               full-screen space below the fixed top header, independent
               of the unlocked page scroll above.                   */

            #app-content.inbox-mode {
                overflow: hidden !important;
                height: calc(100svh - 56px) !important;
                min-height: unset !important;
                padding: 0 !important;
                position: relative !important;
            }

            #view-inbox {
                height: 100% !important;
                overflow: hidden !important;
            }

            .inbox-layout {
                position: relative !important;
                display: block !important;
                height: 100% !important;
                overflow: hidden !important;
                border-radius: 0 !important;
                border: none !important;
            }

            /* ── List column: fills the inbox area, scrollable chat list ── */
            .inbox-list-col {
                position: absolute !important;
                inset: 0 !important;
                width: 100% !important;
                height: 100% !important;
                min-width: unset !important;
                display: flex !important;
                flex-direction: column !important;
                overflow: hidden !important;
                border-left: none !important;
                transition: transform 0.28s cubic-bezier(0.4,0,0.2,1) !important;
                z-index: 1 !important;
            }
            .chat-list-scroller {
                flex: 1 !important;
                overflow-y: auto !important;
                -webkit-overflow-scrolling: touch;
            }

            /* ── Chat column: slides in from left when a chat is opened ── */
            .inbox-chat-col {
                position: absolute !important;
                inset: 0 !important;
                width: 100% !important;
                height: 100% !important;
                min-width: unset !important;
                display: flex !important;
                flex-direction: column !important;
                overflow: hidden !important;
                transform: translateX(-100%) !important;
                transition: transform 0.28s cubic-bezier(0.4,0,0.2,1) !important;
                z-index: 2 !important;
            }

            /* ── When a chat is open: slide list out, slide chat in ── */
            .inbox-layout.mobile-chat-open .inbox-list-col {
                transform: translateX(100%) !important;
            }
            .inbox-layout.mobile-chat-open .inbox-chat-col {
                transform: translateX(0) !important;
            }

            /* ── Chat content fills the column ── */
            #inbox-chat-content {
                display: flex !important;
                flex-direction: column !important;
                flex: 1 !important;
                overflow: hidden !important;
                height: 100% !important;
                min-height: 0 !important;
            }

            /* ── Messages: flex-1 so they fill remaining space ── */
            .inbox-messages-area {
                flex: 1 !important;
                overflow-y: auto !important;
                overflow-x: hidden !important;
                -webkit-overflow-scrolling: touch;
                display: flex !important;
                flex-direction: column !important;
                gap: 2px !important;
                min-height: 0 !important;
                height: auto !important;
                max-height: unset !important;
                padding-bottom: 10px !important;
            }

            /* ── Input area: naturally at bottom of the flex column ── */
            .inbox-input-area,
            .inbox-recording-area {
                flex-shrink: 0 !important;
                position: sticky !important;
                bottom: 0 !important;
                width: 100% !important;
                box-sizing: border-box !important;
            }

            /* ── CRM panel: off-canvas slide-over drawer from the left ── */
            .inbox-crm-col {
                position: fixed !important;
                top: 56px !important;
                left: 0 !important;
                bottom: 0 !important;
                width: 88vw !important;
                max-width: 340px !important;
                height: auto !important;
                min-width: unset !important;
                display: flex !important;
                flex-direction: column !important;
                overflow: hidden !important;
                transform: translateX(-100%) !important;
                transition: transform 0.3s cubic-bezier(0.4,0,0.2,1) !important;
                z-index: 65 !important;
                box-shadow: 4px 0 32px rgba(0,0,0,0.45) !important;
                border-right: none !important;
                border: none !important;
            }
            .inbox-crm-col.crm-drawer-open {
                transform: translateX(0) !important;
            }

            /* Backdrop dims the chat when drawer is open */
            .inbox-crm-backdrop {
                display: none;
                position: fixed;
                top: 56px; left: 0; right: 0; bottom: 0;
                background: rgba(0,0,0,0.52);
                backdrop-filter: blur(1.5px);
                z-index: 64;
            }
            .inbox-crm-backdrop.active { display: block; }

            /* ── Mobile-only buttons ── */
            .inbox-crm-toggle-btn { display: flex !important; }
            .inbox-crm-close-btn  { display: flex !important; }

            /* ── Back button: visible only on mobile ── */
            .inbox-back-btn {
                display: flex !important;
            }

            /* ── Bubbles: slightly wider on mobile ── */
            .msg-bubble {
                max-width: 88% !important;
            }
        }

        /* =========================================
           MOBILE RESPONSIVE — max-width: 639px
           ========================================= */
        @media (max-width: 639px) {

            /* Prevent iOS from zooming into focused inputs */
            .input-dark,
            .crm-input,
            .crm-notes-area,
            select,
            textarea {
                font-size: 16px !important;
            }

            /* Generous touch targets for inputs */
            .input-dark,
            .crm-input {
                min-height: 44px;
                padding-top: 10px;
                padding-bottom: 10px;
            }

            /* Primary buttons: easier to tap */
            .btn-primary {
                min-height: 48px;
                font-size: 15px;
                padding-top: 12px;
                padding-bottom: 12px;
            }

            /* Reduce app-content padding on mobile (not when inbox is active) */
            #app-content:not(.inbox-mode) {
                padding: 12px;
            }

            /* Login / signup panel: less horizontal padding */
            #login-screen > div {
                padding: 28px 20px;
                margin: 0 12px;
            }

            /* Profile modal: full-width with tighter padding */
            #profile-modal > div {
                padding: 20px 16px;
                margin: 0 12px;
                border-radius: 20px;
                max-width: calc(100vw - 24px);
            }

            /* Admin edit modal */
            #admin-edit-modal > div {
                padding: 20px 16px;
                margin: 0 12px;
                border-radius: 20px;
                max-width: calc(100vw - 24px);
            }

            /* New appointment modal */
            #new-appt-modal > div {
                padding: 20px 16px;
                margin: 0 12px;
            }

            /* CRM modal */
            .crm-modal {
                padding: 20px 16px;
                margin: 0 12px;
            }

            /* Tab buttons: smaller padding */
            .tab-btn {
                padding: 8px 12px;
                font-size: 12px;
                gap: 5px;
            }

            /* Top header: tighter padding */
            #top-header {
                padding: 0 12px;
                gap: 8px;
            }

            /* Glass panels: reduce padding inside page cards */
            .glass-panel {
                padding: 16px !important;
            }

            /* Sidebar nav item touch area */
            .sidebar-nav-item {
                padding: 12px 12px;
                font-size: 14px;
            }

            /* Prevent tier stepper from overflowing */
            .tier-stepper-wrap {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }

            /* Lead drawer: full width on mobile */
            .lead-drawer {
                width: 100% !important;
                max-width: 100vw;
            }

            /* Flow sidebar: full width on mobile */
            #flow-sidebar {
                width: 100% !important;
            }

            /* Kanban columns: horizontal scroll */
            #kanban-board {
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
            }

            /* Impersonation banner: center on mobile */
            #impersonation-banner {
                left: 12px;
                right: 12px;
                transform: none;
                bottom: 12px;
            }

            /* Flow canvas toolbar: stack template select below back+save row */
            #flow-canvas-toolbar {
                flex-wrap: wrap;
                padding: 8px 10px;
                row-gap: 6px;
                column-gap: 6px;
            }
            /* Back + title group grows to push save buttons right */
            #flow-canvas-toolbar > div:first-child {
                flex: 1;
                min-width: 0;
            }
            #flow-canvas-toolbar > div:first-child h2 {
                font-size: 11px;
                overflow: hidden;
                text-overflow: ellipsis;
            }
            /* Template select drops to its own full-width row */
            #flow-canvas-toolbar > div:nth-child(2) {
                order: 10;
                flex: 0 0 100%;
                justify-content: flex-start;
            }
            #flow-canvas-toolbar > div:nth-child(2) select {
                width: 100%;
            }
            /* Compact save/preview buttons */
            #flow-canvas-toolbar > div:nth-child(3) {
                flex-shrink: 0;
            }
        }

        /* =========================================
           PREMIUM VISUAL OVERHAUL — LEE.CO.IL AESTHETIC
           Remove purple/indigo tints, enforce clean cards,
           high-contrast text, modern shadows.
           ========================================= */

        /* 1. Neutralize heavy indigo/purple panel backgrounds in all themes */
        .bg-indigo-950\/40 { background-color: var(--bg-elevated) !important; }
        .border-indigo-500\/30 { border-color: var(--border-color) !important; }

        /* 2. Top-header: clean, no tinted borders */
        #top-header {
            background: var(--bg-surface);
            border-bottom: 1px solid var(--border-color);
            box-shadow: 0 1px 0 var(--border-color);
        }

        /* 3. Light mode: override lingering zinc/slate dark backgrounds */
        [data-theme="light"] .bg-zinc-900\/60 { background-color: var(--bg-elevated) !important; }
        [data-theme="light"] .bg-zinc-900\/80 { background-color: var(--bg-input) !important; }
        [data-theme="light"] .bg-zinc-900\/50 { background-color: var(--bg-elevated) !important; }
        [data-theme="light"] .border-zinc-700\/80 { border-color: var(--border-input) !important; }
        [data-theme="light"] .border-zinc-700 { border-color: var(--border-input) !important; }
        [data-theme="light"] .bg-slate-800 { background-color: var(--bg-elevated) !important; }

        /* 4. Light mode: fix select/option inputs to white */
        [data-theme="light"] select.input-dark,
        [data-theme="light"] select[class*="input-dark"] {
            background-color: var(--bg-input) !important;
            color: var(--text-primary) !important;
        }

        /* 5. CRM & Settings table headers: clean light gray, no tint */
        [data-theme="light"] .crm-list-table th {
            background: #F8FAFC !important;
            color: var(--text-secondary) !important;
        }
        [data-theme="light"] .crm-list-table tr:hover td {
            background: #F1F5F9 !important;
        }

        /* 6. Kanban column clean up */
        [data-theme="light"] .kanban-column {
            box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04) !important;
        }

        /* 7. Lead drawer sections: no heavy tinted bg */
        [data-theme="light"] .lead-drawer-section {
            background: #F8FAFC !important;
            border-color: #E2E8F0 !important;
        }

        /* 8. Mobile sidebar overlay backdrop for light mode */
        [data-theme="light"] #mobile-sidebar-overlay {
            background: rgba(15, 23, 42, 0.4);
        }

        /* =========================================
           i18n — LANGUAGE TOGGLE BUTTON STYLES
           ========================================= */

        .lang-switcher-wrap {
            display: flex;
            align-items: center;
            gap: 2px;
            background: var(--bg-elevated, #1e293b);
            border: 1px solid var(--border-color, #1e293b);
            border-radius: 8px;
            padding: 2px;
        }

        .lang-toggle-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            min-width: 32px;
            height: 26px;
            padding: 0 8px;
            border-radius: 6px;
            border: none;
            background: transparent;
            color: var(--text-secondary, #94a3b8);
            font-size: 11px;
            font-weight: 700;
            cursor: pointer;
            transition: background 0.15s, color 0.15s;
            white-space: nowrap;
            font-family: inherit;
        }

        .lang-toggle-btn:hover {
            background: var(--bg-hover, #1e293b);
            color: var(--text-primary, #f8fafc);
        }

        .lang-toggle-btn.lang-btn-active {
            background: var(--accent, #3b82f6);
            color: #fff;
            box-shadow: 0 1px 4px rgba(59,130,246,0.35);
        }

        /* Login screen lang toggle — small, absolute corner */
        #login-screen .lang-switcher-wrap {
            position: absolute;
            top: 14px;
            inset-inline-end: 14px; /* right in LTR, left in RTL */
            right: 14px;            /* fallback for older browsers */
            margin: 0;
            z-index: 2;
            background: var(--bg-elevated, #1e293b);
            border-color: var(--border-input, #334155);
            border-radius: 8px;
            padding: 2px;
        }
        [dir="ltr"] #login-screen .lang-switcher-wrap {
            right: 14px;
            left: auto;
        }
        [dir="rtl"] #login-screen .lang-switcher-wrap {
            left: 14px;
            right: auto;
        }

        #login-screen .lang-toggle-btn {
            min-width: 34px;
            height: 26px;
            font-size: 11px;
            border-radius: 6px;
        }

        /* =========================================
           i18n — LTR LAYOUT OVERRIDES
           Sidebar flips to left, margins flip,
           active indicator moves to left side.
           ========================================= */

        /* ---- Sidebar position ---- */
        [dir="ltr"] #sidebar {
            right: auto;
            left: 0;
            border-left: none;
            border-right: 1px solid var(--sidebar-border);
        }

        /* ---- Main wrapper margin ---- */
        [dir="ltr"] #main-wrapper {
            margin-right: 0;
            margin-left: 260px;
        }

        [dir="ltr"] #app-shell.sidebar-collapsed #main-wrapper {
            margin-right: 0 !important;
            margin-left: 64px !important;
        }

        /* ---- Sidebar active indicator: move to left edge ---- */
        [dir="ltr"] .sidebar-nav-item.nav-active::after {
            right: auto;
            left: 0;
            border-radius: 3px 0 0 3px;
        }

        /* ---- Sidebar text alignment ---- */
        [dir="ltr"] .sidebar-nav-item {
            text-align: left;
        }

        [dir="ltr"] .sidebar-nav-label {
            text-align: left;
        }

        /* ---- Sidebar collapse button ---- */
        [dir="ltr"] .sidebar-collapse-btn {
            justify-content: flex-start;
        }

        [dir="ltr"] #app-shell.sidebar-collapsed .sidebar-collapse-btn {
            justify-content: center;
        }

        /* ---- Mobile sidebar: open from left ---- */
        @media (max-width: 1023px) {
            [dir="ltr"] #sidebar {
                transform: translateX(-100%);
                left: 0;
                right: auto;
            }

            [dir="ltr"] #sidebar.mobile-open {
                transform: translateX(0);
            }

            [dir="ltr"] #main-wrapper {
                margin-left: 0 !important;
            }
        }

        /* ---- Top header: reverse flex for LTR ---- */
        [dir="ltr"] #top-header {
            flex-direction: row;
        }

        /* ---- Workspace dropdown: align to right side in LTR ---- */
        [dir="ltr"] #workspace-dropdown {
            left: auto;
            right: 0;
        }

        /* ---- Input text direction ---- */
        [dir="ltr"] input,
        [dir="ltr"] textarea,
        [dir="ltr"] select {
            text-align: left;
            direction: ltr;
        }

        /* Keep centered login inputs centered in LTR too */
        [dir="ltr"] #login-screen input {
            text-align: center;
        }

        /* ---- Table headers ---- */
        [dir="ltr"] th {
            text-align: left !important;
        }

        /* ---- Flatpickr: restore LTR for date picker ---- */
        [dir="ltr"] .flatpickr-calendar {
            direction: ltr;
        }

        /* ---- Hub tabs bar ---- */
        [dir="ltr"] .hub-tabs-bar {
            direction: ltr;
        }

        /* ---- Sidebar icon flip fix: prevent Phosphor icons from being mirrored ---- */
        [dir="ltr"] .sidebar-nav-icon,
        [dir="ltr"] .ph,
        [dir="ltr"] .ph-fill {
            /* Icons themselves should not flip */
        }

        /* Toast uses left:50%+translateX(-50%) centering — direction-neutral, no LTR override needed */

        /* 9. Quick-var pills: use neutral blue, no indigo-900 bg in light mode */
        [data-theme="light"] .quick-var-pill {
            background: rgba(59,130,246,0.08) !important;
            border-color: rgba(59,130,246,0.3) !important;
            color: #2563EB !important;
        }
        [data-theme="light"] .quick-var-pill:hover {
            background: #2563EB !important;
            border-color: #2563EB !important;
            color: #FFFFFF !important;
        }

        /* 10. Sidebar admin special color: keep green, works on both dark/light */
        [data-theme="light"] .sidebar-nav-admin { color: #059669 !important; }
        [data-theme="light"] .sidebar-nav-admin.nav-active {
            background: rgba(5,150,105,0.08) !important;
            color: #059669 !important;
        }
        [data-theme="light"] .sidebar-nav-admin.nav-active::after { background: #10b981 !important; }

        /* 11. Light mode: stat cards & CRM stat cards clean */
        [data-theme="light"] .crm-stat-card {
            border-color: #E2E8F0 !important;
            box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04) !important;
        }

        /* 12. Smooth sidebar border for light mode */
        [data-theme="light"] #sidebar {
            box-shadow: -4px 0 24px rgba(0,0,0,0.06);
        }

        /* 13. Consistent focus ring color */
        [data-theme="light"] .input-dark:focus,
        [data-theme="light"] .crm-input:focus {
            box-shadow: 0 0 0 3px rgba(59,130,246,0.15) !important;
            border-color: #3B82F6 !important;
        }

        /* 14. Tab buttons: clean blue active, not indigo */
        .tab-active {
            background: #3B82F6 !important;
            border-color: #2563EB !important;
            box-shadow: 0 2px 8px rgba(59,130,246,0.25) !important;
        }

        /* 15. Light mode: login panel — override lingering dark backgrounds */
        [data-theme="light"] #login-screen > div {
            background: #FFFFFF !important;
            border: 1px solid #E2E8F0 !important;
            box-shadow: 0 8px 32px rgba(0,0,0,0.10) !important;
        }

        /* 16. Light mode: neutralize WhatsApp dark preview backgrounds in modals */
        [data-theme="light"] .bg-\[#0b141a\] { background-color: var(--inbox-chat-bg) !important; }
        [data-theme="light"] .bg-\[\#09090b\]\/90 { background-color: var(--overlay-bg) !important; }

        /* 17. Remove shadow-2xl override in favour of our custom card shadow */
        .glass-panel.shadow-2xl {
            box-shadow: 0 8px 32px rgba(0,0,0,0.18) !important;
        }
        [data-theme="light"] .glass-panel.shadow-2xl {
            box-shadow: 0 8px 32px rgba(0,0,0,0.10) !important;
        }

        /* 18. Analytics / stat cards in dark mode — subtle glow, no indigo tint */
        [data-theme="dark"] .glass-panel.shadow-lg {
            box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
        }

        /* 19. Light mode — all text-indigo-* classes: remap to blue */
        [data-theme="light"] .text-indigo-400 { color: #3B82F6 !important; }
        [data-theme="light"] .text-indigo-300 { color: #60A5FA !important; }
        [data-theme="light"] .text-violet-500  { color: #3B82F6 !important; }
        [data-theme="light"] .text-purple-400  { color: #3B82F6 !important; }

        /* 20. Profile modal icon: blue accent */
        [data-theme="light"] .text-indigo-400 i,
        [data-theme="light"] i.text-indigo-400 { color: #3B82F6 !important; }

        /* 21. All app_content glass-panel cards: ensure 24px padding by default */
        #app-content > div > .glass-panel:not([class*="p-"]) {
            padding: 24px;
        }

        /* 22. Consistent rounded-3xl on glass panels */
        .glass-panel { border-radius: 12px; }

        /* 23. Light mode: emerald borders in modals keep their color (meaningful status) */
        .glass-panel.border-t-2.border-emerald-500 {
            border-top-color: #10b981 !important;
        }

        /* === Campaign History: View Toggle === */
        .camp-view-toggle { display:flex; border-radius:8px; overflow:hidden; border:1px solid var(--border-color); flex-shrink:0; }
        .camp-view-toggle-btn { padding:6px 11px; background:transparent; color:var(--text-secondary); border:none; cursor:pointer; font-size:15px; transition:background .15s, color .15s; line-height:1; }
        .camp-view-toggle-btn.active { background:rgba(99,102,241,.2); color:#818cf8; }
        .camp-view-toggle-btn:hover:not(.active) { background:rgba(255,255,255,.05); color:var(--text-primary); }

        /* === Campaign History: List View === */
        .camp-list-view { display:flex; flex-direction:column; gap:3px; }
        .camp-list-header {
            display:grid;
            grid-template-columns: 2fr 1.4fr 1fr 1fr 1fr 1fr 1fr 1fr 56px;
            gap:8px; align-items:center;
            padding:7px 14px;
            font-size:10px; font-weight:700; color:#71717a;
            text-transform:uppercase; letter-spacing:.06em;
            border-bottom:1px solid rgba(255,255,255,.06);
        }
        .camp-list-row {
            display:grid;
            grid-template-columns: 2fr 1.4fr 1fr 1fr 1fr 1fr 1fr 1fr 56px;
            gap:8px; align-items:center;
            padding:10px 14px;
            background:#18181b;
            border-radius:10px;
            border:1px solid transparent;
            transition:border-color .15s, background .15s;
        }
        .camp-list-row:hover { background:#1f1f23; border-color:rgba(99,102,241,.3); }
        .camp-list-name { font-weight:600; font-size:13px; color:#e4e4e7; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:flex; align-items:center; gap:6px; }
        .camp-list-date { font-size:11px; color:#71717a; }
        .camp-list-metric { display:flex; flex-direction:column; align-items:flex-start; gap:1px; }
        .metric-count { font-size:14px; font-weight:700; line-height:1.1; }
        .metric-pct { font-size:10px; color:#71717a; }
        .camp-list-actions { display:flex; align-items:center; justify-content:flex-end; gap:6px; }
        .camp-action-btn {
            width:30px; height:30px; border-radius:7px;
            border:1px solid rgba(255,255,255,.1);
            background:transparent; color:#a1a1aa;
            cursor:pointer; display:flex; align-items:center; justify-content:center;
            font-size:15px;
            transition:background .15s, color .15s, border-color .15s;
        }
        .camp-action-btn:hover { background:rgba(99,102,241,.2); color:#818cf8; border-color:rgba(99,102,241,.4); }
        .camp-action-btn--danger { color:#f87171; border-color:rgba(248,113,113,.25); }
        .camp-action-btn--danger:hover { background:rgba(239,68,68,.2); color:#ef4444; border-color:rgba(239,68,68,.45); }

        /* Light-mode overrides for list view */
        [data-theme="light"] .camp-list-row { background:#f8fafc; border-color:transparent; }
        [data-theme="light"] .camp-list-row:hover { background:#f1f5f9; border-color:rgba(99,102,241,.3); }
        [data-theme="light"] .camp-list-name { color:#1e293b; }
        [data-theme="light"] .camp-list-date { color:#64748b; }
        [data-theme="light"] .camp-list-header { color:#94a3b8; }
        [data-theme="light"] .camp-action-btn { border-color:rgba(0,0,0,.12); color:#64748b; }

        /* === Campaign Preview Modal === */
        .camp-preview-modal {
            background:#18181b; border:1px solid #3f3f46; border-radius:16px;
            width:100%; max-width:560px; max-height:82vh;
            display:flex; flex-direction:column; overflow:hidden;
            box-shadow:0 24px 60px rgba(0,0,0,.55);
        }
        .camp-preview-header { display:flex; justify-content:space-between; align-items:flex-start; padding:20px 24px; border-bottom:1px solid #27272a; }
        .camp-preview-info { display:flex; gap:24px; flex-wrap:wrap; padding:12px 24px; background:#09090b; border-bottom:1px solid #27272a; }
        .camp-preview-info-item { display:flex; flex-direction:column; gap:3px; }
        .camp-preview-info-item .label { font-size:9px; font-weight:700; color:#71717a; text-transform:uppercase; letter-spacing:.07em; }
        .camp-preview-info-item .value { font-size:13px; font-weight:600; color:#c4b5fd; }
        .camp-preview-recipients-section { padding:16px 24px; overflow-y:auto; flex:1; }
        .camp-preview-recipients { display:flex; flex-direction:column; gap:5px; }
        .camp-preview-recipient { display:flex; align-items:center; gap:10px; padding:8px 12px; background:#09090b; border-radius:8px; border:1px solid #27272a; }
        .camp-preview-status { font-size:11px; font-weight:600; }
        .camp-status-sent { color:#818cf8; }
        .camp-status-delivered { color:#34d399; }
        .camp-status-read { color:#10b981; }
        .camp-status-failed { color:#f87171; }

        /* Light-mode overrides for preview modal */
        [data-theme="light"] .camp-preview-modal { background:#ffffff; border-color:#e2e8f0; }
        [data-theme="light"] .camp-preview-header { border-bottom-color:#e2e8f0; }
        [data-theme="light"] .camp-preview-info { background:#f8fafc; border-bottom-color:#e2e8f0; }
        [data-theme="light"] .camp-preview-info-item .label { color:#94a3b8; }
        [data-theme="light"] .camp-preview-info-item .value { color:#7c3aed; }
        [data-theme="light"] .camp-preview-recipient { background:#f8fafc; border-color:#e2e8f0; }

        /* Responsive: stack list columns on mobile */
        @media (max-width: 640px) {
            .camp-list-header { display:none; }
            .camp-list-row { grid-template-columns:1fr 1fr; grid-template-rows:auto auto auto; row-gap:6px; }
            .camp-list-name { grid-column:1 / -1; }
            .camp-list-date { grid-column:1 / -1; }
            .camp-list-actions { grid-column:1 / -1; justify-content:flex-start; }
        }

        /* =========================================
           APPOINTMENTS HUB — PILL TAB NAVIGATION
           ========================================= */

        .hub-tabs-bar {
            display: flex;
            align-items: center;
            gap: 4px;
            background: var(--bg-surface, #0F172A);
            border: 1px solid var(--border-color, #1E293B);
            border-radius: 14px;
            padding: 5px;
        }

        .hub-tab-btn {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 7px;
            padding: 9px 16px;
            border-radius: 10px;
            font-size: 0.875rem;
            font-weight: 600;
            color: var(--text-secondary, #94A3B8);
            background: transparent;
            border: none;
            cursor: pointer;
            transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease !important;
            white-space: nowrap;
        }

        .hub-tab-btn:hover:not(.active) {
            color: var(--text-primary, #F8FAFC);
            background: rgba(255, 255, 255, 0.05);
        }

        .hub-tab-btn.active {
            background: var(--accent, #60A5FA);
            color: #ffffff;
            box-shadow: 0 2px 10px rgba(96, 165, 250, 0.35);
        }

        @media (max-width: 480px) {
            .hub-tab-btn {
                font-size: 0.75rem;
                padding: 8px 8px;
                gap: 4px;
            }
            .hub-tab-btn i { display: none; }
        }

        /* Light theme overrides */
        [data-theme="light"] .hub-tabs-bar {
            background: #f1f5f9;
            border-color: #e2e8f0;
        }
        [data-theme="light"] .hub-tab-btn { color: #64748b; }
        [data-theme="light"] .hub-tab-btn:hover:not(.active) {
            color: #1e293b;
            background: rgba(0,0,0,0.05);
        }

        /* Cream theme overrides */
        [data-theme="cream"] .hub-tabs-bar {
            background: #ede8df;
            border-color: #d6cfc6;
        }
        [data-theme="cream"] .hub-tab-btn { color: #8a7e6e; }
        [data-theme="cream"] .hub-tab-btn:hover:not(.active) {
            color: #3d3328;
            background: rgba(0,0,0,0.05);
        }

        /* =========================================
           SETTINGS HUB — TAB CONTENT
           ========================================= */
        .settings-tab-content {
            display: block;
        }

        /* =========================================
           SETTINGS — TOGGLE SWITCH
           ========================================= */
        .settings-toggle {
            position: relative;
            display: inline-flex;
            align-items: center;
            cursor: pointer;
            flex-shrink: 0;
        }

        .settings-toggle input {
            opacity: 0;
            width: 0;
            height: 0;
            position: absolute;
        }

        .settings-toggle-slider {
            position: relative;
            display: block;
            width: 44px;
            height: 24px;
            background: #334155;
            border-radius: 12px;
            border: 1px solid #475569;
            transition: background 0.25s ease, border-color 0.25s ease;
        }

        .settings-toggle-slider::after {
            content: '';
            position: absolute;
            top: 3px;
            right: 3px;
            width: 16px;
            height: 16px;
            background: #94a3b8;
            border-radius: 50%;
            transition: transform 0.25s ease, background 0.25s ease;
        }

        .settings-toggle input:checked + .settings-toggle-slider {
            background: var(--accent, #60a5fa);
            border-color: var(--accent, #60a5fa);
        }

        .settings-toggle input:checked + .settings-toggle-slider::after {
            transform: translateX(-20px);
            background: #ffffff;
        }

        [data-theme="light"] .settings-toggle-slider {
            background: #e2e8f0;
            border-color: #cbd5e1;
        }

        [data-theme="light"] .settings-toggle-slider::after {
            background: #94a3b8;
        }

        [data-theme="cream"] .settings-toggle-slider {
            background: #d6cfc6;
            border-color: #c5bcb0;
        }

        [data-theme="cream"] .settings-toggle-slider::after {
            background: #8a7e6e;
        }

        /* Transparent click-capture overlay — sits on top of a tab's content
           area to let the user see the layout while routing any click to the
           global locked-feature modal. The parent container must be
           position:relative so the overlay covers exactly that tab. */
        .feature-click-block {
            position: absolute;
            inset: 0;
            z-index: 50;
            background: transparent;
        }
        .feature-click-block.hidden { display: none; }

        /* Lock icon variant for the marketing-hub sub-tab pill buttons —
           same style/color as the sidebar lock icon used by updateNavLocks. */
        .hub-tab-btn .feature-lock-icon {
            color: #eab308;
            font-size: 13px;
            margin-inline-start: 6px;
            opacity: 0.85;
        }

        /* ── Product Tour (custom tooltip system, no external lib) ─────────
           Backdrop dims everything; the highlight uses a CSS box-shadow ring
           around the target's bounding rect so we don't have to clip the
           backdrop with an SVG mask. The tooltip is absolutely-positioned and
           re-anchored via JS on resize/scroll. */
        .tour-backdrop {
            position: fixed; inset: 0; z-index: 9000;
            background: rgba(7, 11, 22, 0.70);
            backdrop-filter: blur(2px);
            -webkit-backdrop-filter: blur(2px);
        }
        .tour-highlight {
            position: fixed; z-index: 9001;
            border-radius: 14px;
            box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.85),
                        0 0 0 9999px rgba(7, 11, 22, 0.70),
                        0 12px 40px rgba(99, 102, 241, 0.45);
            pointer-events: none;
            transition: top 0.35s ease, left 0.35s ease, width 0.35s ease, height 0.35s ease;
        }
        .tour-tooltip {
            position: fixed; z-index: 9002;
            background: linear-gradient(135deg, rgba(28, 26, 60, 0.98), rgba(15, 17, 36, 0.98));
            color: #f4f4f5;
            border: 1px solid rgba(129, 140, 248, 0.45);
            border-radius: 16px;
            padding: 18px 20px 16px;
            min-width: 280px; max-width: 360px;
            box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.25);
            font-size: 14px; line-height: 1.55;
            transition: top 0.35s ease, left 0.35s ease;
        }
        .tour-tooltip-header { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
        .tour-tooltip-step  { font-size: 11px; font-weight: 700; color: #a5b4fc; letter-spacing: 0.08em; text-transform: uppercase; }
        .tour-tooltip-title { font-size: 17px; font-weight: 800; color: #fff; margin: 0 0 8px; }
        .tour-tooltip-body  { color: #d4d4d8; font-size: 14px; }
        .tour-tooltip-footer {
            display: flex; align-items: center; justify-content: space-between;
            gap: 10px; margin-top: 16px;
        }
        .tour-tooltip-actions { display: flex; gap: 8px; }
        .tour-btn {
            border: none; cursor: pointer; font-weight: 700;
            padding: 8px 16px; border-radius: 10px; font-size: 13px;
            transition: background 0.18s, transform 0.18s, opacity 0.18s;
        }
        .tour-btn-primary {
            background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff;
            box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
        }
        .tour-btn-primary:hover { transform: translateY(-1px); }
        .tour-btn-ghost {
            background: transparent; color: #a1a1aa; border: 1px solid rgba(161, 161, 170, 0.30);
        }
        .tour-btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,0.5); }
        .tour-skip {
            background: none; border: none; color: #71717a; font-size: 12px;
            cursor: pointer; padding: 4px 6px; transition: color 0.18s;
        }
        .tour-skip:hover { color: #f4f4f5; text-decoration: underline; }
        .tour-progress { display: flex; gap: 4px; margin-top: 12px; }
        .tour-progress-dot {
            flex: 1; height: 4px; border-radius: 2px;
            background: rgba(161, 161, 170, 0.25);
        }
        .tour-progress-dot.active { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
        .tour-welcome {
            position: fixed; inset: 0; z-index: 9002;
            display: flex; align-items: center; justify-content: center; padding: 20px;
        }
        .tour-welcome-card {
            background: linear-gradient(135deg, rgba(28, 26, 60, 0.98), rgba(15, 17, 36, 0.98));
            border: 1px solid rgba(129, 140, 248, 0.45);
            border-radius: 24px; padding: 36px 32px 28px;
            text-align: center; max-width: 460px; width: 100%;
            box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
            color: #f4f4f5;
        }
        .tour-welcome-icon { font-size: 56px; color: #a5b4fc; margin-bottom: 12px; line-height: 1; }
        .tour-welcome-title { font-size: 24px; font-weight: 800; margin: 0 0 8px; }
        .tour-welcome-sub   { font-size: 14px; color: #d4d4d8; margin: 0 0 24px; }
        .tour-welcome-actions { display: flex; gap: 10px; justify-content: center; }

        /* Sidebar Compliance footer (copyright + Privacy + Terms).
           Lives inside #sidebar above the collapse button. The text wrappers
           reuse .sidebar-collapse-label so they auto-collapse with the
           sidebar's icon-only mode. */
        .sidebar-compliance {
            padding: 10px 14px 4px;
            text-align: center;
            line-height: 1.5;
            color: var(--sidebar-text-muted, #64748b);
            opacity: 0.75;
            flex-shrink: 0;
            overflow: hidden;
        }
        .sidebar-compliance-copy  { font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em; }
        .sidebar-compliance-links {
            font-size: 11px;
            margin-top: 2px;
            display: flex; align-items: center; justify-content: center;
            gap: 6px; flex-wrap: wrap;
        }
        .sidebar-compliance-links a {
            color: var(--sidebar-text-muted, #64748b);
            text-decoration: none;
            transition: color 0.18s;
        }
        .sidebar-compliance-links a:hover { color: var(--sidebar-text, #cbd5e1); text-decoration: underline; }
        .sidebar-compliance-sep { opacity: 0.4; }
        #app-shell.sidebar-collapsed .sidebar-compliance { padding: 6px 0; }
        #app-shell.sidebar-collapsed .sidebar-compliance .sidebar-collapse-label {
            opacity: 0; height: 0; overflow: hidden; margin: 0;
        }

        .login-footer {
            margin-top: 18px;
            padding-top: 14px;
            display: flex; align-items: center; justify-content: center;
            gap: 8px; flex-wrap: wrap;
            font-size: 12px;
            color: var(--text-secondary, #94a3b8);
            border-top: 1px solid var(--border-color, #1e293b);
        }
        .login-footer a {
            color: var(--text-secondary, #94a3b8);
            text-decoration: none;
            display: inline-flex; align-items: center; gap: 4px;
            transition: color 0.18s;
        }
        .login-footer a:hover { color: var(--accent, #6366f1); text-decoration: underline; }
        .login-footer-copy { font-weight: 600; opacity: 0.85; }
        .login-footer-sep  { opacity: 0.4; }

        /* Generic modal overlay (used by workspace modal and others) */
        .modal-overlay { position:fixed; inset:0; background:var(--overlay-bg); z-index:3000; display:flex; align-items:center; justify-content:center; padding:20px; backdrop-filter:blur(4px); }
        .modal-content { background:var(--bg-surface); border-radius:16px; padding:28px; width:100%; border:1px solid var(--border-color); box-shadow:0 24px 60px rgba(0,0,0,.4); max-height:90vh; overflow-y:auto; }
        .modal-close-btn { width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; background:var(--bg-hover,rgba(255,255,255,.06)); color:var(--text-secondary); cursor:pointer; border:none; transition:background 0.2s,color 0.2s; flex-shrink:0; }
        .modal-close-btn:hover { background:var(--border-color); color:var(--text-primary); }
