:root {
  --laranja: #F7941D; --laranja-esc: #E07F10; --amarelo: #F7B733; --laranja-claro: #FFF4E3;
  --grad: linear-gradient(135deg, #F7941D 0%, #F7B733 100%);
  --escuro: #181818; --escuro-2: #242424; --texto: #1E1E1E; --muted: #6F6F6F; --borda: #E3E3E3; --fundo: #F3F3F3;
  --branco: #fff; --verde: #2E9E5B; --vermelho: #D64545; --azul: #2F7DD1; --nota: #FFF7D1;
  --raio: 10px; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--texto); background: var(--fundo); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.erro { color: var(--vermelho); min-height: 18px; font-size: 13px; }
a { color: var(--azul); }

/* botões e campos */
.btn { border: 1px solid var(--borda); background: var(--branco); color: var(--texto); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #EFEFEF; }
.btn.primario { background: var(--grad); border-color: var(--laranja); color: var(--escuro); }
.btn.primario:hover { background: linear-gradient(135deg, #E8850F, #F2A91E); }
.btn.perigo { color: var(--vermelho); border-color: #f0c9c9; }
.btn.verde { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn.peq { padding: 5px 10px; font-size: 12.5px; }
.btn.largo { width: 100%; padding: 11px; }
.btn:disabled { opacity: .55; cursor: default; }
.icone { border: 0; background: none; cursor: pointer; font-size: 18px; padding: 6px 8px; border-radius: 8px; }
.icone:hover { background: #EDEDED; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--borda); border-radius: 8px; background: #fff; width: 100%; color: var(--texto); }
input:focus, select:focus, textarea:focus { outline: 2px solid #FBD28C; border-color: var(--laranja); }
label { display: block; font-weight: 600; font-size: 12.5px; color: #555555; margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

/* login */
.login { height: 100%; display: grid; place-items: center; position: relative; overflow: hidden; background: var(--escuro); }
.login::before { content: ""; position: absolute; width: 420px; height: 420px; right: -120px; top: -120px; background: var(--grad); clip-path: polygon(0 0, 100% 0, 100% 100%); opacity: .95; }
.login::after { content: ""; position: absolute; width: 260px; height: 260px; left: -90px; bottom: -90px; border-radius: 50%; background: var(--grad); opacity: .9; }
.login-box { position: relative; z-index: 1; }
.login-box { width: 360px; background: #fff; padding: 32px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.18); text-align: center; }
.login-box h1 { margin: 12px 0 2px; font-size: 20px; }
.login-box label { text-align: left; }
.logo { width: 52px; height: 52px; margin: 0 auto; border-radius: 14px; background: var(--grad); display: grid; place-items: center; color: var(--escuro); font-weight: 800; font-size: 26px; }
.logo.pequeno { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; margin-bottom: 14px; }

/* estrutura */
.app { display: flex; height: 100%; }
.nav { width: 84px; background: var(--escuro); display: flex; flex-direction: column; align-items: center; padding: 14px 0; gap: 4px; }
.nav button { position: relative; width: 72px; border: 0; background: none; color: #BDBDBD; cursor: pointer; padding: 8px 2px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; }
.nav button i { font-style: normal; font-size: 20px; }
.nav button b { font-size: 10.5px; font-weight: 600; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav button:hover { background: #2C2C2C; color: #fff; }
.nav button.ativo { background: var(--grad); color: var(--escuro); }
.nav-fim { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sock { width: 10px; height: 10px; border-radius: 50%; background: var(--vermelho); margin-bottom: 6px; }
.sock.on { background: #4cd07d; }
.badge { position: absolute; top: 2px; right: 8px; background: var(--vermelho); color: #fff; font-style: normal; font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.view { flex: 1; min-width: 0; height: 100%; overflow: hidden; }
.pagina { height: 100%; overflow: auto; padding: 24px 28px; }
.pagina h2 { margin: 0 0 16px; font-size: 20px; }
.barra { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.barra .cresce { flex: 1; }

/* atendimentos: 3 colunas */
.atd { display: flex; height: 100%; }
.lista { width: 340px; border-right: 1px solid var(--borda); background: #fff; display: flex; flex-direction: column; }
.lista-topo { padding: 12px; border-bottom: 1px solid var(--borda); display: flex; flex-direction: column; gap: 8px; }
.lista-topo .linha { display: flex; gap: 6px; }
.abas { display: flex; border-bottom: 1px solid var(--borda); }
.abas button { flex: 1; border: 0; background: none; padding: 10px 4px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.abas button.ativo { color: var(--laranja-esc); border-bottom-color: var(--laranja); }
.abas button span { display: inline-block; background: #EAEAEA; color: #555; border-radius: 9px; padding: 0 6px; margin-left: 3px; font-size: 11px; }
.abas button.ativo span { background: var(--laranja); color: #fff; }
.itens { flex: 1; overflow: auto; }
.item { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid #EEEEEE; cursor: pointer; }
.item:hover { background: #F8F8F8; }
.item.sel { background: var(--laranja-claro); }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: #E5E5E5; color: #666666; display: grid; place-items: center; font-weight: 700; }
.item .meio { flex: 1; min-width: 0; }
.item .l1 { display: flex; justify-content: space-between; gap: 6px; }
.item .nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .hora { font-size: 11.5px; color: var(--muted); flex: none; }
.item .prev { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.item .l3 { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 9px; font-weight: 600; color: #fff; white-space: nowrap; }
.tag.cinza { background: #E8E8E8; color: #555555; }
.naolidas { margin-left: auto; background: var(--verde); color: #fff; font-size: 11px; font-weight: 700; border-radius: 9px; min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; }
.espera { font-size: 11px; color: var(--vermelho); font-weight: 600; }
.vazio { padding: 40px 20px; text-align: center; color: var(--muted); }

.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #ECECEC; }
.chat-topo { background: #fff; padding: 10px 16px; border-bottom: 1px solid var(--borda); display: flex; align-items: center; gap: 12px; }
.chat-topo .info { flex: 1; min-width: 0; }
.chat-topo .info b { display: block; font-size: 15px; }
.chat-topo .info small { color: var(--muted); }
.msgs { flex: 1; overflow: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 4px; }
.dia { align-self: center; background: #fff; color: var(--muted); font-size: 11.5px; padding: 3px 12px; border-radius: 8px; margin: 10px 0 6px; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.msg { max-width: 68%; padding: 7px 10px 5px; border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.08); word-wrap: break-word; white-space: normal; position: relative; }
.msg.entrada { align-self: flex-start; background: #fff; border-top-left-radius: 2px; }
.msg.saida { align-self: flex-end; background: #FFE9C7; border-top-right-radius: 2px; }
.msg .autor { font-size: 11.5px; font-weight: 700; color: var(--laranja-esc); margin-bottom: 2px; }
.msg .rodape { font-size: 10.5px; color: #888888; text-align: right; margin-top: 2px; }
.msg .rodape .lida { color: var(--azul); }
.msg img.midia, .msg video.midia { max-width: 320px; max-height: 320px; border-radius: 6px; display: block; cursor: pointer; }
.msg audio { width: 260px; display: block; }
.msg .doc { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.05); padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--texto); }
.msg code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; }
.sistema { align-self: center; background: #E3EEF9; color: #3b5772; font-size: 12px; padding: 4px 12px; border-radius: 8px; margin: 4px 0; text-align: center; max-width: 80%; }
.nota { align-self: center; width: 70%; background: var(--nota); border: 1px dashed #e3c860; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.nota .autor { font-size: 11.5px; font-weight: 700; color: #8a6d00; }
.mais { align-self: center; }

.compositor { background: #fff; border-top: 1px solid var(--borda); padding: 8px 12px; position: relative; }
.compositor .modo { display: flex; gap: 4px; margin-bottom: 6px; }
.compositor .modo button { border: 0; background: none; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 10px; border-radius: 12px; cursor: pointer; }
.compositor .modo button.ativo { background: var(--laranja-claro); color: var(--laranja-esc); }
.compositor .modo button.ativo.n { background: var(--nota); color: #8a6d00; }
.compositor .linha { display: flex; align-items: flex-end; gap: 6px; }
.compositor textarea { resize: none; min-height: 42px; max-height: 160px; }
.compositor.nota-on textarea { background: var(--nota); }
.aviso { background: #fff; border-top: 1px solid var(--borda); padding: 14px; display: flex; gap: 12px; align-items: center; justify-content: center; }
.gravando { color: var(--vermelho); font-weight: 600; display: flex; gap: 10px; align-items: center; flex: 1; }
.rapidas { position: absolute; bottom: 100%; left: 12px; right: 12px; background: #fff; border: 1px solid var(--borda); border-radius: 10px; box-shadow: 0 -6px 20px rgba(0,0,0,.1); max-height: 260px; overflow: auto; }
.rapidas div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #F1F1F1; }
.rapidas div.sel, .rapidas div:hover { background: var(--laranja-claro); }
.rapidas b { color: var(--laranja-esc); }
.rapidas small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.detalhe { width: 300px; background: #fff; border-left: 1px solid var(--borda); overflow: auto; padding: 16px; }
.detalhe h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.hist { font-size: 12.5px; padding: 7px 8px; border-radius: 6px; cursor: pointer; border: 1px solid #EDEDED; margin-bottom: 5px; }
.hist:hover { background: #F8F8F8; }
.sem-chat { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; }

/* tabelas e cartões */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--raio); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #EEEEEE; }
th { background: #F8F8F8; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.clicavel { cursor: pointer; } tr.clicavel:hover td { background: #FAFAFA; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: #fff; border-radius: var(--raio); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); border-top: 4px solid var(--laranja); }
.card h4 { margin: 0 0 4px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.card .num { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.card .num div { background: var(--fundo); border-radius: 8px; padding: 8px; }
.card .num strong { display: block; font-size: 20px; }
.card .num span { font-size: 11.5px; color: var(--muted); }
.card .acoes { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.st { font-size: 11px; padding: 2px 8px; border-radius: 9px; font-weight: 700; }
.st.conectado { background: #DDF3E6; color: #1f7a45; }
.st.desconectado { background: #FBE3E3; color: #a83232; }
.st.conectando { background: #FFF1D6; color: #9a6400; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ccc; margin-right: 6px; }
.dot.on { background: #4cd07d; }
.sub-abas { display: flex; gap: 6px; margin-bottom: 18px; }

/* modal e toast */
.modal { position: fixed; inset: 0; background: rgba(30,25,20,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-box { background: #fff; border-radius: 14px; padding: 22px; width: 480px; max-width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-box h3 { margin: 0 0 16px; }
.modal-box .acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.qr { text-align: center; }
.qr img { width: 280px; height: 280px; border: 1px solid var(--borda); border-radius: 10px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--escuro); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.erro { background: var(--vermelho); }
.zoom { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 70; cursor: zoom-out; }
.zoom img { max-width: 92vw; max-height: 92vh; }

@media (max-width: 1100px) { .detalhe { display: none; } .detalhe.forcar { display: block; position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: -8px 0 20px rgba(0,0,0,.1); } .atd { position: relative; } }
@media (max-width: 760px) { .lista { width: 100%; } .atd.com-chat .lista { display: none; } .atd:not(.com-chat) .chat { display: none; } .nav { width: 60px; } .nav button { width: 52px; } .nav button b { display: none; } }

/* ===== Fase 1 ===== */
.nav { overflow-y: auto; }
.tagchip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; color: #fff; white-space: nowrap; }
.tagchip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 12px; line-height: 1; opacity: .8; }
.tagsbar { background: #fff; border-bottom: 1px solid var(--borda); padding: 6px 16px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 36px; }
.tagsbar select { width: auto; padding: 3px 8px; font-size: 12px; }
.proto { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--muted); }
.st.pausado { background: #EDE7FB; color: #5b3cc4; }
.st.aguardando { background: #FFF1D6; color: #9a6400; }
.st.em_atendimento { background: #DDF3E6; color: #1f7a45; }
.st.finalizado { background: #EAEAEA; color: #555555; }
.filtros { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; background: #fff; padding: 14px; border-radius: var(--raio); margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.filtros label { margin: 0; }
.paginacao { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.interno { display: flex; height: 100%; }
.interno .pessoas { width: 280px; background: #fff; border-right: 1px solid var(--borda); overflow: auto; }
.interno .pessoa { padding: 11px 14px; border-bottom: 1px solid #EEEEEE; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.interno .pessoa.sel { background: var(--laranja-claro); }
.interno .conversa { flex: 1; display: flex; flex-direction: column; background: #ECECEC; }
.horario td input { width: 110px; }
.estrelas { color: #E3A008; letter-spacing: 1px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: #fff; border-radius: var(--raio); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.kpi strong { display: block; font-size: 24px; }
.kpi span { font-size: 12px; color: var(--muted); }
