/* ============================================================================
   Painel do check-in — consultório Dr. Matheus Cunha
   Mundo: prontuário de papel, verde do consultório, grafite de caneta.
   Densidade: base 4px. Profundidade: uma estratégia só — borda tênue + sombra
   de 1px; nada de sombra dramática. Uma cor de destaque: o verde.
   ========================================================================= */

:root {
  /* verde do consultório (#184b45 é a cor de marca do portal do paciente) */
  --verde-900: #0d2b27;
  --verde-800: #123a35;
  --verde-700: #184b45;
  --verde-600: #1f6058;
  --verde-500: #2a7a70;
  --verde-100: #d8e9e5;
  --verde-50:  #eff6f4;

  /* papel e tinta: neutros com um fio de verde, para não brigar com a marca */
  --papel:     #f6f7f6;   /* mesa */
  --carta:     #ffffff;   /* folha */
  --carta-2:   #fafbfa;   /* folha recuada (cabeçalho de tabela, campo) */
  --tinta:     #15201e;
  --tinta-2:   #4a5754;
  --tinta-3:   #79847f;
  --tinta-4:   #a6afab;

  --linha:      rgba(24, 75, 69, .12);
  --linha-suave:rgba(24, 75, 69, .07);
  --linha-forte:rgba(24, 75, 69, .22);

  /* semânticas: cores de aviso de consultório, não de dashboard */
  --alerta:    #a3341f;   /* terracota */
  --alerta-bg: #fbeeeb;
  --aviso:     #8a5d0c;   /* âmbar de post-it */
  --aviso-bg:  #fcf5e6;
  --ok:        #2c7a58;
  --ok-bg:     #e8f4ee;

  --r-xs: 5px;
  --r-sm: 8px;
  --r-md: 12px;   /* cartão = interno 8 + padding 4 */
  --r-lg: 16px;

  --sombra-1: 0 0 0 1px var(--linha), 0 1px 2px -1px rgba(13,43,39,.08);
  --sombra-2: 0 0 0 1px var(--linha), 0 2px 4px -1px rgba(13,43,39,.07), 0 6px 16px -6px rgba(13,43,39,.10);

  --curva: cubic-bezier(.23, 1, .32, 1);

  --lateral: 252px;
  --fonte: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--fonte);
  font-size: 15px;
  line-height: 1.5;
  color: var(--tinta);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
  text-wrap: pretty;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p  { margin: 0; }
a  { color: var(--verde-600); text-decoration-color: var(--verde-100); text-underline-offset: 2px; }
a:hover { color: var(--verde-700); text-decoration-color: currentColor; }

/* números não podem dançar: data, contagem, dias */
time, .num, td, th { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- estrutura */
.casca { min-height: 100dvh; }

.lateral {
  display: none;
  position: fixed; inset: 0 auto 0 0; width: var(--lateral);
  padding: 20px 12px 12px;
  background: var(--papel);                /* mesma cor da mesa: sem "dois mundos" */
  border-right: 1px solid var(--linha-suave);
  flex-direction: column; gap: 4px;
}
.lateral .marca svg { width: 19px; height: 19px; flex: none; }
.lateral .marca {
  display: flex; align-items: center; gap: 9px; white-space: nowrap;
  padding: 0 10px 18px; color: var(--verde-700);
  font-weight: 650; font-size: 15px; letter-spacing: -.01em; text-decoration: none;
}
.lateral .marca span:last-child { color: var(--tinta); }
.lateral .secao {
  padding: 16px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--tinta-4);
}
.lateral .rodape { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--linha-suave); }

.item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--tinta-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background .12s var(--curva), color .12s var(--curva);
}
.item:hover { background: var(--verde-50); color: var(--tinta); }
.item[aria-current="page"] { background: var(--verde-100); color: var(--verde-800); font-weight: 600; }
.item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.item[aria-current="page"] svg { opacity: 1; }
.item .conta {
  margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px;
  background: var(--verde-700); color: #fff; font-size: 11px; font-weight: 600; text-align: center;
}

.conteudo { padding: 14px 14px 88px; }

.topo-celular {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 2px 2px 14px;
}
.topo-celular .marca { display: flex; align-items: center; gap: 8px; color: var(--verde-700);
  font-weight: 650; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.topo-celular .marca svg { width: 19px; height: 19px; flex: none; }
.topo-celular .marca span:last-child { color: var(--tinta); }

/* barra de baixo: alcance do polegar, que é como ele usa isto */
.barra-baixo {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--linha);
}
.barra-baixo a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px; border-radius: var(--r-sm); text-decoration: none;
  color: var(--tinta-3); font-size: 11px; font-weight: 500;
}
.barra-baixo a[aria-current="page"] { color: var(--verde-700); font-weight: 600; }
.barra-baixo svg { width: 21px; height: 21px; }

@media (min-width: 900px) {
  .lateral { display: flex; }
  .conteudo { margin-left: var(--lateral); padding: 28px 32px 48px; max-width: 1180px; }
  .barra-baixo, .topo-celular { display: none; }
  h1 { font-size: 30px; }
}

/* ------------------------------------------------------------------ cabeçalho */
.cabecalho { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.cabecalho .titulo { min-width: 0; flex: 1; }
.cabecalho .legenda { margin-top: 3px; color: var(--tinta-3); font-size: 13px; }
.cabecalho .acao { flex: none; }

/* -------------------------------------------------------------------- cartão */
.cartao {
  background: var(--carta); border-radius: var(--r-md); box-shadow: var(--sombra-1);
  padding: 16px;
}
.cartao + .cartao { margin-top: 12px; }
.cartao > header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: -16px -16px 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--linha-suave);
}
.cartao > header h3 { font-size: 15px; }
.cartao.focal { box-shadow: var(--sombra-2); border-top: 3px solid var(--verde-700); }

.grade { display: grid; gap: 12px; }
@media (min-width: 900px) { .grade-2 { grid-template-columns: 1fr 1fr; } }

/* ------------------------------------------------------------------ métricas */
.resumo {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px;
  background: var(--linha-suave); border-radius: var(--r-md); overflow: hidden;
  box-shadow: var(--sombra-1); margin-bottom: 12px;
}
.resumo > * { background: var(--carta); padding: 12px 14px; text-decoration: none; color: inherit; }
.resumo a:hover { background: var(--verde-50); }
.resumo .rotulo { font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--tinta-4); }
.resumo .valor { margin-top: 2px; font-size: 24px; font-weight: 650; letter-spacing: -.02em;
  line-height: 1.1; font-variant-numeric: tabular-nums; }
.resumo .valor.atencao { color: var(--alerta); }
.resumo .valor.zero { color: var(--tinta-4); }

/* --------------------------------------------------------- régua do ciclo (assinatura) */
.ciclo { margin-top: 10px; }
.ciclo .legenda {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--tinta-4); margin-bottom: 6px;
}
.ciclo .trilho {
  position: relative; height: 6px; border-radius: 999px;
  background: var(--linha); overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--linha-suave);
}
.ciclo .marca {
  position: absolute; inset: 0 auto 0 0; min-width: 6px; border-radius: 999px;
  background: var(--verde-600);
  transition: width .3s var(--curva);
}
/* parado nao tem progresso nenhum: o trilho vazio ja diz isso */
.ciclo[data-tom="parado"] .marca { width: 0 !important; min-width: 0; }
.ciclo[data-tom="aguardando"] .marca { background: var(--aviso); }
.ciclo[data-tom="vencido"]    .marca { background: var(--verde-700); }
.ciclo[data-tom="erro"]       .marca { background: var(--alerta); }
.ciclo[data-tom="parado"]     .marca { background: var(--tinta-4); }

/* ---------------------------------------------------------------- situação */
.situacao { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.situacao::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex: none; }
.situacao.s-vencido, .situacao.s-agendado { color: var(--verde-600); }
.situacao.s-aguardando_resposta { color: var(--aviso); }
.situacao.s-erro, .situacao.s-prazo_vencido, .situacao.s-formulario_inativo { color: var(--alerta); }
.situacao.s-pausado, .situacao.s-sem_data { color: var(--tinta-3); }

/* ------------------------------------------------------------------- abas */
.abas {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  padding: 3px; margin-bottom: 14px;
  background: var(--carta-2); border-radius: var(--r-sm); box-shadow: inset 0 0 0 1px var(--linha-suave);
}
.abas::-webkit-scrollbar { display: none; }
.abas a {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 7px 11px; border-radius: var(--r-xs);
  color: var(--tinta-2); font-size: 13px; font-weight: 500; text-decoration: none;
  transition: background .12s var(--curva);
}
.abas a:hover { background: rgba(24,75,69,.05); }
.abas a[aria-current="true"] { background: var(--carta); color: var(--tinta); font-weight: 600;
  box-shadow: var(--sombra-1); }
.abas .conta {
  padding: 1px 6px; border-radius: 999px; background: var(--linha-suave);
  font-size: 11px; font-weight: 600; color: var(--tinta-2); font-variant-numeric: tabular-nums;
}
.abas a[aria-current="true"] .conta { background: var(--verde-100); color: var(--verde-800); }

/* ------------------------------------------------------------------ botões */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 9px 15px; border: 0; border-radius: var(--r-sm);
  background: var(--verde-700); color: #fff;
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .14s var(--curva), transform .1s var(--curva), box-shadow .14s var(--curva);
}
.botao:hover { background: var(--verde-800); color: #fff; }
.botao:active { transform: scale(.975); }
.botao svg { width: 17px; height: 17px; }
.botao.contorno { background: var(--carta); color: var(--tinta); box-shadow: inset 0 0 0 1px var(--linha-forte); }
.botao.contorno:hover { background: var(--verde-50); color: var(--verde-800); }
.botao.discreto { background: transparent; color: var(--tinta-2); }
.botao.discreto:hover { background: var(--linha-suave); color: var(--tinta); }
.botao.perigo { background: var(--alerta); }
.botao.perigo:hover { background: #8b2b1a; }
.botao[disabled] { background: var(--linha-suave); color: var(--tinta-4); cursor: not-allowed; }
.botao[disabled]:active { transform: none; }
.botao.largo { width: 100%; }

.acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.acoes > form { display: contents; }
.acoes .botao { flex: 1 1 9rem; }

/* ----------------------------------------------------------------- campos */
label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--tinta-2); }
label > small { display: block; margin-top: 5px; font-size: 12px; font-weight: 400; color: var(--tinta-3); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; min-height: 42px; padding: 9px 11px;
  border: 0; border-radius: var(--r-sm);
  background: var(--carta-2); box-shadow: inset 0 0 0 1px var(--linha-forte);
  font: inherit; font-size: 15px; color: var(--tinta);
  transition: box-shadow .14s var(--curva), background .14s var(--curva);
}
input[type="checkbox"] { width: auto; min-height: 0; margin: 0 8px 0 0; display: inline-block;
  accent-color: var(--verde-700); transform: scale(1.15); }
select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2379847f' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
input:focus, select:focus, textarea:focus {
  outline: 0; background: var(--carta);
  box-shadow: inset 0 0 0 1px var(--verde-600), 0 0 0 3px var(--verde-100);
}
input[readonly] { color: var(--tinta-2); }

.busca { position: relative; margin-bottom: 12px; }
.busca input { padding-left: 38px; }
.busca svg { position: absolute; left: 12px; top: 13px; width: 17px; height: 17px; color: var(--tinta-4); }

/* ----------------------------------------------------------------- tabela */
.tabela { overflow-x: auto; margin: 0 -16px; }
.tabela table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th {
  padding: 9px 14px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--tinta-4); background: var(--carta-2);
  border-block: 1px solid var(--linha-suave);
}
.tabela th a { color: inherit; text-decoration: none; }
.tabela th a:hover { color: var(--tinta-2); }
.tabela td { padding: 12px 14px; border-bottom: 1px solid var(--linha-suave); vertical-align: middle; }
.tabela tbody tr:last-child td { border-bottom: 0; }
.tabela tbody tr:hover { background: var(--verde-50); }
.tabela .nome { font-weight: 600; color: var(--tinta); text-decoration: none; }
.tabela .nome:hover { color: var(--verde-700); }

/* --------------------------------------------------------------- listagens */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { border-bottom: 1px solid var(--linha-suave); }
.lista > li:last-child { border-bottom: 0; }
.lista .linha {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; color: inherit; text-decoration: none;
}
.lista .linha:hover .nome { color: var(--verde-700); }
.lista .nome { font-weight: 600; font-size: 15px; }
.lista .nome { display: block; }
.lista .seta { margin-left: auto; color: var(--tinta-4); flex: none; }
.lista .seta svg { width: 18px; height: 18px; display: block; }

.paciente { padding: 14px 0; border-bottom: 1px solid var(--linha-suave); }
.paciente:last-of-type { border-bottom: 0; padding-bottom: 4px; }
.paciente .nome { display: block; font-size: 16px; font-weight: 650; color: var(--tinta);
  text-decoration: none; letter-spacing: -.011em; }
.paciente .nome:hover { color: var(--verde-700); }

.meta { color: var(--tinta-3); font-size: 13px; }
.meta b { font-weight: 600; color: var(--tinta-2); }
.discreto { color: var(--tinta-3); font-size: 13px; }
.vazio { padding: 22px 4px; color: var(--tinta-3); font-size: 14px; text-align: center; }

/* ------------------------------------------------------------------ avisos */
.aviso {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 13px; border-radius: var(--r-sm); font-size: 14px; margin-bottom: 14px;
}
.aviso.bom  { background: var(--ok-bg);    color: #1f5a41; box-shadow: inset 0 0 0 1px rgba(44,122,88,.16); }
.aviso.ruim { background: var(--alerta-bg);color: #83291a; box-shadow: inset 0 0 0 1px rgba(163,52,31,.16); }
.aviso.nota { background: var(--aviso-bg); color: #6f4a09; box-shadow: inset 0 0 0 1px rgba(138,93,12,.16); }

/* ------------------------------------------------------------------ modal */
.folha { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(13,43,39,.34); padding: 0; animation: fade .16s var(--curva); }
.folha > .caixa {
  width: 100%; max-width: 470px; max-height: 88dvh; overflow-y: auto;
  background: var(--carta); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px -12px rgba(13,43,39,.3);
  animation: sobe .22s var(--curva);
}
.folha h3 { margin-bottom: 10px; font-size: 18px; }
.folha .acoes { margin-top: 18px; }
@media (min-width: 640px) {
  .folha { align-items: center; padding: 24px; }
  .folha > .caixa { border-radius: var(--r-lg); animation: cresce .18s var(--curva); }
}
@keyframes fade  { from { opacity: 0 } }
@keyframes sobe  { from { transform: translateY(14px); opacity: 0 } }
@keyframes cresce{ from { transform: scale(.97);      opacity: 0 } }

/* ---------------------------------------------------------------- entrada */
.entrada { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: 24px; }
.entrada .cartao { width: 100%; max-width: 360px; padding: 26px 22px; box-shadow: var(--sombra-2); }
.entrada .marca { display: flex; align-items: center; gap: 9px; margin-bottom: 20px;
  color: var(--verde-700); font-weight: 650; letter-spacing: -.01em; }
.entrada .marca span:last-child { color: var(--tinta); }

/* --------------------------------------------------------------- detalhes */
details { border-bottom: 1px solid var(--linha-suave); }
details:last-of-type { border-bottom: 0; }
details > summary {
  padding: 11px 0; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--tinta-2);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; color: var(--tinta-4); font-size: 17px; line-height: 1;
  transition: transform .16s var(--curva); }
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { color: var(--tinta); }
details > :not(summary) { padding: 0 0 12px 16px; font-size: 14px; color: var(--tinta-2); }
pre { margin: 0; padding: 10px; border-radius: var(--r-sm); background: var(--carta-2);
  font-size: 12px; overflow-x: auto; color: var(--tinta-2); }

.so-celular { display: block; }
.so-mesa { display: none; }
@media (min-width: 900px) { .so-celular { display: none; } .so-mesa { display: block; } }

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

/* ============================================================================
   Utilitários. Existem porque a CSP (style-src 'self') proíbe style= inline —
   e isso é bom: força tudo a ter nome.
   ========================================================================= */
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 14px; }
.bloco   { display: block; }
.crescer { min-width: 0; flex: 1; }
.direita { text-align: right; }
.apagado { opacity: .55; }
.risco   { text-decoration: line-through; opacity: .6; }
.estreito{ max-width: 420px; }
.miudo   { font-size: 12px; white-space: nowrap; }
.medio   { font-size: 14px; }
.cartao.rente { padding-block: 2px; }
.cartao.rente-topo { padding-block: 0; }
.botao.mini { min-height: 32px; padding: 5px 11px; font-size: 13px; }
.empurra { margin-left: auto; }
.entre { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.item-linha { padding: 12px 0; }
.sem-borda { border: 0; }
.marcavel { margin: 0; font-weight: 400; cursor: pointer; }
/* botão que mora dentro do menu lateral e precisa parecer um item */
.item.como-item { width: 100%; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }

/* A régua não pode usar width inline (CSP). Passos de 5% dão resolução de
   meio dia num ciclo de 15 — mais que suficiente para ler de relance. */
.ciclo .marca[data-pct="0"]   { width: 0; min-width: 0; }
.ciclo .marca[data-pct="5"]   { width: 5%; }
.ciclo .marca[data-pct="10"]  { width: 10%; }
.ciclo .marca[data-pct="15"]  { width: 15%; }
.ciclo .marca[data-pct="20"]  { width: 20%; }
.ciclo .marca[data-pct="25"]  { width: 25%; }
.ciclo .marca[data-pct="30"]  { width: 30%; }
.ciclo .marca[data-pct="35"]  { width: 35%; }
.ciclo .marca[data-pct="40"]  { width: 40%; }
.ciclo .marca[data-pct="45"]  { width: 45%; }
.ciclo .marca[data-pct="50"]  { width: 50%; }
.ciclo .marca[data-pct="55"]  { width: 55%; }
.ciclo .marca[data-pct="60"]  { width: 60%; }
.ciclo .marca[data-pct="65"]  { width: 65%; }
.ciclo .marca[data-pct="70"]  { width: 70%; }
.ciclo .marca[data-pct="75"]  { width: 75%; }
.ciclo .marca[data-pct="80"]  { width: 80%; }
.ciclo .marca[data-pct="85"]  { width: 85%; }
.ciclo .marca[data-pct="90"]  { width: 90%; }
.ciclo .marca[data-pct="95"]  { width: 95%; }
.ciclo .marca[data-pct="100"] { width: 100%; }

/* Peso: o numero que o Dr. procura primeiro na ficha. Fica maior que o resto de proposito. */
.destaque {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 12px;
  background: var(--verde-50); border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--linha-suave);
}
.destaque .rotulo { font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--tinta-4); }
.destaque .numero { margin-top: 2px; font-size: 24px; font-weight: 650; letter-spacing: -.02em;
  line-height: 1.15; font-variant-numeric: tabular-nums; }
.destaque .meta { margin-top: 1px; }
.subiu  { color: var(--aviso); }
.desceu { color: var(--ok); }
