/* Pronvia - sistema visual (temas claro e escuro)
   Tema: html[data-theme="light"|"dark"] força; sem atributo segue o sistema operacional. */
:root {
  --bg: #f4f7f6; --surface: #ffffff; --surface-2: #eef3f1; --line: #dbe4e1; --line-2: #c9d6d2;
  --ink: #0f1e1c; --muted: #5a6b67; --faint: #8a9a96;
  --brand: #0e7c66; --brand-ink: #ffffff; --brand-deep: #0a4f48; --brand-soft: #dff3ed;
  --coral: #e85d4f; --coral-soft: #fde9e6;
  --ok: #138a5e; --warn: #b7790c; --warn-soft: #fdf3df; --bad: #d1453b;
  --ruim: #d1453b; --atencao: #e09a1e; --normal: #a9ad7c; --boa: #2fa37f; --otima: #0e7c66;
  --shadow: 0 1px 2px rgba(15, 30, 28, .06), 0 4px 14px rgba(15, 30, 28, .05);
  --r: 12px; --r-sm: 8px;
  --display: "Manrope", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0b1413; --surface: #121f1d; --surface-2: #172825; --line: #233733; --line-2: #2e4641;
  --ink: #e7f0ee; --muted: #9bb0ab; --faint: #6f8580;
  --brand: #34c3a1; --brand-ink: #062621; --brand-deep: #0e7c66; --brand-soft: #143a33;
  --coral: #ff7b6e; --coral-soft: #3a1f1c;
  --ok: #4cd3a0; --warn: #e6b040; --warn-soft: #3a2f16; --bad: #ff7b6e;
  --ruim: #ff7b6e; --atencao: #e6b040; --normal: #b9bd8c; --boa: #4cc79c; --otima: #34c3a1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0b1413; --surface: #121f1d; --surface-2: #172825; --line: #233733; --line-2: #2e4641;
  --ink: #e7f0ee; --muted: #9bb0ab; --faint: #6f8580;
  --brand: #34c3a1; --brand-ink: #062621; --brand-deep: #0e7c66; --brand-soft: #143a33;
  --coral: #ff7b6e; --coral-soft: #3a1f1c;
  --ok: #4cd3a0; --warn: #e6b040; --warn-soft: #3a2f16; --bad: #ff7b6e;
  --ruim: #ff7b6e; --atencao: #e6b040; --normal: #b9bd8c; --boa: #4cc79c; --otima: #34c3a1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.55 var(--body); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0 0 .5rem; line-height: 1.25; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 22px; font-weight: 800; } h3 { font-size: 17px; font-weight: 700; } h4 { font-size: 14.5px; font-weight: 700; }
p { margin: .3rem 0; }
a { color: var(--brand); }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Controles */
button, .btn { font: 500 13.5px var(--body); cursor: pointer; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  border-radius: var(--r-sm); padding: .5rem .9rem; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; }
button:hover, .btn:hover { border-color: var(--brand); }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
button.danger { background: var(--coral); color: #fff; border-color: var(--coral); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-2); color: var(--ink); }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
input, select, textarea { font: inherit; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: .5rem .65rem; width: 100%;
  background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
textarea { resize: vertical; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: .25rem; font-weight: 500; }

/* Marca */
.marca { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); }
.marca svg { width: 32px; height: 32px; flex: none; }
.marca .nome { font: 800 19px/1 var(--display); letter-spacing: -.02em; }
.marca .nome b { color: var(--brand); font-weight: 800; }

/* Estrutura do app */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.lateral { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.lateral .marca { padding: 2px 8px 16px; }
.lateral .sec { font: 600 10.5px var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin: 14px 10px 4px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--muted); cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left; font: 500 13.5px var(--body); }
.nav svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav:hover { background: var(--surface-2); color: var(--ink); border: 0; }
.nav.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .breve { margin-left: auto; font-size: 10px; color: var(--faint); border: 1px solid var(--line); border-radius: 99px; padding: 0 6px; font-weight: 500; }
.nav[disabled] { opacity: .55; cursor: default; }
.lateral .rodape { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.usuario { display: flex; gap: 10px; align-items: center; padding: 6px 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font: 700 13px var(--display);
  display: grid; place-items: center; flex: none; }
.usuario .quem { min-width: 0; } .usuario .quem div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conteudo { min-width: 0; display: flex; flex-direction: column; }
.topo { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 12px 28px; display: flex; gap: 12px; align-items: center; }
.busca { flex: 1; max-width: 520px; position: relative; }
.busca input { padding-left: 34px; background: var(--surface); }
.busca svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--faint); fill: none; stroke-width: 2; }
.resultados { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; z-index: 20; }
.resultados div { padding: 9px 12px; cursor: pointer; } .resultados div:hover, .resultados div.sel { background: var(--surface-2); }
main { padding: 24px 28px 48px; max-width: 1320px; width: 100%; }
.faixa { padding: 10px 28px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.faixa.aviso { background: var(--warn-soft); color: var(--warn); }
.faixa.erro { background: var(--coral-soft); color: var(--bad); }
.menu-movel { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .lateral.aberta { transform: none; }
  .menu-movel { display: inline-flex; }
  .topo { flex-wrap: wrap; }
  .busca { order: 3; flex-basis: 100%; max-width: none; }
  main, .topo, .faixa { padding-left: 16px; padding-right: 16px; }
}

/* Cabeçalho de página */
.cab { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.cab .titulo { flex: 1; min-width: 220px; }
.cab .titulo p { color: var(--muted); }

/* Cartões e grades */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; margin-bottom: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1150px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .faint { color: var(--faint); }
.note { padding: .65rem .85rem; border-radius: var(--r-sm); background: var(--surface-2); margin-bottom: .5rem; }
.prio-alta { border-left: 3px solid var(--bad); } .prio-media { border-left: 3px solid var(--atencao); } .prio-baixa { border-left: 3px solid var(--boa); }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.badge { font: 600 11px var(--body); padding: .2rem .6rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--coral-soft); color: var(--bad); }
.badge.neutro { background: var(--surface-2); color: var(--muted); }

/* Pacientes */
.lista-pac { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pac { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; gap: 12px; align-items: center;
  cursor: pointer; text-align: left; width: 100%; }
.pac:hover { border-color: var(--brand); }
.pac .info { min-width: 0; flex: 1; } .pac .info b { display: block; font: 700 14px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nota-anel { --v: 0; --cor: var(--brand); width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--cor) calc(var(--v) * 1%), var(--surface-2) 0); }
.nota-anel span { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font: 800 13.5px var(--display); }
.nota-anel.g { width: 64px; height: 64px; } .nota-anel.g span { width: 52px; height: 52px; font-size: 18px; }
.paciente-cab { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; }
.paciente-cab .info { flex: 1; min-width: 200px; }
.paciente-cab h2 { margin: 0 0 2px; }
.voltar { color: var(--muted); font-size: 13px; cursor: pointer; border: 0; background: none; padding: 0; margin-bottom: 10px; }
.voltar:hover { color: var(--brand); border: 0; }

/* Abas segmentadas */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 0 0 16px; }
.tabs button { border: 0; background: none; padding: .45rem .95rem; border-radius: 7px; color: var(--muted); font-weight: 500; }
.tabs button:hover { color: var(--ink); border: 0; }
.tabs button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }

/* Tabelas */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.st-ok { color: var(--ok); font-weight: 600; } .st-atencao { color: var(--warn); font-weight: 600; } .st-alterado { color: var(--bad); font-weight: 600; }

/* Exames */
.exame-card { cursor: pointer; margin-bottom: 0; }
.exame-card:hover { border-color: var(--line-2); }
.exame-card .valor { font: 800 22px var(--display); }
.exame-card.sel { outline: 2px solid var(--brand); }

/* Pílulas de classificação */
.pill { font: 700 12px var(--body); padding: .15rem .55rem; border-radius: 99px; color: #fff; }
.c-Ruim { background: var(--ruim); } .c-Atenção { background: var(--atencao); } .c-Normal { background: var(--normal); }
.c-Boa { background: var(--boa); } .c-Ótima { background: var(--otima); }

/* Gravação */
.rec { display: inline-flex; align-items: center; gap: .5rem; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--coral); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } .lateral { transition: none; } }

/* Mapa da Saúde */
.gauge { position: relative; height: 12px; border-radius: 99px; margin: 1.4rem 0 .4rem;
  background: linear-gradient(90deg, var(--ruim), var(--atencao) 45%, var(--normal) 65%, var(--boa) 82%, var(--otima)); }
.gauge .marker { position: absolute; top: 50%; transform: translate(-50%, -50%); background: var(--surface); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 99px; font: 800 14px var(--display); padding: .05rem .5rem; }
.nota-grande { font: 800 44px/1 var(--display); letter-spacing: -.02em; }
.md h3 { font-size: 15px; margin: .9rem 0 .3rem; color: var(--brand); }
.md p { margin: .3rem 0; } .md ul { margin: .3rem 0; padding-left: 1.2rem; }
.preceptor .nota { font: 800 26px var(--display); color: var(--brand); }
.preceptor .trecho { font-style: italic; color: var(--muted); border-left: 3px solid var(--line-2); padding-left: .5rem; margin-top: .4rem; }
.bar { height: 10px; border-radius: 99px; display: flex; overflow: hidden; margin: .5rem 0; }
.bar div { height: 100%; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* Medidor de uso */
.medidor { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: .4rem 0; }
.medidor i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.medidor.alto i { background: var(--warn); } .medidor.cheio i { background: var(--bad); }

/* Avisos, janelas */
.toast { position: fixed; bottom: max(1.2rem, env(safe-area-inset-bottom, 0px)); right: 1.2rem; background: var(--ink); color: var(--bg);
  padding: .75rem 1rem; border-radius: var(--r-sm); z-index: 60; max-width: 440px; box-shadow: var(--shadow); }
.toast.erro { background: var(--bad); color: #fff; }
.modal-bg { position: fixed; inset: 0; background: rgba(6, 15, 14, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; width: min(640px, 100%); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.segredo { font: 600 16px ui-monospace, Consolas, monospace; background: var(--surface-2); padding: .6rem .8rem; border-radius: var(--r-sm); user-select: all; word-break: break-all; }

/* Escolha de tema */
.temas { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 3px; background: var(--surface); }
.temas button { border: 0; background: none; border-radius: 99px; padding: 4px 11px; font-size: 12.5px; color: var(--muted); }
.temas button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
