/* Gestão de Cirurgias — tema da aplicação */
:root {
  --app-primary: #0f5c8c;
  --app-primary-600: #0b4a72;
  --app-primary-50: #e8f2f9;
  --app-accent: #0f9d8a;
  --app-bg: #f4f6f9;
  --app-surface: #ffffff;
  --app-border: #e3e8ef;
  --app-text: #1d2733;
  --app-muted: #6b7788;
  --sidebar-w: 248px;
  --bs-primary: #0f5c8c;
  --bs-primary-rgb: 15, 92, 140;
  --bs-link-color: #0f5c8c;
  --bs-link-color-rgb: 15, 92, 140;
  --bs-body-font-size: .925rem;
  --bs-body-color: #1d2733;
  --bs-border-color: #e3e8ef;
}

body { background: var(--app-bg); color: var(--app-text); }
.btn-primary { --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: var(--app-primary-600); --bs-btn-hover-border-color: var(--app-primary-600); --bs-btn-active-bg: var(--app-primary-600); }
.btn-outline-primary { --bs-btn-color: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: var(--app-primary); --bs-btn-hover-border-color: var(--app-primary); }
.text-purple { color: #6f42c1 !important; }
.bg-purple { background-color: #6f42c1 !important; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
@media (min-width: 992px) {
  /* mantém a coluna da barra lateral preenchida em páginas longas */
  .app-shell { background: linear-gradient(to right, #0e2a3f var(--sidebar-w), transparent var(--sidebar-w)); }
}
@media (max-width: 575.98px) {
  .status-cards { grid-template-columns: repeat(3, 1fr); gap: .5rem; }
  .status-card { padding: .5rem; }
  .status-card .status-badge { font-size: .6rem; padding: .2rem .4rem; }
  .status-card .count { font-size: 1.2rem; }
}
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: #0e2a3f; color: #c9d6e2;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 1rem .75rem; z-index: 1040;
  display: flex; flex-direction: column;
}
/* "Fale com a Central": sempre no rodapé da barra lateral */
.sidebar-help { margin-top: auto; padding-top: 1rem; }
.sidebar-help-btn {
  width: 100%; display: flex; align-items: center; gap: .65rem; text-align: left; color: #e6eef5;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; padding: .6rem .75rem;
}
.sidebar-help-btn:hover { background: rgba(255,255,255,.11); color: #fff; }
.sidebar-help-btn > .bi { font-size: 1.35rem; color: #e0b95a; }
.sidebar-help-btn strong { display: block; font-size: .88rem; }
.sidebar-help-btn small { display: block; font-size: .72rem; color: #9fb3c4; }
.contact-card { border: 1px solid var(--app-border); border-radius: 10px; padding: .75rem .9rem; }
.contact-card + .contact-card { margin-top: .65rem; }
.contact-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; margin-bottom: .35rem; }
.contact-label { font-weight: 700; color: var(--app-primary); }
.contact-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .75rem; padding: .2rem 0; }
.contact-value { text-decoration: none; font-weight: 500; }
.brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; padding: .25rem .5rem 1.25rem; line-height: 1.1; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #1a8fd1, #0f9d8a); display: grid; place-items: center; font-size: 1.25rem; }
.brand-logo { display: block; width: 100%; max-width: 210px; height: auto; }
.brand-text { font-size: .85rem; color: #cfe0ee; }
.brand-text strong { font-size: 1.05rem; color: #fff; }
/* "Título" de cada grupo da barra lateral (core/menu.py): tudo visível, sem dropdown. */
.side-nav .nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f98ad; padding: .85rem .75rem .3rem; }
.side-nav .nav-section:first-child { padding-top: .25rem; }
.side-nav .nav-link { color: #c9d6e2; border-radius: 8px; padding: .5rem .75rem; display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.side-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-nav .nav-link.active { background: #1a8fd1; color: #fff; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: var(--app-surface); border-bottom: 1px solid var(--app-border); display: flex; align-items: center; padding: 0 1.5rem; position: sticky; top: 0; z-index: 1030; }
.topbar-title { color: var(--app-muted); font-size: .9rem; }
.user-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--app-border); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--app-primary); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 600; }
.content { padding: 1.5rem; max-width: 1480px; width: 100%; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); transition: left .2s ease; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .brand-logo { max-width: 165px; }  /* espaço para o botão de fechar o menu */
  .content { padding: 1rem; }
  /* Fundo escurecido atrás do menu aberto: tocar nele fecha o menu */
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(9, 22, 34, .45); z-index: 1035; }
  body.sidebar-open { overflow: hidden; }
}
.sidebar-backdrop[hidden] { display: none; }
.sidebar-close { position: absolute; top: .65rem; right: .6rem; width: 40px; height: 40px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.08); color: #fff; display: grid; place-items: center; font-size: 1.1rem; z-index: 1; }
.sidebar-close:hover, .sidebar-close:focus-visible { background: rgba(255,255,255,.18); }

/* Cabeçalhos de página */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.45rem; font-weight: 650; margin: 0; }
.page-header .subtitle { color: var(--app-muted); font-size: .9rem; margin-top: .15rem; }

/* Cartões */
.card { border: 1px solid var(--app-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--app-border); font-weight: 600; padding: .85rem 1.1rem; }
.card-body { padding: 1.1rem; }
.section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); margin-bottom: .75rem; display: flex; align-items: center; gap: .4rem; }
.section-title .step { width: 22px; height: 22px; border-radius: 50%; background: var(--app-primary-50); color: var(--app-primary); display: inline-grid; place-items: center; font-size: .75rem; }

/* Formulários */
.form-label { font-weight: 550; font-size: .85rem; margin-bottom: .3rem; color: #344255; }
.form-label.required::after { content: " *"; color: #d63a3a; }
.form-control, .form-select { border-color: #d5dde7; }
.form-control:focus, .form-select:focus { border-color: #5aa6d6; box-shadow: 0 0 0 .2rem rgba(26,143,209,.15); }
.has-error .form-control, .has-error .form-select, .has-error .ts-control { border-color: #d63a3a; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; padding-top: 1rem; border-top: 1px solid var(--app-border); margin-top: .5rem; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(244,246,249,.95); backdrop-filter: blur(4px); padding: .75rem 0; z-index: 5; }
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; border: 0; box-shadow: none; }
.ts-control { border-color: #d5dde7; border-radius: var(--bs-border-radius); min-height: 38px; font-size: var(--bs-body-font-size); }
.ts-control input, .ts-dropdown { font-size: var(--bs-body-font-size); }
.table-nowrap td, .table-nowrap th { white-space: nowrap; }
.table-nowrap td .wrap { white-space: normal; min-width: 180px; }
.ts-dropdown .option small { color: var(--app-muted); }
.ts-dropdown { z-index: 1060; }

/* Status */
.status-badge { display: inline-flex; align-items: center; gap: .35rem; padding: .28rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; border: 1px solid transparent; }
.status-badge.lg { font-size: .85rem; padding: .4rem .85rem; }
.status-gerada { background: #fff4e0; color: #8a5300; border-color: #f3dcae; }
.status-concluida { background: #e6f0fb; color: #1d5fa8; border-color: #c7dcf3; }
.status-negada { background: #fdecec; color: #b42323; border-color: #f6cccc; }
.status-parcial { background: #fdf7d6; color: #7a5d00; border-color: #efdf9a; }
.status-autorizado { background: #e3f6f1; color: #0b7a66; border-color: #bfe8dd; }
.status-agendado { background: #efe9fb; color: #5b34b0; border-color: #dbcff5; }
.status-realizado { background: #e5f5e5; color: #1f7a2e; border-color: #c4e6c7; }
/* Etapas do faturamento (só na listagem de cirurgias, para quem vê o faturamento) */
.status-prefaturado { background: #fcedf5; color: #9b1f65; border-color: #f3cce1; }
.status-faturado { background: #f1f5e1; color: #4b5b0b; border-color: #dbe4b2; }
/* Cartões "Faturado · recebido" (verde) e "Faturado · a receber" (laranja), como os selos de recebimento */
.status-fat-recebido { background: #d1e7dd; color: #0f5132; border-color: #a3cfbb; }
.status-em-recurso { background: #fdecec; color: #a12a2a; border-color: #f5c2c2; }
.status-pago-recurso { background: #d4f4e9; color: #0b5d45; border-color: #9fdcc6; }
.status-cancelado { background: #eef0f3; color: #4d5866; border-color: #d9dee5; }
/* Pré-agendado (calendário e dashboard): só informação, tracejado para não parecer um agendamento. */
.status-preagendado { background: #f8f6fd; color: #6a52b0; border-color: #c9bcec; border-style: dashed; }
/* Tipo da cirurgia: selo da EMERGÊNCIA (templatetag kind_badge; a eletiva não tem selo) */
.kind-badge { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .55rem; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; background: #b42323; color: #fff; border: 1px solid #b42323; vertical-align: middle; }
.kind-badge.lg { font-size: .85rem; padding: .4rem .85rem; }
.table-surgeries .kind-badge { font-size: .6rem; padding: .12rem .4rem; }
/* Faixa do detalhe da cirurgia de emergência (no lugar dos passos do fluxo) */
.emergency-strip { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .9rem; padding: .6rem .8rem; border-radius: 10px; background: #fdecec; color: #8f1d1d; border: 1px solid #f6cccc; font-size: .85rem; }
/* Escolha do tipo da cirurgia (nova solicitação) */
.kind-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.kind-option { display: flex; flex-direction: column; gap: .5rem; padding: 1.25rem; border-radius: 14px; border: 2px solid var(--app-border); background: var(--app-surface); color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.kind-option:hover, .kind-option:focus-visible { border-color: #1d5fa8; box-shadow: 0 4px 14px rgba(29, 95, 168, .12); }
.kind-option.is-emergency:hover, .kind-option.is-emergency:focus-visible { border-color: #b42323; box-shadow: 0 4px 14px rgba(180, 35, 35, .12); }
.kind-option-icon { font-size: 1.8rem; line-height: 1; color: #1d5fa8; }
.kind-option.is-emergency .kind-option-icon { color: #b42323; }
.kind-option-title { font-size: 1.15rem; font-weight: 700; }
/* Seletor compacto no topo dos formulários de criação */
.kind-switch { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.kind-switch .btn-group .btn { min-width: 7.5rem; }

.status-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
/* Nome longo ("Solicitação concluída") quebra dentro do cartão em vez de ser cortado. */
.status-card .status-badge { white-space: normal; text-align: left; line-height: 1.25; }
.status-card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; padding: .75rem .9rem; text-decoration: none; color: inherit; display: block; transition: border-color .15s, box-shadow .15s; }
.status-card:hover { border-color: #9cc5e3; box-shadow: 0 2px 8px rgba(15,92,140,.08); color: inherit; }
.status-card.active { border-color: var(--app-primary); box-shadow: 0 0 0 2px rgba(15,92,140,.15); }
.status-card .count { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
/* Listagem: o total fica no pé do cartão, alinhado entre os cartões da linha (rótulos de 1 ou 2 linhas). */
.status-cards .status-card { display: flex; flex-direction: column; justify-content: space-between; }
/* Com as etapas do faturamento (11 cartões, para quem vê o faturamento; o FATURADO é dividido em
   "recebido" e "a receber" desde 19/11/2026): uma linha só quando cabem; senão 6 + 5, e 3 por linha no celular. */
.status-cards.with-stages { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (min-width: 1800px) { .status-cards.with-stages { grid-template-columns: repeat(11, minmax(0, 1fr)); } }
@media (max-width: 767.98px) { .status-cards.with-stages { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 575.98px) {
  .status-cards.with-stages { gap: .5rem; }
  .status-cards.with-stages .status-card { padding: .5rem .55rem; }
  .status-cards.with-stages .status-badge .bi { display: none; }  /* o rótulo cabe no cartão estreito */
  .status-cards.with-stages .count { font-size: 1.2rem; }
}

/* Tabelas */
.table-app { margin: 0; }
.table-app thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); font-weight: 650; background: #f8fafc; border-bottom: 1px solid var(--app-border); white-space: nowrap; padding: .65rem .75rem; }
.table-app td { padding: .65rem .75rem; vertical-align: middle; border-color: #eef1f5; }
.table-app tbody tr.row-link { cursor: pointer; }
.table-app tbody tr.row-link:hover td { background: #f5f9fd; }
.table-app thead th a { color: inherit; text-decoration: none; }
.table-app thead th a.sort-link { display: inline; }
.table-app thead th a.sort-link .bi { margin-left: .15rem; white-space: nowrap; }
.table-app thead th a.sort-link:hover, .table-app thead th a.sort-link.active { color: var(--app-primary); }
.table-app thead th .sort-idle { opacity: .35; font-size: .85em; }
.table-app thead th a.sort-link:hover .sort-idle { opacity: .8; }

/* Listagem de cirurgias: tabela densa, títulos quebram linha, cabeçalho fixo na rolagem */
.page-wide .content { max-width: none; }
.table-surgeries { font-size: .82rem; }
.table-surgeries thead th { white-space: normal; vertical-align: bottom; line-height: 1.25; padding: .5rem .4rem; font-size: .76rem; text-transform: none; letter-spacing: 0; }
.table-surgeries td { padding: .4rem .4rem; line-height: 1.3; }
.table-surgeries .col-num { white-space: nowrap; }
.table-surgeries td.col-wide { min-width: 8.5rem; }
.table-surgeries td.col-mid { min-width: 5.5rem; }
.table-surgeries td.col-status { min-width: 7rem; max-width: 10rem; }
.table-surgeries .status-badge { font-size: .64rem; padding: .2rem .45rem; white-space: normal; text-align: left; line-height: 1.2; border-radius: 8px; max-width: 100%; }  /* quebra dentro da coluna em vez de invadir "Paciente" */
.table-surgeries .expiry-badge { white-space: normal; border-radius: 8px; font-size: .68rem; line-height: 1.2; }
.table-surgeries .small-muted { font-size: .74rem; }
.table-scroll { overflow: auto; }
@media (min-width: 992px) {
  .table-scroll { max-height: calc(100vh - 170px); }
  .table-scroll thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--app-border); }
}
/* Termos de Uso e Política de Privacidade */
.legal-public .content { max-width: 960px; }
.legal-draft { display: flex; gap: .6rem; align-items: flex-start; font-size: .88rem; max-width: 960px; }
.legal-doc { max-width: 960px; }
.legal-doc .card-body { padding: 1.5rem 1.75rem; }
.legal-doc section + section { margin-top: 1.4rem; }
.legal-doc h2 { font-size: 1rem; font-weight: 650; color: var(--app-text); margin-bottom: .55rem; }
.legal-doc p, .legal-doc li { line-height: 1.6; color: #344255; }
.legal-doc ul { padding-left: 1.2rem; margin-bottom: .5rem; }
.legal-doc li + li { margin-top: .3rem; }
.legal-doc .legal-table td:first-child { white-space: nowrap; font-weight: 600; }
.legal-fill { background: #fff5e0; color: #8a5a00; border-radius: 4px; padding: 0 .25rem; }
@media (max-width: 575.98px) { .legal-doc .card-body { padding: 1.1rem; } .legal-doc .legal-table td:first-child { white-space: normal; } }
.pager .page-size-form .form-select { width: auto; padding-top: .15rem; padding-bottom: .15rem; }
.pager .pagination .page-link { min-width: 2rem; text-align: center; }
.surgery-number { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; color: var(--app-primary); }
.muted { color: var(--app-muted); }
.small-muted { color: var(--app-muted); font-size: .8rem; }

/* Filtros */
.filters .form-label { font-size: .75rem; }
.filters-toggle[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

/* Detalhes */
.detail-hero { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 14px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.detail-hero .number { font-size: 1.6rem; font-weight: 750; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--app-primary); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem 1.25rem; }
.kv dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); font-weight: 650; margin-bottom: .15rem; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.flow-steps { display: flex; gap: 0; align-items: center; margin-top: 1rem; overflow-x: auto; padding-bottom: .25rem; }
.flow-step { display: flex; align-items: center; gap: .45rem; font-size: .78rem; font-weight: 650; color: #9aa6b5; white-space: nowrap; }
.flow-step .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #d3dae3; display: grid; place-items: center; background: #fff; font-size: .8rem; }
.flow-step.done { color: #0b7a66; }
.flow-step.done .dot { border-color: #0f9d8a; background: #0f9d8a; color: #fff; }
.flow-step.current { color: var(--app-primary); }
.flow-step.current .dot { border-color: var(--app-primary); background: var(--app-primary); color: #fff; box-shadow: 0 0 0 4px rgba(15,92,140,.15); }
.flow-step.failed .dot { border-color: #d63a3a; background: #d63a3a; color: #fff; }
.flow-step.failed { color: #b42323; }
.flow-line { flex: 1 1 24px; min-width: 24px; height: 2px; background: #d3dae3; margin: 0 .5rem; }
.flow-line.done { background: #0f9d8a; }

.nav-tabs-app { border-bottom: 1px solid var(--app-border); gap: .25rem; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.nav-tabs-app .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--app-muted); font-weight: 600; padding: .6rem .7rem; white-space: nowrap; }
.nav-tabs-app .nav-link.active { color: var(--app-primary); border-bottom-color: var(--app-primary); background: transparent; }
.nav-tabs-app .nav-link .badge { font-weight: 600; }

.stage-col { border-radius: 10px; border: 1px solid var(--app-border); padding: .85rem; height: 100%; background: #fff; }
.stage-col h6 { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; margin-bottom: .6rem; }
.stage-col.req h6 { color: #1d5fa8; }
.stage-col.aut h6 { color: #0b7a66; }
.stage-col.rea h6 { color: #1f7a2e; }
.team-list { list-style: none; padding: 0; margin: 0; }
.team-list li { display: flex; justify-content: space-between; gap: .75rem; padding: .35rem 0; border-bottom: 1px dashed #edf0f4; font-size: .88rem; }
.team-list li:last-child { border-bottom: 0; }
.team-list .role { color: var(--app-muted); font-size: .78rem; }
/* Editores de equipe: autorizada × realizada — visualmente distintos */
.team-editor { border-radius: 10px; border: 1px solid var(--app-border); border-left-width: 4px; padding: .5rem .85rem; background: #fff; }
.team-editor.aut { border-left-color: #0b7a66; }
.team-editor.rea { border-left-color: #1f7a2e; background: #fbfdfb; }
.team-editor-head, .team-editor-row { display: grid; grid-template-columns: 1fr; gap: .25rem .75rem; align-items: center; }
.team-editor-head { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; color: var(--app-muted); padding: .35rem 0; border-bottom: 1px solid #edf0f4; }
.team-editor-row { padding: .6rem 0; border-bottom: 1px dashed #edf0f4; }
.team-editor-row:last-child { border-bottom: 0; }
.team-editor-row .form-label { margin: 0; font-weight: 600; }
@media (min-width: 768px) {
  .team-editor-head, .team-editor-row { grid-template-columns: 11rem minmax(0, 1fr); }
  .team-editor.has-participation .team-editor-head, .team-editor.has-participation .team-editor-row { grid-template-columns: 11rem minmax(0, 1fr) 8.5rem; }
}
/* "Participou?" da equipe da realização (16/11/2026) */
.participation-wrap { display: flex; flex-direction: column; justify-content: center; }
.team-list li.is-absent .member-name { color: var(--app-muted); text-decoration: line-through; }
.cmp-table td.diff { background: #fff8e6; }
.qty-pill { display: inline-block; min-width: 28px; text-align: center; padding: .1rem .45rem; border-radius: 6px; background: #eef3f8; font-weight: 700; font-size: .82rem; }
.qty-none { color: #b8c1cc; }
.principal-tag { font-size: .65rem; font-weight: 700; text-transform: uppercase; background: var(--app-primary-50); color: var(--app-primary); border-radius: 4px; padding: .05rem .35rem; margin-left: .35rem; vertical-align: middle; }
/* Porte da CBHPM no editor de procedimentos e na busca (12/11/2026) */
.porte-tag { font-size: .65rem; font-weight: 700; white-space: nowrap; background: #eef2f7; color: #334155; border-radius: 4px; padding: .05rem .35rem; margin-left: .35rem; vertical-align: middle; }
.porte-tag.none { background: transparent; color: #94a3b8; border: 1px dashed #cbd5e1; font-weight: 600; }
.proc-porte-note { color: #475569; padding: .35rem .25rem 0; }

.attempt { border: 1px solid var(--app-border); border-radius: 12px; margin-bottom: 1rem; overflow: hidden; background: #fff; }
.attempt-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: #f8fafc; border-bottom: 1px solid var(--app-border); }
.attempt.denied .attempt-head { background: #fff5f5; }
.attempt.current { border-color: #7cc9b8; box-shadow: 0 0 0 2px rgba(15,157,138,.12); }

/* Timeline */
.timeline { position: relative; list-style: none; padding: 0 0 0 2.25rem; margin: 0; }
.timeline::before { content: ""; position: absolute; left: 14px; top: 6px; bottom: 6px; width: 2px; background: #e1e7ee; }
.timeline-item { position: relative; padding: 0 0 1.1rem; }
.timeline-icon { position: absolute; left: -2.25rem; top: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .9rem; background: #fff; border: 2px solid #d3dae3; color: var(--app-muted); }
.timeline-item.milestone .timeline-icon { color: #fff; border-color: transparent; }
.timeline-item.milestone.c-primary .timeline-icon { background: #1d5fa8; }
.timeline-item.milestone.c-success .timeline-icon { background: #0f9d8a; }
.timeline-item.milestone.c-danger .timeline-icon { background: #d63a3a; }
.timeline-item.milestone.c-purple .timeline-icon { background: #6f42c1; }
.timeline-item.milestone.c-dark .timeline-icon { background: #4d5866; }
.timeline-item.milestone.c-warning .timeline-icon { background: #e39b17; }
.timeline-card { background: #fff; border: 1px solid var(--app-border); border-radius: 10px; padding: .6rem .85rem; }
.timeline-item.milestone .timeline-card { border-left: 3px solid var(--app-primary); }
.timeline-title { font-weight: 700; font-size: .9rem; }
.timeline-meta { font-size: .78rem; color: var(--app-muted); }
.change-list { margin: .4rem 0 0; padding: 0; list-style: none; font-size: .8rem; }
.change-list li { padding: .12rem 0; }
.change-old { color: #b42323; text-decoration: line-through; text-decoration-color: rgba(180,35,35,.4); }
.change-new { color: #1f7a2e; font-weight: 600; }
.timeline.only-milestones .timeline-item:not(.milestone) { display: none; }

/* Procedimentos (editor) */
.proc-editor .proc-row { display: grid; grid-template-columns: 1fr 110px 110px 84px; gap: .5rem; align-items: center; padding: .5rem .6rem; border: 1px solid var(--app-border); border-radius: 10px; margin-bottom: .5rem; background: #fff; }
.proc-editor .proc-row.principal { border-color: #86b7da; background: #f4f9fd; }
.proc-editor .proc-row.replacing { border-color: var(--app-primary); box-shadow: 0 0 0 2px rgba(15,92,140,.15); }
.proc-editor .proc-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; color: var(--app-primary); }
.proc-editor .proc-desc { font-size: .85rem; color: #3c4a5c; }
.proc-editor .empty { border: 1px dashed #cdd6e1; border-radius: 10px; padding: .9rem; color: var(--app-muted); text-align: center; font-size: .88rem; }
@media (max-width: 575.98px) { .proc-editor .proc-row { grid-template-columns: 1fr 80px; } }
/* Procedimentos AUTORIZADOS: solicitado (referência) × autorizado (0 = não autorizado) + motivo da glosa */
.proc-editor .proc-row.auth { grid-template-columns: minmax(0, 1fr) 76px 96px 90px 84px; }
.proc-editor .proc-row.auth .proc-glosa { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .5rem; align-items: center; }
.proc-editor .proc-row.auth .proc-glosa label { margin: 0; white-space: nowrap; }
.proc-editor .proc-row.glosed { border-color: #f1c4c4; background: #fff8f8; }
.proc-editor .proc-row.glosed .proc-glosa-input { border-color: #e9a3a3; }
.proc-editor .proc-ref .qty-pill { background: #f1f4f8; color: #56637a; }
.glosa-tag { font-size: .65rem; font-weight: 700; text-transform: uppercase; background: #fdecec; color: #a12a2a; border-radius: 4px; padding: .05rem .35rem; margin-left: .35rem; vertical-align: middle; }
.qty-pill.qty-zero { background: #fdecec; color: #a12a2a; }
@media (max-width: 767.98px) {
  .proc-editor .proc-row.auth { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proc-editor .proc-row.auth .proc-main { grid-column: 1 / -1; }
  .proc-editor .proc-row.auth .proc-glosa { grid-template-columns: 1fr; gap: .15rem; }
}
/* Card unificado da autorização: subseções no mesmo bloco visual */
/* (não usar .auth-card: é a classe do card de login, com max-width de 410px) */
.authz-card .auth-block { padding: .9rem 0; border-top: 1px dashed var(--app-border); }
.authz-card .auth-block:first-of-type { border-top: 0; padding-top: .25rem; }
.authz-card .auth-block-title { font-size: .82rem; font-weight: 600; color: var(--app-text); margin: 0 0 .6rem; display: flex; align-items: center; gap: .4rem; }
.authz-card .auth-block-title .bi { color: var(--app-primary); }
.authz-card .doc-section { border-top-style: dashed; }
.auth-proc-table tr.glosed td { background: #fff8f8; }
/* Validade da autorização (autorizadas ainda não agendadas) */
.expiry-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; border-radius: 999px; padding: .12rem .5rem; border: 1px solid transparent; white-space: nowrap; text-decoration: none; }
.expiry-badge.due { background: #fff5e0; color: #8a5a00; border-color: #f5dfae; }
.expiry-badge.expired { background: #fdecec; color: #a12a2a; border-color: #f5c9c9; }
.expiry-badge.pending { background: #fdeee4; color: #9a3d0c; border-color: #f6cdb2; }
.expiry-badge.info { background: #eef4fb; color: #2b5d8f; border-color: #d3e3f3; }
a.expiry-badge:hover { filter: brightness(.97); }
.expiry-summary { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .85rem; padding: .55rem .8rem; border-radius: 10px; background: #fffaf0; border: 1px solid #f0d9a4; color: #6b4a00; }
.expiry-summary > .bi { color: #c98a00; }
.expiry-summary.pending { background: #fff6f0; border-color: #f3cfb6; color: #7a3410; }
.expiry-summary.pending > .bi { color: #d2601a; }
.expiry-summary.send { background: #f3f7fc; border-color: #d3e3f3; color: #1f4a73; }
.expiry-summary.send > .bi { color: #2b6cb0; }
/* Tela "Valor retido" (27/11/2026; billing/retained.py): barras do mês e do % por profissional */
.retained-months { display: flex; align-items: flex-end; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; }
.retained-month { flex: 1 0 64px; display: flex; flex-direction: column; align-items: center; gap: .25rem; min-width: 64px; }
.retained-month-value { font-size: .7rem; font-weight: 600; white-space: nowrap; color: #1d5b34; }
.retained-month-bar { display: flex; align-items: flex-end; width: 100%; max-width: 48px; height: 120px; background: #f1f4f8; border-radius: 6px; overflow: hidden; }
.retained-month-bar > span { display: block; width: 100%; background: #1f8a4c; border-radius: 6px 6px 0 0; min-height: 2px; }
.retained-month-label { font-size: .72rem; color: var(--bs-secondary-color, #6c757d); text-transform: capitalize; }
.retained-share { white-space: nowrap; }
.retained-share-bar { display: inline-block; vertical-align: middle; width: 80px; height: 8px; background: #f1f4f8; border-radius: 999px; overflow: hidden; margin-right: .35rem; }
.retained-share-bar > span { display: block; height: 100%; background: #1f8a4c; }
.retained-total { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; padding: .75rem 1rem; border-top: 1px solid var(--bs-border-color, #dee2e6); font-size: .9rem; }
/* Selo "Novo valor" do médico (27/11/2026; billing/recovery_notices.py): recurso de glosa pago ainda não visto */
.expiry-summary.new-value-summary { background: #eefaf2; border-color: #bfe5cc; color: #1d5b34; }
.expiry-summary.new-value-summary > .bi { color: #1f8a4c; }
.new-value-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: .12rem .55rem; background: #1f8a4c; color: #fff; border: 1px solid #1f8a4c; white-space: nowrap; text-decoration: none; }
.new-value-badge:hover, .new-value-badge:focus { background: #176b3a; color: #fff; }
.new-value-banner { background: #eefaf2; border: 1px solid #bfe5cc; color: #1d5b34; }

/* Envio da solicitação ao hospital */
.send-deadline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.send-preview > summary { cursor: pointer; color: var(--app-primary); }
/* E-mails do hospital: todos mantidos; "Remover"/"Desfazer" é o rótulo do checkbox (sem JavaScript) */
.send-to-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.send-to { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; padding: .3rem .3rem .3rem .65rem; border: 1px solid var(--app-border); border-radius: 8px; background: #fff; }
.send-to-email { flex: 1 1 180px; min-width: 0; font-weight: 600; }
.send-to-toggle { white-space: nowrap; margin: 0; }
.send-to-removed, .send-to .when-removed { display: none; }
.send-to-check:not(:checked) ~ .send-to-email { text-decoration: line-through; color: var(--bs-secondary-color, #6c757d); font-weight: 400; }
.send-to-check:not(:checked) ~ .send-to-removed, .send-to-check:not(:checked) ~ .send-to-toggle .when-removed { display: inline; }
.send-to-check:not(:checked) ~ .send-to-toggle .when-kept { display: none; }
.send-to:has(.send-to-check:not(:checked)) { background: #fafafa; border-style: dashed; }
.send-to-check:focus-visible ~ .send-to-toggle { outline: 2px solid var(--app-primary); outline-offset: 2px; }
/* Solicitação assinada: arquivo do dispositivo ou "Do repositório" (um tira o outro) */
.signed-pick { display: flex; flex-wrap: wrap; gap: .5rem; }
.signed-pick input[type="file"] { flex: 1 1 240px; min-width: 0; }
.signed-pick .btn { white-space: nowrap; }
.signed-repo-choice { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; padding: .5rem .65rem; border: 1px solid #cfe2f3; border-radius: 8px; background: #f1f8ff; font-size: .86rem; }
.signed-repo-choice[hidden] { display: none; }
.signed-repo-choice > .bi { font-size: 1.15rem; color: var(--app-primary); }
.send-preview-body { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .82rem; background: #f8fafc; border: 1px solid var(--app-border); border-radius: 8px; padding: .75rem; margin: .5rem 0 0; }
.doc-type-tag.signed { background: #e3f6f1; color: #0b6b58; }
/* Envio feito fora do sistema: atalho na tela de envio e opções de "Como foi enviada?" */
.send-external-hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; padding: .6rem .85rem; border: 1px dashed #b9c6d6; border-radius: 8px; background: #f8fafc; font-size: .9rem; }
.send-means { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; }
.send-means label { display: flex; align-items: center; gap: .55rem; margin: 0; padding: .55rem .7rem; border: 1px solid var(--app-border); border-radius: 8px; cursor: pointer; background: #fff; }
.send-means label:has(input:checked) { border-color: var(--app-primary); background: #f1f8ff; box-shadow: 0 0 0 1px var(--app-primary); }
.send-means .form-check-input { margin: 0; flex: none; }
.send-means .bi { color: var(--app-primary); font-size: 1.05rem; }
.badge.external-send { background: #eef2f7; color: #334155; border: 1px solid #d5dde8; }
/* Envio ao hospital: os 2 e-mails (hospital e aviso ao paciente/médico) */
.send-mails-intro { padding: .7rem .9rem; border-radius: .5rem; background: #eef5fb; border: 1px solid #d3e4f2; font-size: .92rem; }
.send-mail-band { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: 0 0 .6rem; padding-bottom: .35rem; border-bottom: 2px solid #13294b; }
.send-mail-band.notice { border-bottom-color: #c9a24a; margin-top: 1.5rem; }
.send-mail-band.compact { margin: .25rem 0 .5rem; border-bottom-width: 1px; font-size: .92rem; }
/* Conferência dos documentos na confirmação do envio (hospital_send.send_checklist) */
.send-check { border: 1px solid #b7dfc4; background: #f1faf4; border-radius: .5rem; padding: .75rem .9rem; }
.send-check.is-missing { border-color: #f0c36d; background: #fff8e6; }
.send-check-head { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .5rem; }
.send-check-head > i { color: #1e7e44; margin-top: .1rem; }
.send-check.is-missing .send-check-head > i { color: #b7791f; }
.send-check-list { list-style: none; padding: 0; margin: 0 0 .25rem; }
.send-check-list li { display: flex; gap: .5rem; align-items: flex-start; padding: .2rem 0; }
.send-check-list li.is-ok > i { color: #1e7e44; }
.send-check-list li.is-missing > i { color: #b7791f; }
.send-check-list li.is-missing .small { color: #8a5a00; }
.send-check-tip { color: #5c4a1a; margin-top: .35rem; }
.send-check-ack { margin-top: .6rem; padding-top: .5rem; border-top: 1px dashed #f0c36d; font-weight: 600; }
.send-mail-num { display: inline-block; padding: .12rem .55rem; border-radius: 999px; background: #13294b; color: #fff; font-size: .78rem; font-weight: 600; letter-spacing: .02em; }
.send-mail-band.notice .send-mail-num { background: #c9a24a; color: #1d2733; }
.notice-list { list-style: none; margin: 0; padding: 0; }
.notice-row { display: flex; align-items: center; gap: .75rem; padding: .6rem .25rem; border-bottom: 1px solid #eef1f5; }
.notice-row:last-child { border-bottom: 0; }
.notice-row label { cursor: pointer; }
.notice-row.is-off label, .notice-row.is-off .notice-tag { opacity: .5; }
.notice-tag { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #eef2f7; border: 1px solid #d5dde8; color: #334155; white-space: nowrap; }
/* Protocolo do hospital (confirmação de recebimento; só informativo) */
.protocol-code { font-family: var(--bs-font-monospace); font-weight: 600; letter-spacing: .02em; word-break: break-all; }
.badge.protocol-ok { background: #e7f6ee; color: #146c43; border: 1px solid #b7e2c8; font-weight: 500; }
.protocol-card { border-left: 3px solid #d5dde8; }
.protocol-card.confirmed { border-left-color: #2fa36b; }
.protocol-input { font-family: var(--bs-font-monospace); font-size: 1.05rem; }
.list-protocol { font-size: .75rem; color: #146c43; white-space: nowrap; }

.patient-found { border-left: 3px solid var(--app-accent); background: #effaf7; }
/* Busca do paciente pelo nome na nova solicitação (initPatientLookup; registry/patient_search.py). */
.patient-name-results { position: absolute; z-index: 1060; left: 0; right: 0; top: 100%; max-height: 22rem; overflow-y: auto; }
.patient-name-results .list-group-item-action.active .small-muted { color: rgba(255, 255, 255, .85); }
.doc-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .25rem; border-bottom: 1px solid #eef1f5; }
.doc-item:last-child { border-bottom: 0; }
.doc-item > .bi { font-size: 1.3rem; color: var(--app-primary); }
.min-w-0 { min-width: 0; }
.doc-item.deleted { opacity: .6; }
.doc-item.deleted .name { text-decoration: line-through; }

.flash-stack .alert { border-radius: 10px; }
/* Recusa ligada a um campo (extra_tags "goto:"): a faixa inteira leva ao campo (initGotoLinks). */
.alert-goto { cursor: pointer; transition: filter .15s; }
.alert-goto:hover { filter: brightness(.97); }
.alert-goto-link { color: inherit; text-decoration: none; }
.alert-goto:hover .alert-goto-link, .alert-goto-link:focus-visible { text-decoration: underline; }
.alert-goto-link:focus-visible { outline: none; }
.alert-goto:focus-within { box-shadow: 0 0 0 .2rem rgba(220, 53, 69, .35) !important; }
.alert-goto-hint { white-space: nowrap; font-size: .85em; font-weight: 600; opacity: .8; margin-left: .25rem; }
.alert-goto .btn-close { z-index: 2; }
/* Campo de destino: destaque passageiro ao chegar pela faixa. */
.goto-flash { animation: goto-flash 1.8s ease-out; border-radius: 8px; }
@keyframes goto-flash { 0%, 35% { box-shadow: 0 0 0 .3rem rgba(220, 53, 69, .45); } 100% { box-shadow: 0 0 0 .3rem rgba(220, 53, 69, 0); } }
@media (prefers-reduced-motion: reduce) { .goto-flash { animation: none; outline: 2px solid #dc3545; } }
.empty-state { text-align: center; color: var(--app-muted); padding: 2.5rem 1rem; }
.empty-state .bi { font-size: 2.2rem; color: #b6c3d1; display: block; margin-bottom: .5rem; }

/* Login */
body.auth { background: linear-gradient(135deg, #0e2a3f 0%, #0f5c8c 55%, #0f9d8a 100%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 410px; border: 0; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.auth-card .brand-mark { width: 48px; height: 48px; font-size: 1.5rem; color: #fff; }
.auth-logo-wrap { text-align: center; margin-bottom: 1.75rem; }
.auth-logo { display: inline-block; width: 100%; max-width: 300px; height: auto; }

.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix td:first-child, .perm-matrix th:first-child { text-align: left; }

/* ---------------------------------------------------------------- Visualização de dados
   Paleta categórica validada (daltonismo/contraste): série 1 azul, série 2 laranja.
   Texto nunca usa a cor da série; marcas finas, grade recessiva. */
:root {
  --viz-s1: #2a78d6;
  --viz-s2: #eb6834;
  --viz-grid: #e9ecf1;
  --viz-axis: #c9d0d9;
  --viz-track: #eef2f7;
}

/* Indicadores (stat tiles) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); gap: .75rem; }
.kpi { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; padding: .85rem 1rem; }
.kpi-label { font-size: .78rem; font-weight: 600; color: var(--app-muted); }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; margin-top: .2rem; color: var(--app-text); }
.kpi-note { font-size: .72rem; color: var(--app-muted); margin-top: .15rem; }
.kpi-hero { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; border-color: #c7dcf3; background: linear-gradient(180deg, #f5f9ff 0%, #fff 100%); }
.kpi-hero .kpi-value { font-size: 3rem; }
@media (max-width: 575.98px) { .kpi-hero { grid-row: auto; } .kpi-hero .kpi-value { font-size: 2.25rem; } }

/* Legenda (2+ séries) */
.viz-legend { font-size: .8rem; font-weight: 400; color: var(--app-muted); display: inline-flex; align-items: center; gap: .35rem; }
.viz-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.viz-key.s1, .vbar.s1 { background: var(--viz-s1); }
.viz-key.s2, .vbar.s2 { background: var(--viz-s2); }

/* Barras horizontais (uma série, rótulo direto do valor) */
.hbar { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: .6rem; font-size: .85rem; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label .status-badge { white-space: normal; line-height: 1.25; }  /* "Solicitação concluída" quebra em vez de cortar */
.hbar-track { display: block; height: 14px; background: var(--viz-track); border-radius: 0 4px 4px 0; }
.hbar-bar { display: block; height: 100%; min-width: 2px; background: var(--viz-s1); border-radius: 0 4px 4px 0; }
.hbar-bar.is-zero { display: none; }  /* valor zero: sem marca (o número continua escrito ao lado) */
.hbar-row.is-other .hbar-bar { background: var(--viz-axis); }
.hbar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2.5ch; text-align: right; }
.viz-rank td { vertical-align: middle; }
.viz-rank-bar-col { min-width: 140px; }
.rank-cell { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; }
.viz-desc { white-space: normal; min-width: 180px; }

/* Colunas agrupadas (um único eixo de contagem) */
.vchart { --plot-h: 210px; }
.vchart-plot { position: relative; height: var(--plot-h); margin-left: 2rem; border-bottom: 1px solid var(--viz-axis); }
.vchart-tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--viz-grid); }
.vchart-tick span { position: absolute; left: -2rem; width: 1.7rem; text-align: right; transform: translateY(-50%); font-size: .7rem; color: var(--app-muted); font-variant-numeric: tabular-nums; }
.vchart-bands { position: absolute; inset: 0; display: flex; }
.vchart-band { flex: 1 1 0; display: flex; justify-content: center; align-items: flex-end; gap: 2px; min-width: 0; }
.vchart-band:hover { background: rgba(15, 92, 140, .05); }
.vbar { width: 40%; max-width: 18px; min-height: 0; border-radius: 4px 4px 0 0; }
.vchart-x { display: flex; margin-left: 2rem; padding-top: .35rem; }
.vchart-x span { flex: 1 1 0; text-align: center; font-size: .7rem; color: var(--app-muted); white-space: nowrap; min-width: 0; overflow: hidden; }
.viz-table summary { font-size: .8rem; color: var(--app-muted); cursor: pointer; }

/* Volume de cirurgias por mês: colunas empilhadas (realizadas, agendadas, pré-agendadas) */
.vchart-volume { --plot-h: 240px; }
.vchart-volume .vchart-plot { margin-top: 1.1rem; }  /* espaço para o total acima da coluna mais alta */
.vchart-volume .vchart-band { text-decoration: none; color: inherit; border-radius: 6px 6px 0 0; }
.vchart-volume .vchart-band.is-current { background: rgba(15, 92, 140, .06); }
.vstack { position: relative; display: flex; flex-direction: column; align-self: flex-end; margin-top: auto; flex: 0 0 56%; max-width: 46px; min-width: 0; min-height: 0; }
.vstack-total { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 2px; font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--app-text); white-space: nowrap; }
.vseg { display: block; width: 100%; min-height: 2px; }
.vstack-total + .vseg { border-radius: 4px 4px 0 0; }  /* fatia do topo */
.viz-key.vol-realized, .vseg.vol-realized { background: #1f4e79; }
.viz-key.vol-scheduled, .vseg.vol-scheduled { background: var(--viz-s1); }
.viz-key.vol-pre, .vseg.vol-pre { background: repeating-linear-gradient(135deg, #b9a8ea 0 4px, #d9cff5 4px 8px); border: 1px dashed #6a52b0; }
.vchart-x span.is-current { font-weight: 700; color: var(--app-text); }

/* Área "Dashboards": barra de abas (surgeries/dashboards.py) */
.dash-tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--app-border); scrollbar-width: thin; }
.dash-tab { flex: none; display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .95rem; font-weight: 600; font-size: .9rem; color: var(--app-muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.dash-tab:hover { color: var(--app-text); }
.dash-tab.active { color: var(--viz-s1); border-bottom-color: var(--viz-s1); }
.dash-pills { display: inline-flex; flex-wrap: wrap; gap: .25rem; }
.dash-pill { padding: .2rem .7rem; border-radius: 999px; border: 1px solid var(--app-border); font-size: .8rem; font-weight: 400; color: var(--app-muted); text-decoration: none; background: var(--app-surface); }
.dash-pill:hover { color: var(--app-text); }
.dash-pill.active { background: var(--viz-s1); border-color: var(--viz-s1); color: #fff; }

/* Dashboard "Diário": colunas por dia (fim de semana sombreado, dia aberto em destaque) */
.vchart-daily .vchart-band.is-weekend { background: rgba(108, 117, 125, .07); }
.vchart-daily .vchart-band.is-current { background: rgba(15, 92, 140, .14); }
.vchart-daily .vchart-band.is-today .vstack::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 5px; height: 5px; border-radius: 50%; background: var(--viz-s2); transform: translateX(-50%); }
.vchart-daily .vstack { flex-basis: 70%; max-width: 26px; }
.vchart-daily .vstack-total { font-size: .65rem; }
.vchart-daily .vchart-x span.is-weekend { color: #9aa3ad; }
.vchart-daily.is-dense .vstack-total { display: none; }  /* períodos longos: o total fica no título e na tabela */
.vchart-daily.is-dense .vchart-x span:nth-child(odd):not(.is-current) { visibility: hidden; }
@media (max-width: 767.98px) {
  .vchart-daily .vstack-total { display: none; }
  .vchart-daily .vchart-x span { visibility: hidden; }
  .vchart-daily .vchart-x span:nth-child(5n+1), .vchart-daily .vchart-x span.is-current { visibility: visible; }
}

/* Mapa de calor (dimensão × dia): rola dentro do cartão, nome fixo à esquerda */
.heatmap-wrap { max-width: 100%; }
.heatmap { border-collapse: separate; border-spacing: 2px; font-size: .75rem; font-variant-numeric: tabular-nums; margin: 0 .5rem .25rem; }
.heatmap th, .heatmap td { text-align: center; padding: 0; }
.heatmap .heat-name { position: sticky; left: 0; z-index: 1; background: var(--app-surface); text-align: left; padding: .25rem .6rem .25rem .25rem; max-width: 190px; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.heatmap thead .heat-name, .heatmap tfoot .heat-name { color: var(--app-muted); font-size: .72rem; }
.heatmap .heat-day { min-width: 26px; font-weight: 600; color: var(--app-muted); line-height: 1.1; }
.heatmap .heat-day a { display: block; padding: .15rem 0; color: inherit; text-decoration: none; border-radius: 4px; }
.heatmap .heat-day a:hover { background: var(--viz-track); }
.heatmap .heat-day.is-weekend { color: #9aa3ad; }
.heatmap .heat-day.is-selected a { background: var(--viz-s1); color: #fff; }
.heatmap .heat-wd { display: block; font-size: .62rem; font-weight: 400; }
.heatmap .heat-cell { height: 26px; min-width: 26px; border-radius: 4px; background: var(--viz-track); color: var(--app-text); }
.heatmap .heat-cell.is-weekend.heat-0 { background: #e7ebf0; }
.heatmap .heat-1 { background: #d6e6f8; }
.heatmap .heat-2 { background: #9fc4ee; }
.heatmap .heat-3 { background: #4f91de; color: #fff; }
.heatmap .heat-4 { background: #1f4e79; color: #fff; font-weight: 700; }
.heatmap .heat-total { font-weight: 700; padding: 0 .4rem; min-width: 26px; }
.heatmap tr.is-other .heat-name { color: var(--app-muted); }

/* Produção da Central e detalhe do dia */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: .6rem; }
.prod-item { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border: 1px solid var(--app-border); border-radius: 10px; }
.prod-item > i { font-size: 1.1rem; color: var(--viz-s1); }
.prod-value { font-size: 1.35rem; font-weight: 700; line-height: 1.1; color: var(--app-text); }
.day-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.day-stats > div { padding: .5rem .75rem; border-radius: 10px; background: var(--viz-track); }
.day-prod li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--app-border); font-size: .85rem; }
.day-prod li:last-child { border-bottom: 0; }
.day-prod i { color: var(--viz-s1); }
@media (max-width: 575.98px) { .day-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Dashboard "Conversão" (ambulatorio/conversion.py): taxa por profissional; acima de 100% em destaque */
.conv-rate-col { min-width: 190px; width: 30%; }
.conv-rate .hbar-value { min-width: 6.5ch; white-space: nowrap; }
.conv-rate.is-over .hbar-bar, .conv-ranking .is-over .hbar-bar { background: var(--viz-s2); }
.conv-rate.is-over .hbar-value i { color: var(--viz-s2); }
.conv-table .conv-group th { background: var(--viz-track); font-size: .78rem; color: var(--app-muted); padding-top: .35rem; padding-bottom: .35rem; }
.conv-table tfoot td { border-top: 2px solid var(--app-border); }
.conv-ranking .hbar-value { white-space: nowrap; }
.conv-scroll { max-height: 420px; overflow-y: auto; }
.conv-detail-col + .conv-detail-col { border-left: 1px solid var(--app-border); }
.conv-rules li + li { margin-top: .3rem; }
.conv-surgery { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .4rem; }
.conv-surgery + .conv-surgery { margin-top: .25rem; }
.conv-not-counted td { opacity: .6; }  /* solicitação ainda não realizada: não conta na taxa */
.conv-table td.keep-case, .conv-detail-col td.keep-case { text-transform: none; }  /* `.table-app td` é mais específico que `.keep-case` */
@media (max-width: 767.98px) {  /* celular: Profissional, Consultas, Cirurgias e Taxa cabem sem rolar */
  .conv-table { table-layout: fixed; }
  .conv-table thead th { width: 25%; letter-spacing: 0; font-size: .64rem; overflow: hidden; text-overflow: ellipsis; }
  .conv-table thead th:first-child { width: 30%; }
  .conv-table thead th.conv-rate-col { min-width: 0; width: 20%; text-align: right; }
  .conv-table th, .conv-table td { padding-left: .4rem; padding-right: .4rem; }
  .conv-table td:first-child { overflow-wrap: anywhere; }
  .conv-rate .hbar-track { display: none; }
  .conv-rate { grid-template-columns: auto; justify-items: end; }
}
@media (max-width: 1199.98px) { .conv-detail-col + .conv-detail-col { border-left: 0; border-top: 1px solid var(--app-border); padding-top: .75rem; } }

/* Fornecedores de OPME: resumo + barras pareadas (indicações × escolhas, mesma escala) */
.opme-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.opme-stat { display: flex; gap: .75rem; align-items: center; padding: .75rem .9rem; border: 1px solid var(--app-border); border-radius: 12px; background: var(--app-surface); }
.opme-stat-icon { flex: none; width: 2.4rem; height: 2.4rem; border-radius: 10px; display: grid; place-items: center; font-size: 1.15rem; color: var(--viz-s1); background: var(--viz-track); }
.opme-stat-value { font-size: 1.3rem; font-weight: 700; line-height: 1.2; color: var(--app-text); }
.opme-pair-col { min-width: 200px; width: 34%; }
.opme-win-col { min-width: 170px; }
.opme-pair { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: .5rem; row-gap: 2px; }
.opme-pair .hbar-track { height: 9px; }
.opme-pair .hbar-bar.s2 { background: var(--viz-s2); }
.opme-pair-value { font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 2.5ch; text-align: right; line-height: 1; }
.opme-win { display: flex; align-items: center; gap: .5rem; }
.opme-meter { flex: 1 1 auto; min-width: 48px; max-width: 90px; height: 6px; border-radius: 3px; background: var(--viz-track); overflow: hidden; }
.opme-meter > span { display: block; height: 100%; background: var(--app-text); opacity: .55; border-radius: 3px; }
.opme-leader { color: #d9a420; }
.opme-table tr.is-other td { color: var(--app-muted); }
.opme-table tr.is-other .hbar-bar { background: var(--viz-axis); }
@media (max-width: 767.98px) {
  .vchart-x span:nth-child(even) { visibility: hidden; }  /* rótulos alternados em telas estreitas */
  .hbar-row { grid-template-columns: minmax(80px, 42%) 1fr auto; }
}

/* Calendário */
.cal-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cal-month { font-weight: 700; min-width: 11rem; text-align: center; }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cal-card { overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekday { padding: .5rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--app-muted); background: #f8fafc; border-bottom: 1px solid var(--app-border); text-align: center; }
.cal-day { min-height: 118px; padding: .35rem; border-right: 1px solid var(--app-border); border-bottom: 1px solid var(--app-border); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.is-other { background: #fafbfc; }
.cal-day.is-other .cal-day-num { color: #b3bcc8; }
.cal-day-num { font-size: .8rem; font-weight: 600; color: var(--app-text); align-self: flex-end; width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; }
.cal-day.is-today .cal-day-num { background: var(--app-primary); color: #fff; }
.cal-event { display: block; font-size: .72rem; line-height: 1.25; padding: .15rem .35rem; border-radius: 5px; border: 1px solid; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event:hover { filter: brightness(.96); }
.cal-event.status-preagendado { border-style: dashed; }
.cal-event-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-more { font-size: .72rem; padding-left: .35rem; }
.cal-agenda-day + .cal-agenda-day { border-top: 1px solid var(--app-border); }
.cal-agenda-date { padding: .55rem 1rem; font-weight: 700; font-size: .85rem; background: #f8fafc; }
.cal-agenda-date.is-today { background: #eaf3fb; }
.cal-agenda-time { width: 4.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Agenda de um colega (agendas compartilhadas): eventos sem link para o detalhe. */
span.cal-event { cursor: default; }
span.cal-event:hover { filter: none; }
.cal-agenda-select { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cal-agenda-select .form-select { width: auto; min-width: 14rem; max-width: 100%; }
.cal-shared-table td { vertical-align: middle; }
.cal-shared-table td:nth-child(-n+2) { white-space: nowrap; width: 1%; }

/* Agendas compartilhadas (registry/agenda_shares.py) */
.share-request { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.share-request .flex-grow-1 { min-width: min(100%, 18rem); }
.share-steps { padding-left: 1.2rem; }
.share-steps li + li { margin-top: .2rem; }
.share-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .65rem 0; }
.share-item + .share-item { border-top: 1px solid var(--app-border); }
.share-item:first-child { padding-top: 0; }
.share-item:last-child { padding-bottom: 0; }
.share-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.share-actions form { margin: 0; }

/* ---------------------------------------------- Nova solicitação: documentos e autopreenchimento */
.subsection-title { font-size: .8rem; font-weight: 600; color: var(--app-text); margin: 1.1rem 0 .6rem; display: flex; align-items: center; gap: .4rem; }
.subsection-title .bi { color: var(--app-primary); }
.card-body > .subsection-title:first-of-type { margin-top: .25rem; }
.doc-section { margin-top: 1rem; padding-top: .9rem; border-top: 1px dashed var(--app-border); }
.card-body > .doc-section:first-of-type:not(:first-child) { margin-top: 1rem; }
.doc-slot { border: 1px solid var(--app-border); border-radius: 10px; background: #fbfcfe; padding: .6rem .75rem; height: 100%; }
.doc-slot-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.doc-slot-title { font-weight: 600; font-size: .86rem; }
.doc-add { white-space: nowrap; cursor: pointer; }
.doc-list { list-style: none; margin: .5rem 0 0; padding: 0; }
.doc-row { display: flex; align-items: center; gap: .55rem; padding: .35rem .15rem; border-top: 1px solid var(--app-border); font-size: .85rem; }
.doc-row > .bi { font-size: 1.1rem; color: var(--app-muted); }
.doc-empty { padding: .2rem 0; }
.doc-note { color: #8a5a00; }
.doc-status { display: inline-flex; align-items: center; white-space: nowrap; font-size: .72rem; font-weight: 600; border-radius: 999px; padding: .12rem .5rem; border: 1px solid transparent; }
.doc-status.s-wait { background: #f1f4f8; color: #56637a; border-color: #dfe5ee; }
.doc-status.s-proc { background: #eaf3fb; color: var(--app-primary); border-color: #cfe2f3; }
.doc-status.s-ok { background: #e8f6f1; color: #0b6b58; border-color: #c8ebdf; }
.doc-status.s-review { background: #fff5e0; color: #8a5a00; border-color: #f5dfae; }
.doc-status.s-error { background: #fdecec; color: #a12a2a; border-color: #f5c9c9; }
.doc-status.s-neutral { background: #f1f4f8; color: #56637a; }
.doc-status.s-sent { background: #eef4fb; color: #2b5d8f; border-color: #d3e3f3; }
.autofill-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: .75rem; }
.autofill-bar .btn { white-space: nowrap; }
.autofill-result { margin-top: .75rem; border: 1px solid #d7e6f3; background: #f6fafd; border-radius: 10px; padding: .65rem .8rem; }
.af-run { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .85rem; margin-bottom: .3rem; }
.af-items { list-style: none; margin: .35rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .15rem 1.25rem; }
.af-item { display: flex; gap: .4rem; align-items: baseline; font-size: .83rem; min-width: 0; }
.af-item-label { color: var(--app-muted); white-space: nowrap; }
.af-item-value { font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
.af-item.st-found .bi { color: #0f9d8a; }
.af-item.st-review .bi, .af-item.st-conflict .bi, .af-item.st-unmatched .bi { color: #c98a00; }
.af-item.st-not_found .bi, .af-item.st-not_found .af-item-value { color: var(--app-muted); font-weight: 400; }
.af-note { font-size: .76rem; margin-top: .25rem; display: flex; gap: .3rem; align-items: baseline; }
.af-note.ok { color: #0b6b58; }
.af-note.review { color: #8a5a00; }
.af-note.muted { color: var(--app-muted); }
.af-sub { font-size: .74rem; color: var(--app-muted); margin-top: .1rem; }
.af-diverge { margin-top: .35rem; font-size: .8rem; border: 1px solid #f0d9a4; background: #fffaf0; border-radius: 8px; padding: .45rem .6rem; }
.af-diverge ul { padding-left: 1.1rem; }
.field-wrap.af-filled .form-control, .field-wrap.af-filled .form-select, .field-wrap.af-filled .ts-control { border-color: #7fcdb9; background-color: #f5fcf9; }
.field-wrap.af-review .form-control, .field-wrap.af-review .form-select, .field-wrap.af-review .ts-control { border-color: #e9c46a; background-color: #fffcf2; }
.doc-tags { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: .15rem 0; }
.doc-type-tag { font-size: .7rem; font-weight: 600; line-height: 1.5; color: var(--app-primary); background: var(--app-primary-50); border-radius: 999px; padding: .05rem .5rem; }
.doc-status .bi { margin-right: .2rem; }
.allergy-flag { display: inline-block; font-size: .82rem; color: #a12a2a; background: #fdecec; border: 1px solid #f5c9c9; border-radius: 8px; padding: .15rem .55rem; }
@media (max-width: 575.98px) {
  .doc-slot-head { flex-direction: column; }
  .af-items { grid-template-columns: 1fr; }
}

/* Aplicativo (PWA): instruções de instalação */
.app-steps { padding-left: 1.2rem; margin: .5rem 0 0; }
.app-steps li { margin-bottom: .45rem; }
/* No app instalado, respeita a área do entalhe/barra do iPhone */
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); height: calc(58px + env(safe-area-inset-top)); } }

/* Faturamento */
.billing-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.billing-cards .status-card { display: flex; flex-direction: column; gap: .35rem; text-decoration: none; color: inherit; }
.billing-cards .status-card.active { border-color: var(--app-primary); box-shadow: 0 0 0 2px rgba(15,92,140,.15); }
/* Rótulos longos ("Pré-faturamento em andamento") quebram linha dentro da caixinha em vez de vazar */
.billing-cards .status-card { min-width: 0; }
.billing-cards .badge { white-space: normal; text-align: left; line-height: 1.3; max-width: 100%; overflow-wrap: anywhere; }
.billing-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; flex-shrink: 0; }
.billing-docs .repo-doc.is-selected { background: #f1f8ff; }
.doc-slot.is-missing { border-color: #f1c4c4; background: #fffafa; }
.fee-list { list-style: none; margin: 0; padding: 0; }
.fee-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--app-border); }
.fee-list > .fee-row:first-child { border-top: 0; }
.fee-input { width: 190px; flex-shrink: 0; }
/* Regra de faturamento (billing/payment_rules.py, _payment_rule.html), 16/11/2026 */
.rule-card { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid var(--app-border); border-left: 4px solid var(--app-primary); border-radius: 10px; padding: .75rem .9rem; background: var(--app-primary-50); }
.rule-card-icon { font-size: 1.3rem; color: var(--app-primary); line-height: 1; padding-top: .1rem; }
.rule-card-title { margin-bottom: .2rem; }
.rule-steps { padding-left: 1.2rem; margin-top: .35rem; }
/* Solicitação: caixa "Dor" ao lado da articulação, alinhada com o campo (e não com o rótulo) */
.pain-check .form-check { margin-top: 2.05rem; }
.pain-badge { background: #6f42c1; color: #fff; font-weight: 600; }
/* "Autorizado sem guia": autorização vigente sem o documento de autorização (documents.missing_authorization_guide) */
.guide-badge { background: #fff3cd; color: #664d03; border: 1px solid #ffda6a; font-weight: 600; }
.badge.guide-badge { font-size: .8rem; padding: .4em .6em; }
.guide-missing { padding: .4rem .65rem; border-radius: 8px; background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; }
.guide-missing .bi { color: #997404; }
/* Recebimento da cirurgia FATURADA (billing.status.Receipt): "Recebido" verde, "A receber" laranja */
.receipt-badge { font-weight: 600; color: #fff; }
.receipt-badge.received { background: #198754; }
.badge.receipt-badge.lg { font-size: .85rem; padding: .45em .7em; }
.receipt-note { padding: .4rem .65rem; border-radius: 8px; border: 1px solid; }
.receipt-note.received { background: #d1e7dd; color: #0f5132; border-color: #a3cfbb; }
.receipt-note.received .bi { color: #198754; }
/* O cliente definiu a Regra geral para a articulação (Coluna, Quadril, Mão): destaque no cartão do pré-faturamento */
.rule-confirmed { margin-bottom: .35rem; padding: .35rem .6rem; border-radius: 8px; background: rgba(25, 135, 84, .1); color: #0f5132; }
.rule-confirmed .bi { color: #198754; }
.rule-badge { background: var(--app-primary); color: #fff; font-weight: 600; }
/* Combo da regra no faturamento (_payment_rule_choice.html) */
.rule-select { max-width: 26rem; font-weight: 600; }
.rule-info { border-top: 1px dashed var(--app-border); padding-top: .5rem; }
/* Pré-faturamento no Consultório: tabela profissionais (linhas) × códigos TUSS realizados (colunas), 16/11/2026 (_fee_matrix.html) */
.fee-matrix-wrap { border: 1px solid var(--app-border); border-radius: 10px; }
.fee-matrix { font-size: .9rem; }
.fee-matrix th, .fee-matrix td { padding: .5rem .6rem; border-color: var(--app-border); vertical-align: middle; }
.fee-matrix thead th { background: #f8fafc; font-weight: 600; vertical-align: bottom; }
.fee-matrix .fee-matrix-who { position: sticky; left: 0; z-index: 1; background: var(--app-surface); min-width: 11rem; max-width: 15rem; font-weight: normal; box-shadow: inset -1px 0 0 var(--app-border); }
.fee-matrix thead .fee-matrix-who, .fee-matrix tfoot .fee-matrix-who { background: #f8fafc; font-weight: 600; }
.fee-matrix-proc { min-width: 8.5rem; text-align: right; }
.fee-matrix-proc.is-principal { background: var(--app-primary-50) !important; }
.fee-matrix-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: normal; max-width: 12rem; margin-left: auto; text-align: right; }
.fee-matrix-cell { text-align: right; }
.fee-matrix-cell .form-control { min-width: 7rem; }
.fee-matrix-total { text-align: right; white-space: nowrap; background: #f8fafc; min-width: 7.5rem; }
.fee-matrix tfoot td, .fee-matrix tfoot th { background: #f8fafc; border-top: 2px solid var(--app-border); border-bottom: 0; }
.fee-matrix tbody tr:last-child > * { border-bottom: 0; }
/* Glosa por profissional (faturamento, consultório particular) */
.glosa-box { border: 1px solid var(--app-border); border-radius: 10px; padding: .9rem; }
.glosa-list { list-style: none; margin: 0; padding: 0; }
.glosa-row { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: .75rem; align-items: end; padding: .7rem 0; border-top: 1px solid var(--app-border); }
.glosa-row[hidden] { display: none; }
.glosa-list > .glosa-row:first-child { border-top: 0; padding-top: 0; }
.glosa-who { align-self: center; }
/* Valores faturados (Consultório, 23/11/2026): célula abaixo do pré-faturamento destacada; pré-faturado embaixo. */
.billed-matrix .billed-pre { font-size: .72rem; margin-top: .15rem; }
.billed-matrix .is-lower { background: #fff4e5; }
.billed-matrix .is-lower .form-control, .billed-matrix .is-lower > .text-nowrap { color: #9a3412; font-weight: 600; }
/* Recurso de glosa: situação de cada glosa recorrida. */
.appeal-badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 600; border-radius: 999px; padding: .15rem .6rem; border: 1px solid transparent; }
.appeal-badge.is-open { background: #fdecec; color: #a12a2a; border-color: #f5c2c2; }
.appeal-badge.is-paid { background: #d1e7dd; color: #0f5132; border-color: #a3cfbb; }
.appeal-badge.is-kept { background: #eef0f3; color: #495057; border-color: #d9dde3; }
/* Histórico dos recursos de uma glosa (vários recursos, 26/11/2026; billing/appeal.html) */
.appeal-rounds { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .4rem; }
.appeal-round { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .45rem .7rem; background: var(--bs-tertiary-bg, #f8f9fa); }
.appeal-round.is-open { border-color: #f5c2c2; background: #fff8f8; }
.appeal-round-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
@media (max-width: 767.98px) {
  .glosa-row { grid-template-columns: 1fr; gap: .5rem; }
}
.fee-total { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: .5rem; padding: .7rem .9rem; border-radius: 10px; background: #f4f7fb; font-size: 1.05rem; }
@media (max-width: 575.98px) {
  .fee-row { flex-wrap: wrap; }
  .fee-input { width: 100%; }
  .billing-row-side { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
}
.billing-row-side form { margin: 0; }
.kv .kv-wide { grid-column: 1 / -1; }
.context-location { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--app-border); }
.context-location .form-select { max-width: 22rem; }

/* Trilha financeira (Realizada → Pré-faturamento → Faturamento → Recebimento): mesmo visual do detalhe */
.billing-steps .flow-steps { margin-top: 0; padding: .85rem 1.1rem; }
a.flow-step { text-decoration: none; }
a.flow-step:hover { color: var(--app-primary); }
a.flow-step:hover .dot { border-color: var(--app-primary); }
a.flow-step.done:hover .dot { border-color: #0f9d8a; }
@media (max-width: 575.98px) {  /* celular: só o nome da etapa atual; os demais ficam para leitores de tela */
  .billing-steps .flow-steps { padding: .7rem .9rem; }
  .billing-steps .flow-step:not(.is-focus) .flow-step-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
}

/* "Próximo passo": painel no topo dos resumos */
.next-step { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; background: var(--app-surface); border: 1px solid var(--app-border); border-left: 4px solid var(--app-primary); border-radius: 12px; padding: .9rem 1.1rem; }
.next-step.is-done { border-left-color: #0f9d8a; }
.next-step-icon { font-size: 1.6rem; line-height: 1; color: var(--app-primary); }
.next-step-icon + div { flex: 1 1 14rem; }  /* texto ao lado do ícone; os botões descem quando falta espaço */
.next-step.is-done .next-step-icon { color: #0f9d8a; }
.next-step-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-left: auto; }
@media (max-width: 575.98px) {
  .next-step-actions { margin-left: 0; width: 100%; }
  .next-step-actions .btn { flex: 1 1 auto; }
}

/* Valores líquidos de uma cirurgia (billing/_net_values.html): grade no computador, pares rótulo/valor no celular */
.net-list { --net-cols: 4; }
.net-list.has-glosa { --net-cols: 6; }
.net-list.is-final { --net-cols: 2; } /* Hospitais: só o valor final */
/* Assinaturas digitais descontadas (25/11/2026): + colunas "Assinaturas" e "A pagar" */
.net-list.has-signatures { --net-cols: 6; }
.net-list.has-glosa.has-signatures { --net-cols: 8; }
.net-list.is-final.has-signatures { --net-cols: 3; }
.net-signatures { color: #b02a37; }
/* Recurso de glosa separado do faturamento (25/11/2026; billing/_appeal_net.html) */
.net-list.is-appeal { --net-cols: 6; }
.net-list.is-appeal.has-rule-share { --net-cols: 7; }
.appeal-net-card { border-left: 4px solid #d98a00; }
.appeal-sum { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .9rem; padding: .75rem .9rem; border-radius: 10px; background: #eef7f3; }
.appeal-sum .appeal-sum-item { display: flex; flex-direction: column; }
.appeal-sum .appeal-sum-label { font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--app-muted); }
.appeal-sum .appeal-sum-value { font-weight: 700; }
.appeal-sum .appeal-sum-op { font-size: 1.1rem; color: var(--app-muted); }
.net-pending { color: #9a6200; }
.sig-charges .sig-origin { font-size: .72rem; }
.net-row { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(calc(var(--net-cols) - 1), minmax(0, 1fr)); gap: .75rem; align-items: center; padding: .65rem 0; border-top: 1px solid var(--app-border); }
.net-row > .net-cell { text-align: right; white-space: nowrap; }
.net-head { border-top: 0; padding-top: 0; font-size: .72rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--app-muted); }
.net-head > span:not(:first-child) { text-align: right; }
.net-label { display: none; }
.net-value { font-weight: 700; color: #0b6b58; }
.net-total { margin: .25rem -.9rem 0; padding: .7rem .9rem; border-top: 0; border-radius: 10px; background: #f4f7fb; font-weight: 650; }  /* margem negativa: colunas alinhadas às linhas */
@media (max-width: 767.98px) {
  .net-head { display: none; }
  .net-row { grid-template-columns: 1fr 1fr; gap: .35rem .75rem; }
  .net-row > .net-who { grid-column: 1 / -1; }
  .net-row > .net-cell { text-align: left; white-space: normal; }
  .net-label { display: block; font-size: .7rem; font-weight: 600; color: var(--app-muted); text-transform: uppercase; letter-spacing: .04em; }
}

/* Documentos do faturamento: recolhidos por padrão */
.docs-card > summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; cursor: pointer; list-style: none; }
.docs-card > summary::-webkit-details-marker { display: none; }
.docs-card-chevron, .net-group-chevron { color: var(--app-muted); transition: transform .15s; }
.docs-card[open] .docs-card-chevron, .net-group[open] .net-group-chevron { transform: rotate(180deg); }

/* Pré-faturamento: quadro "Para concluir" */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .35rem 1rem; }
.check-item { display: flex; align-items: baseline; gap: .45rem; color: #8a5a00; }
.check-item > .bi::before { content: "\F28A"; }  /* bi-circle */
.check-item.is-ok { color: #0b6b58; }
.check-item.is-ok > .bi::before { content: "\F26A"; }  /* bi-check-circle-fill */

/* Tela "Valores líquidos" (filtros se acomodam em linhas conforme a largura) */
.net-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.net-filters > div { flex: 1 1 9.5rem; min-width: 0; }
.net-filters > .net-filter-prof { flex: 2 1 12rem; }
.net-filters > .net-filter-actions { flex: 0 0 auto; display: flex; gap: .25rem; }
.net-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
@media (min-width: 992px) { .net-tiles { grid-template-columns: repeat(3, 1fr); } } /* 6 blocos: 3 + 3 */
@media (min-width: 1400px) { .net-tiles.net-tiles-5 { grid-template-columns: repeat(5, 1fr); } } /* Ambulatório: 5 blocos (3 + 2 abaixo disso) */
@media (max-width: 575.98px) {
  .net-tiles { grid-template-columns: 1fr 1fr; }
  .net-tile { padding: .7rem .8rem; }
  .net-tile strong { font-size: 1.05rem; }
}
.net-tile { display: flex; flex-direction: column; gap: .15rem; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; padding: .8rem 1rem; min-width: 0; }
.net-tile strong { font-size: 1.3rem; line-height: 1.2; overflow-wrap: anywhere; }
.net-tile-label { font-size: .78rem; color: var(--app-muted); font-weight: 600; }
.net-tile.is-net { border-color: #9fd8c8; background: #f2fbf8; }
.net-tile.is-net strong { color: #0b6b58; }
.net-group + .net-group { border-top: 1px solid var(--app-border); }
.net-group-head { display: flex; align-items: center; gap: .75rem 1rem; padding: .85rem 1.1rem; cursor: pointer; list-style: none; }
.net-group-head::-webkit-details-marker { display: none; }
.net-group-head:hover { background: #f8fafc; }
.net-amounts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .25rem 1.25rem; }
.net-pair { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; min-width: 7.5rem; }  /* colunas alinhadas entre as linhas */
.net-pair-label { font-size: .7rem; font-weight: 600; color: var(--app-muted); text-transform: uppercase; letter-spacing: .04em; }
.net-lines { list-style: none; margin: 0; padding: 0 1.1rem .5rem 2rem; }
.net-line { display: flex; align-items: center; gap: .5rem 1rem; padding: .6rem 0; border-top: 1px dashed var(--app-border); }
/* Articulação da cirurgia, ao lado do paciente (etiqueta discreta). */
.net-articulation { display: inline-block; margin-left: .35rem; padding: .05rem .5rem; border: 1px solid var(--app-border); border-radius: 999px; font-size: .75rem; font-weight: 600; color: var(--app-muted); white-space: nowrap; vertical-align: .1em; }
@media (max-width: 767.98px) {
  .net-group-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .net-group-head > .net-amounts { grid-column: 1 / -1; grid-row: 2; }
  .net-line { flex-wrap: wrap; }
  .net-line > .net-amounts { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .net-amounts { justify-content: flex-start; }
  .net-pair { align-items: flex-start; min-width: 0; }
  .net-lines { padding-left: 1.1rem; }
}

/* Repositório de documentos (pastas em grade; documentos em lista, sem tabela, para ler bem no celular) */
.repo-filters { display: flex; gap: .5rem; flex-wrap: wrap; }
/* Organizar pastas por (12/11/2026) */
.repo-order { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.repo-order .form-select { width: auto; min-width: 0; max-width: 100%; text-transform: none; }
.repo-folder-dates { font-size: .75rem; }
.repo-folder-dates > span { white-space: nowrap; margin-right: .5rem; }
.repo-filters .form-control { flex: 1 1 240px; }
.repo-filters .form-select { flex: 0 1 220px; }
.repo-folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.repo-folders > .card { grid-column: 1 / -1; }
.repo-folder { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; min-height: 64px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: 12px; text-decoration: none; color: inherit; }
.repo-folder:hover, .repo-folder:focus-visible { border-color: var(--app-primary); box-shadow: 0 2px 8px rgba(16,24,40,.08); }
.repo-folder > .bi, .repo-folder-icon { font-size: 1.6rem; color: #d9a420; }
.repo-folder-name { display: block; font-weight: 600; word-break: break-word; }
/* Selo "Hoje": pasta criada no dia (12/11/2026) */
.repo-today-badge { display: inline-flex; align-items: center; gap: .2rem; margin-left: .4rem; padding: .1rem .5rem; border-radius: 999px; background: #e7f6ec; color: #17733a; border: 1px solid #b9e3c6; font-size: .7rem; font-weight: 700; line-height: 1.4; vertical-align: middle; white-space: nowrap; }
h1 .repo-today-badge { font-size: .8rem; }
/* Observações da pasta (recado para quem vai usá-la): cartão da pasta, seletor e página da pasta */
.repo-folder-notes { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .25rem; font-size: .78rem; font-weight: 600; color: #9a5b00; overflow-wrap: anywhere; white-space: normal; }
.repo-folder-alert { overflow-wrap: anywhere; }
/* Lixeira do repositório (18/11/2026) */
.repo-trash { display: grid; gap: .75rem; }
.repo-trash-head { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.repo-trash-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.repo-trash-docs ul { padding-left: 1.2rem; overflow-wrap: anywhere; }
.repo-trash-docs summary { cursor: pointer; color: var(--app-primary); }
/* Seletor do repositório: quem criou a pasta (lista de pastas e cabeçalho da pasta aberta) */
.repo-picker-owner { display: block; margin-top: .1rem; font-size: .78rem; font-weight: 400; color: var(--app-muted); overflow-wrap: anywhere; }
.repo-docs { list-style: none; margin: 0; padding: 0; }
.repo-doc { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem 1rem; border-top: 1px solid var(--app-border); }
.repo-docs > .repo-doc:first-child { border-top: 0; }
.repo-doc.is-disabled { opacity: .6; }
.repo-doc-icon { font-size: 1.35rem; color: var(--app-muted); line-height: 1.2; }
.repo-doc-name { font-weight: 600; word-break: break-word; }
.repo-doc-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .8rem; color: var(--app-muted); margin-top: .15rem; }
.repo-doc-meta a { color: inherit; }
.repo-doc-notes { font-size: .8rem; color: var(--app-text); margin-top: .2rem; overflow-wrap: anywhere; }
.repo-type { color: var(--app-text); font-weight: 600; }
.repo-usage.never { color: #1d7a46; }
.repo-usage.used { color: #9a5b00; font-weight: 600; }
.repo-doc-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.repo-doc-actions form { display: inline; }
.repo-pick { width: 1.35rem; height: 1.35rem; margin-top: .1rem; flex-shrink: 0; }
.repo-picker-docs label { cursor: pointer; }
@media (max-width: 575.98px) {
  .repo-doc { flex-wrap: wrap; }
  .repo-doc > .min-w-0 { flex: 1 1 0; }  /* ícone/caixa continuam ao lado do nome; só as ações descem */
  .repo-picker-docs .repo-doc { flex-wrap: nowrap; }
  .repo-doc-actions { width: 100%; justify-content: flex-end; }
  .repo-doc-actions .btn { min-width: 44px; min-height: 40px; }
  .repo-filters .form-select { flex: 1 1 100%; }
}

/* ---------------------------------------------------------------- Materiais OPME (initOpmeMaterials) */
.opme-materials { min-width: 520px; }
.opme-materials th { font-size: .8rem; font-weight: 600; color: var(--bs-secondary-color); border-bottom-width: 1px; }
.opme-materials .col-qty { width: 80px; }
.opme-materials .col-anvisa { width: 190px; }
.opme-materials .col-del { width: 40px; }
.opme-materials td { padding-left: .25rem; padding-right: .25rem; }
.opme-authorized { min-width: 760px; }
.opme-authorized .col-qty { width: 95px; }
.opme-authorized .col-anvisa { width: 150px; }
.opme-authorized .col-glosa { width: 220px; }
.opme-materials input[readonly] { background: var(--bs-tertiary-bg); }

/* ---------------------------------------------------------------- Receituário Padrão (initPrescription) */
.rx-search { position: relative; max-width: 640px; }
.rx-results { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: .25rem 0 0; padding: .25rem 0;
  background: var(--bs-body-bg); border: 1px solid var(--app-border); border-radius: .5rem; box-shadow: 0 .5rem 1rem rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto; }
.rx-result { display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: .45rem .75rem; border: 0;
  background: none; text-align: left; }
.rx-result:hover, .rx-result:focus { background: var(--bs-tertiary-bg); }
.rx-result-empty { padding: .45rem .75rem; }
.rx-item { display: flex; gap: .5rem; align-items: flex-start; padding: .6rem 0; border-top: 1px solid var(--app-border); }
.rx-items > .rx-item:first-child { border-top: 0; }
.rx-item-num { width: 1.6rem; flex-shrink: 0; padding-top: .45rem; font-weight: 700; color: var(--app-primary); text-align: right; }
.rx-item-fields { flex: 1 1 auto; min-width: 0; }
.rx-item-actions { display: flex; flex-direction: column; flex-shrink: 0; }
.rx-template-name { max-width: 360px; }
.rx-templates .form-select { min-width: 240px; }
.rx-route { font-weight: 700; color: var(--app-primary); margin-top: .5rem; font-size: .9rem; }
.rx-list { padding-left: 1.5rem; margin-bottom: .5rem; }
.rx-list li { padding: .35rem 0; border-bottom: 1px solid var(--app-border); }
@media (max-width: 575.98px) {
  .rx-item-actions { flex-direction: row; }
  .rx-item { flex-wrap: wrap; }
  .rx-item-actions { width: 100%; justify-content: flex-end; }
}

/* ---------------------------------------------------------------- Dados em MAIÚSCULA
   Pedido do cliente (07/10/2026): os DADOS aparecem em maiúscula; rótulos, menus,
   botões e mensagens continuam como estão. Só na exibição: o banco guarda o que foi
   digitado. E-mails ficam em minúscula (`.u-email`). Exceções (ficam como digitado): senhas, nomes de arquivos e
   textos longos (textareas: relatório médico, OPME, observações, motivos).
   - campos: inputs de texto, selects e Tom Select (não pegam e-mail, senha, busca e textarea);
   - blocos de dados: células de tabela, valores das fichas (.kv dd), equipes e `.u-data`;
   - `.keep-case` marca exceções e textos de interface dentro desses blocos. */
input.form-control:not([type=email]):not([type=password]):not([type=search]):not([type=file]):not(.keep-case),
select.form-select:not(.keep-case), .ts-wrapper:not(.keep-case) .ts-control, .ts-wrapper:not(.keep-case) .ts-dropdown .option,
.table-app td, .kv dd, .team-list li, .proc-editor .proc-desc { text-transform: uppercase; }
.form-control::placeholder, .ts-control input::placeholder { text-transform: none; }
.keep-case, .keep-case td, .keep-case dd, .keep-case li, .badge, .btn, .expiry-badge, .empty-state, .muted, .dropdown-menu, .form-check-label, .ts-dropdown .no-results,
.pager .form-select, .repo-filters .form-select { text-transform: none; }
.u-data { text-transform: uppercase; }  /* depois das exceções: marca um dado explicitamente */
/* E-mails sempre em minúscula (pedido do cliente, 09/10/2026), nos campos e na exibição. */
input.form-control[type=email], .u-email, .table-app td.u-email, .kv dd.u-email { text-transform: lowercase; }

/* Aviso da assinatura digital: termo de autorização com rolagem (signatures/prompt.html, 23/11/2026). */
.term-text { max-height: 50vh; overflow-y: auto; border: 1px solid var(--bs-border-color); border-radius: .5rem;
  padding: 1rem 1.25rem; background: #fbfbfd; font-size: .92rem; }
.term-text h3 { font-size: .95rem; font-weight: 600; margin: .9rem 0 .35rem; }
.term-text h3:first-child { margin-top: 0; }
.term-text p { margin-bottom: .45rem; }

@media print {
  .sidebar, .topbar, .btn, .nav-tabs-app, form { display: none !important; }
  .tab-pane { display: block !important; opacity: 1 !important; }
  .content { padding: 0; }
}
