/* ============================================================================
   style.css — visual do portal.

   Organização:
     1. variáveis (mude as cores aqui)
     2. base e utilitários
     3. ícones
     4. header, menu do usuário, menu lateral (recolhível) e container
     5. cartões, formulários, switches, senha, upload
     6. botões
     7. sub-abas
     8. fluxo do bot (grupos em sanfona, lista de passos e etiquetas)
     9. tabelas e leads
    10. simulador de WhatsApp
    11. janela (dialog)
    12. telas estreitas
   ============================================================================ */

/* ---------------------------------------------------------------- 1. cores */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* verde = ação principal (salvar, criar). Amarra com a identidade do WhatsApp. */
  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-soft: #dcfce7;

  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info: #2563eb;
  --info-soft: #eff6ff;

  /* header + menu lateral: mesma cor. A empresa pode ter a sua (companies.brand_color):
     app.js troca --sidebar / --sidebar-text / --sidebar-strong / --nav-active. */
  --sidebar: #111827;
  --sidebar-text: #9ca3af;          /* texto secundário sobre a cor */
  --sidebar-strong: #ffffff;        /* texto principal sobre a cor */
  --sidebar-line: rgba(255,255,255,.08);
  --sidebar-hover: rgba(255,255,255,.08);
  --nav-active: #16a34a;            /* item de menu ativo (verde no padrão; na cor da empresa vira translúcido) */

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-md: 0 4px 16px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 40px rgba(16,24,40,.16);

  --topbar-h: 64px;
  --sidebar-w: 224px;
  --sidebar-w-collapsed: 64px;
  --container: 1200px;

  /* cores do WhatsApp, usadas só no simulador */
  --wa-header: #075e54;
  --wa-green: #25d366;
  --wa-bg: #e5ddd5;
  --wa-in: #ffffff;
  --wa-out: #dcf8c6;
}

/* ------------------------------------------------------- 2. base e utilitários */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 4px; }
h3 {
  font-size: 12px; margin: 22px 0 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
/* só zera a margem quando o título abre o painel; dentro de blocos aninhados
   ele precisa do respiro para não colar na seção anterior */
[data-subpanel] > h3:first-child, .card > h3:first-child { margin-top: 0; }
code {
  background: #f3f4f6; padding: 2px 6px; border-radius: 4px;
  font-size: 13px; word-break: break-all; font-family: ui-monospace, monospace;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* avisos */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px;
  margin: 12px 0; border: 1px solid transparent;
}
.alert.error { color: #991b1b; background: var(--danger-soft); border-color: #fecaca; }
.alert.ok    { color: #166534; background: var(--primary-soft); border-color: #bbf7d0; }
.alert.info  { color: #1e40af; background: var(--info-soft); border-color: #bfdbfe; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 8px; }

/* ---------------------------------------------------------------- 3. ícones */
.ico {
  width: 16px; height: 16px; display: inline-block; flex-shrink: 0;
  background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center;  mask-position: center;
  -webkit-mask-size: contain;     mask-size: contain;
}
.ico-flow   { -webkit-mask-image: var(--i-flow);   mask-image: var(--i-flow); }
.ico-gear   { -webkit-mask-image: var(--i-gear);   mask-image: var(--i-gear); }
.ico-chat   { -webkit-mask-image: var(--i-chat);   mask-image: var(--i-chat); }
.ico-list   { -webkit-mask-image: var(--i-list);   mask-image: var(--i-list); }
.ico-users  { -webkit-mask-image: var(--i-users);  mask-image: var(--i-users); }
.ico-key    { -webkit-mask-image: var(--i-key);    mask-image: var(--i-key); }
.ico-upload { -webkit-mask-image: var(--i-upload); mask-image: var(--i-upload); }
.ico-search { -webkit-mask-image: var(--i-search); mask-image: var(--i-search); }
.ico-download { -webkit-mask-image: var(--i-download); mask-image: var(--i-download); }
.ico-refresh  { -webkit-mask-image: var(--i-refresh);  mask-image: var(--i-refresh); }
.ico-trash    { -webkit-mask-image: var(--i-trash);    mask-image: var(--i-trash); }
.ico-menu     { -webkit-mask-image: var(--i-menu);     mask-image: var(--i-menu); }
.ico-chevron  { -webkit-mask-image: var(--i-chevron);  mask-image: var(--i-chevron); }
.ico-logout   { -webkit-mask-image: var(--i-logout);   mask-image: var(--i-logout); }
.ico-whatsapp { -webkit-mask-image: var(--i-whatsapp); mask-image: var(--i-whatsapp); }
.ico-check    { -webkit-mask-image: var(--i-check);    mask-image: var(--i-check); }

:root {
  --i-flow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='6' cy='4' r='2.5'/%3E%3Ccircle cx='6' cy='20' r='2.5'/%3E%3Ccircle cx='18' cy='12' r='2.5'/%3E%3Cpath d='M6 6.5v11M8.5 5.5h4a3 3 0 0 1 3 3v1M8.5 18.5h4a3 3 0 0 0 3-3v-1'/%3E%3C/svg%3E");
  --i-gear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 21v-7M4 10V3M12 21v-9M12 8V3M20 21v-5M20 12V3M1 14h6M9 8h6M17 16h6'/%3E%3C/svg%3E");
  --i-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
  --i-list: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01'/%3E%3C/svg%3E");
  --i-users: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3C/svg%3E");
  --i-key: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.7 11.3a5.5 5.5 0 1 0-1.4 1.4l2.3 2.3v2h2v2h2v2h3v-3z'/%3E%3C/svg%3E");
  --i-upload: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M17 8l-5-5-5 5M12 3v12'/%3E%3C/svg%3E");
  --i-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
  --i-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4M7 10l5 5 5-5M12 15V3'/%3E%3C/svg%3E");
  --i-eye: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  --i-eye-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19M14.12 14.12a3 3 0 1 1-4.24-4.24M1 1l22 22'/%3E%3C/svg%3E");
  --i-send: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z'/%3E%3C/svg%3E");
  --i-refresh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15'/%3E%3C/svg%3E");
  --i-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M3 12h18M3 18h18'/%3E%3C/svg%3E");
  --i-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  --i-logout: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9'/%3E%3C/svg%3E");
  --i-whatsapp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23000'%3E%3Cpath d='M17.5 14.4c-.3-.1-1.8-.9-2-1-.3-.1-.5-.1-.7.1-.2.3-.8 1-.9 1.2-.2.2-.3.2-.6.1-.3-.1-1.3-.5-2.4-1.5-.9-.8-1.5-1.8-1.7-2.1-.2-.3 0-.5.1-.6l.5-.5c.1-.2.2-.3.3-.5.1-.2 0-.4 0-.5l-.9-2.2c-.2-.6-.5-.5-.7-.5h-.6c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.5s1.1 2.9 1.2 3.1c.1.2 2.1 3.2 5.1 4.5.7.3 1.3.5 1.7.6.7.2 1.4.2 1.9.1.6-.1 1.8-.7 2-1.4.2-.7.2-1.3.2-1.4-.1-.2-.3-.3-.6-.4zM12 2C6.5 2 2 6.5 2 12c0 1.8.5 3.5 1.3 5L2 22l5.2-1.4c1.4.8 3.1 1.2 4.8 1.2 5.5 0 10-4.5 10-10S17.5 2 12 2zm0 18.2c-1.5 0-3-.4-4.3-1.2l-.3-.2-3.1.8.8-3-.2-.3C4.1 15 3.7 13.5 3.7 12c0-4.6 3.7-8.3 8.3-8.3s8.3 3.7 8.3 8.3-3.7 8.2-8.3 8.2z'/%3E%3C/svg%3E");
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  --i-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E");
}

/* giro do ícone enquanto carrega */
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading .ico-refresh { animation: spin .8s linear infinite; }
.btn.loading { pointer-events: none; opacity: .75; }

/* ------------------------------------------- 4. header, menu lateral, container */
.center-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f5ee 0%, var(--bg) 60%);
}

.topbar {
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 24px; background: var(--sidebar); color: var(--sidebar-strong);
  border-bottom: 1px solid var(--sidebar-line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand-sub { color: var(--sidebar-text); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-logo { height: 36px; max-width: 150px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--sidebar-strong); }
.menu-toggle { color: var(--sidebar-text); flex-shrink: 0; }
.menu-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); }
.menu-toggle .ico { width: 20px; height: 20px; }

.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-picker { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; color: var(--sidebar-text); }
.topbar-picker select {
  margin: 0; width: auto; min-width: 180px; padding: 7px 10px;
  background: var(--sidebar-hover); color: var(--sidebar-strong); border-color: var(--sidebar-line);
}
.topbar-picker select option { color: var(--text); background: var(--card); }

/* ..... menu do usuário: "Nome - Empresa" abre a bandeja ..... */
.user-menu { position: relative; min-width: 0; }
.user-trigger {
  display: flex; align-items: center; gap: 6px; max-width: 320px;
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 7px 10px; font: inherit; font-size: 14px; font-weight: 500; color: var(--sidebar-strong); cursor: pointer;
}
.user-trigger:hover, .user-trigger[aria-expanded="true"] { background: var(--sidebar-hover); }
.user-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-trigger .ico { width: 14px; height: 14px; color: var(--sidebar-text); transition: transform .15s; }
.user-trigger[aria-expanded="true"] .ico { transform: rotate(180deg); }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 30;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 6px;
}
.dropdown-email { display: block; padding: 8px 10px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; word-break: break-all; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; text-align: left; padding: 9px 10px;
  border-radius: var(--radius-sm); font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
}
.dropdown-item:hover { background: #f3f4f6; }
.dropdown-item .ico { color: var(--muted); }
#btn-logout.dropdown-item { color: var(--danger); }
#btn-logout.dropdown-item .ico { color: var(--danger); }

/* ..... menu lateral: 224px com texto; recolhido = 64px só com ícones ..... */
.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  padding: 16px 12px; display: flex; flex-direction: column; transition: width .18s ease;
  position: sticky; top: var(--topbar-h); align-self: flex-start;
  height: calc(100vh - var(--topbar-h)); overflow-y: auto; overflow-x: hidden;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
/* crédito discreto, colado no canto inferior esquerdo */
.sidebar-credit { margin-top: auto; position: sticky; bottom: 10px; padding: 12px 12px 0; font-size: 11px; color: #cbd5e1; opacity: .85; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  text-align: left; background: none; border: none; color: var(--sidebar-text);
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: 14px; transition: background .15s, color .15s; white-space: nowrap;
}
.nav-item .ico { width: 18px; height: 18px; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-strong); }
.nav-item.active { background: var(--nav-active); color: #fff; font-weight: 500; }
body.brand-light .nav-item.active { color: var(--sidebar-strong); }
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); padding: 16px 10px; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 11px 0; }
body.sidebar-collapsed .nav-item span { display: none; }
body.sidebar-collapsed .sidebar-credit { display: none; }
.sidebar-backdrop { display: none; }

.content { flex: 1; min-width: 0; padding: 28px 24px 56px; }
.container { max-width: var(--container); margin: 0 auto; }

.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-head p { margin: 4px 0 0; font-size: 14px; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --------------------------------------- 5. cartões, formulários, switches */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card.narrow { max-width: 680px; }
.card.no-pad { padding: 0; overflow: hidden; }
.card-body { padding: 22px; }

 /* linhas de texto curtas são mais fáceis de ler: os campos do formulário da
    empresa não passam de 620px, mesmo em telas largas */
#company-form input, #company-form select, #company-form textarea { max-width: 620px; }
#company-form input[type="color"] { max-width: 48px; }
#company-form .copy-row code { max-width: 620px; }

.login-card { width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); padding: 32px; }
.login-card h1 { margin-bottom: 4px; }
.login-card > p { margin-top: 0; margin-bottom: 22px; }
.login-logo { display: block; max-height: 56px; max-width: 200px; object-fit: contain; margin-bottom: 18px; }

label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 16px; }
label small { display: block; font-weight: 400; margin-top: 5px; font-size: 12.5px; }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 12px; font: inherit;
  border: 1px solid #9ca3af; border-radius: var(--radius-sm);
  background: #fff; color: var(--text); box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: #6b7280; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}
input::placeholder, textarea::placeholder { color: #9ca3af; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* leitura em Z: a ação principal fecha o formulário no canto inferior DIREITO;
   ações destrutivas (excluir) ficam à esquerda, longe do botão de salvar */
.form-actions {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  border-top: 1px solid var(--border); padding-top: 18px; margin-top: 20px;
}
.form-actions .btn.danger-text { margin-right: auto; }
.form-actions.sticky {
  position: sticky; bottom: 0; z-index: 5; background: rgba(250,250,250,.96); backdrop-filter: blur(4px);
  margin-top: 0; padding: 16px 22px; border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 -6px 16px -12px rgba(0,0,0,.25);
}

/* ..... toggle switch (liga/desliga) ..... */
.switch {
  display: flex; align-items: flex-start; gap: 12px;
  font-weight: 500; cursor: pointer; margin-bottom: 16px; position: relative;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.slider {
  width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong);
  flex-shrink: 0; position: relative; transition: background .18s; margin-top: 1px;
}
.slider::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(22,163,74,.25); }
.switch-text { font-size: 14px; }
.switch.big .switch-text { font-size: 15px; font-weight: 600; }
.switch-row { display: flex; gap: 28px; flex-wrap: wrap; margin: 4px 0 8px; }

/* ..... campo de senha com olho ..... */
.input-pass { display: block; position: relative; }
.input-pass input { padding-right: 42px; }
.eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: none; background: none; cursor: pointer;
  padding: 0; opacity: .55; margin-top: 3px;
}
.eye::before {
  content: ""; display: block; width: 18px; height: 18px; margin: 0 auto;
  background: var(--muted);
  -webkit-mask: var(--i-eye) center/contain no-repeat; mask: var(--i-eye) center/contain no-repeat;
}
.eye.on::before { -webkit-mask-image: var(--i-eye-off); mask-image: var(--i-eye-off); }
.eye:hover { opacity: 1; }

/* ..... upload de logo ..... */
.logo-box {
  display: inline-flex; gap: 16px; align-items: center; flex-wrap: wrap;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 14px; background: #fafafa; max-width: 100%;
}
.logo-preview-wrap {
  width: 120px; height: 72px; border-radius: var(--radius-sm); background: #fff;
  border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; flex-shrink: 0;
}
.logo-preview { max-width: 108px; max-height: 60px; object-fit: contain; }
.logo-empty { font-size: 12px; color: #9ca3af; text-align: center; padding: 0 8px; }
.logo-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-actions small { width: 100%; margin: 0; }
#logo-file-label.disabled { opacity: .5; pointer-events: none; }
.logo-preview.pending-remove { opacity: .3; filter: grayscale(1); }
#logo-pending { margin: 4px 0 0; }

/* ..... copiar webhook ..... */
.copy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.copy-row code { flex: 1; min-width: 200px; padding: 9px 12px; background: #f9fafb; border: 1px solid var(--border); }

/* ..... busca ..... */
.search-box { position: relative; display: block; }
.search-box .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-box input { margin: 0; padding-left: 34px; min-width: 260px; }

/* --------------------------------------------------------------- 6. botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; font: inherit; font-size: 14px; font-weight: 500;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: #fff; color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s; white-space: nowrap;
}
/* ação principal: só uma por tela, sempre verde e preenchida */
.btn.primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(22,163,74,.25);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
/* ações secundárias: contorno, sem peso visual */
.btn.outline { background: #fff; border-color: var(--border-strong); color: #374151; }
.btn.outline:hover { background: #f9fafb; border-color: var(--muted); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f3f4f6; color: var(--text); }
.btn.danger-text { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-soft); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.lg { padding: 12px 18px; font-size: 15px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------- 7. sub-abas */
.subtabs {
  display: flex; gap: 4px; padding: 0 12px; background: #fafafa;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.subtab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 14px 12px; font: inherit; font-size: 14px; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--primary-hover); border-bottom-color: var(--primary); font-weight: 600; }

/* --------------------------------------------------------- 8. fluxo do bot */
.flow-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
/* grupos em sanfona: um <details> por grupo ("Compra", "Venda"...) */
.step-groups { display: flex; flex-direction: column; gap: 10px; }
/* flex: none — sem isto os grupos encolhiam para caber na altura e os cabeçalhos
   ficavam empilhados uns sobre os outros (bug visual da sanfona) */
.step-group { flex: none; }
/* muitos passos num grupo: a lista rola dentro da sanfona, o cabeçalho fica visível */
.step-group .step-list { max-height: 48vh; overflow-y: auto; }
.step-group summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer;
  list-style: none; user-select: none; font-weight: 600; font-size: 14px;
}
.step-group summary::-webkit-details-marker { display: none; }
.step-group summary:hover { background: #f9fafb; }
.step-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-group-count {
  font-size: 11.5px; font-weight: 600; color: var(--muted); background: #f3f4f6;
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.step-group summary .ico { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.step-group[open] summary .ico { transform: rotate(180deg); }
.step-group[open] summary { border-bottom: 1px solid var(--border); }
.step-list { list-style: none; margin: 0; padding: 0; }
.step-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .12s;
}
.step-list li:last-child { border-bottom: none; }
.step-list li:hover { background: #f9fafb; }
.step-list li.selected { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.step-list li.inactive { opacity: .45; }
.step-list .k { display: block; font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--muted); }
.step-badges { display: flex; gap: 5px; flex-shrink: 0; }

.badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap; letter-spacing: .01em;
}
/* cores com significado: o usuário entende o fluxo só de bater o olho */
.badge.entry    { background: var(--primary); color: #fff; }               /* início  */
.badge.MESSAGE  { background: #f1f5f9; color: #475569; }                   /* só informa */
.badge.MENU     { background: #f3e8ff; color: #7e22ce; }                   /* escolha */
.badge.QUESTION { background: #fef3c7; color: #b45309; }                   /* espera resposta */
.badge.ACTION   { background: #dbeafe; color: #1d4ed8; }                   /* executa algo */
.badge.END      { background: #374151; color: #fff; }                      /* termina */

.options-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; min-width: 620px; }
.options-table th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.options-table td { padding: 3px; }
.options-table input, .options-table select { margin: 0; padding: 7px 9px; font-size: 13px; }
.options-table td:first-child input { width: 56px; }
.options-table .btn { padding: 4px 9px; }

/* ------------------------------------------------------ 9. tabelas e leads */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: #fafafa; font-weight: 600; white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table .k { display: block; font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f9fafb; }
.table tr.selected td { background: var(--primary-soft); }
.table .empty { text-align: center; color: var(--muted); padding: 32px 16px; }

.leads-table { table-layout: fixed; }
.leads-table th:nth-child(1) { width: 150px; }   /* quando */
.leads-table th:nth-child(2) { width: 190px; }   /* cliente */
.leads-table th:nth-child(3) { width: 84px; }    /* nota */
.leads-table th:nth-child(4) { width: 132px; }   /* interesse — o resto (respostas) fica com a largura que sobrar */
.leads-table td { overflow-wrap: anywhere; }
.leads-table td:first-child { white-space: normal; color: var(--muted); font-size: 13px; }
@media (max-width: 760px) { .leads-table { table-layout: auto; min-width: 640px; } }
.lead-phone { display: block; font-size: 13px; color: var(--muted); }
.leads-table .col-acao { width: 92px; }
.leads-table td:last-child { text-align: right; padding-left: 4px; padding-right: 10px; white-space: nowrap; }
/* mensagem de lista vazia: a regra de td:last-child (ações à direita) não vale aqui */
.leads-table td.empty { text-align: center; white-space: normal; padding: 32px 16px; }

/* cabeçalhos ordenáveis (Quando, Cliente, Interesse) */
.th-sort {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
}
.th-sort:hover, .th-sort.active { color: var(--text); }
.th-sort::after { content: ''; width: 0; height: 0; border: 4px solid transparent; opacity: .35; margin-left: 2px; }
.th-sort.active.asc::after  { border-bottom-color: currentColor; border-top: 0; opacity: 1; }
.th-sort.active.desc::after { border-top-color: currentColor; border-bottom: 0; opacity: 1; }
.th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }

/* etiqueta "em teste" ao lado de um campo ainda não liberado */
.badge-test {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 1px 8px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: #92400e; background: #fef3c7; border-radius: 999px;
}
input:disabled { background: #f3f4f6; color: var(--muted); cursor: not-allowed; }

/* ..... blocos de configuração (aba Empresa) .....
   Um bloco por assunto; dentro, uma linha por configuração: explicação à
   esquerda, controle à direita. Campos têm largura máxima para a linha de
   texto não ficar longa demais. */
.bloco { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; }
.bloco:last-child { margin-bottom: 0; }
.bloco-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.bloco-titulo { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: 0; }

.conf { display: grid; grid-template-columns: minmax(190px, 280px) minmax(0, 1fr); gap: 8px 28px; padding: 18px 0; border-bottom: 1px solid var(--border); align-items: start; }
.conf:last-child { border-bottom: 0; padding-bottom: 4px; }
.conf-info strong { display: block; font-size: 14px; font-weight: 600; }
.conf-info small { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.conf-campo { max-width: 600px; }
.conf-campo.conf-larga { max-width: 760px; }
.conf-campo > input, .conf-campo > select, .conf-campo > textarea,
.conf-campo [data-aviso] > input { margin-top: 0; }
.conf-campo small { display: block; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
@media (max-width: 900px) { .conf { grid-template-columns: 1fr; gap: 10px; } }

/* selo de status no cabeçalho do bloco (em vez de um banner do tamanho de um campo) */
.badge-status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  color: #166534; background: var(--primary-soft); border: 1px solid #bbf7d0; border-radius: 999px; padding: 3px 10px;
}
.badge-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
/* confirmação discreta, em linha, sem bloco de fundo */
.ok-inline { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: 13px; color: #15803d; }
.ok-inline::before { content: '✓'; font-weight: 700; }

/* escolha entre duas opções (número ou grupo) */
.escolha { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.escolha .check { display: inline-flex; align-items: center; gap: 7px; margin: 0; font-weight: 400; font-size: 14px; }
.escolha .check input { width: auto; margin: 0; box-shadow: none; }
.acoes-aviso { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }

/* cor do portal (só o super): controles à esquerda (cor + "usar padrão"), prévia à direita */
.color-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.color-controls { display: flex; flex-direction: column; gap: 10px; }
.color-pick { display: flex; align-items: center; gap: 10px; font-size: 14px; }
/* o checkbox não pode herdar o "display:block; width:100%" dos inputs de texto */
.color-row .check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; margin: 0; white-space: nowrap; }
.color-row .check input { display: inline-block; width: auto; margin: 0; box-shadow: none; }
.color-row input[type="color"] { width: 48px; height: 36px; padding: 2px; margin: 0; cursor: pointer; border-radius: var(--radius-sm); }
.color-row .check { margin: 0; }
.color-preview {
  display: flex; flex-direction: column; width: 220px; height: 84px; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border); font-size: 11px;
}
.color-preview-top { height: 26px; display: flex; align-items: center; padding: 0 10px; font-weight: 600; }
.color-preview-body { display: flex; flex: 1; }
.color-preview-side { width: 70px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.color-preview-side i { display: block; height: 8px; border-radius: 3px; background: currentColor; opacity: .35; }
.color-preview-side i.on { opacity: 1; }
.color-preview-main { flex: 1; background: var(--bg); }

/* lead já contatado (alguém clicou no botão WhatsApp): filete verde à esquerda,
   sem colorir a linha inteira (não briga com as cores das tags de interesse) */
.leads-table tr.contacted td:first-child { box-shadow: inset 4px 0 0 var(--primary); }
.leads-table tr.contacted td { background: #fcfefc; }
.lead-contacted {
  display: flex; align-items: center; gap: 4px; margin-top: 4px;
  font-size: 12px; color: #15803d; background: transparent; border: 0; padding: 0; cursor: pointer; font-family: inherit;
}
.lead-contacted:hover { text-decoration: underline; }
.lead-contacted .ico { width: 13px; height: 13px; }
.row-actions { display: inline-flex; gap: 2px; align-items: center; }
.btn.icon.whats { color: #16a34a; }
.btn.icon.whats:hover { background: var(--primary-soft); color: #15803d; }
.btn.icon.whats .ico { width: 20px; height: 20px; }

/* atualização suave: a tabela esmaece enquanto busca e volta com as linhas novas */
.table-scroll { transition: opacity .25s ease; }
.table-scroll.loading { opacity: .4; pointer-events: none; }
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.leads-table tbody tr { animation: fade-in .3s ease both; }

/* botão só com ícone (a lixeira de cada lead) */
.btn.icon {
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm);
  background: transparent; border-color: transparent; color: var(--muted);
}
.btn.icon:hover { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.icon:disabled { opacity: .3; background: transparent; color: var(--muted); }
.btn.icon .ico { width: 17px; height: 17px; }

/* indicador discreto de que o número está no meio de uma conversa */
.conv-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px;
  vertical-align: middle; background: var(--primary);
}
.conv-dot.HUMAN { background: #f59e0b; }

/* respostas do lead como etiquetas, em vez de texto corrido */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: #f3f4f6; border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; max-width: 100%;
}
.tag b { font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.tag span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
/* campos longos (observação) ficam numa linha só, truncada; "ver mais" abre a linha */
.lead-long { margin-top: 6px; font-size: 13px; color: #374151; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.lead-long b { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.lead-long span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
tr.expanded .lead-long span, tr.expanded .tag span { white-space: normal; max-width: none; }
.btn-more { background: none; border: 0; padding: 0; color: var(--primary-hover); font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
.btn-more:hover { text-decoration: underline; }

.intent { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
/* cores: texto escuro sobre fundo claro (contraste ≥ 7:1) + borda da mesma família */
.intent { border: 1px solid transparent; }
.intent.BUY         { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.intent.SELL        { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.intent.FINANCING   { background: #f3e8ff; color: #581c87; border-color: #e9d5ff; }
.intent.APPOINTMENT { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.intent.HUMAN       { background: #e5e7eb; color: #1f2937; border-color: #d1d5db; }
.intent.none        { background: transparent; color: var(--muted); font-weight: 400; }

/* nota do lead (lead scoring): 🔥 75 / 🟡 48 / ⚪ 20 — o motivo fica no title */
.score { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; cursor: help; padding: 3px 8px; border-radius: 999px; border: 1px solid transparent; }
.score b { font-weight: 700; }
.score.hot  { background: #fee2e2; color: #7f1d1d; border-color: #fecaca; }
.score.warm { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.score.cold { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.score.none { color: var(--muted); }

/* ------------------------------------------- 10. simulador de WhatsApp */
.phone {
  width: 100%; max-width: 400px; margin: 0 auto;
  height: min(680px, 72vh); display: flex; flex-direction: column;
  border: 10px solid #1f2937; border-radius: 34px; overflow: hidden;
  box-shadow: var(--shadow-lg); background: var(--wa-bg);
}
.phone-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--wa-header); color: #fff; flex-shrink: 0;
}
.phone-back { font-size: 22px; line-height: 1; opacity: .9; }
.phone-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.25);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; text-transform: uppercase;
}
.phone-contact { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.phone-contact strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-contact small { font-size: 11.5px; opacity: .8; }

.chat {
  flex: 1; overflow-y: auto; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 8px;
  background-color: var(--wa-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23000' stroke-opacity='.045' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='22' cy='20' r='7'/%3E%3Cpath d='M58 14l7 7-7 7-7-7z'/%3E%3Cpath d='M96 24q9-9 18 0'/%3E%3Crect x='118' y='12' width='14' height='14' rx='4'/%3E%3Cpath d='M14 62h16M14 70h10'/%3E%3Cpath d='M56 58l8 12H48z'/%3E%3Ccircle cx='100' cy='64' r='6'/%3E%3Cpath d='M122 58v12M116 64h12'/%3E%3Cpath d='M20 108q10 10 20 0'/%3E%3Ccircle cx='64' cy='106' r='8'/%3E%3Cpath d='M94 100h16v14H94z'/%3E%3Cpath d='M126 102l8 8-8 8'/%3E%3C/g%3E%3C/svg%3E");
}
.msg {
  position: relative; max-width: 78%; padding: 7px 11px 8px;
  font-size: 14.5px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere;
  border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.12);
}
/* balão recebido (bot): branco, com rabinho à esquerda */
.msg.bot {
  background: var(--wa-in); align-self: flex-start; border-top-left-radius: 0;
}
.msg.bot::before {
  content: ""; position: absolute; top: 0; left: -8px;
  border-width: 0 8px 8px 0; border-style: solid;
  border-color: transparent var(--wa-in) transparent transparent;
}
/* balão enviado (cliente): verde claro, rabinho à direita */
.msg.user {
  background: var(--wa-out); align-self: flex-end; border-top-right-radius: 0;
}
.msg.user::before {
  content: ""; position: absolute; top: 0; right: -8px;
  border-width: 0 0 8px 8px; border-style: solid;
  border-color: transparent transparent transparent var(--wa-out);
}
.msg .hora { display: block; text-align: right; font-size: 10.5px; color: #667781; margin-top: 2px; }
/* lista interativa: as opções aparecem como botões abaixo da pergunta */
.msg-options { display: flex; flex-direction: column; gap: 4px; margin: 8px -4px 2px; }
.msg-option {
  background: #fff; border: 1px solid #d9e2ea; border-radius: 8px; padding: 7px 10px;
  font: inherit; font-size: 13.5px; color: #027eb5; text-align: left; cursor: pointer;
}
.msg-option:hover { background: #f4f9ff; }
.msg-option:disabled { opacity: .55; cursor: default; }
.msg-option.back { color: var(--muted); }
/* aviso do simulador: pílula central, como a tarja de data do WhatsApp */
.msg.sys {
  align-self: center; background: #fff6d6; color: #7a6a1f; font-size: 12.5px;
  max-width: 88%; text-align: center; border-radius: 8px; padding: 6px 12px;
}
.chat-form { display: flex; gap: 8px; padding: 10px; background: #f0f0f0; flex-shrink: 0; align-items: center; }
.chat-form input { margin: 0; border-radius: 999px; border-color: transparent; padding: 10px 16px; }
.chat-form input:focus { box-shadow: none; border-color: transparent; }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--wa-green); cursor: pointer; display: grid; place-items: center;
}
.send-btn::before {
  content: ""; width: 19px; height: 19px; display: block; margin-right: 2px;
  background: #fff;
  -webkit-mask: var(--i-send) center/contain no-repeat; mask: var(--i-send) center/contain no-repeat;
}
.send-btn:hover { filter: brightness(.94); }
/* linha técnica: só aparece com Ctrl+Shift+D */
.debug-bar {
  max-width: 400px; margin: 14px auto 0; font-size: 12px; color: var(--muted); text-align: center;
}

/* ------------------------------------------------------------ 11. dialog */
dialog {
  border: none; border-radius: var(--radius); padding: 26px;
  max-width: 580px; width: calc(100% - 32px); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(17,24,39,.5); }
dialog h2 { margin-bottom: 6px; }
dialog > form > p { margin-top: 0; margin-bottom: 18px; }

/* --------------------------------------------------- 12. telas estreitas */
@media (max-width: 960px) {
  /* header numa linha só: botão do menu, nome, e o usuário; nada estoura a largura */
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-sub { display: none; }
  .brand-logo { height: 30px; max-width: 110px; }
  .topbar-right { gap: 6px; flex-shrink: 1; }
  .topbar-picker span { display: none; }
  .topbar-picker select { min-width: 0; width: 120px; padding: 6px 8px; font-size: 13px; }
  .user-trigger { max-width: 150px; padding: 6px 8px; font-size: 13px; }
  /* no celular, quando o seletor de empresa está no header, o nome ao lado da logo é
     redundante e só encolhe até virar "M..." — some, o seletor já diz a empresa */
  body.has-picker .brand-text { display: none; }

  /* menu lateral vira gaveta por cima do conteúdo, aberta pelo botão do header */
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 25;
    width: min(280px, 85vw); height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: none;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-collapsed .sidebar { width: min(280px, 85vw); padding: 16px 12px; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
  body.sidebar-collapsed .nav-item span { display: inline; }
  .sidebar-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(17,24,39,.45); z-index: 24; }

  .flow-layout, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 20px 14px 40px; }
  .page-head { align-items: stretch; }
  .head-actions { width: 100%; }
  .search-box { flex: 1; }
  .search-box input { min-width: 0; width: 100%; }
  .step-group .step-list { max-height: none; }
  .phone { border-width: 6px; border-radius: 24px; height: min(600px, 68vh); }
  .dropdown { right: 0; }
}

/* ..... conexão com o WhatsApp (status do chip / QR Code) ..... */
.zapi-box { margin-bottom: 20px; }
.zapi-box .alert { margin: 0 0 10px; }
.zapi-qr-wrap { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.zapi-qr { width: 220px; height: 220px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; flex-shrink: 0; display: grid; place-items: center; overflow: hidden; }
.zapi-qr img { width: 100%; height: 100%; }
.zapi-qr-text { flex: 1; min-width: 220px; }

/* ------------------------------------------- 13. relatórios */
.ico-chart { -webkit-mask-image: var(--i-chart); mask-image: var(--i-chart); }
:root { --i-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v18h18'/%3E%3Cpath d='M7 15l4-5 3 3 5-7'/%3E%3C/svg%3E"); }

.rel-periodos { display: inline-flex; gap: 4px; }
.rel-periodo.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-hover); }
.rel-custom { display: inline-flex; align-items: center; gap: 6px; }
.rel-custom input[type=date] { margin: 0; width: auto; padding: 6px 8px; font-size: 13px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 0 18px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .kpi-value { font-size: 28px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .kpi-delta { font-size: 12px; margin-top: 6px; }
.kpi .kpi-delta.up { color: #15803d; }
.kpi .kpi-delta.down { color: var(--danger); }
.kpi.alerta { border-color: #fca5a5; background: var(--danger-soft); }
.kpi.alerta .kpi-value { color: var(--danger); }

.rel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
/* "Mais detalhes": sanfona com os gráficos secundários */
.rel-mais { margin-top: 18px; }
.rel-mais summary {
  display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; user-select: none;
  padding: 12px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
}
.rel-mais summary::-webkit-details-marker { display: none; }
.rel-mais summary small { font-weight: 400; flex: 1; }
.rel-mais summary .ico { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.rel-mais[open] summary .ico { transform: rotate(180deg); }
.rel-mais-nota { margin: 12px 4px 0; }
.rel-mais-nota:empty { display: none; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.rel-grid .card { padding: 18px 20px; }
.rel-grid .card h3 { margin: 0 0 10px; font-size: 15px; }
.rel-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .rel-grid { grid-template-columns: 1fr; } }

/* barras horizontais (rótulo · barra · número) */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-track { background: #f3f4f6; border-radius: 999px; height: 12px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--primary); border-radius: 999px; min-width: 2px; }
.bar-row .bar-n { text-align: right; font-weight: 600; }
.bars .empty, .rel-list .empty { color: var(--muted); font-size: 13px; }

/* barras verticais (por dia / hora) */
.bars-v { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 18px; }
.bars-v.small { height: 110px; }
.bars-v .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; position: relative; }
.bars-v .col .stack { width: 100%; display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.bars-v .col .v { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars-v .col .v.b { background: #f59e0b; }
.bars-v .col .lbl { font-size: 10px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bars-v .col .n { position: absolute; top: -16px; font-size: 10px; color: var(--muted); }
.bars-v .col:hover .v { filter: brightness(.9); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--primary); margin-right: 4px; vertical-align: -1px; }
.legend i.b { background: #f59e0b; }

.rel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.rel-list li { padding: 8px 10px; background: #f9fafb; border-radius: var(--radius-sm); }
.rel-list li .meta { color: var(--muted); font-size: 12px; }

.rel-filtros { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.rel-filtros select { margin: 0; width: auto; }
.rel-table td { font-size: 13px; }
.rel-table .toggle { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 4px; }
.rel-table tr.detalhe td { background: #f9fafb; padding: 14px 20px 18px; }
.rel-detalhe { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .rel-detalhe { grid-template-columns: 1fr; } }
.rel-detalhe h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.rel-lead { padding: 10px 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 13px; }
.rel-lead .campo { color: var(--muted); }
.transcript { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; max-height: 320px; overflow: auto; font-size: 13px; white-space: pre-wrap; line-height: 1.5; }
.transcript .isis { color: #15803d; }
.rtag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #e5e7eb; color: #1f2937; white-space: nowrap; border: 1px solid #d1d5db; }
.rtag.visita { background: #fef3c7; color: #78350f; border-color: #fde68a; }
.rtag.lead { background: #dcfce7; color: #14532d; border-color: #bbf7d0; }
.rtag.transferido { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }
.rtag.fora { background: #ede9fe; color: #4c1d95; border-color: #ddd6fe; }

/* estado vazio dos gráficos: em vez de um bloco em branco */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 110px; color: var(--muted); font-size: 13px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 16px; }
.empty-state .ico { width: 22px; height: 22px; opacity: .6; }
.rel-tabs { margin: 4px 0 16px; }

/* chips de variáveis (Mensagens do bot): clicar insere no texto */
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip {
  font: inherit; font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 4px 10px; border-radius: 999px; cursor: pointer;
  background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe;
}
.chip:hover { background: #dbeafe; border-color: #93c5fd; }
.chip:active { transform: translateY(1px); }
