:root {
  --fundo: #f4f1ea;
  --papel: #fffdf8;
  --linha: #e4ded2;
  --texto: #1f2a25;
  --suave: #6b736e;
  --verde: #1f6b4f;
  --verde-claro: #e3f0e8;
  --balao-meu: #dff1e5;
  --balao-bot: #eceae4;
  --alerta: #b5482e;
  --amarelo: #f6e7b8;
  --raio: 10px;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--texto);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fundo); }
button, input, select, textarea { font: inherit; color: inherit; }
.oculto { display: none !important; }
.sub { color: var(--suave); font-size: 14px; margin: 4px 0; }
.erro { color: var(--alerta); font-size: 14px; min-height: 18px; margin: 4px 0; }

.btn { border: 1px solid var(--linha); background: var(--papel); padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #c9c0ae; }
.btn.primario { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.primario:hover { background: #185a42; }
.btn.perigo { color: var(--alerta); }
.btn.fantasma { background: transparent; border-color: transparent; }
.btn.fantasma:hover { background: rgba(0,0,0,.05); }
.btn.icone { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; font-size: 18px; }
.btn.largo { width: 100%; padding: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; color: var(--suave); cursor: pointer; padding: 0 2px; }
input, select, textarea { border: 1px solid var(--linha); background: #fff; border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc9b2; border-color: var(--verde); }

/* login */
.tela-login { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.cartao-login { background: var(--papel); border: 1px solid var(--linha); border-radius: 16px; padding: 32px; width: min(380px, 100%); display: grid; gap: 12px; box-shadow: 0 10px 40px rgba(40,30,10,.06); }
.cartao-login h1 { margin: 8px 0 0; font-size: 24px; }
.cartao-login label { display: grid; gap: 4px; font-size: 14px; color: var(--suave); }
.marca { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.marca-icone { color: var(--verde); }

/* app */
.app { height: 100%; display: flex; flex-direction: column; }
.topo { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--linha); background: var(--papel); }
.topo-dir { margin-left: auto; display: flex; gap: 6px; }
.pilula { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--verde-claro); color: var(--verde); cursor: default; }
.pilula.ruim { background: #f7e1da; color: var(--alerta); cursor: pointer; }
.corpo { flex: 1; display: flex; min-height: 0; }

.lateral { width: 370px; min-width: 300px; border-right: 1px solid var(--linha); display: flex; flex-direction: column; background: var(--papel); }
.lateral-topo { display: flex; gap: 8px; padding: 12px; }
.lateral-topo input { flex: 1; }
.abas { display: flex; padding: 0 12px; gap: 4px; border-bottom: 1px solid var(--linha); }
.abas button { flex: 1; background: none; border: none; padding: 9px 4px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--suave); font-size: 14px; }
.abas button.ativa { color: var(--verde); border-color: var(--verde); font-weight: 600; }
.abas b { font-weight: 600; background: var(--fundo); border-radius: 999px; padding: 1px 7px; font-size: 12px; margin-left: 2px; }
.abas b:empty { display: none; }
.filtros { display: flex; gap: 10px; align-items: center; padding: 10px 12px 4px; font-size: 13px; }
.filtros select { flex: 1; padding: 5px 8px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 5px; color: var(--suave); white-space: nowrap; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 12px 10px; border-bottom: 1px solid var(--linha); }
.chip { font-size: 12px; border: 1px solid var(--linha); border-radius: 999px; padding: 3px 10px; cursor: pointer; background: #fff; display: inline-flex; align-items: center; gap: 5px; }
.chip .ponto, .ponto { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.chip.ativo { background: var(--texto); color: #fff; border-color: var(--texto); }
.chips:empty { display: none; }

.lista { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.item { display: flex; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #f0ebe1; }
.item:hover { background: #faf7f0; }
.item.sel { background: var(--verde-claro); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #d8e6dc; color: var(--verde); display: grid; place-items: center; font-weight: 700; flex: none; }
.item-meio { flex: 1; min-width: 0; }
.item-linha { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-hora { font-size: 12px; color: var(--suave); flex: none; }
.item-hora.novo { color: var(--verde); font-weight: 600; }
.item-ultima { font-size: 13px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-tags { display: flex; gap: 4px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.tag-dono { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--fundo); color: var(--suave); }
.tag-dono.meu { background: var(--verde-claro); color: var(--verde); }
.tag-dono.livre { background: var(--amarelo); color: #6e5510; }
.badge { background: var(--verde); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: auto; }
.lista-vazia { padding: 30px 20px; text-align: center; color: var(--suave); font-size: 14px; }

.conversa { flex: 1; display: flex; min-width: 0; background: var(--fundo); }
.vazio { margin: auto; text-align: center; color: var(--suave); }
.vazio-icone { font-size: 40px; }
.conversa-cheia { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.conversa-topo { display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--papel); border-bottom: 1px solid var(--linha); }
.btn.voltar { display: none; }
.cv-info { flex: 1; min-width: 0; }
.cv-nome { font-weight: 700; }
.cv-sub { font-size: 13px; color: var(--suave); }
.cv-grupos { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.cv-grupos .chip { cursor: default; padding: 1px 8px; font-size: 11px; }
.cv-acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.mensagens { flex: 1; overflow-y: auto; padding: 16px 8%; display: flex; flex-direction: column; gap: 4px; }
.dia { align-self: center; font-size: 12px; color: var(--suave); background: var(--papel); border: 1px solid var(--linha); padding: 2px 10px; border-radius: 999px; margin: 10px 0 6px; }
.msg { max-width: 70%; padding: 7px 10px 5px; border-radius: 10px; background: #fff; align-self: flex-start; box-shadow: 0 1px 0 rgba(0,0,0,.04); white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; line-height: 1.4; }
.msg.atendente { align-self: flex-end; background: var(--balao-meu); }
.msg.bot { align-self: flex-end; background: var(--balao-bot); }
.msg-autor { font-size: 12px; font-weight: 600; color: var(--verde); margin-bottom: 2px; }
.msg.bot .msg-autor { color: var(--suave); }
.msg-hora { font-size: 11px; color: var(--suave); text-align: right; margin-top: 2px; }
.msg img { max-width: 280px; max-height: 320px; border-radius: 6px; display: block; cursor: zoom-in; }
.msg audio, .msg video { max-width: 280px; display: block; }
.anexo { display: flex; align-items: center; gap: 8px; padding: 8px; background: rgba(0,0,0,.04); border-radius: 8px; text-decoration: none; color: inherit; }
.sistema { align-self: center; font-size: 12px; color: #6e5510; background: var(--amarelo); padding: 3px 10px; border-radius: 8px; margin: 6px 0; }
.carregar-mais { align-self: center; }

.aviso-bloqueio { padding: 10px 16px; background: var(--amarelo); color: #5d4710; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: center; }
.composer { display: flex; gap: 8px; padding: 10px 16px; background: var(--papel); border-top: 1px solid var(--linha); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 160px; line-height: 1.4; }

/* janelas */
.fundo { position: fixed; inset: 0; background: rgba(20,20,15,.35); z-index: 10; }
.janela { position: fixed; inset: 0; display: grid; place-items: center; z-index: 11; pointer-events: none; padding: 16px; }
.janela-conteudo { pointer-events: auto; background: var(--papel); border-radius: 14px; padding: 22px; width: min(640px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.janela-conteudo h2 { margin: 0 0 12px; font-size: 20px; }
.janela-conteudo h3 { margin: 18px 0 8px; font-size: 15px; }
.form-linha { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.form-linha input, .form-linha select { flex: 1; min-width: 120px; }
.janela-rodape { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.abas-janela { display: flex; gap: 4px; border-bottom: 1px solid var(--linha); margin-bottom: 14px; }
.abas-janela button { background: none; border: none; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--suave); }
.abas-janela button.ativa { color: var(--verde); border-color: var(--verde); font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--linha); }
th { color: var(--suave); font-weight: 500; font-size: 13px; }
.qr { display: grid; place-items: center; padding: 10px; }
.qr img { width: 280px; height: 280px; }
.lista-check { display: grid; gap: 6px; margin: 8px 0; }
.lista-check label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--linha); border-radius: 8px; cursor: pointer; }
.cor { width: 38px; height: 34px; padding: 2px; flex: none !important; min-width: 0 !important; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--texto); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 20; font-size: 14px; }
.img-grande { max-width: 100%; max-height: 80vh; display: block; margin: auto; }

@media (max-width: 820px) {
  .lateral { width: 100%; min-width: 0; border-right: none; }
  .conversa { display: none; }
  .app.com-conversa .lateral { display: none; }
  .app.com-conversa .conversa { display: flex; }
  .btn.voltar { display: inline-grid; }
  .mensagens { padding: 12px; }
  .msg { max-width: 85%; }
  .cv-acoes .btn { padding: 5px 8px; font-size: 13px; }
  .topo .marca { display: none; }
}
.form-linha input[type=checkbox], .form-linha input[type=radio] { flex: none; min-width: 0; }
@media (max-width: 820px) {
  .conversa-topo { flex-wrap: wrap; }
  .cv-acoes { width: 100%; justify-content: flex-start; }
  .pilula { font-size: 12px; }
}

.avatar { position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #d8e6dc; }
.msg.chamada { background: #fdf0e3; border: 1px solid #f0d2b0; }
.gravando { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: var(--papel); border-top: 1px solid var(--linha); }
.ponto-rec { width: 10px; height: 10px; border-radius: 50%; background: #d23b2a; animation: piscar 1s infinite; }
@keyframes piscar { 50% { opacity: .2; } }
