:root {
  --fundo: #f4f1ea;
  --superficie: #fffdf8;
  --superficie-2: #f9f6ef;
  --linha: #e4ded2;
  --texto: #1f2421;
  --texto-2: #5d655f;
  --texto-3: #8b928c;
  --acento: #2f7d6d;
  --acento-forte: #23604f;
  --acento-suave: #e1efe9;
  --eu: #dcefe6;
  --cliente: #ffffff;
  --ia: #e6ecfb;
  --ia-borda: #b9c8f2;
  --alerta: #fff3d6;
  --alerta-borda: #ecd08a;
  --perigo: #b3402e;
  --sombra: 0 1px 2px rgba(30, 36, 33, .06), 0 4px 16px rgba(30, 36, 33, .06);
  --raio: 14px;
  --fonte: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #121513;
    --superficie: #1a1e1b;
    --superficie-2: #20251f;
    --linha: #2c332e;
    --texto: #e8ece7;
    --texto-2: #a9b2ab;
    --texto-3: #7a847c;
    --acento: #4fb39b;
    --acento-forte: #6cc9b1;
    --acento-suave: #1f3530;
    --eu: #1f3a32;
    --cliente: #232823;
    --ia: #1f2740;
    --ia-borda: #3a4b80;
    --alerta: #3a321c;
    --alerta-borda: #6b5a2a;
    --perigo: #ff7d68;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--fundo); color: var(--texto); font: 15px/1.45 var(--fonte); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acento); }
.escondido { display: none !important; }
svg.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- botões e campos ---------- */
.bt { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--linha); background: var(--superficie); border-radius: 10px; padding: 8px 12px; font-weight: 550; line-height: 1.1; }
.bt:hover { background: var(--superficie-2); }
.bt:disabled { opacity: .55; cursor: default; }
.bt.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.bt.primario:hover { background: var(--acento-forte); }
.bt.perigo { color: var(--perigo); }
.bt.pequeno { padding: 5px 9px; font-size: 13px; border-radius: 8px; }
.bt-icone { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--texto-2); }
.bt-icone:hover { background: var(--superficie-2); color: var(--texto); }
.bt-icone.ativo { color: var(--acento); background: var(--acento-suave); }
.campo { width: 100%; border: 1px solid var(--linha); background: var(--superficie); border-radius: 10px; padding: 9px 11px; outline: none; }
.campo:focus { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
textarea.campo { resize: vertical; min-height: 80px; }
label.rotulo { display: block; font-size: 13px; font-weight: 600; color: var(--texto-2); margin: 14px 0 6px; }
.ajuda { font-size: 13px; color: var(--texto-3); margin: 4px 0 0; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); background: var(--superficie); border: 1px solid var(--linha); border-radius: 18px; padding: 28px; box-shadow: var(--sombra); }
.login h1 { font-size: 22px; margin: 12px 0 4px; }
.login p { color: var(--texto-2); margin: 0 0 16px; }
.login .bt { width: 100%; justify-content: center; margin-top: 14px; padding: 11px; }
.login img { width: 44px; height: 44px; }

/* ---------- estrutura ---------- */
.casca { display: grid; grid-template-columns: 64px 340px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.casca.com-painel { grid-template-columns: 64px 340px minmax(0, 1fr) 300px; }

.trilho { background: var(--superficie); border-right: 1px solid var(--linha); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 8px; }
.trilho .logo { width: 36px; height: 36px; margin-bottom: 8px; }
.trilho .fim { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.num-bolinha { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 2px solid transparent; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: var(--cor, var(--acento)); }
.num-bolinha.todos { background: var(--superficie-2); color: var(--texto-2); border-color: var(--linha); font-size: 12px; }
.num-bolinha.ativo { outline: 2px solid var(--texto); outline-offset: 2px; }
.num-bolinha .ponto { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--superficie); background: #c9c3b6; }
.num-bolinha .ponto.ok { background: #2fb37f; }
.num-bolinha .ponto.espera { background: #e0a526; }
.num-bolinha .ponto.ruim { background: var(--perigo); }

/* lista */
.lista { background: var(--superficie); border-right: 1px solid var(--linha); display: flex; flex-direction: column; min-height: 0; }
.lista header { padding: 14px 14px 8px; display: flex; align-items: center; gap: 8px; }
.lista header h2 { font-size: 19px; margin: 0; flex: 1; }
.busca { margin: 0 14px; position: relative; }
.busca svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--texto-3); width: 18px; height: 18px; }
.busca input { padding-left: 34px; background: var(--superficie-2); }
.filtros { display: flex; gap: 6px; padding: 10px 14px; overflow-x: auto; scrollbar-width: none; }
.filtro { border: 1px solid var(--linha); background: transparent; border-radius: 999px; padding: 5px 11px; font-size: 13px; white-space: nowrap; color: var(--texto-2); }
.filtro.ativo { background: var(--texto); border-color: var(--texto); color: var(--superficie); }
.filtro .n { margin-left: 4px; font-weight: 700; }
.itens { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.item { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 8px; border-radius: 12px; cursor: pointer; }
.item:hover { background: var(--superficie-2); }
.item.ativo { background: var(--acento-suave); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: var(--cor, var(--acento)); background: color-mix(in srgb, var(--cor, var(--acento)) 16%, transparent); position: relative; flex: none; }
.avatar .marca { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; background: var(--cor, var(--acento)); border: 2px solid var(--superficie); }
.item .nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .previa { color: var(--texto-2); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 4px; align-items: center; }
.item .previa svg { width: 15px; height: 15px; }
.item .lado { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; font-size: 12px; color: var(--texto-3); }
.selo { min-width: 20px; height: 20px; border-radius: 10px; background: var(--acento); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; padding: 0 6px; }
.selo.atencao { background: #e0a526; }
.chips { display: flex; gap: 4px; }
.chip { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--ia); color: #3550a8; border: 1px solid var(--ia-borda); display: inline-flex; align-items: center; gap: 3px; }
@media (prefers-color-scheme: dark) { .chip { color: #a9bbff; } }
.chip.pausa { background: var(--superficie-2); color: var(--texto-3); border-color: var(--linha); }
.vazio { color: var(--texto-3); text-align: center; padding: 40px 20px; }

/* chat */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--fundo); }
.chat-topo { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--superficie); border-bottom: 1px solid var(--linha); min-height: 64px; }
.chat-topo .quem { flex: 1; min-width: 0; }
.chat-topo .quem b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-topo .quem span { display: block; font-size: 13px; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voltar { display: none; }
.modo-ia { display: inline-flex; border: 1px solid var(--linha); border-radius: 10px; overflow: hidden; background: var(--superficie-2); }
.modo-ia button { border: 0; background: transparent; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--texto-2); display: inline-flex; align-items: center; gap: 5px; }
.modo-ia button.ativo { background: var(--superficie); color: var(--texto); box-shadow: inset 0 0 0 1px var(--linha); }
.modo-ia button.ativo.sugerir { color: #3550a8; }
.modo-ia button.ativo.responder { background: var(--acento); color: #fff; box-shadow: none; }
.modo-ia svg { width: 16px; height: 16px; }
.faixa { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 14px; border-bottom: 1px solid var(--linha); }
.faixa.atencao { background: var(--alerta); border-color: var(--alerta-borda); }
.faixa.pausa { background: var(--superficie-2); color: var(--texto-2); }
.faixa span { flex: 1; }
.mensagens { flex: 1; overflow-y: auto; padding: 18px clamp(12px, 4vw, 48px) 10px; display: flex; flex-direction: column; gap: 3px; }
.dia { align-self: center; font-size: 12px; font-weight: 600; color: var(--texto-2); background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; padding: 3px 10px; margin: 12px 0 8px; }
.msg { max-width: min(560px, 78%); padding: 7px 10px 5px; border-radius: 12px; background: var(--cliente); box-shadow: 0 1px 1px rgba(0,0,0,.05); align-self: flex-start; position: relative; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.mim { align-self: flex-end; background: var(--eu); }
.msg.ia { background: var(--ia); box-shadow: inset 0 0 0 1px var(--ia-borda); }
.msg.junto { margin-top: -1px; }
.msg + .msg:not(.junto) { margin-top: 6px; }
.msg .rodape { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--texto-3); margin-top: 2px; white-space: nowrap; }
.msg .rodape .lido { color: #3b8fd8; }
.msg .autor { font-size: 11px; font-weight: 700; color: #3550a8; display: flex; align-items: center; gap: 3px; margin-bottom: 2px; }
@media (prefers-color-scheme: dark) { .msg .autor { color: #a9bbff; } }
.msg .autor svg { width: 13px; height: 13px; }
.msg.erro { box-shadow: inset 0 0 0 1px var(--perigo); }
.msg .falhou { color: var(--perigo); font-size: 12.5px; margin-top: 4px; white-space: normal; }
.msg.apagada .corpo { opacity: .55; text-decoration: line-through; }
.msg .apagou { font-size: 12px; color: var(--texto-3); font-style: italic; white-space: normal; }
.midia { display: block; max-width: 100%; border-radius: 8px; margin: -2px -4px 4px; cursor: zoom-in; background: var(--superficie-2); }
img.midia { max-height: 320px; width: auto; min-width: 120px; object-fit: cover; }
img.midia.mini { filter: blur(2px); }
.figurinha { width: 120px; height: 120px; object-fit: contain; }
audio.midia { width: 260px; max-width: 100%; height: 40px; cursor: default; background: transparent; }
video.midia { max-height: 320px; cursor: default; }
.doc { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; background: color-mix(in srgb, var(--texto) 5%, transparent); margin-bottom: 4px; text-decoration: none; color: var(--texto); white-space: normal; }
.doc span { flex: 1; overflow-wrap: anywhere; font-size: 14px; }
.carregar-mais { align-self: center; margin-bottom: 8px; }

.sugestao { margin: 0 14px 8px; background: var(--ia); border: 1px solid var(--ia-borda); border-radius: var(--raio); padding: 10px 12px; }
.sugestao .cab { font-size: 12.5px; font-weight: 700; color: #3550a8; display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
@media (prefers-color-scheme: dark) { .sugestao .cab { color: #a9bbff; } }
.sugestao textarea { min-height: 60px; background: var(--superficie); }
.sugestao .acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.compor { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; background: var(--superficie); border-top: 1px solid var(--linha); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.compor textarea { flex: 1; resize: none; min-height: 42px; max-height: 180px; border-radius: 12px; padding: 10px 12px; background: var(--superficie-2); }
.compor .enviar { background: var(--acento); color: #fff; border-radius: 12px; width: 42px; height: 42px; }
.compor .enviar:hover { background: var(--acento-forte); color: #fff; }
.gravando { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--perigo); font-weight: 600; padding: 0 8px; height: 42px; }
.gravando .bola { width: 10px; height: 10px; border-radius: 50%; background: var(--perigo); animation: pisca 1s infinite; }
@keyframes pisca { 50% { opacity: .2; } }

.nada { flex: 1; display: grid; place-items: center; color: var(--texto-3); text-align: center; padding: 24px; }
.nada b { display: block; color: var(--texto-2); font-size: 17px; margin-bottom: 4px; }

/* painel do contato */
.painel { background: var(--superficie); border-left: 1px solid var(--linha); overflow-y: auto; padding: 16px; }
.painel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-3); margin: 22px 0 8px; }
.painel .topo { display: flex; align-items: center; justify-content: space-between; }
.painel .topo h3 { margin: 0; }
.linha-dado { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; padding: 4px 0; color: var(--texto-2); }
.linha-dado b { color: var(--texto); font-weight: 550; text-align: right; overflow-wrap: anywhere; }
.registro { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.registro li { font-size: 13px; border: 1px solid var(--linha); border-radius: 10px; padding: 8px 10px; background: var(--superficie-2); }
.registro li .q { display: flex; justify-content: space-between; color: var(--texto-3); font-size: 12px; margin-bottom: 2px; }
.registro li .t { white-space: pre-wrap; overflow-wrap: anywhere; }
.res-enviada { color: var(--acento); font-weight: 700; }
.res-passou, .res-limite { color: #b07c0c; font-weight: 700; }
.res-erro { color: var(--perigo); font-weight: 700; }
.res-sugerida { color: #3550a8; font-weight: 700; }

/* ajustes */
.ajustes { grid-column: 2 / -1; overflow-y: auto; background: var(--fundo); }
.casca.nos-ajustes .lista { display: none; }
.ajustes .dentro { max-width: 820px; margin: 0 auto; padding: 24px clamp(14px, 4vw, 32px) 60px; }
.ajustes h1 { font-size: 24px; margin: 0 0 4px; }
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--linha); margin: 18px 0 20px; }
.abas button { border: 0; background: transparent; padding: 10px 14px; font-weight: 600; color: var(--texto-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.abas button.ativo { color: var(--texto); border-color: var(--acento); }
.cartao { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra); }
.cartao h2 { font-size: 17px; margin: 0 0 4px; }
.num-cartao { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.num-cartao .status { font-size: 13px; color: var(--texto-2); }
.num-cartao .acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.num-edicao { grid-column: 1 / -1; border-top: 1px solid var(--linha); padding-top: 4px; }
.linha-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.cores { display: flex; gap: 8px; }
.cores button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--cor); }
.cores button.ativo { border-color: var(--texto); }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.interruptor input { width: 44px; height: 26px; appearance: none; background: var(--linha); border-radius: 13px; position: relative; cursor: pointer; transition: background .15s; flex: none; }
.interruptor input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.interruptor input:checked { background: var(--acento); }
.interruptor input:checked::after { transform: translateX(18px); }
.estado-chave { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; }
.estado-chave.ok { background: var(--acento-suave); color: var(--acento); }
.estado-chave.falta { background: var(--alerta); color: #8a6200; }
.teste-ia { display: grid; gap: 8px; }
.teste-ia .resp { white-space: pre-wrap; border-radius: 10px; padding: 10px 12px; background: var(--ia); border: 1px solid var(--ia-borda); }
.teste-ia .resp.passou { background: var(--alerta); border-color: var(--alerta-borda); }

/* janela (modal) */
.fundo-modal { position: fixed; inset: 0; background: rgba(20, 24, 21, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: min(440px, 100%); background: var(--superficie); border-radius: 18px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 92vh; overflow-y: auto; }
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal p { color: var(--texto-2); margin: 0 0 12px; }
.modal .acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.qr { display: grid; place-items: center; min-height: 280px; background: #fff; border-radius: 12px; margin: 10px 0; border: 1px solid var(--linha); }
.qr img { width: 264px; height: 264px; image-rendering: pixelated; }
.qr .carregando-qr { color: #5d655f; }
.passos { color: var(--texto-2); padding-left: 20px; margin: 8px 0 0; font-size: 14px; }
.visor { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: grid; place-items: center; z-index: 60; cursor: zoom-out; }
.visor img { max-width: 96vw; max-height: 94vh; border-radius: 6px; }

/* avisos rápidos */
#avisos { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; pointer-events: none; }
.aviso { background: var(--texto); color: var(--superficie); padding: 10px 16px; border-radius: 12px; box-shadow: var(--sombra); font-size: 14px; max-width: min(520px, 92vw); }
.aviso.erro { background: var(--perigo); color: #fff; }
.carregando::after { content: ""; position: fixed; inset: 0; margin: auto; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--linha); border-top-color: var(--acento); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- celular ---------- */
@media (max-width: 1100px) {
  .casca.com-painel { grid-template-columns: 64px 300px minmax(0, 1fr); }
  .casca.com-painel .painel { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); z-index: 40; box-shadow: -8px 0 30px rgba(0,0,0,.15); }
}
@media (max-width: 820px) {
  .casca, .casca.com-painel { grid-template-columns: minmax(0, 1fr); }
  .lista, .chat, .ajustes { min-width: 0; }
  .trilho { display: none; }
  .casca .chat, .casca .ajustes { display: none; }
  .casca.no-chat .lista { display: none; }
  .casca.no-chat .chat { display: flex; }
  .casca.nos-ajustes .lista { display: none; }
  .casca.nos-ajustes .ajustes { display: block; grid-column: 1; }
  .voltar { display: inline-grid; }
  .so-largo { display: none !important; }
  .msg { max-width: 88%; }
  .modo-ia button span { display: none; }
  .num-cartao { grid-template-columns: auto minmax(0, 1fr); }
  .num-cartao .acoes { grid-column: 1 / -1; justify-content: flex-start; }
  .linha-form { grid-template-columns: 1fr; }
}
@media (min-width: 821px) { .so-estreito { display: none !important; } }
