:root {
  --bg: #f4f6f5; --card: #fff; --text: #17201d; --muted: #66726e; --line: #dfe5e2;
  --brand: #0f766e; --brand-ink: #fff; --in: #fff; --out: #d9f3ec; --human: #e6eefc;
  --danger: #b42318; --ok: #12805c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1413; --card: #182120; --text: #e6ecea; --muted: #94a3a0; --line: #2a3533;
    --brand: #2bb3a3; --brand-ink: #062320; --in: #1f2a28; --out: #134a42; --human: #22325a;
    --danger: #f97066; --ok: #4ade80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: .3rem 0; }
.ok { color: var(--ok); }
h1, h2 { margin: 0 0 .5rem; } h2 { font-size: 1.1rem; }
h1:focus { outline: none; }
a { color: var(--brand); }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

input, textarea, select {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; color: var(--text); }
label.check input { width: auto; }
button {
  background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 8px;
  padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
}
button.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }

.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.narrow { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .8rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: 1rem; }
.grid-form .wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid-form { grid-template-columns: 1fr; } }

/* Configurações: tópicos que expandem / retraem */
.topico-cabecalho { display: flex; align-items: center; justify-content: space-between; gap: .8rem;
    padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; user-select: none; }
.topico-cabecalho:hover { border-color: currentColor; }
.topico-cabecalho h2 { margin: 0; }
.topico-cabecalho.aberto { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.topico-botao { white-space: nowrap; flex-shrink: 0; }
.topico-corpo { margin: -.8rem 0 0; padding: .9rem; border: 1px solid var(--line); border-top: 0;
    border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }

/* Assistente de conexão: passos numerados */
.passos { display: flex; flex-direction: column; gap: 1rem; }
.passo { display: grid; grid-template-columns: 2rem 1fr; gap: .7rem; align-items: start; }
.passo > div, .passo > label { min-width: 0; }
.passo-num { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
    background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.passo-titulo { display: flex; align-items: center; gap: .6rem; margin: .6rem 0 0; font-size: 1rem; }
a.botao-link { display: inline-block; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 8px;
    color: var(--brand); font-weight: 600; text-decoration: none; }
a.botao-link:hover { border-color: var(--brand); }
.copiar { display: grid; grid-template-columns: 9rem 1fr auto; gap: .5rem; align-items: center; margin: .4rem 0; }
.copiar code { overflow-wrap: anywhere; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px; }
@media (max-width: 640px) { .copiar { grid-template-columns: 1fr auto; } .copiar > span { grid-column: 1 / -1; } }
details.avancado { border-top: 1px dashed var(--line); padding-top: .6rem; }
details.avancado summary { cursor: pointer; color: var(--muted); }

/* Painel de conexões */
.conexoes { display: flex; flex-direction: column; gap: .5rem; }
.conexao { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px; }
.conexao-icone { font-size: 1.4rem; }
.conexao .grow { flex: 1; min-width: 0; }
.card.stack > .topico-cabecalho + * { margin-top: .2rem; }

/* Layout principal: barra lateral no PC, barra inferior no celular */
#app { display: flex; height: 100%; }
#tabs { display: flex; flex-direction: column; gap: 2px; padding: 8px; background: var(--card); border-right: 1px solid var(--line); }
#tabs a, #tabs button {
  display: block; background: transparent; color: var(--text); text-align: left; font-weight: 500;
  white-space: nowrap; padding: .6rem 1rem; border-radius: 8px; text-decoration: none; width: 100%;
}
#tabs a.active { background: var(--out); }
#tabs #logout { margin-top: auto; }
#tabs #logout button { color: var(--muted); }
main { flex: 1; overflow: auto; padding: 16px; }
.tab { max-width: 1100px; margin: 0 auto; }
@media (max-width: 760px) {
  #app { flex-direction: column-reverse; }
  #tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-top: 1px solid var(--line);
          padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  #tabs a, #tabs button { display: flex; flex-direction: column; align-items: center; font-size: .72rem; padding: .35rem .5rem; flex: 1; }
  #tabs #logout { margin-top: 0; display: flex; }
  main { padding: 12px; }
}

/* Conversas */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 12px; height: calc(100vh - 32px); }
#chatList { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.chat-item { padding: .7rem .8rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.chat-item:hover, .chat-item.active { background: var(--bg); }
.chat-item .top { display: flex; justify-content: space-between; gap: .5rem; }
.chat-item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .last { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--brand); color: var(--brand-ink); border-radius: 99px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }
.tag { font-size: .72rem; border: 1px solid var(--line); border-radius: 99px; padding: 0 .4rem; color: var(--muted); }
#chatView { background: var(--card); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
#chatView.empty { align-items: center; justify-content: center; }
.chat-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head .who { flex: 1; min-width: 150px; }
/* Ações da conversa: grupo de botões iguais (ícone + texto curto), lado a lado. */
.head-acoes { display: flex; gap: .35rem; flex-wrap: wrap; }
.head-acoes .acao { display: inline-flex; align-items: center; gap: .3rem; height: 34px; padding: 0 .7rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text, #17201d); font-size: .82rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.head-acoes .acao:hover { background: var(--bg); }
.head-acoes .acao .ic { font-size: .95rem; line-height: 1; }
.head-acoes .acao.destaque { background: #b05c74; border-color: #b05c74; color: #fff; }
.head-acoes .acao.perigo { color: #c0392b; border-color: #f0c4be; }
.head-acoes .acao.perigo:hover { background: #fdecea; }
@media (max-width: 640px) { .head-acoes .acao span:not(.ic) { display: none; } .head-acoes .acao { width: 38px; padding: 0; justify-content: center; } }
.messages { flex: 1; overflow: auto; padding: .8rem; display: flex; flex-direction: column; gap: .4rem; background: var(--bg); min-height: 200px; }
.msg { max-width: 78%; padding: .45rem .7rem; border-radius: 10px; white-space: pre-wrap; word-wrap: break-word; background: var(--in); border: 1px solid var(--line); }
.msg.out { align-self: flex-end; background: var(--out); border-color: transparent; }
.msg.humano { background: var(--human); }
.msg .meta { display: block; font-size: .7rem; color: var(--muted); margin-top: .2rem; text-align: right; }
.composer { display: flex; gap: .5rem; padding: .6rem; border-top: 1px solid var(--line); }
.msg-img { display: block; max-width: 240px; max-height: 320px; border-radius: 8px; margin-bottom: .3rem; }
.msg-audio { display: block; width: 260px; max-width: 100%; height: 36px; margin-bottom: .3rem; }
.transcript { font-style: italic; color: var(--muted); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.attach { display: flex; align-items: center; justify-content: center; font-size: 1.3rem; cursor: pointer;
          border: 1px solid var(--line); border-radius: 8px; padding: 0 .6rem; color: var(--text); }
.attach input[type=file] { display: none; }
.back { display: none; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - 90px); }
  .chat-layout.open #chatList { display: none; }
  .chat-layout:not(.open) #chatView { display: none; }
  .back { display: inline-block; }
}
.chat-sim .messages { height: 50vh; border-radius: 8px; margin: .8rem 0; }
.chat-sim .composer { padding: 0 0 .6rem; border: 0; }

/* Catálogo: abas Serviços/Produtos e botão liga/desliga */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; margin: .4rem 0 .6rem; flex-wrap: wrap; }
.segmented button { background: transparent; color: var(--text); font-weight: 500; padding: .45rem .9rem; }
.segmented button.on { background: var(--brand); color: var(--brand-ink); }
.switch { position: relative; width: 46px; height: 26px; border-radius: 99px; padding: 0; flex: none;
          background: var(--line); border: 0; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
               box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .15s; }
.switch.on { background: var(--ok); }
.switch.on span { left: 23px; }
.list-row.off .grow { opacity: .55; }

/* Modo embutido (dentro do Controle de Estoque): o app de fora já tem a barra lateral */
html.embed #tabs { display: none; }
html.embed main { padding: 10px; }
html.embed .chat-layout { height: calc(100vh - 20px); }

/* Serviço: botões + profissional embaixo */
.svc-actions { display: flex; flex-direction: column; align-items: stretch; gap: .4rem; min-width: 260px; }
.prof-pick { flex-direction: row; align-items: center; gap: .4rem; font-size: .85rem; white-space: nowrap; }
.prof-pick select { padding: .4rem .5rem; font-size: .9rem; }

/* Popup (oferecer junto) */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 640px;
         max-height: calc(100vh - 32px); display: flex; flex-direction: column; padding: 1rem; gap: .4rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.pick-list { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 10px; min-height: 200px; }
.pick-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.pick-row:hover { background: var(--bg); }
.pick-row.on { background: var(--out); }
.pick-check { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center;
              font-weight: 700; color: var(--brand-ink); flex: none; }
.pick-row.on .pick-check { background: var(--brand); border-color: var(--brand); }
.pick-icon { flex: none; }

/* Consumo da OpenAI */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin: .4rem 0; }
.stat { display: flex; flex-direction: column; gap: .15rem; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat.low { border-color: var(--danger); }
.stat.low b { color: var(--danger); }
.saldo-aviso { display: block; max-width: 1100px; margin: 0 auto 12px; padding: .55rem .8rem; border-radius: 10px;
               background: #fde68a; color: #111; text-decoration: none; font-size: .9rem; }

/* Itens associados (venda casada) */
.field-title { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .35rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 99px; padding: .3rem .75rem; font-weight: 500; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* Avisos internos e funil */
.msg.sistema { align-self: center; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: .85rem; text-align: center; }
.tag.funil-topo { border-color: #fca5a5; color: #dc2626; font-weight: 600; }
.tag.funil-meio { border-color: #fcd34d; color: #b45309; }
.tag.funil-fundo { border-color: #86efac; color: var(--ok); font-weight: 600; }

/* Agenda */
.agenda-top { justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.agenda-top h2 { margin: 0; }
.date-pick { width: auto; }
.agenda-day { border-top: 1px solid var(--line); padding: .6rem 0 .2rem; }
.agenda-day.today .agenda-head b { color: var(--brand); }
.agenda-head { display: flex; gap: .6rem; align-items: baseline; }
.agenda-head b::first-letter { text-transform: uppercase; }
.empty-day { margin: .3rem 0; font-size: .9rem; }
.list-row.appt { border-top: 0; padding: .4rem 0; }
.appt .when { font-weight: 700; min-width: 110px; font-variant-numeric: tabular-nums; }
.appt.concluido .grow { opacity: .55; }
.appt.block .grow { color: var(--muted); }

/* Listas */
.list-row { display: flex; align-items: center; gap: .6rem; padding: .6rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list-row .grow { flex: 1; min-width: 180px; }
.draft { white-space: pre-wrap; background: var(--bg); padding: .8rem; border-radius: 8px; font: inherit; }

#toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--text); color: var(--bg);
         padding: .6rem 1rem; border-radius: 8px; max-width: calc(100% - 32px); z-index: 10; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: .6rem 1rem; background: #fde68a; color: #111; z-index: 20; }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* Foto cadastrada pelo atendente. */
.contact-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: 0 0 44px; }
.chat-item .list-avatar { float: left; margin-right: .65rem; }
.chat-item::after { content: ""; display: block; clear: both; }
.photo-picker { position: relative; display: inline-block; padding: .4rem; cursor: pointer; font-size: .85rem; }
.photo-picker input[type=file] { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.photo-picker:focus-within { outline: 2px solid currentColor; border-radius: 6px; }
/* Atendimento: topo da lista (Clientes + Treinar IA + busca) e painel Treinar IA */
.lista-topo { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .8rem .3rem; }
.treinar-ia { background: #F6EEF2; color: #B05C74; border: 0; border-radius: 10px; padding: .4rem .7rem; font-weight: 700; font-size: .85rem; cursor: pointer; }
.treinar-ia.ativo, .treinar-ia:hover { background: #F3DDE6; }
.busca-cliente { display: block; width: calc(100% - 1.6rem); margin: .3rem .8rem .6rem; box-sizing: border-box; }
.treino-painel { padding: 1rem; overflow: auto; height: 100%; box-sizing: border-box; }
.treino-topo { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.treino-topo h2 { margin: 0; }
.treino-intro { margin: .4rem 0 .9rem; }
.treino-form { margin-bottom: 0; }
.treino-acoes { align-items: center; justify-content: flex-end; position: sticky; bottom: 0; background: var(--card); padding: .6rem 0; }

/* Tiques do WhatsApp nas mensagens da loja: ✓ enviada, ✓✓ entregue, ✓✓ azul lida */
.tique { margin-left: .25rem; font-weight: 700; letter-spacing: -.25em; padding-right: .25em; color: #8a8a8a; }
.tique-read { color: #34B7F1; }
.tique-failed { color: #C0392B; letter-spacing: 0; }

/* Atendimento: botões Testar IA / Treinar IA lado a lado e painel de teste */
.lista-botoes { display: flex; gap: .35rem; flex-shrink: 0; }
.lista-botoes .treinar-ia { padding: .35rem .55rem; font-size: .8rem; white-space: nowrap; }
.teste-painel { height: 100%; overflow: auto; box-sizing: border-box; padding: .6rem; }
.teste-topo { display: flex; justify-content: flex-end; margin-bottom: .3rem; }
.teste-painel .card { margin-bottom: 0; border: 0; padding: .4rem; }

/* Atendimento → 🧪 Testar IA: mesmo visual do "Testar a IA de cobrança" do Controle */
.teste-ia { display: flex; flex-direction: column; gap: .55rem; height: 100%; box-sizing: border-box; padding: .9rem;
    background: #fff; border: 1px solid #EADBE2; border-radius: 14px; color: #5B4450; }
.teste-ia-topo { display: flex; align-items: center; gap: .5rem; }
.teste-ia-topo h2 { flex: 1; margin: 0; font-size: 1.05rem; font-weight: 700; color: #5B4450; }
.teste-ia-botao { background: #F6EEF2; color: #B05C74; border: 0; border-radius: 10px; padding: .55rem .9rem; font-weight: 700; font-size: .8rem; cursor: pointer; }
.teste-ia-botao:hover { background: #F3DDE6; }
.teste-ia-sobre { margin: 0; font-size: .78rem; color: #8F7A84; }
.teste-ia-msgs { flex: 1; min-height: 160px; overflow: auto; display: flex; flex-direction: column; gap: .5rem;
    padding: .6rem; background: #FBF8FA; border: 1px solid #EADBE2; border-radius: 14px; }
.teste-ia-balao { max-width: 78%; padding: .5rem .75rem; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word;
    font-size: .88rem; color: #3E2F37; }
.teste-ia-balao.ia { align-self: flex-end; background: #DCF4E6; }
.teste-ia-balao.cliente { align-self: flex-start; background: #fff; border: 1px solid #EADBE2; }
.teste-ia-balao.sistema { align-self: center; background: #FFF6E5; font-size: .78rem; color: #8F7A84; }
.teste-ia-meta { display: block; text-align: right; font-size: .7rem; color: #8F7A84; margin-top: .15rem; }
.teste-ia-status { font-size: .78rem; color: #8F7A84; padding: 0 .35rem; }
.teste-ia-erro { font-size: .78rem; color: #C0392B; padding: 0 .35rem; }
.teste-ia-envio { display: flex; gap: .5rem; }
.teste-ia-envio input { flex: 1; border: 1px solid #EADBE2; border-radius: 10px; padding: .6rem .7rem; font-size: .88rem; color: #5B4450; background: #fff; }
.teste-ia-envio button { background: #2E7D5B; color: #fff; border: 0; border-radius: 10px; padding: 0 1.1rem; font-weight: 700; cursor: pointer; }
.teste-ia-envio button:disabled { opacity: .6; }
.teste-painel:has(.teste-ia) { padding: 0; }

/* 📣 Campanhas dentro do 🎓 Treinar IA */
.campanhas-embutido { display: grid; gap: .8rem; }
.campanhas-embutido .card { margin: 0; box-shadow: none; }
.campanhas-embutido h3, .tab h3 { font-size: 1rem; margin: 0; }
button.mini { padding: .3rem .7rem; font-size: .85rem; }
.camp-editor { margin: .8rem 0 .4rem; }
.camp-previa { max-width: 380px; background: var(--out); border-radius: 10px; padding: .6rem .8rem; display: grid; gap: .3rem; }
.camp-previa-texto { white-space: pre-wrap; }
.camp-previa-botao { border-top: 1px solid var(--line); padding-top: .4rem; text-align: center; color: var(--brand); font-weight: 600; }
.topo-lista { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1.2rem; }
.selo { font-size: .8rem; font-weight: 700; border-radius: 99px; padding: .1rem .6rem; border: 1px solid var(--line); white-space: nowrap; }
.selo.aprovado { color: var(--ok); border-color: #b7e2cc; background: #e7f6ef; }
.selo.analise { color: #b45309; border-color: #f3d9a8; background: #fdf3e3; }
.selo.recusado { color: var(--danger); border-color: #f5c2bd; background: #fdecea; }
.grupo-linha { cursor: pointer; }
.grupo-linha.aberto { border-top-color: var(--brand); }
.grupo-corpo { display: grid; gap: .6rem; padding: .6rem .8rem .8rem; border: 1px solid var(--line); border-radius: 10px; margin-bottom: .6rem; }
.grupo-corpo .membro { padding: .3rem 0; }
.botao-arquivo { display: inline-flex; flex-direction: row; align-items: center; gap: .4rem; border: 1px solid var(--line); border-radius: 8px;
  padding: .45rem .8rem; color: var(--brand); cursor: pointer; position: relative; overflow: hidden; }
.botao-arquivo input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.busca-membro { max-width: 320px; }

/* 📨 Templates de campanha: lista e editor igual ao "Criar template pelo app" da Cobrança */
.tpl-resumo { display: grid; gap: .5rem; margin-top: .8rem; }
.tpl-item { display: flex; align-items: center; gap: .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; }
.tpl-item .grow { flex: 1; display: grid; gap: .1rem; min-width: 0; }
.tpl-item small { font-size: .78rem; }
.tpl-editor { background: var(--card); border-radius: 12px; padding: 1rem; width: min(980px, 100%); max-height: calc(100vh - 32px);
  overflow: auto; display: grid; gap: .8rem; box-sizing: border-box; }
.tpl-editor h2 { margin: 0; font-size: 1.1rem; }
.tpl-editor p { margin: 0; }
.tpl-editor-topo { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tpl-editor-corpo { display: grid; grid-template-columns: 1fr 320px; gap: 1rem; align-items: start; }
@media (max-width: 760px) { .tpl-editor-corpo { grid-template-columns: 1fr; } }
.tpl-form { display: grid; gap: .65rem; }
.tpl-linha-cat { display: grid; grid-template-columns: 1fr 110px; gap: .6rem; }
.tpl-linha-botao { display: grid; grid-template-columns: 200px 1fr; gap: .6rem; }
@media (max-width: 520px) { .tpl-linha-botao { grid-template-columns: 1fr; } }
.tpl-ia { display: flex; gap: .5rem; flex-wrap: wrap; }
.tpl-ia input { flex: 1; min-width: 200px; }
.tpl-etiquetas { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: -.3rem; }
button.etiqueta { background: #f6eef2; color: #b05c74; border: 0; border-radius: 10px; padding: .25rem .6rem; font-size: .78rem; font-weight: 700; }
.tpl-previa { background: #efe7de; border-radius: 12px; padding: .75rem; display: grid; gap: .5rem; position: sticky; top: 0; }
.tpl-balao { background: #fff; color: #17201d; border-radius: 10px; padding: .6rem .75rem; display: grid; gap: .4rem; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tpl-balao .muted { color: #66726e; }
.tpl-balao-botao { border-top: 1px solid #dfe5e2; padding-top: .45rem; text-align: center; color: #0b84c4; font-weight: 700; }
.tpl-acoes { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.tpl-topo-tipo { display: grid; gap: .3rem; }
.tpl-opcoes { display: flex; flex-wrap: wrap; gap: .4rem; }
button.opcao { background: transparent; color: var(--text); border: 1px solid var(--line); padding: .35rem .75rem; font-weight: 500; }
button.opcao.ativa { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.tpl-midia { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.tpl-balao-midia { width: 100%; max-height: 260px; object-fit: cover; border-radius: 8px; display: block; background: #000; }
.tpl-balao-midia.vazio { height: 140px; display: grid; place-items: center; background: #dfe5e2; color: #66726e; font-weight: 600; }
.tpl-balao-midia.vazio.video { background: #1f2a28; color: #fff; }
.camp-previa .tpl-balao-midia { margin-bottom: .3rem; }
/* Selo no topo da conversa: a última mensagem da loja chegou? a cliente viu? */
.situacao-ultima { display: inline-block; margin-top: .25rem; font-size: .78rem; font-weight: 700; border-radius: 99px; padding: .05rem .55rem;
  border: 1px solid var(--line); color: #66726e; background: #f4f6f5; }
.situacao-ultima.situacao-delivered { color: #4b5563; background: #eef1f0; }
.situacao-ultima.situacao-read { color: #0b7fb3; background: #e6f6fd; border-color: #b9e4f7; }
.situacao-ultima.situacao-failed { color: #c0392b; background: #fdecea; border-color: #f5c2bd; }
.grupo-titulo { margin: .2rem 0 0; font-size: .95rem; }
.membros-lista { border: 1px solid var(--line); border-radius: 8px; padding: 0 .6rem; background: var(--card); max-height: 320px; overflow: auto; }
.membros-lista .list-row:first-child { border-top: 0; }
.agendar-linha { align-items: flex-end; }
.agendar-linha label { min-width: 140px; }
.msg-falhou { display: block; margin-top: .3rem; font-size: .78rem; color: var(--danger); font-weight: 600; }

/* Treinamento e campanhas no celular. */
.treino-atalhos { display: flex; flex-wrap: wrap; margin-bottom: .75rem; }
.treino-painel .topico-corpo { min-width: 0; }
@media (max-width: 760px) {
  .treino-painel { min-width: 0; min-height: 0; padding: .75rem; overflow-y: auto; overflow-x: hidden; }
  .treino-topo { flex-wrap: wrap; }
  .treino-painel .grid-form { grid-template-columns: minmax(0, 1fr); }
  .treino-painel .topico-cabecalho { flex-wrap: wrap; gap: .4rem; }
  .treino-painel .campanhas-embutido .card { min-width: 0; padding: .7rem; }
  .treino-painel .row { flex-wrap: wrap; }
  .treino-painel :is(input, select, textarea) { max-width: 100%; box-sizing: border-box; }
  .treino-acoes { position: static; flex-wrap: wrap; }
}
/* 🚫 Propaganda: botão para ver os números separados da lista de clientes */
.propaganda-toggle { width: calc(100% - 1.2rem); margin: .3rem .6rem .5rem; font-size: .85rem; padding: .35rem .6rem; color: var(--muted); }
.propaganda-toggle.ativo { color: var(--brand); border-color: var(--brand); }
/* 🤖 Simular cliente (Testar IA) */
.sim-painel { display: grid; gap: .5rem; padding: .7rem .8rem; margin: 0 0 .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.sim-painel label { display: grid; gap: .25rem; font-size: .9rem; }
.sim-linha { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.sim-linha label { display: flex; align-items: center; gap: .4rem; }
.sim-linha select { width: auto; }
.teste-ia-botao.ativo { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
/* 📊 Testar IA: funil e o que faltou para fechar */
.analise-painel { display: grid; gap: .5rem; padding: .6rem .8rem; margin: .5rem 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: .9rem; }
.analise-funil { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.analise-funil .teste-ia-botao { margin-left: auto; }
.analise-resultado { border-left: 4px solid #fca5a5; padding: .3rem .7rem; }
.analise-resultado.ok { border-left-color: #86efac; }
.analise-resultado p { margin: .25rem 0 .4rem; }
.analise-resultado ul { margin: .2rem 0 .5rem; padding-left: 1.2rem; }
