:root {
  --verde: #00a884;
  --verde-escuro: #008069;
  --verde-fundo: #d9fdd3;
  --tinta: #111b21;
  --mudo: #667781;
  --linha: #e9edef;
  --painel: #ffffff;
  --topo: #f0f2f5;
  --conversa: #efeae2;
  --app: #d1d7db;
  --sombra: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --padrao: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23d5cfc3' stroke-width='1.2'%3E%3Ccircle cx='18' cy='22' r='7'/%3E%3Cpath d='M58 18h16v12H58z'/%3E%3Cpath d='M112 48c10 0 16 8 16 16'/%3E%3Ccircle cx='136' cy='122' r='6'/%3E%3Cpath d='M24 108h18l6 10H24z'/%3E%3Cpath d='M78 86h22v14H78z'/%3E%3Cpath d='M40 58h8v14'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--tinta);
  background: var(--app);
  font-size: 15px;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--verde-escuro); }
h1, h2, p { margin: 0; }
textarea { resize: none; }

.primario, button.primario, a.primario {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--verde);
  color: white;
  border: 0;
  border-radius: 24px;
  padding: 11px 18px;
  font-weight: 600;
  text-decoration: none;
}
.primario:hover { background: var(--verde-escuro); }
.secundario, button.secundario {
  background: white;
  color: var(--tinta);
  border: 1px solid #d1d7db;
  border-radius: 24px;
  padding: 10px 16px;
  font-weight: 600;
}
.fantasma {
  background: transparent;
  border: 0;
  color: var(--mudo);
  border-radius: 8px;
  padding: 8px 10px;
}
.fantasma:hover { background: var(--topo); }
.erro { color: #c0392b; font-size: 14px; }
#toast[hidden] { display: none; }
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #111b21;
  color: white;
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 30;
  max-width: min(420px, calc(100% - 32px));
}

.avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 650;
  flex: none;
  letter-spacing: 0.02em;
}
.avatar.pequeno { width: 40px; height: 40px; font-size: 14px; }
.avatar.negocio { background: #d9fdd3; color: var(--verde-escuro); }

.bolha {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 8px;
  max-width: min(78%, 520px);
  padding: 6px 8px 5px 9px;
  border-radius: 8px;
  box-shadow: var(--sombra);
}
.bolha.entrada { background: white; border-top-left-radius: 0; }
.bolha.saida { background: var(--verde-fundo); border-top-right-radius: 0; }
.bolha .autor { flex: 1 0 100%; font-size: 12.5px; font-weight: 700; line-height: 1.2; }
.bolha .texto { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.35; padding-top: 1px; }
.bolha .hora { margin-left: auto; color: #667781; font-size: 11px; line-height: 1; position: relative; top: 3px; }
.linha { display: flex; margin: 2px 16px; }
.linha.minha { justify-content: flex-end; }
.dia, .sistema {
  width: fit-content;
  max-width: 86%;
  margin: 8px auto;
  padding: 6px 12px 7px;
  border-radius: 8px;
  box-shadow: var(--sombra);
  text-align: center;
  font-size: 12.5px;
  line-height: 1.35;
  color: #54656f;
}
.dia { background: white; }
.sistema { background: #fff6d9; }

/* Entrada */
body.entrada { background: #f7f5f2; color: var(--tinta); }
.topo-site {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
}
.topo-site strong { letter-spacing: 0.04em; }
.topo-site a { text-decoration: none; font-weight: 650; }
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 36px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 28px 48px;
  align-items: start;
}
.hero h1 { font-size: 40px; line-height: 1.15; letter-spacing: -0.03em; max-width: 16ch; }
.passos { margin: 22px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.passos li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; line-height: 1.4; }
.passos span {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--verde-escuro); color: white;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.cartao, .resultado {
  background: white;
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 12px 40px rgba(11, 20, 26, 0.08);
}
.cartao h2, .resultado h2 { font-size: 18px; margin-bottom: 6px; }
.ajuda { color: var(--mudo); font-size: 14px; margin: 6px 0 16px; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; color: #3b4a54; }
input, textarea, select {
  width: 100%;
  border: 1px solid #d1d7db;
  background: white;
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}
textarea { min-height: 74px; }
input:focus, textarea:focus, select:focus { border-color: var(--verde); box-shadow: 0 0 0 3px rgba(0, 168, 132, 0.16); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; font-weight: 500; }
.checks label { display: flex; grid-auto-flow: column; align-items: center; gap: 6px; font-size: 14px; }
.checks input { width: auto; }
.resultado { max-width: 1040px; margin: 0 auto 40px; }
.resultado[hidden] { display: none; }
.resultado .bolha { max-width: 100%; margin-top: 14px; }
.login-pagina {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
}
.login-pagina .cartao { width: min(420px, 100%); }
#instalacao[hidden], #entrar[hidden], #janela-instalacao[hidden], #verificar[hidden], #instalacao-pronto[hidden], #passos[hidden], #instalar[hidden], .como-liberar[hidden] { display: none !important; }
#instalacao .primario, #janela-instalacao .primario { width: 100%; }
#instalacao .avatar, #janela-instalacao .avatar { margin-bottom: 8px; }
.primario:disabled { opacity: 0.45; }
#janela-instalacao { width: min(420px, 100%); max-height: 100dvh; overflow: auto; }
.barra-verificar { position: sticky; top: 0; z-index: 2; background: white; padding: 4px 0 12px; }
.como-liberar { background: #fff6d9; border-radius: 12px; padding: 12px; margin: 0 0 12px; }
.como-liberar strong { display: block; margin-bottom: 8px; }
.como-liberar .passos { margin: 0; }
.checagem { list-style: none; margin: 0 0 8px; padding: 0; display: grid; }
.checagem li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--linha);
}
.checagem .marca {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--topo);
  color: var(--mudo);
  font-weight: 700;
}
.checagem li.ok .marca { background: var(--verde); color: white; }
.checagem li.negado .marca { background: #c0392b; color: white; }
.checagem li.verificando .marca { background: #fff6d9; color: #8a6d1d; }
.checagem strong { display: block; font-size: 14px; }
.checagem small { display: block; color: var(--mudo); font-weight: 450; font-size: 13px; }
.seletor-perm { position: fixed; width: 1px; height: 1px; opacity: 0; }
.demo { display: grid; gap: 8px; margin-top: 8px; }
.demo p { color: var(--mudo); font-size: 13px; }
.demo button { text-align: left; background: var(--topo); border: 0; border-radius: 8px; padding: 8px 10px; }

/* Cliente */
body.cliente { background: var(--conversa); }
body.cliente .app {
  height: 100dvh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--conversa);
}
.topo-chat {
  min-height: calc(60px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--verde-escuro);
  color: white;
}
@media (display-mode: standalone) {
  html:has(body.cliente) { background: var(--verde-escuro); }
}
html.aplicativo:has(body.cliente) { background: var(--verde-escuro); }
.topo-chat small, .topo-web small { display: block; color: rgba(255,255,255,.82); font-size: 13px; font-weight: 400; }
.topo-web small { color: var(--mudo); }
.topo-chat strong, .topo-web strong { font-size: 16px; font-weight: 600; }
.mensagens {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 0 8px;
  background-color: var(--conversa);
  background-image: var(--padrao);
}
.opcoes { background: white; border-top: 1px solid var(--linha); max-height: 42%; overflow: auto; }
.opcoes[hidden], .compositor[hidden], .app[hidden],
#mic[hidden], #enviar[hidden], #enviar-audio[hidden], #camera[hidden], #abrir-emoji[hidden],
.caixa-msg[hidden], .gravando[hidden], .menu-anexo[hidden], .painel-emoji[hidden], .faixa-atalhos[hidden] {
  display: none !important;
}
.opcao {
  width: 100%;
  text-align: left;
  background: white;
  border: 0;
  border-bottom: 1px solid var(--linha);
  padding: 12px 16px;
  color: var(--verde-escuro);
  font-weight: 650;
}
.opcao small { display: block; color: var(--mudo); font-weight: 450; margin-top: 2px; }
.opcao:hover { background: #f7f8fa; }
body.cliente .app, .thread { position: relative; }
.compositor {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  background: #f0f2f5;
}
body.cliente .compositor { background: transparent; }
.caixa-msg, .gravando {
  flex: 1;
  display: flex;
  align-items: flex-end;
  min-height: 48px;
  background: white;
  border-radius: 24px;
  padding: 0 4px 0 14px;
}
.gravando { align-items: center; gap: 8px; padding-right: 10px; }
.gravando .ponto {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ea0038;
  animation: pulso 1s infinite;
}
.gravando time { color: #54656f; font-size: 15px; margin-right: auto; }
@keyframes pulso { 50% { opacity: .35; } }
.compositor textarea {
  flex: 1;
  width: auto;
  min-height: 48px;
  max-height: 120px;
  border: 0;
  border-radius: 0;
  padding: 13px 0;
  background: transparent;
  box-shadow: none;
  resize: none;
}
.compositor textarea:focus { border: 0; box-shadow: none; }
.icone {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #54656f;
  flex: none;
}
.icone-barra, .emoji {
  width: 40px;
  height: 48px;
  border: 0;
  background: transparent;
  color: #54656f;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
}
.emoji { font-size: 24px; width: 42px; }
.enviar, .mic {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--verde);
  color: white;
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
}
.faixa-atalhos { background: #f0f2f5; padding: 6px 10px 0; }
.atalho {
  height: 28px;
  border: 0;
  background: white;
  color: var(--verde-escuro);
  font-weight: 700;
  font-size: 13px;
  border-radius: 14px;
  padding: 0 12px;
}
.menu-anexo {
  position: absolute;
  right: 70px;
  bottom: 68px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(11, 20, 26, 0.18);
}
.menu-anexo button {
  border: 0;
  background: white;
  text-align: left;
  padding: 12px 16px;
  font-size: 15px;
}
.menu-anexo button:hover { background: var(--topo); }
.painel-emoji {
  flex: 0 1 280px;
  min-height: 0;
  max-height: 46%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
  border-top: 1px solid var(--linha);
}
.abas-emoji { display: flex; gap: 6px; padding: 8px 10px 0; overflow: auto; flex: none; }
.abas-emoji button {
  border: 0;
  background: var(--topo);
  border-radius: 14px;
  padding: 6px 10px;
  color: #54656f;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.abas-emoji button.ativa { background: var(--verde-fundo); color: var(--verde-escuro); }
.grade-emoji {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-content: start;
  overflow: auto;
  padding: 6px 8px 8px;
}
.grade-emoji button {
  width: 100%;
  height: 40px;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  border-radius: 8px;
  padding: 0;
}
.grade-emoji button:hover { background: var(--topo); }
.bolha img.foto { display: block; max-width: min(280px, 68vw); border-radius: 6px; }
.bolha audio { width: min(260px, 64vw); height: 36px; }
.cartao-arquivo {
  display: flex;
  gap: 8px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: rgba(11, 20, 26, 0.05);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 180px;
}
.erro-pagina { padding: 48px 20px; text-align: center; }
.erro-pagina[hidden] { display: none; }

@media (min-width: 840px) {
  body.cliente { background: var(--app); display: grid; place-items: center; }
  body.cliente .app {
    width: 420px;
    height: min(880px, calc(100dvh - 40px));
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 16px 50px rgba(11, 20, 26, 0.2);
  }
}

/* Atendente — WhatsApp Web */
body.atendente { background: var(--app); }
.wa-app {
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  background: white;
  overflow: hidden;
}
.lista, .conversa, .thread { min-width: 0; min-height: 0; }
.lista { display: flex; flex-direction: column; background: white; }
.topo-lista, .topo-web {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 16px;
  background: var(--topo);
}
.eu { display: flex; align-items: center; gap: 10px; min-width: 0; }
.eu strong { display: block; font-size: 15px; }
.eu select { border: 0; background: transparent; padding: 0; color: var(--mudo); width: auto; box-shadow: none; }
.acoes-topo { display: flex; gap: 4px; }
.busca { padding: 8px 12px; }
.busca input { background: var(--topo); border: 0; border-radius: 8px; }
.filtros { display: flex; gap: 6px; padding: 0 12px 8px; overflow: auto; }
.filtros button {
  border: 0;
  background: var(--topo);
  color: #54656f;
  border-radius: 999px;
  padding: 6px 11px;
  white-space: nowrap;
  font-size: 13px;
}
.filtros button.ativo { background: var(--verde-fundo); color: var(--verde-escuro); font-weight: 700; }
.itens { flex: 1; overflow: auto; }
.item {
  width: 100%;
  display: grid;
  grid-template-columns: 49px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--linha);
  background: white;
  text-align: left;
}
.item:hover { background: #f5f6f6; }
.item.ativo { background: var(--topo); }
.item .nome { font-weight: 450; }
.item.nao-lida .nome, .item.nao-lida .previa { font-weight: 700; }
.item .previa {
  color: var(--mudo);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.item .lado { display: grid; justify-items: end; gap: 6px; color: var(--mudo); font-size: 12px; }
.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #25d366;
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.vazio {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
  background: var(--topo);
  border-left: 1px solid var(--linha);
  color: var(--mudo);
  padding: 32px;
}
.vazio strong { color: #41525d; font-size: 32px; font-weight: 300; }
.vazio[hidden], .thread[hidden] { display: none !important; }
.conversa { display: flex; min-height: 0; }
.thread { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.topo-web { border-left: 1px solid var(--linha); }
.topo-web .quem { display: flex; align-items: center; gap: 12px; min-width: 0; }
.voltar { display: none; }
.aviso-fila {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff6d9;
  border-left: 1px solid var(--linha);
}
.aviso-fila[hidden] { display: none; }
.atalhos {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding: 8px 12px 0;
  background: var(--topo);
  border-left: 1px solid var(--linha);
}
.atalhos[hidden] { display: none; }
.atalhos button { white-space: nowrap; }
.atalhos button {
  border: 0;
  background: white;
  border-radius: 999px;
  padding: 6px 10px;
  color: #3b4a54;
  box-shadow: var(--sombra);
}
.thread .compositor { border-left: 1px solid var(--linha); }
.thread .mensagens { border-left: 1px solid transparent; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(420px, calc(100% - 24px)); box-shadow: 0 16px 50px rgba(11, 20, 26, 0.28); }
dialog::backdrop { background: rgba(11, 20, 26, 0.45); }
dialog form, .dlg { padding: 18px; display: grid; gap: 12px; }
dialog h2 { font-size: 18px; }
.botoes { display: flex; justify-content: flex-end; gap: 8px; }

/* Admin */
body.admin { background: #f3f4f6; }
.shell { min-height: 100dvh; display: grid; grid-template-columns: 240px 1fr; }
.shell aside {
  background: #111b21;
  color: white;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.marca { padding: 8px 12px 18px; font-size: 18px; letter-spacing: 0.04em; }
.shell aside a {
  color: #d1d7db;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}
.shell aside a.ativo, .shell aside a:hover { background: #202c33; color: white; }
.shell aside .rodape { margin-top: auto; display: grid; gap: 4px; }
.conteudo { padding: 28px; }
.conteudo h1 { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 6px; }
.conteudo > .ajuda, .bloco .ajuda { margin-bottom: 18px; }
.numeros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.numero { background: white; border-radius: 12px; padding: 16px; }
.numero span { color: var(--mudo); font-size: 13px; }
.numero strong { display: block; margin-top: 6px; font-size: 30px; color: var(--verde-escuro); }
.bloco { background: white; border-radius: 14px; padding: 16px; }
.grade { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.grade-menu { display: grid; grid-template-columns: 280px 1fr 300px; gap: 18px; align-items: start; }
.tabela { width: 100%; border-collapse: collapse; }
.tabela th { text-align: left; font-size: 12px; color: var(--mudo); font-weight: 700; }
.tabela td, .tabela th { padding: 10px 8px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; border-radius: 999px; padding: 2px 8px; background: var(--topo); font-size: 12px; color: #3b4a54; }
.pill.ok { background: var(--verde-fundo); color: var(--verde-escuro); }
.pill.fora { background: #fde8e8; color: #9b2c2c; }
.linha-acoes { display: flex; gap: 4px; justify-content: flex-end; }
.phone {
  background: #efeae2;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(11, 20, 26, 0.12);
  min-height: 420px;
  display: flex;
  flex-direction: column;
}
.phone .topo-chat { min-height: 54px; }
.phone .miolo { flex: 1; padding: 14px 10px; background-image: var(--padrao); }
.phone .opcoes { border-radius: 0 0 18px 18px; }
.vazio-lista { color: var(--mudo); padding: 12px 4px; }

@media (max-width: 1100px) {
  .grade-menu, .grade, .hero, .numeros { grid-template-columns: 1fr; }
}
@media (min-width: 1100px) and (min-height: 760px) {
  body.atendente { padding: 16px; }
  .wa-app { height: calc(100dvh - 32px); box-shadow: 0 8px 28px rgba(11, 20, 26, 0.12); }
}
@media (max-width: 860px) {
  body.atendente { padding: 0; }
  .wa-app { height: 100dvh; grid-template-columns: 1fr; }
  .wa-app .conversa { display: none; }
  .wa-app.aberta .lista { display: none; }
  .wa-app.aberta .conversa { display: flex; }
  .voltar { display: grid; }
  .vazio { display: none; }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .shell aside { flex-direction: row; overflow: auto; align-items: center; padding: 8px; }
  .marca { display: none; }
  .shell aside .rodape { margin-top: 0; display: flex; }
  .conteudo { padding: 16px; }
  .hero h1 { font-size: 32px; }
}
