/* Plataforma Médica — estilos. Tokens herdados do sistema original (cores de sistema, escuro por padrão; .light muda os valores). */

:root {
  --background: 0 0 0;
  --surface: 28 28 30;
  --surface-2: 44 44 46;
  --foreground: 245 245 247;
  --muted: 160 160 168;
  --border: 255 255 255;
  --primary: 10 114 232;
  --primary-fg: 255 255 255;
  --link: 90 172 255;
  --danger: 255 105 97;
  --success: 48 209 88;
  --warning: 255 214 10;
  --violet: 191 130 255;
  --raio: 14px;
  --raio-2: 20px;
  --sombra: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px -12px rgb(0 0 0 / 0.18);
  --fonte: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

.light {
  --background: 242 242 247;
  --surface: 255 255 255;
  --surface-2: 242 242 247;
  --foreground: 28 28 30;
  --muted: 92 92 98;
  --border: 0 0 0;
  --primary: 0 102 214;
  --primary-fg: 255 255 255;
  --link: 0 102 214;
  --danger: 200 30 30;
  --success: 26 127 55;
  --warning: 150 100 0;
  --violet: 112 48 186;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; border: 0 solid rgb(var(--border) / 0.1); }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: rgb(var(--background)); color: rgb(var(--foreground)); font-family: var(--fonte); line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; cursor: pointer; padding: 0; }
button:disabled { cursor: not-allowed; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
::selection { background: rgb(var(--primary) / 0.35); }
:focus-visible { outline: 2px solid rgb(var(--link)); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.tabular, td, .num { font-variant-numeric: tabular-nums; }
* { scrollbar-width: thin; scrollbar-color: rgb(var(--border) / 0.18) transparent; }

/* ---------- ícones (sprite Lucide) ---------- */
.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-xs { width: 14px; height: 14px; }
.i-lg { width: 22px; height: 22px; }
.i-xl { width: 28px; height: 28px; }
.girando { animation: girar 0.9s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- utilitários ---------- */
.flex { display: flex; } .inline-flex { display: inline-flex; } .grid { display: grid; } .block { display: block; } .hidden { display: none; }
.col { flex-direction: column; } .wrap { flex-wrap: wrap; } .items-center { align-items: center; } .items-start { align-items: flex-start; } .items-end { align-items: flex-end; } .items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; } .justify-center { justify-content: center; } .justify-end { justify-content: flex-end; }
.flex-1 { flex: 1 1 0%; min-width: 0; } .shrink-0 { flex-shrink: 0; } .min-w-0 { min-width: 0; }
.gap-1 { gap: 4px; } .gap-1h { gap: 6px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.pilha > * + * { margin-top: 16px; } .pilha-2 > * + * { margin-top: 8px; } .pilha-3 > * + * { margin-top: 12px; } .pilha-6 > * + * { margin-top: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .ml-auto { margin-left: auto; }
.p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; } .p-6 { padding: 24px; } .px-3 { padding-left: 12px; padding-right: 12px; } .py-2 { padding-top: 8px; padding-bottom: 8px; }
.w-full { width: 100%; } .max-w-sm { max-width: 24rem; } .max-w-md { max-width: 28rem; } .max-w-lg { max-width: 32rem; } .max-w-2xl { max-width: 42rem; } .max-w-3xl { max-width: 48rem; } .max-w-4xl { max-width: 56rem; } .max-w-5xl { max-width: 64rem; } .max-w-6xl { max-width: 72rem; } .mx-auto { margin-left: auto; margin-right: auto; }
.text-xs { font-size: 12px; line-height: 16px; } .text-sm { font-size: 13.5px; line-height: 20px; } .text-base { font-size: 15px; } .text-lg { font-size: 17px; line-height: 24px; } .text-xl { font-size: 20px; line-height: 28px; } .text-2xl { font-size: 24px; line-height: 32px; } .text-3xl { font-size: 30px; line-height: 36px; }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.muted { color: rgb(var(--muted)); } .text-danger { color: rgb(var(--danger)); } .text-success { color: rgb(var(--success)); } .text-warning { color: rgb(var(--warning)); } .text-link { color: rgb(var(--link)); } .text-violet { color: rgb(var(--violet)); } .text-primary { color: rgb(var(--primary)); }
.text-center { text-align: center; } .text-right { text-align: right; } .uppercase { text-transform: uppercase; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .nowrap { white-space: nowrap; } .quebra { white-space: pre-wrap; overflow-wrap: anywhere; } .break { overflow-wrap: anywhere; }
.tracking-tight { letter-spacing: -0.01em; }
.link { color: rgb(var(--link)); text-underline-offset: 3px; } .link:hover { text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.relative { position: relative; } .sticky-topo { position: sticky; top: 0; }
.rounded { border-radius: var(--raio); } .rounded-2 { border-radius: var(--raio-2); } .rounded-full { border-radius: 999px; }
.bg-surface { background: rgb(var(--surface)); } .bg-surface-2 { background: rgb(var(--surface-2)); }
.borda { border-width: 1px; } .borda-b { border-bottom-width: 1px; } .borda-t { border-top-width: 1px; }
.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2 / span 2; } .span-3 { grid-column: span 3 / span 3; } .span-todo { grid-column: 1 / -1; }
@media (max-width: 767px) { .cols-2, .cols-3, .cols-4, .cols-5 { grid-template-columns: minmax(0, 1fr); } .span-2, .span-3 { grid-column: auto; } .so-desktop { display: none !important; } }
@media (min-width: 768px) and (max-width: 1023px) { .cols-3, .cols-4, .cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 768px) { .so-celular { display: none !important; } }

/* ---------- superfícies ---------- */
.card { border-radius: var(--raio-2); border-width: 1px; background: rgb(var(--surface)); }
.card-sombra { box-shadow: var(--sombra); }
.card-titulo { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom-width: 1px; }
.card-corpo { padding: 20px; }
.secao-titulo { font-size: 13px; font-weight: 600; color: rgb(var(--muted)); margin-bottom: 8px; }
.aviso { border-radius: var(--raio); padding: 10px 12px; font-size: 13.5px; background: rgb(var(--surface-2)); color: rgb(var(--muted)); }
.aviso-perigo { background: rgb(var(--danger) / 0.1); color: rgb(var(--danger)); }
.aviso-alerta { background: rgb(var(--warning) / 0.12); color: rgb(var(--warning)); }
.aviso-ok { background: rgb(var(--success) / 0.12); color: rgb(var(--success)); }
.aviso-info { background: rgb(var(--primary) / 0.12); color: rgb(var(--link)); }
.divisor { height: 1px; background: rgb(var(--border) / 0.1); margin: 16px 0; }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--raio); font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background-color .15s, opacity .15s, border-color .15s; border-width: 1px; border-color: transparent; user-select: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn-primario { background: rgb(var(--primary)); color: rgb(var(--primary-fg)); }
.btn-primario:hover { background: rgb(var(--primary) / 0.88); }
.btn-secundario { background: rgb(var(--surface-2)); border-color: rgb(var(--border) / 0.1); }
.btn-secundario:hover { background: rgb(var(--border) / 0.12); }
.btn-contorno { border-color: rgb(var(--border) / 0.18); background: transparent; }
.btn-contorno:hover { background: rgb(var(--border) / 0.08); }
.btn-fantasma { background: transparent; }
.btn-fantasma:hover { background: rgb(var(--border) / 0.08); }
.btn-perigo { background: rgb(var(--danger)); color: #fff; }
.light .btn-perigo { color: #fff; }
.btn-perigo:hover { background: rgb(var(--danger) / 0.88); }
.btn-perigo-suave { background: rgb(var(--danger) / 0.1); color: rgb(var(--danger)); }
.btn-perigo-suave:hover { background: rgb(var(--danger) / 0.18); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 8px; gap: 4px; }
.btn-icone { width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.btn-icone.btn-sm { width: 30px; height: 30px; }
.btn-bloco { width: 100%; }

/* ---------- formulários ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > label, .rotulo { font-size: 13px; font-weight: 500; }
.campo .ajuda { font-size: 12px; color: rgb(var(--muted)); }
.campo .erro, .erro-campo { font-size: 12px; color: rgb(var(--danger)); }
.field { height: 40px; width: 100%; border-radius: var(--raio); border: 1px solid rgb(var(--border) / 0.15); background: rgb(var(--surface-2)); padding: 0 12px; font-size: 13.5px; color: rgb(var(--foreground)); transition: border-color .15s; min-width: 0; }
.field::placeholder { color: rgb(var(--muted) / 0.8); }
.field:hover { border-color: rgb(var(--border) / 0.25); }
.field:focus { outline: none; border-color: rgb(var(--link)); box-shadow: 0 0 0 3px rgb(var(--link) / 0.2); }
.field:disabled { opacity: 0.5; }
.field[aria-invalid="true"] { border-color: rgb(var(--danger)); }
textarea.field { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.field { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.field-sm { height: 32px; font-size: 12.5px; border-radius: 10px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: rgb(var(--primary)); margin: 0; flex-shrink: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.com-icone { position: relative; }
.com-icone > .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: rgb(var(--muted)); pointer-events: none; }
.com-icone > .field { padding-left: 36px; }
.form-grade { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-grade { grid-template-columns: minmax(0, 1fr); } }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* ---------- tabelas ---------- */
.tabela-envolve { overflow-x: auto; }
.tabela { font-size: 13.5px; }
.tabela th { text-align: left; font-size: 12px; font-weight: 500; color: rgb(var(--muted)); padding: 10px 16px; border-bottom-width: 1px; white-space: nowrap; }
.tabela td { padding: 12px 16px; border-bottom-width: 1px; vertical-align: middle; }
.tabela tr:last-child td { border-bottom-width: 0; }
.tabela tbody tr:hover { background: rgb(var(--border) / 0.035); }
.tabela .direita { text-align: right; }
.tabela-compacta td { padding: 8px 12px; } .tabela-compacta th { padding: 8px 12px; }

/* ---------- selos ---------- */
.selo { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; background: rgb(var(--border) / 0.1); color: rgb(var(--muted)); }
.selo-azul { background: rgb(var(--primary) / 0.15); color: rgb(var(--link)); }
.selo-verde { background: rgb(var(--success) / 0.15); color: rgb(var(--success)); }
.selo-amarelo { background: rgb(var(--warning) / 0.15); color: rgb(var(--warning)); }
.selo-vermelho { background: rgb(var(--danger) / 0.15); color: rgb(var(--danger)); }
.selo-roxo { background: rgb(var(--violet) / 0.15); color: rgb(var(--violet)); }
.contador { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: rgb(var(--danger)); color: rgb(var(--background)); font-size: 11px; font-weight: 600; line-height: 1; }

/* ---------- avatar ---------- */
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px; background: rgb(var(--primary) / 0.15); color: rgb(var(--link)); font-size: 12.5px; font-weight: 600; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

/* ---------- abas ---------- */
.abas { display: flex; gap: 4px; border-bottom-width: 1px; overflow-x: auto; }
.aba { height: 40px; padding: 0 12px; font-size: 13.5px; color: rgb(var(--muted)); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.aba:hover { color: rgb(var(--foreground)); }
.aba[aria-selected="true"], .aba.ativa { color: rgb(var(--foreground)); border-bottom-color: rgb(var(--primary)); font-weight: 500; }
.segmentos { display: inline-flex; padding: 3px; border-radius: 12px; background: rgb(var(--surface-2)); gap: 2px; }
.segmento { height: 30px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; color: rgb(var(--muted)); display: inline-flex; align-items: center; gap: 6px; }
.segmento[aria-pressed="true"], .segmento.ativo { background: rgb(var(--surface)); color: rgb(var(--foreground)); font-weight: 500; box-shadow: 0 1px 2px rgb(0 0 0 / 0.15); }

/* ---------- diálogo ---------- */
dialog.dialogo { border: 1px solid rgb(var(--border) / 0.12); border-radius: var(--raio-2); background: rgb(var(--surface)); color: rgb(var(--foreground)); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 64px -16px rgb(0 0 0 / 0.5); }
dialog.dialogo.largo { width: min(820px, calc(100vw - 32px)); }
dialog.dialogo.estreito { width: min(420px, calc(100vw - 32px)); }
dialog.dialogo::backdrop { background: rgb(0 0 0 / 0.55); }
dialog.dialogo[open] { animation: surgir .18s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; }
@keyframes surgir { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialogo-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.dialogo-cab h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.dialogo-corpo { padding: 4px 20px 20px; overflow-y: auto; }
.dialogo-rodape { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top-width: 1px; flex-wrap: wrap; }

/* ---------- menu suspenso ---------- */
.menu { position: relative; }
.menu-lista { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 50; border-radius: var(--raio); border-width: 1px; background: rgb(var(--surface)); box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.45); padding: 6px; }
.menu-item { display: flex; width: 100%; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 9px; font-size: 13.5px; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: rgb(var(--border) / 0.08); outline: none; }
.menu-item.perigo { color: rgb(var(--danger)); }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; border-radius: var(--raio); border-width: 1px; background: rgb(var(--surface)); padding: 12px 14px; box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.5); font-size: 13.5px; animation: surgir .2s ease-out; }
.toast .titulo { font-weight: 600; }
.toast .desc { color: rgb(var(--muted)); font-size: 12.5px; margin-top: 2px; }
.toast-sucesso .i { color: rgb(var(--success)); } .toast-erro .i { color: rgb(var(--danger)); } .toast-alerta .i { color: rgb(var(--warning)); } .toast-info .i { color: rgb(var(--link)); }
.toast-erro { border-color: rgb(var(--danger) / 0.35); }

/* ---------- vazio, esqueleto ---------- */
.vazio { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 40px 16px; color: rgb(var(--muted)); font-size: 13.5px; }
.vazio .i { width: 28px; height: 28px; opacity: .7; }
.vazio strong { color: rgb(var(--foreground)); font-weight: 600; font-size: 14px; }
.esqueleto { background: linear-gradient(90deg, rgb(var(--border) / 0.06), rgb(var(--border) / 0.12), rgb(var(--border) / 0.06)); background-size: 200% 100%; animation: brilho 1.4s ease-in-out infinite; border-radius: 8px; min-height: 14px; }
@keyframes brilho { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- casca (shell) ---------- */
.casca { display: flex; min-height: 100vh; }
.lateral { position: sticky; top: 0; height: 100vh; width: 256px; flex-shrink: 0; border-right-width: 1px; background: rgb(var(--surface) / 0.6); backdrop-filter: blur(20px); display: flex; flex-direction: column; transition: width .2s; }
.casca.recolhida .lateral { width: 76px; }
.lateral-marca { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 16px; flex-shrink: 0; }
.marca-icone { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 12px; background: rgb(var(--primary)); color: rgb(var(--primary-fg)); flex-shrink: 0; }
.lateral-nav { flex: 1; overflow-y: auto; padding: 8px 12px 24px; }
.nav-grupo + .nav-grupo { margin-top: 24px; }
.nav-grupo h2 { font-size: 12px; font-weight: 500; color: rgb(var(--muted)); padding: 0 12px; margin-bottom: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: var(--raio); font-size: 13.5px; width: 100%; text-align: left; transition: background-color .15s; position: relative; }
.nav-item:hover { background: rgb(var(--border) / 0.08); }
.nav-item[aria-current="page"] { background: rgb(var(--primary)); color: rgb(var(--primary-fg)); font-weight: 500; box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.nav-sub { margin: 2px 0 0 18px; padding-left: 14px; border-left-width: 1px; }
.nav-sub .nav-item { height: 36px; color: rgb(var(--muted)); }
.nav-sub .nav-item:hover { color: rgb(var(--foreground)); }
.nav-sub .nav-item[aria-current="page"] { color: rgb(var(--primary-fg)); }
.nav-item .seta { margin-left: auto; transition: transform .2s; }
.nav-item[aria-expanded="true"] .seta { transform: rotate(180deg); }
.casca.recolhida .nav-rotulo, .casca.recolhida .nav-grupo h2, .casca.recolhida .seta, .casca.recolhida .marca-nome, .casca.recolhida .nav-sub { display: none; }
.casca.recolhida .nav-item { justify-content: center; padding: 0; }
.casca.recolhida .nav-item .contador { position: absolute; top: 2px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
.conteudo { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: 64px; padding: 0 16px; border-bottom-width: 1px; background: rgb(var(--background) / 0.8); backdrop-filter: blur(20px); }
.topo h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
main.principal { flex: 1; padding: 24px 32px; }
@media (max-width: 1023px) {
  .lateral { position: fixed; left: 0; top: 0; z-index: 45; transform: translateX(-100%); transition: transform .2s; background: rgb(var(--surface)); width: 256px !important; }
  .casca.menu-aberto .lateral { transform: none; }
  .casca.recolhida .nav-rotulo, .casca.recolhida .nav-grupo h2, .casca.recolhida .seta, .casca.recolhida .marca-nome { display: initial; }
  main.principal { padding: 20px 16px; }
}
.veu { position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 40; }
.painel-direito { width: 320px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; border-left-width: 1px; background: rgb(var(--surface)); display: flex; flex-direction: column; }
@media (max-width: 1279px) { .painel-direito { position: fixed; right: 0; top: 0; bottom: 0; z-index: 46; width: min(22rem, 100vw); } }
@media (min-width: 1280px) { .so-ate-xl { display: none !important; } }
.veu-painel { position: fixed; inset: 0; background: rgb(0 0 0 / .5); z-index: 45; }
.painel-conteudo { flex: 1; min-height: 0; overflow-y: auto; }
#painel-chat { display: flex; flex-direction: column; } #painel-chat[hidden] { display: none; }
.painel-aba { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; padding: 14px 4px; font-size: 13px; font-weight: 500; color: rgb(var(--muted)); }
.painel-aba:hover { color: rgb(var(--foreground)); }
.painel-aba[aria-selected="true"] { color: rgb(var(--link)); }
.painel-aba[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: 2px; background: rgb(var(--primary)); }
.contador-azul { background: rgb(var(--primary)); color: rgb(var(--primary-fg)); }
.notif { display: flex; gap: 12px; padding: 10px 12px; border-radius: var(--raio); background: rgb(var(--surface-2)); }
.notif.nova { background: rgb(var(--primary) / 0.1); box-shadow: inset 0 0 0 1px rgb(var(--primary) / 0.3); }
.notif-icone { display: flex; width: 32px; height: 32px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 999px; margin-top: 2px; }
.colega { display: flex; width: 100%; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--raio); text-align: left; }
.colega:hover { background: rgb(var(--border) / 0.08); }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bolha { max-width: 85%; padding: 8px 12px; border-radius: 18px 18px 18px 6px; font-size: 13.5px; background: rgb(var(--surface-2)); }
.bolha.minha { border-radius: 18px 18px 6px 18px; background: rgb(var(--primary)); color: rgb(var(--primary-fg)); }
.bolha-hora { margin-top: 2px; text-align: right; font-size: 10px; color: rgb(var(--muted)); }
.bolha.minha .bolha-hora { color: rgb(var(--primary-fg) / 0.8); }
.sala-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--raio); }
.grupo-tarefas { border-radius: var(--raio); border-width: 1px; padding: 12px; }
.lista-tarefas > li + li { border-top-width: 1px; }
.tarefa { padding: 8px 0; } .tarefa:first-child { padding-top: 0; } .tarefa:last-child { padding-bottom: 0; }
.tarefa > * + * { margin-top: 6px; }
.ponto { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; margin-top: 6px; }
.cabeca-pagina { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cabeca-pagina h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.cabeca-pagina p { color: rgb(var(--muted)); font-size: 13.5px; margin-top: 2px; }
.barra-filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }

/* ---------- páginas de acesso ---------- */
.tela-acesso { position: relative; display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 40px 16px; overflow: hidden; }
.icone-redondo { display: flex; width: 48px; height: 48px; align-items: center; justify-content: center; border-radius: 999px; background: rgb(var(--primary) / 0.15); color: rgb(var(--link)); }
.icone-redondo .i { width: 24px; height: 24px; }
.tela-acesso::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .7; background: radial-gradient(60rem 40rem at 50% -10%, rgb(var(--primary) / 0.28), transparent 60%), radial-gradient(40rem 30rem at 100% 110%, rgb(var(--primary) / 0.14), transparent 60%); }
.marca-grande { display: flex; width: 56px; height: 56px; align-items: center; justify-content: center; border-radius: var(--raio-2); background: rgb(var(--primary)); color: rgb(var(--primary-fg)); box-shadow: var(--sombra); margin: 0 auto 16px; }

/* ---------- métricas ---------- */
.metrica { border-radius: var(--raio-2); border-width: 1px; background: rgb(var(--surface)); padding: 16px 18px; }
.metrica .rot { font-size: 12.5px; color: rgb(var(--muted)); display: flex; align-items: center; gap: 6px; }
.metrica .val { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.metrica .sub { font-size: 12px; color: rgb(var(--muted)); margin-top: 2px; }

/* ---------- gráficos (SVG desenhado pelo app.js) ---------- */
.grafico { width: 100%; height: 240px; }
.grafico text { fill: rgb(var(--muted)); font-size: 11px; }
.grafico .eixo { stroke: rgb(var(--border) / 0.12); }
.legenda { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: rgb(var(--muted)); }
.legenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--cor); margin-right: 6px; vertical-align: -1px; }

/* ---------- paginação ---------- */
.paginacao { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; font-size: 12.5px; color: rgb(var(--muted)); border-top-width: 1px; }

/* ---------- documentos impressos ---------- */
.folha { background: #fff; color: #111; border-radius: 6px; padding: 48px 56px; max-width: 800px; margin: 0 auto; box-shadow: var(--sombra); font-size: 14px; line-height: 1.6; }
.folha .timbre { display: flex; align-items: center; gap: 16px; border-bottom: 1px solid #ccc; padding-bottom: 14px; margin-bottom: 24px; }
.folha .timbre img { max-height: 64px; max-width: 160px; object-fit: contain; }
.folha .rodape-doc { border-top: 1px solid #ccc; padding-top: 10px; margin-top: 40px; font-size: 11px; color: #555; text-align: center; }
.folha .assinatura { margin: 64px auto 0; width: 300px; border-top: 1px solid #333; padding-top: 6px; text-align: center; font-size: 13px; }
.folha table td, .folha table th { border: 1px solid #ccc; padding: 4px 8px; color: #111; }
.folha .muted { color: #555; }

.so-impressao { display: none; }
@media print {
  .so-impressao { display: block; }
  .lateral, .topo, .no-print, .painel-direito, #toasts, .veu { display: none !important; }
  body { background: #fff; color: #000; }
  main.principal { padding: 0; }
  .folha { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .card { border-color: #ccc; background: #fff; }
  @page { margin: 16mm; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* linha de tabela inteira clicável */
.linha-link::before { content: ""; position: absolute; inset: 0; }
tr.relative { position: relative; }

/* ---------- prontuário / atendimento ---------- */
.vazio-tracejado { border: 1px dashed rgb(var(--border) / 0.25); border-radius: var(--raio); padding: 40px 16px; text-align: center; font-size: 13.5px; color: rgb(var(--muted)); }
p.vazio-tracejado.text-xs { padding: 8px 12px; text-align: left; }
.divisor-lista > li + li { border-top-width: 1px; }
.field-atencao { border-color: rgb(var(--warning)); background: rgb(var(--warning) / 0.1); }
.grade-sinais { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1023px) { .grade-sinais { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grade-sinais { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pergunta { padding: 12px 0; border-bottom-width: 1px; }
.pergunta:last-child { border-bottom-width: 0; }
.pilula { border-radius: 8px; border: 1px solid rgb(var(--border) / 0.2); padding: 4px 12px; font-size: 13.5px; color: rgb(var(--muted)); transition: background-color .15s; }
.pilula:hover { background: rgb(var(--border) / 0.05); }
.pilula-ativa { border-color: rgb(var(--primary)); background: rgb(var(--primary) / 0.15); color: rgb(var(--link)); font-weight: 500; }
.pilula-sim { border-color: rgb(var(--warning)); background: rgb(var(--warning) / 0.15); color: rgb(var(--warning)); font-weight: 500; }
.barra-fixa { position: fixed; left: 256px; right: 0; bottom: 0; z-index: 30; border-top-width: 1px; background: rgb(var(--surface) / 0.95); backdrop-filter: blur(12px); padding: 12px 16px; }
.casca.recolhida .barra-fixa { left: 76px; }
@media (max-width: 1023px) { .barra-fixa, .casca.recolhida .barra-fixa { left: 0; } }
@media (min-width: 1280px) { .casca:has(#painel-direito:not([hidden])) .barra-fixa { right: 320px; } }
.barra-fixa-int { max-width: 64rem; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.anexo-item { position: relative; overflow: hidden; }
.anexo-previa { display: flex; height: 144px; align-items: center; justify-content: center; background: rgb(var(--surface-2)); }
.anexo-previa img { width: 100%; height: 100%; object-fit: cover; }
.anexo-remover { position: absolute; right: 8px; top: 8px; opacity: 0; background: rgb(var(--surface) / 0.9); }
.anexo-item:hover .anexo-remover, .anexo-remover:focus { opacity: 1; }
.envio-anexo { border-style: dashed; transition: border-color .15s, background-color .15s; }
.envio-anexo.arrastando { border-color: rgb(var(--primary)); background: rgb(var(--primary) / 0.05); }
@media (max-width: 767px) { .envio-anexo .grid { grid-template-columns: minmax(0, 1fr) !important; } }
.icone-perigo:hover { color: rgb(var(--danger)); }
fieldset.borda { border-style: solid; border-color: rgb(var(--border) / 0.15); border-radius: var(--raio); }
.abas { overflow-y: hidden; }

/* ---------- financeiro ---------- */
.metrica-icone { display: flex; width: 48px; height: 48px; flex-shrink: 0; align-items: center; justify-content: center; border-radius: 16px; }
.clicavel { cursor: pointer; }
.barra-h { display: grid; grid-template-columns: minmax(80px, 140px) 1fr auto; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.barra-h .trilho { height: 22px; border-radius: 0 6px 6px 0; background: rgb(var(--border) / 0.06); }
.barra-h .preenchida { height: 100%; border-radius: 0 6px 6px 0; background: rgb(var(--primary)); min-width: 2px; }
.rosca-caixa { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; justify-content: center; }
.rosca-legenda { list-style: none; font-size: 13px; }
.rosca-legenda li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.rosca-legenda i { width: 10px; height: 10px; border-radius: 999px; flex-shrink: 0; }
.grid-metricas { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ---------- TISS ---------- */
.lista-linhas { list-style: none; margin: 0; padding: 0; }
.lista-linhas > li + li { border-top: 1px solid rgb(var(--border) / 0.1); }
.cartao-link { transition: background-color .15s; }
.cartao-link:hover { background: rgb(var(--border) / 0.05); }
.tabela tr.clicavel:hover td { background: rgb(var(--border) / 0.05); }
.guia-papel { position: relative; max-width: 56rem; margin: 0 auto; background: #fff; color: #000; padding: 24px; border-radius: var(--raio); box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.guia-titulo { font-size: 18px; font-weight: 700; line-height: 1.2; }
.guia-rot { font-size: 8px; line-height: 1.2; color: #525252; }
.guia-val { min-height: 1rem; font-size: 11px; font-weight: 500; line-height: 1.2; }
.guia-cel { border: 1px solid #000; padding: 4px 6px; }
.guia-faixa { margin-top: 8px; border: 1px solid #000; background: #e5e5e5; padding: 2px 6px; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.guia-grade { display: grid; gap: 4px; margin-top: 4px; }
.guia-grade.g2 { grid-template-columns: repeat(2, 1fr); } .guia-grade.g3 { grid-template-columns: repeat(3, 1fr); } .guia-grade.g4 { grid-template-columns: repeat(4, 1fr); }
.guia-grade .c2 { grid-column: span 2; } .guia-grade .c3 { grid-column: span 3; } .guia-grade .c4 { grid-column: span 4; }
.guia-tabela { width: 100%; border-collapse: collapse; font-size: 10px; margin-top: 4px; }
.guia-tabela th, .guia-tabela td { border: 1px solid #000; padding: 4px 6px; text-align: left; }
.guia-tabela th { background: #f5f5f5; font-weight: 600; } .guia-tabela td.direita { text-align: right; }
.guia-assinaturas { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; text-align: center; font-size: 10px; }
.guia-assinaturas > div { border-top: 1px solid #000; padding-top: 4px; } .guia-assinaturas span { color: #525252; }
.guia-rodape { margin-top: 16px; font-size: 8px; color: #737373; }
.guia-cancelada { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 72px; font-weight: 900; letter-spacing: .15em; color: rgb(220 38 38 / .4); transform: rotate(-25deg); }
@media print { .guia-papel { box-shadow: none; padding: 0; max-width: none; } }

/* ---------- caixa de mensagens (WhatsApp) ---------- */
.mensagens-caixa { display: flex; height: calc(100dvh - 9rem); min-height: 30rem; overflow: hidden; }
.msg-lista { display: flex; flex-direction: column; flex-shrink: 0; width: 20rem; border-right: 1px solid rgb(var(--border) / 0.1); }
.msg-itens { flex: 1; min-height: 0; overflow-y: auto; }
.msg-item { display: flex; width: 100%; align-items: flex-start; gap: 12px; padding: 12px 16px; text-align: left; transition: background-color .15s; }
.msg-item:hover { background: rgb(var(--border) / 0.1); }
.msg-item.ativo { background: rgb(var(--primary) / 0.1); }
.contador-msg { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: rgb(var(--primary)); color: rgb(var(--primary-fg)); font-size: 11px; font-weight: 600; flex-shrink: 0; }
.msg-painel { flex: 1; min-width: 0; }
.msg-conversa { display: flex; height: 100%; min-height: 0; }
.msg-principal { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.msg-cab { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid rgb(var(--border) / 0.1); }
.msg-rolagem { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg-lateral { display: none; width: 18rem; flex-shrink: 0; overflow-y: auto; border-left: 1px solid rgb(var(--border) / 0.1); }
.msg-imagem { max-height: 16rem; max-width: 100%; border-radius: 12px; object-fit: contain; }
.msg-doc { padding: 8px 12px; background: rgb(var(--background) / 0.4); }
.bolha.bolha-falha { background: rgb(var(--danger) / 0.1); }
.msg-voltar { display: none; }
@media (min-width: 1280px) { .msg-lateral { display: block; } }
@media (max-width: 1023px) {
  .msg-lista { width: 100%; }
  .msg-oculta-mobile { display: none; }
  .msg-voltar { display: inline-flex; }
  .msg-so-largo { display: none; }
}

/* ---------- assistente de IA flutuante ---------- */
.ia-botao { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 56px; height: 56px; border-radius: 999px; display: flex; align-items: center; justify-content: center; background: rgb(var(--primary)); color: rgb(var(--primary-fg)); box-shadow: 0 6px 20px rgb(0 0 0 / .35); transition: transform .15s; }
.ia-botao:hover { transform: scale(1.05); }
.ia-ponto { position: absolute; right: 0; top: 0; width: 14px; height: 14px; border-radius: 999px; background: rgb(var(--warning)); border: 2px solid rgb(var(--surface)); }
.ia-painel { position: fixed; right: 20px; bottom: 88px; z-index: 50; display: flex; flex-direction: column; width: min(24rem, calc(100vw - 2.5rem)); height: min(34rem, calc(100vh - 7.5rem)); overflow: hidden; border-radius: 18px; background: rgb(var(--surface)); border: 1px solid rgb(var(--border) / .15); box-shadow: 0 16px 48px rgb(0 0 0 / .45); }
.ia-painel[hidden] { display: none; }
.ia-conversa { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.ia-voce { align-self: flex-end; max-width: 85%; padding: 8px 12px; border-radius: 16px 16px 4px 16px; background: rgb(var(--primary)); color: rgb(var(--primary-fg)); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ia-fala { max-width: 92%; padding: 8px 12px; border-radius: 16px 16px 16px 4px; background: rgb(var(--surface-2)); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ia-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; border: 1px solid rgb(var(--border) / .2); font-size: 13.5px; font-weight: 500; color: rgb(var(--link)); }
.ia-cartao { padding: 12px; border-radius: 12px; border: 1px solid rgb(var(--warning) / .5); background: rgb(var(--warning) / .1); }
.ia-sugestao { padding: 4px 12px; border-radius: 999px; border: 1px solid rgb(var(--border) / .2); font-size: 12px; }
.ia-sugestao:hover { background: rgb(var(--border) / .1); }
body:has(#painel-direito:not([hidden])) .ia-botao, body:has(#painel-direito:not([hidden])) .ia-painel { right: 20px; }
@media (min-width: 1280px) { body:has(#painel-direito:not([hidden])) .ia-botao, body:has(#painel-direito:not([hidden])) .ia-painel { right: 344px; } }

/* ---------- marketing ---------- */
.barra-trilho { height: 6px; border-radius: 999px; background: rgb(var(--border) / 0.1); margin-top: 4px; }
.barra-cheia { height: 100%; border-radius: 999px; background: rgb(var(--primary)); }
.selo-rosa { background: rgb(236 72 153 / 0.15); color: rgb(244 114 182); }
.cal-semana, .cal-grade { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-semana { text-align: center; }
.cal-dia { min-height: 6.5rem; border: 1px solid rgb(var(--border) / 0.1); border-radius: 12px; padding: 6px; min-width: 0; }
.cal-dia.hoje { background: rgb(var(--primary) / 0.05); }
.cal-vazio { min-height: 6.5rem; }
.cal-post { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; height: auto; padding: 4px 6px; }
@media (max-width: 640px) { .cal-dia, .cal-vazio { min-height: 4.5rem; } }

/* ---------- início ---------- */
.grade-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grade-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grade-recentes { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grade-graficos { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
@media (max-width: 1023px) { .grade-2, .grade-recentes, .grade-graficos { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 767px) { .grade-3 { grid-template-columns: minmax(0, 1fr); } }
