/* Mais Saúde Atendimento — visual novo (spec §7). Manrope, claro, azul-marinho como ação e azul como destaque raro. */
:root {
  --bg: #F3F6FB;
  --surface: #FFFFFF;
  --surface-soft: #EDF2FA;
  --text: #0F1B33;
  --text-2: #5B6780;
  --text-3: #8E99AE; /* só decoração e itens desativados; nunca texto essencial (não passa em AA) */
  --border: #E3E8F2;
  --primary: #0B2A6B;
  --primary-hover: #143A8C;
  --accent: #2E65F5;
  --accent-soft: #E6EEFF;
  --positive: #54C98A;
  --negative: #F17D79;
  /* versões escuras só para texto sobre fundo claro (AA) */
  --positive-text: #17703F;
  --negative-text: #B4322E;
  --negative-soft: #FDEDEC;
  --negative-line: #F3C9C7;
  --warn-text: #8A5200;
  --warn-bg: #FFF4E0;
  --nota: #FFF4C2;

  --r-card: 20px;
  --r-ctl: 12px;
  --r-pill: 999px;
  --sombra: 0 2px 12px rgba(15, 27, 51, .05);
  --rapido: 140ms;
  --normal: 220ms;
  --altura-topo: 68px;
  --fonte: "Manrope", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* nomes antigos, usados em estilos inline dos scripts */
  --suave: var(--text-2);
  --ok: var(--positive-text);
  --erro: var(--negative-text);
  --azul: var(--accent);
  --azul-claro: var(--accent-soft);
  --borda: var(--border);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font: 500 14.5px/1.5 var(--fonte); color: var(--text); background: var(--bg);
  -webkit-text-size-adjust: 100%; font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.so-leitor { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- ícones e marca ---------- */
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.marca-logo {
  display: block; width: 112px; height: 40px; background-color: var(--primary);
  -webkit-mask: url(/img/logo-mais-saude-branca.png) left center / contain no-repeat;
  mask: url(/img/logo-mais-saude-branca.png) left center / contain no-repeat;
}
.marca-logo.grande { width: 168px; height: 60px; margin: 0 auto 8px; -webkit-mask-position: center; mask-position: center; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--r-ctl);
  padding: 8px 16px; line-height: 1.2; white-space: nowrap; font-weight: 600; text-decoration: none;
  transition: background var(--rapido), border-color var(--rapido), color var(--rapido);
}
.btn:hover { background: var(--surface-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primario { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primario:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.perigo { color: var(--negative-text); border-color: var(--negative-line); background: var(--surface); }
.btn.perigo:hover { background: var(--negative-soft); }
.btn.pequeno { min-height: 36px; padding: 5px 12px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 6px 8px; min-height: 36px; }
.btn.link:hover { background: var(--accent-soft); }
.btn.icone { width: 40px; padding: 0; border-radius: 50%; border-color: transparent; background: transparent; color: var(--text-2); flex: none; }
.btn.icone:hover { background: var(--surface-soft); color: var(--primary); }
.btn.icone[aria-expanded=true] { background: var(--accent-soft); color: var(--primary); }
@media (pointer: coarse) { .btn.pequeno, .btn.link { min-height: 40px; } }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=tel], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 40px; border: 1px solid var(--border); border-radius: var(--r-ctl); padding: 8px 12px;
  background: var(--surface); transition: border-color var(--rapido), box-shadow var(--rapido);
}
textarea { line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 0; box-shadow: none; }
input::placeholder, textarea::placeholder { color: var(--text-2); opacity: .85; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; margin: 0; }
label.campo { display: block; margin-bottom: 14px; }
label.campo > span, .campo > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
label.check { display: flex; gap: 10px; align-items: center; margin: 4px 0; min-height: 36px; }
.dica { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.erro-msg { color: var(--negative-text); font-size: 14px; font-weight: 600; min-height: 1.2em; }
.vazio {
  color: var(--text-2); padding: 28px 16px; text-align: center; font-weight: 600;
}
.vazio::before {
  content: ""; display: block; width: 40px; height: 40px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--surface-soft) radial-gradient(circle, var(--text-3) 0 4px, transparent 5px);
}
td.vazio::before, .historico .vazio::before { display: none; }

/* ---------- cabeçalho (shell) ---------- */
.topo {
  position: sticky; top: 0; z-index: 30; height: var(--altura-topo); padding: 0 24px; background: var(--bg);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px;
}
.topo .marca { margin-right: 8px; flex: none; display: inline-flex; align-items: center; min-height: 44px; justify-self: start; border-radius: var(--r-ctl); }
.shell-nav { justify-self: center; min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; display: flex; gap: 4px; padding: 4px; background: var(--surface); border-radius: var(--r-pill); box-shadow: var(--sombra); border: 1px solid var(--border); }
.shell-aba {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 18px; border-radius: var(--r-pill);
  color: var(--text-2); text-decoration: none; font-weight: 700; white-space: nowrap;
  transition: background var(--rapido), color var(--rapido);
}
.shell-aba:hover { background: var(--surface-soft); color: var(--primary); }
.shell-aba.ativo { background: var(--primary); color: #fff; }
.shell-aba .rot-curto { display: none; }
.shell-nav::-webkit-scrollbar { display: none; }
.shell-aba { flex: none; }
.topo-dir { display: flex; align-items: center; gap: 12px; justify-self: end; min-width: 0; }
.conexao { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.conexao-ponto { width: 9px; height: 9px; border-radius: 50%; background: #F5B942; }
.conexao.on .conexao-ponto { background: var(--positive); box-shadow: 0 0 0 3px rgba(84, 201, 138, .25); }
.conexao.on { color: var(--positive-text); }
.usuario { display: flex; align-items: center; gap: 10px; min-width: 0; }
.usuario-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none;
}
.usuario-dados { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.usuario .quem { font-weight: 700; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usuario .perfil { font-size: 12px; color: var(--text-2); }
.btn.sair { border-radius: var(--r-pill); }
@media (max-width: 1360px) { .usuario .perfil, .sair-rot { display: none; } .btn.sair { width: 40px; padding: 0; } .usuario .quem { max-width: 110px; } }
@media (max-width: 1180px) { .usuario-dados { display: none; } }
@media (max-width: 1240px) { .shell-aba .ic { display: none; } .shell-aba { padding: 0 12px; font-size: 13.5px; } .topo { padding: 0 16px; gap: 12px; } .shell-nav { gap: 0; } .conexao-texto { display: none; } }
@media (max-width: 960px) { .shell-aba { padding: 0 9px; font-size: 13px; } }

/* ---------- página padrão ---------- */
.pagina { max-width: 1200px; margin: 0 auto; padding: 8px 24px 48px; }
.pagina h1, .pagina h2 { margin: 28px 0 12px; font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.pagina > h2:first-child, .pagina > h1:first-child { margin-top: 8px; font-size: 28px; font-weight: 800; }
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 20px; box-shadow: var(--sombra); }
.card h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.card .num { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; color: var(--text-2); font-weight: 600; }
.card .num b { font-size: 20px; font-weight: 800; color: var(--text); }
.card .num b.alerta { color: var(--negative-text); }
.barra-acoes { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }

/* ---------- tabelas leves ---------- */
.tabela-rolagem { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sombra); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 700; white-space: nowrap; }
tbody tr { transition: background var(--rapido); }
tbody tr:hover { background: var(--surface-soft); }
tr:last-child td { border-bottom: 0; }
td.vazio:hover, tr:has(td.vazio):hover { background: none; }
.ponto { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--text-3); margin-right: 8px; }
.ponto.on { background: var(--positive); box-shadow: 0 0 0 3px rgba(84, 201, 138, .25); }

/* ---------- chips e pílulas ---------- */
.pilula { display: inline-block; background: var(--surface-soft); color: var(--text); border-radius: var(--r-pill); padding: 2px 10px; font-size: 12.5px; font-weight: 700; margin: 2px 4px 2px 0; }
.pilula.off { background: var(--negative-soft); color: var(--negative-text); }
button.pilula { border: 1px solid var(--border); background: var(--surface); min-height: 40px; padding: 6px 16px; font-size: 14px; margin: 0; transition: background var(--rapido), color var(--rapido); }
button.pilula:hover { background: var(--surface-soft); }
button.pilula[aria-pressed=true] { background: var(--primary); border-color: var(--primary); color: #fff; }
.tag { font-size: 12px; background: var(--surface-soft); border-radius: var(--r-pill); padding: 2px 10px; color: var(--text-2); font-weight: 700; }

/* ---------- login ---------- */
.login-pagina { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(180deg, var(--bg), var(--surface-soft)); }
.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(15, 27, 51, .08); }
.cartao h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; text-align: center; letter-spacing: -.01em; }
.cartao p.sub { margin: 0 0 22px; color: var(--text-2); text-align: center; }
.cartao .btn.primario { width: 100%; min-height: 44px; }

/* ---------- atendimento ---------- */
body.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
.atend {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 76px 360px minmax(0, 1fr); gap: 16px; padding: 0 24px 24px;
}
.rail {
  display: flex; flex-direction: column; align-items: center; align-self: start; gap: 12px; padding: 14px 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sombra);
}
.rail-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; border: 0; background: none;
  color: var(--text-2); font-size: 11.5px; font-weight: 700; line-height: 1.15; text-align: center; padding: 0 2px; border-radius: var(--r-ctl);
}
.rail-ic {
  position: relative; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-soft);
  color: var(--text-2); transition: background var(--rapido), color var(--rapido);
}
.rail-btn:hover .rail-ic { background: var(--accent-soft); color: var(--primary); }
.rail-btn.ativo { color: var(--primary); }
.rail-btn.ativo .rail-ic { background: var(--primary); color: #fff; }
.rail-btn .n {
  position: absolute; top: -4px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface);
}
.rail-btn .n.zero { background: var(--surface-soft); color: var(--text-2); }

.painel-lista, .painel-conversa {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sombra);
  display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
}
.painel-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 12px; }
.painel-cab h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.lista { overflow-y: auto; flex: 1; padding: 0 8px 8px; }
.item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; border: 0; border-radius: 16px;
  background: none; padding: 12px; cursor: pointer; margin-bottom: 2px; transition: background var(--rapido);
}
.item:hover { background: var(--surface-soft); }
.item.sel { background: var(--accent-soft); }
.item:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.item .corpo { flex: 1; min-width: 0; }
.item .l-assumir { display: flex; justify-content: flex-end; margin: 4px 0 2px; }
.item .l-assumir .btn { border-radius: var(--r-pill); min-height: 32px; padding: 3px 14px; }
.avatar {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; overflow: hidden;
  background: var(--accent-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 14px; user-select: none;
}
.avatar.grande { width: 44px; height: 44px; font-size: 14px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.item .l1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item .nome { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .hora { font-size: 12px; color: var(--text-2); white-space: nowrap; font-weight: 600; }
.item .l2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; margin-top: 3px; }
.item .previa { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .badge { background: var(--accent); color: #fff; border-radius: var(--r-pill); min-width: 22px; text-align: center; padding: 1px 7px; font-size: 12px; font-weight: 800; flex: none; }
.item .meta { font-size: 12px; color: var(--warn-text); font-weight: 700; margin-top: 3px; }
.item .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sem-conversa { margin: auto; color: var(--text-2); text-align: center; padding: 24px; font-weight: 600; }
.cab-conversa { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cab-conversa .quem { flex: 1; min-width: 160px; }
.cab-conversa .quem b { display: block; font-size: 16px; font-weight: 800; }
.cab-conversa .quem small { color: var(--text-2); font-weight: 600; }
.cab-conversa .acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.voltar { display: none; }
.mensagens { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--surface-soft); }
.dia { align-self: center; font-size: 12px; font-weight: 700; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); border-radius: var(--r-pill); padding: 3px 12px; margin: 8px 0; }
.bolha {
  max-width: min(78%, 560px); padding: 9px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--sombra); overflow-wrap: anywhere; white-space: pre-wrap;
}
.bolha.out { align-self: flex-end; background: var(--accent-soft); border-color: #D0DEFF; border-bottom-right-radius: 6px; }
.bolha.in { align-self: flex-start; border-bottom-left-radius: 6px; }
.bolha.nota { align-self: center; background: var(--nota); max-width: 90%; border: 1px dashed #D9BC3E; }
.bolha.sistema { background: var(--surface); color: var(--text-2); }
.bolha .autor { font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 2px; }
.bolha .rodape { font-size: 11.5px; font-weight: 600; color: var(--text-2); text-align: right; margin-top: 3px; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.bolha .st.lida { color: var(--accent); font-weight: 800; }
.bolha .st.falhou { color: var(--negative-text); font-weight: 700; }
.bolha img.midia { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; cursor: zoom-in; background: var(--surface-soft); }
.bolha audio { display: block; max-width: 100%; min-width: 220px; }
.bolha video { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; }
.bolha .doc { display: inline-block; padding: 8px 12px; background: var(--surface); border-radius: var(--r-ctl); color: var(--primary); text-decoration: none; font-weight: 700; }
.bolha .falha-linha { color: var(--negative-text); font-size: 12.5px; margin-top: 4px; }

.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 14px 14px; position: relative; }
.composer .linha { display: flex; gap: 6px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; min-height: 44px; flex: 1; background: var(--surface-soft); border-color: transparent; border-radius: 22px; padding: 10px 16px; }
.composer textarea:focus { background: var(--surface); }
.composer.nota textarea { background: var(--nota); }
.composer .ferr { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; font-size: 13px; font-weight: 600; }
.composer .btn.icone .ic { width: 22px; height: 22px; }
.composer .linha > .btn.primario { min-height: 44px; border-radius: 22px; padding: 0 20px; }
.composer .gravando { color: var(--negative-text); font-weight: 700; display: flex; align-items: center; gap: 8px; flex: 1; min-height: 44px; }
.composer .gravando::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--negative); animation: pisca 1s infinite; }
@keyframes pisca { 50% { opacity: .2; } }
.anexo-chip { display: flex; align-items: center; gap: 8px; background: var(--accent-soft); border-radius: var(--r-ctl); padding: 6px 10px; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.anexo-chip img { height: 36px; border-radius: 6px; }
.atalhos { position: absolute; left: 14px; right: 14px; bottom: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; max-height: 240px; overflow-y: auto; box-shadow: 0 -4px 20px rgba(15, 27, 51, .12); z-index: 5; padding: 4px; }
.atalhos button { display: block; width: 100%; min-height: 40px; text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: var(--r-ctl); }
.atalhos button.sel, .atalhos button:hover { background: var(--accent-soft); }
.atalhos b { color: var(--primary); }
.emoji-pop {
  position: absolute; left: 14px; right: 14px; bottom: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 -4px 20px rgba(15, 27, 51, .14); z-index: 6; padding: 8px;
}
.emoji-abas { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 6px; padding-bottom: 6px; }
.emoji-abas button { border: 0; background: none; min-height: 36px; padding: 4px 12px; font-size: 13px; font-weight: 700; color: var(--text-2); white-space: nowrap; border-radius: var(--r-pill); }
.emoji-abas button.ativo { background: var(--primary); color: #fff; }
.emoji-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; max-height: 200px; overflow-y: auto; }
.emoji-grade .emoji { border: 0; background: none; border-radius: var(--r-ctl); height: 40px; font-size: 22px; line-height: 1; padding: 0; }
.emoji-grade .emoji:hover { background: var(--accent-soft); }
.emoji-grade .emoji:focus-visible { background: var(--accent-soft); outline: 3px solid var(--accent); outline-offset: -3px; }
.aviso-janela { background: var(--warn-bg); border: 1px solid #F0CF94; border-radius: 16px; padding: 14px; }
.aviso-janela p { margin: 0 0 8px; }
.faixa-info { padding: 14px; text-align: center; background: var(--surface); border-top: 1px solid var(--border); color: var(--text-2); font-weight: 600; }

/* ---------- canal Consultórios (js/parceiros.js) ---------- */
.painel-cab { flex-wrap: wrap; }
.barra-filtro { padding: 0 16px 8px; }
.filtro-nao-lidas { border-radius: var(--r-pill); }
.filtro-nao-lidas.ativo { background: var(--accent); border-color: var(--accent); color: #fff; }
.acoes-lista { display: flex; gap: 6px; flex-wrap: wrap; }
.faixa-desconectado { background: var(--negative-text); color: #fff; padding: 10px 16px; font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.faixa-desconectado b { font-weight: 800; }
#faixa-parceiros .faixa-desconectado { margin: 0 8px 8px; border-radius: var(--r-ctl); }
.item .nome.nao-cadastrado { color: var(--text-2); font-style: italic; }
.item .sub-parceiro { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer .dica-assinatura { color: var(--text-2); font-size: 12.5px; }
.aviso-parceiros {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--negative-soft); border: 1px solid var(--negative-line); color: var(--negative-text); font-size: 12.5px; font-weight: 800; text-decoration: none; white-space: nowrap;
}
.aviso-parceiros:hover { background: #FBDCDA; }
.aviso-ponto { width: 9px; height: 9px; border-radius: 50%; background: var(--negative-text); flex: none; }
.aviso-parceiros .rot-curto { display: none; }
@media (max-width: 1240px) { .aviso-parceiros .rot-longo { display: none; } .aviso-parceiros .rot-curto { display: inline; } }
@media (max-width: 420px) { .aviso-parceiros .rot-curto { display: none; } .aviso-parceiros { width: 36px; padding: 0; justify-content: center; } .aviso-ponto { width: 12px; height: 12px; } }
dialog.dlg-agenda { width: min(640px, calc(100vw - 24px)); }
.agenda-barra { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.agenda-barra input { flex: 1 1 200px; width: auto; min-width: 0; border-radius: var(--r-pill); padding-left: 16px; }
.agenda-lista { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.agenda-item { border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; }
.agenda-item.inativo { opacity: .75; }
.agenda-item .cc-dados b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agenda-acoes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.agenda-mais { display: flex; justify-content: center; }
.escolhido { display: flex; gap: 10px; align-items: center; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: var(--r-ctl); padding: 6px 10px; }
.escolhido .avatar { width: 34px; height: 34px; font-size: 12px; }
.escolhido .sg-dados { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.escolhido small { color: var(--text-2); }

/* ---------- fluidez: entradas, troca de conversa, skeletons, carregando (js/fluidez.js) ---------- */
/* Durações e curva dos tokens; com prefers-reduced-motion a regra global acima desliga tudo. */
@keyframes entrar { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes trocar { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes progresso { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.entrando { animation: entrar var(--normal) cubic-bezier(.2, .8, .2, 1) both; }
.bolha.out.entrando { transform-origin: bottom right; }
.bolha.in.entrando { transform-origin: bottom left; }
.trocando { animation: trocar var(--normal) cubic-bezier(.2, .8, .2, 1) both; }

.sk {
  display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-soft) 25%, var(--border) 50%, var(--surface-soft) 75%);
  background-size: 200% 100%; animation: brilho 1.2s linear infinite;
}
.sk-item { display: flex; gap: 12px; padding: 12px; }
.sk-avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.sk-linhas { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 6px; min-width: 0; }
.sk-l1 { height: 12px; width: 55%; }
.sk-l2 { height: 10px; width: 85%; }
.sk-cab { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 160px; }
.skeleton-bolhas { display: flex; flex-direction: column; gap: 10px; }
.sk-bolha { height: 38px; width: 46%; border-radius: 18px; }
.sk-bolha.out { align-self: flex-end; }
.sk-bolha.t1 { width: 32%; }
.sk-bolha.t2 { width: 58%; height: 56px; }

.btn.carregando { position: relative; color: transparent !important; pointer-events: none; }
.btn.carregando > * { visibility: hidden; }
.btn.carregando::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--primary); border-right-color: transparent; animation: girar .7s linear infinite;
}
.btn.primario.carregando::after { border-color: #fff; border-right-color: transparent; }
.btn.perigo.carregando::after { border-color: var(--negative-text); border-right-color: transparent; }

/* Bolha otimista: enviando (relógio), arquivo com barra indeterminada, falha local com "Tentar de novo". */
.bolha.pendente .anexo-nome { font-weight: 700; color: var(--primary); }
.enviando-barra { height: 3px; margin-top: 6px; border-radius: 2px; background: var(--border); overflow: hidden; }
.enviando-barra::after { content: ""; display: block; height: 100%; width: 40%; background: var(--accent); animation: progresso 1.1s ease-in-out infinite; }
.bolha.falhou-local { border-color: var(--negative-line); }
.mensagens.somente-leitura .falha-linha .btn { display: none; }
.pilula-assumindo {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--primary);
  font-size: 12px; font-weight: 700; padding: 3px 12px;
}
.pilula-assumindo::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--primary); border-right-color: transparent; animation: girar .7s linear infinite; }
.falha-linha .btn.link { min-height: 28px; padding: 2px 6px; color: var(--negative-text); font-weight: 700; }

/* ---------- supervisão / admin ---------- */
.abas-admin { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 20px; }
.abas-admin button { border: 1px solid var(--border); background: var(--surface); min-height: 40px; padding: 6px 18px; border-radius: var(--r-pill); color: var(--text-2); font-weight: 700; transition: background var(--rapido), color var(--rapido); }
.abas-admin button:hover { background: var(--surface-soft); color: var(--primary); }
.abas-admin button.ativo { background: var(--primary); border-color: var(--primary); color: #fff; }
.horario-dia { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.horario-dia > b { width: 40px; padding-top: 10px; }
.horario-dia .faixas { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.horario-dia .faixa { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.horario-dia .faixa input { width: 92px; text-align: center; }

/* ---------- diálogo e toast ---------- */
dialog { border: 0; border-radius: var(--r-card); padding: 0; width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 16px 56px rgba(15, 27, 51, .28); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(15, 27, 51, .5); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
dialog .dlg-titulo { padding: 22px 24px 8px; font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
dialog .dlg-corpo { padding: 6px 24px 10px; overflow-y: auto; }
dialog .dlg-rodape { padding: 14px 24px 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 24px)); }
.toast { background: var(--primary); color: #fff; padding: 12px 16px; border-radius: var(--r-ctl); box-shadow: 0 8px 24px rgba(15, 27, 51, .3); font-weight: 600; }
.toast.erro { background: var(--negative-text); }
.toast.ok { background: var(--positive-text); }

/* ---------- contatos ---------- */
.busca-contatos { flex: 1; min-width: 200px; max-width: 460px; width: auto; border-radius: var(--r-pill); padding-left: 18px; }
.lista-contatos { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.card-contato { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px 20px; box-shadow: var(--sombra); }
.card-contato.inativo { opacity: .75; }
.cc-topo { display: flex; gap: 14px; align-items: flex-start; }
.cc-dados { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cc-dados b { overflow-wrap: anywhere; font-size: 15.5px; font-weight: 800; }
.cc-dados small { color: var(--text-2); font-weight: 600; overflow-wrap: anywhere; }
.cc-dados .cc-obs { font-style: italic; }
.acoes-contato { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.historico { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.hist-item { display: flex; gap: 12px; flex-wrap: wrap; padding: 10px 0; min-height: 40px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.hist-item:last-child { border-bottom: 0; }
.hist-item span { color: var(--text-2); }
.hist-item:hover b { color: var(--accent); text-decoration: underline; }
.sugestoes-contato { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-ctl); margin-top: 6px; overflow: hidden; }
.sugestoes-contato button { display: flex; gap: 10px; align-items: center; text-align: left; min-height: 48px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); padding: 6px 10px; }
.sugestoes-contato button:last-child { border-bottom: 0; }
.sugestoes-contato button:hover, .sugestoes-contato button:focus-visible { background: var(--accent-soft); outline: none; }
.sugestoes-contato .avatar { width: 34px; height: 34px; font-size: 12px; }
.sugestoes-contato .sg-dados { display: flex; flex-direction: column; min-width: 0; }
.sugestoes-contato small { color: var(--text-2); }

/* ---------- dashboard ---------- */
.filtros-dash { gap: 12px; }
.filtros-dash label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.filtros-dash input[type=date], .filtros-dash select { width: auto; }
.pilulas { display: flex; gap: 6px; flex-wrap: wrap; }
.grade-cards { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grade-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card-kpi { padding: 22px; }
.card-kpi .rotulo { font-size: 13px; font-weight: 700; color: var(--text-2); }
.card-kpi .valor { font-size: 42px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 4px; }
.card-kpi .sub { font-size: 13px; font-weight: 600; color: var(--text-2); }
.card-kpi.prioritario { background: var(--accent); border-color: var(--accent); color: #fff; }
.card-kpi.prioritario .rotulo, .card-kpi.prioritario .sub { color: #fff; }
.grafico { width: 100%; height: auto; display: block; }
.grafico .g-barra { fill: var(--primary); fill-opacity: .85; transition: fill var(--rapido); }
.grafico .g-barra:hover { fill: var(--accent); fill-opacity: 1; }
.grafico .g-celula { fill: var(--surface-soft); }
.grafico text { fill: var(--text); font-size: 12px; font-weight: 600; font-family: var(--fonte); }
.grafico .g-eixo { fill: var(--text-2); font-size: 11px; }
.th-ordem { border: 0; background: none; font: inherit; font-weight: 700; padding: 8px 0; min-height: 40px; color: inherit; text-align: left; text-transform: inherit; letter-spacing: inherit; }
.th-ordem[aria-pressed=true] { color: var(--primary); }
.th-ordem[aria-pressed=true]::after { content: " ▼"; font-size: 10px; }
.th-ordem[aria-pressed=true].asc::after { content: " ▲"; }
tr.poucas td { color: var(--text-2); }

/* ---------- celular ---------- */
@media (max-width: 760px) {
  body.com-shell { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .topo { height: 56px; grid-template-columns: 1fr auto; padding: 0 16px; }
  .topo .marca { min-height: 44px; }
  .marca-logo { height: 34px; width: 96px; }
  .usuario .quem { display: none; }
  .usuario-avatar { width: 36px; height: 36px; }
  .conexao-texto { display: none; }

  /* abas viram barra inferior */
  .shell-nav {
    position: fixed; left: 0; right: 0; bottom: 0; width: 100%; z-index: 40; border-radius: 0; border-width: 1px 0 0; box-shadow: 0 -2px 12px rgba(15, 27, 51, .06);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 2px; justify-content: space-around;
  }
  .shell-aba { flex: 1 1 0; min-width: 0; overflow: hidden; flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 2px; border-radius: 16px; font-size: 11px; }
  .shell-aba .ic { display: block; }
  .shell-aba .rot-longo { display: none; }
  .shell-aba .rot-curto { display: inline; }
  body.app:has(.atend.mostrando-conversa) .shell-nav { display: none; }
  body.app:has(.atend.mostrando-conversa) { padding-bottom: 0; }
  body.app:has(.atend.mostrando-conversa) .topo { display: none; }

  .pagina { padding: 4px 16px 32px; }
  .pagina > h2:first-child, .pagina > h1:first-child { font-size: 24px; }
  .grade, .grade-cards, .grade-2 { grid-template-columns: 1fr; gap: 14px; }
  .grade-cards { grid-template-columns: 1fr 1fr; }
  .card-kpi { padding: 16px; }
  .card-kpi .valor { font-size: 30px; }
  .busca-contatos { max-width: none; flex-basis: 100%; }
  .barra-acoes > select, .barra-acoes > .btn { flex: 1 1 auto; }
  .filtros-dash label { flex: 1 1 100%; }
  .filtros-dash label input, .filtros-dash label select { flex: 1; width: auto; min-width: 0; }

  /* atendimento: rail vira faixa horizontal, lista e conversa alternam */
  .atend { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 12px; padding: 0 12px 12px; }
  .rail { flex-direction: row; align-self: stretch; padding: 8px; gap: 6px; }
  .rail-btn { flex-direction: row; justify-content: center; gap: 8px; min-height: 44px; padding: 0 8px; border-radius: var(--r-pill); font-size: 13px; flex: 1; }
  .rail-ic { width: 32px; height: 32px; }
  .rail-ic .ic { width: 18px; height: 18px; }
  .rail-btn.ativo { background: var(--surface-soft); }
  .rail-btn .n { top: -6px; right: -8px; }
  /* com Consultórios são 4 botões: ícone sobre o rótulo, como a barra inferior, para caber em 375 px */
  .rail:has(.rail-parceiros) { padding: 6px; gap: 2px; }
  .rail:has(.rail-parceiros) .rail-btn { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; min-height: 56px; padding: 4px 2px; border-radius: 16px; font-size: 11.5px; }
  .rail:has(.rail-parceiros) .rail-rot { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .painel-conversa { display: none; }
  .atend.mostrando-conversa { grid-template-rows: minmax(0, 1fr); padding: 0; gap: 0; }
  .atend.mostrando-conversa .rail, .atend.mostrando-conversa .painel-lista { display: none; }
  .atend.mostrando-conversa .painel-conversa { display: flex; border-radius: 0; border-width: 0; box-shadow: none; }
  .voltar { display: inline-flex; }
  .cab-conversa { padding: 10px 12px; gap: 8px; }
  .cab-conversa .quem { min-width: 0; flex-basis: calc(100% - 120px); }
  .cab-conversa .acoes .btn { min-height: 40px; }
  .bolha { max-width: 88%; }
  .mensagens { padding: 12px; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; }
  .composer textarea::placeholder { font-size: 14px; }
  .composer .linha > .btn.primario { padding: 0 16px; }
  .emoji-pop, .atalhos { left: 8px; right: 8px; }

  /* tabelas viram listas de cards */
  .tabela-rolagem { background: none; border: 0; box-shadow: none; overflow: visible; }
  .tabela-rolagem table, .tabela-rolagem tbody, .tabela-rolagem tr, .tabela-rolagem td { display: block; width: 100%; }
  .tabela-rolagem thead { display: none; }
  .tabela-rolagem tbody tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sombra);
    padding: 10px 16px; margin-bottom: 12px;
  }
  .tabela-rolagem td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: right; overflow-wrap: anywhere; }
  .tabela-rolagem td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--text-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
  .tabela-rolagem td:not([data-label]) { display: block; text-align: left; }
  .tabela-rolagem td:not([data-label])::before { display: none; }
  .tabela-rolagem td.vazio { text-align: center; }
  /* ordenação do dashboard continua acessível como fila de botões */
  #tab-atendentes thead { display: block; margin-bottom: 8px; }
  #tab-atendentes thead tr { display: flex; flex-wrap: wrap; gap: 6px; }
  #tab-atendentes thead th { display: block; padding: 0; border: 0; }
  #tab-atendentes .th-ordem { border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-pill); padding: 4px 14px; min-height: 40px; text-transform: none; letter-spacing: 0; }
  #tab-atendentes .th-ordem[aria-pressed=true] { background: var(--primary); color: #fff; border-color: var(--primary); }
  dialog { width: calc(100vw - 16px); }
  dialog .dlg-titulo { padding: 18px 18px 6px; }
  dialog .dlg-corpo { padding: 6px 18px 8px; }
  dialog .dlg-rodape { padding: 12px 18px 16px; }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* Fixar no topo: alfinete no card (sempre se fixada; ao passar o mouse se não), mini-menu por pressão longa e botão no cabeçalho. */
.item .direita { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.item .alfinete { min-height: 0; width: 26px; height: 26px; padding: 0; border: 0; background: none; color: var(--text-2); border-radius: var(--r-pill); display: inline-grid; place-items: center; box-shadow: none; }
.item .alfinete .ic { width: 16px; height: 16px; }
.item .alfinete:not(.ligado) { opacity: 0; }
.item .alfinete.ligado { color: var(--accent); }
.item .alfinete.ligado .ic { fill: currentColor; }
.item:hover .alfinete, .item .alfinete:focus-visible { opacity: 1; }
.item .alfinete:hover { background: var(--accent-soft); color: var(--accent); }
/* Sem mouse: só aparece fixada; o caminho é a pressão longa no card. */
@media (hover: none) { .item .alfinete:not(.ligado) { display: none; } }
.item { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.btn.alfinete.cab { width: 40px; min-height: 40px; padding: 0; display: inline-grid; place-items: center; }
.btn.alfinete.cab .ic { width: 18px; height: 18px; }
.btn.alfinete.cab.ligado { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn.alfinete.cab.ligado .ic { fill: currentColor; }
.menu-fixar { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); box-shadow: 0 8px 28px rgba(15, 27, 51, .18); padding: 4px; animation: menu-fixar-entra var(--rapido) ease-out; }
.menu-fixar-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px; border: 0; background: none; border-radius: 8px; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; white-space: nowrap; }
.menu-fixar-item:hover, .menu-fixar-item:focus-visible { background: var(--accent-soft); outline: none; }
.menu-fixar-item .ic { width: 18px; height: 18px; color: var(--accent); }
@keyframes menu-fixar-entra { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* Marcar como não lida: ponto azul no lugar do contador, nome mais forte, "⋯" no card (desktop). */
.item .ponto-nao-lida { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; margin: 0 5px; }
.item .nome.marcada { font-weight: 800; }
.item .mais-opcoes { min-height: 0; width: 26px; height: 26px; padding: 0; border: 0; background: none; color: var(--text-2); border-radius: var(--r-pill); display: inline-grid; place-items: center; box-shadow: none; opacity: 0; }
.item .mais-opcoes .ic { width: 18px; height: 18px; fill: currentColor; }
.item:hover .mais-opcoes, .item .mais-opcoes:focus-visible, .item.sel .mais-opcoes { opacity: 1; }
.item .mais-opcoes:hover { background: var(--accent-soft); color: var(--accent); }
@media (hover: none) { .item .mais-opcoes { display: none; } }
.menu-fixar-item .ic { flex: none; }
.menu-fixar-item .ic[viewBox] circle { fill: currentColor; }
@media (max-width: 760px) { #cabecalho-conversa .acoes .btn:not(.alfinete) { padding-left: 10px; padding-right: 10px; } }
