/* ===== VR MedSuite — estilos ===== */
* { box-sizing: border-box; }
:root {
  --azul: #2563eb; --azul-escuro: #1d4ed8;
  --fundo: #f1f5f9; --borda: #e2e8f0; --texto: #0f172a; --mudo: #64748b;
}
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo); color: var(--texto); font-size: 15px;
}
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0 0 12px; }
h2 { font-size: 17px; }
code { background: #eef2ff; padding: 1px 6px; border-radius: 4px; }

/* topo */
.topo { background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 50; }
.topo-inner { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; }
.marca { color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.marca:hover { text-decoration: none; }
.topo nav { display: flex; gap: 4px; flex: 1; }
.topo nav a { color: #cbd5e1; padding: 8px 14px; border-radius: 8px; }
.topo nav a:hover { background: #1e293b; text-decoration: none; }
.topo nav a.ativo { background: var(--azul); color: #fff; }
.topo-usuario { display: flex; align-items: center; gap: 12px; color: #cbd5e1; font-size: 13px; }

.conteudo { max-width: 1400px; margin: 0 auto; padding: 20px; }
.titulo-pagina { font-size: 22px; }
.cabecalho-pagina { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* painéis e formulários */
.painel {
  background: #fff; border: 1px solid var(--borda); border-radius: 12px;
  padding: 16px; margin-bottom: 16px;
}
.painel.vazio, .vazio { text-align: center; color: var(--mudo); padding: 28px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid #cbd5e1;
  border-radius: 8px; background: #fff; color: var(--texto); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--azul); }
input[type="checkbox"] { width: auto; }
input[type="color"] { padding: 2px; height: 40px; width: 70px; }
textarea { resize: vertical; }
.linha-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.linha-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.linha-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }
.form-grande h2 { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--borda); }
.form-grande h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.mudo { color: var(--mudo); font-weight: 400; }
.pre { white-space: pre-wrap; margin: 8px 0 0; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  text-decoration: none !important; white-space: nowrap;
}
.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-escuro); }
.btn-claro { background: #fff; color: var(--texto); border-color: #cbd5e1; }
.btn-claro:hover { background: var(--fundo); }
.btn-perigo { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.btn-mini { padding: 4px 10px; font-size: 12.5px; }
.btn-largo { width: 100%; }

/* flash */
.flashes { max-width: 1400px; margin: 12px auto 0; padding: 0 20px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.flash-ok { background: #dcfce7; color: #166534; }
.flash-erro { background: #fee2e2; color: #b91c1c; }

/* filtros */
.filtros { padding: 12px; }
.filtros-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filtros-form input, .filtros-form select { width: auto; }
.filtros-form input[type="search"] { min-width: 220px; flex: 1; }
.grupo-data { display: flex; gap: 4px; align-items: center; }
.alternar-visao { display: flex; gap: 4px; margin-left: auto; }

/* agenda */
.agenda-grade {
  display: grid; gap: 12px; align-items: start;
  grid-template-columns: repeat(var(--n-colunas, 1), minmax(240px, 1fr));
  overflow-x: auto;
}
.agenda-coluna { background: #fff; border: 1px solid var(--borda); border-radius: 12px; overflow: hidden; }
.coluna-hoje { outline: 2px solid var(--azul); }
.coluna-cabecalho {
  padding: 10px 12px; border-top: 4px solid var(--azul); border-bottom: 1px solid var(--borda);
  display: flex; flex-direction: column; background: #f8fafc;
}
.coluna-cabecalho small { color: var(--mudo); }
.coluna-vazia { padding: 24px 12px; text-align: center; color: var(--mudo); font-size: 13px; }
.slot { display: flex; border-bottom: 1px solid #f1f5f9; min-height: 44px; }
.slot-encaixe { background: #fffbeb; }
.slot-hora { width: 52px; flex-shrink: 0; padding: 8px 6px; font-size: 12.5px; font-weight: 700; color: var(--mudo); text-align: right; }
.slot-corpo { flex: 1; padding: 4px 6px; }
.slot-livre {
  width: 100%; height: 100%; min-height: 36px; border: 1px dashed #cbd5e1; border-radius: 8px;
  background: transparent; color: #94a3b8; font: inherit; font-size: 12.5px; cursor: pointer;
}
.slot-livre:hover { background: #eff6ff; color: var(--azul); border-color: var(--azul); }

.ag-cartao {
  border: 1px solid var(--borda); border-left: 4px solid var(--azul);
  border-radius: 8px; padding: 6px 8px; margin-bottom: 4px; background: #fff;
}
.ag-cartao.status-cancelado { opacity: .55; }
.ag-cartao.status-atendido { background: #f0fdf4; }
.ag-linha1 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ag-paciente { font-weight: 700; font-size: 13.5px; }
.ag-linha2 { font-size: 12px; color: var(--mudo); }
.ag-convenio { margin-top: 3px; font-size: 11px; }
.aviso-restricao { background: #f1f5f9; color: #475569; font-size: 14px; }
.ag-obs { font-size: 12px; color: #92400e; background: #fef3c7; border-radius: 6px; padding: 2px 6px; margin-top: 3px; }
.ag-acoes { display: flex; gap: 4px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.ag-acoes select { padding: 2px 4px; font-size: 12px; width: auto; }
.etiqueta {
  color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
.etiqueta-clara { background: #e2e8f0; color: #334155; margin: 1px; display: inline-block; }
.etiqueta-verde { background: #dcfce7; color: #166534; margin: 1px; display: inline-block; }
.sub-secao { border-left: 3px solid var(--borda); padding-left: 14px; margin: 6px 0; }
.sub-secao-campos { margin-top: 10px; }
.bolinha { display: inline-block; width: 14px; height: 14px; border-radius: 50%; }

/* tabelas */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th { text-align: left; font-size: 12.5px; color: var(--mudo); text-transform: uppercase; letter-spacing: .4px; padding: 8px; border-bottom: 2px solid var(--borda); }
.tabela td { padding: 10px 8px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.tabela .acoes { display: flex; gap: 6px; justify-content: flex-end; }
.tabela-horarios input { width: auto; }
.linha-inativa { opacity: .5; }

/* abas / prontuário */
.cabecalho-paciente { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.aviso-obs { background: #fef3c7; color: #92400e; border-radius: 8px; padding: 6px 10px; display: inline-block; }
.abas { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.aba {
  padding: 9px 18px; border-radius: 10px 10px 0 0; background: #e2e8f0; color: var(--texto);
  font-weight: 600; font-size: 14px; border: 1px solid var(--borda); border-bottom: none;
}
.aba:hover { text-decoration: none; background: #cbd5e1; }
.aba-ativa { background: #fff; color: var(--azul); }
.registro { border-left: 4px solid var(--azul); }
.registro-cabecalho { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.registro-cabecalho .btn { margin-left: auto; }
.campo-alergia textarea { border-color: #fca5a5; background: #fef2f2; }

/* modal */
[hidden] { display: none !important; }
.modal-fundo {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 520px; }
.modal-cabecalho { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* autocomplete */
.autocomplete-lista {
  position: relative; border: 1px solid var(--borda); border-radius: 8px;
  max-height: 200px; overflow-y: auto; background: #fff; box-shadow: 0 8px 20px rgba(0,0,0,.12);
}
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-weight: 400; }
.autocomplete-item:hover { background: #eff6ff; }
.autocomplete-item small { color: var(--mudo); }

/* login */
.tela-login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
}
.cartao-login {
  background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 380px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-logo { font-size: 42px; }
.cartao-login h1 { margin: 6px 0 2px; }
.cartao-login form { text-align: left; margin-top: 18px; }

/* ===== chat interno ===== */
#chat-botao {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--azul); color: #fff; font-size: 24px;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .45);
}
#chat-botao:hover { background: var(--azul-escuro); }
.chat-badge {
  position: absolute; top: -4px; right: -4px; background: #dc2626; color: #fff;
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; line-height: 20px;
  border-radius: 20px; padding: 0 5px; font-family: system-ui, sans-serif;
}
.chat-badge-fixa { position: static; margin-left: auto; }
#chat-painel {
  position: fixed; bottom: 92px; right: 22px; z-index: 200;
  width: 340px; max-width: calc(100vw - 32px); height: 460px; max-height: 70vh;
  background: #fff; border: 1px solid var(--borda); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
}
#chat-painel[hidden] { display: none; }

/* avisos no canto: mostram o texto da mensagem, e não só o contador */
#chat-avisos {
  position: fixed; bottom: 92px; right: 22px; z-index: 210;
  width: 320px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 8px;
}
#chat-avisos:empty { display: none; }
/* com o painel do chat aberto, os avisos sobem para não cobri-lo */
body.chat-aberto #chat-avisos { top: 76px; bottom: auto; }
.chat-aviso {
  background: #fff; border: 1px solid var(--borda); border-left: 4px solid var(--azul);
  border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .22);
  animation: aviso-entra .18s ease-out;
}
@keyframes aviso-entra {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-aviso-topo { display: flex; align-items: baseline; gap: 6px; }
.chat-aviso-de { font-size: 13px; }
.chat-aviso-hora { margin-left: auto; font-size: 11px; color: var(--mudo); }
.chat-aviso-texto {
  font-size: 14px; margin: 4px 0 8px; color: var(--texto);
  white-space: pre-wrap; word-break: break-word;
  max-height: 90px; overflow: auto;
}
.chat-aviso-acoes { display: flex; gap: 6px; justify-content: flex-end; }
@media print { #chat-avisos { display: none !important; } }
.chat-topo {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: #0f172a; color: #fff;
}
.chat-topo strong { flex: 1; font-size: 15px; }
.chat-corpo { flex: 1; overflow-y: auto; padding: 10px; background: #f8fafc; }
.chat-vazio { color: var(--mudo); text-align: center; padding: 24px 10px; }
.chat-canal {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
  cursor: pointer; background: #fff; border: 1px solid var(--borda); margin-bottom: 6px;
}
.chat-canal:hover { background: #eff6ff; }
.chat-canal-info { display: flex; flex-direction: column; min-width: 0; }
.chat-canal-info small { color: var(--mudo); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-msg { max-width: 85%; margin-bottom: 8px; }
.chat-msg-minha { margin-left: auto; text-align: right; }
.chat-msg-texto {
  display: inline-block; padding: 8px 12px; border-radius: 14px; font-size: 14px;
  background: #e2e8f0; color: var(--texto); text-align: left; white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg-minha .chat-msg-texto { background: var(--azul); color: #fff; }
.chat-msg-meta { font-size: 11px; color: var(--mudo); margin-top: 2px; }
#chat-rodape { border-top: 1px solid var(--borda); padding: 8px; background: #fff; }
#chat-atalhos { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chat-atalho {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 10px;
  border-radius: 20px; border: 1px solid #bfdbfe; background: #eff6ff;
  color: var(--azul-escuro); cursor: pointer;
}
.chat-atalho:hover { background: #dbeafe; }
.chat-envio { display: flex; gap: 6px; }
.chat-envio input { flex: 1; }
.chat-envio .btn { padding: 8px 14px; }
@media print { #chat-botao, #chat-painel { display: none !important; } }

/* logomarca nas configurações */
.logo-atual { display: flex; align-items: center; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.logo-atual img { max-height: 80px; max-width: 260px; border: 1px solid var(--borda); border-radius: 8px; padding: 6px; background: #fff; }


/* ==========================================================================
   TABLETS (até 800px)
   ========================================================================== */
@media (max-width: 800px) {
  .linha-2, .linha-3 { grid-template-columns: 1fr; }
  /* campos curtos (Gesta/Para/Cesáreas/Abortos) ficam 2x2: empilhar os
     quatro deixaria o formulário longo demais para um dado de um dígito */
  .linha-4 { grid-template-columns: 1fr 1fr; }
  .topo-inner { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .agenda-grade { grid-template-columns: repeat(var(--n-colunas, 1), minmax(240px, 280px)); }
}

/* ==========================================================================
   CELULARES (até 640px)
   ========================================================================== */
@media (max-width: 640px) {

  /* --- campos: 16px evita que o iPhone dê zoom sozinho ao tocar num campo --- */
  input, select, textarea { font-size: 16px; padding: 10px 12px; }

  /* --- áreas de toque: dedo precisa de mais espaço que o mouse --- */
  .btn { padding: 11px 16px; min-height: 44px; }
  .btn-mini { padding: 8px 12px; font-size: 13px; min-height: 36px; }
  .topo nav a { padding: 10px 14px; }

  /* --- topo em duas faixas: marca + usuário em cima, menu embaixo --- */
  .topo-inner { gap: 8px; padding: 8px 12px 0; }
  .marca {
    font-size: 15px; max-width: 62%;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topo-usuario { margin-left: auto; font-size: 12px; gap: 8px; }
  .topo-usuario span small { display: none; }   /* o perfil sai; o nome fica */
  .topo nav {
    order: 3; width: 100%; flex: none;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 6px; scrollbar-width: none;
  }
  .topo nav::-webkit-scrollbar { display: none; }
  .topo nav a { white-space: nowrap; }

  /* --- respiro geral: ganha largura útil na tela pequena --- */
  .conteudo { padding: 12px; }
  .flashes { padding: 0 12px; }
  .painel { padding: 12px; border-radius: 10px; }
  .titulo-pagina { font-size: 19px; }

  /* título e botão de ação empilhados, botão ocupando a linha */
  .cabecalho-pagina { flex-direction: column; align-items: stretch; gap: 10px; }
  .cabecalho-pagina .btn { width: 100%; }

  /* --- filtros: cada campo em uma linha, sem espremer --- */
  .filtros-form { flex-direction: column; align-items: stretch; }
  .filtros-form input, .filtros-form select { width: 100%; }
  .filtros-form input[type="search"] { min-width: 0; }
  .grupo-data { width: 100%; }
  .grupo-data input { flex: 1; }
  .alternar-visao { margin-left: 0; width: 100%; }
  .alternar-visao .btn { flex: 1; }

  /* --- agenda: uma coluna por vez, deslizando o dedo para o lado --- */
  .agenda-grade {
    grid-template-columns: repeat(var(--n-colunas, 1), 88vw);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
  }
  .agenda-coluna { scroll-snap-align: start; }
  .slot-hora { width: 46px; padding: 8px 4px; }
  .ag-acoes .btn { min-height: 32px; padding: 6px 10px; }

  /* --- abas do prontuário: rolam para o lado em vez de quebrar linha --- */
  .abas {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; padding-bottom: 2px;
  }
  .abas::-webkit-scrollbar { display: none; }
  .aba { white-space: nowrap; padding: 10px 14px; }

  .cabecalho-paciente { flex-direction: column; }
  .cabecalho-paciente .btn { width: 100%; }
  .registro-cabecalho .btn { margin-left: 0; width: 100%; }

  /* --- tabelas viram cartões: linha vira bloco, com o rótulo do lado --- */
  .tabela, .tabela tbody, .tabela tr, .tabela td { display: block; width: 100%; }
  .tabela thead { display: none; }               /* o cabeçalho vira rótulo em cada campo */
  .tabela tr {
    border: 1px solid var(--borda); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 10px; background: #fff;
  }
  .tabela td { border: none; padding: 4px 0; text-align: left; }
  .tabela td::before {
    content: attr(data-rotulo) ": ";
    font-weight: 700; font-size: 12px; color: var(--mudo);
    text-transform: uppercase; letter-spacing: .3px;
  }
  /* campos sem rótulo (ações, bolinha de cor) não mostram o ": " */
  .tabela td:not([data-rotulo])::before { content: ""; }
  .tabela td[data-rotulo=""]::before { content: ""; }
  /* o nome fica em destaque, como título do cartão */
  .tabela td[data-rotulo="Nome"]::before { content: ""; }
  .tabela td[data-rotulo="Nome"] { font-size: 16px; margin-bottom: 4px; }
  /* a bolinha de cor do médico fica na mesma linha do nome */
  .tabela td.celula-cor { display: inline-block; width: auto; padding-right: 8px; vertical-align: middle; }
  .tabela td.celula-cor + td[data-rotulo="Nome"] { display: inline-block; width: auto; vertical-align: middle; }
  .tabela .acoes {
    justify-content: stretch; margin-top: 10px;
    padding-top: 10px; border-top: 1px solid #f1f5f9;
  }
  .tabela .acoes .btn { flex: 1; }
  .tabela-horarios td { display: table-cell; }    /* essa tabela é de campos, não de dados */
  .tabela-horarios, .tabela-horarios tbody, .tabela-horarios tr { display: revert; }
  .tabela-horarios tr { border: 0; padding: 0; margin: 0; }

  /* --- modal quase em tela cheia --- */
  .modal-fundo { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 92vh; overflow-y: auto; padding: 16px;
  }
  .modal-rodape { flex-direction: column-reverse; }
  .modal-rodape .btn { width: 100%; }

  /* --- chat ocupa a tela toda: digitar em 340px no celular é ruim --- */
  #chat-painel {
    inset: 0; width: 100%; height: 100%;
    max-width: 100%; max-height: 100%; border-radius: 0; border: 0;
  }
  #chat-botao { bottom: 16px; right: 16px; }
  #chat-avisos { right: 12px; left: 12px; width: auto; bottom: 84px; }
  body.chat-aberto #chat-avisos { display: none; }  /* o chat já está aberto na frente */

  /* --- login --- */
  .cartao-login { padding: 24px 20px; }
  .login-logo { font-size: 34px; }
}

/* telas bem estreitas (iPhone SE e similares) */
@media (max-width: 380px) {
  .topo-usuario span { display: none; }   /* sobra só o botão Sair */
  .agenda-grade { grid-template-columns: repeat(var(--n-colunas, 1), 92vw); }
}

/* ===== tela de configuração do banco (roda antes do login) ===== */
.tela-config-banco { background: linear-gradient(135deg, #0f172a, #1e3a8a); padding: 24px 16px; }
.caixa-config {
  background: #fff; border-radius: 16px; padding: 28px; max-width: 620px;
  margin: 0 auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.caixa-config h1 { font-size: 22px; }
.caixa-config h2 {
  font-size: 15px; margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--borda);
}
.caixa-config .btn-largo { margin-top: 12px; }
.caixa-config .dica { font-size: 12.5px; margin: 6px 0 0; }
.lista-bancos { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.opcao-banco {
  flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400;
  border: 1px solid var(--borda); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 0; cursor: pointer;
}
.opcao-banco:hover { background: #f8fafc; }
.opcao-banco input { width: auto; margin-top: 3px; flex-shrink: 0; }
.opcao-banco small { display: block; margin-top: 2px; }
.campo-banco-novo { margin-top: 10px; }
.voltar { margin: 18px 0 0; text-align: center; }
@media (max-width: 640px) {
  .caixa-config { padding: 18px 14px; }
}

/* ===== caixa e pagamentos ===== */
.resumo-caixa { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.cartao-forma {
  border: 1px solid var(--borda); border-radius: 10px; padding: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.cartao-forma .cf-nome { font-size: 13px; color: var(--mudo); }
.cartao-forma .cf-valor { font-size: 20px; font-weight: 700; }
.cartao-forma .cf-qtd { font-size: 12px; color: var(--mudo); }
.cartao-total { background: #eff6ff; border-color: #bfdbfe; }
.cartao-total .cf-valor { color: var(--azul); }

.formas-pagamento { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 6px 0 12px; }
.btn-forma {
  padding: 14px; border: 2px solid var(--borda); border-radius: 10px;
  background: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-forma:hover { border-color: var(--azul); }
.btn-forma.forma-ativa { border-color: var(--azul); background: var(--azul); color: #fff; }

.col-valor { text-align: right; white-space: nowrap; }
.col-qtd { color: var(--mudo); font-size: 13px; }
.linha-total td { border-top: 2px solid var(--borda); font-size: 16px; }
.linha-troco td { color: var(--mudo); }
.folha h3 { margin-top: 18px; font-size: 15px; }

@media (max-width: 640px) {
  .formas-pagamento { grid-template-columns: 1fr 1fr; }
}
@media print {
  .no-print, .topo, #chat-botao, #chat-painel, #chat-avisos { display: none !important; }
  .folha { border: 0; box-shadow: none; }
}

/* ===== tela de sair (backup) ===== */
.caixa-sair { max-width: 560px; margin: 24px auto; }
.botoes-sair { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; align-items: stretch; }
.botoes-sair form { margin: 0; }
.btn-grande { width: 100%; padding: 14px; font-size: 16px; }
.botoes-sair .btn-mini { align-self: center; width: auto; margin-top: 4px; }

/* ===== galeria de fotos do prontuário ===== */
.galeria-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 4px; }
.foto-card { background: #fff; border: 1px solid var(--borda); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.foto-card img { width: 100%; height: 180px; object-fit: cover; display: block; cursor: zoom-in; background: #f1f5f9; }
.foto-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.foto-info span { font-size: 12px; }
.foto-card form { margin: 0; padding: 0 10px 10px; }
.foto-card form .btn { width: 100%; }
@media (max-width: 640px) {
  .galeria-fotos { grid-template-columns: 1fr 1fr; }
}

/* ===== status de agendamento travado (atendido) ===== */
.status-travado { display: flex; align-items: center; gap: 6px; }
.status-travado .cadeado { font-size: 12px; opacity: .6; }

/* ===== índice de relatórios ===== */
.lista-relatorios { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.cartao-relatorio {
  display: block; background: #fff; border: 1px solid var(--borda); border-radius: 12px;
  padding: 18px; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s;
}
.cartao-relatorio:hover { border-color: var(--azul); box-shadow: 0 4px 16px rgba(37,99,235,.1); }
.cartao-relatorio h2 { margin: 0 0 6px; font-size: 17px; color: var(--azul); }
.cartao-relatorio p { margin: 0; font-size: 14px; }

/* ===== cabeçalho de relatório com logomarca ===== */
.cabecalho-relatorio { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.logo-relatorio { max-height: 64px; max-width: 180px; object-fit: contain; }
.cabecalho-relatorio-texto h2 { margin: 0; }
.cabecalho-relatorio-texto p { margin: 2px 0 0; font-size: 13px; }
@media print {
  .logo-relatorio { max-height: 20mm; max-width: 45mm; }
  .cabecalho-relatorio { gap: 10mm; }
}

/* ===== fórmulas magistrais ===== */
.componente-linha { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.componente-linha input:first-child { flex: 2; }
.componente-linha input:nth-child(2) { flex: 1; }
.componente-linha .btn { flex-shrink: 0; }
.inserir-formula { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.inserir-formula select { flex: 1; min-width: 180px; }
@media (max-width: 640px) {
  .componente-linha { flex-wrap: wrap; }
  .componente-linha input { flex: 1 1 100% !important; }
  .componente-linha .btn { flex: 0 0 auto; }
}

/* etiqueta vermelha (ex: NFS-e rejeitada) */
.etiqueta-vermelha { background: #fee2e2; color: #991b1b; margin: 1px; display: inline-block; }

/* ===== fila de espera ===== */
.badge-fila {
  background: #d97706; color: #fff; font-size: 13px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; margin-left: 10px; vertical-align: middle;
}
.ordem-fila { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabela-fila .linha-chegou { background: #fffbeb; }
.tabela-fila .link-paciente { font-weight: 600; color: var(--azul); text-decoration: none; }
.tabela-fila .link-paciente:hover { text-decoration: underline; }
.pequeno { font-size: 12px; }
.etiqueta-chegou { background: #dcfce7; color: #166534; font-weight: 600; }

/* aviso de atendimento em andamento no prontuário */
.aviso-atendimento {
  background: #fef3c7; border-left: 4px solid #d97706; color: #78350f;
  padding: 10px 12px; border-radius: 6px; margin: 0 0 12px; font-size: 14px;
}
.btn-salvar-atendimento { font-weight: 700; }

/* convênio editável no cartão da agenda */
.form-convenio { display: inline-block; }
.form-convenio select {
  font-size: 12px; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--borda); background: #f1f5f9; color: #334155; max-width: 150px;
}

/* backup e restauração */
.aviso-restauracao { border-left: 4px solid #dc2626; }
.aviso-restauracao h2 { margin-top: 0; font-size: 17px; }
.texto-perigo { color: #b91c1c; font-weight: 600; }
