:root {
  --fundo: #f4f1ea;
  --superficie: #fffdf8;
  --superficie-2: #efebe1;
  --tinta: #1d2420;
  --suave: #69706b;
  --linha: #e2ddd1;
  --verde: #2f6f5e;
  --verde-claro: #dcebe4;
  --amarelo: #a86b0c;
  --amarelo-claro: #f6e8c9;
  --laranja: #b5531a;
  --laranja-claro: #f6dccb;
  --vermelho: #b3261e;
  --vermelho-claro: #f5d6d2;
  --cinza-claro: #e7e4dc;
  --foco: #2f6f5e;
  --sombra: 0 1px 2px rgba(29, 36, 32, .06), 0 4px 16px rgba(29, 36, 32, .05);
  --raio: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #121614;
    --superficie: #1b201d;
    --superficie-2: #232925;
    --tinta: #e9ece8;
    --suave: #9aa39d;
    --linha: #2c332f;
    --verde: #6cc0a4;
    --verde-claro: #1f3a31;
    --amarelo: #e3b14f;
    --amarelo-claro: #3a3020;
    --laranja: #ec9a62;
    --laranja-claro: #3d2a1f;
    --vermelho: #f08a80;
    --vermelho-claro: #43231f;
    --cinza-claro: #2a302c;
    --foco: #6cc0a4;
    --sombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fundo);
  color: var(--tinta);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.travado { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; }
h1 { font-size: 1.6rem; line-height: 1.15; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
h4 { margin: 0; }
code { background: var(--superficie-2); padding: .1em .35em; border-radius: 6px; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--verde); }
.neg { color: var(--vermelho); }
.suave { color: var(--suave); }
.pequeno { font-size: .85rem; }
.direita { text-align: right; margin-left: auto; }
.centro { text-align: center; }
.grande-num { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; display: block; margin: .15rem 0; }
.medio-num { font-size: 1.35rem; font-weight: 700; display: block; }

/* Estrutura */
.conteudo {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 104px);
  display: flex; flex-direction: column; gap: 12px;
}
.topo { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.topo p { margin: 0; }

.cartao {
  background: var(--superficie);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 16px;
  box-shadow: var(--sombra);
}
.cartao.compacto { padding: 8px 12px; }
.cartao p { margin: .35rem 0; }

/* Navegação */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: center;
  max-width: 560px; margin: 0 auto;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--superficie) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--linha);
}
.abas button:not(.fab) {
  background: none; border: 0; padding: 6px 0; font-size: .75rem; color: var(--suave);
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px;
}
.abas button.ativo { color: var(--verde); font-weight: 600; }
.aba-icone { line-height: 0; }
.fab {
  justify-self: center; width: 58px; height: 58px; margin-top: -26px;
  border-radius: 50%; border: 0; background: var(--verde); color: var(--superficie);
  font-size: 2rem; line-height: 1; box-shadow: 0 6px 18px rgba(47, 111, 94, .35);
}
@media (prefers-color-scheme: dark) { .fab { color: #0d1a15; } }

/* Botões */
.btn {
  border: 1px solid var(--linha); background: var(--superficie); border-radius: 12px;
  padding: .7rem 1rem; font-weight: 600; min-height: 44px;
}
.btn.primario { background: var(--verde); border-color: var(--verde); color: var(--superficie); }
@media (prefers-color-scheme: dark) { .btn.primario { color: #0d1a15; } }
.btn.perigo { color: var(--vermelho); }
.btn.texto { border: 0; background: none; color: var(--verde); padding: .5rem 0; min-height: 0; }
.btn.largo { width: 100%; }
.link { border: 0; background: none; padding: 0; color: var(--verde); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.icone-btn {
  border: 0; background: var(--superficie-2); border-radius: 50%;
  width: 36px; height: 36px; display: inline-grid; place-items: center; font-size: 1.1rem; flex: none;
}
.icone-btn.grande { width: 44px; height: 44px; font-size: 1.3rem; }
.acoes { display: flex; gap: 8px; }
.acoes .btn.largo { flex: 1; }
.acoes.empilhadas { flex-direction: column; margin-top: 8px; }

/* Segmento e mês */
.segmento { display: flex; background: var(--superficie-2); border-radius: 12px; padding: 3px; }
.segmento button {
  flex: 1; border: 0; background: none; border-radius: 9px; padding: .55rem .4rem;
  font-weight: 600; color: var(--suave); font-size: .92rem;
}
.segmento button.ativo { background: var(--superficie); color: var(--tinta); box-shadow: var(--sombra); }
.segmento.pequeno button { padding: .45rem .3rem; font-size: .85rem; }
.barra-mes { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.barra-mes strong { display: inline-block; }
.barra-mes strong::first-letter { text-transform: uppercase; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li + li { border-top: 1px solid var(--linha); }
.linha { display: flex; align-items: center; gap: 10px; padding: 10px 0; width: 100%; }
button.linha, .tocavel { background: none; border: 0; text-align: left; padding-left: 0; padding-right: 0; }
.linha.forte { font-weight: 700; }
.linha.apagada { opacity: .5; }
.linha-data { font-size: .8rem; color: var(--suave); min-width: 40px; font-variant-numeric: tabular-nums; }
.linha-icone { width: 32px; height: 32px; border-radius: 10px; background: var(--superficie-2); display: grid; place-items: center; flex: none; }
.linha-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.tocavel-texto { background: none; border: 0; text-align: left; padding: 0; }
.sub { font-size: .8rem; color: var(--suave); font-weight: 400; display: block; }
.seta { color: var(--suave); width: 14px; }
.dia { font-size: .8rem; color: var(--suave); padding-top: 4px; }
.etiqueta {
  align-self: flex-start; margin-top: 3px; font-size: .72rem; font-weight: 600;
  padding: 1px 8px; border-radius: 99px; background: var(--superficie-2); color: var(--suave);
}
.etiqueta.vermelho { background: var(--vermelho-claro); color: var(--vermelho); }
.bolinha { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.vazio { color: var(--suave); text-align: center; padding: 14px 8px; margin: 0; font-size: .92rem; }
.detalhe { padding: 0 0 8px; }
.lista.interna { background: var(--superficie-2); border-radius: 12px; padding: 0 12px; }
.lista.interna .linha { padding: 8px 0; font-size: .92rem; }

.marcador {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 2px solid var(--linha); background: var(--superficie); color: var(--superficie); font-weight: 700;
}
.marcador.feito { background: var(--verde); border-color: var(--verde); }

/* Resumos */
.resumo-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.resumo-3 > div {
  background: var(--superficie); border: 1px solid var(--linha); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 2px; font-weight: 700; min-width: 0;
}
.resumo-3 .num { font-size: .98rem; overflow: hidden; text-overflow: ellipsis; }

/* Início */
.meses { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mes { padding: 14px; border-top: 4px solid var(--verde); }
.mes.amarelo { border-top-color: var(--amarelo); }
.mes.vermelho { border-top-color: var(--vermelho); }
.mes p { margin: 0; }
.mes-nome { font-weight: 700; text-transform: capitalize; }
.mes .grande-num { font-size: 1.35rem; }
.ponto { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--verde); }
.ponto.amarelo { background: var(--amarelo); }
.ponto.vermelho { background: var(--vermelho); }
.alerta-grande { border: 0; }
.alerta-grande.amarelo { background: var(--amarelo-claro); }
.alerta-grande.vermelho { background: var(--vermelho-claro); }
.alerta-grande strong { font-size: 1.05rem; }
.destaque-info { background: var(--verde-claro); border: 0; }
.passos { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; }
.folga { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.folga p { margin: 0; }

.grafico { width: 100%; height: auto; display: block; margin: 10px 0 4px; overflow: visible; }
.g-zero { stroke: var(--vermelho); stroke-dasharray: 3 4; stroke-width: 1; opacity: .6; }
.g-mes { stroke: var(--linha); stroke-width: 1; }
.g-area { fill: var(--verde); opacity: .1; }
.g-linha { fill: none; stroke: var(--verde); stroke-width: 2.2; stroke-linejoin: round; }
.g-min { fill: var(--superficie); stroke: var(--verde); stroke-width: 2; }
.g-min.neg { stroke: var(--vermelho); }
.g-rotulo { font-size: 10px; fill: var(--suave); }
.g-rotulo.forte { font-weight: 700; fill: var(--tinta); }

/* Diagnóstico */
.nivel { border: 0; }
.nivel.verde { background: var(--verde-claro); }
.nivel.amarelo { background: var(--amarelo-claro); }
.nivel.laranja { background: var(--laranja-claro); }
.nivel.vermelho { background: var(--vermelho-claro); }
.nivel.cinza { background: var(--cinza-claro); }
.nivel-titulo { font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; margin: 0 !important; }
.nivel.verde .nivel-titulo { color: var(--verde); }
.nivel.amarelo .nivel-titulo { color: var(--amarelo); }
.nivel.laranja .nivel-titulo { color: var(--laranja); }
.nivel.vermelho .nivel-titulo { color: var(--vermelho); }
.gargalos { margin: 0; padding-left: 1.1rem; display: grid; gap: 8px; }
.medidor { position: relative; height: 12px; background: var(--superficie-2); border-radius: 99px; overflow: hidden; }
.medidor-barra { height: 100%; background: var(--verde); border-radius: 99px; }
.medidor-barra.alto { background: var(--laranja); }
.medidor-marca { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--tinta); opacity: .35; }
.barras { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.barra-topo { display: flex; justify-content: space-between; gap: 8px; font-size: .95rem; }
.barra { height: 8px; background: var(--superficie-2); border-radius: 99px; margin: 4px 0; overflow: hidden; }
.barra > div { height: 100%; border-radius: 99px; background: var(--laranja); min-width: 3px; }
.barra > div.essencial { background: var(--verde); }
.barra > div.fixo { background: var(--suave); }
.barra-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--suave); }
.legenda { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.leg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--laranja); margin-left: 6px; }
.leg.fixo { background: var(--suave); }
.leg.essencial { background: var(--verde); }

/* Faturas */
.cartao-cab { display: flex; align-items: center; gap: 10px; padding: 6px 0 4px; }
.faixa { width: 6px; align-self: stretch; border-radius: 4px; }
.conferencia { background: var(--amarelo-claro); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.conferencia.ok { background: var(--verde-claro); }
.conferencia p { margin: 0; }

/* Formulários */
.campo { display: flex; flex-direction: column; gap: 6px; }
.rotulo { font-size: .85rem; font-weight: 600; color: var(--suave); }
.dica { font-size: .8rem; color: var(--suave); }
input[type=text], input[type=date], input[type=month], input:not([type]), select {
  width: 100%; min-height: 46px; padding: .6rem .75rem;
  border: 1px solid var(--linha); border-radius: 12px; background: var(--superficie);
}
.campo-valor { display: flex; align-items: center; border: 1px solid var(--linha); border-radius: 12px; background: var(--superficie); padding-left: .75rem; }
.campo-valor:focus-within { border-color: var(--foco); }
.campo-valor input { border: 0; min-height: 46px; padding-left: .4rem; background: none; }
.campo-valor input:focus-visible { outline: none; }
.campo-valor .prefixo { color: var(--suave); font-weight: 600; }
.campo-valor.grande input { font-size: 1.9rem; font-weight: 700; min-height: 60px; font-variant-numeric: tabular-nums; }
.dupla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.contador { display: flex; align-items: center; gap: 8px; }
.contador input { width: 70px; text-align: center; }
.alternar { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 46px; }
.alternar input { width: 20px; height: 20px; accent-color: var(--verde); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.rolagem { flex-wrap: nowrap; overflow-x: auto; }
.chip {
  border: 1px solid var(--linha); background: var(--superficie); border-radius: 99px;
  padding: .42rem .8rem; font-size: .88rem; display: inline-flex; align-items: center; gap: 6px; min-height: 38px;
}
.chip-icone { font-size: .95rem; color: var(--cor-chip, inherit); }
.chip.ativo { background: var(--verde); border-color: var(--verde); color: var(--superficie); font-weight: 600; }
.chip.ativo .chip-icone { color: inherit; }
@media (prefers-color-scheme: dark) { .chip.ativo { color: #0d1a15; } }

.estimativa { display: grid; gap: 8px; padding: 12px 0; }
.estimativa-topo { display: flex; justify-content: space-between; align-items: center; }
.cores { display: flex; gap: 8px; }
.cor { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; }
.cor.ativo { border-color: var(--tinta); box-shadow: inset 0 0 0 2px var(--superficie); }

/* Folha (modal de baixo para cima) */
.folha-fundo {
  position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 12, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparecer .15s ease-out;
}
.folha {
  width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--fundo); border-radius: 22px 22px 0 0; overflow: hidden;
  animation: subir .22s cubic-bezier(.2, .8, .2, 1);
}
.folha-topo { display: flex; justify-content: space-between; align-items: center; padding: 16px 16px 8px; gap: 8px; }
.folha-corpo { overflow-y: auto; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.folha-rodape { padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); border-top: 1px solid var(--linha); background: var(--superficie); }
@media (min-width: 700px) {
  .folha-fundo { align-items: center; }
  .folha { border-radius: 22px; max-height: 88vh; }
}
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(40px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .folha, .folha-fundo { animation: none; } }

/* Aviso */
.aviso {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  background: var(--tinta); color: var(--fundo); padding: .65rem 1rem; border-radius: 12px;
  font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.aviso.erro { background: var(--vermelho); color: #fff; }
.alerta { padding: .75rem 1rem; border-radius: 12px; }
.alerta.vermelho { background: var(--vermelho-claro); color: var(--vermelho); }

/* Login */
.tela-central {
  min-height: 100dvh; max-width: 420px; margin: 0 auto; padding: 24px;
  display: flex; flex-direction: column; justify-content: center; gap: 14px; text-align: center;
}
.marca { font-size: 3rem; color: var(--verde); line-height: 1; }
.g { font-weight: 800; margin-right: 6px; }

@media (max-width: 360px) {
  .meses { grid-template-columns: 1fr; }
  .resumo-3 .num { font-size: .85rem; }
}
