/* Chatbot do CRM NC (gerado em Chatbot do CRM). Ao recolar o código do CRM, o <style> vem para cá. */
  #crm-chatbot-toggle, #crm-chat-bubble, #crm-chatbot-window {
    --crm-cor: #1c24f2; --crm-cor-escura: #0000cc; --crm-texto-cor: #FFFFFF;
    --crm-texto: #1f2937; --crm-suave: #6b7280; --crm-borda: #e5e7eb; --crm-fundo: #f6f7f9; --crm-verde: #22c55e;
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif; box-sizing: border-box;
  }
  #crm-chatbot-window *, #crm-chat-bubble * { box-sizing: border-box; }
  /* Blindagem contra o CSS do tema/Elementor do site: mesma tipografia em todos os sites */
  #crm-chatbot-toggle, #crm-chatbot-window button, #crm-chatbot-window input, #crm-chat-bubble button {
    font-family: inherit !important; letter-spacing: normal !important; text-transform: none !important;
    text-decoration: none !important; min-width: 0 !important; min-height: 0 !important; margin: 0;
    text-shadow: none !important;
  }
  #crm-chatbot-window p, #crm-chat-bubble p { margin: 0; }
  #crm-chatbot-toggle {
    position: fixed; right: 24px; bottom: 24px; z-index: 99999;
    width: 64px; height: 64px; padding: 0; border: 3px solid #fff; border-radius: 50%;
    background: var(--crm-cor); cursor: pointer; overflow: visible;
    box-shadow: 0 8px 24px rgb(17 24 39 / .28);
    transition: transform .2s ease, box-shadow .2s ease; animation: crmPulse 2.4s infinite;
  }
  #crm-chatbot-toggle img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
  #crm-chatbot-toggle:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgb(17 24 39 / .32); }
  #crm-chatbot-toggle .crm-online { position: absolute; right: 1px; bottom: 3px; }
  .crm-online { width: 14px; height: 14px; border-radius: 50%; background: var(--crm-verde); border: 2px solid #fff; display: block; }
  @keyframes crmPulse {
    0% { box-shadow: 0 0 0 0 #1c24f273, 0 8px 24px rgb(17 24 39 / .28); }
    70% { box-shadow: 0 0 0 16px #1c24f200, 0 8px 24px rgb(17 24 39 / .28); }
    100% { box-shadow: 0 0 0 0 #1c24f200, 0 8px 24px rgb(17 24 39 / .28); }
  }

  #crm-chat-bubble {
    position: fixed; right: 24px; bottom: 100px; z-index: 99998;
    display: flex; align-items: flex-start; gap: 10px; max-width: 290px;
    padding: 14px 34px 14px 14px; background: #fff; color: var(--crm-texto);
    border-radius: 16px 16px 4px 16px; box-shadow: 0 10px 30px rgb(17 24 39 / .18);
    cursor: pointer; font-size: 14px !important; line-height: 1.45; animation: crmBubbleIn .35s ease;
  }
  #crm-chat-bubble[hidden] { display: none; }
  #crm-chat-bubble img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
  #crm-chat-bubble p { margin: 0; }
  #crm-chat-bubble strong { display: block; font-size: 13px; color: var(--crm-cor-escura); }
  #crm-chat-bubble .crm-bubble-close {
    position: absolute; top: 6px; right: 8px; width: 24px; height: 24px; padding: 0;
    background: none; border: 0; border-radius: 50%; color: #9ca3af; font-size: 18px; line-height: 1; cursor: pointer;
  }
  #crm-chat-bubble .crm-bubble-close:hover { background: var(--crm-fundo); color: var(--crm-texto); }
  @keyframes crmBubbleIn { from { opacity: 0; transform: translateY(10px) scale(.95); } to { opacity: 1; transform: none; } }

  #crm-chatbot-window {
    display: none; position: fixed; right: 24px; bottom: 100px; z-index: 99999;
    width: 380px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 128px);
    flex-direction: column; overflow: hidden; background: #fff; border-radius: 20px;
    box-shadow: 0 24px 64px rgb(17 24 39 / .28); animation: crmChatSlideUp .28s ease;
  }
  #crm-chatbot-window.open { display: flex; }
  @keyframes crmChatSlideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

  .crm-chat-header {
    display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 18px;
    background: linear-gradient(135deg, var(--crm-cor) 0%, var(--crm-cor-escura) 100%); color: var(--crm-texto-cor);
  }
  .crm-chat-header-avatar { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
  .crm-chat-header-avatar img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid rgb(255 255 255 / .85); display: block; }
  .crm-chat-header-avatar .crm-online { position: absolute; right: -1px; bottom: 0; width: 12px; height: 12px; }
  .crm-chat-header-info { min-width: 0; }
  .crm-chat-header-info strong { display: block; margin: 0; font-size: 16px !important; font-weight: 600; color: var(--crm-texto-cor) !important; line-height: 1.2; }
  .crm-chat-header-info span { display: block; margin-top: 2px; font-size: 12px !important; line-height: 1.3; color: var(--crm-texto-cor) !important; opacity: .9; }
  .crm-chat-close {
    margin-left: auto; width: 34px; height: 34px; padding: 0; flex-shrink: 0;
    background: rgb(255 255 255 / .15); border: 0; border-radius: 50%; color: var(--crm-texto-cor);
    font-size: 22px; line-height: 1; cursor: pointer; transition: background .2s;
  }
  .crm-chat-close:hover { background: rgb(255 255 255 / .3) !important; color: var(--crm-texto-cor) !important; }

  .crm-chat-messages {
    flex: 1; overflow-y: auto; padding: 18px 16px; background: var(--crm-fundo);
    display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth;
  }
  .crm-chat-msg {
    position: relative; max-width: 80%; padding: 10px 14px; border-radius: 16px;
    font-size: 14px !important; line-height: 1.5 !important; font-weight: 400; color: var(--crm-texto); word-wrap: break-word; animation: crmMsgIn .2s ease;
  }
  @keyframes crmMsgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
  .crm-chat-msg.bot {
    align-self: flex-start; margin-left: 34px; background: #fff; border: 1px solid var(--crm-borda);
    border-bottom-left-radius: 4px; box-shadow: 0 1px 2px rgb(17 24 39 / .04);
  }
  .crm-chat-msg.bot::before {
    content: ''; position: absolute; left: -34px; bottom: 0; width: 26px; height: 26px; border-radius: 50%;
    background: url(https://crm.nationcorretora.com.br/chatbot-avatar.webp) center / cover no-repeat;
  }
  .crm-chat-msg.user { align-self: flex-end; background: var(--crm-cor); color: var(--crm-texto-cor); border-bottom-right-radius: 4px; }
  .crm-chat-msg.typing { font-size: 0 !important; padding: 12px 16px; }
  .crm-chat-msg.typing::after {
    content: ''; display: block; width: 34px; height: 8px;
    background: radial-gradient(circle 4px, #9ca3af 95%, transparent) 0 50% / 8px 8px no-repeat,
      radial-gradient(circle 4px, #9ca3af 95%, transparent) 13px 50% / 8px 8px no-repeat,
      radial-gradient(circle 4px, #9ca3af 95%, transparent) 26px 50% / 8px 8px no-repeat;
    animation: crmTyping 1s infinite ease-in-out;
  }
  @keyframes crmTyping { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

  .crm-chat-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-self: stretch; margin-left: 34px; padding: 2px 0; }
  .crm-chat-option-btn {
    padding: 9px 10px; border: 1.5px solid var(--crm-cor); border-radius: 12px; background: #fff;
    color: var(--crm-cor-escura); font-size: 13px !important; font-weight: 500 !important; line-height: 1.3 !important;
    white-space: normal !important; word-break: normal; overflow-wrap: anywhere; width: auto; height: auto;
    box-shadow: none; text-align: center; cursor: pointer;
    transition: background .15s, color .15s, transform .15s;
  }
  .crm-chat-option-btn:hover, .crm-chat-option-btn:focus-visible { background: var(--crm-cor); color: var(--crm-texto-cor); transform: translateY(-1px); outline: none; }

  .crm-chat-input-area { display: flex; gap: 8px; padding: 12px 14px; background: #fff; border-top: 1px solid var(--crm-borda); }
  .crm-chat-input-area input {
    flex: 1; min-width: 0; height: auto; padding: 11px 16px; border: 1.5px solid var(--crm-borda); border-radius: 24px;
    font-size: 16px !important; line-height: 1.3 !important; box-shadow: none; color: var(--crm-texto); background: var(--crm-fundo); outline: none; transition: border-color .2s, background .2s;
  }
  .crm-chat-input-area input:focus { border-color: var(--crm-cor); background: #fff; }
  .crm-chat-input-area button {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
    background: var(--crm-cor); color: var(--crm-texto-cor); cursor: pointer;
    box-shadow: 0 4px 12px #1c24f259; transition: background .2s, transform .2s;
  }
  .crm-chat-input-area button:hover { background: var(--crm-cor-escura); transform: scale(1.05); }
  .crm-chat-input-area button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

  .crm-chat-whatsapp { display: none; padding: 14px 16px; background: #fff; border-top: 1px solid var(--crm-borda); text-align: center; }
  .crm-chat-whatsapp a {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    padding: 12px 20px; border-radius: 24px; background: #25d366; color: #fff; text-decoration: none;
    font-weight: 600; font-size: 15px !important; box-shadow: 0 4px 12px rgb(37 211 102 / .35);
  }
  .crm-chat-whatsapp a:hover { background: #1ebe5a; }
  .crm-chat-legal { margin: 0; padding: 8px 14px 10px; background: #fff; color: var(--crm-suave); font-size: 11px !important; line-height: 1.4; text-align: center; }

  @media (max-width: 480px) {
    #crm-chatbot-window { right: 0; bottom: 0; width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
    #crm-chatbot-toggle { right: 16px; bottom: 16px; width: 58px; height: 58px; }
    #crm-chat-bubble { right: 16px; bottom: 88px; max-width: calc(100vw - 32px); }
  }
  @media (prefers-reduced-motion: reduce) {
    #crm-chatbot-toggle, #crm-chat-bubble, #crm-chatbot-window, .crm-chat-msg, .crm-chat-msg.typing::after { animation: none; }
  }
