:root {
  --navy: #153f5c;
  --navy-dark: #0d2b40;
  --blue: #2b76a8;
  --green: #2b7559;
  --orange: #9b5e22;
  --red: #a44040;
  --bg: #edf2f5;
  --card: #ffffff;
  --border: #d3dde4;
  --text: #22313b;
  --muted: #647681;
  --shadow: 0 10px 28px rgba(18, 58, 86, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 255px 1fr; }
.sidebar { background: var(--navy-dark); color: #fff; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 4px 20px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.55); display: grid; place-items: center; font-weight: 800; }
.brand small { display: block; color: #b8cfdd; margin-top: 3px; }
.role-card { margin: 14px 0; padding: 12px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); border-radius: 8px; }
.role-card span, .role-card small { display: block; color: #b8cfdd; font-size: 12px; }
.role-card strong { display: block; margin: 5px 0; }
.nav { display: grid; gap: 5px; }
.nav button { width: 100%; text-align: left; padding: 11px 12px; border: 0; color: #dfeaf0; background: transparent; border-radius: 7px; }
.nav button:hover, .nav button.active { background: #24536f; color: #fff; }
.content { min-width: 0; }
.topbar { height: 70px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 19px; color: var(--navy); }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
main { padding: 24px; max-width: 1500px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; }
.page-head { display: flex; justify-content: space-between; gap: 15px; align-items: flex-end; margin-bottom: 17px; }
.page-head h2 { margin: 0; color: var(--navy); font-size: 24px; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.grid { display: grid; gap: 15px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); }
.card-head { padding: 15px 17px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h3 { margin: 0; color: var(--navy); font-size: 15px; }
.card-body { padding: 17px; }
.metric { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 8px; padding: 17px; }
.metric span { color: var(--muted); font-size: 12px; display: block; }
.metric strong { display: block; margin-top: 8px; font-size: 28px; color: var(--navy); }
.field label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; color: #41535f; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #bdcad2; border-radius: 6px; padding: 10px 11px; background: #fff; color: var(--text); }
.field textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43,118,168,.12); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--border); background: #fff; color: var(--navy); padding: 9px 13px; border-radius: 6px; font-weight: 700; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.secondary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f2f6f8; color: #566772; font-size: 11px; text-transform: uppercase; letter-spacing: .45px; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; border-radius: 20px; padding: 5px 9px; font-size: 11px; font-weight: 700; background: #eef2f4; color: #52636e; }
.status.ok { background: #e8f5ee; color: #2a7056; }
.status.warn { background: #fff1e2; color: #8c561b; }
.status.info { background: #e7f2f8; color: #2a668d; }
.status.danger { background: #fae9e9; color: #9a3b3b; }
.notice { padding: 13px 14px; border-left: 4px solid var(--blue); background: #eaf4f9; color: #2c526a; border-radius: 5px; line-height: 1.5; }
.notice.success { border-left-color: var(--green); background: #edf8f3; color: #2a634d; }
.notice.warning { border-left-color: var(--orange); background: #fff5e8; color: #754a1e; }
.list-card { border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: 14px; margin-bottom: 10px; }
.list-card h4 { margin: 0; color: var(--navy); }
.list-card p { margin: 7px 0 0; line-height: 1.45; }
.list-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.empty { text-align: center; color: var(--muted); border: 1px dashed #bcc9d1; background: #fafcfd; border-radius: 7px; padding: 28px; }
.tele-layout { display: grid; grid-template-columns: minmax(360px, .75fr) minmax(520px, 1.25fr); gap: 16px; align-items: start; }
.video-box { min-height: 350px; background: #182832; border-radius: 9px; color: #dce8ee; display: grid; place-items: center; text-align: center; position: sticky; top: 88px; }
.video-box strong { display: block; font-size: 18px; }
.video-box span { display: block; margin-top: 8px; color: #a9bec9; }
.section { border: 1px solid var(--border); background: #f8fafb; padding: 15px; border-radius: 8px; }
.section h4 { margin: 0 0 5px; color: var(--navy); }
.section > p { margin: 0 0 13px; color: var(--muted); font-size: 12px; }
.referral-card { border: 1px solid #b9cad4; background: #fff; border-radius: 8px; padding: 14px; margin-top: 12px; }
.referral-card.saved { border-color: #8ebba7; background: #f5fbf8; }
.protocol { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; color: var(--navy); }
.modal { position: fixed; inset: 0; background: rgba(9, 25, 36, .62); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal-card { width: min(900px, 96vw); max-height: 90vh; overflow: auto; background: #fff; border-radius: 10px; box-shadow: 0 22px 60px rgba(0,0,0,.25); }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #173d57; color: #fff; padding: 12px 15px; border-radius: 7px; box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 200; }
.small { color: var(--muted); font-size: 12px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
@media (max-width: 1050px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tele-layout { grid-template-columns: 1fr; }
  .video-box { position: static; }
  .grid.four, .grid.three { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 680px) {
  main { padding: 16px; }
  .topbar { padding: 0 16px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .nav { grid-template-columns: 1fr; }
}

/* Navegação retrátil */
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sidebar-toggle { border: 1px solid var(--border); background: #fff; color: var(--navy); border-radius: 6px; width: 38px; height: 38px; font-size: 19px; line-height: 1; }
.nav button { display: flex; align-items: center; gap: 10px; }
.nav-icon { display: inline-grid; place-items: center; width: 20px; min-width: 20px; font-weight: 800; }
.nav-label { white-space: nowrap; }
@media (min-width: 1051px) {
  body.sidebar-collapsed .shell { grid-template-columns: 76px 1fr; }
  body.sidebar-collapsed .sidebar { padding-inline: 10px; }
  body.sidebar-collapsed .brand { justify-content: center; }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .role-card,
  body.sidebar-collapsed .nav-label { display: none; }
  body.sidebar-collapsed .nav button { justify-content: center; padding-inline: 8px; }
}

/* Teleatendimento por vídeo */
.video-page-layout { display: grid; grid-template-columns: minmax(300px, .65fr) minmax(560px, 1.35fr); gap: 16px; align-items: start; }
.tele-layout > div { min-width: 0; }
.video-panel { background: #fff; border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); overflow: hidden; position: static; top: auto; }
.video-panel-head { min-height: 68px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); background: #f8fafb; }
.video-details { display: grid; gap: 4px; min-width: 0; }
.video-details strong { color: var(--navy); font-size: 14px; }
.video-details span { color: var(--muted); font-size: 12px; line-height: 1.35; }
.video-status { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.video-status.info { background: #e7f2f8; color: #2a668d; }
.video-status.warn { background: #fff1e2; color: #8c561b; }
.video-status.ok { background: #e8f5ee; color: #2a7056; }
.video-status.danger { background: #fae9e9; color: #9a3b3b; }
.daily-video-container { width: 100%; height: min(62vh, 560px); min-height: 390px; background: #10212c; position: relative; }
.daily-video-container iframe { display: block; width: 100% !important; height: 100% !important; }
.video-placeholder, .mock-video { height: 100%; min-height: 390px; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: #dce8ee; text-align: center; }
.video-placeholder span, .mock-video span, .mock-video small { color: #a9bec9; max-width: 460px; line-height: 1.5; }
.camera-icon { width: 58px; height: 58px; border: 1px solid #66818f; border-radius: 50%; display: grid; place-items: center; font-size: 28px; margin-bottom: 4px; }
.mock-avatar { width: 86px; height: 86px; border-radius: 50%; background: #2b76a8; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: #fff; }
.video-controls { padding: 13px 15px; display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; border-top: 1px solid var(--border); }
.consent-box { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; color: #41535f; }
.consent-box input { margin-top: 3px; width: 17px; height: 17px; }
@media (max-width: 1150px) {
  .video-page-layout { grid-template-columns: 1fr; }
  .video-panel { position: static; }
}
@media (max-width: 680px) {
  .daily-video-container, .video-placeholder, .mock-video { min-height: 330px; height: 52vh; }
  .video-panel-head { align-items: flex-start; flex-direction: column; }
}

/* Histórico automático de prescrições — v3.2 */
.prescription-summary {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #c9dbe6;
  border-radius: 10px;
  background: #f4f9fc;
}
.prescription-summary > strong { display: block; margin-bottom: 8px; color: #0d4665; }
.prescription-item {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-top: 1px solid #dbe7ee;
}
.prescription-item:first-of-type { border-top: 0; }
.prescription-item span,
.prescription-item strong { color: #123b53; font-weight: 700; }
.prescription-item small { display: block; color: #536b78; }
.prescription-item p { margin: 3px 0 0; white-space: pre-line; }
.prescription-item a { width: fit-content; font-weight: 700; }


/* Leitor e transcrição automática de PDFs — v3.3 */
.document-reader-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(300px, .95fr);
  gap: 14px;
  margin-top: 14px;
  align-items: stretch;
}
.document-frame-wrap {
  min-height: 470px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #eef3f6;
}
.document-frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 470px;
  border: 0;
  background: #fff;
}
.document-analysis {
  min-height: 470px;
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}
.analysis-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.analysis-head strong { display: block; color: var(--navy); }
.analysis-head small { display: block; color: var(--muted); margin-top: 4px; }
.analysis-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.analysis-meta div { border: 1px solid var(--border); border-radius: 7px; padding: 9px; background: #fff; min-width: 0; }
.analysis-meta dt { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 800; }
.analysis-meta dd { margin: 4px 0 0; color: var(--text); overflow-wrap: anywhere; }
.extracted-text { margin-top: 12px; }
.extracted-text summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.extracted-text pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #fff; border: 1px solid var(--border); border-radius: 7px; padding: 11px; max-height: 320px; overflow: auto; }
.empty.compact { padding: 18px; }
@media (max-width: 920px) {
  .document-reader-grid { grid-template-columns: 1fr; }
  .document-frame-wrap, .document-frame-wrap iframe, .document-analysis { min-height: 380px; }
  .document-analysis { max-height: none; }
}


/* Correção de empilhamento da coluna de teleconsulta — v3.3.1
   O vídeo permanece no fluxo normal e não encobre documentos, botões ou encaminhamentos durante a rolagem. */
.tele-left-column {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: start;
  position: relative;
  isolation: isolate;
}
.tele-left-column > .video-panel,
.tele-left-column > .card {
  width: 100%;
  margin: 0 !important;
  position: relative !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
}
.tele-left-column > .video-panel {
  z-index: 1;
  align-self: stretch;
  height: auto !important;
  max-height: none !important;
}
.tele-left-column > .card {
  z-index: 0;
  clear: both;
}
.video-controls {
  position: relative;
  z-index: 2;
  background: #fff;
}
.daily-video-container {
  z-index: 0;
  overflow: hidden;
}
.daily-video-container iframe {
  position: absolute !important;
  inset: 0 !important;
}
@media (max-width: 1050px) {
  .tele-left-column { gap: 14px; }
}


/* Prontuário longitudinal do paciente — v3.3.2 */
.patient-record-search-card { margin-bottom: 18px; }
.patient-record-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.patient-search-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.patient-search-result {
  appearance: none;
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 13px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.patient-search-result:hover,
.patient-search-result.selected {
  border-color: #1f6f99;
  box-shadow: 0 6px 20px rgba(13, 53, 76, .10);
  transform: translateY(-1px);
}
.patient-result-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.patient-result-main strong { color: var(--navy); }
.patient-result-main small,
.patient-result-meta { color: var(--muted); font-size: .82rem; }
.patient-result-meta { text-align: right; }
.empty.compact { padding: 12px; }

.patient-record-header {
  border-radius: 12px;
  background: linear-gradient(135deg, #0d354c, #175b7d);
  color: #fff;
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  box-shadow: 0 10px 28px rgba(13, 53, 76, .18);
}
.patient-record-header h3 { margin: 4px 0 8px; font-size: 1.55rem; color: #fff; }
.patient-record-header p { margin: 4px 0; color: rgba(255,255,255,.88); }
.patient-record-header .eyebrow {
  display: block;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .72rem;
  color: rgba(255,255,255,.7);
}
.patient-identifiers { font-size: .88rem; }
.patient-record-contact {
  min-width: 190px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  border-radius: 9px;
}
.patient-record-contact span { display: block; font-size: .75rem; color: rgba(255,255,255,.7); margin-bottom: 4px; }

.record-summary-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.record-summary-cards > div {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.record-summary-cards strong { font-size: 1.45rem; color: var(--navy); }
.record-summary-cards span { color: var(--muted); font-size: .82rem; }

.record-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin: 20px 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.record-filter-buttons { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.record-filter-buttons .btn { padding: 8px 11px; font-size: .82rem; }
.record-filter-buttons .btn.active { box-shadow: 0 0 0 2px rgba(31,111,153,.18); }

.record-timeline { position: relative; padding-left: 42px; }
.record-timeline::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: #ccd9e1;
}
.record-timeline-item { position: relative; margin-bottom: 12px; }
.record-timeline-marker {
  position: absolute;
  left: -42px;
  top: 13px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0d354c;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 800;
  border: 4px solid #eef3f6;
  z-index: 1;
}
.record-timeline-item details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.record-timeline-item summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 15px 16px;
}
.record-timeline-item summary::-webkit-details-marker { display: none; }
.record-timeline-item summary::after {
  content: "＋";
  color: var(--muted);
  font-weight: 700;
}
.record-timeline-item details[open] summary::after { content: "−"; }
.record-summary-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.record-summary-main strong { color: var(--navy); }
.record-summary-main span { color: var(--muted); font-size: .86rem; }
.record-summary-meta {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: .82rem;
  white-space: nowrap;
}
.record-timeline-body {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
}
.record-event-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.record-event-grid > div {
  border: 1px solid #dde6eb;
  border-radius: 8px;
  background: #fff;
  padding: 11px;
}
.record-event-grid p { margin: 5px 0 0; white-space: pre-wrap; }
.record-evolution-block { margin-top: 12px; }
.record-evolution-block h5 { margin: 0 0 10px; color: var(--navy); font-size: .95rem; }
.record-vitals {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-radius: 8px;
  padding: 10px;
  background: #edf6fa;
  border: 1px solid #c9e2ed;
}
.record-vitals span { font-size: .84rem; }

@media (max-width: 1200px) {
  .record-summary-cards { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}
@media (max-width: 760px) {
  .patient-record-search { grid-template-columns: 1fr; }
  .patient-record-header { flex-direction: column; }
  .patient-record-contact { width: 100%; }
  .record-summary-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-toolbar { align-items: flex-start; flex-direction: column; }
  .record-filter-buttons { justify-content: flex-start; }
  .record-timeline { padding-left: 34px; }
  .record-timeline::before { left: 14px; }
  .record-timeline-marker { left: -34px; width: 30px; height: 30px; top: 15px; }
  .record-timeline-item summary { align-items: flex-start; flex-direction: column; }
  .record-summary-meta { margin-left: 0; white-space: normal; flex-wrap: wrap; }
  .record-event-grid { grid-template-columns: 1fr; }
}


/* Visualizador dinâmico de documentos — v3.3.4
   Mantém o PDF e a transcrição dentro da coluna, sem sobreposição, com abas, recolhimento e fechamento. */
.clinical-documents-card,
.clinical-document-entry {
  min-width: 0;
  overflow: hidden;
}
.document-viewer-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #f7fafc;
  box-shadow: 0 8px 24px rgba(13, 53, 76, .08);
  position: relative;
  z-index: 0;
}
.document-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.document-viewer-tabs,
.document-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.document-viewer-tab {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--navy);
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.document-viewer-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.document-viewer-content {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px;
  overflow: hidden;
}
.document-viewer-panel.is-collapsed .document-viewer-content { display: none; }
.document-viewer-pane { width: 100%; max-width: 100%; min-width: 0; }
.document-viewer-panel .document-frame-wrap {
  width: 100%;
  max-width: 100%;
  height: clamp(360px, 58vh, 620px);
  min-height: 360px;
}
.document-viewer-panel .document-frame-wrap iframe {
  width: 100%;
  height: 100%;
  min-height: 360px;
}
.document-viewer-panel .document-analysis {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  max-height: min(58vh, 620px);
  overflow: auto;
}
.document-result-actions { margin-top: 10px; }
@media (max-width: 760px) {
  .document-viewer-toolbar { align-items: stretch; }
  .document-viewer-tabs, .document-viewer-actions { width: 100%; }
  .document-viewer-tab, .document-viewer-actions .btn { flex: 1 1 auto; text-align: center; }
  .document-viewer-content { padding: 8px; }
  .document-viewer-panel .document-frame-wrap { height: 440px; min-height: 320px; }
}


/* Abas de status para agendas e consultas — v3.3.6 */
.status-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(18, 58, 86, .04);
}
.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #c9d5dc;
  border-radius: 999px;
  padding: 8px 12px;
  background: #f8fafb;
  color: #355162;
  font-weight: 700;
}
.status-tab strong {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #e4edf2;
  color: #36586b;
  font-size: 11px;
}
.status-tab:hover { border-color: var(--blue); color: var(--navy); }
.status-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.status-tab.active strong { background: rgba(255,255,255,.18); color: #fff; }
.status-filter-summary { margin: -5px 0 12px; color: var(--muted); font-size: 12px; }
@media (max-width: 680px) {
  .status-tabs { gap: 6px; padding: 7px; }
  .status-tab { flex: 1 1 auto; justify-content: center; padding: 8px 10px; }
}

/* Regras operacionais por UBS e novos módulos — v3.4.0 */
.compact-table th,
.compact-table td { vertical-align: middle; }
.patient-summary-strip {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7fafc;
}
.patient-summary-strip > div { display: flex; flex-direction: column; gap: 5px; }
.patient-summary-strip span { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.sensitive-card {
  min-width: 0;
  border: 1px solid #d8e2e8;
  border-radius: 10px;
  padding: 14px;
  background: #fbfcfd;
}
.sensitive-value {
  margin: 10px 0;
  padding: 12px;
  border-radius: 8px;
  background: #eef3f6;
  color: #405762;
  min-height: 44px;
  overflow-wrap: anywhere;
}
.small-modal { max-width: 560px !important; }
.slot-grid { display: grid; gap: 9px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.slot-choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid #d7e1e7;
  border-radius: 9px;
  padding: 11px 12px;
  background: #fff;
  cursor: pointer;
}
.slot-choice:hover { border-color: var(--blue); background: #f7fbfd; }
.slot-choice:has(input:checked) { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); background: #f3f8fb; }
.slot-choice input { margin-top: 3px; }
.slot-choice span { display: flex; flex-direction: column; gap: 4px; }
.slot-choice small { color: var(--muted); }
.triage-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.triage-row:last-child { border-bottom: 0; }
.triage-row small { color: var(--muted); text-align: right; }
.triage-completed { opacity: .48; filter: grayscale(.35); }
.compact-info { margin-top: 12px; }
.compact-info > div { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 760px) {
  .patient-summary-strip { grid-template-columns: 1fr; }
  .triage-row { align-items: flex-start; flex-direction: column; }
  .triage-row small { text-align: left; }
}

/* Autenticação v3.5 */
.auth-body{min-height:100vh;background:linear-gradient(135deg,#eef4fb 0%,#f8fafc 60%,#edf7f4 100%);display:grid;place-items:center;padding:28px}
.auth-shell{width:min(980px,100%);display:grid;grid-template-columns:minmax(0,1.05fr) minmax(340px,.95fr);background:#fff;border:1px solid var(--border);border-radius:24px;overflow:hidden;box-shadow:0 24px 70px rgba(15,43,70,.14);padding:0}
.auth-brand-panel{background:var(--navy);color:#fff;padding:46px;display:flex;flex-direction:column;justify-content:space-between;gap:56px;min-height:590px}.auth-brand-panel .brand{padding:0}.auth-brand-panel h1{font-size:38px;margin:0 0 14px}.auth-brand-panel p{color:#dce8f5;line-height:1.65;max-width:470px}.auth-security-note{display:grid;gap:5px;padding:16px;border:1px solid rgba(255,255,255,.22);border-radius:14px;background:rgba(255,255,255,.07)}.auth-security-note span{font-size:13px;color:#dce8f5;line-height:1.45}
.auth-card{padding:48px;align-self:center}.auth-card h2{font-size:30px;margin:18px 0 8px;color:var(--navy)}.auth-card>p{color:var(--muted)}.auth-back{display:inline-block;margin-bottom:20px;color:var(--navy);text-decoration:none;font-weight:700}.auth-form{display:grid;gap:18px;margin-top:28px}.auth-submit{width:100%;justify-content:center;min-height:46px}.password-field{display:flex;position:relative}.password-field input{padding-right:82px;width:100%}.password-toggle{position:absolute;right:7px;top:50%;transform:translateY(-50%);border:0;background:transparent;color:var(--navy);font-weight:700;cursor:pointer}.auth-help{margin-top:20px;font-size:13px}.hidden{display:none!important}
@media(max-width:760px){.auth-body{padding:14px}.auth-shell{grid-template-columns:1fr}.auth-brand-panel{min-height:auto;padding:28px;gap:28px}.auth-brand-panel h1{font-size:30px}.auth-card{padding:28px}}

/* Acesso rápido para homologação — v3.5.1 */
.test-user-summary{display:grid;gap:5px;padding:14px 16px;border:1px solid #cfe0e8;border-radius:12px;background:#f4f9fb;color:var(--navy)}
.test-user-summary strong{font-size:1rem}.test-user-summary span{font-size:.9rem;color:#355162}.test-user-summary small{color:var(--muted);line-height:1.4}
.auth-card select{width:100%;min-height:46px}

/* Vínculos profissionais — modalidades por UBS */
.professional-link-layout {
  display: grid;
  grid-template-columns: minmax(440px, .92fr) minmax(520px, 1.08fr);
  gap: 18px;
  align-items: start;
}
.professional-link-editor .card-head,
.professional-link-current .card-head { align-items: flex-start; }
.professional-link-editor .card-head h3,
.professional-link-current .card-head h3 { margin-bottom: 5px; }
.form-section-title {
  margin: 2px 0 9px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .35px;
}
.modality-selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.modality-option {
  min-height: 104px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid #bfd0db;
  border-radius: 9px;
  background: #f8fbfd;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.modality-option:hover {
  border-color: var(--blue);
  background: #f1f8fc;
  box-shadow: 0 5px 16px rgba(18, 58, 86, .08);
}
.modality-option input {
  width: 18px !important;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
  accent-color: var(--blue);
}
.modality-option span { min-width: 0; }
.modality-option strong {
  display: block;
  color: var(--navy);
  font-size: 13px;
  margin-bottom: 6px;
}
.modality-option small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.modality-option:has(input:checked) {
  border-color: #4e94be;
  background: #eaf5fb;
  box-shadow: inset 0 0 0 1px rgba(43,118,168,.16);
}
.modality-option.modality-presential:has(input:checked) {
  border-color: #5fa487;
  background: #eef8f3;
}
.professional-link-save { min-height: 44px; }
.professional-link-card { padding: 15px; }
.professional-link-card h4 { margin: 0; color: var(--navy); font-size: 14px; }
.modality-badges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.modality-badge {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #f6f8f9;
}
.modality-badge strong { font-size: 11px; color: #435661; }
.modality-badge small { font-size: 10px; color: var(--muted); }
.modality-badge.enabled { border-color: #acd3c1; background: #edf8f3; }
.modality-badge.enabled strong { color: #2a7056; }
.modality-badge.disabled { opacity: .72; }
.modality-selector.compact .modality-option { min-height: 86px; }

@media (max-width: 1180px) {
  .professional-link-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .modality-selector,
  .modality-badges { grid-template-columns: 1fr; }
  .modality-option { min-height: auto; }
}


/* Filtros de vínculos profissionais — v3.5.8 */
.professional-link-filters {
  display: grid;
  grid-template-columns: minmax(180px,1fr) minmax(240px,1.35fr) minmax(150px,.8fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #d8e3ea;
  border-radius: 10px;
  background: #f8fbfd;
}
.professional-link-filters .field { margin: 0; }
.professional-link-filter-actions { display:flex; align-items:flex-end; }
.professional-link-filter-actions .btn { min-height: 42px; white-space: nowrap; }
.professional-link-summary {
  display:flex; justify-content:space-between; gap:12px; align-items:center; flex-wrap:wrap;
  margin: 0 0 12px; padding: 10px 12px; border-left: 3px solid var(--blue);
  background:#eef6fb; color:var(--navy); border-radius:6px;
}
.professional-link-summary span { color: var(--muted); font-size: 12px; }
@media(max-width:1050px){.professional-link-filters{grid-template-columns:1fr 1fr}.professional-link-filter-actions{align-self:end}}
@media(max-width:700px){.professional-link-filters{grid-template-columns:1fr}.professional-link-filter-actions .btn{width:100%}}

/* v3.6.1 — acesso único */
.auth-shell-login{grid-template-columns:minmax(0,1.08fr) minmax(360px,.92fr)}
.auth-eyebrow{display:inline-block;margin-bottom:12px;color:#bcd6ec;letter-spacing:.12em;text-transform:uppercase;font-weight:800;font-size:.72rem}
@media(max-width:760px){.auth-shell-login{grid-template-columns:1fr}}


/* Identidade visual UBS Online — v3.6.2 */
.sidebar { overflow-y: auto; }
.system-brand {
  min-height: 132px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 14px;
}
.brand-logo {
  display: block;
  height: auto;
  object-fit: contain;
}
.brand-logo-full {
  width: 145px;
  max-width: 100%;
}
.brand-logo-compact {
  display: none;
  width: 48px;
}
.brand-context {
  color: #b8cfdd !important;
  font-size: 10px !important;
  line-height: 1.2;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 1px !important;
}
.auth-brand-panel .auth-product-brand {
  padding: 0;
  border-bottom: 0;
  align-items: flex-start;
}
.auth-product-logo {
  display: block;
  width: min(230px, 72%);
  height: auto;
}
.redirect-logo {
  display: block;
  width: min(240px, 72%);
  height: auto;
  margin: 0 auto 20px;
}
@media (min-width: 1051px) {
  body.sidebar-collapsed .system-brand {
    min-height: 72px;
    padding: 8px 0 14px;
  }
  body.sidebar-collapsed .brand-logo-full { display: none; }
  body.sidebar-collapsed .brand-logo-compact { display: block; }
  body.sidebar-collapsed .brand-context { display: none !important; }
}
@media (max-width: 1050px) {
  .system-brand { min-height: 118px; }
  .brand-logo-full { width: 132px; }
}
@media (max-width: 760px) {
  .auth-product-logo { width: min(190px, 68%); }
}
