/* ============================================================
   App Endoscopia — styles.css v1.2
   iPad Pro landscape-first. Touch-first. Print-friendly.
   Design system upgrade with Inter font, refined colors, new screen system.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Montserrat:wght@600;700;800;900&display=swap');

:root {
  /* Força controles nativos (datalist/select/date) em tema CLARO. Sem isto, o Safari
     com o macOS em dark mode renderiza o popup do datalist em escuro sobre a página
     clara → texto ilegível (bug do dropdown de Convênio, 2026-06-06). O app é só light. */
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --ink: #1a1f2e;
  --ink-soft: #5a6578;
  --line: #e2e6eb;
  --brand: #0052cc;
  --brand-light: #e6f0ff;
  --brand-ink: #ffffff;
  --warn: #d97706;
  --danger: #dc2626;
  --ok: #16a34a;
  --colono: #16a34a;
  --eda: #0052cc;
  --radius: 8px;
  --radius-sm: 5px;
  --pad: 14px;
  --font: 'Gotham', 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 14px;
  --fs-sm: 12px;
  --fs-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,.08);
  --transition: .15s ease;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs)/1.35 var(--font);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* ========== Screen system (agenda vs exam) ========== */
/* SEM !important — inline styles do JS precisam funcionar */
.screen { display: none; }
.screen.active { display: block; }

/* Agenda: scroll livre */
#screen_agenda,
#screen_agenda.active {
  max-width: 1200px;
  margin: 0 auto;
}
#screen_agenda.active {
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 20px 24px;
}

/* Exame: grid de 3 colunas fixo */
#screen_exame.active {
  grid-template-columns: 200px 1fr 280px;
  gap: 0;
  height: calc(100vh - 52px);
  overflow: hidden;
}
/* display do exame é grid — setado via JS inline style */

/* E10 — Screens admin (mestres/vigilância/config): scroll confinado à viewport
   Sem height:calc + overflow, conteúdo extenso (tabelas de pacientes, listas de
   vigilância) transborda o body e scroll global não alcança o rodapé. */
#screen_mestres.active,
#screen_vigilancia.active,
#screen_config.active {
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 20px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ========== Top bar ========== */
/* ══════════════════════════════════════════════════
   TOPBAR — redesign v2
   ══════════════════════════════════════════════════ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 48px; padding: 6px 14px;
  background: #17202a; color: #fff;
  border-bottom: 1px solid #0d1419;
}
.tb-left { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.tb-center { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tb-right { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }

.tb-context { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-nome { font-weight: 600; font-size: 14px; color: #fff; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; }
.tb-tipo-pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; background: var(--brand); color: #fff; }
.tb-data { font-size: 12px; color: #a0aec0; white-space: nowrap; }

.tb-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 600; }
.tb-pill--muted { background: rgba(255,255,255,.1); color: #94a3b8; }
.tb-pill--ok { background: #059669; color: #fff; }
.tb-pill--warn { background: #d97706; color: #fff; }

.tb-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border: none; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all .12s; color: #fff; }
.tb-btn--back { background: rgba(255,255,255,.08); }
.tb-btn--back:hover { background: rgba(255,255,255,.15); }
/* "← Exame": atalho de retorno ao exame aberto (a partir de Banco/Config/etc.) — destaque âmbar. */
.tb-btn--exame { background: #d97706; }
.tb-btn--exame:hover { background: #b45309; }
.tb-btn--save { background: #2563eb; }
.tb-btn--save:hover { background: #1d4ed8; }
.tb-btn--sign { background: #059669; }
.tb-btn--sign:hover { background: #047857; }
.tb-btn--pdf { background: rgba(255,255,255,.1); }
.tb-btn--pdf:hover { background: rgba(255,255,255,.18); }
.tb-btn--new { background: #f59e0b; color: #1a1a1a; }
.tb-btn--new:hover { background: #d97706; }
.tb-btn--more { background: rgba(255,255,255,.08); font-size: 16px; padding: 4px 10px; }
.tb-btn--more:hover { background: rgba(255,255,255,.15); }

/* ── Laudo cards ── */
.laudo-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.laudo-card-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 14px; font-weight: 700; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.laudo-card-head--eda { background: #eff6ff; color: #1e40af; }
.laudo-card-head--colono { background: #ecfdf5; color: #065f46; }
.laudo-card--tech .laudo-card-head { background: #f8fafc; color: var(--ink); }
.laudo-card-hint { margin-left: auto; font-size: 10px; font-weight: 500; color: var(--ink-soft); }
.laudo-card-icon { font-size: 14px; }
.laudo-card-status { margin-left: auto; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #fef3c7; color: #92400e; }
.laudo-card-status.done { background: #d1fae5; color: #065f46; }
.laudo-card-body { padding: 14px 16px; }
.laudo-field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 10px; }
.laudo-field-label .hint { display: block; font-size: 11px; font-weight: 400; color: #94a3b8; margin-top: 2px; margin-bottom: 4px; }
.laudo-textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit; resize: vertical; background: var(--surface); box-sizing: border-box; }
.laudo-textarea--full { min-height: 200px; }
.laudo-preview { background: #fafbfc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px 16px; margin-bottom: 10px; max-height: 400px; overflow-y: auto; }
.laudo-preview-text { font-size: 13px; line-height: 1.7; white-space: pre-wrap; color: var(--ink); font-family: 'Georgia', serif; }
.laudo-card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 1px solid #f1f5f9; align-items: center; }
/* F6 — toggle compacto + hint (tela; escondidos na impressão) */
.laudo-compact-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #555; margin-left: 4px; cursor: pointer; user-select: none; }
.laudo-compact-toggle input { margin: 0; cursor: pointer; }
.laudo-compact-hint { flex-basis: 100%; margin-top: 6px; padding: 6px 10px; background: #fff6d6; border-left: 3px solid #d4a017; color: #5c4a1a; font-size: 12px; border-radius: 3px; }
.laudo-tech-actions { display: flex; gap: 6px; margin-top: 8px; }
.laudo-edit-wrap { margin-bottom: 10px; }

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: .02em;
  background: #2c3947;
  color: #cfd8dc;
}
.pill-warn { background: var(--warn); color: #fff; }
.pill-ok { background: var(--ok); color: #fff; }
.pill-muted { background: #44525f; color: #cfd8dc; }

.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #2c3947;
  background: #22303f;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s ease;
  min-height: 40px;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { filter: brightness(0.9); }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-warn { background: var(--warn); border-color: var(--warn); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-small { height: 28px; padding: 0 8px; font-size: 12px; }

/* Dropdown menus */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-content,
.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 100;
  overflow: hidden;
}
.dropdown-content.show,
.dropdown-menu.show { display: block; }
.dropdown-content button,
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.dropdown-content button:last-child,
.dropdown-menu button:last-child { border-bottom: none; }
.dropdown-content button:hover,
.dropdown-menu button:hover { background: var(--surface-2); }

/* ========== Layout ========== */
/* .layout é apenas um wrapper de telas — NÃO deve ser grid.
   O grid de 3 colunas fica em #screen_exame.active */
.layout {
  display: block;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* Sidenav */
.sidenav {
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
  padding: 10px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  text-align: left;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--transition);
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}
.nav-item.has-alert::after {
  content: "●";
  color: var(--warn);
  margin-left: 6px;
}
.nav-item.tab-colono { border-left: 3px solid var(--colono); }
.nav-item.tab-eda { border-left: 3px solid var(--eda); }
.nav-item.tab-hidden { display: none; }

/* Content area */
.content {
  overflow-y: auto;
  padding: 16px 20px 40px;
  background: var(--bg);
}

/* Seções do exame: só a ativa é visível (via goToSection) */
#screen_exame .block { display: none; }
#screen_exame .block.active { display: block; }
/* Fora do exame (agenda), .block é sempre visível */

.block h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--brand);
  padding-bottom: 6px;
}

.block h3 {
  margin: 20px 0 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

/* Grid layouts */
.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  #screen_exame.active { grid-template-columns: 180px 1fr; }
  .rightpane { display: none; }
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Form elements */
label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

input, select, textarea {
  font: var(--fs) var(--font);
  height: 38px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  height: auto;
  padding: 8px 14px;
  resize: vertical;
  min-height: 60px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 82, 204, .12);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--ink-soft);
}

.field-default {
  border-style: dashed;
  border-color: var(--warn);
  background: #fffbeb;
}

/* Vitals table */
.vitals {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.vitals th, .vitals td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.vitals thead th {
  background: var(--surface-2);
  font-weight: 600;
}
.vitals tbody th {
  background: var(--surface-2);
  font-weight: 500;
  width: 150px;
}
.vitals td input { height: 36px; }

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.chip {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.chip.on {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.chip:active { transform: scale(0.96); }
.chips-lg .chip { height: 44px; font-size: 14px; }

/* Segment chips for alt_mucosa */
.seg-chips { gap: 5px; }
.seg-chips .chip-seg {
  height: 30px; padding: 0 10px; font-size: 12px;
  border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: all var(--transition);
}
.seg-chips .chip-seg.on {
  background: #16a34a; color: #fff; border-color: #16a34a; font-weight: 600;
}

/* Cards (lesions, bottles, events) */
.list-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}
.card-title { font-size: 14px; }
.card-id {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
}
.card-head button { margin-left: auto; }

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 6px;
}
.btngrp {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hint {
  color: var(--ink-soft);
  font-size: 12.5px;
  margin: 4px 0 10px;
}

/* Collapsible details element */
details.collapsible { margin: 8px 0; }
details.collapsible summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
  padding: 6px 0;
  user-select: none;
}
details.collapsible summary:hover { text-decoration: underline; }
details.collapsible[open] summary { margin-bottom: 8px; }

/* Anesthetic chart */
.chart-container {
  margin: 16px 0;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
#chart_anestesico {
  width: 100%;
  height: 300px;
  display: block;
}

/* ══════════════════════════════════════════════════
   AGENDA OPERACIONAL
   ══════════════════════════════════════════════════ */

/* ── Header ── */
.ag-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.ag-header-left { display: flex; align-items: baseline; gap: 12px; }
.ag-title { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); }
.ag-date-display { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.ag-header-right { display: flex; gap: 8px; }

/* ── Buttons ── */
.ag-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.ag-btn--primary { background: var(--brand); color: #fff; }
.ag-btn--primary:hover { background: var(--brand-dark, #1e40af); }
.ag-btn--success { background: #059669; color: #fff; }
.ag-btn--success:hover { background: #047857; }
.ag-btn--outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.ag-btn--outline:hover { background: var(--surface-2); }
.ag-btn--danger { background: #ef4444; color: #fff; }
.ag-btn--danger:hover { background: #dc2626; }
.ag-btn--sm { padding: 5px 10px; font-size: 11px; }
.ag-btn--full { width: 100%; }
.ag-btn:disabled { opacity: .45; pointer-events: none; }

/* ── KPI Bar ── */
.ag-kpi-bar { display: flex; gap: 8px; padding: 8px 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ag-kpi { display: flex; flex-direction: column; align-items: center; min-width: 90px; padding: 10px 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; transition: all .15s; }
.ag-kpi:hover, .ag-kpi.active { border-color: var(--brand); background: var(--brand-light, #eff6ff); }
.ag-kpi-num { font-size: 22px; font-weight: 700; line-height: 1.1; color: var(--ink); }
.ag-kpi-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin-top: 2px; }
.ag-kpi--green { border-color: #a7f3d0; }
.ag-kpi--green .ag-kpi-num { color: #059669; }
.ag-kpi--green:hover, .ag-kpi--green.active { background: #ecfdf5; border-color: #059669; }
.ag-kpi--amber { border-color: #fde68a; }
.ag-kpi--amber .ag-kpi-num { color: #d97706; }
.ag-kpi--amber:hover, .ag-kpi--amber.active { background: #fffbeb; border-color: #d97706; }
.ag-kpi--red { border-color: #fecaca; }
.ag-kpi--red .ag-kpi-num { color: #dc2626; }
.ag-kpi--red:hover, .ag-kpi--red.active { background: #fef2f2; border-color: #dc2626; }

/* ── Toolbar ── */
.ag-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 20px; gap: 12px; border-bottom: 1px solid var(--line); }
.ag-period-tabs { display: flex; gap: 4px; }
.ag-tab { padding: 6px 14px; border: none; border-radius: 6px; background: transparent; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: all .12s; }
.ag-tab:hover { background: var(--surface-2); }
.ag-tab--active { background: var(--brand); color: #fff; }
.ag-toolbar-right { display: flex; gap: 8px; align-items: center; }
.ag-date-input, .ag-search-input, .ag-sort-select { height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: var(--surface); }
.ag-search-input { width: 200px; }
.ag-date-input { width: 140px; }

/* ── Turno sections ── */
.ag-body { padding: 0 20px 20px; overflow-y: auto; max-height: calc(100vh - 230px); }
.ag-turno { margin-top: 16px; }
.ag-turno-head { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 2px solid var(--line); margin-bottom: 6px; }
.ag-turno-icon { font-size: 16px; }
.ag-turno-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.ag-turno-count { font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--ink-soft); padding: 2px 8px; border-radius: 999px; }

/* ── Row cards ── */
.ag-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; transition: all .12s; border-left: 4px solid transparent; }
.ag-row:hover { background: #f8fafc; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.ag-row--green { border-left-color: #10b981; }
.ag-row--amber { border-left-color: #f59e0b; }
.ag-row--red { border-left-color: #ef4444; }
.ag-row--grey { border-left-color: #9ca3af; }

.ag-row-hora { font-size: 13px; font-weight: 700; color: var(--ink); min-width: 42px; text-align: center; }
.ag-row-nome { font-size: 13px; font-weight: 600; color: var(--ink); flex: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-row-age { font-size: 11px; color: var(--ink-soft); min-width: 60px; }
.ag-row-tipo { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.ag-row-tipo[data-t="EDA"] { background: #dbeafe; color: #1d4ed8; }
.ag-row-tipo[data-t="COLONO"] { background: #d1fae5; color: #065f46; }
.ag-row-tipo[data-t="EDA+COLONO"] { background: #ede9fe; color: #5b21b6; }
.ag-row-conv { font-size: 11px; color: var(--ink-soft); min-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-row-status { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.ag-row-status--green { background: #d1fae5; color: #065f46; }
.ag-row-status--amber { background: #fef3c7; color: #92400e; }
.ag-row-status--red { background: #fee2e2; color: #991b1b; }
.ag-row-status--grey { background: #f3f4f6; color: #6b7280; }

/* 2026-07-10 — exame travado: tag do status em DESTAQUE no lugar do botão "Abrir"
   (buildAgRow, app.js). Paleta âmbar do .ag-row-status--amber invertida; mesmo
   footprint do .ag-btn--sm para não desalinhar a coluna de ações. */
.ag-locktag { display: inline-flex; align-items: center; justify-content: center; padding: 5px 10px; border-radius: 8px; background: #92400e; color: #fef3c7; font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; cursor: default; }

.ag-row-flags { display: flex; gap: 4px; min-width: 60px; }
.ag-flag { font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.ag-flag--sig { background: #fef3c7; color: #92400e; }
.ag-flag--pdf { background: #e0e7ff; color: #3730a3; }
.ag-flag--ap { background: #fce7f3; color: #9d174d; }

.ag-row-actions { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.ag-row-actions .ag-btn { padding: 4px 8px; font-size: 10px; }

/* ── Empty state ── */
.ag-empty { text-align: center; padding: 60px 20px; }
.ag-empty-icon { font-size: 48px; margin-bottom: 12px; }
.ag-empty-text { font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.ag-empty-hint { font-size: 13px; color: var(--ink-soft); }

/* ── Pagination ── */
.ag-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 0; }
.ag-page-info { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

/* ── Drawer ── */
.ag-drawer { position: fixed; top: 0; right: -420px; width: 400px; max-width: 90vw; height: 100vh; background: var(--surface); box-shadow: -4px 0 20px rgba(0,0,0,.15); z-index: 900; display: flex; flex-direction: column; transition: right .25s ease; }
.ag-drawer.open { right: 0; }
.ag-drawer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 899; display: none; }
.ag-drawer-overlay.open { display: block; }
.ag-drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.ag-drawer-title { margin: 0; font-size: 16px; font-weight: 700; }
.ag-drawer-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #94a3b8; padding: 4px 8px; border-radius: 4px; }
.ag-drawer-close:hover { background: var(--surface-2); color: var(--ink); }
.ag-drawer-body { flex: 1; overflow-y: auto; padding: 14px 18px; }
.ag-drawer-section { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f1f5f9; }
.ag-drawer-section:last-child { border-bottom: none; }
.ag-drawer-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 8px; }
.ag-drawer-patient { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.ag-drawer-meta { font-size: 12px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 8px; }
.ag-drawer-meta span { display: inline-flex; align-items: center; gap: 4px; }
.ag-drawer-clinical { font-size: 12px; line-height: 1.7; color: var(--ink); }
.ag-drawer-clinical .drow { display: flex; gap: 6px; }
.ag-drawer-clinical .dlabel { font-weight: 600; color: var(--ink-soft); min-width: 100px; flex-shrink: 0; }
.ag-drawer-clinical .dval { color: var(--ink); }
.ag-drawer-laudo { font-size: 13px; line-height: 1.6; color: var(--ink); background: #f8fafc; padding: 10px 12px; border-radius: 8px; border: 1px solid #e2e8f0; }
.ag-drawer-pendencias { display: flex; flex-direction: column; gap: 4px; }
.ag-drawer-pend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.ag-drawer-pend-item--ok { background: #ecfdf5; color: #065f46; }
.ag-drawer-pend-item--warn { background: #fffbeb; color: #92400e; }
.ag-drawer-pend-item--bad { background: #fef2f2; color: #991b1b; }
.ag-drawer-actions { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ── Modal cadastro rápido ── */
.ag-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: none; align-items: center; justify-content: center; }
.ag-modal-overlay.open { display: flex; }
.ag-modal { background: #fff; border-radius: 12px; width: 500px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.ag-modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.ag-modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.ag-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #94a3b8; }
.ag-modal-body { padding: 16px 20px; }
.ag-modal-footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.ag-form-row { margin-bottom: 12px; }
.ag-form-row--2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ag-form-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.ag-form-input { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; background: var(--surface); width: 100%; box-sizing: border-box; }

/* Vigilância table */
.vigil-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 12.5px;
}
.vigil-table th, .vigil-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.vigil-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

/* Right pane */
.rightpane {
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
  overflow-y: auto;
}

.pane-block {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}
.pane-block h4 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
}

.alerts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.alerts li {
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fff5e6;
  border: 1px solid #f0c088;
  color: #8a4e0c;
}
.alerts li.err {
  background: #ffecec;
  border-color: #f0a0a0;
  color: #8a1c1c;
}
.alerts li.ok {
  background: #edf7ee;
  border-color: #a7d4ad;
  color: #2e5c33;
}

/* --- Sidebar operational enhancements --- */
.pane-block--case {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border-bottom: 2px solid #93c5fd;
  padding: 10px 12px;
}
.side-case-name {
  font-size: 14px; font-weight: 700; color: #0c4a6e;
  text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-case-meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; font-size: 11px; color: #475569; }
.side-case-sub { display: flex; gap: 8px; align-items: center; margin-top: 2px; font-size: 10px; color: #64748b; }

.side-clinical { font-size: 11px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.side-clin-row { display: flex; justify-content: space-between; gap: 6px; }
.side-clin-row span:first-child { color: #64748b; }
.side-clin-row span:last-child { font-weight: 600; }
.side-clin-row--warn span:last-child { color: #dc2626; }

.side-lesoes { display: flex; flex-direction: column; gap: 3px; }
.side-les-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 3px 6px;
  background: #f8fafc; border-radius: 4px; cursor: pointer;
  transition: background .12s;
}
.side-les-row:hover { background: #e0f2fe; }
.side-les-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.side-les-badge--polipo { background: #dbeafe; color: #1d4ed8; }
.side-les-badge--lst { background: #ede9fe; color: #7c3aed; }
.side-les-badge--massa { background: #fee2e2; color: #dc2626; }
.side-les-badge--alt_mucosa { background: #dcfce7; color: #16a34a; }
.side-les-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-les-ap { font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 999px; background: #dbeafe; color: #1e40af; }

.side-val-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.side-val-header h4 { margin: 0; flex: 1; }
.side-btn-next {
  border: 1px solid var(--line); background: #fff; border-radius: 4px;
  font-size: 12px; padding: 2px 8px; cursor: pointer; font-weight: 700;
}
.side-btn-next:hover { background: var(--brand); color: #fff; }

.side-val-filters { display: flex; gap: 3px; margin-bottom: 4px; }
.side-val-filter {
  border: 1px solid var(--line); background: #fff; border-radius: 4px;
  font-size: 10px; padding: 2px 6px; cursor: pointer;
}
.side-val-filter.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.side-alerts { max-height: 350px; overflow-y: auto; }
.side-alerts li { cursor: pointer; transition: background .12s; font-size: 11px; padding: 5px 7px; }
.side-alerts li:hover { filter: brightness(0.95); }
.side-alerts li.val-bloqueio { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.side-alerts li.val-forte { background: #fff7ed; border-color: #fdba74; color: #9a3412; }
.side-alerts li.val-leve { background: #fefce8; border-color: #fde047; color: #854d0e; }
.side-alerts li.val-info { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

.pane-block--meta { padding: 6px 10px; }

/* Highlight flash for navigated fields */
@keyframes field-highlight {
  0% { box-shadow: 0 0 0 3px rgba(14,165,233,.6); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.field-highlight {
  animation: field-highlight 1.5s ease-out;
}

.summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
}
.summary > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.summary code {
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Signature */
.signature-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.sigpad {
  width: 100%;
  max-width: 100%;
  height: 180px;
  background: #fafbfc;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  display: block;
  margin: 8px 0;
  touch-action: none;
}

/* Drafts table */
.drafts {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.drafts th, .drafts td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.drafts thead th { background: var(--surface-2); font-weight: 600; }
.drafts td code { font-size: 11px; color: var(--ink-soft); }
.drafts td .btngrp .btn { height: 28px; font-size: 12px; }

/* ========== Theme badges EDA vs COLONO ========== */
.theme-eda {
  border-left: 3px solid var(--eda);
  padding-left: 12px;
}
.theme-colono {
  border-left: 3px solid var(--colono);
  padding-left: 12px;
}

.organ-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .03em;
  color: #fff;
}
.organ-eda { background: var(--eda); }
.organ-colono { background: var(--colono); }

.organ-bar {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  color: #fff;
  font-size: 12.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.organ-bar.organ-eda { background: var(--eda); }
.organ-bar.organ-colono { background: var(--colono); }

/* ========== Catálogo (Cadastros) ========== */
.catlist {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 360px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.catlist li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.catlist li:last-child { border-bottom: none; }
.catlist li input { flex: 1; height: 30px; font-size: 13px; }
.catlist li .btn { height: 28px; padding: 0 8px; font-size: 12px; }

/* ========== Preview laudo paciente ========== */
.preview {
  margin-top: 10px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: 14px/1.55 "SF Pro Text", Georgia, serif;
  white-space: pre-wrap;
  color: #222;
  min-height: 120px;
}
.preview.empty {
  color: var(--ink-soft);
  font-style: italic;
}

/* ========== Print (two modes) ========== */
.print-only { display: none; }

/* Relatório técnico padrão */
.print-relatorio {
  font: 13px/1.45 var(--font);
  color: #000;
}
.print-relatorio h1 {
  font-size: 18px;
  margin: 0 0 6px;
}
.print-relatorio h3 {
  font-size: 13px;
  margin: 10px 0 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid #333;
}
.print-relatorio section {
  page-break-inside: avoid;
  margin-bottom: 8px;
}
.print-relatorio .chart-section {
  page-break-inside: avoid;
}

/* Laudo paciente */
.print-paciente {
  font: 14px/1.6 "SF Pro Text", Georgia, serif;
  color: #111;
}
.print-paciente h1 {
  font-size: 20px;
  text-align: center;
  margin: 0 0 4px;
}
.print-paciente .laudo-hdr {
  text-align: center;
  font-size: 12px;
  color: #444;
  margin-bottom: 12px;
}
.print-paciente .laudo-body { white-space: pre-wrap; }
.print-paciente .laudo-sig {
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  gap: 30px;
}
.print-paciente .laudo-sig .sig-box {
  flex: 1;
  text-align: center;
}
.print-paciente .laudo-sig img {
  height: 60px;
  max-width: 220px;
}
.print-paciente .laudo-sig .sig-line {
  border-top: 1px solid #000;
  margin-top: 8px;
  padding-top: 4px;
  font-size: 12px;
}

/* ═══════════ LAUDO TEMPLATE — DESIGN SYSTEM ═══════════ */
/* Variables for identity — configurable */
:root {
  --laudo-font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --laudo-font-title: 'Montserrat', 'Inter', system-ui, sans-serif;
  --laudo-color-primary: #1a1a1a;
  --laudo-color-secondary: #333;
  --laudo-color-accent: #1a1a1a;
  --laudo-color-line: #999;
  --laudo-color-line-strong: #1a1a1a;
  --laudo-color-bg-section: #f5f5f5;
  --laudo-color-bg-conclusao: #f5f5f5;
  --laudo-line-width: 1.5px;
  /* Margens: esquerda ampliada para grampeamento em pasta */
  --laudo-margin-top: 42mm;
  --laudo-margin-bottom: 25mm;
  --laudo-margin-left: 28mm;
  --laudo-margin-right: 16mm;
}

/* ── Laudo on-screen preview ── */
.laudo-html-preview {
  font-family: var(--laudo-font-body);
  color: var(--laudo-color-primary);
  font-size: 11px;
  line-height: 1.55;
  max-height: 500px;
  overflow-y: auto;
  padding: 16px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.laudo-html-preview .ld-title { font-family: var(--laudo-font-title); font-weight: 800; font-size: 16px; text-align: left; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 2px; }
.laudo-html-preview .ld-date-sub { text-align: left; font-size: 10px; color: #666; font-style: italic; margin-bottom: 10px; }
.laudo-html-preview .ld-rule { border: none; border-top: var(--laudo-line-width) solid var(--laudo-color-line-strong); margin: 10px 0; }
.laudo-html-preview .ld-rule--light { border-top-color: var(--laudo-color-line); }
.laudo-html-preview .ld-meta { font-size: 10px; line-height: 1.6; margin-bottom: 8px; }
.laudo-html-preview .ld-meta-row { display: flex; gap: 4px; }
.laudo-html-preview .ld-meta-label { font-weight: 600; min-width: 120px; flex-shrink: 0; }
.laudo-html-preview .ld-section-title { font-family: var(--laudo-font-title); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--laudo-color-accent); margin: 10px 0 4px 0; padding-bottom: 2px; border-bottom: 1px solid var(--laudo-color-line); }
.laudo-html-preview .ld-section-body { margin: 0 0 6px 0; padding-left: 0; text-align: justify; font-size: 10.5px; }
.laudo-html-preview .ld-conclusao { background: var(--laudo-color-bg-conclusao); padding: 8px 10px; border-radius: 4px; border-left: 3px solid var(--laudo-color-accent); margin: 8px 0; }
.laudo-html-preview .ld-conclusao-title { font-family: var(--laudo-font-title); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.laudo-html-preview .ld-conclusao ol { margin: 0; padding-left: 18px; }
.laudo-html-preview .ld-conclusao li { font-weight: 600; font-size: 10.5px; margin-bottom: 2px; }
.laudo-html-preview .ld-nota { font-size: 9px; color: #666; font-style: italic; margin: 6px 0; padding: 4px 8px; border-left: 2px solid var(--laudo-color-line); }
.laudo-html-preview .ld-sig { text-align: right; margin-top: 16px; padding-top: 8px; }
.laudo-html-preview .ld-sig-img { max-height: 50px; margin-bottom: 2px; }
.laudo-html-preview .ld-sig-name { font-weight: 700; font-size: 11px; }
.laudo-html-preview .ld-sig-crm { font-size: 10px; color: var(--laudo-color-secondary); }
.laudo-html-preview .ld-footer { font-size: 8px; color: #999; text-align: center; margin-top: 12px; padding-top: 6px; border-top: 1px solid #e0e0e0; }
/* Tables for colono */
.laudo-html-preview .ld-table { width: 100%; border-collapse: collapse; font-size: 10px; margin: 6px 0; }
.laudo-html-preview .ld-table th { background: #e8e8e8; color: #1a1a1a; padding: 4px 6px; font-weight: 600; text-transform: uppercase; font-size: 9px; letter-spacing: 0.3px; text-align: left; }
.laudo-html-preview .ld-table td { padding: 4px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
.laudo-html-preview .ld-table tr:last-child td { border-bottom: none; }
.laudo-html-preview .ld-table--meta th { background: #e8e8e8; }
.laudo-html-preview .ld-boston-grid { display: inline-grid; grid-template-columns: repeat(4, auto); gap: 0; border: 1px solid #999; margin: 4px 0 6px 0; }
.laudo-html-preview .ld-boston-cell { text-align: center; padding: 3px 8px; border-right: 1px solid #999; font-size: 10px; }
.laudo-html-preview .ld-boston-cell:last-child { border-right: none; }
.laudo-html-preview .ld-boston-cell--total { background: #f0f0f0; }
.laudo-html-preview .ld-boston-label { font-size: 7px; color: #333; display: block; }
.laudo-html-preview .ld-boston-score { font-size: 13px; font-weight: 700; display: block; }
.laudo-html-preview .ld-orientacao { background: #f5f5f5; padding: 6px 10px; border-radius: 4px; border-left: 3px solid #1a1a1a; margin: 8px 0; font-size: 10px; }
.laudo-html-preview .ld-lesao-row { padding: 4px 0; border-bottom: 1px dotted #ddd; font-size: 10px; }
.laudo-html-preview .ld-lesao-row:last-child { border-bottom: none; }
.laudo-html-preview .ld-lesao-id { font-weight: 700; color: var(--laudo-color-accent); }
/* Alerta rodapé */
.laudo-html-preview .ld-alert-footer { font-size: 7.5px; color: #888; font-style: italic; margin-top: 8px; line-height: 1.3; }
.laudo-html-preview .ld-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 10px; margin: 4px 0 8px 0; }
.laudo-html-preview .ld-info-item { display: flex; gap: 4px; padding: 2px 0; }
.laudo-html-preview .ld-info-label { font-weight: 600; min-width: 110px; flex-shrink: 0; color: #333; }
.laudo-html-preview .ld-info-val { color: var(--laudo-color-primary); }

/* ═══════════ PRINT — A4 PDF ═══════════ */
@media print {
  @page { size: A4 portrait; margin: 42mm 16mm 25mm 28mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff; margin: 0; padding: 0; }
  .no-print { display: none !important; }
  .layout { display: none !important; }
  .screen { display: none !important; }
  #screen_exame.active { display: none !important; }
  .content { overflow: visible; padding: 0; }
  .print-only { display: block; }
  body:not(.print-mode-paciente) .print-paciente { display: none; }
  body:not(.print-mode-relatorio) .print-relatorio { display: none; }
  body.print-mode-relatorio .print-relatorio { display: block; }
  body.print-mode-paciente .print-paciente { display: block; }

  /* ── Laudo print layout (F6 Camada 1 — otimizado default) ── */
  .print-paciente {
    font-family: var(--laudo-font-body);
    color: var(--laudo-color-primary);
    font-size: 11pt;
    line-height: 1.40;     /* F6: 1.6 → 1.40, ganho vertical sem deformar */
  }
  .print-paciente .ld-title {
    font-family: var(--laudo-font-title);
    font-weight: 800;
    font-size: 18pt;
    text-align: left;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: 0 0 2pt 0;
    color: var(--laudo-color-primary);
  }
  .print-paciente .ld-date-sub {
    text-align: left;
    font-size: 10pt;
    color: #555;
    font-style: italic;
    margin-bottom: 6pt;    /* F6: 8 → 6 */
  }
  .print-paciente .ld-rule {
    border: none;
    border-top: 2px solid var(--laudo-color-line-strong);
    margin: 5pt 0;         /* F6: 8 → 5 */
  }
  .print-paciente .ld-rule--light {
    border-top: 1px solid var(--laudo-color-line);
    margin: 4pt 0;         /* F6: 6 → 4 */
  }
  .print-paciente .ld-meta {
    font-size: 10pt;
    line-height: 1.45;     /* F6: 1.7 → 1.45 */
    margin-bottom: 4pt;    /* F6: 6 → 4 */
  }
  .print-paciente .ld-meta-row {
    display: flex;
    gap: 4pt;
  }
  .print-paciente .ld-meta-label {
    font-weight: 600;
    min-width: 140pt;
    flex-shrink: 0;
  }
  .print-paciente .ld-section-title {
    font-family: var(--laudo-font-title);
    font-weight: 700;
    font-size: 11pt;
    text-transform: uppercase;
    letter-spacing: 0.5pt;
    color: var(--laudo-color-accent);
    margin: 10pt 0 3pt 0;  /* F6: 14 0 4 → 10 0 3 */
    padding-bottom: 2pt;
    border-bottom: 1px solid var(--laudo-color-line);
    page-break-after: avoid;
  }
  .print-paciente .ld-section-body {
    margin: 0 0 3pt 0;     /* F6: 4 → 3 */
    padding-left: 0;
    text-align: justify;
    page-break-before: avoid;
    orphans: 2;            /* F6: 3 → 2, aceita 1 linha órfã se necessário */
    widows: 2;
  }
  /* F6: não partir seção curta no meio */
  .print-paciente .ld-section {
    page-break-inside: avoid;
  }

  /* F6 — esconde toggle/hint na impressão (UI-only) */
  .laudo-compact-toggle, .laudo-compact-hint { display: none !important; }

  /* ── F6 Camada 2 — .laudo-compact (opt-in agressivo) ── */
  .print-paciente.laudo-compact { font-size: 10pt; line-height: 1.25; }
  .print-paciente.laudo-compact .ld-title { font-size: 16pt; margin: 0 0 1pt 0; }
  .print-paciente.laudo-compact .ld-date-sub { font-size: 9pt; margin-bottom: 4pt; }
  .print-paciente.laudo-compact .ld-rule { margin: 3pt 0; }
  .print-paciente.laudo-compact .ld-rule--light { margin: 2pt 0; }
  .print-paciente.laudo-compact .ld-meta { font-size: 9pt; line-height: 1.30; margin-bottom: 3pt; }
  .print-paciente.laudo-compact .ld-meta-label { min-width: 100pt; }
  .print-paciente.laudo-compact .ld-section-title { font-size: 10pt; margin: 6pt 0 2pt 0; padding-bottom: 1pt; }
  .print-paciente.laudo-compact .ld-section-body { margin: 0 0 2pt 0; }
  .print-paciente.laudo-compact .ld-conclusao { padding: 6pt 10pt; margin: 8pt 0; }
  .print-paciente.laudo-compact .ld-conclusao-title { font-size: 10pt; margin-bottom: 2pt; }
  .print-paciente.laudo-compact .ld-conclusao li { font-size: 10pt; margin-bottom: 2pt; }
  .print-paciente.laudo-compact .ld-sig { margin-top: 14pt; padding-top: 6pt; }
  .print-paciente.laudo-compact .ld-sig-img { max-height: 45pt; }
  .print-paciente.laudo-compact .ld-sig-name { font-size: 10pt; }
  .print-paciente.laudo-compact .ld-sig-crm { font-size: 9pt; }
  .print-paciente.laudo-compact .ld-footer { font-size: 7pt; margin-top: 10pt; padding-top: 4pt; }
  .print-paciente.laudo-compact .ld-alert-footer { font-size: 7pt; margin-top: 6pt; }
  .print-paciente.laudo-compact .ld-table { font-size: 9pt; margin: 5pt 0; }
  .print-paciente.laudo-compact .ld-table th,
  .print-paciente.laudo-compact .ld-table td { padding: 3pt 6pt; }
  .print-paciente.laudo-compact .ld-info-grid { font-size: 9pt; gap: 1pt 10pt; }
  .print-paciente.laudo-compact .ld-info-label { min-width: 100pt; }
  .print-paciente .ld-conclusao {
    background: var(--laudo-color-bg-conclusao);
    padding: 10pt 14pt;
    border-radius: 0;
    border-left: 3pt solid var(--laudo-color-accent);
    margin: 12pt 0;
    page-break-inside: avoid;
  }
  .print-paciente .ld-conclusao-title {
    font-family: var(--laudo-font-title);
    font-weight: 700;
    font-size: 11pt;
    text-transform: uppercase;
    letter-spacing: 0.5pt;
    margin-bottom: 4pt;
  }
  .print-paciente .ld-conclusao ol {
    margin: 0;
    padding-left: 20pt;
  }
  .print-paciente .ld-conclusao li {
    font-weight: 600;
    font-size: 11pt;
    margin-bottom: 3pt;
  }
  .print-paciente .ld-nota {
    font-size: 9pt;
    color: #555;
    font-style: italic;
    margin: 8pt 0;
    padding: 4pt 8pt;
    border-left: 2pt solid var(--laudo-color-line);
  }
  .print-paciente .ld-sig {
    text-align: right;
    margin-top: 24pt;
    padding-top: 10pt;
    page-break-inside: avoid;
  }
  .print-paciente .ld-sig-img {
    max-height: 60pt;
    margin-bottom: 4pt;
  }
  .print-paciente .ld-sig-name {
    font-weight: 700;
    font-size: 11pt;
  }
  .print-paciente .ld-sig-crm {
    font-size: 10pt;
    color: var(--laudo-color-secondary);
  }
  .print-paciente .ld-footer {
    font-size: 8pt;
    color: #888;
    text-align: center;
    margin-top: 16pt;
    padding-top: 6pt;
    border-top: 1px solid #ddd;
    page-break-inside: avoid;
  }
  /* Tables */
  .print-paciente .ld-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
    margin: 8pt 0;
    page-break-inside: avoid;
  }
  .print-paciente .ld-table th {
    background: #e8e8e8 !important;
    color: #1a1a1a !important;
    padding: 5pt 8pt;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 9pt;
    letter-spacing: 0.3pt;
    text-align: left;
  }
  .print-paciente .ld-table td {
    padding: 5pt 8pt;
    border-bottom: 1px solid #ddd;
    vertical-align: top;
  }
  .print-paciente .ld-table tr:last-child td { border-bottom: none; }
  .print-paciente .ld-boston-grid {
    display: inline-grid;
    grid-template-columns: repeat(4, auto);
    gap: 0;
    border: 1px solid #999;
    margin: 4pt 0 8pt 0;
    page-break-inside: avoid;
  }
  .print-paciente .ld-boston-cell {
    text-align: center;
    padding: 4pt 10pt;
    border-right: 1px solid #999;
  }
  .print-paciente .ld-boston-cell:last-child { border-right: none; }
  .print-paciente .ld-boston-label { font-size: 7pt; color: #333; display: block; text-transform: uppercase; letter-spacing: 0.3pt; }
  .print-paciente .ld-boston-score { font-size: 13pt; font-weight: 700; display: block; }
  .print-paciente .ld-boston-cell--total { background: #f0f0f0; }
  .print-paciente .ld-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2pt 14pt; font-size: 10pt; margin: 4pt 0 8pt 0; }
  .print-paciente .ld-info-item { display: flex; gap: 4pt; padding: 1pt 0; }
  .print-paciente .ld-info-label { font-weight: 600; min-width: 120pt; flex-shrink: 0; }
  .print-paciente .ld-info-val { }
  .print-paciente .ld-orientacao {
    background: #f5f5f5 !important;
    padding: 8pt 12pt;
    border-left: 3pt solid #1a1a1a;
    margin: 10pt 0;
    font-size: 10pt;
    page-break-inside: avoid;
  }
  .print-paciente .ld-lesao-row { padding: 4pt 0; border-bottom: 1px dotted #ccc; font-size: 10pt; }
  .print-paciente .ld-lesao-row:last-child { border-bottom: none; }
  .print-paciente .ld-lesao-id { font-weight: 700; color: var(--laudo-color-accent); }
  .print-paciente .ld-alert-footer { font-size: 7.5pt; color: #888; font-style: italic; margin-top: 10pt; line-height: 1.4; }
  /* Page break helpers */
  .ld-page-break { page-break-before: always; }
  .ld-no-break { page-break-inside: avoid; }
}

/* ── Chips (multi-select) ── */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-flex; align-items: center; padding: 5px 12px;
  border: 1.5px solid #bbb; border-radius: 16px; background: #fff;
  font-size: 12px; font-weight: 500; color: #333; cursor: pointer;
  transition: all .15s ease; user-select: none;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
}
.chip:hover { border-color: #888; background: #f5f5f5; }
.chip.on { background: var(--c-eda-light, #e0f0ff); border-color: var(--c-eda, #2680c2); color: var(--c-eda-dark, #1a5276); font-weight: 600; }
.chip--warn { border-color: #e0a800; }
.chip--warn.on { background: #fff3cd; border-color: #d4a017; color: #856404; }
.chip--danger { border-color: #e74c3c; }
.chip--danger.on { background: #fce4ec; border-color: #c0392b; color: #922b21; }

/* ── Prox panels ── */
.prox-panel { margin-top: 8px; padding: 8px 10px; background: #fafafa; border-radius: 6px; border: 1px solid #e0e0e0; }
.prox-panel .col-label { font-size: 11px; font-weight: 600; color: #555; margin-bottom: 4px; display: block; }
.prox-advanced { margin-top: 6px; }
.prox-advanced summary { font-size: 11px; color: #888; cursor: pointer; user-select: none; }
.prox-advanced summary:hover { color: #555; }

/* ── Resumo auto inline ── */
.col-resumo-auto {
  font-size: 11px; line-height: 1.5; padding: 8px 10px;
  background: #f0f4f8; border-radius: 6px; border-left: 3px solid #2680c2;
  color: #333; font-style: italic;
}

/* Touch/iPad sizing */
@media (pointer: coarse) {
  .btn, .chip, input, select {
    min-height: 44px;
  }
  input, select {
    font-size: 15px;
  }
  .nav-item {
    height: 44px;
    font-size: 14px;
  }
}

/* Collapsible sections */
.collapsible { cursor: pointer; user-select: none; position: relative; padding-right: 24px; }
.collapsible::after { content: '▾'; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 12px; transition: transform .2s; }
.collapsible.collapsed::after { transform: translateY(-50%) rotate(-90deg); }
.collapsible + div, .collapsible + .grid { overflow: hidden; transition: max-height .25s ease, opacity .2s; max-height: 2000px; opacity: 1; }
.collapsible.collapsed + div, .collapsible.collapsed + .grid { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0; }

/* ═══════════ CLASSIFICAÇÕES — 3-LAYER SYSTEM ═══════════ */

/* Layers */
.cx-layer { margin-bottom: 12px; }
.cx-layer--triggers { background: #f8fafc; border-radius: 10px; padding: 10px 12px; border: 1px solid #e2e8f0; }
.cx-layer--cards { min-height: 40px; }
.cx-layer--summary { background: linear-gradient(135deg, #eff6ff, #f0fdf4); border-radius: 10px; padding: 12px; border: 1px solid #c7d8e8; }
.cx-layer--achados { background: #fafafa; border-radius: 8px; padding: 0; border: 1px solid #e5e7eb; margin-top: 8px; }

/* ── CAMADA A: Trigger grid ── */
.cx-trigger-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.cx-organ-group { display: flex; flex-direction: column; gap: 4px; }
.cx-organ-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 4px; width: fit-content; }
.cx-organ-label--eso { color: #c2410c; background: #fff7ed; }
.cx-organ-label--est { color: #b91c1c; background: #fef2f2; }
.cx-organ-label--col { color: #1d4ed8; background: #eff6ff; }
.cx-organ-label--dii { color: #7c3aed; background: #f5f3ff; }
.cx-organ-label--out { color: #475569; background: #f1f5f9; }
.cx-trigger-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cx-trigger-hint { font-size: 10px; color: #94a3b8; margin-top: 6px; text-align: center; }

.chip-trigger { border: 2px solid #ddd; background: #fff; transition: all .15s; font-size: 12px; padding: 5px 10px; border-radius: 6px; }
.chip-trigger.active { border-color: #2563eb; background: #dbeafe; color: #1e40af; font-weight: 600; }

/* ── CAMADA B: Classification cards ── */
.cx-cards-empty { text-align: center; color: #94a3b8; font-size: 12px; padding: 20px 0; }
.cx-cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cx-card { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; overflow: hidden; transition: border-color .2s; }
.cx-card--wide { grid-column: 1 / -1; }
.cx-card.cx-filled { border-color: #86efac; }
.cx-card.cx-pending { border-color: #fdba74; }
.cx-card.cx-incoherent { border-color: #fca5a5; }

.cx-card-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; cursor: pointer; user-select: none; background: #fafbfc; border-bottom: 1px solid #f1f5f9; }
.cx-card-head:hover { background: #f1f5f9; }
.cx-card-organ { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cx-card-organ--eso { background: #ea580c; }
.cx-card-organ--est { background: #dc2626; }
.cx-card-organ--col { background: #2563eb; }
.cx-card-organ--dii { background: #7c3aed; }
.cx-card-organ--out { background: #64748b; }
.cx-card-title { font-weight: 700; font-size: 13px; color: #1e293b; }
.cx-card-reason { font-size: 10px; color: #94a3b8; flex: 1; }
.cx-card-badge { font-size: 9px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.cx-card-badge[data-status="pendente"] { background: #fff7ed; color: #c2410c; }
.cx-card-badge[data-status="preenchida"] { background: #dcfce7; color: #15803d; }
.cx-card-badge[data-status="incoerente"] { background: #fef2f2; color: #dc2626; }
.cx-card-chevron { font-size: 11px; color: #94a3b8; transition: transform .2s; }
.cx-card.cx-collapsed .cx-card-chevron { transform: rotate(-90deg); }
.cx-card.cx-collapsed .cx-card-body { display: none; }

.cx-card-body { padding: 8px 10px 10px; }

/* Compact fields */
.cx-compact-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.cx-field { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 80px; }
.cx-field-label { font-size: 10px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
.cx-num { width: 60px; text-align: center; font-size: 15px; font-weight: 700; padding: 6px 4px; border: 1px solid #d1d5db; border-radius: 6px; }
.cx-sel { font-size: 12px; padding: 5px 6px; border: 1px solid #d1d5db; border-radius: 5px; min-height: 32px; }

/* Score number chips (replace dropdowns) */
.cx-score-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cx-score-item { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 60px; flex: 1; }
.cx-score-label { font-size: 9px; font-weight: 700; color: #64748b; text-transform: uppercase; }
.cx-num-chips { display: flex; gap: 2px; }
.cx-num-chip { width: 30px; height: 30px; border-radius: 6px; border: 1.5px solid #d1d5db; background: #fff; font-size: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .12s; color: #374151; }
.cx-num-chip:hover { border-color: #93c5fd; }
.cx-num-chip.active { background: #2563eb; color: #fff; border-color: #2563eb; }
/* Chips com rótulo de texto (DICA: "≤15", ">15", "Edema/hiper.", "Erosões", "SCAD")
   crescem para caber o texto — os 30px fixos dos chips numéricos cortavam/deformavam. */
.cx-num-chip--text { width: auto; min-width: 40px; padding: 0 12px; white-space: nowrap; }
/* DICA: leitura da localização derivada da topografia (não é input — é calculado). */
.cx-loc-readout { font-size: 11px; font-weight: 700; color: #374151; padding: 6px 10px; border: 1.5px dashed #cbd5e1; border-radius: 6px; background: #f8fafc; min-width: 56px; text-align: center; white-space: nowrap; }
/* DICA: distribui os botões/grupos por toda a largura do card (layout de score uniforme,
   como os demais cards) — sem isso os botões ficavam amontoados à esquerda. */
#panel_dica .chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
#panel_dica .chips > .chip { flex: 1 1 auto; justify-content: center; }
#panel_dica .cx-score-row { gap: 14px; align-items: flex-start; }
#panel_dica .cx-score-item { flex: 1 1 0; min-width: 0; }
#panel_dica .cx-num-chips { display: flex; width: 100%; }
#panel_dica .cx-num-chips > .cx-num-chip { flex: 1 1 auto; }
#panel_dica .cx-loc-readout { width: 100%; box-sizing: border-box; }

/* Classification chips */
.classif-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.classif-chips .chip { height: auto; min-height: 30px; font-size: 12px; padding: 5px 10px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.3; min-width: 46px; border-radius: 6px; }
.classif-chips .chip small { display: block; font-size: 9px; opacity: .6; font-weight: normal; max-width: 90px; text-align: center; margin-top: 1px; line-height: 1.1; }
.chip-classif.active { background: #0052cc; color: #fff; border-color: #0052cc; font-weight: 600; }
.chip-classif.active small { opacity: .9; color: #fff; }

.classif-result { margin-top: 6px; padding: 6px 10px; background: #f0faf0; border-radius: 6px; font-weight: 600; font-size: 12px; color: #15803d; }
.classif-result:empty { display: none; }
.classif-warn { color: #c2410c; font-size: 11px; font-weight: 600; margin-top: 4px; padding: 4px 8px; background: #fff7ed; border-radius: 4px; }

/* SES-CD table — compact */
.classif-table { width: 100%; border-collapse: collapse; font-size: 11px; margin: 6px 0; }
.classif-table th, .classif-table td { border: 1px solid #e5e7eb; padding: 3px 4px; text-align: center; }
.classif-table th { background: #f8fafc; font-size: 9px; font-weight: 700; color: #64748b; }
.classif-table select { width: 100%; min-height: 30px; font-size: 12px; }
.classif-table td:first-child { text-align: left; font-weight: 600; white-space: nowrap; font-size: 10px; }

/* DII subpanels */
.dii-subpanel { margin-top: 8px; padding: 6px 0; }
.chip-dii-tipo { border: 2px solid #ddd; background: #fafafa; font-size: 12px; padding: 5px 10px; border-radius: 6px; }
.chip-dii-tipo.active { border-color: #7c3aed; background: #f5f3ff; color: #6d28d9; font-weight: 600; }

/* Úlcera dual layout */
.cx-ulcera-dual { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cx-ulcera-half { }
.cx-ulcera-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.cx-ulcera-title { font-weight: 700; font-size: 12px; color: #1e293b; }
.cx-ulcera-sub { font-size: 9px; color: #94a3b8; flex: 1; }
.ulcera-subpanel { padding: 6px; background: #fafafa; border-radius: 6px; border: 1px solid #f1f5f9; }
.chip-ulcera-tipo { border: 1.5px solid #ddd; background: #fafafa; font-size: 9px; padding: 2px 8px; border-radius: 4px; }
.chip-ulcera-tipo.active { border-color: #c2410c; background: #fff7ed; color: #c2410c; font-weight: 600; }

/* Achados toggle */
.cx-achados-head { font-size: 12px; font-weight: 600; color: #475569; padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; }
.cx-achados-head:hover { background: #f1f5f9; }
.cx-achados-chevron { font-size: 10px; transition: transform .2s; }
.cx-achados-body { padding: 8px 12px; }

/* ── CAMADA C: Diagnostic summary ── */
.cx-summary-head { font-size: 13px; font-weight: 700; color: #1e40af; margin-bottom: 8px; }
.cx-summary-body { display: flex; flex-direction: column; gap: 6px; }
.cx-summary-diags { font-size: 12px; color: #1e293b; }
.cx-diag-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px solid #e2e8f0; }
.cx-diag-row:last-child { border: none; }
.cx-diag-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cx-diag-dot--filled { background: #22c55e; }
.cx-diag-dot--derived { background: #3b82f6; }
.cx-diag-label { font-weight: 600; }
.cx-diag-value { color: #475569; }
.cx-summary-pending { font-size: 11px; }
.cx-pending-row { display: flex; align-items: center; gap: 4px; color: #c2410c; cursor: pointer; padding: 2px 0; }
.cx-pending-row:hover { text-decoration: underline; }
.cx-summary-incoherent { font-size: 11px; }
.cx-incoherent-row { display: flex; align-items: center; gap: 4px; color: #dc2626; padding: 2px 0; }

/* Seg-ctrl small variant for Prague ilhotas */
.seg-ctrl--sm { gap: 0; display: inline-flex; border-radius: 6px; overflow: hidden; border: 1px solid #d1d5db; }
.seg-ctrl--sm .seg-btn { font-size: 11px; padding: 4px 10px; min-height: 28px; border: none; border-radius: 0; }

.g5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .cx-cards-grid { grid-template-columns: 1fr; }
  .cx-ulcera-dual { grid-template-columns: 1fr; }
  .cx-trigger-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .g5 { grid-template-columns: repeat(2, 1fr); }
  .classif-table { font-size: 10px; }
  .classif-table select { min-height: 28px; font-size: 10px; }
}

/* Validation styles */
.val-bloqueio { color: #c00; font-weight: 600; }
.val-forte { color: #b45309; }
.val-leve { color: #666; }
.val-info { color: #888; font-style: italic; }

.pill-danger { background: #c00 !important; color: #fff !important; }
.pill-warn { background: #b45309 !important; color: #fff !important; }
.pill-info { background: #4a90d9 !important; color: #fff !important; }

.alerts li { padding: 4px 0; border-bottom: 1px solid #f0f0f0; font-size: 12px; line-height: 1.4; }
.alerts li:hover { background: #f8f8f8; }
.alerts li.ok { color: #2e7d32; border-bottom: none; }

/* Nav status dots */
.nav-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.nav-dot-bloqueio { background: #c00; }
.nav-dot-alerta { background: #e89000; }
.nav-dot-info { background: #4a90d9; }

/* ==================== SEDAÇÃO — COMPACT PANEL ==================== */
.sed-quick-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.sed-group {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px 10px;
}
.sed-group-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 6px;
}
.sed-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.sed-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.sed-chip b { font-weight: 700; }
.sed-chip small { font-size: 10px; color: #94a3b8; margin-left: 1px; }
.sed-chip:active { transform: scale(0.95); }

.sed-chip--sedativo { border-color: #c4b5fd; }
.sed-chip--sedativo:hover, .sed-chip--sedativo:active { background: #ede9fe; border-color: #8b5cf6; }
.sed-chip--analgesico { border-color: #fed7aa; }
.sed-chip--analgesico:hover, .sed-chip--analgesico:active { background: #fff7ed; border-color: #f97316; }
.sed-chip--adjuvante { border-color: #a7f3d0; }
.sed-chip--adjuvante:hover, .sed-chip--adjuvante:active { background: #ecfdf5; border-color: #10b981; }
.sed-chip--resgate { border-color: #fecaca; }
.sed-chip--resgate:hover, .sed-chip--resgate:active { background: #fef2f2; border-color: #ef4444; }

/* Totals row */
.sed-totais-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.sed-total-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1.5px solid #cbd5e1;
  border-radius: 20px;
  background: #fff;
  font-size: 12px;
  color: #334155;
}
.sed-total-pill strong { font-weight: 700; }
.sed-total-pill small { color: #94a3b8; font-size: 10px; }
.sed-total-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* List header */
.sed-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.sed-list-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
}
.sed-btn-add {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #3b82f6;
  background: transparent;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s;
}
.sed-btn-add:hover { background: #eff6ff; border-color: #3b82f6; }

/* Compact table */
.sed-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sed-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.sed-table thead th {
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #94a3b8;
  border-bottom: 2px solid #e2e8f0;
  text-align: left;
  white-space: nowrap;
}
.sed-th-hora { width: 80px; }
.sed-th-dose { width: 65px; }
.sed-th-unit { width: 60px; }
.sed-th-via { width: 50px; }
.sed-th-act { width: 32px; }
.sed-row { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.sed-row:hover { background: #f8fafc; }
.sed-row td { padding: 3px 4px; vertical-align: middle; }

/* Inline inputs inside table */
.sed-input-time {
  width: 78px;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  transition: border-color .15s;
}
.sed-input-time:focus { border-color: #3b82f6; background: #fff; outline: none; }

.sed-select-med {
  max-width: 140px;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
  background: transparent;
  cursor: pointer;
  transition: border-color .15s;
}
.sed-select-med:focus { border-color: #3b82f6; background: #fff; outline: none; }

.sed-input-outro {
  width: 100px;
  padding: 2px 6px;
  margin-left: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
  background: #fffbeb;
}
.sed-input-outro:focus { border-color: #f59e0b; outline: none; }

.sed-input-dose {
  width: 58px;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  background: transparent;
  transition: border-color .15s;
}
.sed-input-dose:focus { border-color: #3b82f6; background: #fff; outline: none; }

.sed-select-sm {
  padding: 2px 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  color: #64748b;
  background: transparent;
  cursor: pointer;
}
.sed-select-sm:focus { border-color: #3b82f6; background: #fff; outline: none; }

.sed-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.sed-btn-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #cbd5e1;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.sed-btn-del:hover { background: #fef2f2; color: #ef4444; }

.sed-empty {
  text-align: center;
  padding: 20px;
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
}

/* ==================== MONITORING PANEL — UNIFIED GRID ==================== */
.mon-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 14px;
}
.mon-col {
  min-width: 0; /* prevent grid blowout */
}
.mon-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e2e8f0;
}
.mon-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
}

/* ==================== SINAIS VITAIS — TABLE (enlarged 2026-05-21) ==================== */
.sv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}
.sv-table thead th {
  padding: 6px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #475569;
  border-bottom: 2px solid #cbd5e1;
  text-align: center;
  white-space: nowrap;
}
.sv-row { border-bottom: 1px solid #e2e8f0; }
.sv-row:hover { background: #f8fafc; }
.sv-row td { padding: 5px 3px; text-align: center; vertical-align: middle; }

.sv-in {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  text-align: center;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  height: 38px;
  box-sizing: border-box;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.sv-in:hover  { border-color: #cbd5e1; }
.sv-in:focus  { border-color: #3b82f6; background: #fff; outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.sv-in-time   { width: 92px; padding: 4px 6px; }
.sv-in-num    { width: 72px; padding: 4px 6px; font-weight: 700; }
.sv-in-num.sv-warn { color: #d97706; background: #fffbeb; border-color: #fde68a; }
.sv-in-num.sv-crit { color: #dc2626; background: #fef2f2; border-color: #fecaca; font-weight: 800; }
.sv-pam {
  font-size: 15px;
  color: #7c3aed;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ==================== INTERCORRÊNCIAS — COMPACT ==================== */
.int-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.int-chip {
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all .12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.int-chip:hover { border-color: #94a3b8; background: #f8fafc; }
.int-chip.on { background: #fef2f2; border-color: #f87171; color: #dc2626; font-weight: 600; }
.int-chip--ok.on { background: #ecfdf5; border-color: #34d399; color: #059669; }
.int-chip--sm { font-size: 11px; padding: 3px 8px; }
.int-chips--sm { gap: 3px; }

/* B1 (#4, 2026-04-24): "+ Outras" colapsável + lista de raras */
.int-chip--more {
  border-style: dashed;
  color: #64748b;
  font-style: italic;
}
.int-chip--more[aria-expanded="true"] {
  background: #eef2ff; border-color: #6366f1; color: #4338ca;
  font-style: normal; font-weight: 600;
}
.int-chips-more {
  display: flex; flex-wrap: wrap; gap: 4px;
  width: 100%; padding-top: 6px; margin-top: 4px;
  border-top: 1px dashed #e2e8f0;
}
.int-chips-more[hidden] { display: none; }

.int-detail-list { display: flex; flex-direction: column; gap: 3px; }
.int-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid #f1f5f9;
}
.int-label {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  white-space: nowrap;
  min-width: 80px;
}
.int-desc {
  flex: 1;
  min-width: 0;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  background: transparent;
  transition: border-color .15s;
}
.int-desc:focus { border-color: #3b82f6; background: #fff; outline: none; }

/* iPad landscape: side-by-side columns */
@media (min-width: 900px) {
  .mon-grid {
    grid-template-columns: 55fr 45fr;
    gap: 20px;
  }
  .sed-quick-panel {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1200px) {
  .sed-quick-panel {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .sed-chip {
    padding: 6px 12px;
    font-size: 14px;
  }
}

/* ═══════════════════════════════════════════════════════
   COLONOSCOPY REDESIGN — Clinical Panel UX
   ═══════════════════════════════════════════════════════ */

/* Panel grid: 2×2 on landscape iPad, single column on portrait */
.col-panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px) {
  .col-panels {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

/* Card container */
.col-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.col-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f8faf8;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: #1a3a1a;
  letter-spacing: .02em;
}
.col-card-icon { font-size: 15px; }
.col-card-body {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Boston card special header */
.col-card--boston .col-card-head { justify-content: space-between; }

/* E6 (2026-04-24): Col-card colapsável */
.col-card.col-card--collapsible > .col-card-head {
  cursor: pointer;
  user-select: none;
  padding-right: 12px;
  justify-content: space-between;
  transition: background-color .15s ease;
}
.col-card.col-card--collapsible > .col-card-head:hover { background: #eef5ef; }
.col-card.col-card--collapsible > .col-card-head:focus-visible {
  outline: 2px solid var(--accent, #2d6a4f);
  outline-offset: -2px;
}
.col-card-head-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.col-card-toggle {
  font-size: 12px;
  color: #5a7a5a;
  transition: transform .18s ease;
  margin-left: 8px;
  flex-shrink: 0;
}
.col-card.col-card--collapsed > .col-card-head .col-card-toggle { transform: rotate(-90deg); }
.col-card.col-card--collapsed > .col-card-body { display: none; }
.col-card.col-card--collapsed > .col-card-head { border-bottom-color: transparent; }
/* Badge com contador de itens quando colapsado (populado via JS) */
.col-card-count {
  display: none;
  font-size: 11px;
  font-weight: 600;
  color: #5a7a5a;
  background: #e8f0e8;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}
.col-card.col-card--collapsed > .col-card-head .col-card-count[data-has-count="1"] { display: inline-block; }
/* Sem mudar margens/flex dos cards EDA/Colono/HP existentes */
@media print {
  .col-card.col-card--collapsed > .col-card-body { display: flex !important; }
  .col-card-toggle, .col-card-count { display: none !important; }
}

/* Row: horizontal flex with wrapping */
.col-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

/* Field container */
.col-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.col-field--grow { flex: 1 1 140px; }
.col-field--full { flex: 1 1 100%; }

/* ── Cards com campos distribuídos por toda a largura (.col-card--fill) ──
   Antes os controles ficavam agrupados à esquerda com muito vazio à direita.
   Os campos crescem igualmente (com wrap quando o card é estreito), e os
   controles segmentados / chips ocupam toda a largura da sua coluna. Vale
   tanto no layout clássico quanto no v2 (masonry) — não depende de data-layout.
   Campos condicionais (motivo da dificuldade, exame incompleto, preparo outro)
   entram na mesma malha e se redistribuem sozinhos ao aparecer/desaparecer.
   Aplicado em: Progressão e extensão, Preparo e tolerância. */
.col-card--fill .col-row > .col-field:not(.col-field--full) { flex: 1 1 160px; }
.col-card--fill .col-row .seg-ctrl { display: flex; width: 100%; }
.col-card--fill .col-row .seg-ctrl > .seg-btn { flex: 1 1 0; padding: 0 8px; }
.col-card--fill .col-field--full .chips { width: 100%; }
.col-card--fill .col-field--full .chips .chip { flex: 1 1 auto; justify-content: center; }
/* Classificações: a faixa de gatilhos é um grid de 1 item só, que colapsava
   à esquerda (~250px). Vira bloco full-width e os gatilhos se distribuem.
   Só os .chip-trigger (faixa de classificações) preenchem — os pickers de
   "+ Achado" (.chip-achado/.chip-achado-eda) seguem como pílulas naturais. */
.col-card--fill .cx-trigger-grid { display: block; }
.col-card--fill .cx-trigger-chips { gap: 8px; }
.col-card--fill .cx-trigger-chips .chip-trigger { flex: 1 1 auto; justify-content: center; }
/* DENTRO de cada classificação: chips de opção e itens de score crescem para
   preencher a largura do card. O card encolhe quando o resumo lateral abre —
   flex-wrap reflui sozinho. Selecionar é só toggle de .active, não afeta o fluxo.
   (.cx-score-item tem flex:1 na base, mas o layout v2 zera o grow — reativamos
   com especificidade maior. Inputs .cx-num do Prague seguem pequenos de propósito.) */
.col-card--fill .classif-chips .chip { flex: 1 1 auto; }
.col-card--fill .cx-score-row .cx-score-item { flex: 1 1 auto; }

/* Labels */
.col-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Inputs inside colono panels */
.col-input, .col-select {
  font: var(--fs) var(--font);
  height: 36px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
}
.col-input:focus, .col-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(0,82,204,.10);
}

/* Conditional fields — slide animation */
.col-cond {
  transition: max-height .25s ease, opacity .2s ease, margin .2s ease;
}

/* ── Segmented Controls ── */
.seg-ctrl {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
}
.seg-btn {
  height: 36px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .12s ease;
  white-space: nowrap;
  position: relative;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:active { transform: scale(0.97); }

/* Selected state */
.seg-btn.on {
  background: var(--colono);
  color: #fff;
  font-weight: 700;
  border-color: transparent;
}
.seg-btn.on + .seg-btn { border-left-color: transparent; }
.seg-btn + .seg-btn.on { border-left-color: transparent; }

/* Warn variant (Ruim, Intensa, Sim for negative events) */
.seg-btn--warn.on {
  background: #f59e0b;
  color: #fff;
}

/* OK variant (positive outcomes) */
.seg-btn--ok.on {
  background: var(--colono);
  color: #fff;
}

/* Danger variant (negative outcomes) */
.seg-btn--danger.on {
  background: #dc2626;
  color: #fff;
}

/* Small seg button */
.seg-btn--sm { padding: 0 8px; font-size: 11px; }

/* Key control — slightly larger for important fields */
.seg-ctrl--key .seg-btn {
  height: 40px;
  font-size: 13px;
  padding: 0 16px;
}

/* ── Boston Score Visual Selector ── */
.boston-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.boston-seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.boston-seg-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.boston-btns {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
}
.boston-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .12s ease;
}
.boston-btn + .boston-btn { border-left: 1px solid var(--line); }
.boston-btn:active { transform: scale(0.95); }

/* Boston score color coding */
.boston-btn.on[data-val="3"] { background: #16a34a; color: #fff; }
.boston-btn.on[data-val="2"] { background: #84cc16; color: #fff; }
.boston-btn.on[data-val="1"] { background: #f59e0b; color: #fff; }
.boston-btn.on[data-val="0"] { background: #dc2626; color: #fff; }

/* Boston summary */
.boston-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f8faf8;
  border-radius: 8px;
  margin-top: 6px;
}
.boston-total-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.boston-total-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  min-width: 30px;
  text-align: center;
}
.boston-status {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.boston-status--ok { background: #dcfce7; color: #166534; }
.boston-status--warn { background: #fef3c7; color: #92400e; }
.boston-status--danger { background: #fee2e2; color: #991b1b; }

/* Boston badge in header */
.boston-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  margin-left: auto;
}
.boston-badge--ok { background: #dcfce7; color: #166534; }
.boston-badge--warn { background: #fef3c7; color: #92400e; }
.boston-badge--danger { background: #fee2e2; color: #991b1b; }

/* Boston — layout compacto + coerência visibilidade (ajustes PDF 2026-06-08) */
.col-card--boston .boston-grid { grid-template-columns: repeat(3, max-content); justify-content: start; gap: 14px; }
/* tudo numa linha: D/T/E à esquerda, Total+Visibilidade empurrados à direita (aproveita o espaço) */
.boston-line { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 28px; }
.boston-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-left: auto; }
.boston-footer .boston-summary { margin-top: 0; }
.boston-vis { display: flex; flex-direction: column; gap: 4px; }
.boston-vis .col-label { font-size: 11px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
.seg-ctrl .seg-btn.is-incoerente { opacity: .3; pointer-events: none; text-decoration: line-through; }

/* ── Alerts (conditional panels) ── */
.col-alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.col-alert--danger {
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  color: #991b1b;
}
.col-alert--warn {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
}

/* ── Touch optimization ── */
@media (pointer: coarse) {
  .seg-btn { min-height: 44px; font-size: 13px; }
  .boston-btn { width: 50px; height: 50px; font-size: 18px; }
  .seg-ctrl--key .seg-btn { min-height: 48px; }
}

/* ═══════════════════════════════════════════════════════
   EDA REDESIGN — Clinical Panel UX
   ═══════════════════════════════════════════════════════ */

/* EDA color variant for cards */
.col-card--eda { border-color: #dbeafe; }
.col-card-head--eda {
  background: #eff6ff;
  border-bottom-color: #dbeafe;
  color: #1e3a5f;
}

/* EDA seg-ctrl selected state (blue instead of green) */
.seg-ctrl--eda .seg-btn.on {
  background: var(--eda);
  color: #fff;
}
/* Keep warn/danger/ok overrides */
.seg-ctrl--eda .seg-btn--warn.on { background: #f59e0b; color: #fff; }
.seg-ctrl--eda .seg-btn--danger.on { background: #dc2626; color: #fff; }
.seg-ctrl--eda .seg-btn--ok.on { background: #16a34a; color: #fff; }

/* HP card highlight when context active */
.col-card--hp.hp-active {
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(0,82,204,.12);
}

/* Info alert variant */
.col-alert--info {
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  color: #1e40af;
}

/* Result badges (pending/positive/negative) */
.eda-badges { display: inline-flex; gap: 6px; margin-left: auto; }
.eda-result-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: .02em;
}
.eda-result-badge--pending { background: #fef3c7; color: #92400e; }
.eda-result-badge--positive { background: #fee2e2; color: #991b1b; }
.eda-result-badge--negative { background: #dcfce7; color: #166534; }

/* Status row for badges */
.eda-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

/* ═══════════════════════════════════════════════════════
   PACIENTE E EXAME — Clinical panel redesign (pex-)
   ═══════════════════════════════════════════════════════ */

/* --- Hero / case header --- */
.pex-hero {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #f0fdf4 100%);
  border: 1px solid #bae6fd;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}
.pex-hero-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1 1 300px;
  min-width: 0;
}
.pex-hero-nome {
  font-size: 18px;
  font-weight: 700;
  color: #0c4a6e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pex-hero-age {
  font-size: 13px;
  color: #475569;
  white-space: nowrap;
}
.pex-hero-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pex-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pex-badge--tipo { background: #0ea5e9; color: #fff; }
.pex-badge--tipo[data-val="COLONO"] { background: #8b5cf6; }
.pex-badge--tipo[data-val="EDA+COLONO"] { background: linear-gradient(90deg, #0ea5e9, #8b5cf6); color: #fff; }
.pex-badge--tipo[data-val="PROCEDIMENTO"] { background: #f59e0b; color: #fff; }
.pex-badge--asa { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.pex-badge--status { background: #f1f5f9; color: #64748b; }
.pex-badge--status[data-val="em_andamento"] { background: #dcfce7; color: #166534; }
.pex-badge--status[data-val="finalizado"] { background: #dbeafe; color: #1e40af; }

.pex-hero-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 0 0 auto;
}
.pex-hero-data {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
.pex-hero-ind {
  font-size: 12px;
  color: #0369a1;
  font-style: italic;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pex-hero-sub {
  width: 100%;
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}
.pex-hero-sub span:empty { display: none; }

/* --- 2-col panel layout --- */
.pex-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) {
  .pex-panels { grid-template-columns: 1fr; }
}
.pex-col { display: flex; flex-direction: column; gap: 14px; }

/* --- Card --- */
.pex-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.pex-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.pex-card-body { padding: 10px 14px; }

.pex-card--timeline { border-color: #93c5fd; }
.pex-card--timeline .pex-card-head { background: #eff6ff; color: #1e40af; }
.pex-card--meta { border-color: #e2e8f0; }
.pex-card--meta .pex-card-head { background: #f8fafc; color: #64748b; }

/* --- Rows and fields --- */
.pex-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  align-items: flex-end;
}
.pex-row:last-child { margin-bottom: 0; }
.pex-field { flex: 1 1 0; min-width: 0; }
.pex-field--wide { flex: 2 1 0; }
.pex-field--sm { flex: 0 0 auto; min-width: 80px; max-width: 160px; }
.pex-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 3px;
}
.pex-card-body input[type="text"],
.pex-card-body input[type="date"],
.pex-card-body input[type="time"],
.pex-card-body select {
  width: 100%;
  padding: 7px 8px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s;
}
.pex-card-body input:focus,
.pex-card-body select:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 2px rgba(14,165,233,.15);
}
.pex-input--muted {
  background: #f8fafc !important;
  color: #94a3b8 !important;
}
.pex-cond { transition: all .15s; }

/* --- Age badge (derived) --- */
.pex-birth-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pex-birth-group input { flex: 1; }
.pex-age-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #0369a1;
  background: #e0f2fe;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  min-width: 40px;
  text-align: center;
}
.pex-age-badge:empty { display: none; }

/* --- Seg-ctrl variants for pex --- */
.seg-ctrl--pex { gap: 0; }
.seg-ctrl--pex .seg-btn { min-height: 34px; font-size: 12px; }
.seg-ctrl--tipo {
  display: flex;
  gap: 0;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 2px;
}
.seg-ctrl--tipo .seg-btn {
  flex: 1;
  min-height: 38px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: all .15s;
  padding: 0 8px;
}
.seg-ctrl--tipo .seg-btn.on {
  background: #0ea5e9;
  color: #fff;
  box-shadow: 0 1px 3px rgba(14,165,233,.3);
}
.seg-ctrl--tipo .seg-btn--accent.on {
  background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
}
.seg-ctrl--tipo .seg-btn--sm {
  flex: 0.7;
  font-size: 11px;
}
.seg-ctrl--tipo .seg-btn--sm.on {
  background: #f59e0b;
}
.seg-ctrl--asa { gap: 0; }
.seg-ctrl--asa .seg-btn { min-height: 32px; min-width: 32px; font-size: 12px; padding: 0 6px; }

/* --- Data badge in timeline header --- */
.pex-data-badge {
  font-size: 12px;
  font-weight: 600;
  color: #1e40af;
  margin-left: auto;
}

/* --- Timeline blocks --- */
.pex-tl-block {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.pex-tl-block:last-of-type { margin-bottom: 0; }
.pex-tl-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 6px;
}
.pex-tl-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pex-tl-field {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.pex-tl-field input[type="time"] {
  width: 100%;
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-align: center;
}
.pex-tl-field input[type="time"]:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 2px rgba(14,165,233,.15);
}
.pex-tl-icon {
  font-size: 10px;
  color: #94a3b8;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}
.pex-tl-arrow {
  font-size: 14px;
  color: #94a3b8;
  flex-shrink: 0;
}
.pex-tl-dur {
  font-size: 12px;
  font-weight: 700;
  color: #0ea5e9;
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}
.pex-tl-dur:empty { display: none; }
.pex-tl-dur--ret { color: #8b5cf6; }
.pex-tl-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}
.pex-tl-field--ceco {
  flex: 0 1 auto;
  max-width: 160px;
}
.pex-tl-hint {
  font-size: 10px;
  color: #64748b;
  flex-shrink: 0;
}

/* --- Timeline summary --- */
.pex-tl-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  margin-top: 4px;
}
.pex-tl-total {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}
.pex-tl-total:empty { display: none; }
.pex-tl-alert {
  font-size: 11px;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  padding: 2px 8px;
  border-radius: 4px;
}

/* --- Touch targets for iPad --- */
@media (pointer: coarse) {
  .pex-card-body input[type="text"],
  .pex-card-body input[type="date"],
  .pex-card-body select {
    min-height: 42px;
    font-size: 14px;
  }
  .seg-ctrl--tipo .seg-btn { min-height: 44px; font-size: 13px; }
  .pex-tl-field input[type="time"] { min-height: 44px; font-size: 15px; }
  .pex-hero-nome { font-size: 20px; }
}

/* ═══════════════════════════════════════════════════════
   LESÕES REDESIGN — Compact list + type templates
   ═══════════════════════════════════════════════════════ */

.les-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.les-header h2 { margin: 0; }
.les-counters { display: flex; gap: 6px; }
.les-counter-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 999px; background: var(--surface-2); color: var(--ink-soft);
}
.les-counter-badge--ap { background: #dbeafe; color: #1e40af; }

/* Add bar */
.les-add-bar {
  display: flex; gap: 6px; margin-left: auto;
}
.les-add-btn {
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .12s;
}
.les-add-btn:active { transform: scale(0.97); }
.les-add-btn--polipo { border-color: #93c5fd; color: #1d4ed8; }
.les-add-btn--lst { border-color: #c084fc; color: #7c3aed; }
.les-add-btn--massa { border-color: #fca5a5; color: #dc2626; }
.les-add-btn--mucosa { border-color: #86efac; color: #16a34a; }

/* Lesion list */
.les-list { display: flex; flex-direction: column; gap: 4px; }

/* Lesion row (collapsed) */
.les-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; transition: all .12s;
}
.les-row:hover { border-color: var(--brand); }
.les-row.les-row--expanded { border-radius: 8px 8px 0 0; border-bottom: none; }

/* Type badge */
.les-type-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.les-type-badge--polipo { background: #dbeafe; color: #1d4ed8; }
.les-type-badge--lst { background: #ede9fe; color: #7c3aed; }
.les-type-badge--massa { background: #fee2e2; color: #dc2626; }
.les-type-badge--alt_mucosa { background: #dcfce7; color: #16a34a; }

/* Summary text */
.les-summary {
  flex: 1; min-width: 0; font-size: 13px; color: var(--ink); line-height: 1.4;
  /* #43 (2026-04-24): permite até 2 linhas — topografia precisa ficar visível sem expandir o card */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.les-summary-empty { color: var(--ink-soft); font-style: italic; }

/* AP badge */
.les-ap-badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
}
.les-ap-badge--sim { background: #dbeafe; color: #1e40af; }
.les-ap-badge--nao { background: #f1f5f9; color: #94a3b8; }

/* Origem badge (exame dual) — mostra de qual exame a lesão é */
.les-origem-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing:.3px;
  padding: 2px 6px; border-radius: 4px; text-transform: uppercase;
  border: 1px solid transparent;
}
.les-origem-badge--eda    { background:#e0f2fe; color:#0369a1; border-color:#7dd3fc; }
.les-origem-badge--colono { background:#fee2e2; color:#b91c1c; border-color:#fca5a5; }

/* #45 (2026-04-24): toggle persistente "Próximo achado: EDA / Colono / Perguntar" — só visível em exame dual */
.les-origem-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 8px 0;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  flex-wrap: wrap;
}
.les-origem-bar-label {
  font-size: 12px; font-weight: 600; color: var(--ink-soft, #64748b);
  white-space: nowrap;
}
.les-origem-bar-segs {
  display: inline-flex; gap: 0;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 6px; overflow: hidden;
  background: #fff;
}
.les-origem-seg {
  border: none; background: transparent;
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  color: var(--ink-soft, #64748b);
  cursor: pointer; transition: all .12s;
  border-right: 1px solid var(--line, #e2e8f0);
}
.les-origem-seg:last-child { border-right: none; }
.les-origem-seg:hover { background: var(--surface-2, #f1f5f9); color: var(--ink, #0f172a); }
.les-origem-seg.on[data-origem-set="eda"]    { background: #e0f2fe; color: #0369a1; }
.les-origem-seg.on[data-origem-set="colono"] { background: #fee2e2; color: #b91c1c; }
.les-origem-seg.on[data-origem-set="ask"]    { background: #f1f5f9; color: #475569; }
.les-origem-seg--ask { font-style: italic; }

/* B3 (#10, 2026-04-24): bulk delete lesões — checkbox + barra de ação */
.les-bulk-cb {
  margin-right: 6px;
  width: 16px; height: 16px;
  cursor: pointer; accent-color: #dc2626;
}
.les-row--selected {
  background: #fef2f2 !important;
  border-color: #fecaca;
}
.les-bulk-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 8px 0;
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; flex-wrap: wrap;
}
.les-bulk-count {
  font-size: 12px; font-weight: 700; color: #b91c1c;
  flex: 1;
}
.les-bulk-btn {
  padding: 5px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .12s;
  border: 1px solid;
}
.les-bulk-btn--del {
  background: #dc2626; color: #fff; border-color: #dc2626;
}
.les-bulk-btn--del:hover { background: #b91c1c; }
.les-bulk-btn--clear {
  background: #fff; color: #475569; border-color: #cbd5e1;
}
.les-bulk-btn--clear:hover { background: #f1f5f9; }

/* C1 (#2, 2026-04-24): card Histórico Clínico — chips de comorbidades */
.pex-card--hist .pex-card-head {
  background: linear-gradient(180deg,#fef3c7 0%,#fde68a 100%);
  color: #78350f;
}
.pex-field--full { width: 100%; }
.hist-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 4px 0;
}
.hist-chip {
  padding: 5px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all .12s;
  user-select: none;
}
.hist-chip:hover { border-color: #94a3b8; background: #f8fafc; }
.hist-chip.on {
  background: #fef3c7; border-color: #f59e0b; color: #78350f;
  font-weight: 600;
}
/* Comorbidades da tela de exame (Fase 2, 2026-06-06): mesmo visual indigo/pill do cadastro */
.hist-chips--comorb .hist-chip { border-radius: 999px; padding: 5px 13px; }
.hist-chips--comorb .hist-chip:hover { border-color: #a5b4fc; background: #f5f6ff; }
.hist-chips--comorb .hist-chip.on {
  background: #eef2ff; border-color: #6366f1; color: #3730a3; font-weight: 600;
}
.hist-chips--comorb .hist-chip.on::before { content: '✓ '; color: #4f46e5; font-weight: 700; }

/* C2 (#3, 2026-04-24): chips multi-topografia em achados colono */
.achado-topo-chips { display: flex; flex-wrap: wrap; gap: 3px; }
.achado-topo-chip {
  font-size: 10px; padding: 2px 8px;
  border: 1px solid #e2e8f0; border-radius: 4px;
  background: #fff; color: #64748b;
  cursor: pointer; transition: all .12s;
}
.achado-topo-chip:hover { border-color: #94a3b8; background: #f8fafc; }
.achado-topo-chip.on {
  background: #dbeafe; border-color: #3b82f6; color: #1e40af;
  font-weight: 600;
}

/* D1 (#7, 2026-04-24): chips esquemas H. pylori */
.hp-esquemas-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 0; }
.hp-chip {
  font-size: 11px; padding: 5px 9px;
  border: 1px solid #e2e8f0; border-radius: 6px;
  background: #fff; color: #475569;
  cursor: pointer; transition: all .12s; user-select: none;
  text-align: left; line-height: 1.3;
}
.hp-chip:hover { border-color: #94a3b8; background: #f8fafc; }
.hp-chip.on {
  background: #ecfdf5; border-color: #10b981; color: #065f46;
  font-weight: 600;
}
.hp-chip[data-val="bismuto_metro_tetra_vpz_14d"] {
  /* 1ª linha — destaque sutil */
  border-left: 3px solid #f59e0b;
}

/* D1.1 (#7, 2026-04-25): card HP em s_pac_exame */
.pex-card--hp .pex-card-head {
  background: linear-gradient(180deg,#dbeafe 0%,#93c5fd 100%);
  color: #1e3a8a;
}

/* A4 (#5, 2026-04-24): default endoscopista — input lock + botão Modificar */
.endo-input-wrap { display: flex; align-items: center; gap: 6px; }
.endo-input-wrap input { flex: 1; }
.endo-input-wrap[data-endo-locked="true"] input {
  background: #f8fafc; color: #475569;
  border-color: #e2e8f0; cursor: default;
}
.endo-input-wrap[data-endo-locked="false"] .btn-endo-edit { display: none; }
.btn-endo-edit {
  font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 4px;
  background: #f1f5f9; color: #475569;
  border: 1px solid #cbd5e1; cursor: pointer;
  transition: all .12s;
}
.btn-endo-edit:hover { background: #e2e8f0; color: #0f172a; }

/* Actions */
.les-actions { display: flex; gap: 4px; }
.les-btn-expand, .les-btn-del {
  width: 28px; height: 28px; border-radius: 6px; border: none;
  background: transparent; color: var(--ink-soft); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .12s;
}
.les-btn-expand:hover { background: var(--surface-2); }
.les-btn-del:hover { background: #fee2e2; color: #dc2626; }

/* Edit panel (expanded) */
.les-edit {
  padding: 12px 14px; background: #fafbfc; border: 1px solid var(--line);
  border-top: none; border-radius: 0 0 8px 8px; display: none;
}
.les-edit.open { display: block; }

/* Edit sections */
.les-edit-section { margin-bottom: 8px; }
.les-edit-section-label {
  font-size: 10px; font-weight: 700; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px;
}

/* Edit grid — auto-fit faz as seções parciais (2–3 campos) preencherem a largura
   do card em vez de deixar colunas vazias à direita (antes era fixo em 4 colunas). */
.les-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
@media (min-width: 900px) {
  .les-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .les-grid--wide { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

/* Edit field */
.les-field {
  display: flex; flex-direction: column; gap: 2px;
}
.les-field-label {
  font-size: 10px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: .03em;
}
.les-field select, .les-field input {
  height: 34px; padding: 0 8px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink);
}

/* Quick technique chips — preenchem a largura (antes agrupavam à esquerda) */
.les-tecnica-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.les-tecnica-chip {
  flex: 1 1 auto;
  height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all .12s;
}
.les-tecnica-chip.on {
  background: var(--brand); color: #fff; border-color: var(--brand);
}

/* Mucosal descriptor chips (seg-ctrl style) */
.les-desc-grid {
  display: grid; gap: 6px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 900px) {
  .les-desc-grid { grid-template-columns: repeat(4, 1fr); }
}
.les-desc-item {
  display: flex; flex-direction: column; gap: 2px;
}

/* Item wrapper */
.les-item-wrapper { margin-bottom: 2px; }

/* Detail toggle */
.les-detail-toggle { margin-top: 4px; }
.les-detail-btn {
  font-size: 11px; color: var(--brand); cursor: pointer;
  background: none; border: none; padding: 4px 0; font-weight: 600;
}
.les-detail-panel { padding: 4px 0; }

/* Agenda terapêutica (lesão "não removida") — ajustes PDF 2026-06-08 */
.les-naoremovida-wrap { padding: 6px 0; }
.les-agendar-btn { font-size: 12px; padding: 6px 12px; border: 1px solid #d97706; border-radius: 8px; background: #fffbeb; color: #92400e; cursor: pointer; font-weight: 600; min-height: 34px; }
.les-agendar-btn.is-on { background: #d97706; color: #fff; }
.les-agendar-hint { font-size: 11px; color: #92400e; margin-top: 4px; }
.les-field--compact select { max-width: 170px; }

/* Agenda terapêutica — lista de pendências na tela Agenda (ajustes PDF 2026-06-08) */
.ag-terap { margin: 8px 0 4px; border: 1px solid #fcd34d; border-radius: 10px; background: #fffbeb; overflow: hidden; }
.ag-terap-head { cursor: pointer; padding: 10px 12px; font-size: 13px; font-weight: 700; color: #92400e; display: flex; align-items: center; gap: 6px; list-style: none; }
.ag-terap-head::-webkit-details-marker { display: none; }
.ag-terap-count { background: #d97706; color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.ag-terap-sub { font-weight: 400; color: #b45309; font-size: 11px; }
.ag-terap-list { display: flex; flex-direction: column; gap: 4px; padding: 0 8px 10px; }
.ag-terap-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: #fff; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; cursor: pointer; min-height: 40px; }
.ag-terap-item:hover { background: #fef3c7; }
.ag-terap-nome { font-weight: 700; color: #0f172a; font-size: 13px; }
.ag-terap-desc { flex: 1 1 auto; color: #475569; font-size: 12px; }
.ag-terap-data { color: #92400e; font-size: 12px; font-weight: 600; }

/* Frasco field inline */
.les-frasco-field input[readonly] {
  background: var(--surface-2); cursor: default;
}

@media (pointer: coarse) {
  .les-row { padding: 10px 14px; }
  .les-add-btn { min-height: 44px; font-size: 13px; }
  .les-tecnica-chip { min-height: 38px; font-size: 12px; }
  .les-btn-expand, .les-btn-del { width: 36px; height: 36px; }
}

/* ═══ Achados colonoscópicos contextuais ═══ */
.chip-achado {
  font-size: 10px; padding: 3px 8px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.chip-achado.active {
  background: var(--col-primary, #10b981); color: #fff;
  border-color: var(--col-primary, #10b981);
}
.achado-item { font-size: 11px; }
.achado-item .btn--sm { cursor: pointer; background: none; border: 1px solid #fecaca; border-radius: 4px; }
.achado-item .btn--sm:hover { background: #fef2f2; }

/* ═══ Retite actínica sub-sections ═══ */
.retite-sub { padding: 4px 0; }
.retite-sub .classif-chips { gap: 4px; }

/* ═══ New organ badge colors ═══ */
.cx-card-organ--col { background: #10b981; }

/* ═══ Seg-ctrl disabled state ═══ */
.seg-disabled { opacity: 0.4; pointer-events: none; }
.seg-disabled .seg-btn { cursor: not-allowed; }

/* ═══ Goligher legend ═══ */
.goligher-legend {
  display: flex; flex-wrap: wrap; gap: 2px 10px;
  font-size: 9px; color: #64748b; margin-top: 4px; line-height: 1.4;
  padding: 4px 6px; background: #f8fafc; border-radius: 4px;
}
.goligher-legend-title { font-weight: 600; color: #475569; width: 100%; margin-bottom: 1px; }
.goligher-legend-item { white-space: nowrap; }
.goligher-legend b { color: #334155; font-weight: 700; }

/* ═══════════════════════════════════════════ */
/*   ASSINATURA / FINALIZAÇÃO — redesign      */
/* ═══════════════════════════════════════════ */

/* Checkpoint card (resumo pré-assinatura) */
.chk-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.chk-head { padding: 10px 14px; font-weight: 600; font-size: 13px; color: #334155; background: #f1f5f9; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.chk-body { padding: 12px 14px; }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 12px; }
.chk-row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #f1f5f9; }
.chk-label { color: #64748b; }
.chk-value { font-weight: 500; color: #1e293b; text-align: right; }
.chk-value--ok { color: #16a34a; }
.chk-value--warn { color: #d97706; }
.chk-value--danger { color: #dc2626; }
.chk-value--muted { color: #94a3b8; font-style: italic; }

/* Assinatura card */
.sig-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.sig-card-head { padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #f1f5f9; }
.sig-card-title { font-weight: 600; font-size: 13px; color: #334155; }
.sig-card-status { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.sig-card-status--pending { background: #fef3c7; color: #92400e; }
.sig-card-status--signed { background: #d1fae5; color: #065f46; }
.sig-card-body { padding: 12px 14px; }
.sig-meta-row { display: flex; gap: 12px; margin-bottom: 10px; }
.sig-meta-field { flex: 1; }
.sig-meta-field label { display: block; font-size: 11px; color: #64748b; margin-bottom: 3px; font-weight: 500; }
.sig-meta-field input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.sig-canvas-wrap { position: relative; border: 1px dashed #cbd5e1; border-radius: var(--radius-sm); background: #fafbfc; overflow: hidden; }
.sig-canvas-wrap canvas { display: block; width: 100%; height: 140px; touch-action: none; cursor: crosshair; }
.sig-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.sig-actions button { padding: 5px 14px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.sig-actions button.sig-btn-save { background: #2563eb; color: #fff; border-color: #2563eb; }
.sig-note { font-size: 10px; color: #94a3b8; margin-top: 6px; line-height: 1.4; }

/* Signatário adicional (colapsado por padrão) */
.sig-extra { border-top: 1px solid #f1f5f9; padding: 10px 14px; }
.sig-extra-toggle { font-size: 12px; color: #6366f1; cursor: pointer; font-weight: 500; }
.sig-extra-body { display: none; margin-top: 10px; }
.sig-extra.open .sig-extra-body { display: block; }

/* Finalização stepper */
.fin-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.fin-head { padding: 10px 14px; font-weight: 600; font-size: 13px; color: #334155; background: #f1f5f9; border-bottom: 1px solid var(--line); }
.fin-body { padding: 14px; }
.fin-stepper { display: flex; gap: 0; margin-bottom: 14px; }
.fin-step { flex: 1; text-align: center; padding: 8px 4px; font-size: 11px; font-weight: 500; border-bottom: 3px solid #e2e8f0; color: #94a3b8; transition: all .2s; }
.fin-step--active { border-color: #2563eb; color: #2563eb; }
.fin-step--done { border-color: #16a34a; color: #16a34a; }
.fin-status-select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.fin-validation { padding: 10px; background: #fafafa; border-radius: var(--radius-sm); margin-bottom: 12px; min-height: 40px; }
.fin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fin-btn { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; border: none; cursor: pointer; }
.fin-btn--primary { background: #2563eb; color: #fff; }
.fin-btn--success { background: #16a34a; color: #fff; }
.fin-btn--outline { background: transparent; color: #475569; border: 1px solid var(--line); }
.fin-btn--warn { background: #d97706; color: #fff; }
.fin-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.fin-info { padding: 10px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 12px; color: #065f46; }
.fin-info--pending { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.fin-post-actions { margin-top: 14px; padding-top: 12px; border-top: 1px solid #f1f5f9; display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════ */
/*   CADASTROS / CONFIGURAÇÃO — redesign      */
/* ═══════════════════════════════════════════ */
.cfg-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.cfg-head { padding: 10px 14px; font-weight: 600; font-size: 13px; color: #334155; background: #f8fafc; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.cfg-body { padding: 12px 14px; }
.cfg-row { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.cfg-field { flex: 1; min-width: 140px; }
.cfg-field label { display: block; font-size: 11px; color: #64748b; margin-bottom: 3px; font-weight: 500; }
.cfg-field input, .cfg-field select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; }
.cfg-toggle { display: flex; align-items: flex-start; gap: 10px; padding: 10px; background: #f8fafc; border-radius: var(--radius-sm); cursor: pointer; }
.cfg-toggle input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; }
.cfg-toggle-text { font-size: 13px; font-weight: 500; color: #334155; }
.cfg-toggle-desc { font-size: 11px; color: #64748b; margin-top: 2px; }
.cfg-cert-note { padding: 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius-sm); font-size: 11px; color: #1e40af; line-height: 1.4; margin-top: 10px; }
.cfg-vig-btn { display: flex; align-items: center; gap: 10px; padding: 12px; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500; color: #0369a1; transition: background .2s; }
.cfg-vig-btn:hover { background: #e0f2fe; }

/* Vigilância modal/overlay */
.vig-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; display: none; align-items: center; justify-content: center; }
.vig-overlay.open { display: flex; }
.vig-modal { background: #fff; border-radius: 12px; width: 90%; max-width: 800px; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.vig-modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.vig-modal-head h3 { margin: 0; font-size: 16px; }
.vig-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #94a3b8; padding: 4px; }
.vig-modal-body { padding: 14px 18px; }

/* ── Anatomia / Alterações Cirúrgicas ── */
.anat-card { border-left: 3px solid #f59e0b; }
.anat-detail { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e5e7eb; }
.anat-detail .col-row { margin-bottom: 6px; }
.anat-tipo-sel, .anat-grupo-sel { min-width: 200px; }
.anat-resumo { margin-top: 10px; padding: 8px 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; font-size: 12px; line-height: 1.5; }
.anat-resumo-label { font-weight: 600; color: #92400e; margin-right: 6px; }
.anat-resumo-text { color: #78350f; }

/* ════════════════════════════════════════════════════════════════════════════
 * UX v1.3 — Templates de frases (Seção 9 Bloco E + modais)
 * ════════════════════════════════════════════════════════════════════════════ */
.tpl-toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.tpl-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; color: #334155; cursor: pointer; }
.tpl-filter-chip input[type="checkbox"] { margin: 0; }
.tpl-toolbar-actions { display: flex; gap: 6px; }

.tpl-table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tpl-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.tpl-table thead th { background: #f8fafc; padding: 8px 10px; text-align: left; font-weight: 600; color: #334155; border-bottom: 1px solid var(--line); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.tpl-table tbody td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.tpl-table tbody tr:hover { background: #fafafa; }
.tpl-table tbody tr:last-child td { border-bottom: none; }
.tpl-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; color: #fff; font-weight: 600; letter-spacing: .3px; }
.tpl-seed-badge { display: inline-block; padding: 1px 6px; background: #fef3c7; color: #92400e; border-radius: 999px; font-size: 9px; font-weight: 600; margin-left: 4px; vertical-align: middle; }
.tpl-preview { font-size: 11px; color: #475569; line-height: 1.4; display: inline-block; }

/* Botão tpl-picker inline (pequeno) */
.tpl-picker-btn--tiny { padding: 0 5px; font-size: 12px; line-height: 1; height: 18px; min-height: 18px; background: transparent; border: 1px solid var(--line); color: #475569; cursor: pointer; border-radius: 4px; }
.tpl-picker-btn--tiny:hover { background: #f1f5f9; color: #1e40af; }

/* Overlay + modal base (compartilhado entre editor e picker) */
.tpl-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); z-index: 1050; display: none; align-items: center; justify-content: center; padding: 20px; }
.tpl-overlay.show { display: flex; }
.tpl-modal { background: #fff; border-radius: 12px; width: 90%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 25px 70px rgba(0,0,0,0.35); }
.tpl-modal--picker { max-width: 720px; }
.tpl-modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.tpl-modal-head h3 { margin: 0; font-size: 16px; color: #1e293b; }
.tpl-modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #94a3b8; padding: 4px 8px; line-height: 1; }
.tpl-modal-close:hover { color: #334155; }
.tpl-modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.tpl-modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-shrink: 0; background: #fafafa; border-radius: 0 0 12px 12px; }

/* Editor form */
.tpl-form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.tpl-form-field { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.tpl-form-field > span:first-child { font-size: 11px; color: #64748b; font-weight: 500; }
.tpl-form-field input[type="text"],
.tpl-form-field select,
.tpl-form-field textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; }
.tpl-form-field textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
.tpl-form-hint { font-size: 11px; color: #64748b; margin-top: 4px; }
.tpl-form-hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 3px; font-size: 10px; color: #1e293b; }

/* Picker list */
.tpl-picker-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.tpl-picker-list { display: flex; flex-direction: column; gap: 8px; }
.tpl-picker-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fafafa; transition: background .15s, border-color .15s; }
.tpl-picker-item:hover { background: #f0f9ff; border-color: #bae6fd; }
.tpl-picker-item-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.tpl-picker-item-head strong { color: #1e293b; font-size: 13px; flex: 1; min-width: 150px; }
.tpl-picker-item-body { font-size: 12px; color: #334155; line-height: 1.5; margin-bottom: 8px; white-space: pre-wrap; max-height: 120px; overflow-y: auto; }
.tpl-picker-item-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============================================================
 * REFORMA CADASTROS FASE 1 — 2026-04-19
 * Módulos globais: Mestres / Vigilância / Config
 * ============================================================ */

/* Topbar módulos */
.tb-modules {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0 12px;
  padding: 0 12px;
  border-left: 1px solid rgba(148,163,184,.3);
  border-right: 1px solid rgba(148,163,184,.3);
}
.tb-btn.tb-btn--module {
  background: #fff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  font-weight: 500;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}
.tb-btn.tb-btn--module:hover { background: #f1f5f9; border-color: #94a3b8; }
.tb-btn.tb-btn--module.active { background: #1e293b; color: #fff; border-color: #1e293b; }

/* Screens de módulo — full width, sem sidenav nem aside */
/* REGRA: altura deve casar com #screen_agenda.active (linhas 59-63).
   Sem `height: calc(100vh - 52px)` o overflow-y não rola — o container
   cresce junto com o conteúdo e o scroll delega pro body (que também
   não rola porque html/body têm height:100% sem overflow). */
#screen_mestres.active,
#screen_vigilancia.active,
#screen_config.active {
  height: calc(100vh - 52px);
  overflow-y: auto;
  padding: 24px;
}
.mst-wrap {
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
  overflow: hidden;
}

/* Topo do módulo */
.mst-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.mst-title { display: flex; gap: 14px; align-items: center; }
.mst-icon {
  font-size: 28px;
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e0f2fe;
  border-radius: 10px;
}
.mst-title h1 { font-size: 19px; font-weight: 600; margin: 0; color: #0f172a; }
.mst-sub { font-size: 12px; color: #64748b; margin: 2px 0 0 0; }

/* Tabs internas */
.mst-tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  overflow-x: auto;
}
.mst-tab, .cfg-tab {
  background: transparent;
  border: none;
  padding: 12px 16px;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.mst-tab:hover, .cfg-tab:hover { color: #1e293b; }
.mst-tab.active, .cfg-tab.active {
  color: #0369a1;
  border-bottom-color: #0369a1;
}

/* Painéis */
.mst-panel { display: none; padding: 20px 24px; }
.mst-panel.active { display: block; }

/* Toolbar de painel */
.mst-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.mst-toolbar-left { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; flex: 1; min-width: 300px; }
.mst-toolbar-actions { display: flex; gap: 8px; align-items: center; }
.mst-filters { display: flex; gap: 6px; flex-wrap: wrap; }

/* Campo de busca */
.mst-search {
  min-width: 260px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}
.mst-search:focus { outline: none; border-color: #0369a1; box-shadow: 0 0 0 2px rgba(3,105,161,.15); }

/* Tabela */
.mst-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.mst-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mst-table thead { background: #f8fafc; }
.mst-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--line);
}
.mst-table tbody tr { transition: background .1s; }
.mst-table tbody tr:hover { background: #f8fafc; }
.mst-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.mst-table tbody tr:last-child td { border-bottom: none; }

/* Empty state */
.mst-empty {
  padding: 40px 20px;
  text-align: center;
  color: #64748b;
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafafa;
}

/* Stub (FASE 2/3) */
.mst-stub {
  padding: 60px 30px;
  text-align: center;
  background: #fafafa;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.mst-stub-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.mst-stub h2 { font-size: 17px; color: #475569; margin: 0 0 8px 0; }
.mst-stub p { font-size: 13px; color: #64748b; max-width: 500px; margin: 0 auto; line-height: 1.5; }

/* Dedupe alert (dentro do modal de paciente) */
.dedupe-alert {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  border-radius: 6px;
  overflow: hidden;
}
.dedupe-alert b { color: #1e293b; }

/* Search result inline (FASE 2 — autocomplete rico) */
.pac-search-result {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  background: #f8fafc;
  cursor: pointer;
}
.pac-search-result:hover { background: #e0f2fe; border-color: #7dd3fc; }

/* Config sections — reaproveita .cfg-* já existentes (mantém consistência visual) */

/* Impressão: oculta screens de módulo */
@media print {
  #screen_mestres, #screen_vigilancia, #screen_config { display: none !important; }
  .tb-modules { display: none !important; }
}

/* Mobile / iPad */
@media (max-width: 768px) {
  #screen_mestres, #screen_vigilancia, #screen_config { padding: 12px; }
  .mst-topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding: 14px 16px; }
  .mst-tabs { padding: 0 8px; }
  .mst-tab, .cfg-tab { padding: 10px 12px; font-size: 12px; }
  .mst-panel { padding: 14px 16px; }
  .mst-toolbar { flex-direction: column; align-items: stretch; }
  .mst-toolbar-left { flex-direction: column; align-items: stretch; }
  .mst-search { min-width: 0; width: 100%; }
  .tb-modules {
    margin: 0 4px;
    padding: 0 4px;
  }
  .tb-btn.tb-btn--module {
    padding: 5px 7px;
    font-size: 11px;
  }
}

/* =========================================================
   IMPORTAÇÃO DE PACIENTES (CSV / XLSX) — 2026-04-20
   ========================================================= */
.imp-overlay .imp-modal{
  max-width: 1060px;
  width: calc(100vw - 32px);
}
.imp-stepper{
  display:flex;
  gap:6px;
  padding:10px 16px 0;
  border-bottom:1px solid var(--line,#e5e7eb);
  background:#fafafa;
}
.imp-step{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:6px 6px 0 0;
  color:#64748b;
  font-size:12px;
  font-weight:500;
  border-bottom:3px solid transparent;
}
.imp-step-n{
  width:22px;height:22px;border-radius:50%;
  background:#e2e8f0;color:#475569;
  display:flex;align-items:center;justify-content:center;
  font-size:12px;font-weight:700;
}
.imp-step.active{ color:#0f172a; border-bottom-color:#2563eb; background:#fff; }
.imp-step.active .imp-step-n{ background:#2563eb; color:#fff; }
.imp-step.done .imp-step-n{ background:#16a34a; color:#fff; }
.imp-step.done .imp-step-n::before{ content:"✓"; }
.imp-step.done .imp-step-n > *{ display:none; }

.imp-body{ padding:16px; max-height:72vh; overflow:auto; }
.imp-pane{ display:block; }
.imp-pane[hidden]{ display:none !important; }

.imp-drop{
  border:2px dashed #cbd5e1;
  border-radius:10px;
  padding:32px 16px;
  text-align:center;
  background:#f8fafc;
  transition:border-color .15s, background .15s;
}
.imp-drop.is-drag{ border-color:#2563eb; background:#eff6ff; }
.imp-drop-icon{ font-size:42px; margin-bottom:6px; }
.imp-drop-title{ font-size:15px; font-weight:600; color:#0f172a; margin-bottom:2px; }
.imp-drop-hint{ font-size:12px; color:#64748b; margin-bottom:12px; }
.imp-drop-meta{ margin-top:10px; font-size:12px; color:#334155; }
.imp-drop-meta strong{ color:#0f172a; }

.imp-opts{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap:10px;
  margin-top:14px;
}
.imp-opts label{
  display:flex; flex-direction:column; gap:4px;
  font-size:11px; color:#475569; font-weight:500;
}
.imp-opts label select, .imp-opts label input{
  padding:6px 8px; font-size:13px;
  border:1px solid #d1d5db; border-radius:6px; background:#fff;
}

.imp-hint{ margin-top:10px; font-size:12px; color:#64748b; }
.imp-hint--warn{
  margin-top:10px; padding:8px 10px;
  background:#fef3c7; border:1px solid #fde68a;
  color:#78350f; border-radius:6px; font-size:12px;
}

.imp-map-wrap{ max-height:50vh; overflow:auto; border:1px solid var(--line,#e5e7eb); border-radius:6px; }
.imp-map-table{ width:100%; border-collapse:collapse; font-size:13px; }
.imp-map-table th, .imp-map-table td{
  padding:8px 10px; text-align:left; border-bottom:1px solid #f1f5f9;
  vertical-align:middle;
}
.imp-map-table thead th{
  position:sticky; top:0; background:#f8fafc; font-size:11px; color:#475569;
  text-transform:uppercase; letter-spacing:.05em; font-weight:600;
}
.imp-map-table td select{
  width:100%; padding:5px 8px; font-size:13px;
  border:1px solid #d1d5db; border-radius:4px; background:#fff;
}
.imp-map-table .imp-field-label{
  font-weight:600; color:#0f172a; font-size:13px;
}
.imp-map-table .imp-field-req{ color:#dc2626; margin-left:2px; }
.imp-map-table .imp-example{ font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:12px; color:#475569; }

.imp-stats{
  display:flex; flex-wrap:wrap; gap:8px; margin-bottom:10px;
}
.imp-stat{
  padding:6px 10px; border-radius:6px; font-size:12px; font-weight:500;
  border:1px solid transparent;
}
.imp-stat strong{ font-weight:700; margin-left:4px; }
.imp-stat--total{ background:#f1f5f9; color:#0f172a; border-color:#e2e8f0; }
.imp-stat--ok{ background:#dcfce7; color:#14532d; border-color:#bbf7d0; }
.imp-stat--warn{ background:#fef3c7; color:#78350f; border-color:#fde68a; }
.imp-stat--soft{ background:#e0e7ff; color:#312e81; border-color:#c7d2fe; }
.imp-stat--err{ background:#fee2e2; color:#7f1d1d; border-color:#fecaca; }

.imp-filter{
  display:flex; flex-wrap:wrap; gap:10px; align-items:center;
  margin-bottom:8px; font-size:12px; color:#475569;
}
.imp-filter label{ display:inline-flex; gap:4px; align-items:center; }
.imp-filter input[type="search"]{
  flex:1; min-width:180px; padding:5px 8px; font-size:13px;
  border:1px solid #d1d5db; border-radius:6px;
}

.imp-preview-wrap{
  max-height:50vh; overflow:auto; border:1px solid var(--line,#e5e7eb); border-radius:6px;
}
.imp-preview-table{ width:100%; border-collapse:collapse; font-size:12px; }
.imp-preview-table th, .imp-preview-table td{
  padding:6px 8px; border-bottom:1px solid #f1f5f9; text-align:left;
  vertical-align:top;
}
.imp-preview-table thead th{
  position:sticky; top:0; background:#f8fafc; font-size:10px; color:#475569;
  text-transform:uppercase; letter-spacing:.05em; font-weight:600;
}
.imp-preview-table tr[data-status="error"]{ background:#fef2f2; }
.imp-preview-table tr[data-status="dup_strong"]{ background:#fffbeb; }
.imp-preview-table tr[data-status="dup_soft"]{ background:#eef2ff; }
.imp-preview-table .imp-badge{
  display:inline-block; padding:2px 6px; border-radius:4px;
  font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.04em;
}
.imp-badge--new{ background:#dcfce7; color:#14532d; }
.imp-badge--strong{ background:#fef3c7; color:#78350f; }
.imp-badge--soft{ background:#e0e7ff; color:#312e81; }
.imp-badge--err{ background:#fee2e2; color:#7f1d1d; }
.imp-err-list{ font-size:11px; color:#7f1d1d; margin-top:2px; }

.imp-result{
  padding:20px; text-align:center;
}
.imp-result-icon{ font-size:52px; margin-bottom:8px; }
.imp-result-title{ font-size:18px; font-weight:700; margin-bottom:8px; color:#0f172a; }
.imp-result-detail{ font-size:13px; color:#475569; margin-bottom:16px; }
.imp-result-stats{
  display:inline-flex; gap:12px; padding:12px 16px;
  background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px;
  font-size:13px; color:#0f172a;
}
.imp-result-stats strong{ font-weight:700; }

.imp-foot{ display:flex; align-items:center; gap:8px; }

@media (max-width: 820px){
  .imp-stepper{ overflow-x:auto; }
  .imp-step-l{ display:none; }
  .imp-opts{ grid-template-columns: 1fr 1fr; }
}
@media print{
  .imp-overlay{ display:none !important; }
}

/* =========================================================
   BULK DELETE + LIXEIRA DE PACIENTES (Sprint 2 Item 1) — 2026-04-23
   ========================================================= */

/* Bulk action bar (aparece só quando há seleção) */
.pac-bulk-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 14px;
  margin:8px 0 0;
  background:#fef3c7;
  border:1px solid #fcd34d;
  border-radius:8px;
  font-size:13px;
  color:#78350f;
}
.pac-bulk-bar[hidden]{ display:none !important; }
.pac-bulk-info strong{ font-size:15px; color:#b45309; }
.pac-bulk-actions{ display:flex; gap:8px; }

/* Checkbox cell na tabela de pacientes */
.pac-chk-cell{ text-align:center; padding:4px !important; }
.pac-row-chk{ cursor:pointer; width:16px; height:16px; }

/* =========================================================
   AGENDA — SELEÇÃO MÚLTIPLA + EXCLUSÃO EM MASSA — 2026-07-05
   Discreto de propósito: apagar não é rotina. Barra fina, sem fundo
   chamativo; as ações só aparecem quando há algo selecionado.
   ========================================================= */
.ag-bulk-bar{
  display:flex;
  align-items:center;
  gap:10px;
  padding:3px 4px 5px;
  margin:0 0 6px;
  font-size:11.5px;
  color:#9a8a73;
  background:transparent;
  border-bottom:1px solid rgba(120,85,51,.10);
}
.ag-bulk-selectall{
  display:flex; align-items:center; gap:5px;
  cursor:pointer; user-select:none; color:#9a8a73;
}
.ag-bulk-selectall input{ width:13px; height:13px; cursor:pointer; }
.ag-bulk-actions{ display:flex; align-items:center; gap:10px; margin-left:auto; }
.ag-bulk-actions[hidden]{ display:none; }
.ag-bulk-info strong{ color:#785533; font-weight:700; }
.ag-bulk-clear{
  background:transparent; border:none; padding:0;
  color:#9a8a73; font-size:11.5px; cursor:pointer; text-decoration:underline;
}
.ag-bulk-clear:hover{ color:#785533; }
.ag-bulk-del{
  background:transparent; border:1px solid #e3c9c0; color:#b0503f;
  padding:2px 9px; border-radius:6px; font-size:11.5px; cursor:pointer;
}
.ag-bulk-del:hover{ background:#fbeae6; border-color:#d9a99d; }
.ag-bulk-del:disabled{ opacity:.5; cursor:default; }
/* Checkbox por linha: sutil por padrão, realça no hover/selecionado. */
.ag-row-chk{
  cursor:pointer; width:14px; height:14px; margin-right:7px; flex:0 0 auto;
  opacity:.5; transition:opacity .12s ease;
}
.ag-row-chk:hover, .ag-row-chk:checked, .ag-row:hover .ag-row-chk{ opacity:1; }

/* =========================================================
   CONFIGURAÇÕES — RESET DE DADOS DE TESTE (SOMENTE MASTER) — 2026-07-05
   ========================================================= */
.reset-teste-tag{
  font-size:10px; font-weight:700; letter-spacing:.04em;
  color:#b91c1c; background:#fee2e2; border:1px solid #fecaca;
  border-radius:4px; padding:2px 6px; margin-left:8px; vertical-align:middle;
}
.reset-teste-section .cfg-body p{ font-size:13px; color:#475569; margin:0 0 8px; }
.reset-teste-table{ width:100%; max-width:420px; border-collapse:collapse; font-size:13px; }
.reset-teste-table th, .reset-teste-table td{ padding:6px 10px; border-bottom:1px solid var(--line, #e5e7eb); }
.reset-teste-table thead th{ text-align:left; color:#64748b; font-weight:600; font-size:11px; text-transform:uppercase; }
.reset-teste-table tfoot td{ border-top:2px solid var(--line, #e5e7eb); border-bottom:none; }

/* Sprint 3 Item #60 — Paginação lista de pacientes */
.pac-pagination{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 14px;
  margin:12px 0 0;
  background:var(--bg-soft, #f9fafb);
  border:1px solid var(--line, #e5e7eb);
  border-radius:8px;
  font-size:13px;
  color:var(--ink, #1f2937);
  flex-wrap:wrap;
}
.pac-pagination[hidden]{ display:none !important; }
.pac-pag-info{ font-weight:500; color:var(--ink-soft, #6b7280); }
.pac-pag-info span strong{ color:var(--ink, #1f2937); }
.pac-pag-controls{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.pac-pag-label{ display:flex; align-items:center; gap:6px; margin-right:8px; font-size:12px; color:var(--ink-soft, #6b7280); }
.pac-pag-label select{ padding:4px 8px; border:1px solid var(--line, #e5e7eb); border-radius:6px; background:#fff; font-size:13px; cursor:pointer; }
.pac-pag-pages{ display:inline-flex; gap:4px; align-items:center; }
.pac-pag-pages button{
  min-width:32px;
  height:28px;
  padding:0 8px;
  border:1px solid var(--line, #e5e7eb);
  border-radius:6px;
  background:#fff;
  font-size:13px;
  cursor:pointer;
  color:var(--ink, #1f2937);
}
.pac-pag-pages button:hover:not(:disabled){ background:var(--bg-soft, #f3f4f6); }
.pac-pag-pages button.pac-pag-current{
  background:var(--brand, #4f46e5);
  color:#fff;
  border-color:var(--brand, #4f46e5);
  font-weight:600;
}
.pac-pag-pages .pac-pag-ellipsis{ padding:0 4px; color:var(--ink-soft, #9ca3af); }
.pac-pagination button:disabled{ opacity:0.4; cursor:not-allowed; }
#pac_chk_all{ cursor:pointer; width:16px; height:16px; }

/* Botão Lixeira (com badge de contagem) */
#btn_pac_trash{ white-space:nowrap; }

/* Modal da Lixeira */
.trash-overlay .trash-modal{
  max-width: 900px;
  width: calc(100vw - 32px);
}
.trash-overlay[hidden]{ display:none !important; }
.trash-head-actions{ display:flex; align-items:center; gap:8px; }
.trash-hint{
  margin:0 0 10px;
  padding:8px 12px;
  background:#f8fafc;
  border-left:3px solid #2563eb;
  font-size:12.5px;
  color:#475569;
  border-radius:0 6px 6px 0;
}
.trash-count-row{
  display:flex;
  justify-content:flex-end;
  padding:4px 0 8px;
}
.trash-count{
  font-size:12px;
  color:#64748b;
  font-weight:500;
}
.trash-tablewrap{
  max-height: 60vh;
  overflow:auto;
  border:1px solid var(--line, #e5e7eb);
  border-radius:8px;
}
.trash-tablewrap .mst-table thead th{
  position:sticky; top:0; z-index:1;
  background:#f8fafc;
}
.trash-expires{
  display:inline-block;
  padding:2px 8px;
  background:#fee2e2;
  color:#991b1b;
  border-radius:10px;
  font-size:11px;
  font-weight:600;
}

@media print{
  .trash-overlay{ display:none !important; }
  .pac-bulk-bar{ display:none !important; }
}

/* ═══════════════════════════════════════════════════════════════════ */
/*  SPRINT 2 ITEM 4 — ALERTAS CLÍNICOS (flags de paciente)            */
/* ═══════════════════════════════════════════════════════════════════ */

/* Seção collapsible dentro do modal de paciente */
.flags-section{
  margin-top:14px;
  border:1px solid #fde68a;
  background:#fffbeb;
  border-radius:8px;
  overflow:hidden;
}
.flags-section[open]{ background:#fff; }
.flags-section > summary{
  padding:10px 14px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:600;
  color:#92400e;
  list-style:none;
  user-select:none;
}
.flags-section > summary::-webkit-details-marker{ display:none; }
.flags-section > summary::before{
  content:'▶';
  font-size:10px;
  color:#b45309;
  transition:transform .15s;
}
.flags-section[open] > summary::before{ transform:rotate(90deg); }
.flags-sum-title{ flex:1; }
.flags-sum-count{
  background:#f59e0b;
  color:#fff;
  font-size:11px;
  font-weight:700;
  padding:2px 8px;
  border-radius:10px;
}
.flags-sum-count[hidden]{ display:none !important; }
.flags-body{
  padding:10px 14px 14px;
  background:#fff;
  border-top:1px solid #fde68a;
}
.flags-hint{
  font-size:12px;
  color:#6b7280;
  margin:0 0 10px;
}
.flags-group{
  border:1px solid #e5e7eb;
  border-radius:6px;
  padding:8px 12px 10px;
  margin-bottom:10px;
}
.flags-group legend{
  font-size:12px;
  font-weight:600;
  color:#374151;
  padding:0 6px;
  display:flex;
  align-items:center;
  gap:8px;
}
.flag-chips{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:6px;
}
.flag-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border:1px solid #d1d5db;
  border-radius:999px;
  font-size:12px;
  color:#374151;
  cursor:pointer;
  background:#fff;
  user-select:none;
}
.flag-chip:has(input:checked){
  border-color:#b45309;
  background:#fffbeb;
  color:#92400e;
  font-weight:600;
}
.flag-chip input{ margin:0; cursor:pointer; }
/* Comorbidades do card clínico (P3): selecionadas viram TAG indigo (consistente com as
   tags de medicamento); checkbox nativo oculto, ✓ à esquerda; visual mais limpo (2026-06-06).
   Força flex-direction:row porque a regra genérica `label{flex-direction:column}` (l.319)
   empilhava o ✓ acima do texto e deformava a pill. */
#pc_comorb_chips .flag-chip{ display:inline-flex; flex-direction:row; align-items:center; gap:6px;
  white-space:nowrap; padding:5px 13px; border-color:#d8dde5; color:#475569; font-size:12.5px;
  transition:background .12s, border-color .12s, color .12s; }
#pc_comorb_chips .flag-chip input{ display:none; }
#pc_comorb_chips .flag-chip:hover{ border-color:#a5b4fc; background:#f5f6ff; }
#pc_comorb_chips .flag-chip:has(input:checked){ border-color:#6366f1; background:#eef2ff; color:#3730a3; font-weight:600; }
#pc_comorb_chips .flag-chip:has(input:checked)::before{ content:'✓'; flex:0 0 auto; font-size:11px; font-weight:700; color:#4f46e5; line-height:1; }
.flag-sub{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:8px;
  padding:8px 10px;
  background:#f9fafb;
  border-radius:6px;
  border:1px dashed #d1d5db;
}
.flag-sub .tpl-form-field{ margin:0; }
.flag-hint-sub{
  font-size:11px;
  color:#6b7280;
  width:100%;
  margin-bottom:2px;
}
.flag-outra-wrap{ width:100%; max-width:none !important; }

/* Lista de alergias (itens editáveis) */
.flag-alergias-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:8px;
}
/* Card clínico: campos aproveitam a largura do quadro em telas largas (2026-06-06) */
.flag-alergias-list > .flag-alergia-row{ width:100%; }
#pc_hist_clinico, #pc_intercor_prev, #pc_sens_med{ width:100%; box-sizing:border-box; resize:vertical; }
.flag-alergia-item{
  display:flex;
  gap:8px;
  align-items:center;
  padding:6px 10px;
  border:1px solid #e5e7eb;
  border-radius:6px;
  background:#fff;
}
.flag-alergia-item select, .flag-alergia-item input{
  padding:4px 8px;
  border:1px solid #d1d5db;
  border-radius:4px;
  font-size:12px;
}
.flag-alergia-item .flag-al-desc{ flex:1; min-width:120px; }
.flag-alergia-rm{
  background:none;
  border:1px solid #fecaca;
  color:#b91c1c;
  border-radius:4px;
  cursor:pointer;
  padding:2px 8px;
  font-size:12px;
}
.flag-alergia-rm:hover{ background:#fef2f2; }

/* Badge na lista de pacientes */
.pac-flag-badge{
  display:inline-flex;
  align-items:center;
  margin-left:6px;
  padding:1px 6px;
  background:#fffbeb;
  color:#b45309;
  border:1px solid #fcd34d;
  border-radius:10px;
  font-size:10px;
  font-weight:700;
  cursor:help;
}

/* Banner no topo do exame quando paciente tem flags */
.exame-flags-alert{
  margin:0 0 14px;
  padding:12px 16px;
  background:linear-gradient(90deg, #fffbeb 0%, #fff 60%);
  border:1px solid #fbbf24;
  border-left:4px solid #f59e0b;
  border-radius:8px;
  color:#78350f;
  font-size:13px;
  line-height:1.5;
}
.exame-flags-alert[hidden]{ display:none; }
.exame-flags-alert-head{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:6px;
  font-weight:700;
  color:#92400e;
}
.exame-flags-alert-head .efa-icon{
  font-size:18px;
}
.exame-flags-alert-dismiss{
  margin-left:auto;
  background:transparent;
  border:1px solid #fbbf24;
  color:#92400e;
  padding:2px 10px;
  border-radius:4px;
  font-size:11px;
  cursor:pointer;
}
.exame-flags-alert-dismiss:hover{ background:#fde68a; }
.exame-flags-alert-list{
  margin:0;
  padding-left:20px;
}
.exame-flags-alert-list li{ margin:2px 0; }

/* Modal "pedir justificativa" */
.flag-justif-overlay{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.55);
  z-index:1100;
  display:none;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.flag-justif-overlay.show{ display:flex; }
.flag-justif-modal{
  background:#fff;
  border-radius:10px;
  width:90%;
  max-width:460px;
  padding:18px 20px;
  box-shadow:0 25px 70px rgba(0,0,0,.35);
}
.flag-justif-modal h4{ margin:0 0 8px; color:#92400e; font-size:15px; }
.flag-justif-modal p{ font-size:13px; color:#475569; margin:0 0 10px; }
.flag-justif-modal textarea{
  width:100%;
  min-height:80px;
  padding:8px 10px;
  border:1px solid #d1d5db;
  border-radius:6px;
  font-size:13px;
  resize:vertical;
  box-sizing:border-box;
}
.flag-justif-foot{
  display:flex;
  gap:8px;
  justify-content:flex-end;
  margin-top:12px;
}

@media print{
  .exame-flags-alert{ display:none !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   CONTROLE DE ACESSO (2026-06-22) — login flexível, chip de usuário, tela de
   Usuários e Permissões, banner de negação, modais. Self-contained; usa as
   variáveis de tema existentes (--brand/--ink/--line/--danger/--ok).
   ════════════════════════════════════════════════════════════════════════ */

/* cores por perfil (reuso em avatar/badge) */
.role-master              { --r: #6d28d9; }
.role-medico_endoscopista { --r: #0052cc; }
.role-medico_anestesista  { --r: #0d9488; }
.role-secretaria          { --r: #d97706; }
.role-tecnica_endoscopia  { --r: #16a34a; }

/* ── overlay de login ── */
.cedar-login-overlay{
  position: fixed; inset: 0; z-index: 9000;
  display: none; align-items: center; justify-content: center;
  background: rgba(15,23,42,.55); backdrop-filter: blur(3px);
}
.cedar-login-card{
  width: min(440px, 92vw); background: #fff; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.32); padding: 26px 26px 18px;
  text-align: center;
}
.cedar-login-brand{ font-size: 13px; letter-spacing:.08em; text-transform:uppercase; color: var(--brand); font-weight:800; }
.cedar-login-title{ font-size: 20px; font-weight: 700; color: var(--ink); margin: 6px 0 18px; }
.cedar-login-body{ display:flex; flex-direction:column; gap:10px; max-height: 52vh; overflow:auto; }
.cedar-login-user{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 12px 16px; border:1px solid var(--line); border-radius:10px;
  background:#fff; cursor:pointer; font-size:15px; transition: all .12s;
}
.cedar-login-user:hover{ border-color: var(--brand); background: var(--brand-light); }
.cedar-login-user .clu-name{ font-weight:600; color: var(--ink); }
.cedar-login-user .clu-role{ font-size:12px; color: var(--ink-soft); }
.cedar-login-input{ height:42px; padding:0 12px; border:1px solid var(--line); border-radius:8px; font-size:15px; }
.cedar-login-go{ height:42px; border:0; border-radius:8px; background: var(--brand); color:#fff; font-weight:700; cursor:pointer; }
.cedar-login-msg{ color: var(--danger); font-size:13px; min-height:18px; margin-top:8px; }
.cedar-login-loading{ color: var(--ink-soft); padding:18px; }
.cedar-login-foot{ margin-top:14px; font-size:11px; color: var(--ink-soft); }

/* ── chip de usuário no topbar ── */
.cedar-user-chip{ position:relative; margin-left:6px; }
.cedar-user-chip .cuc-btn{
  display:flex; align-items:center; gap:8px; height:36px; padding:0 8px 0 6px;
  border:1px solid var(--line); border-radius:20px; background:#fff; cursor:pointer;
}
.cedar-user-chip .cuc-avatar{
  width:26px; height:26px; border-radius:50%; background: var(--r,#64748b); color:#fff;
  display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:800;
}
.cedar-user-chip .cuc-meta{ display:flex; flex-direction:column; line-height:1.05; text-align:left; }
.cedar-user-chip .cuc-name{ font-size:12.5px; font-weight:700; color: var(--ink); }
.cedar-user-chip .cuc-role{ font-size:10.5px; color: var(--r,#64748b); font-weight:600; }
.cedar-user-chip .cuc-caret{ font-size:10px; color: var(--ink-soft); }
.cedar-user-chip .cuc-menu{
  position:absolute; right:0; top:42px; background:#fff; border:1px solid var(--line);
  border-radius:10px; box-shadow:0 12px 30px rgba(0,0,0,.16); min-width:210px; padding:6px; z-index:9100;
}
.cedar-user-chip .cuc-item{
  display:block; width:100%; text-align:left; padding:9px 12px; border:0; background:none;
  border-radius:7px; cursor:pointer; font-size:14px; color: var(--ink);
}
.cedar-user-chip .cuc-item:hover{ background: var(--bg); }

/* ── banner de negação ── */
.cedar-access-denied{
  position: fixed; top:-60px; left:50%; transform: translateX(-50%);
  background: var(--danger); color:#fff; padding:11px 20px; border-radius:0 0 12px 12px;
  font-size:14px; font-weight:600; z-index:9500; transition: top .25s ease; box-shadow:0 8px 24px rgba(0,0,0,.25);
}
.cedar-access-denied.show{ top:0; }

/* ── tela de Usuários e Permissões ── */
.cedar-noperm{ padding:40px; text-align:center; color: var(--danger); font-size:16px; font-weight:600; }
#screen_usuarios{ padding: 0 var(--content-px, 20px) 40px; }
.utabs{ display:flex; gap:6px; margin:14px 0 18px; border-bottom:1px solid var(--line); }
.utab{ padding:10px 16px; border:0; background:none; cursor:pointer; font-size:14px; color: var(--ink-soft); border-bottom:2px solid transparent; }
.utab.on{ color: var(--brand); border-bottom-color: var(--brand); font-weight:700; }
.usec-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.usec-head h3{ margin:0; font-size:16px; color: var(--ink); }
.utable{ width:100%; border-collapse:collapse; font-size:13.5px; background:#fff; border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.utable th{ text-align:left; padding:10px 12px; background: var(--bg); color: var(--ink-soft); font-weight:700; font-size:12px; border-bottom:1px solid var(--line); }
.utable td{ padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:top; }
.utable tr:last-child td{ border-bottom:0; }
.urow-inactive{ opacity:.55; }
.ucell-name{ font-weight:600; color: var(--ink); }
.ucell-sub{ font-size:11.5px; color: var(--ink-soft); }
.ucell-login{ white-space:nowrap; color: var(--ink-soft); }
.ucell-reason{ max-width:240px; }
.ucell-actions{ white-space:nowrap; text-align:right; }
.utag-you{ font-size:10px; background: var(--brand-light); color: var(--brand); padding:1px 6px; border-radius:10px; }
.ubadge{ display:inline-block; padding:3px 9px; border-radius:12px; font-size:11.5px; font-weight:700; color:#fff; background: var(--r,#64748b); }
.ustatus{ font-size:12px; font-weight:700; }
.ustatus.on{ color: var(--ok); }
.ustatus.off{ color: var(--ink-soft); }
.ustatus.warn{ color: #d97706; }
.ua-btn{ border:1px solid var(--line); background:#fff; border-radius:7px; width:30px; height:30px; cursor:pointer; margin-left:3px; font-size:14px; }
.ua-btn:hover{ background: var(--bg); }
.ua-btn.ua-danger:hover{ background: #fef2f2; border-color: var(--danger); }
.ugrant-sec{ margin-bottom:22px; }
.ugrant-sec h4{ margin:0 0 8px; font-size:13.5px; color: var(--ink); }
.utable--grants td{ font-size:12.5px; }

/* ── modal genérico ── */
.cedar-modal-ov{ position:fixed; inset:0; z-index:9300; background: rgba(15,23,42,.5); display:flex; align-items:center; justify-content:center; padding:20px; }
.cedar-modal{ width:min(560px,96vw); max-height:90vh; overflow:auto; background:#fff; border-radius:12px; box-shadow:0 24px 60px rgba(0,0,0,.3); }
.cedar-modal-head{ display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--line); font-size:16px; font-weight:700; color: var(--ink); }
.cedar-modal-x{ border:0; background:none; font-size:18px; cursor:pointer; color: var(--ink-soft); }
.cedar-modal-body{ padding:18px; }
.cuf-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.cuf-grid label{ display:flex; flex-direction:column; gap:4px; font-size:12.5px; color: var(--ink-soft); font-weight:600; }
.cuf-grid input, .cuf-grid select, .cuf-grid textarea{ height:38px; padding:0 10px; border:1px solid var(--line); border-radius:7px; font-size:14px; color: var(--ink); }
.cuf-grid textarea{ height:auto; padding:8px 10px; resize:vertical; }
.cuf-medico{ grid-column:1/-1; display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; padding:10px; background: var(--bg); border-radius:8px; }
.cuf-pass{ grid-column:1/-1; }
.cuf-check{ grid-column:1/-1; flex-direction:row !important; align-items:center; gap:8px; }
.cuf-check input{ height:auto; }
.cuf-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top:18px; }
.cuf-actions .btn--primary{ background: var(--brand); border-color: var(--brand); }
.cuf-msg{ color: var(--danger); font-size:13px; min-height:18px; margin-top:8px; text-align:right; }

@media (max-width: 640px){
  .cuf-grid{ grid-template-columns:1fr; }
  .cuf-medico{ grid-template-columns:1fr; }
  .ucell-reason{ max-width:140px; }
}

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT_V2 — Fase 0 (containers full-width) + Fase 1 (grid fluido)
   Aplicado 2026-04-25. Gateado por :root[data-layout="v2"].
   Flag OFF (default) = ZERO impacto. Activar via:
     localStorage.setItem('cedar_layout_v2','on'); location.reload();
     // ou ?layout=v2 na URL
   Backup: historico/backups/styles.css.bak.2026-04-26.pre-LAYOUT_V2
   ═══════════════════════════════════════════════════════════════════ */

:root[data-layout="v2"]{
  /* Tokens */
  --rail-w: 200px;
  --ctx-w: clamp(300px, 22vw, 420px);
  --topbar-h: 48px;
  --content-px: clamp(12px, 2vw, 32px);
}
:root[data-layout="v2"][data-rail="collapsed"]{ --rail-w: 56px; }
:root[data-layout="v2"][data-ctx="off"]       { --ctx-w: 0px; }

/* Fase 0 — remover max-width:1200px de agenda/mestres/vigilância/config */
:root[data-layout="v2"] #screen_agenda,
:root[data-layout="v2"] #screen_agenda.active,
:root[data-layout="v2"] #screen_mestres.active,
:root[data-layout="v2"] #screen_vigilancia.active,
:root[data-layout="v2"] #screen_config.active{
  max-width: none;
  padding-inline: var(--content-px);
}

/* Fase 1 — grid fluido do exame */
:root[data-layout="v2"] #screen_exame.active{
  grid-template-columns: var(--rail-w) minmax(560px, 1fr) var(--ctx-w);
}

/* Sidenav colapsada: esconde labels, mantém ícones (futuro) */
:root[data-layout="v2"][data-rail="collapsed"] .sidenav .nav-item{
  font-size: 0;
  text-align: center;
  padding: 0 6px;
}
:root[data-layout="v2"][data-rail="collapsed"] .sidenav .nav-item::first-letter{
  font-size: 16px;
}

/* Context panel — quando off, esconde border também */
:root[data-layout="v2"][data-ctx="off"] .rightpane{
  display: none;
}

/* Topbar — nome do paciente respira em telas largas */
:root[data-layout="v2"] .tb-nome{
  max-width: clamp(220px, 30vw, 520px);
}

/* Drawer mode em telas <1100px: rightpane vira off-canvas */
@media (max-width: 1100px){
  :root[data-layout="v2"] #screen_exame.active{
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }
  :root[data-layout="v2"] .rightpane{
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: min(420px, 92vw);
    transform: translateX(100%);
    transition: transform .2s ease;
    z-index: 60;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
    display: block;
  }
  :root[data-layout="v2"][data-ctx="open"] .rightpane{
    transform: translateX(0);
  }
}

/* Botão toggle do context panel (injetado pelo addon na topbar) */
.lv2-toggle-ctx{
  display: none;
}
:root[data-layout="v2"] .lv2-toggle-ctx{
  display: inline-flex;
}

/* Indicador discreto: layout v2 ativo */
:root[data-layout="v2"] .tb-pill.lv2-badge{
  display: inline-block;
  background: #7c3aed;
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
}
.lv2-badge{ display: none; }

/* ═══════════════════════════════════════════════════════════════════
   LAYOUT_V2 — Fase 2 (scrolls aninhados) + Fase 3 (densidade + chips)
   Aplicado 2026-04-25. Continuação do bloco Fase 0+1.
   Mantém gating estrito por :root[data-layout="v2"].
   ═══════════════════════════════════════════════════════════════════ */

/* ─── FASE 2 — Eliminação de scrolls aninhados ─────────────────────
   Estratégia:
   - .laudo-preview: troca 400px fixo por clamp(280px, 60vh, 800px) —
     respeita viewport, evita scroll-em-scroll em monitor pequeno.
   - .side-alerts: troca 350px fixo por calc(100vh - 280px) —
     usa toda a altura disponível do rightpane sem precisar de scroll
     independente quando a lista é curta. Para listas longas, ainda
     rola, mas como ÚNICO scroll do painel direito (não duplo).
   - .ag-body: remove o max-height; deixa #screen_agenda.active ser
     o scroller único da tela de agenda.
   - .laudo-preview também ganha max-height responsivo no print
     (preserva regra atual de impressão).
*/
:root[data-layout="v2"] .laudo-preview{
  max-height: clamp(280px, 60vh, 800px);
}
:root[data-layout="v2"] .side-alerts{
  max-height: none;
  /* Como o .rightpane já é overflow-y:auto, deixar o conteúdo fluir
     evita o segundo scrollbar dentro da coluna da direita. */
}
:root[data-layout="v2"] .ag-body{
  max-height: none;
  overflow: visible;
}

/* ─── FASE 3a — Densidade-aware (compact|touch) ────────────────────
   Tokens controlados por data-density no <html>. Default só vale
   quando layout v2 está ON. Touch é forçado em pointer:coarse pelo
   addon (iPad), preservando alvo de toque mínimo 40×40.
*/
:root[data-layout="v2"]{
  --input-h: 38px;
  --btn-h:   36px;
  --pad-x:   12px;
  --gap:     10px;
  --fs-base: 14px;
}
:root[data-layout="v2"][data-density="compact"]{
  --input-h: 32px;
  --btn-h:   30px;
  --pad-x:   10px;
  --gap:     8px;
  --fs-base: 13px;
}
:root[data-layout="v2"][data-density="touch"]{
  --input-h: 42px;
  --btn-h:   40px;
  --pad-x:   14px;
  --gap:     12px;
  --fs-base: 14px;
}
/* Aplicação dos tokens — EXCLUI checkbox/radio/range/file/color/image
   (inputs nativos que NÃO devem ter height/padding tratados como text) */
:root[data-layout="v2"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="image"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
:root[data-layout="v2"] select{
  height: var(--input-h);
  padding-inline: var(--pad-x);
}
:root[data-layout="v2"] textarea{
  padding-inline: var(--pad-x);
}
/* Garante que checkbox/radio fiquem com tamanho nativo dentro de v2,
   contrabalançando a regra global "input { height:38px }" do styles.css:328 */
:root[data-layout="v2"] input[type="checkbox"],
:root[data-layout="v2"] input[type="radio"]{
  height: auto;
  width: auto;
  padding: 0;
  margin: 0 6px 0 0;
  vertical-align: middle;
  appearance: auto;
  -webkit-appearance: auto;
}
/* Filtros de papéis e templates — voltar ao visual de chip horizontal */
:root[data-layout="v2"] .tpl-filter-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  height: auto;
  line-height: 1.3;
}
:root[data-layout="v2"] .tpl-filter-chip:hover{
  background: var(--surface-2);
}

/* ─── ASA + Justificativa — fix do --sm que limitava a 160px ─────────
   ASA está dentro de .pex-field--sm (max-width:160px). Não basta mexer
   no .seg-ctrl — precisa SOBREPOR o pai usando :has(). Safari 15.4+ ok.
   Anti/Antiplaq NÃO devem esticar (são Sim/Não, ficam compactos).
*/
:root[data-layout="v2"] .pex-row .pex-field:has(> .seg-ctrl--asa){
  max-width: none;
  flex: 1 1 100%;
  min-width: 0;
}
:root[data-layout="v2"] .seg-ctrl--asa{
  display: flex;
  width: 100%;
}
:root[data-layout="v2"] .seg-ctrl--asa .seg-btn{
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}
/* Sugestão (banner azul) e wrap da justificativa também full-width */
:root[data-layout="v2"] #asa_sugestao_badge,
:root[data-layout="v2"] #asa_justificativa_wrap{
  width: 100%;
}
:root[data-layout="v2"] #asa_justificativa_input{
  width: 100% !important;
  min-height: 72px;
  padding: 8px 10px !important;
  font-size: 13px !important;
  box-sizing: border-box;
}
/* Anticoag/Antiplaq toggles — compactos (cabem em ~180px) */
:root[data-layout="v2"] .pex-card .seg-ctrl[data-bind="colono.uso_anticoag"],
:root[data-layout="v2"] .pex-card .seg-ctrl[data-bind="colono.uso_antiplaq"]{
  display: inline-flex;
  width: auto;
  max-width: 200px;
}

/* ─── Datalist/select option legíveis ─────────────────────────────────
   Safari renderiza dropdown de datalist via sistema. Para garantir
   contraste, usamos -webkit-text-fill-color (override do fill no
   webkit) + cor absoluta + !important. Vale para datalist, select,
   option e qualquer descendente herdado.
*/
:root[data-layout="v2"] datalist,
:root[data-layout="v2"] datalist option,
:root[data-layout="v2"] datalist option *,
:root[data-layout="v2"] select,
:root[data-layout="v2"] select option,
:root[data-layout="v2"] select option *{
  color: #1a1a1a !important;
  background-color: #ffffff !important;
  -webkit-text-fill-color: #1a1a1a !important;
  text-shadow: none !important;
  opacity: 1 !important;
}
:root[data-layout="v2"] datalist option:hover,
:root[data-layout="v2"] select option:hover,
:root[data-layout="v2"] select option:checked{
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background-color: #2563eb !important;
}
:root[data-layout="v2"] datalist option,
:root[data-layout="v2"] select option{
  padding: 4px 8px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
}
:root[data-layout="v2"] .btn{
  height: var(--btn-h);
  min-height: var(--btn-h);
  padding-inline: var(--pad-x);
}
:root[data-layout="v2"] .grid{ gap: var(--gap); }

/* ─── FASE 3b — Botões e chips com wrap padronizado ────────────────
   Resolve "texto cortado em chip", "barra de ações com overflow".
*/
:root[data-layout="v2"] .btn{
  min-width: 84px;
  white-space: nowrap;
  max-width: 100%;
}
:root[data-layout="v2"] .btn.btn-icon,
:root[data-layout="v2"] .btn[data-icon-only="true"]{
  min-width: 0;
  padding-inline: 8px;
}
:root[data-layout="v2"] .chip,
:root[data-layout="v2"] .int-chip{
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: auto;
}
:root[data-layout="v2"] .chip-group,
:root[data-layout="v2"] .classif-chips{
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap, 6px);
}
:root[data-layout="v2"] .laudo-card-actions{
  flex-wrap: wrap;
  gap: 6px;
}
:root[data-layout="v2"] .laudo-card-actions > .btn{
  flex: 0 1 auto;
}

/* Inputs de pesquisa/data na agenda — fluidos com cap */
:root[data-layout="v2"] .ag-search-input{
  width: clamp(160px, 24vw, 320px);
}
:root[data-layout="v2"] .ag-date-input{
  width: clamp(120px, 14vw, 180px);
}

/* ─── FASE 3c — Nav rail collapsible ───────────────────────────────
   Quando data-rail="collapsed" (já gateado no token --rail-w), o
   conteúdo dos nav-items vira ícone-only. Tooltip do title nativo
   cobre acessibilidade. Botão de toggle injetado pelo addon.
*/
:root[data-layout="v2"][data-rail="collapsed"] .sidenav .nav-item{
  font-size: 0;
  text-align: center;
  padding-inline: 0;
  position: relative;
}
:root[data-layout="v2"][data-rail="collapsed"] .sidenav .nav-item::before{
  content: attr(data-icon);
  font-size: 16px;
  display: inline-block;
}
:root[data-layout="v2"][data-rail="collapsed"] .sidenav .nav-item:not([data-icon])::before{
  /* fallback: primeira letra do texto via JS attr — ver addon */
  content: attr(data-letter);
  font-size: 14px;
  font-weight: 700;
}
/* Botão toggle do rail (no topo da sidenav) */
.lv2-toggle-rail{
  display: none;
}
:root[data-layout="v2"] .lv2-toggle-rail{
  display: inline-flex;
  align-items: center; justify-content: center;
  height: 28px; width: 100%;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
}
:root[data-layout="v2"] .lv2-toggle-rail:hover{
  background: var(--surface);
  color: var(--ink);
}

/* ─── FASE 3d — Topbar: tb-nome respira ────────────────────────────
   Já aplicado em Fase 1, reforça aqui com !important para o caso de
   alguma regra específica de id sobrescrever.
*/
:root[data-layout="v2"] .topbar .tb-nome{
  max-width: clamp(220px, 30vw, 520px);
}

/* ─── Print: hardening — flag não afeta impressão ──────────────────
   Garante que nenhum token v2 quebre laudos PDF.
*/
@media print{
  :root[data-layout="v2"] .lv2-badge,
  :root[data-layout="v2"] .lv2-toggle-ctx,
  :root[data-layout="v2"] .lv2-toggle-rail{
    display: none !important;
  }
}

/* ─── FASE 3e — Reflow dos cards de Paciente/Exame ─────────────────
   Causa-raiz: .pex-panels usa grid 1fr 1fr com 2 colunas LEFT/RIGHT
   hardcoded. Cards da esquerda terminam antes que os da direita,
   deixando whitespace inferior na coluna esquerda.

   Estratégia: usar CSS multi-column. Cards fluem para preencher a
   coluna mais curta automaticamente. Em monitor largo, vira 3 cols.

   Implementação: .pex-col vira display:contents (filhos viram filhos
   diretos de .pex-panels), depois aplica column-count.

   Trade-off: ordem visual pode mudar (cards são distribuídos
   sequencialmente nas colunas). Mantém ordem semântica HTML.

   Reverter: toggleLayoutV2() OFF restaura o grid 1fr 1fr original.
*/
/* ESTRATÉGIA: Grid auto-fit + CONTAINER QUERIES (Safari 16+).
   Container queries reagem à largura do CONTAINER (.col-panels), não
   da viewport. Importante: quando context panel está aberto, o main
   tem ~1100px; quando fechado, ~1500px. Media query erra (vê só a
   viewport). Container query acerta.
   Bloco "containment" + cap por largura real do container.
*/
:root[data-layout="v2"] .pex-panels,
:root[data-layout="v2"] .col-panels{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  grid-auto-flow: row dense;
  align-items: start;
  gap: 14px;
  container-type: inline-size;
  container-name: cards-grid;
}
/* Masonry SÓ em .col-panels (Colono/EDA). Pex-panels (Paciente/Exame)
   conflita com lockProtectedFields que altera DOM após o masonry medir
   → causava sobreposições. Pex usa Grid auto-fit puro (vácuo tolerável).
*/
:root[data-layout="v2"] .col-panels{
  grid-auto-rows: 8px;
}
:root[data-layout="v2"] .pex-col{
  display: contents;
}
:root[data-layout="v2"] .pex-panels .pex-card,
:root[data-layout="v2"] .col-panels > .col-card,
:root[data-layout="v2"] .col-panels > div{
  display: block;
  width: 100%;
  min-height: 0;
  margin-bottom: 0;
}
:root[data-layout="v2"] .col-panels > .col-card[data-lv2-relocated]{
  margin-top: 0;
}

/* Kyoto Score: 5 segmentos × 3 chips de 30px (94px cada) precisam de
   largura mínima. Em coluna estreita, chips estouravam horizontalmente
   sobrepondo labels. Solução: forçar min-width adequado e wrap interno. */
:root[data-layout="v2"] .cx-score-row{
  flex-wrap: wrap;
  row-gap: 10px;
}
:root[data-layout="v2"] .cx-score-item{
  min-width: 100px;
  flex: 0 1 auto;
}
:root[data-layout="v2"] .cx-num-chips{
  flex-wrap: nowrap;
  justify-content: center;
}

/* Card Boston: 3 segmentos lado a lado precisam de largura ≥ ~580px.
   Numa coluna estreita (380-450px) o "Esquerdo" é cortado.
   Solução: span 2 colunas no grid quando há 2+ disponíveis. */
:root[data-layout="v2"] .col-panels > .col-card--boston{
  grid-column: span 2;
}
/* Quando o container só tem 1 coluna, span 2 vira 1 (auto-clip do Grid)
   e os segmentos do boston-grid empilham para caber. */
@container cards-grid (max-width: 760px){
  :root[data-layout="v2"] .col-panels > .col-card--boston{
    grid-column: span 1;
  }
  :root[data-layout="v2"] .col-card--boston .boston-grid{
    grid-template-columns: 1fr;
  }
}
/* Fallback sem container queries */
@supports not (container-type: inline-size){
  @media (max-width: 900px){
    :root[data-layout="v2"] .col-panels > .col-card--boston{
      grid-column: span 1;
    }
    :root[data-layout="v2"] .col-card--boston .boston-grid{
      grid-template-columns: 1fr;
    }
  }
}

/* Caps por LARGURA DO CONTAINER (não viewport) */
@container cards-grid (max-width: 760px){
  :root[data-layout="v2"] .pex-panels,
  :root[data-layout="v2"] .col-panels{
    grid-template-columns: 1fr;
  }
}
@container cards-grid (min-width: 761px) and (max-width: 1180px){
  :root[data-layout="v2"] .pex-panels,
  :root[data-layout="v2"] .col-panels{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@container cards-grid (min-width: 1181px) and (max-width: 1700px){
  :root[data-layout="v2"] .pex-panels,
  :root[data-layout="v2"] .col-panels{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@container cards-grid (min-width: 1701px){
  :root[data-layout="v2"] .pex-panels,
  :root[data-layout="v2"] .col-panels{
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Fallback para Safari ≤15.3 (sem container queries) — mantém media */
@supports not (container-type: inline-size){
  @media (max-width: 900px){
    :root[data-layout="v2"] .pex-panels,
    :root[data-layout="v2"] .col-panels{ grid-template-columns: 1fr; }
  }
  @media (min-width: 901px) and (max-width: 1280px){
    :root[data-layout="v2"] .pex-panels,
    :root[data-layout="v2"] .col-panels{
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }
}


/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE FIX PACK — 2026-07-04
   Correção CSS-only e ADITIVA de responsividade dos quadros/cards.
   Causa-raiz recorrente: linhas/faixas flex nowrap com filhos incompressíveis
   e SEM min-width:0 → transbordo/scroll horizontal em telas estreitas/iPad.
   Nada aqui remove classe/ID; apenas adiciona regras que vencem por ordem
   de cascata (mesma especificidade, mais abaixo no arquivo).
   Ver RESPONSIVIDADE_QUADROS_AUDITORIA_2026-07-04.md.
   ════════════════════════════════════════════════════════════════════════ */

/* ── AGENDA · grupo de botões de ação (HEADRIGHT-01) ── */
.ag-header{ flex-wrap: wrap; row-gap: 8px; }
.ag-header-left{ min-width: 0; }
.ag-header-right{ flex-wrap: wrap; justify-content: flex-end; min-width: 0; }

/* ── AGENDA · barra de filtros (TOOLBAR-01 / AGTOOLBAR-03) ──
   Só habilita a quebra de linha; preserva o width fluido (clamp) que o
   layout v2 já aplica aos inputs. Casa a especificidade do v2. */
:root[data-layout="v2"] .ag-toolbar, .ag-toolbar{ flex-wrap: wrap; row-gap: 8px; }
:root[data-layout="v2"] .ag-toolbar-right, .ag-toolbar-right{ flex-wrap: wrap; row-gap: 8px; min-width: 0; }
.ag-sort-select{ min-width: 0; }

/* ── AGENDA · linha da agenda (AGROW-FLAGS-04) ── */
.ag-row{ flex-wrap: wrap; row-gap: 6px; }
.ag-row-flags{ flex-wrap: wrap; }
.ag-row-nome{ flex: 1 1 140px; }
/* robustez sob os dois temas (que re-skinnam .ag-row sem definir flex-wrap) */
body.cds-theme-on .ag-row,
:root:not([data-cdr-theme="off"]) #screen_agenda .ag-row{ flex-wrap: wrap; row-gap: 6px; }

/* ── AGENDA · modal cadastro rápido, linhas 2 colunas (MODAL2COL-01) ── */
.ag-form-row--2col{ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 414px){ .ag-form-row--2col{ grid-template-columns: 1fr; } }

/* ── GLOBAL · filhos de grid/flex sem min-width:0 (GRID-MINWIDTH-02) ──
   min-width:auto (default) impede minmax(0,1fr) de segurar → cards esticam
   e conteúdo largo transborda. :where() = especificidade 0, não quebra nada. */
:where(.pex-panels, .col-panels, .grid, .g2, .g3, .g4) > *{ min-width: 0; }
:where(.pex-row, .cx-compact-row, .ag-row) > *{ min-width: 0; }

/* ── EXAMES · Boston Score no layout base/legado (BOSTON-BASE-01) ── */
@media (max-width: 760px){
  :root:not([data-layout="v2"]) .col-card--boston .boston-grid{ grid-template-columns: 1fr; }
}

/* ── EXAMES · checkpoint pré-assinatura (CHKGRID-01) ── */
.chk-grid{ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.chk-row{ min-width: 0; }
.chk-value{ overflow-wrap: anywhere; }

/* ── EXAMES · descritores mucosos da lesão (LESDESC-01) ──
   auto-fit responde à largura real do card (não à viewport); vence o
   @media(min-width:900px){.les-desc-grid{4 cols}} por vir depois. */
.les-desc-grid{ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.les-desc-item{ min-width: 0; }

/* ── DRAWERS · gaveta lateral da Agenda em telas estreitas (AGDRAWER-01) ── */
@media (max-width: 640px){
  .ag-drawer{ width: 100vw; max-width: 100vw; right: -100vw; }
}
/* ── DRAWERS · valor clínico longo sem espaços não transborda (AGDRAWER-02) ── */
.ag-drawer-clinical .dval{ min-width: 0; overflow-wrap: anywhere; word-break: break-word; }

/* ── CONFIG · abas de Usuários rolam em vez de espremer (UTABS-09) ── */
.utabs{ overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
.utabs > .utab{ white-space: nowrap; flex: 0 0 auto; }
/* FIM RESPONSIVE FIX PACK 2026-07-04 */
