:root {
  color-scheme: light;
  --verde-escuro: #1b5215;
  --verde: #2f7d24;
  --verde-claro: #43ab37;
  --verde-fundo: #eef6ec;
  --texto: #1d241c;
  --texto-suave: #5b6658;
  --borda: #d9e2d6;
  --fundo: #f6f8f5;
  --branco: #fff;
  --erro: #b3261e;
  --alerta: #8a5a00;
  --raio: 14px;
  font-size: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 400 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

.topo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--branco); border-bottom: 1px solid var(--borda);
}
.topo-logo { height: 54px; width: auto; }
@media (min-width: 720px) { .topo-logo { height: 76px; } }
#menu { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
#menu a, #menu button {
  font: inherit; font-size: .9rem; color: var(--verde-escuro); background: none; border: 0;
  padding: 6px 10px; border-radius: 8px; cursor: pointer; text-decoration: none;
}
#menu a[aria-current="page"] { background: var(--verde-fundo); font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: 20px 16px calc(40px + env(safe-area-inset-bottom, 0px)); }
main.largo { max-width: 1040px; }
.carregando { color: var(--texto-suave); text-align: center; padding: 40px 0; }

h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 8px; color: var(--verde-escuro); }
h2 { font-size: 1.15rem; margin: 28px 0 10px; color: var(--verde-escuro); }
h3 { font-size: 1rem; margin: 18px 0 6px; }
p { margin: 0 0 12px; }
.suave { color: var(--texto-suave); font-size: .92rem; }
.pequeno { font-size: .85rem; }

.cartao {
  background: var(--branco); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 20px; margin-bottom: 16px;
}
.cartao.destaque { border-color: var(--verde-claro); background: var(--verde-fundo); }

.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px; border-radius: 12px; border: 0; cursor: pointer;
  font: 600 1rem/1.2 inherit; text-decoration: none;
  background: var(--verde-escuro); color: #fff;
}
.botao:hover { background: var(--verde); }
.botao:disabled { background: #d4d9d2; color: #8b938a; cursor: not-allowed; }
.botao.secundario { background: var(--branco); color: var(--verde-escuro); border: 1.5px solid var(--borda); }
.botao.secundario:hover { border-color: var(--verde-escuro); }
.botao.whats { background: #128c4a; }
.botao.pequeno { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.botao.perigo { background: var(--branco); color: var(--erro); border: 1.5px solid #e8c4c1; }
.bloco { display: flex; width: 100%; }
.acoes { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.acoes .botao { flex: 1 1 140px; }
.link { background: none; border: 0; padding: 0; color: var(--verde); text-decoration: underline; cursor: pointer; font: inherit; }

label.campo, .campo { display: block; margin: 14px 0; }
.campo > span { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="date"], input[inputmode], textarea, select {
  width: 100%; font: inherit; color: inherit; background: var(--branco);
  border: 1.5px solid var(--borda); border-radius: 10px; padding: 12px 14px; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(67, 171, 55, .45); outline-offset: 1px; border-color: var(--verde);
}
.input-codigo { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

.opcoes { display: grid; gap: 8px; margin: 10px 0; }
.opcao {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; cursor: pointer;
  background: var(--branco); border: 1.5px solid var(--borda); border-radius: 12px;
}
.opcao input { margin: 3px 0 0; width: 20px; height: 20px; accent-color: var(--verde-escuro); flex: none; }
.opcao:has(input:checked) { border-color: var(--verde-escuro); background: var(--verde-fundo); }
.opcoes.linha { grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); }
.opcoes.linha .opcao { justify-content: center; padding: 12px 6px; }

.pergunta { font-size: 1.2rem; font-weight: 400; line-height: 1.35; margin: 0 0 10px; color: var(--texto); }
.pergunta b { color: var(--verde-escuro); }
.ajuda { color: var(--texto-suave); font-size: .95rem; background: var(--fundo); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.complemento { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--borda); }
.erro { color: var(--erro); font-size: .92rem; margin-top: 8px; }
.aviso { color: var(--alerta); background: #fff6e0; border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
.figura { display: block; margin: 12px auto; border-radius: 10px; border: 1px solid var(--borda); max-height: 460px; }

.progresso { height: 8px; background: var(--borda); border-radius: 99px; overflow: hidden; margin: 0 0 18px; }
.progresso > div { height: 100%; background: var(--verde-claro); transition: width .25s ease; }

.marcador { padding: 16px 0; border-top: 1px solid var(--borda); }
.marcador:first-of-type { border-top: 0; }
.marcador-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.marcador-nome { font-weight: 700; color: var(--verde-escuro); }
.marcador-valor { font: 700 1.5rem/1 inherit; color: var(--verde-escuro); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.marcador input[type="range"] { width: 100%; height: 36px; accent-color: var(--verde-escuro); margin: 6px 0 2px; }
.marcador-rotulo { font-size: .95rem; min-height: 1.5em; }
.marcador-ultimo { font-size: .82rem; color: var(--texto-suave); margin-top: 4px; }

.modal { position: fixed; inset: 0; background: rgba(10, 20, 10, .55); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-caixa { background: var(--branco); border-radius: var(--raio); padding: 18px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; }
.modal-caixa .botao { width: 100%; margin-top: 12px; }

/* Histórico */
.grafico { width: 100%; height: auto; display: block; }
.grafico text { font: 12px system-ui, sans-serif; fill: var(--texto-suave); }
.grafico { touch-action: pan-y; cursor: crosshair; }
.grafico text.tt-valor { font: 700 15px system-ui, sans-serif; fill: #fff; }
.grafico text.tt-data { font: 11px system-ui, sans-serif; fill: #cfe3ca; }
.lista { display: grid; gap: 10px; }
details.item { background: var(--branco); border: 1px solid var(--borda); border-radius: 12px; }
details.item > summary {
  list-style: none; cursor: pointer; padding: 14px 16px; display: flex; gap: 12px;
  justify-content: space-between; align-items: center; flex-wrap: wrap;
}
details.item > summary::-webkit-details-marker { display: none; }
details.item[open] > summary { border-bottom: 1px solid var(--borda); }
.item-corpo { padding: 8px 18px 20px; }
.resposta { padding: 8px 0; border-bottom: 1px solid #eef1ed; }
.resposta:last-child { border-bottom: 0; }
.resposta dt { font-size: .8rem; color: var(--texto-suave); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.resposta dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.etiqueta { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--verde-fundo); color: var(--verde-escuro); white-space: nowrap; }
.etiqueta.alerta { background: #fff1d6; color: var(--alerta); }
.etiqueta.erro { background: #fde8e6; color: var(--erro); }
.etiqueta.cinza { background: #eceeeb; color: var(--texto-suave); }
/* Detalhe do check-in */
.detalhe { display: grid; gap: 4px; }
.resumo-semana { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 10px 0 18px; border-bottom: 1px solid var(--borda); }
.nota-circulo {
  width: 86px; height: 86px; border-radius: 50%; flex: none; display: grid; place-content: center; text-align: center;
  background: #6b7568; color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
}
.nota-circulo small { font-size: .72rem; font-weight: 700; letter-spacing: .06em; opacity: .9; }
.nota-circulo b { font-size: 2rem; line-height: 1; }
.nota-circulo.ok { background: var(--verde); }
.nota-circulo.atencao { background: #c98a00; }
.nota-circulo.alerta { background: var(--erro); }
.vitoria { flex: 1 1 240px; min-width: 0; }
.vitoria small, .medidas small, .mbf-nome, .bloco-topo h4 {
  font-size: .76rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--texto-suave);
}
.vitoria p { margin: 4px 0 6px; background: #fbf3df; border-radius: 10px; padding: 10px 14px; font-size: 1.02rem; overflow-wrap: anywhere; }

.bloco-resp { padding: 18px 0; border-bottom: 1px solid var(--borda); }
.bloco-resp:last-child { border-bottom: 0; }
.bloco-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.bloco-topo h4 { margin: 0; }
.resp-texto { margin: 8px 0 0; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.chip {
  display: inline-block; font-size: .88rem; font-weight: 600; padding: 4px 12px; border-radius: 99px;
  background: var(--verde-fundo); color: var(--verde-escuro); border: 1px solid #cfe3ca;
}
.pares { margin: 0; display: grid; gap: 8px; }
.pares > div { display: grid; grid-template-columns: minmax(130px, 180px) 1fr; gap: 10px; }
.pares dt { font-size: .85rem; color: var(--texto-suave); }
.pares dd { margin: 0; line-height: 1.5; }
@media (max-width: 520px) { .pares > div { grid-template-columns: 1fr; gap: 2px; } }

.medidas { display: flex; gap: 10px; flex-wrap: wrap; }
.medidas > div { background: var(--fundo); border-radius: 10px; padding: 10px 14px; min-width: 104px; }
.medidas b { display: block; font-size: 1.15rem; color: var(--verde-escuro); margin-top: 2px; }

.grade-mbf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .grade-mbf { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grade-mbf { grid-template-columns: repeat(4, 1fr); } }
.mbf {
  display: grid; gap: 2px; align-content: start; text-align: left; font: inherit; color: inherit; padding: 10px 12px; border-radius: 12px;
  border: 1.5px solid var(--borda); background: var(--branco); border-left-width: 6px;
}
button.mbf { cursor: pointer; }
button.mbf:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
.mbf-num { font-size: 1.6rem; line-height: 1.1; }
.mbf-desc { font-size: .8rem; color: var(--texto-suave); line-height: 1.35; }
.mbf.ok { border-left-color: var(--verde-claro); }
.mbf.ok .mbf-num, .num.ok { color: var(--verde); }
.mbf.atencao { border-left-color: #e0a100; background: #fffaf0; }
.mbf.atencao .mbf-num, .num.atencao { color: #a06c00; }
.mbf.alerta { border-left-color: var(--erro); background: #fff5f4; }
.mbf.alerta .mbf-num, .num.alerta { color: var(--erro); }

.hist { margin-top: 12px; background: var(--fundo); border-radius: 12px; padding: 12px 14px; }
.hist h5 { margin: 0 0 8px; font-size: .95rem; color: var(--verde-escuro); }
.hist-grafico { margin-bottom: 12px; }
.hist-grafico small { font-weight: 600; color: var(--texto-suave); }
.hist-lista { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.hist-lista li { display: grid; grid-template-columns: 74px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--borda); }
.hist-lista li:last-child { border-bottom: 0; }
.hist-lista li.atual { background: #e6f2e2; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.hist-data { font-size: .82rem; color: var(--texto-suave); font-variant-numeric: tabular-nums; padding-top: 2px; }
.hist-lista .resp-texto:first-child { margin-top: 0; }
.hist-lista .chip { font-size: .8rem; }

/* Mensagem para o WhatsApp */
.mensagem-preview { white-space: pre-wrap; background: var(--branco); border: 1px solid var(--borda); border-radius: 10px; padding: 12px 14px; font-size: .9rem; max-height: 260px; overflow: auto; margin: 8px 0; }

/* Admin */
.tabela-wrap { overflow-x: auto; background: var(--branco); border: 1px solid var(--borda); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef1ed; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texto-suave); background: #fafbf9; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.clicavel { cursor: pointer; }
tbody tr.clicavel:hover { background: var(--verde-fundo); }
tr.inativo td { color: var(--texto-suave); }
.barra { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 14px; }
.barra input[type="search"] { flex: 1 1 220px; width: auto; min-height: 44px; font: inherit; border: 1.5px solid var(--borda); border-radius: 10px; padding: 8px 12px; }
.grade-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--verde-escuro); }
.ok-msg { color: var(--verde); font-size: .9rem; }
.admin-feedback { background: #fafbf9; border: 1px dashed var(--borda); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }

@media (min-width: 720px) {
  h1 { font-size: 1.7rem; }
  .cartao { padding: 26px; }
}

.passo { display: flex; align-items: center; gap: 8px; margin: 20px 0 4px; font-size: .95rem; color: var(--verde-escuro); }
.passo > span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--verde-escuro); color: #fff; font-size: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.barra-hist { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding: 4px 0 8px; }
.tabela-mbf { margin-bottom: 12px; }
.tabela-mbf th { font-size: .7rem; padding: 8px 6px; text-align: center; white-space: normal; min-width: 54px; line-height: 1.2; }
.tabela-mbf th:first-child, .tabela-mbf td:first-child { text-align: left; position: sticky; left: 0; background: #fafbf9; white-space: nowrap; }
.tabela-mbf td { text-align: center; font-weight: 700; padding: 7px 6px; font-variant-numeric: tabular-nums; }
.tabela-mbf td.num.atencao { background: #fff6e0; }
.tabela-mbf td.num.alerta { background: #fdecea; }
.tabela-mbf tr.atual td { box-shadow: inset 0 2px 0 var(--verde-claro), inset 0 -2px 0 var(--verde-claro); }
.tabela-mbf { max-height: 460px; overflow: auto; }
.tabela-mbf thead th { position: sticky; top: 0; z-index: 2; }
.tabela-mbf thead th:first-child { z-index: 3; }

/* Índice lateral da ficha do paciente (só desktop) */
.indice { display: none; }
@media (min-width: 1100px) {
  main.largo:has(.com-indice) { max-width: 1320px; }
  .com-indice { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 28px; align-items: start; }
  .indice {
    display: grid; gap: 2px; position: sticky; top: calc(16px + env(safe-area-inset-top, 0px));
    max-height: calc(100vh - 32px); overflow: auto; padding: 14px 10px; background: var(--branco);
    border: 1px solid var(--borda); border-radius: var(--raio); font-size: .9rem;
  }
  .indice a { color: var(--texto); text-decoration: none; padding: 6px 10px; border-radius: 8px; display: block; }
  .indice a:hover { background: var(--verde-fundo); color: var(--verde-escuro); }
  .indice a.ativo { background: var(--verde-escuro); color: #fff; font-weight: 600; }
  .indice-titulo { font-weight: 700; color: var(--verde-escuro); margin: 0 0 6px; padding: 0 10px; }
  .indice-checkin { display: grid; gap: 1px; margin: 6px 0; padding: 8px 0 8px 8px; border-left: 2px solid var(--verde-claro); }
  .indice-checkin > b { font-size: .8rem; color: var(--texto-suave); padding: 0 10px 4px; }
  .indice-checkin a { font-size: .85rem; padding: 4px 10px; }
}
.detalhe section, .resumo-semana, .passo, .acordeao-resposta, #secao-dados, #secao-checkins, #secao-evolucao { scroll-margin-top: 64px; }

.voltar-fixo { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--fundo); padding: 10px 0; margin: -10px 0 4px; }
.contatos { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--texto-suave); }
.contatos > span { display: inline-flex; align-items: center; gap: 8px; }
.copiar { font: 600 .78rem/1 inherit; color: var(--verde-escuro); background: var(--verde-fundo); border: 1px solid #cfe3ca; border-radius: 99px; padding: 6px 10px; cursor: pointer; min-height: 30px; }
.copiar:hover { border-color: var(--verde); }
.acordeao-resposta { margin-top: 18px; border: 1.5px solid var(--borda); border-radius: 12px; background: #fafbf9; }
.acordeao-resposta > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.acordeao-resposta > summary::-webkit-details-marker { display: none; }
.acordeao-resposta > summary::after { content: '▾'; color: var(--texto-suave); margin-left: auto; }
.acordeao-resposta[open] > summary::after { content: '▴'; }
.acordeao-resposta[open] > summary { border-bottom: 1px dashed var(--borda); }
.acordeao-resposta > .admin-feedback { border: 0; margin: 0; background: transparent; }

.atalhos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 6px; }
.presets .atalhos { margin-top: 0; }
.copiar.ativo { background: var(--verde-escuro); color: #fff; border-color: var(--verde-escuro); }

.grafico-wrap { width: 100%; min-height: 220px; }
.grafico-wrap .grafico { display: block; width: 100%; height: 220px; }

.ordenar { font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
.ordenar:hover, .ordenar.ativo { color: var(--verde-escuro); }
.ordenar span { opacity: .7; }
