/* Painel Creare: claro, sobrio, magenta so onde importa. */
:root {
  --bg: #f5f3f5;
  --card: #ffffff;
  --ink: #1f1a20;
  --muted: #6b6470;
  --line: #e8e3e9;
  --line-soft: #f0ecf1;
  --brand: #a3297a;
  --brand-ink: #7d1d5d;
  --brand-soft: #f9ecf4;
  --ok: #17794d;
  --warn: #b45309;
  --danger: #c0262d;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button:not(:disabled), [role=button], summary, select, input[type=checkbox], input[type=radio], input[type=file], label.clicavel { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- estrutura ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; height: 100dvh; }
.lateral { background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 22px 14px 14px; min-height: 0; }
.lateral .marca { display: block; padding: 0 8px 22px; }
.lateral .marca img { display: block; width: 138px; height: auto; }
.menu { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.menu a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.menu a svg { width: 18px; height: 18px; flex: none; }
.menu a:hover { background: var(--line-soft); color: var(--ink); }
.menu a[aria-current=page] { background: var(--brand-soft); color: var(--brand-ink); }
.menu .rotulo { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #9a929d; font-weight: 600; }
.menu .selo { margin-left: auto; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; line-height: 18px; min-width: 18px; text-align: center; }
.rodape-lateral { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.eu { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.eu b { display: block; font-size: 13px; line-height: 1.2; }
.eu small { color: var(--muted); font-size: 12px; }
.link-fino { background: none; border: 0; padding: 7px 10px; text-align: left; color: var(--muted); border-radius: 8px; text-decoration: none; display: block; font-size: 13px; }
.link-fino:hover { background: var(--line-soft); color: var(--ink); }
.principal { min-width: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.principal > .atend { flex: 1; height: auto; }
.pagina { max-width: 980px; margin: 0 auto; padding: 32px 28px 56px; }
.pagina > header { margin-bottom: 22px; }
.pagina h1 { font-size: 22px; letter-spacing: -.01em; }
.pagina header p { margin: 6px 0 0; color: var(--muted); }
.topo-mobile { display: none; }

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card { margin-top: 16px; }
.card-cab { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; gap: 12px; }
.card-cab h2 { font-size: 15px; }
.card-cab p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-corpo { padding: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 600; text-decoration: none; line-height: 1.2; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { background: var(--line-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primario { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primario:hover:not(:disabled) { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn-perigo { color: var(--danger); }
.btn-perigo:hover:not(:disabled) { background: #fdf0f0; border-color: #f2c9cb; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo > label, .campo > .rotulo { font-weight: 600; font-size: 13px; }
.campo small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=time], input[type=number], input[type=color], select, textarea {
  width: 100%; border: 1px solid #d9d2db; border-radius: 8px; padding: 9px 11px; background: #fff; }
input[type=color] { padding: 3px; height: 38px; width: 64px; }
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
.linha { display: flex; gap: 12px; flex-wrap: wrap; }
.linha > * { flex: 1 1 180px; }
.interruptor { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.interruptor input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--brand); }
.interruptor b { display: block; }
.interruptor small { color: var(--muted); }
.vazio { text-align: center; color: var(--muted); padding: 44px 20px; }
.vazio svg { width: 34px; height: 34px; color: #c9bfcc; margin-bottom: 8px; }
.vazio b { display: block; color: var(--ink); margin-bottom: 3px; }
.ponto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #b9b0bc; margin-right: 6px; vertical-align: 1px; }
.ponto.ok { background: var(--ok); } .ponto.aviso { background: var(--warn); } .ponto.erro { background: var(--danger); }
.etq { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.etq i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* lista simples (usuarios, setores) */
.lista > .item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--line-soft); }
.lista > .item:first-child { border-top: 0; }
.lista .quem { flex: 1; min-width: 0; }
.lista .quem b { display: block; }
.lista .quem small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.lista .item.inativo { opacity: .55; }
.grade-perm { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; }
.grade-perm label { display: flex; gap: 10px; padding: 8px 0; align-items: flex-start; }
.grade-perm input { margin-top: 3px; accent-color: var(--brand); width: 16px; height: 16px; }
.grade-perm small { display: block; color: var(--muted); }
.grupo-titulo { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #9a929d; font-weight: 700; margin: 14px 0 4px; }

/* dialogo */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 24px 70px rgba(31, 26, 32, .28); color: var(--ink); }
dialog::backdrop { background: rgba(31, 26, 32, .45); }
dialog form { display: block; }
.dlg-cab { padding: 18px 22px 8px; }
.dlg-cab h2 { font-size: 17px; }
.dlg-cab p { margin: 4px 0 0; color: var(--muted); }
.dlg-corpo { padding: 10px 22px 6px; }
.dlg-rodape { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.etapas { display: flex; gap: 4px; background: var(--line-soft); padding: 3px; border-radius: 9px; margin: 6px 22px 0; }
.etapas button { flex: 1; border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; font-weight: 600; color: var(--muted); }
.etapas button[aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* aviso (toast) */
.avisos { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.aviso { background: #2a232b; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); max-width: 340px; animation: sobe .18s ease-out; }
.aviso.erro { background: #8e1f25; }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } }

/* login */
.entrada { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.entrada .caixa { width: min(400px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 34px 32px 30px; }
.entrada .logo { display: block; width: 150px; margin: 0 auto 22px; }
.entrada h1 { font-size: 18px; text-align: center; }
.entrada .sub { text-align: center; color: var(--muted); margin: 6px 0 22px; }
.entrada .btn { width: 100%; padding: 11px; }
.erro-form { background: #fdf0f0; color: var(--danger); border: 1px solid #f2c9cb; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; }

/* ---------- atendimento ---------- */
.atend { display: grid; grid-template-columns: 340px 1fr; height: 100%; min-height: 0; background: var(--card); }
.fila { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.fila-topo { padding: 16px 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.fila-topo .linha1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fila-topo h1 { font-size: 17px; }
.segmentos { display: flex; background: var(--line-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.segmentos button { flex: 1 1 auto; border: 0; background: transparent; border-radius: 7px; padding: 6px 4px; font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; display: inline-flex; gap: 5px; justify-content: center; align-items: center; }
.segmentos button[aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.segmentos .n { background: #e2dbe4; color: #5e5662; border-radius: 999px; font-size: 11px; padding: 0 6px; line-height: 17px; min-width: 17px; }
.segmentos .n.vivo { background: var(--brand); color: #fff; }
.busca { position: relative; }
.busca input { padding-left: 33px; }
.busca svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #9a929d; }
.itens { flex: 1; overflow-y: auto; min-height: 0; }
.conv { display: flex; gap: 11px; padding: 12px 16px; border-top: 1px solid var(--line-soft); border-left: 3px solid transparent; width: 100%; text-align: left; background: none; border-right: 0; border-bottom: 0; align-items: flex-start; position: relative; }
.conv:hover { background: #faf8fa; }
.conv[aria-current=true] { background: var(--brand-soft); border-left-color: var(--brand); }
.conv .avatar { width: 38px; height: 38px; font-size: 14px; position: relative; }
.conv .avatar .alerta { position: absolute; right: -2px; top: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; animation: pulsa 1.6s infinite; }
@keyframes pulsa { 50% { transform: scale(1.25); } }
.conv .meio { flex: 1; min-width: 0; }
.conv .l1 { display: flex; justify-content: space-between; gap: 8px; }
.conv .nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .hora { color: var(--muted); font-size: 12px; flex: none; }
.conv .l2 { display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; }
.conv .previa { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.conv .nl { background: var(--ok); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 19px; height: 19px; line-height: 19px; text-align: center; padding: 0 5px; flex: none; }
.conv .l3 { display: flex; gap: 8px; align-items: center; margin-top: 5px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.conv .espera { color: var(--warn); font-weight: 600; }
.conv .espera.longa { color: var(--danger); }
.conv .setor { display: inline-flex; align-items: center; gap: 5px; }
.conv .setor i { width: 7px; height: 7px; border-radius: 50%; }
.paginacao { display: flex; align-items: center; justify-content: space-between; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.esqueleto .conv { pointer-events: none; }
.esq { background: linear-gradient(90deg, #f0ecf1, #f8f5f9, #f0ecf1); background-size: 200% 100%; animation: brilho 1.2s infinite; border-radius: 6px; }
@keyframes brilho { to { background-position: -200% 0; } }

.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: #f7f4f7; }
.chat-vazio { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 24px; }
.chat-vazio svg { width: 44px; height: 44px; color: #cbbfcf; margin-bottom: 10px; }
.chat-cab { background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 18px; display: flex; align-items: center; gap: 12px; }
.chat-cab .voltar { display: none; }
.chat-cab .info { flex: 1; min-width: 0; }
.chat-cab .info b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-cab .info small { color: var(--muted); }
.chat-cab .acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.dia { align-self: center; margin: 12px 0 6px; background: #ece6ee; color: #6b6470; font-size: 12px; font-weight: 600; padding: 3px 11px; border-radius: 999px; }
.sistema { align-self: center; margin: 6px 0; color: var(--muted); font-size: 12.5px; background: #fff; border: 1px solid var(--line); padding: 3px 12px; border-radius: 999px; }
.bolha { max-width: min(560px, 80%); padding: 8px 11px 6px; border-radius: 12px; background: #fff; border: 1px solid var(--line); word-wrap: break-word; overflow-wrap: anywhere; position: relative; }
.bolha.in { align-self: flex-start; border-top-left-radius: 4px; }
.bolha.out { align-self: flex-end; background: var(--brand-soft); border-color: #efd3e5; border-top-right-radius: 4px; }
.bolha .autor { font-size: 12px; font-weight: 700; color: var(--brand-ink); margin-bottom: 2px; }
.bolha .texto { white-space: pre-wrap; }
.bolha .rod { display: flex; justify-content: flex-end; gap: 5px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 3px; }
.bolha .rod .vis { color: #1e88e5; }
.bolha .rod .falha { color: var(--danger); font-weight: 700; }
.bolha img.foto { display: block; max-width: 100%; max-height: 300px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; }
.bolha audio, .bolha video { max-width: 100%; display: block; margin-bottom: 4px; }
.bolha video { max-height: 300px; }
.arquivo { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0, 0, 0, .04); border-radius: 8px; text-decoration: none; color: inherit; margin-bottom: 4px; }
.arquivo svg { width: 22px; height: 22px; color: var(--brand); flex: none; }
.arquivo span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mais-antigas { align-self: center; }
.composer { background: var(--card); border-top: 1px solid var(--line); padding: 10px 14px 12px; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; resize: none; padding: 10px 12px; flex: 1; }
.composer .btn { height: 42px; }
.composer-aviso { padding: 14px 18px; background: var(--card); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 12px; justify-content: space-between; color: var(--muted); }
.lightbox { position: fixed; inset: 0; background: rgba(20, 15, 22, .86); display: grid; place-items: center; z-index: 60; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* conexao */
.conexao { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: center; }
.qr { width: 280px; height: 280px; border: 1px dashed #d9d2db; border-radius: 12px; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 14px; }
.qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.passos { margin: 14px 0 0; padding-left: 18px; color: var(--muted); }
.passos li { margin: 4px 0; }

/* ---------- responsivo ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .lateral.aberta { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .topo-mobile { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); }
  .topo-mobile img { height: 26px; width: auto; }
  .topo-mobile button { border: 0; background: none; padding: 6px; border-radius: 8px; }
  .topo-mobile svg { width: 22px; height: 22px; display: block; }
  .pagina { padding: 22px 16px 44px; }
  .atend { grid-template-columns: 1fr; position: relative; }
  .atend .chat { position: absolute; inset: 0; transform: translateX(100%); transition: transform .2s; z-index: 5; }
  .atend.em-chat .chat { transform: none; }
  .chat-cab .voltar { display: inline-flex; }
  .chat-cab { flex-wrap: wrap; padding: 10px 12px; }
  .chat-cab .acoes { flex: 1 1 100%; justify-content: flex-start; }
  .conexao { grid-template-columns: 1fr; }
  .qr { margin: 0 auto; }
  .grade-perm { grid-template-columns: 1fr; }
  .msgs { padding: 14px 12px; }
  .bolha { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
