/* Visual no estilo de app de mensagens do iPhone (lista de conversas, pílulas verdes, balões). */
:root {
  --fundo: #FFFFFF;
  --fundo-agrupado: #F6F5F3;
  --texto: #111B21;
  --sec: #667781;
  --linha: #E9EDEF;
  --verde: #25D366;
  --verde-texto: #008069;
  --verde-escuro: #0A5C36;
  --pilula: #F0F2F5;
  --pilula-texto: #54656F;
  --pilula-ativa: #D9FDD3;
  --papel: #EFEAE2;
  --balao-in: #FFFFFF;
  --balao-out: #D9FDD3;
  --vermelho: #C62F3E;
  --e-atendente-bg: #FDE7E9; --e-atendente: #A3182B;
  --e-promessa-bg: #FFEBD6; --e-promessa: #8A3B00;
  --e-sem-bg: #FFF4C2; --e-sem: #6B4E00;
  --e-ia-bg: #ECE6FF; --e-ia: #4B2BB3;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0B141A;
    --fundo-agrupado: #0B141A;
    --texto: #E9EDEF;
    --sec: #8696A0;
    --linha: #222D34;
    --verde-texto: #21C063;
    --verde-escuro: #D9FDD3;
    --pilula: #202C33;
    --pilula-texto: #AEBAC1;
    --pilula-ativa: #103529;
    --papel: #0B141A;
    --balao-in: #202C33;
    --balao-out: #005C4B;
    --vermelho: #F15C6D;
    --e-atendente-bg: #4A1820; --e-atendente: #FFB3BC;
    --e-promessa-bg: #43260C; --e-promessa: #FFC48A;
    --e-sem-bg: #3D3209; --e-sem: #FFE07A;
    --e-ia-bg: #2B2350; --e-ia: #CDBEFF;
  }
  .secao { background: #111B21 !important; }
  html .e-numero { color: var(--c-d); }
  html .pilula .pt { background: var(--c-d); }
  html .btn-verde { color: #0B141A; }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fundo); color: var(--texto); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Roboto, sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
p { margin: 0; }
.sec { color: var(--sec); }
.pequeno { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.erro { color: var(--vermelho); font-size: 14px; min-height: 18px; }

/* Botões */
.btn-verde, .btn-contorno {
  min-height: 46px; padding: 0 22px; border-radius: 23px; font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; gap: 6px;
}
.btn-verde { background: var(--verde-texto); color: #FFFFFF; border: none; }
.btn-contorno { background: transparent; color: var(--verde-texto); border: 1px solid var(--linha); }
.btn-p { min-height: 38px; padding: 0 16px; font-size: 15px; border-radius: 19px; }
.icone-btn {
  width: 44px; height: 44px; border: none; border-radius: 22px; background: transparent; color: var(--verde-texto);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icone-btn:disabled { color: var(--linha); cursor: default; }
.icone-btn.girando svg { animation: gira 0.8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--fundo-agrupado); }
.login-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login-logo { border-radius: 22px; margin-bottom: 6px; }
.login-box h1 { margin: 0; font-size: 28px; font-weight: 700; }
.login-box .grupo { width: 100%; background: var(--fundo); border-radius: 12px; overflow: hidden; text-align: left; margin-top: 10px; }
.campo { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 50px; }
.campo + .campo { border-top: 1px solid var(--linha); }
.campo span { width: 64px; font-size: 16px; white-space: nowrap; }
.campo input { flex: 1; border: none; outline: none; background: transparent; color: var(--texto); font: inherit; font-size: 17px; min-height: 48px; }
.login-box .btn-verde { width: 100%; }
.demo-hint { background: var(--e-sem-bg); color: var(--e-sem); padding: 8px 12px; border-radius: 10px; font-size: 14px; }

/* Topo */
.app { min-height: 100vh; padding-bottom: calc(86px + var(--safe-b)); }
.topo {
  position: sticky; top: 0; z-index: 5; background: var(--fundo);
  padding: calc(6px + var(--safe-t)) 16px 10px; display: flex; flex-direction: column; gap: 6px;
}
.topo-acoes { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.topo h1 { margin: 0; font-size: 34px; font-weight: 700; letter-spacing: -0.6px; }
.busca {
  display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; border-radius: 10px;
  background: var(--pilula); color: var(--sec);
}
.busca input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font: inherit; font-size: 17px; color: var(--texto); }
.busca input::-webkit-search-cancel-button { display: none; }

.aba { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; }

/* Pílulas de filtro */
.pilulas { display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px; scrollbar-width: none; }
.pilulas::-webkit-scrollbar { display: none; }
.pilula {
  flex-shrink: 0; min-height: 34px; padding: 0 14px; border-radius: 17px; border: none; cursor: pointer;
  background: var(--pilula); color: var(--pilula-texto); font: inherit; font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.pilula[aria-pressed="true"], .pilula[aria-selected="true"] { background: var(--pilula-ativa); color: var(--verde-escuro); font-weight: 600; }
.pilula .n { font-size: 13px; opacity: 0.85; }
.pilula .pt { width: 8px; height: 8px; border-radius: 4px; display: inline-block; background: var(--c); }

/* Lista de conversas */
.lista { list-style: none; margin: 4px 0 0; padding: 0; }
.conv { position: relative; }
.conv-linha {
  width: 100%; display: flex; gap: 12px; align-items: flex-start; padding: 10px 16px 0; background: transparent;
  border: none; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.conv-linha:active { background: var(--pilula); }
.avatar {
  width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 19px; color: #FFFFFF;
}
.avatar-g { width: 64px; height: 64px; font-size: 22px; background: var(--verde-texto); }
.conv-corpo { flex: 1; min-width: 0; padding-bottom: 10px; border-bottom: 1px solid var(--linha); display: flex; flex-direction: column; gap: 3px; }
.conv:last-child .conv-corpo { border-bottom: none; }
.conv-l1, .conv-l2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.conv-nome { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-hora { flex-shrink: 0; font-size: 14px; color: var(--verde-texto); font-weight: 500; }
.conv-hora.atraso { color: var(--vermelho); }
.conv-prev { font-size: 15px; color: var(--sec); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; min-width: 0; }
.conv-prev span { overflow: hidden; text-overflow: ellipsis; }
.conv-prev svg { flex-shrink: 0; }
.conv-prev b { color: var(--texto); font-weight: 600; }
.espera {
  flex-shrink: 0; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; font-size: 12px; font-weight: 700;
  background: var(--verde); color: #0B141A; display: inline-flex; align-items: center; justify-content: center;
}
.espera.atraso { background: var(--vermelho); color: #FFFFFF; }
.etqs { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.etq { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.e-numero { color: var(--c); background: transparent; padding-left: 0; padding-right: 2px; display: inline-flex; align-items: center; gap: 5px; }
.e-numero::before { content: ""; width: 8px; height: 8px; border-radius: 4px; background: currentColor; }
.e-atendente { background: var(--e-atendente-bg); color: var(--e-atendente); }
.e-promessa { background: var(--e-promessa-bg); color: var(--e-promessa); }
.e-sem { background: var(--e-sem-bg); color: var(--e-sem); }
.e-ia { background: var(--e-ia-bg); color: var(--e-ia); }
.e-resp { background: var(--pilula); color: var(--pilula-texto); font-weight: 500; }

/* Detalhe com balões */
.conv-detalhe { margin: 0 0 4px 82px; padding: 0 16px 12px 0; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--linha); }
.papel {
  background-color: var(--papel); border-radius: 12px; padding: 12px 10px; display: flex; flex-direction: column; gap: 6px;
  background-image: radial-gradient(rgba(0,0,0,0.035) 1px, transparent 1px); background-size: 14px 14px;
}
.balao {
  max-width: 88%; padding: 6px 9px 5px; border-radius: 8px; font-size: 15px; line-height: 1.35;
  box-shadow: 0 1px 0.5px rgba(11,20,26,0.13); position: relative; display: flex; flex-direction: column;
}
.balao.in { align-self: flex-start; background: var(--balao-in); border-top-left-radius: 0; }
.balao.out { align-self: flex-end; background: var(--balao-out); border-top-right-radius: 0; }
.balao .autor { font-size: 13px; font-weight: 600; margin-bottom: 1px; }
.balao .meta { align-self: flex-end; font-size: 11px; color: var(--sec); margin-top: 2px; display: inline-flex; gap: 3px; align-items: center; }
.aviso-sis { align-self: center; font-size: 12px; background: var(--balao-in); color: var(--sec); padding: 4px 10px; border-radius: 8px; box-shadow: 0 1px 0.5px rgba(11,20,26,0.13); text-align: center; }
.conv-acoes { display: flex; gap: 8px; flex-wrap: wrap; }

.rodape { text-align: center; padding: 16px; }
.vazio { text-align: center; padding: 48px 24px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.vazio .grande { font-size: 18px; font-weight: 600; }
.vazio svg { color: var(--verde-texto); margin-bottom: 4px; }
.faixa { margin: 6px 16px 0; padding: 8px 12px; background: var(--papel); border-radius: 10px; font-size: 14px; color: var(--texto); text-align: center; }

/* Verificações */
.dia { display: flex; justify-content: space-between; align-items: center; padding: 2px 8px; }
.dia-label { font-weight: 600; font-size: 16px; }
.horarios .pilula { flex: 1; flex-direction: column; gap: 0; min-height: 50px; border-radius: 14px; justify-content: center; }
.horarios .h { font-size: 16px; font-weight: 700; }
.horarios .s { font-size: 12px; }

/* Ajustes (lista agrupada) */
.ajustes { background: var(--fundo-agrupado); min-height: calc(100vh - 160px); padding: 8px 16px 24px; gap: 6px; }
.secao { background: #FFFFFF; border-radius: 12px; overflow: hidden; }
.secao-titulo { margin: 16px 0 4px 16px; font-size: 13px; font-weight: 500; text-transform: uppercase; color: var(--sec); letter-spacing: 0.2px; }
.secao-nota { margin: 6px 16px 0; }
.perfil { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.perfil-nome { font-size: 20px; font-weight: 600; }
.linha { display: flex; align-items: center; gap: 12px; padding: 11px 16px; min-height: 48px; }
.linha + .linha { border-top: 1px solid var(--linha); }
.linha-texto { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.linha-botoes { gap: 8px; flex-wrap: wrap; padding-left: 58px; }
.linha-btn { width: 100%; border: none; background: transparent; font: inherit; font-size: 17px; cursor: pointer; justify-content: center; }
.vermelho { color: var(--vermelho); }
.quadrado { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: #FFFFFF; flex-shrink: 0; }
.q-verde { background: #1DAA61; }
.passos { margin: 0; padding: 12px 16px 12px 36px; line-height: 1.8; font-size: 15px; }
.legenda .linha { align-items: flex-start; }
.legenda .etq { flex-shrink: 0; width: 132px; text-align: center; }

/* Barra de abas */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + var(--safe-b)); border-top: 1px solid var(--linha);
  background: color-mix(in srgb, var(--fundo) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.aba-btn {
  min-width: 90px; min-height: 52px; border: none; background: transparent; color: var(--pilula-texto); cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 500; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.aba-btn[aria-current="page"] { color: var(--texto); font-weight: 700; }
.aba-btn[aria-current="page"] svg { stroke-width: 2.4; }
.aba-icone { position: relative; display: flex; }
.aba-badge {
  position: absolute; top: -4px; left: 18px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--verde); color: #0B141A; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--fundo);
}

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(98px + var(--safe-b)); z-index: 20; max-width: 480px; margin: 0 auto;
  background: #111B21; color: #FFFFFF; padding: 12px 14px; border-radius: 12px; font-size: 15px; text-align: center;
}

/* Números de WhatsApp */
.espaco { margin-top: 8px; }
.verde-txt { color: var(--verde-texto); font-weight: 500; gap: 8px; }
.num-linha { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 64px; }
.num-linha + .num-linha { border-top: 1px solid var(--linha); }
.num-linha .avatar { width: 44px; height: 44px; font-size: 16px; position: relative; }
.num-dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #FFFFFF; }
.num-dot.ok { background: var(--verde); }
.num-dot.off { background: #A0AAB0; }
.num-dot.meio { background: #F2B01E; }
.num-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.num-texto p:first-child { font-weight: 600; }
.num-acoes { display: flex; gap: 6px; flex-shrink: 0; }
.link-btn { border: none; background: transparent; color: var(--verde-texto); font: inherit; font-size: 16px; cursor: pointer; min-height: 44px; padding: 0 4px; }
.link-btn.vermelho { color: var(--vermelho); }

/* Folha (QR Code) */
.folha {
  border: none; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 14px 14px 0 0; background: var(--fundo-agrupado); color: var(--texto);
  padding-bottom: var(--safe-b);
}
.folha::backdrop { background: rgba(11, 20, 26, 0.45); }
.folha-topo {
  position: sticky; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 12px;
  background: var(--fundo-agrupado); border-bottom: 1px solid var(--linha);
}
.folha-topo h2 { margin: 0; font-size: 17px; font-weight: 600; }
.folha-topo .link-btn { justify-self: start; }
.folha-corpo { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.folha-corpo .grupo { background: var(--fundo); border-radius: 12px; overflow: hidden; }
.folha-corpo .btn-verde { width: 100%; }
.centro { text-align: center; align-items: center; }
.grande { font-size: 20px; font-weight: 600; }
.passos-qr { margin: 0; padding-left: 22px; line-height: 1.6; font-size: 15px; }
.qr-caixa {
  align-self: center; width: 288px; height: 288px; background: #FFFFFF; border-radius: 16px; padding: 12px;
  display: flex; align-items: center; justify-content: center; position: relative; box-shadow: 0 1px 3px rgba(11,20,26,0.12);
}
.qr-caixa img { width: 264px; height: 264px; image-rendering: pixelated; }
.qr-caixa img:not([src]) { display: none; }
.qr-caixa p { position: absolute; color: #667781; }
.parear { background: var(--fundo); border-radius: 12px; padding: 12px 14px; }
.parear summary { cursor: pointer; color: var(--verde-texto); font-size: 15px; font-weight: 500; }
.parear[open] { display: flex; flex-direction: column; gap: 10px; }
.parear .grupo { border: 1px solid var(--linha); }
.codigo { font-size: 30px; font-weight: 700; letter-spacing: 4px; text-align: center; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) {
  html .num-dot { border-color: #111B21; }
}
.num-acoes { flex-direction: column; align-items: flex-end; gap: 0; }
.num-acoes .link-btn { min-height: 34px; font-size: 15px; }

/* Embutido no Chatwoot (aba "Pendências" dentro da conversa) */
.faixa-alerta { background: var(--e-atendente-bg); color: var(--e-atendente); font-weight: 600; }
.faixa-ok { background: var(--pilula-ativa); color: var(--verde-escuro); font-weight: 600; }
.embutido .topo { padding-top: 4px; gap: 4px; }
.embutido .topo h1 { font-size: 22px; }
.embutido .topo-acoes { min-height: 36px; }
.embutido .conv-detalhe { margin-left: 16px; }
.embutido .avatar:not(.avatar-g) { width: 42px; height: 42px; font-size: 15px; }
