:root {
  --verde: #c4161c; --verde-esc: #9b1015; --verde-claro: #fdeeee; --fundo-chat: #f4f1ee; --destaque: #e9a23b;
  --barra: #17181c; --barra2: #2a2c33; --painel: #fff; --cinza: #f4f6f9; --linha: #dfe3ea;
  --texto: #17181c; --suave: #5b6475; --quente: #e8590c; --morno: #fb8c00; --frio: #78909c; --azul: #027eb5;
  --alto: 100dvh;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14.5px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, sans-serif; color: var(--texto); background: #e4e7ec; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.oculto { display: none !important; }
a { color: var(--azul); }

/* ---------- estrutura ---------- */
.app { display: flex; height: var(--alto); max-width: 1700px; margin: 0 auto; background: var(--painel); box-shadow: 0 6px 18px rgba(11,20,26,.15); }
.trilho { width: 64px; background: var(--barra); border-right: 1px solid var(--linha); display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px; flex-shrink: 0; }
.trilho .logo { width: 42px; height: 42px; border-radius: 11px; background: var(--verde); color: #fff; font: 900 26px/1 "Segoe UI", Arial, sans-serif; display: grid; place-items: center; margin-bottom: 12px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.trilho button { width: 46px; height: 46px; border: 0; border-radius: 12px; background: transparent; color: #aeb4bf; display: grid; place-items: center; position: relative; }
.trilho button:hover { background: #2a2c33; color: #fff; }
.trilho button.ativo { background: var(--verde); color: #fff; }
.trilho button svg { width: 24px; height: 24px; }
.trilho .espaco { flex: 1; }
.trilho .contador { position: absolute; top: 4px; right: 3px; background: var(--destaque); color: #17181c; color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 99px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; }
.dica { position: relative; }
.dica[data-dica]:hover::after { content: attr(data-dica); position: absolute; left: 54px; top: 50%; transform: translateY(-50%); background: var(--barra); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; z-index: 50; }

.tela { flex: 1; min-width: 0; display: flex; }
.vista { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- lista de conversas ---------- */
.lista { width: 380px; border-right: 1px solid var(--linha); display: flex; flex-direction: column; flex-shrink: 0; background: #fff; }
.topo { height: 60px; padding: 0 16px; background: var(--cinza); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--linha); flex-shrink: 0; }
.topo h2 { font-size: 19px; margin: 0; font-weight: 600; flex: 1; }
.icone { border: 0; background: transparent; color: #54656f; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.icone:hover { background: rgba(0,0,0,.06); }
.icone svg { width: 22px; height: 22px; }
.busca { padding: 8px 12px; border-bottom: 1px solid var(--linha); }
.busca input { width: 100%; border: 0; background: var(--cinza); border-radius: 8px; padding: 8px 12px; outline: none; }
.abas { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--linha); scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.aba { flex-shrink: 0; border: 0; background: var(--cinza); color: #54656f; border-radius: 99px; padding: 5px 12px; font-size: 13.5px; white-space: nowrap; }
.aba.ativa { background: var(--barra); color: #fff; font-weight: 600; }
.aba .n { margin-left: 4px; font-size: 12px; opacity: .8; }
.aba.nova { background: transparent; border: 1px dashed #aebac1; }
.conversas { flex: 1; overflow-y: auto; }
.item { display: flex; gap: 12px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--linha); align-items: center; }
.item:hover { background: #f5f6f6; }
.item.ativo { background: #f0f2f5; }
.avatar { width: 48px; height: 48px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 600; flex-shrink: 0; font-size: 17px; position: relative; }
.avatar.p { width: 40px; height: 40px; font-size: 15px; }
.avatar .temp { position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.temp.quente, .ponto.quente { background: var(--quente); } .temp.morno, .ponto.morno { background: var(--morno); } .temp.frio, .ponto.frio { background: var(--frio); }
.item .meio { flex: 1; min-width: 0; }
.item .l1, .item .l2 { display: flex; align-items: center; gap: 6px; }
.item .nome { font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .hora { font-size: 12px; color: var(--suave); flex-shrink: 0; }
.item.pendente .hora { color: var(--verde); font-weight: 600; }
.item .previa { color: var(--suave); font-size: 13.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .bolinha { width: 10px; height: 10px; border-radius: 50%; background: var(--verde); flex-shrink: 0; }
.selo { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: #e7f0ff; color: #2954a3; white-space: nowrap; }
.selo.ped { background: #fff3e0; color: #b45309; }
.selo.dono { background: #ede7f6; color: #5e35b1; }
.selo.etq { background: #eef0f4; color: #3b4252; }
.vazio { padding: 40px 20px; text-align: center; color: var(--suave); }

/* ---------- chat ---------- */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--fundo-chat); }
.chat .topo { background: var(--cinza); }
.chat .topo .info { flex: 1; min-width: 0; cursor: pointer; }
.chat .topo .info b { display: block; font-weight: 500; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .topo .info small { color: var(--suave); font-size: 12.5px; }
.chat .topo select { border: 1px solid var(--linha); border-radius: 8px; padding: 5px 8px; background: #fff; max-width: 170px; }
.ia-chave { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--suave); white-space: nowrap; }
.mensagens { flex: 1; overflow-y: auto; padding: 14px 6% 10px; background-color: var(--fundo-chat);
  background-image: radial-gradient(rgba(196,22,28,.06) 1px, transparent 1px); background-size: 18px 18px; }
.dia { text-align: center; margin: 10px 0; }
.dia span { background: #fff; color: var(--suave); font-size: 12px; padding: 5px 12px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11,20,26,.13); }
.bolha { max-width: min(78%, 560px); padding: 6px 9px 6px; border-radius: 8px; margin: 2px 0; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px .5px rgba(11,20,26,.13); position: relative; font-size: 14.5px; }
.bolha.entrada { background: #fff; border-top-left-radius: 0; }
.bolha.saida { background: var(--verde-claro); margin-left: auto; border-top-right-radius: 0; }
.bolha.saida.ia { background: #fff; border: 1px solid #f3c9cb; }
.bolha.saida.sistema { background: #fff8e1; }
.bolha .autor { display: block; font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.bolha.ia .autor { color: var(--verde); } .bolha.sistema .autor { color: #b45309; } .bolha.humano .autor { color: var(--barra); }
.bolha .rodape { float: right; font-size: 11px; color: var(--suave); margin: 6px 0 -4px 10px; }
.bolha .falhou { color: var(--quente); display: block; font-size: 12px; }
.bolha .tipo { font-style: italic; color: var(--suave); }
.aviso { background: #fff3cd; color: #7a5b00; padding: 9px 14px; font-size: 13.5px; border-top: 1px solid #f1e2a8; }
.compor { background: var(--cinza); padding: 8px 12px; display: flex; gap: 8px; align-items: flex-end; position: relative; }
.compor textarea { flex: 1; border: 0; border-radius: 8px; padding: 10px 12px; resize: none; max-height: 140px; min-height: 42px; outline: none; background: #fff; }
.botao-red { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--verde); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.botao-red.sec { background: #fff; color: #54656f; }
.botao-red svg { width: 22px; height: 22px; }
.rapidas { display: flex; gap: 6px; overflow-x: auto; padding: 6px 12px 0; background: var(--cinza); scrollbar-width: thin; }
.rapidas button { flex-shrink: 0; border: 1px solid var(--linha); background: #fff; border-radius: 99px; padding: 4px 11px; font-size: 13px; color: #3b4a54; }
.atalhos { position: absolute; bottom: 60px; left: 12px; right: 70px; background: #fff; border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,.18); max-height: 260px; overflow-y: auto; z-index: 20; }
.atalhos div { padding: 9px 14px; cursor: pointer; border-bottom: 1px solid var(--linha); }
.atalhos div:hover, .atalhos div.sel { background: var(--cinza); }
.atalhos b { color: var(--verde-esc); margin-right: 6px; }
.boas-vindas { flex: 1; display: grid; place-items: center; text-align: center; color: var(--suave); background: var(--cinza); border-bottom: 6px solid var(--verde); }
.boas-vindas h3 { color: #41525d; font-weight: 300; font-size: 28px; margin: 10px 0; }

/* ---------- ficha (CRM) ---------- */
.ficha { width: 360px; border-left: 1px solid var(--linha); background: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.ficha .corpo { flex: 1; overflow-y: auto; }
.bloco { padding: 14px 18px; border-bottom: 8px solid var(--cinza); }
.bloco h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--verde-esc); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.bloco h4 .dir { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.cabeca-ficha { text-align: center; padding: 20px 18px; border-bottom: 8px solid var(--cinza); }
.cabeca-ficha .avatar { width: 84px; height: 84px; font-size: 30px; margin: 0 auto 10px; }
.cabeca-ficha b { font-size: 19px; font-weight: 500; display: block; }
.cabeca-ficha small { color: var(--suave); }
.campo { display: block; margin-bottom: 9px; }
.campo span { display: block; font-size: 12px; color: var(--suave); margin-bottom: 3px; }
.campo input, .campo select, .campo textarea, .ent { width: 100%; border: 1px solid #d1d7db; border-radius: 8px; padding: 7px 10px; background: #fff; outline: none; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .ent:focus { border-color: var(--verde); }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.etiquetas { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.etiquetas .selo button { border: 0; background: none; color: inherit; padding: 0 0 0 2px; font-size: 13px; line-height: 1; }
.etiquetas input { border: 1px dashed #aebac1; border-radius: 99px; padding: 2px 10px; font-size: 12.5px; width: 120px; outline: none; }
.btn { border: 0; background: var(--verde); color: #fff; border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn:hover { background: var(--verde-esc); }
.btn.sec { background: #fff; color: var(--verde-esc); border: 1px solid #d1d7db; }
.btn.sec:hover { background: var(--cinza); }
.btn.perigo { background: #fff; color: var(--quente); border: 1px solid #f3c1c1; }
.btn:disabled { opacity: .55; cursor: default; }
.linha-btn { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg { font-size: 12.5px; color: var(--suave); margin-top: 6px; }
.msg.erro, .erro { color: var(--quente); }
.lembrete { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px dashed var(--linha); }
.lembrete .q { color: var(--suave); white-space: nowrap; }
.lembrete.atrasado .q { color: var(--quente); font-weight: 600; }
.lembrete span.t { flex: 1; }
.status-pedido { background: var(--cinza); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 10px; }
.status-pedido b { display: block; font-size: 14.5px; }
.etapa { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #e0e0e0; }
.etapa.rascunho { background: #eceff1; } .etapa.enviada { background: #e3f2fd; color: #0d47a1; } .etapa.erro, .etapa.conferir { background: #ffebee; color: #b71c1c; }
.etapa.finalizada { background: #e8f5e9; color: #1b5e20; } .etapa.cancelada { background: #fbe9e7; color: #8d2b0b; } .etapa.enviando { background: #fff8e1; }

/* ---------- páginas (funil, leads, config) ---------- */
.pagina { flex: 1; overflow-y: auto; background: var(--cinza); }
.pagina .dentro { max-width: 1200px; margin: 0 auto; padding: 18px; }
.cartao { background: #fff; border-radius: 12px; padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(11,20,26,.08); }
.cartao h3 { margin: 0 0 12px; font-size: 16px; }
.ajuda { color: var(--suave); font-size: 13px; margin: 4px 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(11,20,26,.08); }
.kpi b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--suave); font-size: 13px; }
.funil { display: flex; gap: 12px; overflow-x: auto; padding: 18px; height: 100%; align-items: flex-start; }
.coluna { background: #e9edef; border-radius: 12px; padding: 10px; width: 280px; flex-shrink: 0; max-height: 100%; display: flex; flex-direction: column; }
.coluna h4 { margin: 2px 4px 10px; font-size: 14px; display: flex; justify-content: space-between; }
.coluna .cards { overflow-y: auto; min-height: 60px; flex: 1; }
.coluna.alvo { outline: 2px dashed var(--verde); }
.card { background: #fff; border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(11,20,26,.1); font-size: 13.5px; }
.card .t { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.card .t b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card p { margin: 0; color: #54656f; font-size: 13px; }
.card select { margin-top: 6px; width: 100%; border: 1px solid var(--linha); border-radius: 6px; padding: 3px; font-size: 12.5px; }
.ponto { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { color: var(--suave); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.tabela-rolagem { overflow-x: auto; }
.resultado { background: var(--barra); color: #e9edef; padding: 12px; border-radius: 8px; white-space: pre-wrap; font: 12.5px/1.5 ui-monospace, Consolas, monospace; max-height: 340px; overflow: auto; }

/* ---------- login ---------- */
.entrada-tela { min-height: var(--alto); display: grid; place-items: center; background: linear-gradient(160deg, var(--barra) 0 45%, var(--verde) 45% 52%, var(--cinza) 52%); padding: 20px; }
.entrada-caixa { background: #fff; border-radius: 14px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,.15); }
.entrada-caixa h1 { font-size: 22px; margin: 0 0 4px; }
.entrada-caixa .btn { width: 100%; padding: 11px; margin-top: 8px; }
.entrada-caixa .troca { text-align: center; margin-top: 14px; font-size: 13.5px; }

dialog { border: 0; border-radius: 14px; padding: 20px; max-width: 460px; width: 94%; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(11,20,26,.5); }
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--barra); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

/* modo privado: desfoca dados para gravar a tela */
body.privado .item .nome, body.privado .item .previa, body.privado .bolha, body.privado .chat .topo .info, body.privado .cabeca-ficha,
body.privado .card, body.privado td, body.privado .ficha .corpo input, body.privado .ficha .corpo textarea { filter: blur(6px); }

/* ---------- celular ---------- */
.nav-baixo { display: none; }
@media (max-width: 1180px) { .ficha { position: fixed; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: -6px 0 20px rgba(0,0,0,.18); } }
@media (max-width: 820px) {
  .app { flex-direction: column; box-shadow: none; }
  .trilho { display: none; }
  .tela { flex: 1; min-height: 0; }
  .lista { width: 100%; border-right: 0; }
  .app.em-chat .lista { display: none; }
  .app:not(.em-chat) .chat { display: none; }
  .ficha { width: 100%; }
  .mensagens { padding: 10px 10px; }
  .bolha { max-width: 88%; }
  .voltar { display: grid !important; }
  .chat .topo select.dono-sel { display: none; }
  .ia-chave span { display: none; }
  .nav-baixo { display: flex; background: #fff; border-top: 1px solid var(--linha); padding-bottom: env(safe-area-inset-bottom); flex-shrink: 0; }
  .app.em-chat .nav-baixo { display: none; }
  .nav-baixo button { flex: 1; border: 0; background: none; padding: 8px 0 6px; color: #54656f; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
  .nav-baixo button.ativo { color: var(--verde-esc); font-weight: 600; }
  .nav-baixo svg { width: 23px; height: 23px; }
  .nav-baixo .contador { position: absolute; top: 2px; left: 55%; background: var(--verde); color: #fff; font-size: 10px; border-radius: 99px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }
  .funil { padding: 12px; }
  .coluna { width: 82vw; }
  .pagina .dentro { padding: 12px; }
  .esconde-cel { display: none; }
}
@media (min-width: 821px) { .voltar { display: none !important; } }

.vista-c { flex: 1; min-width: 0; min-height: 0; display: flex; }
.conversa { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.menu-mais button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 12px 6px; border-bottom: 1px solid var(--linha); font-size: 15px; }
/* identidade PiraGo! */
.entrada-caixa .marca-logo { display: block; width: 100%; max-width: 280px; margin: 0 auto 14px; }
.topo h2 .g { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--verde); color: #fff; font-weight: 900; font-size: 17px; margin-right: 6px; vertical-align: -3px; }
.lista > .topo { background: #fff; border-bottom: 3px solid var(--verde); }
.boas-vindas { border-bottom-color: var(--verde); }
.boas-vindas img { width: 260px; max-width: 70%; }
.nav-baixo button.ativo { color: var(--verde); }
.kpi b { color: var(--barra); }
.kpi:first-child { border-top: 3px solid var(--verde); }