/* DRE da Família — "livro-caixa de noite".
   Papel grafite quente, tinta de caneta, régua e pontilhado de livro de contas.
   Hierarquia por tipografia e filetes, não por caixas. O total fecha com filete duplo, como no caderno de contador. */
:root {
  --papel: #171a1c; --folha: #1f2427; --tinta: #ece6d6; --apoio: #c2bcad; --fraco: #98938a;
  --linha: #353b3f; --regua: #50575b;
  --azul: #93b4e6; --sobrou: #a9d6a3; --ambar: #eaa93a; --faltou: #ff9087;
  --fonte-texto: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --fonte-titulo: "Bricolage Grotesque", "Atkinson Hyperlegible Next", "Segoe UI", system-ui, sans-serif;
  --raio: 6px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--papel); color: var(--tinta); }
body { font: 400 16px/1.5 var(--fonte-texto); padding-bottom: 104px; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.num, .valor, .preco { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- topo ---------- */
.topo { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; padding: 0 8px;
  background: var(--papel); border-bottom: 1px solid var(--regua); }
.seta { min-height: 56px; min-width: 48px; border: 0; background: none; padding: 0 8px; font-size: 15px; color: var(--apoio); }
.seta span { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--regua); }
.mes-nome { flex: 1; text-align: center; font: 700 21px/1.1 var(--fonte-titulo); letter-spacing: -.01em; text-transform: capitalize; white-space: nowrap; }
.selo { flex: 1 0 100%; margin: 0 -8px; padding: 0 20px; min-height: 44px; border: 0; border-top: 1px solid var(--linha);
  background: #2a2417; color: var(--ambar); text-align: left; font-size: 15px; font-weight: 700; }
.selo::before { content: "●"; margin-right: 8px; font-size: 11px; vertical-align: 2px; }

main { max-width: 640px; margin: 0 auto; padding: 20px 20px 8px; }
.aba > * + * { margin-top: 28px; }

/* ---------- blocos de página (antes eram cartões) ---------- */
.cartao { border-top: 2px solid var(--tinta); padding-top: 12px; }
.cartao h2 { font: 700 23px/1.15 var(--fonte-titulo); letter-spacing: -.015em; margin: 0 0 4px; }
.apoio { color: var(--apoio); font-size: 15px; margin: 2px 0 6px; }
.fraco { color: var(--fraco); font-size: 15px; }
.pequeno-titulo { color: var(--apoio); font-size: 15px; margin: 0 0 6px; }
.grupo { margin: 22px 0 0; padding: 4px 0; font-size: 15px; color: var(--apoio); border-bottom: 1px solid var(--regua); }
.grupo b { font: 700 18px var(--fonte-titulo); color: var(--tinta); margin-right: 4px; }

/* linha de livro-caixa: descrição ........ valor */
.numero-linha { display: flex; align-items: baseline; gap: 0; padding: 7px 0 3px; }
.nome { display: flex; flex: 1; align-items: baseline; min-width: 0; font-size: 17px; }
.nome::after { content: ""; flex: 1 1 18px; min-width: 14px; margin: 0 8px; border-bottom: 2px dotted var(--regua); transform: translateY(-4px); }
.numero-linha .valor { font: 600 26px/1.1 var(--fonte-titulo); white-space: nowrap; }
.comparacao { font-size: 15px; color: var(--fraco); margin: 0 0 4px; }
.resumo { border-top-width: 3px; }
.resultado { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--regua); }
.resultado .nome { font: 700 22px var(--fonte-titulo); }
.resultado .valor { font: 800 clamp(40px, 13vw, 56px)/1.05 var(--fonte-titulo); letter-spacing: -.025em; padding-bottom: 3px;
  border-bottom: 7px double currentColor; }
.verde { color: var(--sobrou); } .ciano { color: var(--azul); } .ambar { color: var(--ambar); } .vermelho { color: var(--faltou); }
.link { background: none; border: 0; color: var(--azul); padding: 10px 0; min-height: 48px; font-size: 16px; text-decoration: underline; text-underline-offset: 4px; }

.frase { padding: 2px 0 2px 14px; border-left: 3px solid var(--regua); font-size: 17px; line-height: 1.5; }
.frase.atencao, .frase.alerta { border-left-color: var(--ambar); }

/* ---------- contas ---------- */
.conta { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; padding: 12px 0 10px; border-top: 1px solid var(--linha); }
.conta .titulo { grid-column: 1; font-size: 17px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.conta .preco { grid-column: 2; grid-row: 1; justify-self: end; font: 700 19px var(--fonte-titulo); white-space: nowrap; }
.conta .motivo { grid-column: 1; font-size: 15px; color: var(--ambar); }
.conta .motivo.ok { color: var(--fraco); }
.conta .btn { grid-column: 2; grid-row: 2; margin-top: 2px; }
.btn { min-height: 48px; border-radius: var(--raio); border: 1px solid var(--regua); background: none; padding: 0 16px; font-size: 16px; font-weight: 500; }
.btn.verde-borda { border-color: var(--sobrou); color: var(--sobrou); font-weight: 700; }
.btn-principal { display: block; width: 100%; min-height: 56px; border: 0; border-radius: var(--raio); background: var(--tinta);
  color: var(--papel); font: 700 19px var(--fonte-titulo); margin-top: 18px; }
.btn-principal:disabled { opacity: .5; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }

.barra-prog { height: 12px; background: var(--linha); border-radius: 2px; overflow: hidden; margin: 12px 0 8px; }
.barra-prog div { height: 100%; background: var(--sobrou); transition: width .4s; }

/* ---------- DRE ---------- */
.dre-linha { width: 100%; display: flex; align-items: baseline; gap: 0; background: none; border: 0; text-align: left; color: inherit;
  padding: 9px 0; min-height: 46px; border-top: 1px solid var(--linha); font-size: 17px; font-variant-numeric: tabular-nums lining-nums; }
.dre-linha > span:last-child { font-weight: 600; white-space: nowrap; }
.dre-linha.menos .nome::before { content: "−"; margin-right: 8px; color: var(--fraco); }
.dre-linha.mais .nome::before { content: "+"; margin-right: 8px; color: var(--fraco); }
.dre-linha.final { border-top: 1px solid var(--tinta); margin-top: 4px; padding-top: 12px; font: 700 21px var(--fonte-titulo); }
.dre-linha.final > span:last-child, .dre-linha.final .valor { font: 800 28px var(--fonte-titulo); padding-bottom: 2px; border-bottom: 6px double currentColor; }
.dre-linha.final .nome { font: 700 21px var(--fonte-titulo); }
.dre-detalhe { padding: 2px 0 10px 18px; font-size: 15px; color: var(--apoio); }
.dre-detalhe div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.chave { display: flex; border-bottom: 1px solid var(--regua); }
.chave button { flex: 1; min-height: 52px; border: 0; border-bottom: 4px solid transparent; margin-bottom: -1px; background: none; font-size: 16px; color: var(--fraco); line-height: 1.25; padding: 4px 6px; }
.chave button.ativa { color: var(--tinta); font-weight: 700; border-bottom-color: var(--tinta); }

/* ---------- lançamentos ---------- */
.item-lista { width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left; background: none; border: 0; color: inherit;
  border-top: 1px solid var(--linha); padding: 12px 0; min-height: 56px; align-items: flex-start; }
.item-lista .titulo { font-weight: 700; font-size: 17px; }
.item-lista .preco { font: 700 18px var(--fonte-titulo); white-space: nowrap; }
.etiqueta { display: inline-block; font-size: 15px; line-height: 1.3; padding: 0 6px; border: 1px solid var(--regua); border-radius: 3px; color: var(--apoio); margin-right: 6px; }
.etiqueta.agente { color: var(--azul); border-color: var(--azul); }

/* ---------- botão Lançar + barra de abas ---------- */
.barra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: 1fr 1fr 112px 1fr 1fr;
  background: var(--papel); border-top: 1px solid var(--regua); padding: 0 max(0px, calc((100vw - 640px) / 2)) env(safe-area-inset-bottom); }
.barra .vao { display: block; }
.barra button { position: relative; min-height: 64px; border: 0; background: none; color: var(--fraco); font-size: 15px; display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.barra button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.barra button.ativa { color: var(--tinta); font-weight: 700; }
.barra button.ativa::before { content: ""; position: absolute; top: -1px; left: 18%; right: 18%; height: 4px; background: var(--tinta); }
.fab { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 10px); width: 108px; min-height: 56px;
  border: 0; border-radius: var(--raio); background: var(--tinta); color: var(--papel); font: 800 19px var(--fonte-titulo); }
.fab:active { transform: translateX(-50%) translateY(1px); }

/* ---------- folha "Lançar" ---------- */
.folha-fundo { position: fixed; inset: 0; background: rgba(8, 10, 11, .72); z-index: 10; }
.folha { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 92vh; overflow: auto; background: var(--folha);
  border-top: 3px solid var(--tinta); padding: 16px 20px calc(24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.folha h2 { margin: 0 0 12px; font: 700 23px/1.2 var(--fonte-titulo); letter-spacing: -.015em; }
.fechar { float: right; min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--regua); background: none; border-radius: var(--raio); font-size: 16px; }
.campo { width: 100%; min-height: 52px; border-radius: var(--raio); border: 1px solid var(--regua); background: var(--papel); color: var(--tinta);
  font: 400 18px var(--fonte-texto); padding: 0 14px; margin: 6px 0 14px; }
.campo.grande { font: 800 44px var(--fonte-titulo); min-height: 76px; border: 0; border-bottom: 3px solid var(--tinta); border-radius: 0; background: none; padding: 0 2px; letter-spacing: -.02em; }
.campo.grande::placeholder { color: var(--fraco); font-weight: 600; }
select.campo { font-size: 17px; }
input[type=date].campo { color-scheme: dark; }
.rotulo { font-size: 15px; color: var(--apoio); margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.chip { min-height: 48px; border-radius: var(--raio); border: 1px solid var(--regua); background: none; padding: 0 14px; font-size: 16px; }
.chip.ativo, .opcao.ativa { border: 2px solid var(--tinta); background: #2c3236; font-weight: 700; }
.chip.ativo::before, .opcao.ativa::before { content: "✓ "; }
.escolha { display: flex; gap: 8px; margin: 8px 0 14px; }
.opcao { flex: 1; min-height: 48px; border-radius: var(--raio); border: 1px solid var(--regua); background: none; font-size: 16px; line-height: 1.2; padding: 4px 8px; }
.explica { border-left: 3px solid var(--azul); padding: 4px 0 4px 12px; font-size: 15px; margin: 10px 0 0; color: var(--apoio); }

/* ---------- aviso ---------- */
.aviso { position: fixed; left: 16px; right: 16px; bottom: 90px; z-index: 20; background: var(--tinta); color: var(--papel); border-radius: var(--raio);
  padding: 12px 14px; font-size: 16px; font-weight: 500; display: flex; align-items: center; gap: 12px; max-width: 608px; margin: 0 auto; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.aviso button { margin-left: auto; min-height: 44px; border: 0; background: var(--papel); color: var(--tinta); border-radius: 4px; padding: 0 14px; font-weight: 700; }

/* ---------- entrada ---------- */
.login { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 14vh 24px 24px; }
.login-caixa { width: 100%; max-width: 380px; }
.marca { font: 800 clamp(40px, 13vw, 52px)/1 var(--fonte-titulo); letter-spacing: -.03em; padding-bottom: 12px; border-bottom: 7px double var(--tinta); margin-bottom: 14px; }
.login .apoio { font-size: 17px; margin-bottom: 24px; }
.erro { color: var(--faltou); font-size: 16px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
