/* TeleHealthNest — design system.
   Identidade: verde-petróleo profundo, areia e coral; títulos serifados. */
:root {
  --ink: #16302e; --ink-soft: #4c6663; --ink-faint: #627b77;
  --brand: #155e55; --brand-strong: #0e453e; --brand-tint: #e2f0ec;
  --accent: #b9472f; --accent-tint: #fbe9e4;
  --bg: #f6f3ec; --surface: #ffffff; --surface-2: #fbf9f5; --line: #e4ded2;
  --ok: #1d6f42; --ok-tint: #e3f3e9; --warn: #8a5a00; --warn-tint: #fdf0d2;
  --danger: #a32d2d; --danger-tint: #fbe7e7; --info: #245a8c; --info-tint: #e5eef8;
  --sidebar-bg: #11302c; --sidebar-ink: #cfe0da; --sidebar-active: #1e4a43;
  --radius-s: 6px; --radius: 12px; --radius-l: 20px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --shadow: 0 1px 2px rgba(22,48,46,.06), 0 8px 24px -16px rgba(22,48,46,.25);
  --shadow-l: 0 24px 60px -24px rgba(22,48,46,.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --ink: #e7efec; --ink-soft: #b3c6c0; --ink-faint: #8fa6a0;
  --brand: #6cc4b0; --brand-strong: #93d8c7; --brand-tint: #173a34;
  --accent: #ff9d86; --accent-tint: #3d231d;
  --bg: #0d1b19; --surface: #132523; --surface-2: #17302c; --line: #27433e;
  --ok: #7fd3a2; --ok-tint: #153526; --warn: #f2c364; --warn-tint: #3a2e10;
  --danger: #ff9a9a; --danger-tint: #3d1d1d; --info: #98c4f0; --info-tint: #172c40;
  --sidebar-bg: #0a1614; --sidebar-ink: #b8cdc6; --sidebar-active: #17302c;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0 0 var(--space-3); letter-spacing: -.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 var(--space-3); }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-strong); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
img, video { max-width: 100%; }
/* Fundo branco também no tema escuro, para a câmera ler o código. */
.mfa-qr { display: block; background: #fff; border-radius: 8px; height: auto; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-s); z-index: 99; }
.skip:focus { left: 8px; }
.muted { color: var(--ink-soft); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-ink); padding: var(--space-5) var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 1.2rem; color: inherit; text-decoration: none; padding: 0 var(--space-3) var(--space-4); }
.brand:hover { color: inherit; }
.brand img { display: block; width: auto; height: 36px; max-width: 100%; object-fit: contain; }
.brand .brand-dark { display: none; }
/* Fundos sempre escuros (e o tema escuro) usam a versão clara da logo. */
:is([data-theme="dark"], .sidebar, .auth-aside, .lp, .room-body) .brand .brand-light { display: none; }
:is([data-theme="dark"], .sidebar, .auth-aside, .lp, .room-body) .brand .brand-dark { display: block; }
.sidebar .brand img { height: 38px; }
.auth-aside .brand img { height: 46px; }
.sidebar .brand { color: #fff; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; opacity: .6; padding: var(--space-4) var(--space-3) var(--space-1); }
.sidebar a.nav { display: flex; align-items: center; gap: 10px; color: var(--sidebar-ink); text-decoration: none; padding: 9px var(--space-3); border-radius: var(--radius-s); }
.sidebar a.nav:hover { background: var(--sidebar-active); color: #fff; }
.sidebar a.nav[aria-current="page"] { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.crumbs { font-size: .85rem; color: var(--ink-soft); display: flex; gap: 6px; flex-wrap: wrap; }
.menu-toggle { display: none; }
.content { padding: var(--space-5); max-width: 1240px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; justify-content: space-between; margin-bottom: var(--space-5); }
.page-head h1, .page-head p { margin: 0; }
.page-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Banners */
.banner { padding: 10px var(--space-5); display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; font-size: .9rem; background: var(--warn-tint); color: var(--warn); border-bottom: 1px solid var(--line); }
.banner-support { background: var(--danger); color: #fff; font-weight: 600; position: sticky; top: 0; z-index: 30; }
[data-theme="dark"] .banner-support { color: #200; }

/* Cartões e grades */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); box-shadow: var(--shadow); margin-bottom: var(--space-4); }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: var(--space-4); margin-bottom: var(--space-4); }
.grid > .card { margin-bottom: 0; }
.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-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stat { border-top: 3px solid var(--brand); }
.stat strong { display: block; font-family: var(--font-display); font-size: 2rem; line-height: 1.1; }
.stat span { color: var(--ink-soft); font-size: .85rem; }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 700; }
tbody tr:hover { background: var(--surface-2); }
.empty { text-align: center; color: var(--ink-soft); padding: var(--space-6); }
.pager { display: flex; justify-content: flex-end; gap: var(--space-3); align-items: center; margin-top: var(--space-3); }

/* Pares de horário: lado a lado quando cabem, um sob o outro no celular. */
.time-pair { display: flex; flex-wrap: wrap; gap: 6px; }
.time-pair input { flex: 1 1 104px; width: auto; min-width: 104px; }
@media (max-width: 820px) {
  .hours tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
  .hours th { grid-column: 1 / -1; border: 0; padding-bottom: 0; }
  .hours td { border: 0; padding: 6px; }
  .time-pair { flex-direction: column; }
  .time-pair input { flex: none; width: 100%; }
}

.currency-switch { margin-bottom: var(--space-2); }
.credit { text-align: center; font-size: .82rem; color: var(--ink-faint); margin: var(--space-5) 0 var(--space-4); }
.credit a { color: inherit; font-weight: 700; }
.credit a:hover { color: var(--brand); }
.room-body .credit { color: #8fa6a0; margin: var(--space-3) 0 0; }
.lp-footer .credit { color: #a9c7c1; text-align: left; margin: 12px 0 0; }
.lp-footer .credit a:hover { color: #fff; }

/* Página da consulta: o essencial visível, o resto recolhido. */
.appt-head { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; }
.appt-head h1 { margin: 0 0 4px; }
.appt-when { color: var(--ink-soft); margin-bottom: 8px; }
.appt-head p:last-child { margin: 0; }
.btn-lg { min-height: 48px; padding: 12px 26px; font-size: 1rem; }
.appt-side, .appt-main { min-width: 0; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-l); z-index: 40; }
.menu-item { display: block; width: 100%; text-align: left; font: inherit; background: transparent; border: 0; color: var(--ink); padding: 10px 12px; border-radius: var(--radius-s); cursor: pointer; }
.menu-item:hover { background: var(--brand-tint); }
.menu-item.danger { color: var(--danger); }
/* Seção recolhida: o título e o resumo dizem o que há dentro sem precisar abrir. */
details.fold { padding: 0; scroll-margin-top: 80px; }
details.fold > summary { list-style: none; display: flex; align-items: center; gap: var(--space-3); min-height: 52px; cursor: pointer; padding: 12px var(--space-5); font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; border-radius: var(--radius); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary:hover { background: var(--surface-2); }
details.fold > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: 0 3px 4px auto; border-right: 2px solid var(--ink-faint); border-bottom: 2px solid var(--ink-faint); transform: rotate(45deg); }
details.fold[open] > summary::after { margin-bottom: -4px; transform: rotate(-135deg); }
details.fold[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; margin-bottom: var(--space-3); }
.fold-hint { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font); font-weight: 400; font-size: .85rem; color: var(--ink-soft); }
details.fold > summary:has(.fold-hint)::after { margin-left: 0; }
details.fold.danger-zone > summary { color: var(--danger); }
details.fold > :not(summary) { margin-left: var(--space-5); margin-right: var(--space-5); }
details.fold > :last-child { margin-bottom: var(--space-4); }
details.sub { margin-top: var(--space-3); border-top: 1px solid var(--line); padding-top: var(--space-3); }
details.sub { scroll-margin-top: 80px; }
details.sub > summary { cursor: pointer; font-weight: 700; color: var(--brand); margin-bottom: var(--space-3); padding: 4px 0; }
details.sub > summary .fold-hint { margin-left: 8px; font-weight: 400; white-space: normal; }
details.sub:not([open]) > summary { margin-bottom: 0; }

/* Fatos curtos em colunas, no lugar de tabelas de uma linha só. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: var(--space-3) var(--space-4); margin: 0 0 var(--space-3); }
.facts.one { grid-template-columns: minmax(0, 1fr); }
.facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); font-weight: 700; }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.head-meta { display: flex; flex-wrap: wrap; gap: 4px var(--space-3); align-items: center; margin-top: 6px; color: var(--ink-soft); }
.head-id { display: flex; gap: var(--space-4); align-items: center; min-width: 0; }
.avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); column-gap: var(--space-4); margin-bottom: var(--space-3); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.list > details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.list > details:last-child { border-bottom: 0; }
.list > details > summary { cursor: pointer; }
.list > details[open] > summary { margin-bottom: var(--space-3); }
details.more > summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: .85rem; }
.row-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-top: var(--space-3); }
.row-actions form { margin: 0; }
.save-bar { position: sticky; bottom: 0; z-index: 10; display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-3); padding: 10px 0; background: var(--surface); border-top: 1px solid var(--line); }
.content > form > .save-bar { background: var(--bg); margin: 0 0 var(--space-4); }
.grid-top { align-items: start; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--space-4); border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 12px; text-decoration: none; font-weight: 600; font-size: .9rem; color: var(--ink-soft); border-bottom: 3px solid transparent; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }
.chart rect.bar-2 { fill: var(--accent); }
.chart rect.bar-3 { fill: var(--warn); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 12px; background: var(--brand); }
.key-2 { background: var(--accent); }
.key-3 { background: var(--warn); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) auto; gap: var(--space-3); align-items: center; font-size: .9rem; }
.bars-label { overflow-wrap: anywhere; }
.bars progress { margin: 0; }
.bars-n { text-align: right; white-space: nowrap; font-weight: 600; }
a.stat { display: block; color: inherit; text-decoration: none; }
a.stat:hover { color: inherit; border-color: var(--brand); }
.card.is-current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
a.menu-item { text-decoration: none; }
a.menu-item:hover { color: var(--ink); }

/* Listas no celular: cada linha vira um bloco, sem rolagem lateral. */
@media (max-width: 640px) {
  table.stack, table.stack tbody { display: block; }
  table.stack thead { display: none; }
  table.stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: block; border: 0; padding: 2px 0; text-align: left; min-width: 0; overflow-wrap: anywhere; }
  table.stack td:first-child { flex-basis: 100%; }
  table.stack td:empty { display: none; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-soft); font-size: .8rem; }
  table.stack td.empty { text-align: center; }
}
@media (max-width: 480px) {
  .grid-4.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Tabelas com cabeçalho (relatórios) cabem na tela com menos folga. */
  table:not(.stack) th, table:not(.stack) td { padding: 8px 5px; }
  table:not(.stack) th { letter-spacing: 0; text-transform: none; overflow-wrap: anywhere; }
}
.grid > div > :last-child, .grid > aside > :last-child { margin-bottom: 0; }
ul.plain { list-style: none; padding: 0; margin-top: 0; }
ul.plain li { display: flex; justify-content: space-between; gap: var(--space-3); align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
@media (max-width: 820px) {
  .appt-head .page-actions, .appt-head .page-actions .btn-lg { width: 100%; }
  /* No celular o menu abre como folha na parte de baixo: nunca sai da tela. */
  .menu-list { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; }
}

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--space-3); }
.form-grid .field { margin-bottom: 0; }
.field.full, .form-grid .full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .85rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 11px; width: 100%; min-height: 42px; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; accent-color: var(--brand); flex: none; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .8rem; }
.hint { color: var(--ink-faint); font-size: .8rem; }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; font-size: .92rem; margin-bottom: var(--space-2); }
.check input { margin-top: 3px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); margin: 0 0 var(--space-4); }
legend { font-weight: 700; padding: 0 6px; }
.inline-form { display: inline-flex; gap: var(--space-2); align-items: center; margin: 0; }
.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: flex-end; margin-bottom: var(--space-4); }
.filters .field { margin: 0; min-width: 160px; }

/* Botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: .9rem; padding: 9px 16px; min-height: 40px; border-radius: 999px; border: 1px solid transparent; background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; transition: transform .08s ease, background .15s ease; }
[data-theme="dark"] .btn { color: #06201b; }
.btn:hover { background: var(--brand-strong); color: #fff; }
[data-theme="dark"] .btn:hover { color: #06201b; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--brand); border-color: var(--line); }
[data-theme="dark"] .btn-secondary { color: var(--brand); }
.btn-secondary:hover { background: var(--brand-tint); color: var(--brand-strong); }
[data-theme="dark"] .btn-secondary:hover { color: var(--brand-strong); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); }
.btn-small { padding: 4px 11px; min-height: 30px; font-size: .8rem; }
.btn-block { width: 100%; }

/* Selos, alertas, toasts, modais */
.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--brand-tint); color: var(--brand-strong); white-space: nowrap; }
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-warn { background: var(--warn-tint); color: var(--warn); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-info { background: var(--info-tint); color: var(--info); }
.alert { border-radius: var(--radius-s); padding: 11px 14px; margin-bottom: var(--space-4); background: var(--info-tint); color: var(--info); }
.alert-success { background: var(--ok-tint); color: var(--ok); }
.alert-error { background: var(--danger-tint); color: var(--danger); }
.alert-warning { background: var(--warn-tint); color: var(--warn); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toasts .alert { margin: 0; box-shadow: var(--shadow-l); cursor: pointer; }
dialog { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); color: var(--ink); padding: var(--space-5); width: min(640px, calc(100vw - 24px)); box-shadow: var(--shadow-l); }
dialog::backdrop { background: rgba(10, 24, 22, .55); }

/* Idioma */
.lang { position: relative; }
.lang summary { list-style: none; cursor: pointer; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; background: var(--surface); }
.lang summary::-webkit-details-marker { display: none; }
.lang summary { white-space: nowrap; }
@media (max-width: 480px) {
  .topbar .lang-name, .room-bar .lang-name { display: none; }
  .topbar .lang .flag, .room-bar .lang .flag { margin-right: 0; }
  .topbar-actions { gap: 6px; }
}
.lang ul { position: absolute; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-l); min-width: 170px; z-index: 40; }
.lang a { display: block; padding: 7px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--ink); }
.lang a:hover, .lang a[aria-current="true"] { background: var(--brand-tint); }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: 36px; height: 36px; cursor: pointer; color: var(--ink); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; text-align: center; }

/* Páginas públicas / autenticação */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-aside { background: radial-gradient(120% 90% at 0% 100%, #1f6b60 0%, #11302c 60%); color: #eef6f3; padding: var(--space-7); display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside h2 { font-size: clamp(2rem, 3.4vw, 3rem); max-width: 14ch; }
.auth-aside .brand { color: #fff; padding: 0; }
.auth-aside ul { padding: 0; list-style: none; display: grid; gap: 10px; }
.auth-aside li::before { content: "—  "; color: #ff9d86; }
.auth-main { display: flex; flex-direction: column; padding: var(--space-5); }
.auth-top { display: flex; justify-content: flex-end; }
.auth-box { margin: auto; width: min(420px, 100%); }
.auth-box.wide { width: min(620px, 100%); }
.public { max-width: 760px; margin: 0 auto; padding: var(--space-5) var(--space-4); }
.public-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-5); }
.prose h2 { margin-top: var(--space-5); }

/* Calendário */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head { background: var(--surface-2); padding: 6px 8px; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--ink-faint); }
.cal-cell { background: var(--surface); min-height: 104px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal-week .cal-cell { min-height: 360px; }
.cal-cell.out { background: var(--surface-2); color: var(--ink-faint); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day { font-weight: 700; font-size: .8rem; text-decoration: none; }
.cal-item { display: block; font-size: .76rem; padding: 3px 6px; border-radius: var(--radius-s); background: var(--brand-tint); color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.canceled { text-decoration: line-through; opacity: .55; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segmented a { padding: 7px 14px; text-decoration: none; font-size: .85rem; font-weight: 600; }
.segmented a[aria-current="true"] { background: var(--brand-tint); }

/* Gráfico de barras em SVG */
.chart { width: 100%; height: auto; }
.chart rect { fill: var(--brand); }
.chart text { fill: var(--ink-soft); font-size: 11px; }
progress { width: 100%; height: 8px; accent-color: var(--brand); }

/* Sala de consulta */
.room-body { background: #0b1513; color: #e7efec; }
.room { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.room > .stage { flex: 1; }
.room-bar { display: flex; gap: var(--space-3); align-items: center; padding: 10px var(--space-4); font-size: .88rem; }
.room-chips { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; flex: 1; min-width: 0; }
.room-bar .chip { white-space: nowrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: #182a27; border-radius: 999px; padding: 4px 11px; font-size: .8rem; }
.chip.rec { background: #6d1f1f; color: #fff; }
.chip.ok { background: #153526; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.rec .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.stage { position: relative; display: flex; min-height: 0; gap: var(--space-3); padding: 0 var(--space-4); }
.stage-video { position: relative; flex: 1; min-width: 0; background: #12211f; border-radius: var(--radius-l); overflow: hidden; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.main { position: absolute; inset: 0; }
.tile.main video { object-fit: contain; }
.tile.pip { position: absolute; right: 14px; bottom: 14px; width: min(260px, 32%); aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; border: 2px solid #2d4b45; background: #000; z-index: 2; cursor: pointer; }
.tile .who { position: absolute; left: 10px; bottom: 8px; background: rgba(0,0,0,.55); padding: 2px 9px; border-radius: 999px; font-size: .75rem; }
/* Rola quando não cabe: nenhum botão pode ficar cortado atrás da barra. */
.stage-wait { position: absolute; inset: 0; display: flex; overflow-y: auto; text-align: center; padding: var(--space-4); z-index: 3; }
.stage-wait > div { margin: auto; width: min(520px, 100%); }
.stage-wait .card { margin: 0; }
.stage-wait .btn { min-height: 46px; margin-bottom: var(--space-2); }
.opens-info { font-size: 1.05rem; font-weight: 700; color: #f2c364; }
.lobby-message:empty { display: none; }
.stage-video.waiting .tile.pip { top: 10px; bottom: auto; width: min(180px, 28%); z-index: 4; }
.tile .no-video { display: none; position: absolute; inset: 0; place-items: center; text-align: center; background: #16302b; color: #b3c6c0; font-size: .9rem; padding: 8px; }
.tile.cam-off .no-video { display: grid; }
.tile .who { z-index: 1; }
.panel { width: 320px; display: flex; flex-direction: column; background: #132522; border-radius: var(--radius-l); padding: var(--space-3); min-height: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.panel-close { background: transparent; border: 0; color: inherit; font-size: 1.1rem; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.panel-form { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.panel-form input { min-width: 0; }
.notes-panel { width: 380px; }
.notes-panel textarea { flex: 1; min-height: 120px; resize: none; background: #0b1513; color: #e7efec; border-color: #2d4b45; line-height: 1.5; }
.notes-status { margin: 6px 0 0; min-height: 1.4em; }
.notes-status.problem { color: var(--accent); font-weight: 700; }
.notes-area { min-height: 220px; }
.early-info { color: #f2c364; }
.panel-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.panel input { background: #0b1513; color: #e7efec; border-color: #2d4b45; }
.controls { display: flex; justify-content: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-3); }
/* Controles redondos com ícones, como nas ferramentas de reunião. */
.controls { align-items: center; }
.controls button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: .85rem; font-weight: 600; border: 0; border-radius: 999px; min-height: 52px; padding: 0 20px; background: #2a403b; color: #eef6f3; cursor: pointer; }
.controls button:hover { filter: brightness(1.15); }
.controls button svg { width: 24px; height: 24px; flex: none; }
.controls button.ctl { width: 52px; padding: 0; }
.controls button.ctl.ctl-text { width: auto; padding: 0 18px; }
.controls button[aria-pressed="true"] { background: #bfe9dd; color: #08211f; }
.controls button.ctl-media[aria-pressed="true"] { background: #2a403b; color: #eef6f3; }
.controls button.ctl-media[aria-pressed="false"] { background: #d93025; color: #fff; }
.controls .ctl-media[aria-pressed="true"] .off, .controls .ctl-media[aria-pressed="false"] .on { display: none; }
.controls button.ctl-rec[aria-pressed="true"] { background: #d93025; color: #fff; }
.controls button.leave { background: #d93025; color: #fff; }
.controls button.admit { background: #f2c364; color: #2b1d00; }
.controls button:disabled { opacity: .45; cursor: not-allowed; }
.tile .mic-badge { display: none; position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; border-radius: 50%; background: #d93025; color: #fff; place-items: center; z-index: 2; }
.tile .mic-badge svg { width: 17px; height: 17px; }
.tile.muted .mic-badge { display: grid; }
.preview-off { display: grid; place-items: center; color: #b3c6c0; }
.controls button.unread::after { content: ""; position: absolute; top: 6px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: #ff9d86; }
.room-flash { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); margin: 0; padding: 12px 16px; border-radius: var(--radius); background: #6d1f1f; color: #fff; text-align: center; z-index: 60; box-shadow: var(--shadow-l); }
.room-notice { margin: 0; padding: 6px var(--space-4); text-align: center; font-size: .82rem; background: #3a2e10; color: #f2c364; }
.local-copy { cursor: pointer; font-weight: 400; }
.lobby-video { width: 100%; max-height: 38vh; aspect-ratio: 4 / 3; background: #0b1513; border-radius: var(--radius); object-fit: cover; margin-bottom: var(--space-2); }
.meter { height: 8px; width: 100%; }

/* Documentos clínicos */
.doc-section { border-left: 3px solid var(--line); padding-left: var(--space-4); margin-bottom: var(--space-4); }
.doc-item { margin-bottom: var(--space-2); }
.transcript { display: grid; gap: var(--space-2); }
.turn { display: grid; grid-template-columns: 130px 56px minmax(0, 1fr); gap: var(--space-3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.turn .speaker { font-weight: 700; font-size: .8rem; text-transform: uppercase; }
.turn.professional .speaker { color: var(--brand); } .turn.patient .speaker { color: var(--accent); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform .2s ease; z-index: 50; visibility: hidden; }
  .sidebar.open { transform: none; visibility: visible; box-shadow: var(--shadow-l); }
  .menu-toggle { display: inline-block; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .content { padding: var(--space-4); }
  .topbar { padding: var(--space-3) var(--space-4); }
  .crumbs { display: none; }
  .calendar { grid-template-columns: minmax(0, 1fr); }
  .cal-head, .cal-cell.out { display: none; }
  .cal-cell, .cal-week .cal-cell { min-height: 0; }
  .turn { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .stage { flex-direction: column; padding: 0 var(--space-2); }
  /* Celular: chips rolam na horizontal e o chat vira uma folha sobre o vídeo. */
  .room-bar { flex-wrap: wrap; gap: var(--space-2); padding: 8px var(--space-3); }
  .room-clinic { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .room-chips { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .room-chips::-webkit-scrollbar { display: none; }
  .panel { position: absolute; left: var(--space-2); right: var(--space-2); bottom: 0; width: auto; height: 62%; z-index: 5; box-shadow: var(--shadow-l); border: 1px solid #2d4b45; }
  .tile.pip { width: 34%; right: 10px; bottom: 10px; }
  .lobby-video { width: auto; max-width: 100%; max-height: 30vh; margin: 0 auto; display: block; }
  .controls { gap: 8px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
  .controls button { min-height: 48px; padding: 0 14px; font-size: .8rem; }
  .controls button.ctl { width: 48px; padding: 0; }
  .controls button.ctl.ctl-text { width: auto; padding: 0 12px; }
  .controls .local-copy { flex-basis: 100%; justify-content: center; }
}
@media (max-width: 480px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }
@media print { .sidebar, .topbar, .page-actions, .toasts, .banner, details.fold, details.sub, .doc-section details, .save-bar { display: none !important; } .shell { display: block; } .card { box-shadow: none; } }
.flag { display: inline-block; vertical-align: -2px; margin-right: 6px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.auth-aside .chip { background: rgba(255,255,255,.12); color: #eef6f3; text-decoration: none; }
.room-body .lang summary { background: #182a27; color: #e7efec; border-color: #2d4b45; }
.room-body .lang ul { background: #132522; border-color: #2d4b45; }
.room-body .lang a { color: #e7efec; }
.room-body .lang a:hover, .room-body .lang a[aria-current="true"] { background: #1d332f; }
.room-body .card { background: #132522; border-color: #2d4b45; color: #e7efec; text-align: left; }
.stat strong { font-size: clamp(1.35rem, 2.2vw, 2rem); white-space: nowrap; }
/* Depois das regras de celular: o aviso fica no centro do quadro. */
.lobby-video.preview-off { display: grid; place-items: center; width: 100%; }
