/* b2-ia-e-contatos.css — pedaço 2/8 do antigo painel-body.css. A ORDEM dos links
   no index.html é a cascata: não reordenar, não trocar de posição. */
        /* === AI Conversation Sidebar Items === */
        @keyframes ai-conv-item-in {
            from { opacity: 0; transform: translateX(-8px); }
            to   { opacity: 1; transform: translateX(0); }
        }

        .ai-conv-item {
            padding: 9px 12px;
            border-radius: 10px;
            cursor: pointer;
            font-size: 13px;
            color: var(--text-main);
            display: flex;
            align-items: center;
            gap: 8px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 2px;
            background: transparent;
            transition: background 0.2s ease, box-shadow 0.2s ease;
            animation: ai-conv-item-in 0.28s ease both;
        }

        .ai-conv-item .ai-conv-icon {
            font-size: 11px;
            color: var(--text-secondary);
            flex-shrink: 0;
            transition: color 0.2s ease;
        }

        .ai-conv-item .ai-conv-title {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .ai-conv-item:hover {
            background: rgba(255, 255, 255, 0.07);
            box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        }

        .ai-conv-item:hover .ai-conv-icon {
            color: var(--accent);
        }

        .ai-conv-item.ai-conv-active {
            background: var(--bg-header);
            box-shadow: 0 2px 10px rgba(0,0,0,0.2);
            font-weight: 600;
        }

        .ai-conv-item.ai-conv-active .ai-conv-icon {
            color: var(--accent);
        }

        .chat-info-right {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            justify-content: center;
            gap: 6px;
            margin-left: auto;
            min-width: 65px;
            transition: gap 0.2s ease;
        }

        .chat-time {
            font-size: 10px;
            color: var(--text-secondary);
        }

        .chat-meta-row {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0;
            min-height: 28px;
            position: relative;
        }

        /* Pílula, não círculo de tamanho fixo: com 20px cravados, "34" espremia o
           número e deformava a bolinha. Agora cresce com o conteúdo e o número fica
           com dígitos de largura igual (tabular-nums), que é o que faz parar de dançar
           quando o contador sobe. */
        .unread-badge {
            background: var(--accent, #00a884);
            color: #04231c;
            font-size: 11px;
            line-height: 1;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
            letter-spacing: 0.2px;
            box-shadow: 0 2px 8px rgba(0,168,132,0.34);
            transition: transform 0.22s ease, opacity 0.22s ease;
        }

        :root.light-theme .unread-badge {
            color: #ffffff;
            box-shadow: 0 2px 8px rgba(0,168,132,0.28);
        }

        .chat-meta-row .chat-item-menu-trigger {
            position: absolute;
            right: 0;
            top: 50%;
            transform: translateX(10px) translateY(-50%) scale(0.92);
        }

        .chat-item:hover .chat-meta-row .chat-item-menu-trigger,
        .chat-meta-row .chat-item-menu-trigger:focus-visible {
            transform: translateX(0) translateY(-50%) scale(1);
        }

        .chat-meta-row .unread-badge {
            transform: translateX(-16px);
        }

        .chat-item:hover .chat-meta-row .unread-badge {
            transform: translateX(-38px);
        }

        :root.light-theme .chat-item-menu-trigger {
            background: linear-gradient(180deg, rgba(17,27,33,0.08), rgba(17,27,33,0.03));
            box-shadow: 0 6px 18px rgba(17,27,33,0.08);
        }

        :root.light-theme .chat-item-menu-trigger:hover,
        :root.light-theme .chat-item-menu-trigger:focus-visible {
            background: linear-gradient(180deg, rgba(17,27,33,0.12), rgba(17,27,33,0.06));
        }

        /* ── TRIÂNGULO SUPERIOR ESQUERDO: QUEM ESTÁ NA CONVERSA (HUMANO OU IA) ── */
        .chat-item {
            position: relative;
        }

        .chat-item:hover {
            z-index: 60;
        }

        .chat-item-corner-attendant {
            position: absolute;
            top: 0;
            left: 0;
            width: 34px;
            height: 34px;
            display: flex;
            align-items: flex-start;
            justify-content: flex-start;
            padding: 3px 0 0 4px;
            box-sizing: border-box;
            z-index: 5;
            cursor: pointer;
        }

        .chat-item-corner-attendant::before {
            content: '';
            position: absolute;
            inset: 0;
            clip-path: polygon(0 0, 100% 0, 0 100%);
            z-index: 1;
            transition: filter 0.2s ease;
        }

        .chat-item-corner-attendant.is-human::before {
            background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
        }

        .chat-item-corner-attendant.is-bot::before,
        .chat-item-corner-attendant.is-bot.is-bot-on::before {
            background: var(--accent, #00a884);
        }

        .chat-item-corner-attendant.is-bot.is-bot-off::before,
        .chat-item-corner-attendant.is-bot-off::before {
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
        }

        .chat-item-corner-attendant.is-bot.is-bot-handoff::before,
        .chat-item-corner-attendant.is-bot-handoff::before {
            background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
        }

        .chat-item.chat-item-drag-over {
            outline: 2px dashed var(--accent, #00a884) !important;
            outline-offset: -2px;
            background: rgba(0, 168, 132, 0.16) !important;
            box-shadow: 0 0 14px rgba(0, 168, 132, 0.35) inset;
            transform: scale(1.01);
            transition: all 0.15s ease;
        }

        .chat-item-corner-attendant i {
            position: relative;
            z-index: 2;
            font-size: 10.5px;
            color: #ffffff !important;
            text-shadow: 0 1px 2px rgba(0,0,0,0.4);
            line-height: 1;
        }

        .chat-item-corner-attendant:hover::before {
            filter: brightness(1.18);
        }

        .chat-item-corner-attendant:hover {
            z-index: 1000;
        }

        /* Popover flutuante global anexado ao body: 100% livre de overflow e stacking contexts */
        .global-attendant-popover {
            position: fixed;
            z-index: 99999999;
            pointer-events: none;
            opacity: 0;
            visibility: hidden;
            transform: scale(0.94);
            transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
            background: #1e293b;
            color: #ffffff;
            border: 1px solid rgba(255,255,255,0.14);
            border-radius: 14px;
            padding: 10px 14px;
            box-shadow: 0 16px 40px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.06);
            display: flex;
            align-items: center;
            gap: 12px;
            min-width: 210px;
            max-width: 280px;
            white-space: normal;
            text-align: left;
        }

        .global-attendant-popover.is-visible {
            opacity: 1;
            visibility: visible;
            transform: scale(1);
        }

        html.light-theme .global-attendant-popover {
            background: #ffffff !important;
            border-color: #e2e8f0 !important;
            box-shadow: 0 16px 40px rgba(15,23,42,0.22), 0 0 0 1px rgba(0,0,0,0.04) !important;
        }

        .global-attendant-popover .chat-attendant-popover-avatar {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            overflow: hidden;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 8px rgba(0,0,0,0.25);
            border: 2px solid rgba(255,255,255,0.2);
            background: #2563eb;
        }

        .global-attendant-popover .chat-attendant-popover-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .global-attendant-popover .chat-attendant-popover-initial {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            font-weight: 800;
            color: #ffffff !important;
            line-height: 1;
            text-transform: uppercase;
        }

        .global-attendant-popover .chat-attendant-popover-avatar.is-bot-avatar {
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--accent, #00a884);
        }

        .global-attendant-popover .chat-attendant-popover-avatar.is-bot-avatar i {
            font-size: 20px !important;
            color: #ffffff !important;
            line-height: 1;
        }

        .global-attendant-popover .chat-attendant-popover-info {
            min-width: 0;
            flex: 1;
        }

        .global-attendant-popover .chat-attendant-popover-name {
            font-size: 13.5px;
            font-weight: 700;
            color: #ffffff;
            line-height: 1.25;
            margin-bottom: 2px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        html.light-theme .global-attendant-popover .chat-attendant-popover-name {
            color: #0f172a !important;
        }

        .global-attendant-popover .chat-attendant-popover-role {
            font-size: 12px;
            font-weight: 700;
            line-height: 1.2;
            margin-bottom: 3px;
            display: flex;
            align-items: center;
        }

        .global-attendant-popover .chat-attendant-popover-time {
            font-size: 11px;
            color: #94a3b8;
            line-height: 1.2;
            display: flex;
            align-items: center;
            font-weight: 500;
        }

        html.light-theme .global-attendant-popover .chat-attendant-popover-time {
            color: #64748b !important;
        }

        .global-attendant-popover .chat-attendant-popover-status {
            font-size: 11px;
            color: #94a3b8;
            line-height: 1.2;
        }

        html.light-theme .global-attendant-popover .chat-attendant-popover-status {
            color: #64748b !important;
        }

        /* ── TRIÂNGULO DA REDE SOCIAL NO CANTO INFERIOR DIREITO ── */
        .chat-item-corner-network {
            position: absolute;
            bottom: 0;
            right: 0;
            width: 36px;
            height: 36px;
            clip-path: polygon(100% 0, 100% 100%, 0 100%);
            display: flex;
            align-items: flex-end;
            justify-content: flex-end;
            padding: 0 4px 4px 0;
            box-sizing: border-box;
            z-index: 3;
            pointer-events: none;
            transition: transform 0.15s ease, opacity 0.15s ease;
        }

        .chat-item-corner-network i {
            font-size: 12px;
            color: #ffffff !important;
            text-shadow: 0 1px 2px rgba(0,0,0,0.4);
            line-height: 1;
        }

        .chat-item-corner-network.is-whatsapp {
            background: #25d366;
        }

        .chat-item-corner-network.is-instagram {
            background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
        }

        .chat-item-corner-network.is-messenger {
            background: #0084ff;
        }

        .chat-item-corner-network.is-bootcamp {
            background: #f59e0b;
        }

        .chat-item-corner-network.is-app,
        .chat-item-corner-network.is-site {
            background: #0284c7;
        }

        .chat-info {
            flex: 1;
            overflow: hidden;
            min-width: 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        .chat-title-row {
            display: flex;
            align-items: center;
            gap: 6px;
            min-width: 0;
            margin-bottom: 3px;
        }

        .chat-name {
            font-weight: 600;
            font-size: 13.5px;
            color: var(--text-main);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            min-width: 0;
            flex-shrink: 1;
            transition: color 0.24s ease, letter-spacing 0.24s ease;
        }

        .chat-name-text {
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .chat-tags-inline {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            flex-shrink: 0;
            max-width: 150px;
            overflow: hidden;
        }

        .chat-tags-inline .chat-label-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            min-height: 18px;
            padding: 2px 7px;
            border-radius: 6px;
            font-size: 10.5px;
            font-weight: 700;
            line-height: 1.2;
            color: #ffffff;
            box-shadow: 0 1px 3px rgba(0,0,0,0.15);
            text-transform: none;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .chat-tags-inline .chat-label-badge i {
            font-size: 9px;
        }

        .chat-top-meta {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 6px;
        }

        .chat-top-meta .chat-time {
            font-size: 11px;
            color: var(--text-secondary);
            font-weight: 500;
        }

        .chat-top-meta .chat-mute-badge {
            font-size: 11px;
            color: var(--text-secondary);
            opacity: 0.75;
            flex-shrink: 0;
        }

        .chat-channel-badge {
            width: 28px;
            min-width: 28px;
            height: 24px;
            padding: 0;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0;
            flex-shrink: 0;
            color: #fff;
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0;
            line-height: 1;
            text-transform: uppercase;
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16), 0 4px 10px rgba(0,0,0,0.16);
        }

        .chat-channel-badge i {
            font-size: 12px;
            line-height: 1;
        }

        .chat-channel-badge span {
            display: none;
        }

        .chat-channel-badge.is-whatsapp {
            background: #00a884;
        }

        .chat-channel-badge.is-instagram {
            background: linear-gradient(45deg, #f09433, #e6683c 28%, #dc2743 55%, #bc1888);
        }

        .chat-channel-badge.is-messenger {
            background: #0084ff;
        }

        .chat-channel-badge.is-app {
            background: #607d8b;
        }

        /* Simulação de treino da IA: roxo, o mesmo tom que o funil já usa para
           etapa criada pela IA — lead de mentira não pode parecer lead de verdade. */
        .chat-channel-badge.is-bootcamp {
            background: #8b5cf6;
        }

        /* Mesmo selo, escala de CRM: a linha da lista e o card compacto do funil não
           comportam os 28px do selo da lista de conversas. Só o tamanho muda — cor e
           ícone continuam vindo de `.chat-channel-badge`, uma fonte só. (26/08/2026) */
        .chat-channel-badge.crm-channel-badge {
            width: 20px;
            min-width: 20px;
            height: 20px;
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16), 0 2px 6px rgba(0,0,0,0.14);
        }

        .chat-channel-badge.crm-channel-badge i {
            font-size: 10px;
        }

        /* Botão para copiar a identificação da conversa — suporte pede isso para
           investigar direto no banco/log; copiar à mão do meio da URL é lento e
           propenso a erro de dedo. (26/08/2026) */
        .chat-header-copy-id-btn {
            width: 24px;
            height: 24px;
            min-width: 24px;
            padding: 0;
            border: none;
            border-radius: var(--r-full);
            background: transparent;
            color: var(--text-secondary);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            flex-shrink: 0;
            transition: background 0.15s ease, color 0.15s ease;
        }

        .chat-header-copy-id-btn:hover {
            background: var(--bg-surface-hover);
            color: var(--accent);
        }

        .chat-header-copy-id-btn i {
            font-size: 12px;
            line-height: 1;
        }

        .chat-last {
            font-size: 13px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: color 0.24s ease;
        }

        .chat-time {
            transition: color 0.24s ease, opacity 0.24s ease;
        }

        .chat-item:hover .chat-name {
            color: var(--text-main);
        }

        .chat-item:hover .chat-last {
            color: rgba(255, 255, 255, 0.82);
        }

        :root.light-theme .chat-item:hover .chat-last {
            color: #43525d;
        }

        /* Main Area */
        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--bg-chat);
            position: relative;
            min-width: 0;
            min-height: 0;
            overflow: hidden;
        }

        /* Light Theme Background Adjustments */
        :root.light-theme .main {
            background-color: #efeae2;
            background-image: url('/img/chat-bg-light.jpg');
            background-repeat: repeat;
            background-size: auto;
        }

        :root.light-theme .messages,
        :root.light-theme .messages-container {
            background-color: transparent;
        }

        /* Dark Theme Background Adjustments */
        :root.dark-theme .main {
            background-image: url('/img/chat-bg-dark.jpg');
            background-repeat: repeat;
            background-size: auto;
            background-color: var(--bg-chat);
        }

        /* Overlay para Arrastar e Soltar Mídia/Arquivos no Chat */
        .chat-drag-overlay {
            position: absolute;
            inset: 0;
            z-index: 999;
            background: rgba(15, 23, 42, 0.88);
            backdrop-filter: blur(8px);
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 14px;
            border: 2.5px dashed var(--accent, #00a884);
            border-radius: 14px;
            margin: 10px;
            color: #ffffff;
            pointer-events: none;
            opacity: 0;
            transform: scale(0.98);
            transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .chat-drag-overlay.is-active {
            display: flex;
            opacity: 1;
            transform: scale(1);
            pointer-events: all;
        }
        .chat-drag-overlay-icon {
            width: 76px;
            height: 76px;
            border-radius: 50%;
            background: rgba(0, 168, 132, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 34px;
            color: var(--accent, #00a884);
            border: 2px solid rgba(0, 168, 132, 0.45);
            animation: pulse-drag 1.8s infinite;
        }
        .chat-drag-overlay-title {
            font-size: 19px;
            font-weight: 700;
            letter-spacing: 0.2px;
            text-align: center;
        }
        .chat-drag-overlay-subtitle {
            font-size: 13.5px;
            color: rgba(255, 255, 255, 0.72);
            text-align: center;
        }
        @keyframes pulse-drag {
            0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.4); }
            50% { transform: scale(1.06); box-shadow: 0 0 20px rgba(0, 168, 132, 0.65); }
        }

        /* Miniaturas de Múltiplos Arquivos no Modal de Prévia */
        .preview-thumbnails-container {
            display: flex;
            align-items: center;
            gap: 8px;
            overflow-x: auto;
            max-width: 100%;
            padding: 8px 4px 12px;
            margin-bottom: 12px;
            box-sizing: border-box;
            scrollbar-width: thin;
        }
        .preview-thumbnails-container::-webkit-scrollbar {
            height: 5px;
        }
        .preview-thumbnails-container::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 4px;
        }
        .preview-thumb-item {
            position: relative;
            width: 56px;
            height: 56px;
            border-radius: 8px;
            border: 2px solid transparent;
            cursor: pointer;
            flex-shrink: 0;
            overflow: hidden;
            background: rgba(255, 255, 255, 0.08);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.16s ease;
            box-sizing: border-box;
        }
        .preview-thumb-item:hover {
            border-color: rgba(255, 255, 255, 0.4);
        }
        .preview-thumb-item.is-active {
            border-color: var(--accent, #00a884) !important;
            box-shadow: 0 0 8px rgba(0, 168, 132, 0.5);
        }
        .preview-thumb-item img,
        .preview-thumb-item video {
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }
        .preview-thumb-item .thumb-doc-icon {
            font-size: 22px;
            color: var(--accent, #00a884);
        }
        .preview-thumb-remove {
            position: absolute;
            top: 2px;
            right: 2px;
            width: 17px;
            height: 17px;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.75);
            color: #ffffff;
            border: none;
            font-size: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            line-height: 1;
            padding: 0;
            transition: background 0.15s ease;
            z-index: 3;
        }
        .preview-thumb-remove:hover {
            background: #ef4444;
        }
        .preview-add-more-btn {
            width: 56px;
            height: 56px;
            border-radius: 8px;
            border: 2px dashed rgba(255, 255, 255, 0.32);
            background: transparent;
            color: rgba(255, 255, 255, 0.65);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            cursor: pointer;
            flex-shrink: 0;
            transition: all 0.15s ease;
            box-sizing: border-box;
        }
        .preview-add-more-btn:hover {
            border-color: var(--accent, #00a884);
            color: var(--accent, #00a884);
            background: rgba(0, 168, 132, 0.12);
        }

        :root.dark-theme .messages,
        :root.dark-theme .messages-container {
            background-color: transparent;
        }

        .chat-header {
            background: var(--bg-header);
            padding: 10px 16px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid var(--border);
            flex-shrink: 0;
            min-width: 0;
        }

        .chat-pinned-banner {
            position: sticky;
            top: -20px;
            z-index: 3;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            margin: -8px 0 14px;
            padding: 10px 14px;
            border-radius: 14px;
            border: 1px solid rgba(0, 168, 132, 0.18);
            background:
                linear-gradient(135deg, rgba(0, 168, 132, 0.14), rgba(0, 168, 132, 0.05)),
                var(--bg-header);
            box-shadow: 0 10px 28px rgba(0,0,0,0.12);
            backdrop-filter: blur(8px);
        }

        .chat-pinned-banner-main {
            min-width: 0;
            display: flex;
            align-items: center;
            gap: 12px;
            flex: 1;
            cursor: pointer;
        }

        .chat-pinned-banner-icon {
            width: 38px;
            height: 38px;
            border-radius: 12px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            color: var(--accent);
            background: rgba(0, 168, 132, 0.14);
            box-shadow: inset 0 0 0 1px rgba(0, 168, 132, 0.16);
        }

        .chat-pinned-banner-copy {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .chat-pinned-banner-label {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: var(--accent);
        }

        .chat-pinned-banner-text {
            font-size: 13px;
            line-height: 1.4;
            color: var(--text-main);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .chat-pinned-banner-meta {
            font-size: 11px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .chat-pinned-banner-controls {
            display: flex;
            align-items: center;
            gap: 6px;
            flex-shrink: 0;
        }

        .chat-pinned-banner-btn {
            width: 30px;
            height: 30px;
            border: none;
            border-radius: 999px;
            background: rgba(255,255,255,0.06);
            color: var(--text-secondary);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
        }

        .chat-pinned-banner-btn:hover {
            background: rgba(0, 168, 132, 0.14);
            color: var(--accent);
            transform: translateY(-1px);
        }

        .chat-pinned-highlight {
            animation: pinnedMessagePulse 1.7s ease;
            box-shadow: 0 0 0 2px rgba(0, 168, 132, 0.22), 0 16px 32px rgba(0, 168, 132, 0.16);
        }

        @keyframes pinnedMessagePulse {
            0% {
                box-shadow: 0 0 0 0 rgba(0, 168, 132, 0.36);
                transform: scale(0.995);
            }
            35% {
                box-shadow: 0 0 0 6px rgba(0, 168, 132, 0.18);
                transform: scale(1);
            }
            100% {
                box-shadow: 0 0 0 0 rgba(0, 168, 132, 0);
                transform: scale(1);
            }
        }

        .chat-label-row {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 7px;
        }

        .chat-label-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            max-width: 100%;
            min-height: 23px;
            padding: 5px 12px;
            border-radius: 999px;
            font-size: 12px;
            font-weight: 800;
            letter-spacing: 0;
            color: #fff;
            white-space: nowrap;
            box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
        }

        .messages {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            background-color: transparent;
            z-index: 0;
            position: absolute;
            top: 60px;
            left: 0;
            right: 0;
            bottom: 60px;
            pointer-events: none;
        }

        .messages-container {
            flex: 1;
            padding: 20px;
            padding-bottom: 96px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            position: relative;
            z-index: 1;
            min-height: 0;
            min-width: 0;
            overscroll-behavior: contain;
        }

        .scroll-to-bottom-btn {
            position: absolute;
            right: 18px;
            bottom: 84px;
            width: 44px;
            height: 44px;
            border: none;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #00c2a8 0%, #00a884 100%);
            color: #fff;
            box-shadow: 0 10px 24px rgba(0, 168, 132, 0.28);
            cursor: pointer;
            z-index: 4;
            opacity: 0;
            transform: translateY(12px) scale(0.94);
            pointer-events: none;
            transition: opacity .18s ease, transform .18s ease, box-shadow .18s ease;
        }

        .scroll-to-bottom-btn:hover {
            box-shadow: 0 14px 30px rgba(0, 168, 132, 0.34);
            transform: translateY(0) scale(1.02);
        }

        .scroll-to-bottom-btn:active {
            transform: translateY(1px) scale(0.98);
        }

        .scroll-to-bottom-btn.visible {
            opacity: 1;
            transform: translateY(0) scale(1);
            pointer-events: auto;
        }

        .scroll-to-bottom-btn i {
            font-size: 16px;
        }

        @media (max-width: 768px) {
            .scroll-to-bottom-btn {
                right: 14px;
                bottom: 78px;
                width: 42px;
                height: 42px;
            }
        }

        .message-content,
        .bubble {
            overflow-wrap: anywhere;
            word-break: break-word;
            min-width: 0;
        }

        .bubble {
            padding: 6px 7px 8px 9px;
            border-radius: 7.5px;
            max-width: 65%;
            font-size: 14.2px;
            position: relative;
            box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
            line-height: 19px;
        }

        .message-bubble-shell {
            position: relative;
            display: flex;
            align-items: flex-start;
            gap: 8px;
            width: 100%;
        }

        /* ─────────── SEQUÊNCIA DE MENSAGENS (a régua do WhatsApp) ───────────
           Mensagens seguidas da mesma pessoa andam coladas (2px) e formam um bloco;
           quando muda quem fala, o espaço abre (10px) e a bolha ganha o rabinho. É
           esse contraste que dá o ritmo da conversa — espaçamento igual entre todas
           deixa a tela com cara de lista, não de conversa. */
        .message-bubble-shell + .message-bubble-shell {
            margin-top: 2px;
        }

        .message-bubble-shell + .message-bubble-shell.inicio-de-sequencia {
            margin-top: 10px;
        }

        /* ─────────── RABINHO ───────────
           8×13px colado no canto de cima, que é onde o WhatsApp o desenha. O canto
           correspondente da bolha perde o arredondamento para o triângulo encaixar
           sem degrau. Só a 1ª bolha da sequência tem rabo. */
        .bubble.com-rabo::before {
            content: '';
            position: absolute;
            top: 0;
            width: 8px;
            height: 13px;
            background: inherit;
            filter: drop-shadow(0 1px 0.5px rgba(11, 20, 26, 0.13));
        }

        .bubble.sent.com-rabo {
            border-top-right-radius: 0;
        }

        .bubble.sent.com-rabo::before {
            right: -8px;
            clip-path: polygon(0 0, 100% 0, 0 100%);
        }

        .bubble.received.com-rabo {
            border-top-left-radius: 0;
        }

        .bubble.received.com-rabo::before {
            left: -8px;
            clip-path: polygon(100% 0, 100% 100%, 0 0);
        }

        /* ─────────── AUTOR NO GRUPO ───────────
           Foto na coluna da esquerda (só na 1ª da sequência; nas seguintes fica um
           espaçador invisível, senão a fileira desalinha) e nome COLORIDO DENTRO da
           bolha, como no WhatsApp — fora dela virava uma linha solta acima. */
        .autor-foto {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            object-fit: cover;
            flex: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-top: 1px;
        }

        .autor-iniciais {
            color: #fff;
            font-size: 11px;
            font-weight: 700;
            letter-spacing: .3px;
        }

        .autor-foto-vazia {
            visibility: hidden;
        }

        /* 12px, não 8: o rabinho invade 8px à esquerda da bolha e encostaria na foto. */
        .message-bubble-shell.com-autor {
            gap: 12px;
        }

        .autor-nome {
            font-size: 12.8px;
            font-weight: 500;
            line-height: 22px;
            margin-bottom: 1px;
            color: var(--autor-cor-escuro, var(--accent));
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        :root.light-theme .autor-nome {
            color: var(--autor-cor-claro, var(--accent));
        }

        .autor-nome.autor-operador {
            font-size: 11px;
            font-weight: 700;
            line-height: 16px;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            color: var(--accent);
            margin-bottom: 3px;
        }

        /* ─────────── MENSAGEM CITADA (resposta) ───────────
           Faixa colorida à esquerda + fundo mais escuro que a bolha, igual ao
           WhatsApp. Clicar leva até a mensagem original. */
        .msg-citacao {
            display: block;
            width: 100%;
            margin-bottom: 4px;
            padding: 5px 8px 5px 10px;
            border-left: 4px solid var(--autor-cor-escuro, var(--accent));
            border-radius: 4px;
            background: rgba(0, 0, 0, 0.28);
            overflow: hidden;
        }

        :root.light-theme .msg-citacao {
            background: rgba(11, 20, 26, 0.06);
            border-left-color: var(--autor-cor-claro, var(--accent));
        }

        .msg-citacao.clicavel {
            cursor: pointer;
        }

        .msg-citacao.clicavel:hover {
            background: rgba(0, 0, 0, 0.36);
        }

        :root.light-theme .msg-citacao.clicavel:hover {
            background: rgba(11, 20, 26, 0.1);
        }

        .msg-citacao-autor {
            font-size: 12.8px;
            font-weight: 500;
            line-height: 18px;
            color: var(--autor-cor-escuro, var(--accent));
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        :root.light-theme .msg-citacao-autor {
            color: var(--autor-cor-claro, var(--accent));
        }

        .msg-citacao-corpo {
            font-size: 13px;
            line-height: 18px;
            max-height: 36px;
            overflow: hidden;
            opacity: 0.7;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
        }

        .citacao-anexo i {
            margin-right: 5px;
            font-size: 11px;
        }

        /* Transcrição de áudio: bloco discreto abaixo do player, não outro parágrafo
           com o mesmo peso da mensagem. */
        .message-transcricao {
            margin-top: 8px;
        }

        .transcricao-rotulo {
            font-size: 11px;
            opacity: 0.72;
            margin-bottom: 4px;
        }

        /* Foto/vídeo sem legenda: bolha é só a mídia — sem sobra de padding em volta
           e com a hora sobreposta (regra em b3). */
        /* Sem `overflow:hidden` aqui: ele cortaria o rabinho, que é desenhado FORA da
           caixa da bolha. Quem arredonda é a própria mídia. */
        .bubble.so-midia {
            padding: 3px;
        }

        .bubble.so-midia .message-media {
            margin-bottom: 0;
        }

        .bubble.so-midia .message-media-preview img,
        .bubble.so-midia .message-media-preview video {
            border-radius: 5px;
        }

        .message-bubble-shell.sent {
            justify-content: flex-end;
        }

        .message-bubble-shell.received {
            justify-content: flex-start;
        }

        .bubble {
            position: relative !important;
        }

        .bubble .message-menu-trigger {
            position: absolute !important;
            top: 3px !important;
            right: 4px !important;
            left: auto !important;
            bottom: auto !important;
            width: 24px !important;
            height: 24px !important;
            border-radius: 50% !important;
            border: none !important;
            background: transparent !important;
            color: var(--text-secondary, #8696a0) !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            opacity: 0 !important;
            pointer-events: none !important;
            cursor: pointer !important;
            z-index: 50 !important;
            transition: opacity 0.06s linear, background 0.06s linear, color 0.06s linear !important;
            font-size: 12px !important;
            box-shadow: none !important;
            margin: 0 !important;
            padding: 0 !important;
        }

        .message-bubble-shell:hover .message-menu-trigger,
        .bubble:hover .message-menu-trigger,
        .bubble .message-menu-trigger:focus-visible {
            opacity: 1 !important;
            pointer-events: auto !important;
        }

        .bubble .message-menu-trigger:hover,
        .bubble .message-menu-trigger:focus-visible {
            background: rgba(0, 0, 0, 0.28) !important;
            color: #ffffff !important;
            outline: none !important;
        }

        :root.light-theme .bubble .message-menu-trigger:hover,
        body.light-theme .bubble .message-menu-trigger:hover {
            background: rgba(0, 0, 0, 0.12) !important;
            color: #111b21 !important;
        }

        #message-context-menu.chat-context-menu {
            position: fixed;
            z-index: 999999999;
            background: #233138;
            border: 1px solid rgba(255, 255, 255, 0.08);
            border-radius: 12px;
            padding: 5px 0 3px 0;
            box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
            min-width: 215px;
            max-width: 245px;
            display: none;
            overflow: hidden !important;
            scrollbar-width: none !important;
            -ms-overflow-style: none !important;
            box-sizing: border-box;
        }

        #message-context-menu.chat-context-menu::-webkit-scrollbar {
            display: none !important;
            width: 0 !important;
            height: 0 !important;
        }

        :root.light-theme #message-context-menu.chat-context-menu,
        body.light-theme #message-context-menu.chat-context-menu {
            background: #ffffff;
            border-color: #e2e8f0;
            box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
        }

        .msg-context-reactions-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 4px 10px 7px 10px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            margin-bottom: 3px;
            overflow: hidden !important;
            box-sizing: border-box;
        }

        :root.light-theme .msg-context-reactions-bar,
        body.light-theme .msg-context-reactions-bar {
            border-bottom-color: #e2e8f0;
        }

        .msg-reaction-btn {
            background: transparent;
            border: none;
            font-size: 19px;
            cursor: pointer;
            padding: 3px;
            border-radius: 50%;
            transition: transform 0.12s ease, background 0.12s ease;
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .msg-reaction-btn:hover {
            transform: scale(1.25);
            background: rgba(255, 255, 255, 0.12);
        }

        :root.light-theme .msg-reaction-btn:hover,
        body.light-theme .msg-reaction-btn:hover {
            background: rgba(0, 0, 0, 0.06);
        }

        .msg-reaction-btn.msg-reaction-more {
            font-size: 12px;
            width: 26px;
            height: 26px;
            background: rgba(255, 255, 255, 0.08);
            color: var(--text-secondary, #8696a0);
        }

        :root.light-theme .msg-reaction-btn.msg-reaction-more,
        body.light-theme .msg-reaction-btn.msg-reaction-more {
            background: #f1f5f9;
            color: #64748b;
        }

        .msg-context-menu-list {
            display: flex;
            flex-direction: column;
            overflow: hidden !important;
        }

        .msg-context-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 7px 16px;
            background: transparent;
            border: none;
            color: #d1d7db;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            text-align: left;
            width: 100%;
            box-sizing: border-box;
            transition: background 0.08s ease, color 0.08s ease;
        }

        :root.light-theme .msg-context-item,
        body.light-theme .msg-context-item {
            color: #3b4a54;
        }

        .msg-context-item:hover {
            background: rgba(255, 255, 255, 0.08);
            color: #ffffff;
        }

        :root.light-theme .msg-context-item:hover,
        body.light-theme .msg-context-item:hover {
            background: #f1f5f9;
            color: #111b21;
        }

        .msg-context-item i {
            width: 16px;
            font-size: 13.5px;
            text-align: center;
            color: #8696a0;
            flex-shrink: 0;
        }

        .msg-context-item.destructive {
            color: #ef4444 !important;
        }

        .msg-context-item.destructive i {
            color: #ef4444 !important;
        }

        /* ─────────── WHATSAPP MODAL: APAGAR MENSAGEM ─────────── */
        .wa-delete-swal-popup.swal2-popup {
            background: #233138 !important;
            border-radius: 16px !important;
            padding: 24px 20px !important;
            max-width: 380px !important;
            border: 1px solid rgba(255, 255, 255, 0.08) !important;
            box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6) !important;
            color: #e9edef !important;
        }

        :root.light-theme .wa-delete-swal-popup.swal2-popup,
        body.light-theme .wa-delete-swal-popup.swal2-popup {
            background: #ffffff !important;
            border-color: #e2e8f0 !important;
            box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16) !important;
            color: #111b21 !important;
        }

        .wa-delete-modal-content {
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
        }

        .wa-delete-modal-icon {
            width: 52px;
            height: 52px;
            border-radius: 50%;
            background: rgba(239, 68, 68, 0.12);
            color: #ef4444;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 22px;
            margin-bottom: 14px;
        }

        .wa-delete-modal-title {
            font-size: 18px;
            font-weight: 700;
            margin-bottom: 8px;
            color: inherit;
        }

        .wa-delete-modal-text {
            font-size: 14px;
            line-height: 1.45;
            color: var(--text-secondary, #8696a0);
            margin-bottom: 20px;
        }

        .wa-delete-modal-buttons {
            display: flex;
            flex-direction: column;
            gap: 8px;
            width: 100%;
        }

        .wa-delete-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            width: 100%;
            padding: 11px 16px;
            border-radius: 10px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            border: none;
            transition: background 0.15s ease, transform 0.1s ease;
        }

        .wa-delete-btn:active {
            transform: scale(0.98);
        }

        .wa-delete-everyone {
            background: #ef4444;
            color: #ffffff;
        }

        .wa-delete-everyone:hover {
            background: #dc2626;
        }

        .wa-delete-me {
            background: rgba(255, 255, 255, 0.08);
            color: inherit;
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        :root.light-theme .wa-delete-me,
        body.light-theme .wa-delete-me {
            background: #f1f5f9;
            border-color: #cbd5e1;
            color: #111b21;
        }

        .wa-delete-me:hover {
            background: rgba(255, 255, 255, 0.14);
        }

        :root.light-theme .wa-delete-me:hover,
        body.light-theme .wa-delete-me:hover {
            background: #e2e8f0;
        }

        .wa-delete-cancel {
            background: transparent;
            color: var(--text-secondary, #8696a0);
        }

        .wa-delete-cancel:hover {
            background: rgba(255, 255, 255, 0.04);
            color: inherit;
        }

        /* ─────────── WHATSAPP MODAL: ENCAMINHAR ─────────── */
        .wa-fwd-swal-popup.swal2-popup {
            background: #233138 !important;
            border-radius: 16px !important;
            padding: 0 !important;
            max-width: 440px !important;
            border: 1px solid rgba(255, 255, 255, 0.08) !important;
            box-shadow: 0 20px 48px rgba(0, 0, 0, 0.6) !important;
            overflow: hidden !important;
            color: #e9edef !important;
        }

        :root.light-theme .wa-fwd-swal-popup.swal2-popup,
        body.light-theme .wa-fwd-swal-popup.swal2-popup {
            background: #ffffff !important;
            border-color: #e2e8f0 !important;
            box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16) !important;
            color: #111b21 !important;
        }

        .wa-fwd-modal-container {
            display: flex;
            flex-direction: column;
            max-height: 80vh;
        }

        .wa-fwd-header {
            padding: 16px 18px 12px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        }

        :root.light-theme .wa-fwd-header,
        body.light-theme .wa-fwd-header {
            border-bottom-color: #e2e8f0;
        }

        .wa-fwd-title {
            font-size: 16px;
            font-weight: 700;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
        }

        .wa-fwd-search-wrap {
            position: relative;
            display: flex;
            align-items: center;
        }

        .wa-fwd-search-icon {
            position: absolute;
            left: 12px;
            color: var(--text-secondary, #8696a0);
            font-size: 13px;
        }

        .wa-fwd-search-input {
            width: 100%;
            padding: 8px 12px 8px 34px;
            border-radius: 8px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            background: rgba(0, 0, 0, 0.2);
            color: inherit;
            font-size: 13.5px;
            outline: none;
        }

        :root.light-theme .wa-fwd-search-input,
        body.light-theme .wa-fwd-search-input {
            background: #f8fafc;
            border-color: #cbd5e1;
        }

        .wa-fwd-list {
            max-height: 320px;
            overflow-y: auto;
            padding: 6px 12px;
            display: flex;
            flex-direction: column;
            gap: 3px;
        }

        .wa-fwd-contact-row {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px 10px;
            border-radius: 10px;
            cursor: pointer;
            transition: background 0.12s ease;
        }

        .wa-fwd-contact-row:hover {
            background: rgba(255, 255, 255, 0.05);
        }

        :root.light-theme .wa-fwd-contact-row:hover,
        body.light-theme .wa-fwd-contact-row:hover {
            background: #f1f5f9;
        }

        .wa-fwd-checkbox {
            width: 18px;
            height: 18px;
            accent-color: var(--accent, #00a884);
            cursor: pointer;
        }

        .wa-fwd-avatar-wrap {
            width: 40px;
            height: 40px;
            flex-shrink: 0;
            border-radius: 50%;
            overflow: hidden;
            background: #00a884;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .wa-fwd-avatar-img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .wa-fwd-avatar-initial {
            font-size: 16px;
            font-weight: 700;
            color: #ffffff;
        }

        .wa-fwd-contact-info {
            flex: 1;
            min-width: 0;
            text-align: left;
        }

        .wa-fwd-contact-name {
            font-size: 14px;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .wa-fwd-contact-phone {
            font-size: 12px;
            color: var(--text-secondary, #8696a0);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .wa-fwd-footer {
            padding: 12px 18px;
            border-top: 1px solid rgba(255, 255, 255, 0.08);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        :root.light-theme .wa-fwd-footer,
        body.light-theme .wa-fwd-footer {
            border-top-color: #e2e8f0;
        }

        .wa-fwd-count {
            font-size: 12.5px;
            color: var(--text-secondary, #8696a0);
        }

        .wa-fwd-actions {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .wa-fwd-cancel-btn {
            background: transparent;
            border: none;
            color: var(--text-secondary, #8696a0);
            font-size: 13.5px;
            font-weight: 600;
            cursor: pointer;
            padding: 6px 12px;
            border-radius: 8px;
        }

        .wa-fwd-send-btn {
            background: var(--accent, #00a884);
            color: #ffffff;
            border: none;
            border-radius: 8px;
            padding: 8px 16px;
            font-size: 13.5px;
            font-weight: 600;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: opacity 0.15s ease;
        }

        .wa-fwd-send-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        /* ─────────── WHATSAPP REPLY PREVIEW BAR ─────────── */
        .composer-reply-preview {
            width: calc(100% - 32px);
            margin: 0 16px 8px;
        }

        .composer-reply-preview-box {
            display: flex;
            align-items: center;
            width: 100%;
            background: #202c33;
            border-radius: 8px;
            overflow: hidden;
            padding: 8px 12px;
            position: relative;
            box-shadow: 0 2px 6px rgba(0,0,0,0.2);
        }

        :root.light-theme .composer-reply-preview-box,
        body.light-theme .composer-reply-preview-box {
            background: #e9edef;
        }

        .composer-reply-preview-bar {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: var(--accent, #00a884);
        }

        .composer-reply-preview-content {
            flex: 1;
            min-width: 0;
            margin-left: 6px;
            text-align: left;
        }

        .composer-reply-preview-author {
            font-size: 12.5px;
            font-weight: 600;
            color: var(--accent, #00a884);
            margin-bottom: 2px;
        }

        .composer-reply-preview-body {
            font-size: 13px;
            color: var(--text-secondary, #8696a0);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .composer-reply-preview-close {
            background: transparent;
            border: none;
            color: var(--text-secondary, #8696a0);
            font-size: 16px;
            cursor: pointer;
            padding: 4px 8px;
            border-radius: 50%;
            transition: color 0.15s ease;
        }

        .composer-reply-preview-close:hover {
            color: #ffffff;
        }

        :root.light-theme .composer-reply-preview-close:hover,
        body.light-theme .composer-reply-preview-close:hover {
            color: #111b21;
        }

        /* ─────────── WHATSAPP MULTI-SELECT BAR & CHECKBOXES ─────────── */
        .msg-select-checkbox-wrap {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            padding: 0 6px !important;
            cursor: pointer !important;
            flex-shrink: 0 !important;
            z-index: 10 !important;
        }

        .msg-select-checkbox {
            width: 20px !important;
            height: 20px !important;
            accent-color: var(--accent, #00a884) !important;
            cursor: pointer !important;
            border-radius: 4px !important;
        }

        .message-bubble-shell.is-selected .bubble {
            box-shadow: 0 0 0 2px var(--accent, #00a884) !important;
        }

        .bubble.bolha-apagada {
            font-style: italic !important;
        }

        .msg-apagada-aviso {
            color: rgba(255, 255, 255, 0.65) !important;
            font-size: 13.5px !important;
            display: inline-flex !important;
            align-items: center !important;
            gap: 7px !important;
            user-select: none !important;
        }

        .msg-apagada-aviso em {
            font-style: italic !important;
            font-size: 13.5px !important;
            color: rgba(255, 255, 255, 0.65) !important;
        }

        .msg-apagada-aviso i {
            font-size: 13.5px !important;
            color: rgba(255, 255, 255, 0.65) !important;
            opacity: 0.85 !important;
        }

        :root.light-theme .msg-apagada-aviso,
        :root.light-theme .msg-apagada-aviso em,
        :root.light-theme .msg-apagada-aviso i,
        body.light-theme .msg-apagada-aviso,
        body.light-theme .msg-apagada-aviso em,
        body.light-theme .msg-apagada-aviso i {
            color: rgba(0, 0, 0, 0.45) !important;
        }

        .msg-selection-bar {
            position: fixed;
            bottom: 74px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 999999;
            background: #233138;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 10px 18px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
            color: #e9edef;
            min-width: 320px;
        }

        :root.light-theme .msg-selection-bar,
        body.light-theme .msg-selection-bar {
            background: #ffffff;
            border-color: #cbd5e1;
            box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
            color: #111b21;
        }

        .msg-selection-bar-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .msg-selection-bar-close {
            background: transparent;
            border: none;
            color: var(--text-secondary, #8696a0);
            font-size: 16px;
            cursor: pointer;
        }

        .msg-selection-bar-count {
            font-size: 14px;
            font-weight: 600;
        }

        .msg-selection-bar-actions {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .msg-selection-bar-btn {
            background: rgba(255, 255, 255, 0.08);
            border: none;
            border-radius: 8px;
            padding: 6px 12px;
            font-size: 13px;
            font-weight: 600;
            color: inherit;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        :root.light-theme .msg-selection-bar-btn,
        body.light-theme .msg-selection-bar-btn {
            background: #f1f5f9;
        }

        .msg-selection-bar-btn.destructive {
            color: #ef4444;
            background: rgba(239, 68, 68, 0.12);
        }

        .msg-selection-bar-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        /* ─────────── WHATSAPP EMOJI REACTIONS PICKER ─────────── */
        .wa-emoji-swal-popup.swal2-popup {
            background: #233138 !important;
            border-radius: 16px !important;
            padding: 16px !important;
            max-width: 380px !important;
            color: #e9edef !important;
        }

        :root.light-theme .wa-emoji-swal-popup.swal2-popup,
        body.light-theme .wa-emoji-swal-popup.swal2-popup {
            background: #ffffff !important;
            color: #111b21 !important;
        }

        .wa-emoji-picker-container {
            max-height: 280px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 12px;
            text-align: left;
        }

        .wa-emoji-category-title {
            font-size: 12px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--text-secondary, #8696a0);
            margin-bottom: 6px;
        }

        .wa-emoji-grid {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 6px;
        }

        .wa-emoji-btn {
            background: transparent;
            border: none;
            font-size: 24px;
            padding: 6px 0;
            border-radius: 8px;
            cursor: pointer;
            transition: transform 0.12s ease, background 0.12s ease;
        }

        .wa-emoji-btn:hover {
            transform: scale(1.3);
            background: rgba(255, 255, 255, 0.1);
        }

        :root.light-theme .wa-emoji-btn:hover,
        body.light-theme .wa-emoji-btn:hover {
            background: rgba(0, 0, 0, 0.06);
        }

        .chat-ai-replying-banner {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 10px;
            width: fit-content;
            max-width: min(360px, calc(100% - 34px));
            margin: 8px 16px 18px;
            padding: 10px 13px;
            border-radius: 18px 18px 18px 6px;
            background: linear-gradient(135deg, rgba(32,44,51,0.96), rgba(23,34,40,0.96));
            border: 1px solid rgba(255,255,255,0.07);
            box-shadow: 0 12px 28px rgba(0,0,0,0.16);
            animation: chatAiReplyBannerIn 0.22s ease-out;
        }

        .chat-ai-replying-copy {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
            color: #d8fbe8;
        }

        .chat-ai-replying-copy strong {
            display: block;
            font-size: 12.5px;
            font-weight: 650;
            color: #f4fff8;
            line-height: 1.25;
        }

        .chat-ai-replying-typing {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            margin-left: 2px;
        }

        .chat-ai-replying-typing span {
            width: 4px;
            height: 4px;
            border-radius: 999px;
            background: #25d366;
            opacity: 0.45;
            animation: typing-bounce 1.15s infinite ease-in-out;
        }

        .chat-ai-replying-typing span:nth-child(2) { animation-delay: 0.18s; }
        .chat-ai-replying-typing span:nth-child(3) { animation-delay: 0.36s; }

        :root.light-theme .chat-ai-replying-banner {
            background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(240,247,244,0.96));
            border-color: rgba(17,27,33,0.08);
            box-shadow: 0 12px 28px rgba(17,27,33,0.1);
        }

        :root.light-theme .chat-ai-replying-copy {
            color: #0f5132;
        }

        :root.light-theme .chat-ai-replying-copy strong {
            color: #0b3f27;
        }

        /* Janela de 24h da Meta fechada — aviso colado no campo de digitação.
           Mesma família do banner de IA acima: só a cor muda (âmbar = espera). */
        .chat-meta-janela-banner {
            display: flex;
            align-items: flex-start;
            gap: 12px;
            width: fit-content;
            max-width: min(520px, calc(100% - 34px));
            margin: 8px 16px 18px;
            padding: 12px 14px;
            border-radius: 18px 18px 18px 6px;
            background: linear-gradient(135deg, rgba(60,45,22,0.96), rgba(41,32,18,0.96));
            border: 1px solid rgba(233,162,59,0.28);
            box-shadow: 0 12px 28px rgba(0,0,0,0.16);
            animation: chatAiReplyBannerIn 0.22s ease-out;
        }

        .chat-meta-janela-icone {
            display: flex;
            align-items: center;
            justify-content: center;
            flex: 0 0 auto;
            width: 28px;
            height: 28px;
            border-radius: 999px;
            background: rgba(233,162,59,0.16);
            color: #e9a23b;
            font-size: 13px;
        }

        .chat-meta-janela-copy {
            display: flex;
            flex-direction: column;
            gap: 6px;
            min-width: 0;
            color: #e6d6bb;
        }

        .chat-meta-janela-copy strong {
            font-size: 12.5px;
            font-weight: 650;
            color: #fbe7c6;
            line-height: 1.25;
        }

        .chat-meta-janela-copy span {
            font-size: 12px;
            line-height: 1.45;
        }

        .chat-meta-janela-acoes {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 2px;
        }

        .chat-meta-janela-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 7px 12px;
            border-radius: 10px;
            border: 1px solid transparent;
            background: #e9a23b;
            color: #241a08;
            font-size: 12px;
            font-weight: 650;
            cursor: pointer;
            transition: filter 0.18s ease, background 0.18s ease;
        }

        .chat-meta-janela-btn:hover { filter: brightness(1.08); }

        .chat-meta-janela-btn.secundario {
            background: transparent;
            border-color: rgba(233,162,59,0.4);
            color: #e9a23b;
        }

        /* A saída que entrega: cor do WhatsApp, para o olho achar antes das outras. */
        .chat-meta-janela-btn.destaque {
            background: #25d366;
            color: #04231c;
        }

        /* Aviso preventivo (janela ainda aberta): mesma família, tom mais discreto —
           é lembrete, não problema. */
        .chat-meta-janela-banner.fechando {
            background: linear-gradient(135deg, rgba(38,48,44,0.96), rgba(26,35,32,0.96));
            border-color: rgba(37,211,102,0.24);
        }

        .chat-meta-janela-banner.fechando .chat-meta-janela-icone {
            background: rgba(37,211,102,0.14);
            color: #25d366;
        }

        .chat-meta-janela-banner.fechando .chat-meta-janela-copy { color: #cfe6da; }
        .chat-meta-janela-banner.fechando .chat-meta-janela-copy strong { color: #eafff4; }

        :root.light-theme .chat-meta-janela-banner.fechando {
            background: linear-gradient(135deg, rgba(245,255,250,0.98), rgba(233,248,240,0.98));
            border-color: rgba(16,120,72,0.22);
        }

        :root.light-theme .chat-meta-janela-banner.fechando .chat-meta-janela-copy { color: #2f5f47; }
        :root.light-theme .chat-meta-janela-banner.fechando .chat-meta-janela-copy strong { color: #1d4634; }
        :root.light-theme .chat-meta-janela-banner.fechando .chat-meta-janela-icone { background: rgba(16,120,72,0.12); color: #178a55; }

        .chat-meta-janela-btn.secundario:hover { background: rgba(233,162,59,0.12); }

        /* Mensagem guardada: mesma bolha de enviada, tracejada, sem a cor de
           "entregue" — o atendente vê o que escreveu sem achar que já saiu. */
        .bubble.sent.aguardando-janela {
            background: rgba(233,162,59,0.1) !important;
            border: 1px dashed rgba(233,162,59,0.45);
            opacity: 0.92;
        }

        :root.light-theme .chat-meta-janela-banner {
            background: linear-gradient(135deg, rgba(255,250,241,0.98), rgba(252,242,225,0.98));
            border-color: rgba(180,120,20,0.26);
            box-shadow: 0 12px 28px rgba(17,27,33,0.1);
        }

        :root.light-theme .chat-meta-janela-copy { color: #6b4d19; }
        :root.light-theme .chat-meta-janela-copy strong { color: #4a340d; }
        :root.light-theme .chat-meta-janela-icone { background: rgba(180,120,20,0.14); color: #a9741a; }
        :root.light-theme .chat-meta-janela-btn { background: #b4791a; color: #fff8ec; }
        :root.light-theme .chat-meta-janela-btn.secundario { background: transparent; border-color: rgba(180,120,20,0.4); color: #8a5c11; }
        :root.light-theme .bubble.sent.aguardando-janela {
            background: rgba(180,120,20,0.09) !important;
            border-color: rgba(180,120,20,0.4);
        }

        /* ===================================================================
           CICLO DE VIDA DA MENSAGEM — apagada, editada, reagida (26/08/2026)
           -------------------------------------------------------------------
           A bolha apagada continua sendo uma bolha (mesma coluna, mesmo lado,
           mesma hora): o que muda é o tom. Ela fica esmaecida e tracejada, com
           o aviso em cima e o conteúdo guardado embaixo, rotulado — para
           ninguém confundir o que o painel guardou com o que ainda está na
           conversa do cliente.
           =================================================================== */
        .bubble.bolha-apagada {
            opacity: 0.78;
            border: 1px dashed rgba(148,158,168,0.42);
        }

        .msg-apagada-aviso {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 12.5px;
            font-style: italic;
            color: var(--text-secondary);
        }

        .msg-apagada-aviso i { font-size: 11px; opacity: 0.85; }

        .msg-apagada-original {
            margin-top: 8px;
            padding: 8px 10px;
            border-left: 2px solid rgba(148,158,168,0.4);
            border-radius: 0 8px 8px 0;
            background: rgba(148,158,168,0.09);
            font-size: 13.5px;
            line-height: 1.45;
        }

        .msg-apagada-rotulo {
            display: block;
            margin-bottom: 4px;
            font-size: 10.5px;
            letter-spacing: 0.02em;
            text-transform: uppercase;
            color: var(--text-secondary);
            opacity: 0.85;
        }

        :root.light-theme .bubble.bolha-apagada { border-color: rgba(17,27,33,0.2); }
        :root.light-theme .msg-apagada-original {
            background: rgba(17,27,33,0.05);
            border-left-color: rgba(17,27,33,0.22);
        }

        /* "editada" vive dentro do bloco da hora, à esquerda dela — mesma régua
           do WhatsApp. Fonte um degrau abaixo da hora para não competir. */
        .msg-editada {
            margin-right: 5px;
            font-size: 10.5px;
            font-style: italic;
            opacity: 0.72;
        }

        /* Reações penduradas na borda de baixo da bolha, como no WhatsApp. */
        .msg-reacoes {
            display: flex;
            flex-wrap: wrap;
            gap: 4px;
            margin: 6px -2px -4px;
        }

        .msg-reacao {
            display: inline-flex;
            align-items: center;
            gap: 3px;
            padding: 2px 7px;
            border-radius: 999px;
            background: rgba(17,27,33,0.55);
            border: 1px solid rgba(255,255,255,0.1);
            font-size: 12px;
            line-height: 1.4;
        }

        .msg-reacao b { font-size: 10.5px; font-weight: 600; opacity: 0.85; }

        :root.light-theme .msg-reacao {
            background: rgba(255,255,255,0.94);
            border-color: rgba(17,27,33,0.12);
            box-shadow: 0 2px 6px rgba(17,27,33,0.08);
        }

        .chat-history-status {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            width: fit-content;
            max-width: min(520px, calc(100% - 40px));
            margin: 12px auto 18px;
            padding: 9px 13px;
            border-radius: 999px;
            background: rgba(17,27,33,0.82);
            color: var(--text-secondary);
            font-size: 12px;
            line-height: 1.35;
            text-align: center;
            border: 1px solid rgba(255,255,255,0.08);
            box-shadow: 0 8px 24px rgba(0,0,0,0.18);
        }

        .chat-history-status i {
            color: var(--accent);
            flex: 0 0 auto;
        }

        :root.light-theme .chat-history-status {
            background: rgba(255,255,255,0.92);
            border-color: rgba(17,27,33,0.08);
            box-shadow: 0 8px 22px rgba(17,27,33,0.08);
        }

        @keyframes chatAiReplyBannerIn {
            from { opacity: 0; transform: translateY(8px) scale(0.985); }
            to { opacity: 1; transform: translateY(0) scale(1); }
        }

        .bubble.sent {
            background: var(--bg-bubble-sent);
            align-self: flex-end;
            color: #e9edef;
        }

        :root.light-theme .bubble.sent {
            color: #111b21;
        }

        .bubble.received {
            background: var(--bg-bubble-received);
            align-self: flex-start;
            color: #e9edef;
        }

        :root.light-theme .bubble.received {
            color: #111b21;
        }

        .message-media {
            width: fit-content;
            max-width: 100%;
            margin-bottom: 8px;
        }

        .message-media.audio-media {
            width: 100%;
            min-width: 0;
            margin-bottom: 0;
        }

        .media-download-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            max-width: 100%;
            padding: 10px 12px;
            border: 0;
            border-radius: 12px;
            background: rgba(37, 211, 102, 0.18);
            color: inherit;
            font: inherit;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            transition: opacity 0.2s ease, transform 0.2s ease;
        }

        .media-download-btn:hover:not(:disabled) {
            transform: translateY(-1px);
        }

        .bubble.sent .media-download-btn {
            background: rgba(255, 255, 255, 0.22);
        }

        :root.light-theme .bubble.sent .media-download-btn {
            background: rgba(255, 255, 255, 0.45);
        }

        .media-download-btn:disabled,
        .media-download-btn.is-loading {
            opacity: 0.72;
            cursor: wait;
        }

        .media-download-btn i {
            font-size: 12px;
        }

        .message-media img,
        .message-media video {
            display: block;
            max-width: 100%;
        }

        .message-media-preview {
            border: 0;
            padding: 0;
            background: transparent;
            display: block;
            position: relative;
            cursor: zoom-in;
            color: inherit;
            max-width: 100%;
            width: auto;
        }

        .message-media-preview img,
        .message-media-preview video {
            display: block;
            width: auto;
            min-width: 160px;
            max-width: 280px;
            height: auto;
            min-height: 120px;
            max-height: 320px;
            border-radius: 8px;
            object-fit: cover;
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
            transition: transform 0.18s ease, filter 0.18s ease;
        }

        .message-media-preview.is-sticker img {
            min-width: unset;
            min-height: unset;
            max-width: 140px;
            max-height: 140px;
            object-fit: contain;
            box-shadow: none;
        }

        .message-media-preview:hover img,
        .message-media-preview:hover video {
            transform: translateY(-1px) scale(1.015);
            filter: brightness(1.06);
        }

        .contact-card {
            display: grid;
            gap: 12px;
            min-width: min(320px, 72vw);
            padding: 14px;
            border-radius: 18px;
            border: 1px solid rgba(255,255,255,0.08);
            background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.035));
        }

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

        .contact-card-avatar {
            width: 52px;
            height: 52px;
            border-radius: 16px;
            overflow: hidden;
            flex: 0 0 52px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(255,255,255,0.08);
            color: rgba(255,255,255,0.9);
        }

        .contact-card-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            object-position: center 20%;
            display: block;
        }

        .contact-card-meta {
            min-width: 0;
            display: grid;
            gap: 3px;
        }

        .contact-card-label {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: .12em;
            opacity: .68;
            font-weight: 700;
        }

        .contact-card-name {
            font-size: 15px;
            font-weight: 700;
            line-height: 1.25;
            word-break: break-word;
        }

        .contact-card-phone {
            font-size: 12px;
            opacity: .8;
            word-break: break-word;
        }

        .contact-card-actions {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }

        .contact-card-btn {
            appearance: none;
            border: 0;
            border-radius: 12px;
            padding: 10px 12px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            font-size: 12px;
            font-weight: 700;
            cursor: pointer;
            transition: transform .16s ease, opacity .16s ease, background .16s ease;
        }

        .contact-card-btn:hover {
            transform: translateY(-1px);
        }

        .contact-card-btn.primary {
            background: #00a884;
            color: #fff;
        }

        .contact-card-btn.secondary {
            background: rgba(255,255,255,0.09);
            color: var(--text-main);
        }

        .contact-card-btn:disabled {
            opacity: .6;
            cursor: default;
            transform: none;
        }

        :root.light-theme .contact-card {
            background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(244,247,250,0.92));
            border-color: rgba(15,23,42,0.08);
        }

        :root.light-theme .contact-card-avatar {
            background: rgba(15,23,42,0.06);
            color: #334155;
        }

        :root.light-theme .contact-card-btn.secondary {
            background: rgba(15,23,42,0.06);
            color: #0f172a;
        }

        .message-video-overlay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 10px;
            background: linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.38));
            pointer-events: none;
        }

        .message-video-overlay i {
            width: 46px;
            height: 46px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.62);
            color: #fff;
            font-size: 16px;
            box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38);
        }

        #media-viewer-modal {
            display: none;
            position: fixed;
            inset: 0;
            z-index: 10050;
            align-items: center;
            justify-content: center;
            padding: 28px;
            background: rgba(0, 0, 0, 0.86);
            backdrop-filter: blur(8px);
        }

        #media-viewer-modal.is-open {
            display: flex;
        }

        .media-viewer-shell {
            width: min(1120px, 96vw);
            height: min(720px, 82vh);
            max-height: 92vh;
            display: flex;
            flex-direction: column;
            gap: 12px;
            animation: mediaViewerIn 0.18s ease-out;
        }

        .media-viewer-topbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            color: #fff;
        }

        .media-viewer-title {
            font-size: 13px;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            opacity: 0.78;
        }

        .media-viewer-close {
            border: 0;
            width: 42px;
            height: 42px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.12);
            color: #fff;
            cursor: pointer;
            transition: background 0.18s ease, transform 0.18s ease;
        }

        .media-viewer-close:hover {
            background: rgba(255, 255, 255, 0.22);
            transform: scale(1.04);
        }

        .media-viewer-stage {
            flex: 1 1 auto;
            min-height: 240px;
            max-height: calc(92vh - 64px);
            border: 1px solid rgba(255, 255, 255, 0.12);
            border-radius: 8px;
            background: rgba(12, 18, 22, 0.74);
            box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .media-viewer-stage img,
        .media-viewer-stage video {
            width: 100%;
            height: 100%;
            max-width: 100%;
            max-height: calc(92vh - 86px);
            object-fit: contain;
            display: block;
        }

        .media-viewer-stage video {
            background: #000;
            outline: none;
        }

        .custom-video-player {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            background: #000;
        }

        .custom-video-surface {
            position: relative;
            flex: 1;
            min-height: 320px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #000;
            cursor: pointer;
        }

        .custom-video-player video {
            width: 100%;
            height: 100%;
            max-height: calc(92vh - 160px);
            object-fit: contain;
            background: #000;
        }

        .custom-video-bigplay {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            transition: opacity 0.18s ease;
        }

        .custom-video-bigplay.is-hidden {
            opacity: 0;
        }

        .custom-video-bigplay span {
            width: 72px;
            height: 72px;
            border-radius: 50%;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(0, 0, 0, 0.54);
            color: #fff;
            font-size: 24px;
            box-shadow: 0 18px 32px rgba(0, 0, 0, 0.35);
        }

        .custom-video-controls {
            display: grid;
            grid-template-columns: auto minmax(96px, 120px) 1fr auto auto;
            align-items: center;
            gap: 12px;
            padding: 12px 14px;
            background: rgba(5, 8, 10, 0.96);
            border-top: 1px solid rgba(255, 255, 255, 0.08);
        }

        .custom-video-btn {
            border: 0;
            width: 36px;
            height: 36px;
            border-radius: 8px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background: rgba(255, 255, 255, 0.1);
            color: #fff;
            cursor: pointer;
            transition: background 0.18s ease;
        }

        .custom-video-btn:hover {
            background: rgba(255, 255, 255, 0.18);
        }

        .custom-video-time {
            color: rgba(255, 255, 255, 0.82);
            font-size: 12px;
            font-weight: 600;
            min-width: 90px;
            text-align: center;
        }

        .custom-video-slider {
            width: 100%;
            margin: 0;
            accent-color: var(--accent);
            cursor: pointer;
        }

        .custom-video-volume {
            width: 88px;
        }

        @media (max-width: 720px) {
            .custom-video-controls {
                grid-template-columns: auto 1fr auto;
                grid-template-areas:
                    "play progress fullscreen"
                    "time volume volume";
            }

            .custom-video-controls .custom-video-btn[data-role="play"] { grid-area: play; }
            .custom-video-controls .custom-video-progress { grid-area: progress; }
            .custom-video-controls .custom-video-btn[data-role="fullscreen"] { grid-area: fullscreen; }
            .custom-video-controls .custom-video-time { grid-area: time; text-align: left; min-width: 0; }
            .custom-video-controls .custom-video-volume { grid-area: volume; width: 100%; }
        }

        @keyframes mediaViewerIn {
            from { opacity: 0; transform: scale(0.985) translateY(6px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }

        .audio-message-card {
            width: 100%;
            min-width: 0;
            max-width: 100%;
            padding: 12px 14px;
            border-radius: 14px;
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.08);
            display: flex;
            flex-direction: column;
            gap: 10px;
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
            box-sizing: border-box;
            overflow: hidden;
        }

        .bubble.received .audio-message-card {
            background: rgba(255, 255, 255, 0.04);
        }

        :root.light-theme .bubble.received .audio-message-card {
            background: rgba(17, 27, 33, 0.04);
            border-color: rgba(17, 27, 33, 0.08);
        }

        :root.light-theme .bubble.sent .audio-message-card {
            background: rgba(255, 255, 255, 0.28);
            border-color: rgba(255, 255, 255, 0.22);
        }

        .audio-message-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            min-width: 0;
        }

        .audio-message-meta {
            flex: 1;
            min-width: 0;
        }

        .audio-message-title {
            font-size: 13px;
            font-weight: 700;
            line-height: 1.2;
        }

        .audio-message-hint {
            font-size: 11px;
            opacity: 0.75;
            margin-top: 3px;
        }

        .audio-status-badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 4px 8px;
            border-radius: 999px;
            font-size: 9.5px;
            font-weight: 700;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            background: rgba(37, 211, 102, 0.14);
            color: var(--accent);
            white-space: nowrap;
            flex-shrink: 0;
        }

        .bubble.sent .audio-status-badge {
            background: rgba(255, 255, 255, 0.18);
            color: #fff;
        }

        :root.light-theme .bubble.sent .audio-status-badge {
            background: rgba(15, 81, 50, 0.14);
            color: #0f5132;
        }

        .custom-audio-player {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .custom-audio-player audio {
            display: none;
        }

        .audio-player-controls {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .audio-play-btn {
            width: 42px;
            height: 42px;
            border: 0;
            border-radius: 50%;
            display: grid;
            place-items: center;
            flex: 0 0 42px;
            background: linear-gradient(135deg, var(--accent), #2bd9b0);
            color: #05231d;
            cursor: pointer;
            box-shadow: 0 10px 22px rgba(37, 211, 102, 0.24);
            transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
        }

        .audio-play-btn:hover {
            transform: translateY(-1px) scale(1.01);
            box-shadow: 0 12px 24px rgba(37, 211, 102, 0.3);
        }

        .audio-play-btn.is-playing {
            background: linear-gradient(135deg, #fefefe, #d8fff1);
        }

        .audio-play-btn.is-download {
            background: linear-gradient(135deg, rgba(37, 211, 102, 0.18), rgba(43, 217, 176, 0.26));
            color: var(--accent);
            box-shadow: none;
        }

        .bubble.sent .audio-play-btn.is-download {
            background: rgba(255,255,255,0.18);
            color: #fff;
        }

        .bubble.sent .audio-play-btn {
            background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(236,255,248,0.92));
            color: #0f5132;
        }

        .audio-play-btn:disabled {
            opacity: 0.6;
            cursor: wait;
            transform: none;
            box-shadow: none;
        }

        .audio-track-wrap {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 6px;
            overflow: visible !important;
            padding-top: 4px;
        }

        .audio-progress {
            --audio-progress: 0%;
            width: 100%;
            height: 6px;
            margin: 4px 0;
            appearance: none;
            -webkit-appearance: none;
            border-radius: 999px;
            outline: none;
            background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--audio-progress), rgba(255,255,255,0.18) var(--audio-progress), rgba(255,255,255,0.18) 100%);
            cursor: pointer;
            overflow: visible !important;
        }

        .bubble.sent .audio-progress {
            background: linear-gradient(90deg, #ffffff 0%, #ffffff var(--audio-progress), rgba(255,255,255,0.24) var(--audio-progress), rgba(255,255,255,0.24) 100%);
        }

        :root.light-theme .bubble.received .audio-progress {
            background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--audio-progress), rgba(17,27,33,0.12) var(--audio-progress), rgba(17,27,33,0.12) 100%);
        }

        :root.light-theme .bubble.sent .audio-progress {
            background: linear-gradient(90deg, #0f5132 0%, #0f5132 var(--audio-progress), rgba(15,81,50,0.14) var(--audio-progress), rgba(15,81,50,0.14) 100%);
        }

        .audio-progress::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #fff;
            border: 2px solid var(--accent);
            box-shadow: 0 2px 8px rgba(0,0,0,0.22);
            cursor: pointer;
            position: relative;
            z-index: 2;
        }

        .audio-progress::-moz-range-thumb {
            width: 14px;
            height: 14px;
            border-radius: 50%;
            background: #fff;
            border: 2px solid var(--accent);
            box-shadow: 0 2px 8px rgba(0,0,0,0.22);
            cursor: pointer;
        }

        .audio-progress::-moz-range-track {
            height: 6px;
            border-radius: 999px;
            background: transparent;
        }

        .audio-time-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            font-size: 11px;
            opacity: 0.82;
            font-variant-numeric: tabular-nums;
            min-width: 0;
        }

        .audio-loading-player {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .audio-placeholder-wave {
            display: grid;
            grid-template-columns: repeat(24, minmax(4px, 1fr));
            gap: 4px;
            align-items: end;
            height: 34px;
        }

        .audio-placeholder-bar {
            border-radius: 999px;
            background: rgba(255,255,255,0.2);
            min-height: 6px;
        }

        .audio-placeholder-wave.is-digifood-thinking .audio-placeholder-bar,
        .audio-transcription-wave .audio-placeholder-bar {
            background: linear-gradient(180deg, rgba(37,211,102,0.95), rgba(43,217,176,0.36));
            transform-origin: center bottom;
            animation: digifoodAudioThinking 1.05s ease-in-out infinite;
            box-shadow: 0 0 14px rgba(37,211,102,0.16);
        }

        .audio-placeholder-wave.is-digifood-thinking .audio-placeholder-bar:nth-child(3n),
        .audio-transcription-wave .audio-placeholder-bar:nth-child(3n) {
            animation-delay: -0.24s;
        }

        /* ─── Uso e custos da IA (aba Inteligência Artificial) ──────────────────
           Painel único de consumo: respostas, tokens, dinheiro e limites. Só tokens
           do design system aqui — a tela é validada no tema escuro E no claro, e
           cor fixa neste painel já vazou para o tema errado antes. */
        .uso-ia {
            display: flex;
            flex-direction: column;
            gap: 16px;
            margin: 0 0 20px;
            padding: 16px;
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: var(--r-md);
        }

        .uso-ia.is-carregando { opacity: .55; }

        .uso-ia__topo {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            flex-wrap: wrap;
        }

        .uso-ia__identidade { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }

        .uso-ia__selo {
            font-size: 12px;
            font-weight: 700;
            color: var(--text-main);
            background: var(--accent-subtle);
            border: 1px solid var(--accent-border);
            border-radius: var(--r-full);
            padding: 4px 12px;
        }

        .uso-ia__modelo {
            font-family: var(--font-mono);
            font-size: 11px;
            color: var(--text-secondary);
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: var(--r-full);
            padding: 3px 10px;
        }

        .uso-ia__acoes { display: flex; align-items: center; gap: 10px; min-width: 0; }

        .uso-ia__conta {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            max-width: 260px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .uso-ia__conta i { color: var(--accent); }

        .uso-ia__botao {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 7px 13px;
            font-size: 12px;
            font-weight: 600;
            font-family: var(--font-sans);
            color: var(--text-main);
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: var(--r-sm);
            cursor: pointer;
            transition: border-color .18s ease, color .18s ease;
        }

        .uso-ia__botao:hover { border-color: var(--accent-border); background: var(--accent-subtle); }

        .uso-ia__cartoes {
            display: grid;
            /* 148 e nao 168: com 168 os quatro cartoes nao cabiam na largura real da
               area de configuracoes (medido: 700px uteis) e o de tokens caia sozinho
               numa segunda linha, deixando um vazio do tamanho de dois cartoes. */
            grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
            gap: 12px;
        }

        .uso-ia__cartao {
            display: flex;
            flex-direction: column;
            gap: 4px;
            min-width: 0;
            padding: 12px 14px;
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: var(--r-sm);
        }

        .uso-ia__cartao.is-dinheiro { border-color: var(--accent-border); background: var(--accent-subtle); }

        .uso-ia__rotulo {
            font-size: 11px;
            font-weight: 600;
            letter-spacing: .4px;
            text-transform: uppercase;
            color: var(--text-secondary);
        }

        .uso-ia__valor {
            font-size: 22px;
            font-weight: 700;
            line-height: 1.15;
            color: var(--text-main);
            font-variant-numeric: tabular-nums;
        }

        .uso-ia__nota { font-size: 11px; line-height: 1.45; color: var(--text-secondary); }

        .uso-ia__barras {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
            gap: 16px;
        }

        .uso-ia__barra-topo {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 6px;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .uso-ia__barra-topo strong { color: var(--text-main); font-variant-numeric: tabular-nums; }

        .uso-ia__trilho {
            height: 8px;
            overflow: hidden;
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: var(--r-full);
        }

        .uso-ia__preenche {
            width: 0;
            height: 100%;
            border-radius: var(--r-full);
            background: linear-gradient(90deg, #22c55e, var(--accent));
            transition: width .25s ease;
        }

        /* 80% do teto é onde ainda dá tempo de reagir; estouro é vermelho cheio. */
        .uso-ia__preenche.is-alerta { background: linear-gradient(90deg, #f59e0b, #ef4444); }
        .uso-ia__preenche.is-estouro { background: linear-gradient(90deg, #ef4444, #b91c1c); }

        .uso-ia__barra-bloco .uso-ia__nota { display: block; margin-top: 6px; }

        .uso-ia__grafico-topo {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 10px;
            font-size: 12px;
            font-weight: 600;
            color: var(--text-main);
        }

        .uso-ia__colunas {
            display: flex;
            align-items: flex-end;
            gap: 6px;
            height: 96px;
        }

        .uso-ia__coluna {
            display: flex;
            flex: 1;
            flex-direction: column;
            align-items: center;
            justify-content: flex-end;
            gap: 6px;
            height: 100%;
            min-width: 0;
        }

        .uso-ia__haste {
            width: 100%;
            max-width: 26px;
            min-height: 2px;
            border-radius: var(--r-xs) var(--r-xs) 0 0;
            background: linear-gradient(180deg, var(--accent), rgba(var(--accent-rgb), .35));
        }

        .uso-ia__coluna.is-hoje .uso-ia__haste { background: linear-gradient(180deg, var(--brand-blue), rgba(56, 189, 248, .35)); }

        .uso-ia__dia { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

        .uso-ia__detalhes {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
            gap: 12px;
        }

        .uso-ia__detalhe {
            display: flex;
            flex-direction: column;
            gap: 3px;
            padding: 10px 12px;
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: var(--r-sm);
        }

        .uso-ia__detalhe-valor { font-size: 14px; font-weight: 600; color: var(--text-main); }

        .uso-ia__aviso {
            padding: 12px 14px;
            font-size: 12.5px;
            line-height: 1.55;
            color: var(--text-main);
            background: var(--brand-amber-subtle);
            border: 1px solid rgba(245, 158, 11, .28);
            border-radius: var(--r-sm);
        }

        .uso-ia__aviso.is-grave { background: var(--brand-rose-subtle); border-color: rgba(244, 63, 94, .3); }

        /* Limites do plano (29/08/2026) — só leitura, no lugar do antigo campo de teto.
           Reaproveita os tokens e a grade dos cartões de cima em vez de inventar escala. */
        .uso-ia__plano {
            display: flex;
            flex-direction: column;
            gap: 10px;
            padding-top: 14px;
            border-top: 1px solid var(--border);
        }

        .uso-ia__plano-titulo {
            font-size: 12px;
            font-weight: 600;
            letter-spacing: .04em;
            text-transform: uppercase;
            color: var(--text-muted);
        }

        .uso-ia__plano-grade {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
            gap: 12px;
        }

        .uso-ia__plano-item {
            display: flex;
            flex-direction: column;
            gap: 3px;
            padding: 10px 12px;
            background: var(--bg-main);
            border: 1px solid var(--border);
            border-radius: var(--r-sm);
        }

        .uso-ia__plano-item strong { font-size: 15px; font-weight: 600; color: var(--text-main); }

        .uso-ia__teto { padding-top: 14px; border-top: 1px solid var(--border); }

        .uso-ia__teto summary {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-main);
            cursor: pointer;
            list-style: none;
        }

        .uso-ia__teto summary::-webkit-details-marker { display: none; }
        .uso-ia__teto summary i { color: var(--accent); }

        .uso-ia__teto-campos {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
            gap: 12px;
            margin: 14px 0 8px;
        }

        .uso-ia__campo {
            display: flex;
            flex-direction: column;
            gap: 6px;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .uso-ia__campo input[type="number"],
        .uso-ia__campo select {
            padding: 8px 10px;
            font-family: var(--font-sans);
            font-size: 13px;
            color: var(--text-main);
            background: var(--bg-input);
            border: 1px solid var(--border);
            border-radius: var(--r-sm);
        }

        .uso-ia__campo.is-switch { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }

        .uso-ia__teto-acoes { margin-top: 12px; text-align: right; }

        @media (max-width: 720px) {
            .uso-ia { padding: 14px; gap: 14px; }
            .uso-ia__valor { font-size: 19px; }
            .uso-ia__colunas { height: 72px; gap: 4px; }
            .uso-ia__conta { max-width: 100%; }
            .uso-ia__acoes { width: 100%; justify-content: space-between; }
        }

/* ==========================================================================
   DADOS DO CONTATO - WHATSAPP WEB NATIVE REDESIGN
   ========================================================================== */

.contact-details-panel {
    position: absolute;
    top: 0;
    right: -460px;
    width: 440px;
    height: 100%;
    background: var(--bg-main, #111b21);
    border-left: 1px solid var(--border, #222d34);
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.contact-details-panel.open {
    right: 0;
}

/* WhatsApp Drawer Header */
.cd-header {
    height: 60px;
    min-height: 60px;
    background: var(--bg-header, #202c33);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border, #222d34);
    z-index: 10;
}

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

.cd-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #e9edef);
}

.cd-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #8696a0);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s ease, color 0.15s ease;
}

.cd-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e9edef);
}

/* Drawer Scrollable Body */
.cd-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 14px 40px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cd-body::-webkit-scrollbar {
    width: 6px;
}

.cd-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Native WhatsApp Cards */
.cd-card {
    background: var(--bg-card, #1e1e1e);
    border: 1px solid var(--border, #2a2a2a);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* Hero Card (Avatar, Name, Quick Actions) */
.cd-hero-card {
    padding: 24px 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: linear-gradient(180deg, var(--bg-card, #1e1e1e) 0%, rgba(30,30,30,0.85) 100%);
}

.cd-avatar-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    margin-bottom: 14px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.cd-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 3px solid rgba(255, 255, 255, 0.08);
}

.cd-avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a3942, #182229);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8696a0;
    font-size: 56px;
    border: 3px solid rgba(255, 255, 255, 0.06);
}

.cd-hero-info {
    width: 100%;
    margin-bottom: 18px;
}

.cd-name-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    max-width: 100%;
}

.cd-contact-name {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    line-height: 1.3;
    word-break: break-word;
    cursor: pointer;
}

.cd-edit-inline-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #8696a0);
    font-size: 13px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
}

.cd-edit-inline-btn:hover {
    color: var(--accent, #00a884);
    background: rgba(255, 255, 255, 0.06);
}

.cd-name-edit-box {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px auto 4px;
    max-width: 320px;
}

.cd-name-input {
    flex: 1;
    background: var(--bg-input, #121212);
    border: 1px solid var(--accent, #00a884);
    color: var(--text-primary, #ffffff);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    outline: none;
}

.cd-name-save-btn,
.cd-name-cancel-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
}

.cd-name-save-btn {
    background: var(--accent, #00a884);
    color: #ffffff;
}

.cd-name-cancel-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary, #8696a0);
}

.cd-contact-phone {
    font-size: 14px;
    color: var(--text-secondary, #8696a0);
    margin-top: 4px;
}

.cd-whatsapp-name-badge {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: var(--accent, #00a884);
    background: rgba(0, 168, 132, 0.1);
    padding: 2px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0, 168, 132, 0.2);
}

/* Quick Action Circle Buttons (WhatsApp Web Native) */
.cd-quick-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    width: 100%;
    padding-top: 6px;
}

.cd-quick-btn {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-secondary, #8696a0);
    font-size: 11px;
    font-weight: 500;
    transition: transform 0.15s ease, color 0.15s ease;
}

.cd-quick-btn:hover {
    color: var(--accent, #00a884);
    transform: translateY(-2px);
}

.cd-quick-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: var(--text-primary, #e9edef);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.cd-quick-btn:hover .cd-quick-icon {
    background: rgba(0, 168, 132, 0.15);
    border-color: rgba(0, 168, 132, 0.4);
    color: var(--accent, #00a884);
}

/* Card Sections & Common Headers */
.cd-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cd-card-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cd-card-icon {
    font-size: 14px;
    color: var(--text-secondary, #8696a0);
}

.cd-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #8696a0);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cd-card-section {
    padding: 4px 0;
}

.cd-section-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #8696a0);
    margin-bottom: 4px;
}

.cd-about-text {
    font-size: 14px;
    color: var(--text-primary, #e9edef);
    line-height: 1.5;
    word-break: break-word;
}

.cd-phone-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cd-phone-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #e9edef);
}

.cd-copy-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary, #8696a0);
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.cd-copy-btn:hover {
    color: var(--accent, #00a884);
    background: rgba(255, 255, 255, 0.06);
}

.cd-info-text {
    font-size: 14px;
    color: var(--text-primary, #e9edef);
}

.cd-card-divider {
    height: 1px;
    background: var(--border, rgba(255, 255, 255, 0.06));
    margin: 10px 0;
}

.cd-text-btn {
    background: transparent;
    border: none;
    color: var(--accent, #00a884);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: opacity 0.15s ease;
}

.cd-text-btn:hover {
    opacity: 0.8;
}

/* Mídia, Links e Docs Card */
.cd-media-card .cd-card-header {
    cursor: pointer;
    margin-bottom: 8px;
}

.cd-card-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cd-counter-badge {
    font-size: 12px;
    color: var(--text-secondary, #8696a0);
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 8px;
    border-radius: 12px;
}

.cd-chevron {
    font-size: 11px;
    color: var(--text-secondary, #8696a0);
}

.cd-media-preview-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 6px;
}

.cd-media-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.cd-media-thumb:hover {
    transform: scale(1.04);
    border-color: var(--accent, #00a884);
}

.cd-media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cd-media-thumb.is-video {
    background: #182229;
    color: #ffffff;
}

.cd-media-play-icon {
    font-size: 18px;
    opacity: 0.9;
}

.cd-media-thumb.is-doc {
    background: rgba(56, 189, 248, 0.1);
    color: var(--brand-blue, #38bdf8);
    font-size: 20px;
}

.cd-media-empty {
    font-size: 12px;
    color: var(--text-secondary, #8696a0);
    font-style: italic;
    padding: 6px 0;
    grid-column: 1 / -1;
}

/* Labels Section */
.cd-label-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 24px;
}

.cd-label-row:empty::before {
    content: "Nenhuma etiqueta aplicada";
    font-size: 12px;
    color: var(--text-secondary, #8696a0);
    font-style: italic;
}

/* CTWA / Meta Ad Card */
.cd-tag-pill {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--brand-blue, #38bdf8);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.cd-ad-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cd-ad-row {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}

.cd-ad-row-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #8696a0);
    margin-bottom: 3px;
}

.cd-ad-row-val {
    font-size: 13px;
    color: var(--text-primary, #e9edef);
    line-height: 1.45;
}

/* CRM / Intelligence Section */
.cd-crm-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.cd-metric-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #e9edef);
}

.cd-metric-chip.temp-quente {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.3);
    color: #fb7185;
}

.cd-metric-chip.temp-morno {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fbbf24;
}

.cd-metric-chip.temp-frio {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.3);
    color: #38bdf8;
}

.cd-metric-chip.stage-chip {
    background: rgba(0, 168, 132, 0.12);
    border-color: rgba(0, 168, 132, 0.3);
    color: var(--accent, #00a884);
}

.cd-next-action-box {
    background: linear-gradient(135deg, rgba(0, 168, 132, 0.1), rgba(0, 168, 132, 0.04));
    border: 1px solid rgba(0, 168, 132, 0.25);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.cd-next-action-icon {
    color: var(--accent, #00a884);
    font-size: 14px;
    margin-top: 2px;
    flex-shrink: 0;
}

.cd-next-action-body {
    flex: 1;
}

.cd-next-action-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent, #00a884);
    font-weight: 700;
    margin-bottom: 2px;
}

.cd-next-action-text {
    font-size: 13px;
    color: var(--text-primary, #e9edef);
    line-height: 1.4;
    font-weight: 500;
}

.cd-crm-ficha {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cd-ficha-row {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 10px;
}

.cd-ficha-row-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary, #8696a0);
    font-weight: 600;
    margin-bottom: 2px;
}

.cd-ficha-row-val {
    font-size: 12.5px;
    color: var(--text-primary, #e9edef);
    line-height: 1.45;
}

.cd-notes-editor-box {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

.cd-editor-hint {
    font-size: 11px;
    color: var(--text-secondary, #8696a0);
    margin-bottom: 8px;
}

.cd-notes-textarea {
    width: 100%;
    height: 140px;
    background: var(--bg-input, #121212);
    border: 1px solid var(--border, #2a2a2a);
    color: var(--text-primary, #ffffff);
    padding: 10px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}

.cd-notes-textarea:focus {
    border-color: var(--accent, #00a884);
}

.cd-editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.cd-save-notes-btn {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
}

.cd-cancel-notes-btn {
    background: transparent;
    border: 1px solid var(--border, #2a2a2a);
    color: var(--text-secondary, #8696a0);
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
}

/* Appointments Section */
.cd-appointments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.cd-app-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border, #2a2a2a);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cd-app-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary, #e9edef);
}

.cd-app-service {
    font-size: 11px;
    color: var(--text-secondary, #8696a0);
}

.cd-app-delete-btn {
    background: transparent;
    border: none;
    color: #f43f5e;
    cursor: pointer;
    font-size: 11px;
    padding: 4px;
}

/* Footer Actions Card (WhatsApp Native) */
.cd-actions-card {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cd-action-row {
    background: transparent;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary, #e9edef);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: background 0.15s ease;
}

.cd-action-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.cd-action-row.is-danger {
    color: #f43f5e;
}

.cd-action-row.is-danger:hover {
    background: rgba(244, 63, 94, 0.1);
}

.cd-action-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--text-secondary, #8696a0);
}

.cd-action-row.is-danger .cd-action-icon {
    color: #f43f5e;
}

/* Light Theme Overrides */
html.light-theme .contact-details-panel {
    background: #f0f2f5;
    border-left-color: #d1d7db;
    box-shadow: -4px 0 20px rgba(11, 20, 26, 0.08);
}

html.light-theme .cd-header {
    background: #ffffff;
    border-bottom-color: #e9edef;
}

html.light-theme .cd-card {
    background: #ffffff;
    border-color: #e9edef;
    box-shadow: 0 1px 3px rgba(11, 20, 26, 0.06);
}

html.light-theme .cd-hero-card {
    background: #ffffff;
}

html.light-theme .cd-avatar-fallback {
    background: #e9edef;
    color: #667781;
}

html.light-theme .cd-quick-icon {
    background: #f0f2f5;
    border-color: #e9edef;
    color: #111b21;
}

html.light-theme .cd-quick-btn:hover .cd-quick-icon {
    background: #d9fdd3;
    border-color: var(--accent, #00a884);
}

html.light-theme .cd-card-divider {
    background: #e9edef;
}

html.light-theme .cd-media-thumb {
    background: #f0f2f5;
    border-color: #e9edef;
}

html.light-theme .cd-counter-badge {
    background: #f0f2f5;
    color: #4d5c66;   /* #667781 sobre #f0f2f5 dava 4,14:1; o mínimo é 4,5:1 */
}

html.light-theme .cd-action-row:hover {
    background: #f5f6f6;
}


/* =========================================================================
   ANEL DA JANELA DE CONTEXTO (30/08/2026)
   -------------------------------------------------------------------------
   Cada conversa da lista mostra o tamanho do prompt que a ULTIMA mensagem dela
   mandou ao modelo. Cores por TOKENS, nao por % da janela: a janela e de 1M e a
   conversa comum usa 2%, entao pintar pela % deixaria tudo verde — inclusive as
   conversas caras, que sao justamente o que se quer enxergar.

   Todas as cores saem de token de tema e foram medidas nos DOIS temas contra o
   fundo real da lista (>= 4,5:1 para texto, >= 3:1 para o arco).
   ========================================================================= */
:root {
    --ctx-normal: #00a884;
    --ctx-atencao: #d97706;
    --ctx-critico: #d13438;
    --ctx-trilho: rgba(255, 255, 255, 0.14);
    --ctx-rotulo: #aaaaaa;
    --ctx-persona: #2389c7;
    --ctx-historico: #00a884;
    --ctx-crm: #d97706;
    --ctx-agenda: #9b6bd1;
}

html.light-theme {
    /* #00a884 como TEXTO da 3,03:1 no fundo claro (medido em 26/08/2026); o
       arco e preenchimento, entao passa em 3:1, mas o rotulo ao lado dele nao —
       por isso o rotulo usa --text-secondary e nunca a cor da faixa. */
    --ctx-normal: #00806a;
    --ctx-atencao: #a35c05;
    --ctx-critico: #b3282c;
    --ctx-trilho: rgba(17, 27, 33, 0.12);
    --ctx-rotulo: #4e5f68;
    --ctx-persona: #1b6f9f;
}

.ctx-anel {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    line-height: 1;
    border-radius: 999px;
    padding: 1px 3px 1px 1px;
    transition: background 0.15s ease;
}

.ctx-anel:hover,
.ctx-anel:focus-visible {
    background: rgba(127, 127, 127, 0.14);
    outline: none;
}

.ctx-anel svg {
    display: block;
    transform: rotate(-90deg); /* o arco comeca no topo, nao na direita */
    flex: none;
}

.ctx-anel .ctx-trilho {
    fill: none;
    stroke: var(--ctx-trilho);
    stroke-width: 2.5;
}

.ctx-anel .ctx-arco {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke: var(--ctx-normal);
}

.ctx-anel.ctx-atencao .ctx-arco { stroke: var(--ctx-atencao); }
.ctx-anel.ctx-critico .ctx-arco { stroke: var(--ctx-critico); }

.ctx-anel .ctx-rotulo {
    font-size: 10px;
    font-variant-numeric: tabular-nums; /* o numero nao dança quando muda */
    color: var(--ctx-rotulo);
    letter-spacing: -0.2px;
}

/* No celular a linha da lista ja e apertada (regra de 20/08): so o anel, sem o
   numero ao lado. O balao continua contando tudo. */
@media (max-width: 960px) {
    .ctx-anel .ctx-rotulo { display: none; }
}

/* ---- o detalhe, dentro do Swal ---- */
.ctx-detalhe {
    text-align: left;
    font-size: 13px;
    color: var(--text-main);
}

.ctx-detalhe .ctx-topo {
    font-size: 15px;
    margin-bottom: 10px;
}

.ctx-detalhe .ctx-topo strong { font-size: 22px; }

.ctx-detalhe .ctx-de {
    color: var(--text-secondary);
    font-size: 12px;
    margin-left: 4px;
}

.ctx-detalhe .ctx-barra {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--ctx-trilho);
}

.ctx-detalhe .ctx-barra span { display: block; height: 100%; }

.ctx-detalhe .ctx-linha {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.ctx-detalhe .ctx-cor {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex: none;
}

.ctx-detalhe .ctx-nome { flex: 1; }

.ctx-detalhe .ctx-num,
.ctx-detalhe .ctx-pct {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    font-size: 12px;
}

.ctx-detalhe .ctx-pct { width: 46px; text-align: right; }

.ctx-detalhe .ctx-rodape {
    margin-top: 12px;
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}
