/* Portal IORB: layout base. Cores próximas às do sistema anterior (azul), para não estranhar. */
:root {
  --azul: #1565c0;
  --azul-escuro: #0d3c75;
  --azul-claro: #e8f1fc;
  --fundo: #f4f6f9;
  --borda: #dfe3ea;
  --sidebar-largura: 250px;
}

body.app { background: var(--fundo); font-size: .95rem; }
.app-shell { display: flex; min-height: 100vh; }

/* Menu lateral: seções planas, no máximo 2 níveis */
.sidebar {
  width: var(--sidebar-largura); flex-shrink: 0; background: var(--azul-escuro); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040;
}
.brand { display: flex; flex-direction: column; padding: 1.1rem 1.25rem .9rem; text-decoration: none; color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .12); }
.brand-mark { font-weight: 800; font-size: 1.5rem; letter-spacing: .12em; }
.brand-sub { font-size: .72rem; opacity: .75; line-height: 1.2; }
.side-nav { padding: .5rem 0 1.5rem; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .6; padding: 1rem 1.25rem .3rem; }
.side-nav .nav-link { display: flex; align-items: center; gap: .65rem; color: rgba(255, 255, 255, .88); padding: .45rem 1.25rem;
  border-left: 3px solid transparent; text-decoration: none; }
.side-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.side-nav .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-nav .nav-link.active { background: rgba(255, 255, 255, .14); border-left-color: #ffc107; color: #fff; font-weight: 600; }
.badge-futuro { margin-left: auto; font-size: .62rem; background: rgba(255, 255, 255, .15); border-radius: 1rem; padding: .05rem .45rem;
  white-space: nowrap; }
.sidebar-close { position: absolute; right: .5rem; top: .5rem; background: none; border: 0; color: #fff; font-size: 1.2rem; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1035; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 1rem; background: #fff; border-bottom: 1px solid var(--borda);
  padding: .6rem 1.5rem; position: sticky; top: 0; z-index: 1020; }
.busca-paciente { position: relative; flex: 1; max-width: 520px; }
.busca-paciente i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #6c757d; }
.busca-paciente input { padding-left: 2.2rem; border-radius: 2rem; background: var(--fundo); }
.user-chip { display: flex; align-items: center; gap: .5rem; }
.avatar { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--azul); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.content { padding: 1.5rem; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.aberto { transform: none; }
  .topbar { padding: .6rem 1rem; }
  .content { padding: 1rem; }
}

/* Cabeçalho da página, trilha, filtros e barra de ações */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.45rem; margin: 0; color: var(--azul-escuro); }
.trilha { font-size: .85rem; color: #6c757d; margin-bottom: .6rem; }
.trilha a { color: var(--azul); text-decoration: none; }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filtros input[type=search] { flex: 1; min-width: 220px; max-width: 480px; }
.filtros select { width: auto; }
.barra-acoes { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0;
  background: var(--fundo); padding: .75rem 0; }
.card { border-color: var(--borda); }
.card-header { background: #fff; font-weight: 600; color: var(--azul-escuro); }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: #5f6b7a; white-space: nowrap; }
.amostra-cor { display: inline-block; width: 1rem; height: 1rem; border-radius: .25rem; vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, .15); }

/* Atalhos (Painel e índice de Cadastros) */
.atalho { display: flex; gap: .9rem; align-items: flex-start; background: #fff; border: 1px solid var(--borda); border-radius: .6rem;
  padding: 1rem; text-decoration: none; color: inherit; height: 100%; transition: border-color .15s, box-shadow .15s; }
.atalho:hover { border-color: var(--azul); box-shadow: 0 2px 8px rgba(21, 101, 192, .12); }
.atalho i { font-size: 1.6rem; color: var(--azul); }
.atalho strong { display: block; color: var(--azul-escuro); }
.atalho small { display: block; color: #6c757d; line-height: 1.3; margin-top: .15rem; }
.atalho-futuro { opacity: .65; }
.atalho-compacto { padding: .7rem .9rem; align-items: center; }
.atalho-compacto i { font-size: 1.2rem; }

/* Ações das linhas: botões com nome + "Mais ações" */
.acoes-linha { display: inline-flex; gap: .35rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.acoes-linha form { margin: 0; }
.dropdown-menu form { margin: 0; }
.badge-status { display: inline-block; color: #fff; font-size: .8rem; font-weight: 600; padding: .2rem .55rem; border-radius: 1rem; }
.linha-livre td { background: #fbfcfe; }
.filtro-status .nav-link { padding: .3rem .8rem; }
.dados dt { font-weight: 500; color: #5f6b7a; }
.dados dd { margin-bottom: .4rem; }

/* Impressão (Agenda, Pré-Atendimento) */
@media print {
  .sidebar, .topbar, .nao-imprimir, .mensagens, .trilha { display: none !important; }
  .content { padding: 0; }
  body.app { background: #fff; }
  .card { border: 0; }
}

/* Tela de Chamadas (TV) */
body.telao { background: #0d3c75; color: #fff; min-height: 100vh; margin: 0; overflow: hidden; }
.telao-topo { display: flex; justify-content: space-between; align-items: center; padding: 1.5vh 3vw; background: rgba(0, 0, 0, .2); }
.telao-topo .brand-mark { font-size: 4vh; }
.telao-relogio { font-size: 5vh; font-weight: 700; }
.telao-atual { text-align: center; padding: 6vh 2vw 5vh; border-bottom: 2px solid rgba(255, 255, 255, .2); }
.telao-senha { font-size: 22vh; font-weight: 800; line-height: 1; letter-spacing: .05em; color: #ffc107; }
.telao-nome { font-size: 8vh; font-weight: 700; margin-top: 2vh; text-transform: uppercase; }
.telao-destino { font-size: 6vh; margin-top: 1vh; opacity: .9; }
.telao-atual.nova { animation: piscar 1s ease-in-out 5; }
@keyframes piscar { 50% { background: rgba(255, 193, 7, .35); } }
.telao-anteriores { width: 92%; margin: 3vh auto 0; font-size: 4vh; border-collapse: collapse; }
.telao-anteriores th { font-size: 2.4vh; text-transform: uppercase; opacity: .7; text-align: left; padding: .5vh 1vw; }
.telao-anteriores td { padding: 1vh 1vw; border-top: 1px solid rgba(255, 255, 255, .15); }
.telao-sair { position: fixed; right: 1rem; bottom: .5rem; color: rgba(255, 255, 255, .25); font-size: .8rem; }

/* Grade de permissões */
.grade-permissoes td:not(:first-child), .grade-permissoes th:not(:first-child) { width: 90px; }

/* Login */
.tela-login { background: linear-gradient(160deg, var(--azul-escuro), var(--azul)); min-height: 100vh; }
.login-box { max-width: 420px; margin: 0 auto; padding: 8vh 1rem 2rem; }
.login-marca { color: #fff; text-align: center; margin-bottom: 1.25rem; display: flex; flex-direction: column; }
.login-marca .brand-mark { font-size: 2.2rem; }
.tela-login .text-muted { color: rgba(255, 255, 255, .8) !important; }
.tela-login .card .text-muted { color: #6c757d !important; }

/* Atendimento: editor de atestado/receita e histórico */
.editor-area { min-height: 320px; overflow-y: auto; background: #fff; }
.editor-area:focus { outline: 2px solid var(--azul); }
.historico { max-height: 70vh; overflow-y: auto; }

/* Folha de atestado/receita */
.pagina-impressao { background: #e9ecef; }
.barra-impressao { display: flex; gap: .5rem; justify-content: center; padding: .75rem; }
.folha { background: #fff; max-width: 210mm; min-height: 270mm; margin: 0 auto 2rem; padding: 18mm 20mm; box-shadow: 0 2px 10px rgba(0, 0, 0, .1); }
.folha-cabecalho { text-align: center; border-bottom: 1px solid #adb5bd; padding-bottom: .5rem; margin-bottom: 1.5rem; }
.folha-titulo { text-align: center; font-size: 1.4rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 1.5rem; }
.folha-texto { font-size: 1.05rem; line-height: 1.6; }
/* Guia TISS impressa */
.guia-tiss { font-size: .82rem; padding: 12mm 12mm; }
.guia-tiss h2 { font-size: .8rem; text-transform: uppercase; background: #e9ecef; padding: 2px 6px; margin: 10px 0 4px; }
.caixas { display: flex; flex-wrap: wrap; gap: 4px; }
.caixas > div { border: 1px solid #adb5bd; padding: 2px 6px; min-width: 120px; flex: 1 1 120px; min-height: 2.4rem; }
.caixas > div.largo { flex: 3 1 300px; }
.caixas span { display: block; font-size: .65rem; color: #495057; }
.assinaturas { display: flex; gap: 2rem; margin-top: 3rem; }
.assinaturas div { flex: 1; border-top: 1px solid #000; text-align: center; padding-top: 4px; font-size: .75rem; }
@media print {
  .pagina-impressao { background: #fff; }
  .folha { box-shadow: none; margin: 0; padding: 0; max-width: none; min-height: 0; }
  @page { size: A4; margin: 18mm 20mm; }
}

/* Aviso de paciente novo na fila (como a faixa laranja do iOrb): fixa no topo, texto correndo, pausa ao passar o mouse */
.aviso-fila { position: fixed; top: 0; left: 0; right: 0; height: 26px; z-index: 1060; display: flex; align-items: center;
  gap: .5rem; padding: 0 .5rem; background: #fb8c00; color: #fff; font-weight: 800; font-size: .875rem; }
.aviso-fila[hidden] { display: none; }
.aviso-fila-janela { flex: 1; overflow: hidden; white-space: nowrap; color: #fff; text-decoration: none; }
.aviso-fila-janela:hover { color: #fff; }
.aviso-fila-trilho { display: inline-flex; animation: aviso-correr var(--aviso-duracao, 10s) linear infinite; }
.aviso-fila-janela:hover .aviso-fila-trilho { animation-play-state: paused; }
.aviso-fila-trilho span { padding-right: 4rem; }
.aviso-fila-fechar { background: none; border: 0; color: #fff; padding: 0 .25rem; line-height: 1; }
@keyframes aviso-correr { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .aviso-fila-trilho { animation: none; } }
body.com-aviso-fila { padding-top: 26px; }
body.com-aviso-fila .sidebar { top: 26px; height: calc(100vh - 26px); }
body.com-aviso-fila .topbar { top: 26px; }
.aviso-toast { position: fixed; top: 34px; right: 1rem; z-index: 1070; max-width: 360px; background: #fb8c00; color: #fff;
  border-radius: .4rem; padding: .6rem .9rem; box-shadow: 0 .4rem 1rem rgba(0, 0, 0, .2); font-weight: 600; }
@media print { .aviso-fila, .aviso-toast { display: none !important; } body.com-aviso-fila { padding-top: 0; } }