/* ═══════════════════════════════════════════════════════
   AuroraMD — Design System
   ═══════════════════════════════════════════════════════ */

/* IBM Plex (SIL OFL 1.1, licença em /static/fonts/OFL.txt) — self-hosted,
   sem CDN externa (mesmo padrão de infra self-hosted do resto do projeto). */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 100 700;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-sans-latin-var.woff2') format('woff2-variations');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-sans-italic-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-serif-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-serif-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Serif';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-serif-latin-700.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-latin-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/static/fonts/ibm-plex-mono-latin-600.woff2') format('woff2');
}

:root {
  /* Paleta do mockup A32 (reskin): teal como cor interativa, verde só p/ "ok",
     neutros com leve viés frio. Os NOMES dos tokens são os mesmos de antes, então
     todo o app herda o novo visual sem tocar em cada regra. */
  --primary:       #0E7C7B;   /* teal — interativo, nav, links, foco */
  --primary-dark:  #0B5F5E;
  --primary-light: #D8ECEB;
  --accent:        #2C8467;   /* verde — confirmar/ok/emitir */
  --accent-soft:   #DBEDE5;
  --warn:          #A9741A;
  --warn-soft:     #F6ECD6;
  --danger:        #BC3B2C;
  --danger-soft:   #F7E1DD;
  --bg:            #F4F6F8;
  --surface:       #FFFFFF;
  --surface2:      #EDF1F4;
  --surface3:      #E4EAEE;
  --border:        #E0E6EC;
  --border-strong: #C9D2DB;
  --text:          #17212D;
  --text-muted:    #586573;
  --faint:         #8A9AA9;
  --sidebar-bg:    #12242B;   /* teal bem escuro (harmoniza com o accent) */
  --sidebar-text:  #C3D3D6;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active:#0E7C7B;
  --radius:        10px;
  --font-body:     'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-name:     'IBM Plex Serif', ui-serif, Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --font-data:     'IBM Plex Mono', ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --shadow:        0 1px 2px rgba(20,30,45,.06), 0 6px 20px rgba(20,30,45,.05);
  --shadow-lg:     0 4px 24px rgba(20,30,45,.12);
}

:root[data-theme="dark"] {
  --bg:#10171c; --surface:#172126; --surface2:#1d2a30; --surface3:#26353c;
  --border:#304148; --border-strong:#40545d; --text:#e5edf0; --text-muted:#a9bac1;
  --faint:#7f929a; --primary:#58b9b5; --primary-dark:#8bd3cf; --primary-light:#203f40;
  --accent:#62b493; --accent-soft:#203b31; --warn-soft:#3d321e; --danger-soft:#402522;
  --shadow:0 1px 2px rgba(0,0,0,.25); --shadow-lg:0 8px 30px rgba(0,0,0,.38);
  color-scheme:dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Nomes de paciente em SERIFA — identidade do mockup A32 (o nome "respira"
   diferente do resto da UI, que é sans). */
.pc-name, .p-name, #sb-nome, #consult-patient-name, .detail-card h2 {
  font-family: var(--font-name);
  letter-spacing: .01em;
}

/* ── LAYOUT ────────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
}

#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  min-width: 0;
}

.patient-toolbar {
  position:sticky; top:-24px; z-index:20; display:flex; align-items:center;
  gap:10px; margin:-24px -24px 20px; padding:11px 24px;
  background:color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom:1px solid var(--border); backdrop-filter:blur(10px);
}
.patient-view-tabs { display:flex; padding:3px; border-radius:9px; background:var(--surface2); }
.patient-view-tabs button { border:0; background:transparent; color:var(--text-muted); border-radius:7px; padding:6px 11px; cursor:pointer; font-size:12.5px; font-weight:650; }
.patient-view-tabs button.active { background:var(--surface); color:var(--primary-dark); box-shadow:var(--shadow); }
.patient-docbar { display:flex; gap:7px; flex-wrap:wrap; margin-left:4px; }
.patient-docbar button, .theme-toggle {
  border:1px solid var(--border); background:var(--surface); color:var(--text);
  border-radius:8px; padding:7px 11px; font-size:12.5px; cursor:pointer;
}
.patient-docbar button:hover, .theme-toggle:hover { border-color:var(--primary); color:var(--primary-dark); background:var(--primary-light); }
.patient-docbar .ghost { border-style:dashed; }
.operational-docs-banner { display:flex; align-items:center; justify-content:space-between;
  gap:18px; margin:14px 0; padding:16px 18px; border:1px solid var(--primary);
  border-radius:var(--radius); background:var(--primary-light); }
.operational-docs-banner div { display:grid; gap:4px; }
.operational-docs-banner span { color:var(--text-muted); font-size:13px; }
.patient-toolbar-right { margin-left:auto; display:flex; align-items:center; gap:7px; min-width:0; }
.theme-toggle { width:31px; height:29px; padding:0; font-size:16px; flex:0 0 auto; }
.mobile-pair-status {
  min-height:28px; max-width:155px; display:flex; align-items:center; gap:5px;
  padding:4px 7px; border:1px solid var(--border); border-radius:8px;
  background:var(--surface); color:var(--text-muted); cursor:pointer;
  font-size:10px; font-weight:650; white-space:nowrap;
}
.mobile-pair-status:hover { border-color:var(--primary); color:var(--primary-dark); }
.mobile-pair-status-dot {
  width:6px; height:6px; flex:0 0 6px; border-radius:50%; background:var(--faint);
}
.mobile-pair-status.active { color:#17634f; background:#edf8f4; border-color:#bcded2; }
.mobile-pair-status.active .mobile-pair-status-dot { background:#22a06b; }
.mobile-pair-status.warning .mobile-pair-status-dot { background:#d99a00; }
.mobile-pair-status.error .mobile-pair-status-dot { background:var(--danger); }
.patient-toolbar .signature-status {
  margin:0; padding:3px 5px; display:flex; align-items:center; gap:5px;
  max-width:220px; min-height:28px; background:var(--surface); font-size:10px;
}
.patient-toolbar .signature-status-line { min-width:0; }
.patient-toolbar #signature-status-text { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.patient-toolbar .signature-status button {
  width:auto; margin:0; padding:3px 5px; flex:0 0 auto; white-space:nowrap;
  font-size:9.5px;
}

/* ── SIDEBAR ───────────────────────────────────────────── */
/* TRILHO claro (layout do mockup A32): marca + Storyboard do paciente + nav.
   Antes era uma sidebar escura; agora hospeda o cabeçalho do paciente. */
#sidebar {
  width: 268px;
  min-width: 268px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 11px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 8px;
}
.brand-logo { height: 26px; object-fit: contain; }
.brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
}

.sidebar-nav {
  padding: 4px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 550;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 650; }
.nav-icon        { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 6px 4px;
  border-top: 1px solid var(--border);
}
.footer-label { display: block; color: var(--faint); font-size: 11px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }

/* ── GENERIC VIEWS ────────────────────────────────────── */
.view       { display: block; }
.view.hidden { display: none !important; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.view-title { font-size: 20px; font-weight: 700; color: var(--text); }
.view-sub   { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── SEARCH ──────────────────────────────────────────── */
.search-bar { margin-bottom: 16px; }
.search-bar input {
  width: 100%;
  max-width: 420px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.search-bar input:focus { border-color: var(--primary); }

/* ── PATIENT GRID ─────────────────────────────────────── */
.patients-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.patient-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.patient-card:hover { box-shadow: var(--shadow); border-color: var(--primary); }

.patient-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.patient-card-info { flex: 1; min-width: 0; }
.pc-name     { font-weight: 600; font-size: 15px; }
.pc-meta     { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.pc-complaint { color: var(--text); font-size: 13px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.patient-card-arrow { color: var(--text-muted); font-size: 20px; margin-left: 8px; }

/* ── PATIENT DETAIL ───────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}

.detail-card {
  grid-row: 1 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.patient-avatar-lg {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}

.detail-card h2    { font-size: 17px; margin-bottom: 8px; }
.detail-meta       { display: flex; flex-direction: column; gap: 4px; }
.detail-meta span  { font-size: 12px; color: var(--text-muted); }

.detail-info-card, .detail-history-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.detail-info-card h3, .detail-history-card h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin-bottom: 10px;
}

.complaint-text { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 12px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-grid h4 { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
.info-grid p  { font-size: 13px; }

.allergy-tag {
  display: inline-block;
  background: #fef2f2; color: #c0392b;
  border: 1px solid #fca5a5;
  border-radius: 4px; padding: 1px 7px;
  font-size: 12px; margin-right: 4px;
}

.history-item {
  display:block; padding:8px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.hist-date-col { display: flex; flex-direction: column; gap: 2px; min-width: 90px; margin-top: 2px; flex-shrink: 0; }
.hist-date   { color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }
.hist-medico { color:var(--text-muted); font-size:11px; white-space:normal; overflow-wrap:anywhere; text-align:right; flex:0 1 auto; }
.hist-main-line { width:100%; display:grid; grid-template-columns:auto minmax(0,1fr) auto auto; align-items:center; gap:9px; border:0; border-radius:7px; padding:6px 7px; background:transparent; color:var(--text); text-align:left; cursor:pointer; font:inherit; }
.hist-main-line:hover { background:var(--surface2); }
.hist-diagnostico { font-size:13px; font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hist-chevron { color:var(--text-muted); transition:transform .16s ease; }
.history-item.expanded .hist-chevron { transform:rotate(180deg); }
.hist-body { min-width:0; }
.hist-body strong { font-size: 13px; display: block; margin-bottom: 3px; }
.hist-body p { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.hist-nota-medico { font-style: italic; color: var(--primary) !important; font-size: 12px !important; }
.hist-procs { font-size: 11px !important; color: var(--text-muted) !important; }

/* MVP-23: consulta em 1 linha (resumo) + links de exames/documentos por data */
.hist-resumo { font-size:12.5px; color:var(--text); display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hist-cid { font:600 10.5px var(--font-data); color:var(--primary-dark); background:var(--primary-light); border-radius:5px; padding:2px 6px; white-space:nowrap; }
.hist-links-line { min-height:28px; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:2px 7px 0 104px; }
.hist-links { display:flex; flex-wrap:wrap; gap:5px; margin-top:0; align-items:center; }
.hist-links:empty { display: none; }
.hist-link {
  font-size: 11px; font-weight: 600; text-decoration: none;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap;
}
.hist-link-exame { color: var(--primary); background: var(--primary-light); border-color: transparent; }
.hist-link-exame:hover { background: var(--primary); color: #fff; }
.hist-link-doc { color: var(--accent); background: #e8f5e9; border-color: transparent; }
.hist-link-doc:hover { filter: brightness(.96); }
.hist-link.disabled { color: var(--text-muted); background: transparent; cursor: default; opacity: .7; }
.hist-expanded { display:none; margin:8px 7px 2px 104px; padding:10px 12px; border:1px solid var(--border); border-radius:8px; background:var(--bg); }
.history-item.expanded .hist-expanded { display:block; }
.hist-expanded-sec { margin-bottom:9px; }
.hist-expanded-sec:last-child { margin-bottom:0; }
.hist-expanded-sec > strong { display:block; margin-bottom:3px; font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted); }
.hist-expanded-sec p, .hist-expanded-sec li { font-size:12.5px; line-height:1.5; }
.hist-expanded-sec ul { margin:0; padding-left:18px; }

/* exame como link na seção "Exames e resultados" */
.exame-link { color: var(--primary); font-weight: 600; text-decoration: none; font-size: 13px; }
.exame-link:hover { text-decoration: underline; }
.pend-grafico {
  margin-top: 10px; padding: 9px 11px; border: 1px dashed var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text-muted); font-size: 12px;
}

.exame-viewer { position:fixed; inset:0; z-index:75; display:flex; align-items:center; justify-content:center; }
.exame-viewer-backdrop { position:absolute; inset:0; background:rgba(10,16,24,.82); }
.exame-viewer-box { position:relative; z-index:1; width:min(1100px, 92vw); height:min(86vh, 880px); display:grid; grid-template-rows:auto minmax(0,1fr) auto; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:var(--shadow-lg); overflow:hidden; }
.exame-viewer-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 14px; border-bottom:1px solid var(--border); background:var(--surface2); }
.exame-viewer-head > div { display:flex; align-items:center; gap:8px; }
.exame-viewer-head .btn-imprimir { padding:6px 10px; text-decoration:none; }
.exame-viewer-content { min-height:0; background:#30343a; display:flex; align-items:center; justify-content:center; }
.exame-viewer-content iframe { width:100%; height:100%; border:0; background:#fff; }
.exame-viewer-content img { max-width:100%; max-height:100%; object-fit:contain; }
.exame-viewer-loading { color:#f4f6f8; font-size:13px; padding:20px; text-align:center; }
.exame-viewer-note { padding:10px 14px; border-top:1px solid var(--border); background:var(--surface); }
.exame-viewer-note label { display:block; font-size:11px; color:var(--text-muted); margin-bottom:4px; }
.exame-viewer-note textarea { width:100%; resize:vertical; max-height:150px; padding:7px 9px; border:1px solid var(--border); border-radius:7px; background:var(--surface2); color:var(--text); font:13px/1.45 inherit; }
.exame-viewer-note > div { display:flex; justify-content:flex-end; align-items:center; gap:10px; margin-top:6px; }
.exame-viewer-note .btn-emitir { flex:0 0 auto; padding:7px 14px; }
@media (max-width:760px) { .exame-viewer-box { width:96vw; height:92vh; } }

/* demografia copiável (storyboard) */
.sb-copiavel { cursor: pointer; border-radius: 5px; padding: 0 2px; transition: background .12s; }
.sb-copiavel:hover { background: var(--primary-light); }
.sb-copy-ic { font-size: 9.5px; opacity: 0; margin-left: 3px; vertical-align: middle; }
.sb-copiavel:hover .sb-copy-ic { opacity: .65; }

/* ── CONSULTATION ─────────────────────────────────────── */
.consult-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
}

.consult-topbar-left  { font-size: 14px; color: var(--text-muted); }
.consult-topbar-left strong { color: var(--text); }

.consult-topbar-center {
  display: flex; align-items: center; gap: 12px;
}

.rec-dot { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.rec-dot.active { color: #e53e3e; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.4} }

.consult-timer { font-size: 15px; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--primary); }

/* Histórico do prontuário: duração, vínculo de agenda e blocos
   recolhidos de transcrição/análise (A14) */
.hist-meta { font-size: 11px; color: var(--muted, #6b7280); display: block; margin-top: 2px; }
.hist-agendada { color: var(--primary); }
.hist-extra { margin-top: 8px; }
.hist-extra > summary { cursor: pointer; font-size: 12px; color: var(--primary); user-select: none; }
.hist-extra[open] > summary { margin-bottom: 6px; }
.hist-transcricao { font-size: 13px; line-height: 1.5; white-space: pre-wrap; color: var(--text, #374151); }
.hist-analise-sec { font-size: 13px; margin: 4px 0; }

/* Estado do autosave do rascunho (A12) */
.autosave-status { font-size: 12px; font-weight: 500; }
.autosave-ok { color: var(--muted, #6b7280); }
.autosave-pendente, .autosave-salvando { color: var(--primary); }
.autosave-erro, .autosave-conflito, .autosave-incerto { color: #b45309; }

.consult-topbar-right { display: flex; gap: 8px; align-items: center; }

.consult-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(400px, 2fr);
  gap: 12px;
  height: min(660px, calc(100dvh - 210px));
  min-height: 420px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* status assíncrono da transcrição (A35): "transcrevendo… 3/5", lacunas */
.transcript-status {
  margin-left: auto;
  margin-right: 10px;
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
  opacity: .85;
}

.panel-body {
  flex: 1; overflow-y: auto; padding: 14px;
}

/* Contexto compacto, em uma coluna, como no A32. */
.panel-patient { overflow:hidden; }
.patient-context { flex:1; min-height:0; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:10px; }
.patient-context-ident { display:flex; align-items:center; gap:9px; padding-bottom:8px; border-bottom:1px solid var(--border); }
.patient-context-ident .p-avatar { margin:0; flex:0 0 auto; }
.context-field { padding-bottom:8px; border-bottom:1px solid var(--border); }
.context-field:last-child { border-bottom:0; }
.context-exams { margin-top:auto; }

/* Patient column B: antecedentes + meds fill available space */
.p-antecedentes-field {
  min-height: 72px; max-height:120px; resize:vertical;
}
.p-meds-field {
  min-height: 72px; max-height:120px; resize:vertical;
  font-size: 12px;
}
.patient-col-b .p-divider { margin: 8px 0; }

/* Avatar small in consultation */
.p-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}

.p-name    { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.p-meta    { font-size: 11.5px; color: var(--text-muted); }
.p-divider { border-top: 1px solid var(--border); margin: 8px 0; }
.p-label   { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: 3px; }
.p-val     { font-size: 13px; }
.p-allergy { color: #c0392b; }

.exams-list   { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.exam-item {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; padding: 4px 0;
}
.exam-item a { color: var(--primary); font-size: 11px; }
.exam-item > span { min-width:0; display:flex; flex-direction:column; }
.exam-view-btn, .exam-view-link { border:0; background:none; color:var(--primary); cursor:pointer; font:inherit; text-align:left; padding:0; }
.exam-view-btn { font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.exam-view-link { font-size:11px; }
.exam-note-preview { color:var(--text-muted); font-size:10.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:100%; }

/* Transcript panel */
.transcript-content {
  flex: 1; overflow-y: auto; padding: 14px;
}
.transcript-chunk {
  font-size: 14px; line-height: 1.65;
  padding: 6px 0; border-bottom: 1px solid #f0f4f9;
  color: var(--text);
}
.transcript-chunk:last-child { border-bottom: none; }

.transcript-exam-suggestions {
  flex:0 0 auto; max-height:112px; overflow-y:auto;
  padding:8px 12px 10px; border-top:1px solid var(--border);
  background:var(--surface2);
}
.transcript-suggestions-heading {
  display:flex; align-items:baseline; justify-content:space-between; gap:8px;
  margin-bottom:6px; color:var(--text-muted); font-size:10.5px;
  text-transform:uppercase; letter-spacing:.35px;
}
.transcript-suggestions-heading small {
  font-size:10px; text-transform:none; letter-spacing:0; opacity:.8;
}
.transcript-exam-suggestions .procedure-btn { padding:4px 9px; font-size:11px; }

.proc-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: 6px; }
.procedures-panel { display: flex; flex-wrap: wrap; gap: 6px; }

.procedure-btn {
  padding: 5px 11px;
  border: 1px solid var(--primary);
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .15s;
  position: relative;
}
.procedure-btn:hover {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(30,77,140,.25);
}
.procedure-btn::after {
  content: '↗';
  font-size: 10px;
  margin-left: 4px;
  opacity: .6;
}

/* Editable patient fields */
.p-editable-field {
  width: 100%; min-height: 32px;
  resize: none; overflow-y: auto;
  padding: 5px 7px;
  border: 1px solid transparent; border-radius: 4px;
  background: transparent;
  font-family: inherit; font-size: 12px; line-height: 1.5;
  color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
.p-editable-field:hover  { border-color: var(--border); background: var(--surface2); }
.p-editable-field:focus  { border-color: var(--primary); background: var(--surface); }
.p-editable-field::placeholder { color: var(--text-muted); font-style: italic; }

.p-complaint-field { font-size: 12.5px; font-weight: 500; min-height: 36px; max-height: 56px; }
.p-allergy-field   { min-height: 32px; max-height: 56px; color: #c0392b; }
.p-allergy-field::placeholder { color: #c0392b; opacity: .5; }

.p-label-edit {
  font-size: 9px; font-weight: normal; text-transform: none;
  letter-spacing: 0; color: var(--text-muted); margin-left: 4px;
  opacity: .7;
}

/* Exame físico button */
.btn-exame-fisico {
  padding: 7px 12px;
  background: var(--primary-light); color: var(--primary);
  border: 1px solid var(--primary-light); border-radius: var(--radius);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn-exame-fisico:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-pre-exame { background: var(--surface); color: var(--text-muted); border-color: var(--border); }

/* MVP-30.1 — Pack ORL Geral rápido. */
.orl-exam-dialog {
  width:min(1680px,calc(100vw - 16px)); max-height:calc(100vh - 16px);
  padding:0; border:1px solid var(--border); border-radius:14px;
  background:var(--surface); color:var(--text); box-shadow:var(--shadow-lg);
}
.orl-exam-dialog::backdrop { background:rgba(16,28,43,.62); backdrop-filter:blur(2px); }
.orl-exam-shell { display:flex; flex-direction:column; max-height:calc(100vh - 18px); }
.orl-exam-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:18px 20px 14px; border-bottom:1px solid var(--border); }
.orl-exam-head h2 { margin:3px 0 4px; font-size:22px; }
.orl-exam-head p { margin:0; color:var(--text-muted); font-size:12.5px; }
.orl-head-actions { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:8px; }
.orl-head-actions .btn-secondary { white-space:nowrap; }
.orl-document-action { border-color:var(--primary); color:var(--primary); }
.orl-kicker { color:var(--primary); text-transform:uppercase; letter-spacing:.08em; font-size:10px; font-weight:750; }
.orl-exam-body { min-height:0; max-height:calc(100vh - 110px); overflow:auto; display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:16px; padding:16px 20px; }
.orl-clinical-fields { min-width:0; display:grid; grid-template-columns:minmax(0,3fr) minmax(250px,1fr); gap:12px; align-items:start; }
.orl-general-column, .orl-endoscopy-column { min-width:0; }
.orl-toolbar { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; color:var(--text-muted); font-size:11.5px; }
.orl-toolbar > div:first-child { display:flex; flex-direction:column; gap:2px; }
.orl-toolbar .btn-secondary { padding:5px 9px; font-size:11px; }
.orl-complaints-section { padding:12px; margin-bottom:14px; border:1px solid var(--border); border-radius:10px; background:var(--surface); }
.orl-section-heading { display:flex; justify-content:space-between; align-items:end; gap:10px; margin-bottom:9px; color:var(--text-muted); font-size:11px; }
.orl-section-heading h3 { margin:2px 0 0; font-size:14px; color:var(--text); }
.orl-complaint-buttons { margin-bottom:8px; }
.orl-complaint-note { margin-top:9px; }
.orl-regions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; }
.orl-region { border:1px solid var(--border); border-radius:10px; padding:11px; background:var(--surface); }
.orl-region.has-value { border-color:color-mix(in srgb,var(--primary) 48%,var(--border)); box-shadow:0 0 0 1px color-mix(in srgb,var(--primary) 10%,transparent); }
.orl-region-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:9px; }
.orl-region-head h3 { font-size:13.5px; margin:0; }
.orl-normal-btn { border:1px solid #9bb7aa; background:#f1f8f4; color:#17663d; border-radius:999px; padding:5px 9px; cursor:pointer; font-size:10.5px; font-weight:650; }
.orl-normal-btn.active { background:#18794e; border-color:#18794e; color:white; }
.orl-finding-list { display:flex; flex-wrap:wrap; gap:5px; }
.orl-finding-btn { border:1px solid var(--border); background:var(--surface2); color:var(--text); border-radius:999px; padding:5px 8px; cursor:pointer; font-size:10.5px; }
.orl-finding-btn:hover, .orl-finding-btn:focus-visible { border-color:var(--primary); outline:none; }
.orl-finding-btn.active { background:var(--primary-light); border-color:var(--primary); color:var(--primary-dark); font-weight:650; }
.orl-selected-list { display:flex; flex-direction:column; gap:5px; margin-top:9px; }
.orl-selected { display:grid; grid-template-columns:minmax(120px,1fr) auto auto; align-items:center; gap:7px; padding:6px 7px; border-radius:7px; background:var(--surface2); font-size:10.5px; }
.orl-selected-label { overflow:hidden; text-overflow:ellipsis; }
.orl-laterality { display:flex; align-items:center; gap:3px; }
.orl-laterality-label { color:var(--danger); font-size:9px; margin-right:2px; }
.orl-laterality button { min-width:25px; border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:5px; padding:3px 5px; cursor:pointer; font-size:9.5px; }
.orl-laterality button.active { background:var(--primary); border-color:var(--primary); color:#fff; }
.orl-remove { border:0; background:transparent; color:var(--danger); cursor:pointer; font-size:14px; line-height:1; }
.orl-inline-note { display:flex; flex-direction:column; gap:4px; margin-top:10px; color:var(--text-muted); font-size:10.5px; }
.orl-inline-note input { width:100%; box-sizing:border-box; border:1px solid var(--border); border-radius:7px; padding:7px 8px; background:var(--surface2); color:var(--text); font:inherit; font-size:11.5px; }
.orl-inline-note input:focus { border-color:var(--primary); outline:2px solid color-mix(in srgb,var(--primary) 18%,transparent); }
.orl-endoscopy-heading { margin:0 0 8px; }
.orl-endoscopy-heading h3 { margin:2px 0 0; font-size:14px; }
.orl-endoscopy-notes { display:grid; grid-template-columns:1fr; gap:10px; }
.orl-endoscopy-card { border:1px solid var(--border); border-radius:10px; padding:11px; background:var(--surface); }
.orl-endoscopy-card.has-value { border-color:color-mix(in srgb,var(--primary) 48%,var(--border)); box-shadow:0 0 0 1px color-mix(in srgb,var(--primary) 10%,transparent); }
.orl-endoscopy-card-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:9px; }
.orl-endoscopy-card-head h3 { margin:0; font-size:13.5px; }
.orl-endoscopy-selected { display:flex; flex-wrap:wrap; }
.orl-endoscopy-selected .orl-selected-label { flex:1 1 130px; }
.orl-attribute-control { display:flex; align-items:center; gap:4px; color:var(--text-muted); font-size:9.5px; }
.orl-attribute-control select { max-width:118px; border:1px solid var(--border); border-radius:5px; padding:3px 5px; background:var(--surface); color:var(--text); font-size:10px; }
.orl-endoscopy-card .orl-inline-note span { color:var(--text-muted); }
.orl-nasal-septum { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:6px; }
.orl-nasal-septum-detail { min-width:0; display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:5px; }
.orl-nasal-septum input { min-width:0; width:100%; box-sizing:border-box; border:1px solid var(--border); border-radius:7px; padding:6px 7px; background:var(--surface2); color:var(--text); font-size:10.5px; }
.orl-nasal-septum input:focus { border-color:var(--primary); outline:2px solid color-mix(in srgb,var(--primary) 18%,transparent); }
.orl-nasal-mode { display:flex; align-items:center; justify-content:center; gap:7px; margin:11px 0 8px; color:var(--text-muted); font-size:9.5px; }
.orl-nasal-mode > span.active { color:var(--primary-dark); font-weight:700; }
.orl-switch { position:relative; display:inline-flex; flex:0 0 auto; width:32px; height:18px; cursor:pointer; }
.orl-switch input { position:absolute; opacity:0; pointer-events:none; }
.orl-switch > span { width:100%; border-radius:999px; background:var(--border); transition:background .15s; }
.orl-switch > span::after { content:''; position:absolute; top:3px; left:3px; width:12px; height:12px; border-radius:50%; background:white; box-shadow:0 1px 3px rgba(0,0,0,.25); transition:transform .15s; }
.orl-switch input:checked + span { background:var(--primary); }
.orl-switch input:checked + span::after { transform:translateX(14px); }
.orl-switch input:focus-visible + span { outline:2px solid var(--primary); outline-offset:2px; }
.orl-nasal-columns { display:grid; gap:6px; }
.orl-nasal-columns.lateralized { grid-template-columns:repeat(2,minmax(0,1fr)); }
.orl-nasal-side { min-width:0; border:1px solid var(--border); border-radius:8px; padding:7px 5px; background:var(--surface2); }
.orl-nasal-side h4 { margin:0 0 6px; text-align:center; color:var(--primary-dark); font-size:10px; }
.orl-nasal-grade-row { display:grid; gap:3px; margin-top:7px; }
.orl-nasal-grade-row:first-of-type { margin-top:0; }
.orl-nasal-grade-row > span { overflow:hidden; text-overflow:ellipsis; color:var(--text-muted); font-size:9px; white-space:nowrap; }
.orl-grade-buttons { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:2px; }
.orl-grade-buttons button { min-width:0; border:1px solid var(--border); border-radius:5px; padding:4px 0; background:var(--surface); color:var(--text); cursor:pointer; font-size:9.5px; }
.orl-grade-buttons button.active { border-color:var(--primary); background:var(--primary); color:#fff; font-weight:700; }
.orl-nasal-secretion { display:grid; gap:4px; margin-top:8px; padding-top:7px; border-top:1px solid var(--border); }
.orl-adenoid-grade { display:grid; grid-template-columns:minmax(70px,.7fr) minmax(150px,1fr); align-items:center; gap:8px; margin-top:9px; padding:9px 7px; border:1px solid var(--border); border-radius:8px; background:var(--surface2); color:var(--text-muted); font-size:10.5px; }
.orl-nasal-secretion > span { color:var(--text-muted); font-size:9px; }
.orl-secretion-line { display:grid; grid-template-columns:minmax(36px,.8fr) repeat(3,minmax(0,1fr)); gap:2px; align-items:center; }
.orl-secretion-line small { overflow:hidden; color:var(--text-muted); font-size:8px; }
.orl-secretion-line button { min-width:0; border:1px solid var(--border); border-radius:5px; padding:4px 2px; background:var(--surface); color:var(--text); cursor:pointer; font-size:8.5px; }
.orl-secretion-line button.active { border-color:var(--primary); background:var(--primary); color:#fff; font-weight:700; }
.orl-legacy-findings { margin-top:9px; color:var(--text-muted); font-size:9.5px; }
.orl-legacy-findings summary { cursor:pointer; }
.orl-narrative-panel { position:sticky; top:0; align-self:start; border:1px solid var(--border); border-radius:10px; padding:14px; background:var(--surface2); }
.orl-narrative-panel h3 { margin:3px 0 10px; font-size:15px; }
.orl-narrative-preview { max-height:46vh; overflow:auto; white-space:pre-wrap; font-size:12.5px; line-height:1.55; color:var(--text); }
.orl-source-note { margin-top:14px; padding-top:10px; border-top:1px solid var(--border); font-size:10px; line-height:1.45; color:var(--text-muted); }
.orl-projection-actions { display:grid; gap:7px; margin-top:14px; padding-top:12px; border-top:1px solid var(--border); }
.orl-projection-actions button { width:100%; }
.orl-projection-actions .orl-exam-status { min-height:1.4em; }
.orl-exam-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:11px 20px; border-top:1px solid var(--border); background:var(--surface2); }
.orl-exam-actions > div { display:flex; gap:7px; }
.orl-exam-status { color:var(--text-muted); font-size:11.5px; }
.orl-exam-status.error { color:var(--danger); font-weight:650; }
.orl-config-view { min-height:0; overflow:auto; }
.orl-config-intro { display:flex; justify-content:space-between; gap:20px; padding:16px 20px 12px; border-bottom:1px solid var(--border); }
.orl-config-intro h3 { margin:2px 0 0; font-size:17px; }
.orl-config-intro p { max-width:480px; margin:0; color:var(--text-muted); font-size:11.5px; }
.orl-config-grid { display:grid; grid-template-columns:280px minmax(0,1fr); gap:16px; padding:16px 20px; max-height:62vh; overflow:auto; }
.orl-config-grid h4 { margin:0 0 9px; font-size:13px; }
.orl-config-section-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:9px; }
.orl-config-section-head h4 { margin:0; }
.orl-config-section-head .btn-secondary { padding:4px 8px; font-size:10.5px; }
.orl-config-options { display:grid; gap:5px; }
.orl-config-option { display:flex; align-items:center; gap:7px; padding:6px 8px; border:1px solid var(--border); border-radius:7px; font-size:11.5px; background:var(--surface); cursor:pointer; }
.orl-config-option input { accent-color:var(--primary); }
.orl-config-option-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:4px; align-items:stretch; }
.orl-config-option-row .orl-config-option { min-width:0; }
.orl-term-edit { border:1px solid var(--border); border-radius:7px; padding:0 8px; background:var(--surface); color:var(--primary); cursor:pointer; font-size:10px; }
.orl-config-region { padding:10px; border:1px solid var(--border); border-radius:9px; margin-bottom:8px; }
.orl-config-region-head { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:7px; }
.orl-config-region-head label { font-weight:700; font-size:12.5px; }
.orl-config-order { display:flex; gap:4px; }
.orl-config-order button { border:1px solid var(--border); background:var(--surface); border-radius:5px; cursor:pointer; }
.orl-config-findings { display:flex; flex-wrap:wrap; gap:5px; padding-left:20px; }
.orl-config-findings .orl-config-option { padding:4px 7px; }
.orl-term-editor { grid-column:1 / -1; border:1px solid var(--primary); border-radius:10px; padding:13px; background:var(--surface2); }
.orl-term-fields { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:9px; }
.orl-term-fields label { display:grid; gap:4px; color:var(--text-muted); font-size:10.5px; font-weight:650; }
.orl-term-fields input,.orl-term-fields select { min-width:0; border:1px solid var(--border); border-radius:7px; padding:7px 8px; background:var(--surface); color:var(--text); font:inherit; }
.orl-term-fields input:disabled,.orl-term-fields select:disabled { opacity:.65; }
.orl-term-narrative { grid-column:span 2; }
.orl-term-actions { display:flex; align-items:center; justify-content:flex-end; gap:7px; margin-top:11px; }
.orl-term-actions .orl-exam-status { margin-right:auto; }
.hist-orl-narrative { white-space:pre-wrap; line-height:1.55; }

/* Pre-exame banner in analysis */
.pre-exame-banner {
  background: var(--primary-light); color: var(--primary-dark);
  border: 1px solid var(--primary-light); border-radius: var(--radius);
  padding: 6px 10px; font-size: 12px; font-weight: 600;
  margin-bottom: 10px;
}

/* Doctor audio */
.btn-doc-audio {
  padding: 4px 10px;
  background: var(--surface2); color: var(--primary);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn-doc-audio:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-doc-audio.recording {
  background: #fee2e2; color: #c0392b; border-color: #fca5a5;
  animation: blink 1.2s ease-in-out infinite;
}
.doc-audio-status { font-size: 10px; color: var(--text-muted); }
.doctor-audio-text {
  font-size: 11.5px; color: var(--text); line-height: 1.5;
  margin-top: 4px;
  background: var(--surface2); border-radius: var(--radius);
  padding: 4px 8px;
  display: none;
}
.doctor-audio-text:not(:empty) { display: block; }

/* TUSS badge in exam modal */
.tuss-badge {
  font-size: 10px; color: var(--text-muted); margin-left: 6px;
  background: var(--bg); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border);
}

/* Analysis panel */
.doctor-note-area {
  padding: 8px 14px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.doctor-note-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 5px;
}
.doctor-note-header .p-label { margin-bottom: 0; }

.doctor-audio-inline { display: flex; align-items: center; gap: 6px; }

.doctor-note-input {
  width: 100%; min-height: 180px; max-height: 320px;
  resize: vertical; overflow-y: auto;
  padding: 6px 9px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface2); color: var(--text);
  font-family: inherit; font-size: 12.5px; line-height: 1.55;
  outline: none; transition: border-color .15s, background .15s;
}
.doctor-note-input:focus { border-color: var(--primary); background: var(--surface); }
.doctor-note-input::placeholder { color: var(--text-muted); }

.analysis-content { flex: 1; overflow-y: auto; padding: 14px; }
.analysis-header-meta { display:flex; align-items:center; gap:7px; margin-left:auto; }
.llm-usage {
  font-size:10px; font-weight:600; text-transform:none; letter-spacing:0;
  color:var(--text-muted); white-space:nowrap;
}
.llm-usage.warning { color:#b45309; }
.llm-usage.blocked { color:#b42318; }
.analysis-source { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.analysis-source.demo { background: #fef3c7; color: #92400e; }
.analysis-source.live { background: #d1fae5; color: #065f46; }
.analysis-source.error { background:#fee2e2; color:#991b1b; }

.a-section { margin-bottom: 10px; }
.a-section h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: 4px; }
.a-section p  { font-size: 13px; line-height: 1.55; }
.a-section ul { padding-left: 14px; }
.a-section li { font-size: 12.5px; line-height: 1.6; }
.a-alert      { background: #fef2f2; border: 1px solid #fca5a5; border-radius: var(--radius); padding: 8px 10px; }
.a-alert h4   { color: #c0392b; }
.a-queixa {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 6px 10px;
  margin-bottom: 10px;
}
.a-queixa p { font-size: 13px; font-weight: 600; color: var(--primary); line-height: 1.4; }

.analysis-actions {
  display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}

.clinical-orders {
  flex:0 0 auto; max-height:180px; overflow-y:auto;
  padding:9px 14px; border-bottom:1px solid var(--border); background:var(--surface2);
}
.clinical-orders-header { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.clinical-orders-header .proc-label { margin:0; }
.clinical-orders .procedures-panel { max-height:62px; overflow-y:auto; margin-top:6px; }
.clinical-orders .generated-pdfs { max-height:78px; overflow-y:auto; }
.btn-order-all {
  border:0; background:none; color:var(--primary); cursor:pointer;
  padding:2px 0; font:inherit; font-size:11px; font-weight:650;
}
.orders-empty { margin:5px 0 0; color:var(--text-muted); font-size:11px; }
.clinical-orders.has-orders .orders-empty { display:none; }
.btn-reception { color:var(--primary); border-color:var(--primary); }

/* ── RESEARCH ─────────────────────────────────────────── */
.research-form {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px; max-width: 700px;
}
.research-textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; resize: vertical;
  font-family: inherit; outline: none;
  transition: border-color .15s;
}
.research-textarea:focus { border-color: var(--primary); }

.research-results { max-width: 800px; }
.research-card    { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }

.r-section { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.r-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.r-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.r-section h3 { font-size: 14px; font-weight: 600; color: var(--primary); margin-bottom: 8px; }
.r-section ul { padding-left: 18px; }
.r-section li { font-size: 13px; line-height: 1.7; }
.r-section p  { font-size: 14px; line-height: 1.65; }
.r-caveat     { background: #fffbeb; border-radius: var(--radius); padding: 12px; }

.ev-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; background: var(--primary-light); color: var(--primary);
}
.ev-a { background: #d1fae5; color: #065f46; }
.ev-b { background: var(--primary-light); color: var(--primary-dark); }
.ev-c { background: #fef3c7; color: #92400e; }
.ev-d { background: #fee2e2; color: #991b1b; }
.demo-badge { background: #fef3c7; color: #92400e; }

.pubmed-card {
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.pubmed-card:last-child { border-bottom: none; }
.pub-title { font-size: 13px; font-weight: 600; color: var(--primary); text-decoration: none; display: block; margin-bottom: 3px; }
.pub-title:hover { text-decoration: underline; }
.pub-meta { font-size: 11px; color: var(--text-muted); }

.demo-banner {
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
  border-radius: var(--radius); padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
}

/* ── WORKLIST MODAL ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none !important; }

.modal-box {
  background: var(--surface); border-radius: 10px;
  width: 600px; max-width: 95vw;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-muted);
  line-height: 1;
}
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-sub  { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.pdf-result-link {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin-bottom: 8px;
  background: var(--surface2); border-radius: var(--radius);
  color: var(--primary); font-weight: 600; font-size: 14px;
  text-decoration: none;
}
.pdf-result-link:hover { background: #dde8f8; }
.request-result { margin-top:12px; padding:10px; border:1px solid var(--border); border-radius:8px; background:var(--surface2); }

.worklist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background .12s;
}
.worklist-item:hover { background: var(--bg); }
.wl-time  { font-size: 13px; font-weight: 600; color: var(--primary); min-width: 42px; }
.wl-type  { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
.wl-new     { background: #d1fae5; color: #065f46; }
.wl-return  { background: var(--primary-light); color: var(--primary); }
.wl-urgent  { background: #fee2e2; color: #991b1b; }
.wl-info    { flex: 1; min-width: 0; }
.wl-info strong { display: block; font-size: 13px; }
.wl-info span   { font-size: 12px; color: var(--text-muted); }
.wl-doctor { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Exam search in modal */
.modal-box-lg { width: 680px; }

.exam-search-row {
  display: flex; gap: 8px; align-items: center;
}
.exam-search-input {
  flex: 1; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; outline: none;
  transition: border-color .15s;
}
.exam-search-input:focus { border-color: var(--primary); }

.exam-search-results {
  position: relative; margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
  display: none;
}
.exam-search-results:not(:empty) { display: block; }
.exam-search-item {
  padding: 8px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.exam-search-item:last-child { border-bottom: none; }
.exam-search-item:hover { background: var(--primary-light); color: var(--primary); }
.exam-search-empty { padding: 8px 12px; font-size: 12px; color: var(--text-muted); }

.request-exams-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.exam-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.exam-check input { width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }

.exam-group { margin-bottom: 8px; }
.exam-group-title {
  font-size: 12px; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .3px;
  padding: 4px 0 2px;
}
.exam-sub-item { padding-left: 10px; }
.exam-sub-item .exam-check { font-size: 12px; }

.exam-variante-row { display: flex; align-items: center; gap: 8px; padding: 4px 0 4px 2px; }
.exam-variante-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.exam-variante-select {
  font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 3px 8px; background: var(--surface2); color: var(--text); cursor: pointer;
}

.exam-justificativa-row { padding: 6px 2px 2px; }
.exam-justificativa-label { font-size: 11px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.exam-justificativa {
  width: 100%; min-height: 46px; font-size: 12px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px 8px; color: var(--text); background: var(--surface);
  font-family: inherit; box-sizing: border-box;
}
.exam-justificativa:focus { border-color: var(--primary); outline: none; }

.generated-pdfs { margin-top: 6px; }
.gen-pdfs-label { margin-top: 8px !important; padding-top: 8px; border-top: 1px solid var(--border); }
.gen-pdf-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 8px; background: var(--surface2); border-radius: var(--radius);
  margin-bottom: 4px;
}
.gen-pdf-copy { display:flex; flex-direction:column; gap:2px; min-width:0; flex:1; }
.gen-pdf-name {
  font-size: 12px; color: var(--primary); text-decoration: none;
  font-weight: 500; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gen-pdf-meta { color:var(--text-muted); font-size:9.5px; line-height:1.25; }
.gen-pdf-name:hover { text-decoration: underline; }
.gen-pdf-actions { display: flex; gap: 4px; margin-left: 8px; flex-shrink: 0; }
.btn-pdf-action {
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 3px 7px; cursor: pointer; font-size: 13px; line-height: 1;
  color: var(--text-muted);
}
.btn-pdf-action:hover { background: var(--surface); color: var(--text); }
.btn-pdf-recepcao { color: var(--primary) !important; }

/* ── BUTTONS ──────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0; z-index: 3000;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at top, #e8f4f6 0, #f4f7f9 48%, #e8edf2 100%);
}
.login-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 9px;
  padding: 36px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
}
.login-brand { color: var(--primary); font-size: 24px; font-weight: 750; margin-bottom: 12px; }
.login-card h1 { margin: 0; color: var(--text); font-size: 23px; }
.login-card > p { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; }
.login-card label { margin-top: 5px; color: var(--text); font-size: 13px; font-weight: 600; }
.login-card input {
  width: 100%; box-sizing: border-box; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--radius); font-size: 15px;
  color: var(--text); background: var(--surface); outline: none;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-card .btn-primary { margin-top: 12px; padding: 11px 16px; }
.login-card .btn-primary:disabled { opacity: .65; cursor: wait; }
.login-error { color: var(--danger) !important; margin: 4px 0 0 !important; }
.login-info { color: var(--primary) !important; margin: 4px 0 0 !important; }
.login-card .btn-link {
  margin-top: 8px; background: none; border: none; padding: 4px;
  color: var(--text-muted); font-size: 13px; text-decoration: underline;
  cursor: pointer; text-align: center;
}
.login-card .btn-link:hover { color: var(--primary); }
.login-card .btn-link:disabled { opacity: .65; cursor: wait; }
.session-email {
  margin-top: 4px; color: var(--faint); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.signature-status {
  margin-top: 8px; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface2); font-size: 11px;
  color: var(--text-muted);
}
.signature-status-line { display: flex; align-items: center; gap: 6px; line-height: 1.25; }
.signature-status-dot {
  width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%;
  background: var(--faint);
}
.signature-status.active .signature-status-dot { background: #22a06b; }
.signature-status.warning .signature-status-dot { background: #d99a00; }
.signature-status.error .signature-status-dot { background: var(--danger); }
.signature-status button {
  width: 100%; margin-top: 6px; padding: 5px 8px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); color: var(--primary);
  cursor: pointer; font-size: 11px;
}
.signature-status button:disabled { cursor: not-allowed; opacity: .55; }
.btn-logout {
  width: 100%; margin-top: 7px; padding: 6px 10px; cursor: pointer;
  color: var(--text-muted); background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.btn-logout:hover { background: var(--surface3); color: var(--text); }

.link-curadoria {
  display: block; width: 100%; margin-top: 7px; padding: 6px 10px;
  text-align: center; text-decoration: none; font-size: 12.5px;
  color: var(--text-muted); background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.link-curadoria:hover { background: var(--surface3); color: var(--primary-dark); }

.btn-primary {
  padding: 8px 16px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); font-size: 13px;
  font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  padding: 8px 16px; background: var(--surface); color: var(--primary);
  border: 1px solid var(--primary); border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.btn-secondary:hover { background: var(--primary-light); }

.btn-back {
  padding: 7px 14px; background: none; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; cursor: pointer;
}
.btn-back:hover { background: var(--bg); }

.btn-start-consult { padding: 9px 20px; font-size: 14px; }

.btn-rec-start {
  padding: 7px 14px; background: #22c55e; color: #fff;
  border: none; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-rec-start:hover:not(:disabled)  { background: #16a34a; }
.btn-rec-start:disabled { opacity: .45; cursor: not-allowed; }

.btn-rec-stop {
  padding: 7px 14px; background: #e53e3e; color: #fff;
  border: none; border-radius: var(--radius); font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-rec-stop:hover:not(:disabled) { background: #c0392b; }
.btn-rec-stop:disabled { opacity: .45; cursor: not-allowed; }

.btn-danger-sm {
  padding: 7px 12px; background: none; color: var(--danger);
  border: 1px solid var(--danger); border-radius: var(--radius);
  font-size: 13px; cursor: pointer;
}
.btn-danger-sm:hover { background: #fee2e2; }

.btn-analyze {
  padding: 4px 10px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); font-size: 11px;
  font-weight: 600; cursor: pointer;
}
.btn-analyze:hover { background: var(--primary-dark); }
.btn-analyze-note { display: block; margin-top: 6px; margin-left: auto; }

.consult-safety { --safety-color:#8a640b; display:grid; grid-template-columns:minmax(0,1fr) auto;
  margin:9px 16px 0; border:1px solid var(--safety-color); border-left-width:5px;
  border-radius:10px; background:var(--surface); color:var(--text); box-shadow:var(--shadow); }
.consult-safety.state-normal { --safety-color:#18794e; }
.consult-safety.state-atencao { --safety-color:#9a6b00; border-style:solid; }
.consult-safety.state-degradado { --safety-color:#a84f00; border-style:dashed; border-left-style:solid; }
.consult-safety.state-interromper { --safety-color:#b42318; border-width:2px; border-left-width:7px; }
.safety-summary { min-width:0; display:grid; grid-template-columns:auto minmax(160px,1fr) auto auto;
  align-items:center; gap:10px; border:0; background:transparent; color:inherit; padding:9px 11px;
  text-align:left; cursor:pointer; }
.safety-summary:focus-visible,.safety-quick-actions button:focus-visible,.safety-details button:focus-visible {
  outline:3px solid color-mix(in srgb, var(--safety-color) 45%, transparent); outline-offset:2px; }
.safety-icon { display:grid; place-items:center; width:23px; height:23px; border:2px solid var(--safety-color);
  border-radius:50%; color:var(--safety-color); font-size:11px; font-weight:800; }
.state-degradado .safety-icon { border-radius:4px; }
.state-interromper .safety-icon { border-radius:2px; }
.safety-copy { min-width:0; display:grid; gap:1px; }
.safety-copy strong { color:var(--safety-color); font-size:13px; }
.safety-copy span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11.5px; color:var(--text-muted); }
.safety-expand { color:var(--text-muted); font-size:10.5px; white-space:nowrap; }
.safety-quick-actions { display:flex; align-items:center; padding:7px 9px 7px 0; }
.safety-quick-actions button,.safety-details button { border:1px solid var(--safety-color); border-radius:7px;
  background:transparent; color:var(--safety-color); padding:6px 9px; cursor:pointer; font-weight:650; }
.safety-details { grid-column:1/-1; border-top:1px solid var(--border); padding:10px 12px 12px; }
.safety-dependencies { display:flex; flex-wrap:wrap; gap:6px; }
.safety-resource { display:inline-flex; align-items:center; gap:5px; border:1px solid var(--border);
  border-radius:999px; padding:3px 7px; font-size:10.5px; }
.safety-resource::before { content:'○'; font-weight:800; }
.safety-resource.ok::before { content:'✓'; color:#18794e; }
.safety-resource.warn::before { content:'!'; color:#a84f00; }
.safety-resource.stop::before { content:'×'; color:#b42318; }
.safety-causes { display:grid; gap:6px; margin:9px 0; padding:0; list-style:none; }
.safety-causes li { display:grid; grid-template-columns:auto 1fr; gap:7px; font-size:11.5px; }
.safety-cause-level { min-width:75px; text-transform:uppercase; font-size:9px; font-weight:750; letter-spacing:.04em; }
.safety-support { display:flex; justify-content:space-between; align-items:center; gap:10px;
  padding-top:8px; border-top:1px solid var(--border); color:var(--text-muted); font-size:10.5px; }
.safety-support div { display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.safety-support button { font-size:10.5px; padding:4px 7px; border-color:var(--border); color:var(--text); }
.incident-dialog { width:min(650px, calc(100vw - 28px)); padding:0; border:0; border-radius:14px; }
.incident-dialog::backdrop { background:rgba(15,23,42,.52); }
.safety-contingency-dialog { width:min(620px, calc(100vw - 28px)); padding:0; border:0;
  border-radius:14px; background:var(--surface); color:var(--text); }
.safety-contingency-dialog::backdrop { background:rgba(15,23,42,.52); }
.safety-contingency-content { display:grid; gap:13px; padding:22px; }
.safety-contingency-content ul { margin:0; padding-left:20px; font-size:12px; line-height:1.5; }
.incident-form { display:grid; gap:15px; padding:22px; }
.incident-heading { display:flex; justify-content:space-between; gap:18px; }
.incident-heading strong { font-family:var(--font-serif); font-size:20px; }
.incident-heading p { margin:5px 0 0; color:var(--text-muted); font-size:12px; line-height:1.45; }
.incident-fields { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.incident-form label { display:grid; gap:5px; color:var(--text-muted); font-size:12px; }
.incident-form select,.incident-form textarea { width:100%; padding:9px; border:1px solid var(--border);
  border-radius:8px; background:var(--surface); color:var(--text); }
.incident-actions { display:flex; justify-content:flex-end; gap:8px; }
@media (max-width: 800px) {
  .consult-safety { grid-template-columns:1fr; margin:7px 8px 0; }
  .safety-summary { grid-template-columns:auto minmax(0,1fr); }
  .safety-summary .autosave-status,.safety-expand { grid-column:2; }
  .safety-quick-actions { padding:0 10px 9px 43px; }
  .safety-details { grid-column:1; }
  .safety-support { align-items:flex-start; flex-direction:column; }
  .safety-support div { justify-content:flex-start; }
  .incident-fields { grid-template-columns:1fr; }
}

.btn-upload {
  display: inline-block; margin-top: 8px;
  padding: 6px 12px; background: var(--surface2); color: var(--primary);
  border: 1px dashed var(--primary); border-radius: var(--radius);
  font-size: 12px; cursor: pointer; text-align: center; transition: background .12s;
}
.btn-upload:hover { background: var(--primary-light); }

.doctor-select {
  width: 100%; padding: 7px 10px;
  background: rgba(255,255,255,.07); color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,.15); border-radius: var(--radius);
  font-size: 13px; outline: none; cursor: pointer;
}
.doctor-select option { background: #1a2332; color: #fff; }

/* ── STATES ──────────────────────────────────────────── */
.loading-spinner {
  text-align: center; padding: 32px; color: var(--text-muted);
  font-size: 15px; animation: spin 1.5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted-hint   { color: var(--text-muted); font-size: 13px; }
.error-hint   { color: var(--danger); font-size: 13px; }

/* ── Cirurgias no prontuário ── */
.cir-diags { font-size: 13px; color: var(--text-muted); margin: 0 0 4px; }
.cir-procs { font-size: 13px; color: var(--primary); margin: 0 0 4px; }
.cir-nota  { font-size: 14px; line-height: 1.6; white-space: pre-wrap; margin: 4px 0 0; }

/* ── Lembretes de seguimento ── */
.nav-badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--primary-light); color: var(--primary); font-size: 11px; font-weight: 700;
  text-align: center; margin-left: 4px; }
.nav-badge.vencido { background: var(--danger); color: #fff; }
.lembrete-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.lembrete-card.vencido { border-left-color: var(--danger); }
.lembrete-topo { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.lembrete-data { font-weight: 700; font-variant-numeric: tabular-nums; }
.lembrete-texto { font-size: 14px; line-height: 1.5; margin-bottom: 10px; white-space: pre-wrap; }
.lembretes-colunas { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:18px; align-items:start; }
.lembretes-coluna { min-width:0; }
.lembrete-secao { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: 18px 0 8px; }

/* formulário de novo lembrete */
.lembrete-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; display: grid; gap: 10px; }
.lem-cats { display: flex; gap: 18px; font-size: 14px; }
.lem-form-row { display: flex; gap: 10px; }
.lem-form-row input { flex: 1; }
.lem-campo { display: grid; gap: 4px; font-size: 13px; color: var(--text-muted); }
.lembrete-acoes { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.lembrete-acoes-principais,
.lembrete-acoes-gestao { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.lembrete-acoes-gestao { margin-left:auto; justify-content:flex-end; }
.lembrete-workflow { margin: 0 0 12px; padding: 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px; }
.lembrete-workflow-meta { display:flex; align-items:center; gap:8px 12px; flex-wrap:wrap;
  color:var(--text-muted); font-size:12px; }
.lembrete-workflow-badge { display:inline-flex; padding:3px 8px; border-radius:999px;
  background:var(--primary-light); color:var(--primary); font-size:11px; font-weight:700; }
.lembrete-workflow-badge.status-autorizado,
.lembrete-workflow-badge.status-agendado,
.lembrete-workflow-badge.status-concluido { background:#dcfce7; color:#166534; }
.lembrete-workflow-badge.status-nao_autorizado { background:#fee2e2; color:#991b1b; }
.lembrete-workflow-badge.status-autorizacao_solicitada { background:#fef3c7; color:#92400e; }
.lembrete-workflow-obs { margin-top:8px; font-size:13px; white-space:pre-wrap; }
.lembrete-workflow-editor { display:grid; grid-template-columns:minmax(150px,.8fr) minmax(180px,1.6fr) auto;
  gap:8px; margin-top:10px; }
.lembrete-workflow-editor select,
.lembrete-workflow-editor input { min-width:0; }
.lembrete-historico-btn { margin-top:7px; padding:0; font-size:12px; }
.lembrete-historico { display:grid; gap:6px; margin-top:8px; padding-top:8px;
  border-top:1px solid var(--border); }
.lembrete-historico-item { display:grid; grid-template-columns:130px minmax(110px,.8fr) minmax(100px,1fr);
  gap:4px 10px; color:var(--text-muted); font-size:11px; }
.lembrete-historico-item strong { color:var(--text); }
.lembrete-historico-item div { grid-column:2 / -1; color:var(--text); }

@media (max-width: 900px) {
  .lembretes-colunas { grid-template-columns:1fr; }
}

@media (max-width: 620px) {
  .lembrete-acoes { align-items:stretch; flex-direction:column; }
  .lembrete-acoes-gestao { margin-left:0; justify-content:flex-start; }
  .lembrete-workflow-editor { grid-template-columns:1fr; }
  .lembrete-historico-item { grid-template-columns:1fr; }
  .lembrete-historico-item div { grid-column:auto; }
}
.lem-sug { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lem-sug li { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.lem-sug li:last-child { border-bottom: none; }
.lem-sug li:hover { background: var(--primary-light); }

/* alerta piscando no prontuário */
.lembrete-alerta { display: flex; align-items: center; gap: 12px; background: var(--primary-light);
  border: 1px solid var(--primary); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px;
  animation: lembrete-pisca 1.4s ease-in-out 3; }
.lembrete-alerta.vencido { background: var(--danger-soft); border-color: var(--danger); }
.lembrete-alerta-icone { font-size: 22px; }
.lembrete-alerta-txt { flex: 1; font-size: 14px; }
@keyframes lembrete-pisca { 0%,100% { box-shadow: 0 0 0 0 rgba(56,189,248,.0); } 50% { box-shadow: 0 0 0 4px rgba(56,189,248,.35); } }

/* badge "vence esta semana" perto da worklist */
.agenda-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; padding: 2px 8px;
  border-radius: 999px; background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 700; }
.agenda-badge.vencido { background: #fee2e2; color: var(--danger); }
.raw-output   { font-size: 11px; background: var(--bg); padding: 10px; border-radius: var(--radius); overflow-x: auto; white-space: pre-wrap; }

/* ── TOAST ───────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; z-index: 2000;
  box-shadow: var(--shadow-lg); transition: opacity .3s;
}
.toast.hidden    { display: none; }
.toast-ok        { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.toast-warn      { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.toast-error     { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── SCROLLBARS ──────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0bccc; }

/* ═══════════════════════════════════════════════════════════════════════════
   A32 — Storyboard, ciclo de vida da consulta e Prontuário em 2 colunas.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Storyboard: trilho fino e persistente. Fino de propósito — ele rouba altura
   de todas as telas, então cada pixel precisa se justificar. */
/* Storyboard = CARTÃO VERTICAL no trilho (layout do mockup A32). */
.storyboard {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.sb-identidade { display: flex; align-items: center; gap: 11px; min-width: 0; }
.sb-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--primary), #3AA0A0);
  color: #fff; font-weight: 700; font-size: 15px;
}
.sb-nome-bloco { min-width: 0; }
#sb-nome { display: block; font-size: 17px; line-height: 1.14; }   /* serifa: regra global */
.sb-linha1 { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.sb-linha1 strong { font-size: 15px; }
.sb-chip {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 99px;
}
.sb-chip-conv { background: var(--primary-light); color: var(--primary-dark); border-color: transparent; }
.sb-demografia { display:flex; flex-direction:column; border-top:1px solid var(--border); }
.sb-demog-row { display:grid; grid-template-columns:76px minmax(0,1fr); gap:7px; padding:5px 2px; border-bottom:1px solid var(--border); font-size:11.5px; }
.sb-demog-key { color:var(--text-muted); text-align:left; }
.sb-demog-value { color:var(--text); font-weight:550; overflow-wrap:anywhere; text-align:right; }
.sb-demog-value.sb-copiavel { cursor:pointer; }
.sb-peso-input { width:64px; border:1px solid var(--border); border-radius:5px; padding:2px 5px; background:var(--surface2); color:var(--text); font-size:11.5px; font-weight:600; text-align:right; }
.sb-peso-input:focus { outline:none; border-color:var(--primary); }
.sb-sep { display: none; }

.sb-clinico { padding-top:2px; }
.sb-section-label { display:block; margin-bottom:5px; font-size:10.5px; font-weight:750; color:var(--text-muted); text-transform:uppercase; letter-spacing:.05em; }
.sb-section-value { font-size:11.5px; color:var(--text-muted); }
.sb-alertas { display:flex; flex-direction:column; gap:5px; }
.sb-alerta { border:1px solid var(--border); border-left:3px solid var(--warn); border-radius:7px; padding:6px 7px; font-size:11.5px; background:var(--warn-soft); color:var(--text); }
.sb-alerta.neutro { border-left-color:var(--primary); background:var(--primary-light); }
.sb-sem-alertas { color:var(--text-muted); font-size:11.5px; font-style:italic; }

/* Alergia: cor de alerta, largura total — é o dado cuja ausência causa dano. */
.sb-alergias { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sb-alergias-ativas {
  width: 100%; background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: 8px; padding: 7px 9px;
}
.sb-alerg-rot { display: block; font-size: 10.5px; font-weight: 700; color: var(--danger); letter-spacing: .04em; margin-bottom: 4px; }
.sb-alerg-tag {
  font-size: 11.5px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger); padding: 1px 7px; border-radius: 99px;
}
.sb-alerg-nenhuma { font-size: 11.5px; color: var(--text-muted); font-style: italic; }

/* Ciclo de vida: botões grandes (§4.10 pediu "facilmente visíveis") e um por
   estado — mostrar Pausar e Retomar juntos obrigaria a ler qual está ativo. */
.btn-ciclo {
  font-size: 13.5px; font-weight: 600; padding: 9px 18px; cursor: pointer;
  border: none; border-radius: 7px; color: #fff;
}
.btn-ciclo-gravar { background: #1a7f37; }
.record-start-dot { color:#ef4444; margin-right:2px; }
.btn-ciclo-pausar { background: #b45309; }
.btn-ciclo-retomar { background: #1a7f37; }
.btn-ciclo-pausar-consulta { background:var(--surface); color:#9a4d08; border:1px solid #c87925; }
.btn-ciclo-cancelar { background:var(--surface); color:var(--danger); border:1px solid var(--danger); font-size:11px; padding:7px 10px; }
.btn-ciclo-finalizar { background: var(--primary-dark, #084d93); }
.btn-mobile-pair { background:var(--surface); color:var(--primary-dark); border:1px solid var(--primary); }
.btn-ciclo:hover { filter: brightness(1.1); }
.rec-dot.pausado { color: #b45309; font-weight: 600; }

/* MVP-31 — QR companion: grande o bastante para leitura a uma distância
   confortável, sem exibir o token opaco como texto copiável. */
.mobile-pair-box { width:min(450px,94vw); }
.mobile-pair-box .modal-header p { margin:3px 0 0; font-size:11px; color:var(--text-muted); }
.mobile-pair-body { display:flex; flex-direction:column; align-items:center; text-align:center; gap:11px; }
.mobile-pair-loading { min-height:270px; display:grid; place-items:center; color:var(--text-muted); }
.mobile-pair-qr { width:min(280px,75vw); height:min(280px,75vw); padding:9px; background:#fff; border:1px solid var(--border); border-radius:14px; }
.mobile-pair-body>p { margin:0; max-width:360px; color:var(--text-muted); font-size:12px; line-height:1.4; }
.mobile-pair-context { max-width:360px; color:var(--text); font-size:12px; font-weight:600; }
.mobile-pair-actions { display:flex; justify-content:center; gap:8px; margin-top:5px; }
.exam-origin { display:inline-block; margin-left:5px; padding:1px 6px; border-radius:999px; background:var(--primary-light); color:var(--primary-dark); font-size:9px; font-weight:700; text-transform:uppercase; }

/* Prontuário: esquerda = o que muda a cada encontro; direita = ficha estável.
   Proporção 3:2 porque a linha do tempo é o que mais se lê. */
.pront-grid {
  display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start;
}
.pront-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pront-bloco {
  background: var(--surface, #fff); border: 1px solid var(--border, #e3e6ea);
  border-radius: 10px; padding: 14px 16px;
}
.pront-h {
  margin: 0 0 10px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted, #6b7280);
}
.pront-timeline {
  /* Quatro cartões recolhidos (≈ 72 px cada); o histórico cresce para dentro
     com scroll, sem empurrar "Exames e resultados" para fora da tela. */
  max-height: min(42vh, 304px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 5px;
}
.pront-exames, .pront-lista { max-height: 30vh; overflow-y: auto; font-size: 13.5px; }
.pront-lista li { margin: 3px 0; }

/* Central de Documentos (MVP-24): timeline + detalhe sem exibir UUIDs. */
.emit-lista { display: flex; flex-direction: column; gap: 6px; }
.emit-atalhos { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:9px; }
.emit-atalhos button { border:1px solid var(--border); border-radius:999px; background:var(--surface); color:var(--text); padding:5px 10px; cursor:pointer; font-size:11px; }
.emit-atalhos button.active { background:var(--primary); border-color:var(--primary); color:#fff; }
.emit-filtros { display:flex; align-items:end; flex-wrap:wrap; gap:8px; margin-bottom:10px; }
.emit-filtros label { display:flex; flex-direction:column; gap:3px; font-size:11px; color:var(--text-muted); }
.emit-filtros input, .emit-filtros select { padding:6px 8px; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text); }
.emit-filtros .emit-busca { min-width:180px; flex:1; }
.emit-filtros .btn-imprimir { margin-left:auto; }
.emit-central { display:grid; grid-template-columns:minmax(260px,.9fr) minmax(300px,1.1fr); gap:10px; align-items:start; }
.emit-dia { margin:7px 2px 1px; font-size:11px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.04em; }
.emit-date-group { border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.emit-date-group > summary { cursor:pointer; padding:8px 10px; background:var(--surface2); color:var(--text); font-size:12.5px; font-weight:650; }
.emit-date-group > summary span { color:var(--text-muted); font-weight:400; margin-left:4px; }
.emit-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  border-top: 1px solid var(--border, #e3e6ea); padding: 8px 11px;
  font-size:12.5px;
}
.emit-item-button { width:100%; text-align:left; color:var(--text); background:var(--surface); border:1px solid var(--border); border-left-width:3px; border-radius:7px; cursor:pointer; }
.emit-item-button:hover, .emit-item-button:focus-visible { border-color:var(--primary); outline:none; background:var(--surface2); }
.estado-borda-cancelado { border-left-color:var(--danger); opacity:.8; }
.estado-borda-substituido { border-left-color:#aa8500; }
.estado-borda-enviado { border-left-color:#18794e; }
.emit-data { font-size: 12.5px; color: var(--text-muted, #6b7280); margin-top: 1px; }
.emit-abrir {
  font-size: 12px; padding: 4px 12px; cursor: pointer;
  border: 1px solid var(--primary, #0b6bcb); color: var(--primary, #0b6bcb);
  background: var(--surface, #fff); border-radius: 5px;
}
.emit-acoes { display:flex; align-items:center; justify-content:flex-end; gap:5px; flex-wrap:wrap; }
.emit-sec { font-size:11px; padding:4px 7px; cursor:pointer; border:1px solid var(--border); color:var(--text); background:var(--surface); border-radius:5px; }
.emit-cancelar { color:var(--danger, #b42318); }
.emit-meta { display:flex; gap:7px; align-items:center; flex-wrap:wrap; margin-top:3px; color:var(--text-muted); font-size:10.5px; }
.emit-estado { padding:1px 6px; border-radius:10px; background:var(--surface2); font-weight:650; }
.estado-enviado, .emit-assinatura.ok { color:#18794e; background:#e9f7ef; }
.estado-cancelado { color:#b42318; background:#fff0ee; }
.estado-substituido { color:#765b00; background:#fff8d8; }
.estado-rascunho { color:#46505a; background:#edf0f3; }
.emit-assinatura { padding:1px 6px; border-radius:10px; }
.emit-entrega-falhou { color:var(--danger); border:1px solid var(--danger); border-radius:10px; padding:1px 6px; font-weight:650; }
.emit-motivo { margin-top:4px; color:var(--text-muted); font-size:10.5px; max-width:58ch; }
.emit-sem { font-size: 11.5px; color: var(--text-muted, #6b7280); font-style: italic; }
.emit-detalhe { border:1px solid var(--border); border-radius:9px; padding:12px; background:var(--surface); position:sticky; top:0; max-height:calc(100vh - 220px); overflow:auto; }
.emit-detail-head { display:flex; justify-content:space-between; align-items:start; gap:8px; }
.emit-detail-head h2 { font-size:17px; margin:6px 0 10px; }
.emit-ficha { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:0; }
.emit-ficha div { padding:7px; border-radius:6px; background:var(--surface2); }
.emit-ficha dt { color:var(--text-muted); font-size:10px; text-transform:uppercase; }
.emit-ficha dd { margin:2px 0 0; font-size:12px; }
.emit-detail-actions { display:flex; flex-wrap:wrap; gap:6px; margin:11px 0; }
.emit-detail-actions button { width:auto; }
.emit-versoes { display:flex; flex-direction:column; gap:5px; }
.emit-versao { text-align:left; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text); padding:6px 8px; cursor:pointer; }
.emit-versao.active { border-color:var(--primary); background:var(--primary-light); }
.emit-versao small, .emit-entregas small { display:block; color:var(--text-muted); margin-top:2px; }
.emit-entregas { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:5px; font-size:12px; }
.emit-entregas li { border-bottom:1px solid var(--border); padding:5px 0; }
.emit-preview-note { font-size:10.5px; color:var(--text-muted); display:flex; align-items:center; justify-content:space-between; gap:8px; }
#emit-preview iframe { width:100%; height:360px; border:1px solid var(--border); border-radius:6px; margin:6px 0; background:#fff; }
.document-dialog { width:min(460px,calc(100vw - 32px)); border:1px solid var(--border); border-radius:10px; background:var(--surface); color:var(--text); padding:18px; }
.document-dialog::backdrop { background:rgba(20,30,40,.48); }
.document-dialog form, .document-dialog label { display:flex; flex-direction:column; gap:7px; }
.document-dialog textarea { padding:9px; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text); resize:vertical; }
.document-dialog .document-check { flex-direction:row; align-items:center; margin:8px 0; }
.document-dialog-actions { display:flex; justify-content:flex-end; gap:7px; margin-top:13px; }
.form-error { color:var(--danger); font-size:12px; min-height:1em; }

@media (max-width: 1200px) {
  .pront-grid { grid-template-columns: 1fr; }
  .orl-regions { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width: 1100px) {
  .orl-exam-body { grid-template-columns:1fr; }
  .orl-narrative-panel { position:static; }
}

@media (max-width: 760px) {
  .patient-toolbar { position:static; margin:-24px -24px 16px; padding:10px 12px; }
  .patient-docbar { display:grid; grid-template-columns:1fr 1fr; flex:1; }
  .patient-docbar button { padding:6px; font-size:11px; }
  .emit-central { grid-template-columns:1fr; }
  .emit-detalhe { position:static; max-height:none; }
  .orl-exam-body { grid-template-columns:1fr; padding:12px; }
  .orl-clinical-fields { grid-template-columns:1fr; }
  .orl-regions { grid-template-columns:1fr; }
  .orl-endoscopy-notes { grid-template-columns:1fr; }
  .orl-config-grid { grid-template-columns:1fr; padding:12px; }
  .orl-config-intro { flex-direction:column; padding:12px; }
  .orl-exam-head { flex-wrap:wrap; }
  .orl-narrative-panel { position:static; }
  .orl-exam-head, .orl-exam-actions { padding:12px; }
  .orl-exam-actions { align-items:flex-start; flex-direction:column; }
  .orl-exam-actions > div { width:100%; justify-content:flex-end; }
  .orl-selected { grid-template-columns:1fr; }
}

@media (max-width: 1050px) {
  .consult-grid { grid-template-columns:1fr; height:auto; }
  .panel { min-height:420px; }
  .hist-links-line, .hist-expanded { margin-left:0; padding-left:7px; }
}
