/* =========================================================================
   BOSIA — Design System (fundação de frontend reutilizável)
   Preview Visual. Reutilizado na construção real do produto.
   Paleta clínica sóbria: navy profundo + teal assistencial + cores de risco.
   ========================================================================= */

:root {
  /* Marca */
  --brand-900: #071a24;
  --brand-800: #0b2432;
  --brand-700: #0d3648;
  --brand-600: #0f4c61;
  --teal-600: #0e8f8a;
  --teal-500: #12a8a0;
  --teal-400: #35c2b8;
  --teal-050: #e6f7f5;

  /* Superfícies */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --border: #dde5ee;
  --border-strong: #c7d3e0;

  /* Texto */
  --ink: #12202f;
  --ink-2: #33475c;
  --muted: #6b7f95;
  --muted-2: #74889f;

  /* Risco P1–P4 */
  --p1: #d92d3a;
  --p1-bg: #fdecec;
  --p2: #e0700a;
  --p2-bg: #fdf1e3;
  --p3: #b98900;
  --p3-bg: #fbf6e0;
  --p4: #1f9d62;
  --p4-bg: #e8f6ee;

  /* Semânticas */
  --ok: #1f9d62;
  --ok-bg: #e8f6ee;
  --warn: #9a6f00;
  --warn-bg: #fbf6e0;
  --danger: #d92d3a;
  --danger-bg: #fdecec;
  --info: #2f6fed;
  --info-bg: #eaf1fe;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 34, 52, .06), 0 1px 3px rgba(16, 34, 52, .05);
  --shadow: 0 6px 20px rgba(16, 34, 52, .08);
  --shadow-lg: 0 24px 60px rgba(16, 34, 52, .16);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

svg.ico { width: 16px; height: 16px; flex: 0 0 auto; }
.aa-point svg.ico { width: 19px; height: 19px; margin-top: 2px; }
.quick .q-ico svg.ico { width: 21px; height: 21px; }
.e-ico svg.ico { width: 30px; height: 30px; }
.btn svg.ico { width: 15px; height: 15px; }
.badge svg.ico { width: 12px; height: 12px; }

a { color: var(--teal-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
small { color: var(--muted); }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.strong { font-weight: 700; }
.tiny { font-size: 11px; }

/* ---------- Etiqueta de dados de exemplo ---------- */
.data-note {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--warn); background: var(--warn-bg);
  border: 1px solid #f0e2b0; border-radius: 999px; padding: 2px 10px;
}
.data-note::before { content: "●"; font-size: 8px; }
.preview-flag {
  display: block; font-size: 11px; color: var(--muted); margin: 2px 0 0;
}

/* =========================================================================
   SHELL DO PROFISSIONAL
   ========================================================================= */
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--brand-900), #0a1f2c 60%, #08171f);
  color: #cfe3ec; padding: 16px 12px 24px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--teal-400), var(--teal-600));
  display: grid; place-items: center; color: #052224; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 12px rgba(18, 168, 160, .35);
}
.brand-text { line-height: 1.15; }
.brand-name { color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .04em; }
.brand-sub { font-size: 10.5px; color: #6f95a6; text-transform: uppercase; letter-spacing: .09em; }

.org-context {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  border-radius: 10px; padding: 9px 10px; margin: 2px 4px 14px; display: flex; gap: 9px; align-items: center;
}
.org-context .oc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-400); flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(53,194,184,.15); }
.org-context .oc-name { color: #eaf6fb; font-size: 12.5px; font-weight: 600; }
.org-context .oc-unit { color: #7fa3b3; font-size: 11px; }

.nav-group { margin-bottom: 6px; }
.nav-group-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: .11em;
  color: #5f8394; padding: 12px 12px 5px; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 9px;
  color: #b7cfda; font-size: 13px; font-weight: 500; text-decoration: none !important;
  border-left: 2px solid transparent; transition: background .12s ease, color .12s ease;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(18,168,160,.16); color: #fff; border-left-color: var(--teal-400); }
.nav-link .ico { width: 16px; height: 16px; flex: 0 0 auto; opacity: .9; }
.nav-count { margin-left: auto; background: rgba(255,255,255,.12); color: #dff3f8; border-radius: 999px; font-size: 10.5px; padding: 1px 7px; font-weight: 700; }
.nav-count.hot { background: var(--p1); color: #fff; }

/* Conteúdo */
.main { min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  height: 64px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px;
  padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.crumb b { color: var(--ink); font-weight: 600; }
.crumb .sep { color: var(--muted-2); }
.topbar .spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; width: 320px; max-width: 34vw; color: var(--muted);
}
.search input { border: 0; background: transparent; outline: none; width: 100%; font: inherit; color: var(--ink); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; color: var(--ink-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--p1); border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff; background: linear-gradient(140deg, var(--brand-700), #0c7d78); flex: 0 0 auto; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.user-chip .u-name { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.user-chip .u-role { font-size: 10.5px; color: var(--muted); }

.page { padding: 22px 24px 48px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .ph-main { min-width: 0; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Tabs internas de entidade */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 13px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; cursor: pointer; text-decoration: none !important;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--teal-600); border-bottom-color: var(--teal-500); }

/* =========================================================================
   COMPONENTES
   ========================================================================= */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
/* Filhos de grid/flex não devem forçar overflow por min-width implícito
   (ex.: tabelas largas dentro de cards) — mantém o layout responsivo íntegro. */
.grid > *, .cols > * { min-width: 0; }
.cols { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.cols-wide { grid-template-columns: 1fr 420px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap-sm { gap: 6px; } .gap-lg { gap: 20px; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head .card-title { font-size: 14px; font-weight: 700; }
.card-head .card-sub { font-size: 11.5px; color: var(--muted); }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 10px 12px; }
.card.flush .card-body { padding: 0; }

/* KPIs */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--teal-400); opacity: .0; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.kpi-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.delta { font-weight: 700; font-size: 11.5px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.badge-p1 { color: var(--p1); background: var(--p1-bg); border-color: #f6c9cd; }
.badge-p2 { color: var(--p2); background: var(--p2-bg); border-color: #f6d9b6; }
.badge-p3 { color: var(--p3); background: var(--p3-bg); border-color: #ecdfa6; }
.badge-p4 { color: var(--p4); background: var(--p4-bg); border-color: #bfe6d0; }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: #bfe6d0; }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: #ecdfa6; }
.badge-danger { color: var(--danger); background: var(--danger-bg); border-color: #f6c9cd; }
.badge-info { color: var(--info); background: var(--info-bg); border-color: #cdddfb; }
.badge-muted { color: var(--muted); background: var(--surface-3); border-color: var(--border); }
.badge-brand { color: var(--teal-600); background: var(--teal-050); border-color: #b7e6e1; }

/* Tabelas */
.tbl-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td .cell-main { font-weight: 600; color: var(--ink); }
.table td .cell-sub { font-size: 11.5px; color: var(--muted); }
.table.compact td, .table.compact th { padding: 7px 12px; }
tr.row-danger td { background: #fef7f7; }
tr.row-warn td { background: #fffdf4; }

/* Botões */
.btn {
  font: inherit; font-size: 13px; font-weight: 600; border-radius: 9px; padding: 8px 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 7px; text-decoration: none !important;
  transition: filter .12s ease, background .12s ease;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn-primary { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }
.btn-primary:hover { background: var(--teal-500); color: #fff; }
.btn-dark { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.btn-dark:hover { background: var(--brand-700); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--teal-600); }
.btn-ghost:hover { background: var(--teal-050); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Filtros / chips */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.chip .x { color: var(--muted); margin-left: 5px; }
.chip.active { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.filter-bar .grow { flex: 1; }

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.label .req { color: var(--danger); }
.hint { font-size: 11px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(18,168,160,.14); }
.input.cf-invalid, .textarea.cf-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,53,69,.12); }
.check.cf-invalid { color: var(--danger); }
.textarea { min-height: 92px; resize: vertical; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); }
.check input { margin-top: 2px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; }
legend { font-size: 12px; font-weight: 800; color: var(--teal-600); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }

/* Timeline */
.timeline { position: relative; margin: 0; padding: 0 0 0 22px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px 8px; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--teal-500); }
.tl-item.p1::before { border-color: var(--p1); } .tl-item.p2::before { border-color: var(--p2); }
.tl-item.p3::before { border-color: var(--p3); } .tl-item.doc::before { border-color: var(--info); }
.tl-item.vital::before { border-color: var(--ok); }
.tl-date { font-size: 11px; color: var(--muted); font-weight: 600; }
.tl-title { font-size: 13px; font-weight: 600; color: var(--ink); margin: 1px 0 2px; }
.tl-desc { font-size: 12px; color: var(--muted); }

/* Alertas/linhas */
.alert-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .ar-body { flex: 1; min-width: 0; }
.alert-row .ar-title { font-weight: 600; font-size: 13px; }
.alert-row .ar-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.alert-row .ar-side { text-align: right; white-space: nowrap; }

/* Progresso */
.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--teal-500); }
.progress.warn > span { background: var(--p3); } .progress.danger > span { background: var(--p1); }
.meter { display: flex; flex-direction: column; gap: 5px; }
.meter .m-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.meter .m-val { font-weight: 700; color: var(--ink); }

/* Estados de tela */
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty .e-ico { font-size: 30px; opacity: .5; }
.empty .e-title { font-weight: 700; color: var(--ink-2); margin-top: 8px; }
.state-note { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; color: var(--muted); background: var(--surface-2); }
.state-note.blocked { border-color: #f0c98a; background: var(--warn-bg); color: #7a5b00; }
.state-note.info { border-color: #bcd2f7; background: var(--info-bg); color: #1d4ea8; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, #f2f6fa 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 6px; height: 12px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Chips de classificação */
.risk { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-size: 11px; font-weight: 800; color: #fff; }
.risk.p1 { background: var(--p1); } .risk.p2 { background: var(--p2); }
.risk.p3 { background: var(--p3); } .risk.p4 { background: var(--p4); }
.risk-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12px; }

/* Perfil do paciente (cabeçalho clínico) */
.patient-header { display: flex; gap: 16px; align-items: center; }
.patient-header .ph-info { flex: 1; min-width: 0; }
.patient-header .ph-name { font-size: 18px; font-weight: 800; }
.patient-header .ph-meta { color: var(--muted); font-size: 12.5px; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; font-weight: 600; background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; color: var(--ink-2); }
.tag.danger { background: var(--danger-bg); border-color: #f6c9cd; color: var(--danger); }

/* Video / teleconsulta */
.video-stage { background: radial-gradient(120% 120% at 30% 10%, #12303f, #08161d 70%); border-radius: var(--radius); min-height: 380px; position: relative; overflow: hidden; display: grid; place-items: center; color: #cfe3ec; }
.video-stage .vs-avatar { width: 118px; height: 118px; border-radius: 50%; background: linear-gradient(140deg, var(--brand-700), #0c7d78); display: grid; place-items: center; font-size: 42px; font-weight: 800; color: #fff; box-shadow: 0 18px 50px rgba(0,0,0,.4); }
.video-stage .vs-name { margin-top: 14px; font-weight: 700; color: #fff; }
.video-stage .vs-status { font-size: 12px; color: #7fd8d0; }
.video-pip { position: absolute; right: 14px; top: 14px; width: 148px; height: 100px; border-radius: 10px; background: linear-gradient(140deg, #1c3b4c, #0c1f29); border: 2px solid rgba(255,255,255,.18); display: grid; place-items: center; color: #9dc0cd; font-size: 26px; }
.video-controls { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 9px; }
.vc { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.vc.end { background: var(--danger); border-color: var(--danger); }
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; font-size: 12.5px; padding: 8px 11px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.chat-msg.me { align-self: flex-end; background: var(--teal-050); border-color: #b7e6e1; }
.chat-msg .cm-meta { font-size: 10px; color: var(--muted); margin-top: 3px; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }

/* Gráfico (placeholder de container; ECharts preenche) */
.chart { width: 100%; height: 260px; }
.chart.tall { height: 320px; }
.chart.short { height: 190px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Inline SVG charts (usados no snapshot autocontido) */
.svg-chart { width: 100%; height: auto; display: block; }
.svg-chart text { font-family: var(--font); font-size: 10px; fill: var(--muted); }
.svg-chart .grid-line { stroke: var(--border); stroke-width: 1; }
.svg-chart .axis { stroke: var(--border-strong); stroke-width: 1; }

/* Blocos de expansão (detalhes) */
details.disclose { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
details.disclose > summary { cursor: pointer; padding: 10px 12px; font-size: 13px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::before { content: "▸"; color: var(--muted); }
details.disclose[open] > summary::before { content: "▾"; }
details.disclose .d-body { padding: 0 12px 12px; }

/* =========================================================================
   PORTAL DO PACIENTE (responsivo)
   ========================================================================= */
.portal { min-height: 100vh; background: var(--bg); }
.portal-top {
  background: linear-gradient(140deg, var(--brand-800), var(--brand-600)); color: #fff;
  padding: 18px 20px 22px; border-radius: 0 0 22px 22px;
}
.portal-top .pt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.portal-top .pt-hi { font-size: 12.5px; color: #b9dbe4; }
.portal-top .pt-name { font-size: 19px; font-weight: 800; }
.portal-body { padding: 16px 16px 90px; max-width: 820px; margin: 0 auto; }
.portal-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255,255,255,.97);
  border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 7px 4px 9px; z-index: 30;
}
.portal-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; color: var(--muted); font-weight: 600; text-decoration: none !important; flex: 1; }
.portal-nav a.active { color: var(--teal-600); }
.portal-nav .pico { font-size: 18px; line-height: 1; }
.hero-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow-sm); }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.quick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: left; box-shadow: var(--shadow-sm); display: flex; gap: 11px; align-items: center; }
.quick .q-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; background: var(--teal-050); color: var(--teal-600); flex: 0 0 auto; }
.quick .q-t { font-weight: 700; font-size: 13px; }
.quick .q-s { font-size: 11px; color: var(--muted); }
.pos-big { font-size: 42px; font-weight: 800; color: var(--teal-600); line-height: 1; }

/* =========================================================================
   AUTENTICAÇÃO / PÚBLICO
   ========================================================================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: var(--surface); }
.auth-aside {
  background: radial-gradient(120% 120% at 15% 10%, #10475a, #071a24 65%);
  color: #d7ecf2; padding: 46px 48px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside .aa-brand { display: flex; align-items: center; gap: 12px; }
.auth-aside .aa-title { font-size: 32px; font-weight: 800; color: #fff; margin: 34px 0 12px; line-height: 1.15; letter-spacing: -.02em; }
.auth-aside .aa-text { color: #a9cbd6; font-size: 14px; max-width: 440px; }
.auth-aside .aa-points { margin-top: 22px; display: flex; flex-direction: column; gap: 11px; }
.auth-aside .aa-point { display: flex; gap: 10px; font-size: 13px; color: #cbe6ee; align-items: flex-start; }
.auth-aside .aa-point b { color: #fff; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 24px; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; margin: 16px 0; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.verify-box { max-width: 620px; margin: 40px auto; }
.verify-result { border-radius: var(--radius); padding: 18px; margin-top: 18px; }
.verify-result.ok { background: var(--ok-bg); border: 1px solid #bfe6d0; }

/* Utilitários diversos */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; color: var(--ink); }
.divider-h { height: 1px; background: var(--border); margin: 14px 0; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.stat-inline { display: flex; align-items: baseline; gap: 6px; }
.stat-inline .v { font-size: 19px; font-weight: 800; }
.scroll-y { max-height: 340px; overflow-y: auto; }
.dot-status { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-status.online { background: var(--ok); box-shadow: 0 0 0 3px rgba(31,157,98,.16); }
.dot-status.busy { background: var(--p2); box-shadow: 0 0 0 3px rgba(224,112,10,.16); }
.dot-status.offline { background: var(--muted-2); }
.rating { color: var(--p3); letter-spacing: 1px; }
.cover-note { background: var(--brand-900); color: #cfe3ec; border-radius: var(--radius); padding: 16px 18px; }
.cover-note h3 { color: #fff; }

/* Responsivo */
@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar .nav-group { display: none; }
  .cols, .cols-wide { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .search { display: none; }
  .page { padding: 16px 14px 48px; }
  .table th, .table td { padding: 9px 10px; }
  .patient-header { flex-wrap: wrap; }
}

@media print {
  .sidebar, .topbar, .portal-nav, .no-print { display: none !important; }
  body { background: #fff; }
  .app-shell { grid-template-columns: 1fr; }
}

/* =========================================================================
   SNAPSHOT (docs/preview-visual.html) — legibilidade sem sobreposição
   ========================================================================= */
.snap-body { background: #dfe6ee; }
.snap-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 62px; z-index: 100;
  background: var(--brand-900); color: #eaf6fb; display: flex; align-items: center; gap: 14px; padding: 0 20px;
  border-bottom: 1px solid #123244;
}
.snap-topbar .snap-brand { display: flex; align-items: center; gap: 10px; }
.snap-topbar .snap-title { font-weight: 800; letter-spacing: .04em; }
.snap-topbar .snap-sub { font-size: 11px; color: #7fa3b3; }
.snap-topbar .spacer { flex: 1; }
.snap-topbar .snap-badge { font-size: 11px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); padding: 3px 10px; border-radius: 999px; color: #bfe1ea; }
.snap-wrap { padding: 78px 0 80px; }
.snap-intro { max-width: 1180px; margin: 0 auto 20px; padding: 0 20px; }
.snap-index-wrap { max-width: 1180px; margin: 0 auto 26px; padding: 0 20px; }
.snap-index {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 14px 14px; box-shadow: var(--shadow-sm);
}
.snap-index > summary { cursor: pointer; font-weight: 800; padding: 12px 2px; font-size: 14px; }
.snap-index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; }
.snap-index-grid a { font-size: 12.5px; color: var(--ink-2); }
.snap-index-grid .snap-domain { grid-column: 1 / -1; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--teal-600); font-weight: 800; margin: 10px 0 2px; }
.snap-screen { max-width: 1180px; margin: 0 auto 34px; padding: 0 20px; scroll-margin-top: 80px; }
.snap-screen-head { display: flex; align-items: baseline; gap: 12px; margin: 0 4px 8px; flex-wrap: wrap; }
.snap-screen-head h2 { font-size: 16px; }
.snap-screen-head .sid { font-family: var(--mono); font-size: 11px; color: #fff; background: var(--brand-700); padding: 2px 8px; border-radius: 6px; }
.snap-screen-head .sroute { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.snap-stage {
  background: #f4f7fa; border: 1px solid var(--border-strong); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow); position: relative;
}
.snap-stage .stage-bar { height: 30px; background: #e7edf3; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.snap-stage .stage-bar i { width: 10px; height: 10px; border-radius: 50%; background: #cfd9e3; display: inline-block; }
.snap-stage .stage-inner { max-height: 720px; overflow: auto; }
.snap-footer { max-width: 1180px; margin: 0 auto; padding: 20px; color: var(--muted); font-size: 12px; }

/* Neutraliza posicionamentos fixos/sticky dentro das molduras do snapshot para
   que nada escape do quadro nem cubra outras telas. */
.snap-stage .sidebar { position: static; height: auto; max-height: 720px; }
.snap-stage .topbar { position: static; }
.snap-stage .portal { min-height: 0; }
.snap-stage .portal-nav { position: static; }
.snap-stage .auth { min-height: 0; }
.snap-stage .page { max-width: none; }
.snap-note { background: #fff; border-left: 4px solid var(--teal-500); border-radius: 8px; padding: 12px 14px; font-size: 12.5px; color: var(--ink-2); box-shadow: var(--shadow-sm); }

/* =========================================================================
   SPRINT 1 — Identidade, autenticação, sessão e contexto multi-organização
   Complementa o Design System congelado (mesmos tokens, mesma linguagem).
   ========================================================================= */
[hidden] { display: none !important; }
.link-arrow::after { content: " →"; }
.mono-sm { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.full { grid-column: 1 / -1; }

/* Alertas acionáveis (erro / bloqueio / aviso / sucesso) */
.alert { display: flex; gap: 10px; padding: 11px 12px; border-radius: 10px; border: 1px solid; font-size: 12.5px; line-height: 1.45; }
.alert .a-ico { flex: 0 0 auto; margin-top: 1px; }
.alert .a-ico svg { width: 17px; height: 17px; }
.alert .a-body { min-width: 0; }
.alert .a-title { font-weight: 700; display: block; }
.alert .a-text { color: inherit; opacity: .92; }
.alert .a-actions { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.alert-danger { background: var(--danger-bg); border-color: #f6c9cd; color: #8a1f28; }
.alert-warn { background: var(--warn-bg); border-color: #ecdfa6; color: #7a5b00; }
.alert-info { background: var(--info-bg); border-color: #cdddfb; color: #1d4ea8; }
.alert-ok { background: var(--ok-bg); border-color: #bfe6d0; color: #14663f; }

/* Spinner e botão carregando */
.spinner { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: spin .7s linear infinite; display: inline-block; }
.spinner.dark { border-color: rgba(15,76,97,.25); border-top-color: var(--teal-600); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn .spin-slot { display: none; }
.btn.is-loading .spin-slot { display: inline-flex; }
.btn.is-loading .lbl { display: none; }

/* Controle segmentado (chips de cenário/estado) */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { font: inherit; font-size: 11.5px; font-weight: 700; color: var(--muted); background: transparent; border: 0; border-radius: 999px; padding: 5px 11px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.state-switch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.state-switch .ss-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 800; }

/* Fluxo de etapas (Entrar → Contexto → Plataforma) */
.flow { display: flex; align-items: center; gap: 6px; margin: 2px 0 4px; }
.flow .fs { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; color: var(--muted-2); }
.flow .fs .fs-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: 11px; }
.flow .fs.active { color: var(--teal-600); }
.flow .fs.active .fs-n { background: var(--teal-050); color: var(--teal-600); box-shadow: 0 0 0 3px rgba(18,168,160,.14); }
.flow .fs.done .fs-n { background: var(--ok-bg); color: var(--ok); }
.flow .fs-sep { width: 22px; height: 1px; background: var(--border-strong); }

/* Cartões de vínculo (seleção de contexto) */
.vinc-list { display: grid; gap: 10px; }
.vinc { display: flex; gap: 13px; align-items: center; width: 100%; text-align: left; cursor: pointer; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); font: inherit; transition: border-color .12s ease, background .12s ease; }
.vinc:hover { border-color: var(--border-strong); background: var(--surface-2); }
.vinc.active { border-color: var(--teal-500); background: var(--teal-050); box-shadow: 0 0 0 3px rgba(18,168,160,.12); }
.vinc .v-logo { width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; background: linear-gradient(140deg, var(--brand-600), var(--teal-500)); }
.vinc .v-main { min-width: 0; flex: 1; }
.vinc .v-name { display: block; font-weight: 700; font-size: 13.5px; }
.vinc .v-meta { display: block; font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.vinc .v-roles { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.vinc .v-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); flex: 0 0 auto; display: grid; place-items: center; }
.vinc.active .v-check { border-color: var(--teal-500); background: var(--teal-500); }
.vinc.active .v-check::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; }

.ctx-summary { background: var(--brand-800); color: #dff3f8; border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.ctx-summary .cs-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal-400); box-shadow: 0 0 0 4px rgba(53,194,184,.18); flex: 0 0 auto; }
.ctx-summary .cs-name { font-weight: 700; color: #fff; font-size: 13.5px; }
.ctx-summary .cs-meta { font-size: 11.5px; color: #9fc3ce; }

/* Permissões */
.perm-list { display: flex; flex-wrap: wrap; gap: 6px; }
.perm-group { display: flex; flex-direction: column; gap: 8px; }
.perm-group .pg-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }

/* =================== Shell: seletor de contexto e menu do usuário =================== */
.sidebar .org-context { width: 100%; text-align: left; font: inherit; cursor: pointer; align-items: center; }
.org-context .oc-chevron { margin-left: auto; opacity: .7; width: 14px; height: 14px; }
.org-context:hover { background: rgba(255,255,255,.09); }

.menu { position: fixed; z-index: 210; min-width: 264px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu-head { padding: 10px 10px 9px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.menu-head .mh-name { font-weight: 700; font-size: 13.5px; }
.menu-head .mh-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.menu-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 800; padding: 8px 10px 4px; }
.menu-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-decoration: none !important; cursor: pointer; background: none; border: 0; width: 100%; text-align: left; font-family: inherit; }
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-bg); }
.menu-item .mi-ico { width: 16px; height: 16px; opacity: .85; flex: 0 0 auto; }
.menu-item .mi-badge { margin-left: auto; }
.menu-ctx { display: flex; gap: 9px; align-items: center; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu-ctx:hover { background: var(--surface-2); }
.menu-ctx.active { background: var(--teal-050); }
.menu-ctx .mc-main { min-width: 0; flex: 1; }
.menu-ctx .mc-name { display: block; font-size: 12.5px; font-weight: 700; }
.menu-ctx .mc-meta { display: block; font-size: 11px; color: var(--muted); }
.menu-ctx .mc-check { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); flex: 0 0 auto; }
.menu-ctx.active .mc-check { border-color: var(--teal-500); background: var(--teal-500); box-shadow: inset 0 0 0 2px var(--teal-050); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

.topbar .user-trigger { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font: inherit; }
.topbar .user-trigger:hover { background: var(--surface-2); }
.topbar .user-trigger .ut-chevron { width: 14px; height: 14px; color: var(--muted); }
.topbar .user-trigger .u-name { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.1; text-align: left; }
.topbar .user-trigger .u-role { display: block; font-size: 10.5px; color: var(--muted); text-align: left; }
.topbar .user-trigger .avatar { display: grid; }

/* Navegação restrita por função (RBAC) — itens visíveis, porém bloqueados */
.nav-link.locked { opacity: .48; cursor: not-allowed; }
.nav-link.locked .lock-ico { margin-left: auto; width: 13px; height: 13px; opacity: .9; }
.nav-link.locked .nav-count { display: none; }
.nav-link.nav-denied-flash { animation: denyflash .5s ease; }
@keyframes denyflash { 0%,100% { background: transparent; } 40% { background: rgba(217,45,58,.22); } }

/* Estado de tela: sem_permissao (overlay na rota) */
.perm-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(7,26,36,.55); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; }
.perm-panel { background: var(--surface); border-radius: var(--radius-lg); max-width: 480px; width: 100%; padding: 28px 26px; box-shadow: var(--shadow-lg); text-align: center; }
.perm-panel .p-ico { width: 58px; height: 58px; border-radius: 17px; background: var(--danger-bg); color: var(--danger); display: grid; place-items: center; margin: 0 auto 14px; }
.perm-panel .p-ico svg { width: 28px; height: 28px; }
.perm-panel h2 { font-size: 19px; }
.perm-panel .p-text { color: var(--muted); font-size: 13px; margin-top: 8px; }
.perm-panel .p-meta { margin-top: 14px; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.perm-panel .p-actions { display: flex; gap: 9px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* Sessão / perfil */
.session-head { display: flex; gap: 14px; align-items: center; }
.session-meta { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px 16px; }
.session-meta .sm-item { min-width: 0; }
.session-meta .sm-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
.session-meta .sm-v { font-size: 13px; font-weight: 600; margin-top: 1px; }
.pill-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; }

/* Consentimento */
.consent-doc { font-size: 13px; color: var(--ink-2); }
.consent-doc h3 { margin: 14px 0 6px; font-size: 13.5px; }
.consent-doc p { margin: 0 0 9px; }
.consent-doc ul { margin: 0 0 9px; padding-left: 18px; }
.consent-meta { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.consent-meta .cm-k { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
.consent-meta .cm-v { font-size: 12.5px; font-weight: 600; }

/* Login: lateral de estados */
.auth-states { margin-top: 22px; border-top: 1px dashed var(--border-strong); padding-top: 16px; }
.auth-states .as-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 800; margin-bottom: 10px; }
.demo-scenarios { display: flex; gap: 6px; flex-wrap: wrap; }

/* Splash de sucesso (transitório) */
.success-panel { text-align: center; padding: 8px 0 4px; }
.success-panel .sp-ico { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; margin: 0 auto 12px; }
.success-panel .sp-ico svg { width: 28px; height: 28px; }

/* Skeleton de listas (carregando) */
.skel-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); display: flex; gap: 13px; align-items: center; }
.skel-card .sk-avatar { width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto; }
.skel-line { height: 11px; border-radius: 6px; margin: 6px 0; }
.w-40 { width: 40%; } .w-60 { width: 60%; } .w-75 { width: 75%; } .w-100 { width: 100%; }

@media (max-width: 720px) {
  .auth-states { margin-top: 16px; }
  .state-switch { align-items: flex-start; flex-direction: column; gap: 6px; }
  .session-meta { grid-template-columns: 1fr; }
}

/* =========================================================================
   Sprint 3 — Timeline clínica longitudinal e histórico imutável
   ========================================================================= */
.patient-header .ph-side { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.ptl-stamp { font-size: 12px; color: var(--muted); }
.ptl-stamp b { color: var(--ink-2); }

.timeline-toolbar { margin-bottom: 16px; }
.timeline-toolbar .tl-count { font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; white-space: nowrap; }
.tl-search-row { flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
.tl-search-row #timeline-search { min-width: 0; flex: 0 1 240px; }
@media (max-width: 720px) {
  .tl-search-row { width: 100%; }
  .tl-search-row #timeline-search { flex: 1 1 auto; width: 100%; }
}
#timeline-cuts .chip { cursor: pointer; user-select: none; }
#timeline-cuts .chip.active { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }

.tl-kpis { margin-bottom: 16px; }
.kpi-clickable { cursor: pointer; transition: box-shadow .12s ease, transform .12s ease; }
.kpi-clickable:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-clickable:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--teal-400); }
.kpi-clickable.active { border-color: var(--teal-500); }

.tl-charts { margin-bottom: 18px; }
.tl-chart-card .card-body { padding-top: 6px; }

/* Item clicável da timeline */
.tl-item { cursor: pointer; border-radius: 10px; transition: background .12s ease; }
.tl-item:hover, .tl-item:focus-visible { background: var(--surface-2); outline: none; }
.tl-item:focus-visible { box-shadow: 0 0 0 2px var(--teal-400); }
.tl-item .tl-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 5px; font-size: 11px; color: var(--muted); }
.tl-item .tl-type { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--border); }
.tl-item .tl-type.t-atendimento { background: var(--info-bg); color: var(--info); border-color: #cdddfb; }
.tl-item .tl-type.t-documento { background: var(--teal-050); color: var(--teal-600); border-color: #b7e6e1; }
.tl-item .tl-type.t-medicao { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d0; }
.tl-item .tl-type.t-alerta { background: var(--danger-bg); color: var(--danger); border-color: #f6c9cd; }
.tl-item .tl-type.t-exame { background: var(--info-bg); color: var(--info); border-color: #cdddfb; }
.tl-item .tl-type.t-intercorrencia { background: var(--p2-bg); color: var(--p2); border-color: #f6d9b6; }
.tl-item .tl-type.t-comunicacao { background: var(--surface-3); color: var(--ink-2); }
.tl-item .tl-type.t-problema { background: var(--p3-bg); color: var(--p3); border-color: #ecdfa6; }
.tl-item .tl-type.t-consentimento { background: var(--surface-3); color: var(--muted); }
.tl-item .tl-open { margin-left: auto; font-weight: 700; color: var(--teal-600); }
.tl-item .tl-origin::before { content: "· "; }
.tl-item .tl-author { color: var(--muted); }
.tl-item.tl-highlight { animation: tlflash 1.6s ease; }
@keyframes tlflash { 0% { background: var(--teal-050); } 100% { background: transparent; } }

/* Selo de versão no título */
.tl-version-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 800; color: var(--info); background: var(--info-bg); border: 1px solid #cdddfb; border-radius: 999px; padding: 1px 7px; margin-left: 6px; vertical-align: middle; }

/* Drawer de detalhe do evento */
.evt-backdrop { position: fixed; inset: 0; z-index: 340; background: rgba(7,26,36,.42); backdrop-filter: blur(2px); }
.evt-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 350; width: min(560px, 96vw); background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; transform: translateX(6px); animation: evtslide .18s ease; }
@keyframes evtslide { from { transform: translateX(40px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.evt-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.evt-head h2 { font-size: 17px; margin: 2px 0 0; line-height: 1.3; }
.evt-head .evt-type { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-600); }
.evt-head .icon-btn { margin-left: auto; }
.evt-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.evt-section { padding: 0 20px 8px; }
.evt-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; margin: 8px 0 10px; }
.evt-actions { padding: 14px 20px 18px; border-top: 1px solid var(--border); display: flex; gap: 9px; flex-wrap: wrap; }
.evt-meta-grid { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 13px; }
.evt-meta-grid dt { color: var(--muted); font-weight: 600; }
.evt-meta-grid dd { margin: 0; color: var(--ink); word-break: break-word; }

/* Histórico de versões */
.ver-item { border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; margin-bottom: 9px; background: var(--surface-2); }
.ver-item.current { border-color: #b7e6e1; background: var(--teal-050); }
.ver-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.ver-num { font-weight: 800; color: var(--ink-2); }
.ver-change { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--border); }
.ver-change.correcao, .ver-change.alteracao { background: var(--info-bg); color: var(--info); border-color: #cdddfb; }
.ver-change.criado { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d0; }
.ver-author { color: var(--muted); margin-left: auto; }
.ver-reason { font-size: 12px; color: var(--ink-2); margin-top: 5px; }
.ver-diff { margin-top: 8px; display: grid; gap: 6px; }
.ver-diff .diff-row { display: grid; grid-template-columns: 74px 1fr; gap: 8px; font-size: 12px; }
.ver-diff .diff-k { font-weight: 700; }
.ver-diff .diff-before { color: var(--danger); text-decoration: line-through; text-decoration-color: rgba(217,45,58,.5); }
.ver-diff .diff-after { color: var(--ok); }
.ver-diff pre { margin: 0; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; word-break: break-word; }

/* Formulário de correção (nova versão) */
.ver-form { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px; margin-top: 6px; background: var(--surface); }
.ver-form label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: block; margin: 8px 0 4px; }
.ver-form textarea, .ver-form input { width: 100%; }

@media (max-width: 720px) {
  .tl-chart-card, #timeline-kpis { display: none; }
  .evt-drawer { width: 100vw; }
}

/* =========================================================================
   BOSIA — Sprint 4 · Pronto atendimento virtual e teletriagem P1–P4
   Cartões de classificação de risco (T-ENT-05) e realces de estado.
   ========================================================================= */
.level-card { cursor: pointer; border-color: var(--border); transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease; }
.level-card:hover { border-color: var(--border-strong); }
.level-card.active { border-color: var(--teal-500); box-shadow: 0 0 0 2px var(--teal-050), var(--shadow-sm); }
.level-card.active .strong { color: var(--teal-600); }
.level-card:focus-visible { outline: 3px solid var(--teal-400); outline-offset: 2px; }

#triagem-panel .alert, #pe-panel .alert { margin-top: 0; }
#triagem-attachment-list .att, #pe-attachment-list .att { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
#triagem-attachment-list .att .x, #pe-attachment-list .att .x { margin-left: auto; color: var(--muted); cursor: pointer; }

.s4-result-ok { border-color: #bfe6d0; background: var(--ok-bg); }
#cls-result-card.hidden, #s4-state[hidden] { display: none; }

@media (max-width: 1100px) {
  .level-card .card-body { padding: 12px 8px; }
}

/* =========================================================================
   BOSIA — Sprint 6 · Teleconsulta WebRTC e Cockpit clínico integrado
   T-CLI-01 /app/atendimentos/:id · T-POR-06 /portal/teleconsulta/:id
   Estados de chamada, painéis clínicos, chat e assistente de IA.
   ========================================================================= */
.video-stage .video-feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #06141c; z-index: 1; }
.video-stage.has-video .vs-avatar,
.video-stage.has-video .vs-name,
.video-stage.has-video .vs-status { display: none; }
.video-stage .video-feed[hidden] { display: none; }
.video-stage { isolation: isolate; }
.video-stage .video-pip { z-index: 2; overflow: hidden; padding: 0; }
.video-pip video.video-feed, .video-pip .video-feed { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.video-stage video.video-pip { object-fit: cover; background: #0c1f29; }

.vc.off { background: var(--danger); border-color: var(--danger); }
.vc.off svg { opacity: .95; }
.vc.active { background: var(--teal-500); border-color: var(--teal-500); }
.vc:disabled { opacity: .45; cursor: not-allowed; }

.ck-callbar { display: flex; align-items: center; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.ck-callbar-abs { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; border-top: 1px solid rgba(255,255,255,.12); background: rgba(6,20,28,.62); color: #cfe3ec; backdrop-filter: blur(3px); }
.ck-callbar-abs .tiny, .ck-callbar-abs b { color: #cfe3ec; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ck-callbar-abs .conn { color: #cfe3ec; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(147,164,183,.18); }
.conn.ok .conn-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(31,157,98,.2); }
.conn.warn .conn-dot { background: var(--p2); box-shadow: 0 0 0 3px rgba(224,112,10,.2); }
.conn.bad .conn-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(217,45,58,.2); }

.panel-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.pt-tab { border: 0; background: transparent; padding: 9px 11px; font: 600 12.5px var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; }
.pt-tab:hover { color: var(--ink); background: var(--surface-2); }
.pt-tab.active { color: var(--teal-600); border-bottom-color: var(--teal-500); }
.ck-panels { max-height: 460px; overflow-y: auto; }
.ck-panel { animation: ckfade .18s ease; }
@keyframes ckfade { from { opacity: .4; } to { opacity: 1; } }
.ck-loading { padding: 18px 4px; }

.ck-kv { display: flex; flex-direction: column; gap: 2px; }
.ck-kv b { font-size: 13px; color: var(--ink); }

.clini-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.clini-block + .clini-block { margin-top: 10px; }
.clini-block h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.clini-list { margin: 0; padding-left: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.clini-list li { display: flex; gap: 8px; align-items: flex-start; }
.clini-list li::before { content: ""; width: 6px; height: 6px; margin-top: 6px; border-radius: 50%; background: var(--teal-400); flex: 0 0 auto; }
.clini-empty { font-size: 12.5px; color: var(--muted); }

.ck-ai-suggestion { border: 1px solid #bcd2f7; background: var(--info-bg); border-radius: var(--radius-sm); padding: 11px 12px; font-size: 13px; color: #1d4ea8; }
.ck-ai-suggestion.pending { border-color: #f0c98a; background: var(--warn-bg); color: #7a5b00; }
.ck-ai-decision { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

.chat-presence-on { color: var(--ok); }
.ck-msg-sys { align-self: center; font-size: 11px; color: var(--muted); background: transparent; border: 0; }

@media (max-width: 1080px) {
  .ck-callbar-abs { position: static; }
}

/* =========================================================================
   Dashboards ricos (sprint 6): filtros globais, KPIs clicáveis,
   tabelas de detalhe com contagem/estado vazio e drill-down (§6).
   ========================================================================= */
a.kpi { display: block; color: inherit; text-decoration: none; }
a.kpi .kpi-hint {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; color: var(--teal-600);
  margin-top: 8px; letter-spacing: .02em;
}
a.kpi .kpi-hint::after { content: "→"; font-size: 13px; transition: transform .12s ease; }
a.kpi:hover .kpi-hint::after { transform: translateX(3px); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
.dash-grid > .card.wide { grid-column: 1 / -1; }
.dash-card .card-body { padding-bottom: 14px; }
.dash-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.dash-card-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.dash-card-sub { font-size: 11.5px; color: var(--muted); }
.dash-count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.filter-bar .dash-note { font-size: 12px; color: var(--muted); }
.filter-bar .dash-note[data-has-filters="1"] { color: var(--ink-2); font-weight: 600; }
.filter-bar select.select { max-width: 220px; }
.filter-bar [data-dash-reset] { margin-left: 2px; }

table.table tr[hidden] { display: none !important; }
.tbl-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); font-size: 12px; color: var(--muted); }
.tbl-empty { border-top: 1px solid var(--border); }

/* Drill-down: linhas de detalhe clicáveis */
tr[data-drill-row] { cursor: pointer; }
tr[data-drill-row]:hover td { background: var(--surface-2); }

/* Relatórios (§7) */
.rpt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rpt-stamp { display: flex; flex-direction: column; gap: 2px; text-align: right; font-size: 11.5px; color: var(--muted); }
.rpt-stamp b { color: var(--ink-2); font-size: 12px; }
.rpt-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.rpt-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.rpt-total { border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px 14px; }
.rpt-total .kpi-label { font-size: 10.5px; }
.rpt-total .kpi-value { font-size: 21px; }

@media print {
  .sidebar, .topbar, .filter-bar, .page-actions, .rpt-actions, .tbl-foot { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { break-inside: avoid; box-shadow: none !important; }
  body { background: #fff !important; }
}

/* =========================================================================
   BOSIA — Sprint 7 · Evolução clínica, documentação e assinatura interna
   T-CLI-03 /app/atendimentos/:id/evolucao · T-CLI-04 .../documentos/novo
   T-CLI-05 /app/pacientes/:id/documentos · T-POR-07 /portal/documentos
   T-POR-14 /verificar/:codigo · papel do documento e verificação por código.
   ========================================================================= */
.doc-paper {
  background: #fff; border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 20px 22px; box-shadow: var(--shadow-sm); font-size: 13px; color: var(--ink);
  background-image: linear-gradient(180deg, #fbfdff, #fff 60px);
}
.doc-paper .dp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--brand-600); padding-bottom: 12px; }
.doc-paper .dp-org { display: flex; align-items: center; gap: 10px; }
.doc-paper .dp-org .brand-mark { width: 34px; height: 34px; font-size: 16px; }
.doc-paper .dp-kind { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--teal-600); background: var(--teal-050); border: 1px solid #b7e6e1; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.doc-paper .dp-patient { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px 16px; margin: 12px 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.doc-paper .dp-body { min-height: 84px; padding: 6px 0 2px; }
.doc-paper .dp-list { margin: 0 0 8px; padding-left: 18px; }
.doc-paper .dp-list li { margin: 4px 0; }
.doc-paper .dp-text { margin: 0 0 8px; line-height: 1.55; }
.doc-paper .dp-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 8px; }
.doc-paper .dp-seal { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 11px; border-radius: 8px; background: var(--ok-bg); border: 1px solid #bfe6d0; color: #14663f; font-size: 12px; }
.doc-paper .dp-seal b { color: #14663f; }
.doc-paper .dp-notice { margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--border-strong); font-size: 11px; color: var(--muted); }

.verify-result.bad { background: var(--danger-bg); border: 1px solid #f6c9cd; color: #8a1f28; }
.verify-result.warn { background: var(--warn-bg); border: 1px solid #ecdfa6; color: #7a5b00; }
.verify-result.exp { background: var(--surface-3); border: 1px solid var(--border); color: var(--ink-2); }
.verify-result .kv dt { color: inherit; opacity: .75; }
.verify-result .kv dd { color: inherit; }

#evo-versions .tl-item:last-child { padding-bottom: 4px; }
#doc-items .input { min-width: 120px; }

/* =========================================================================
   BOSIA — Sprint 12 · Painel operacional em tempo real da central (T-CEN-01)
   KPIs clicáveis, carimbo de tempo/tempo_real, estado degradado, drill-down,
   ações operacionais e modal de ação.
   ========================================================================= */
button.ct-kpi { text-align: left; font: inherit; cursor: pointer; width: 100%; border: 1px solid var(--border); }
button.ct-kpi:hover { border-color: var(--teal-500); box-shadow: var(--shadow); transform: translateY(-1px); }
button.ct-kpi:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--teal-400); }
button.ct-kpi:active { transform: translateY(0); }
.ct-kpi .kpi-hint {
  display: flex; align-items: center; gap: 4px; margin-top: 8px;
  font-size: 11px; font-weight: 700; color: var(--teal-600); letter-spacing: .02em;
  opacity: 0; transition: opacity .12s ease;
}
.ct-kpi .kpi-hint::after { content: "→"; font-size: 13px; transition: transform .12s ease; }
.ct-kpi:hover .kpi-hint { opacity: 1; }
.ct-kpi:hover .kpi-hint::after { transform: translateX(3px); }

/* Pulso de tempo real no selo */
.ct-pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; animation: ctpulse 1.6s ease-in-out infinite; }
@keyframes ctpulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.72); } }

/* Linha/registro recém-atualizado pelo drill-down */
.ct-flash { animation: ctflash 1.6s ease; }
@keyframes ctflash { 0% { box-shadow: 0 0 0 3px rgba(18,168,160,.35); } 100% { box-shadow: 0 0 0 3px rgba(18,168,160,0); } }

/* Ações em linha das tabelas */
.ct-row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.alert-row.ct-alert-overdue { background: #fef7f7; }
.alert-row.ct-alert-overdue .ar-title a { color: var(--danger); }

/* Estado sem_permissao inline */
.permission-state { text-align: center; padding: 26px 16px; }
.permission-state .ps-ico { width: 54px; height: 54px; border-radius: 15px; background: var(--danger-bg); color: var(--danger); display: grid; place-items: center; margin: 0 auto 12px; }
.permission-state .ps-ico svg { width: 26px; height: 26px; }
.permission-state h2 { font-size: 18px; }
.permission-state p { margin: 8px 0 14px; }

/* Modal de ação operacional */
.ct-modal { position: fixed; inset: 0; z-index: 320; display: grid; place-items: center; padding: 18px; }
.ct-modal[hidden] { display: none !important; }
.ct-modal-backdrop { position: absolute; inset: 0; background: rgba(7,26,36,.5); backdrop-filter: blur(2px); }
.ct-modal-panel { position: relative; width: min(520px, 96vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 86vh; }
.ct-modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.ct-modal-head .ct-modal-title { font-size: 15px; font-weight: 700; }
.ct-modal-head .icon-btn { margin-left: auto; font-size: 18px; line-height: 1; color: var(--muted); }
.ct-modal-body { padding: 16px 18px; overflow-y: auto; }
.ct-modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.ct-modal-body .form-grid { gap: 12px 14px; }

@media (max-width: 720px) {
  .ct-row-actions { justify-content: flex-start; }
  #ct-filters .select { max-width: none; width: 100%; }
}

/* ============================ SPRINT 13 =============================
   Portal do paciente responsivo, notificações e pagamento particular. */

/* Selo de não lidas na navegação inferior do portal */
.portal-nav a { position: relative; }
.portal-nav .nav-badge {
  position: absolute; top: -2px; right: 26%;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 999px; background: var(--danger, #d92d3a); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 17px; text-align: center;
}
.portal-nav .nav-badge[hidden] { display: none !important; }

/* Modal de ação de pagamento (espelha o padrão ct-modal) */
.pg-modal { position: fixed; inset: 0; z-index: 340; display: grid; place-items: center; padding: 18px; }
.pg-modal[hidden] { display: none !important; }
.pg-modal::before { content: ''; position: absolute; inset: 0; background: rgba(7,26,36,.5); backdrop-filter: blur(2px); }
.pg-modal-panel { position: relative; width: min(520px, 96vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 86vh; }
.pg-modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.pg-modal-body { padding: 16px 18px; overflow-y: auto; }
.pg-modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }

/* Comprovante */
.kv-block { display: block; }

/* Acessibilidade: foco visível nos componentes interativos do portal */
.portal-nav a:focus-visible,
.quick:focus-visible { outline: 2px solid var(--teal-600, #0f4c61); outline-offset: 2px; border-radius: 8px; }

/* Atalhos do portal nunca estouram a largura em telas estreitas */
.quick { min-width: 0; }
.quick > span { min-width: 0; }
.quick .q-t, .quick .q-s { overflow-wrap: anywhere; }

/* Portal responsivo — refinamentos em telas estreitas */
@media (max-width: 720px) {
  .portal-body { padding: 12px 12px 88px; }
  .portal-top .pt-name { font-size: 17px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head .page-actions { width: 100%; flex-wrap: wrap; }
  .page-head .page-actions .btn { flex: 1 1 auto; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.grid-2, .grid.grid-3, .grid.grid-4 { grid-template-columns: 1fr; }
  .filter-bar { flex-wrap: wrap; row-gap: 6px; }
  .card .row.between.wrap { row-gap: 8px; }
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .pg-modal-foot .btn, .pg-modal-body .btn { min-height: 40px; }
  .pg-modal-panel { width: 100%; max-height: 92vh; }
}
@media (max-width: 420px) {
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .quick { padding: 12px; gap: 9px; }
  .quick .q-ico { width: 36px; height: 36px; }
  .portal-nav a { font-size: 10px; min-width: 0; }
  .portal-nav .pico { font-size: 17px; }
}

/* =========================================================================
   SPRINT 15 — Trilha de auditoria (T-AUD-01/T-AUD-02)
   Garante leitura estável de identificadores longos e das diferenças (diff)
   sem provocar overflow horizontal em viewports estreitas.
   ========================================================================= */
#au-d-root .kv { grid-template-columns: 118px minmax(0, 1fr); }
#au-d-root .kv dd { min-width: 0; overflow-wrap: anywhere; }
#au-d-root .card, #au-d-root .cols, #au-d-root .card-body { min-width: 0; }
#au-d-root pre { overflow-wrap: anywhere; word-break: break-word; }
#au-rows td { overflow-wrap: anywhere; }
#au-filters { row-gap: 8px; }
