:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #17201d;
  --muted: #64716c;
  --line: #e2e8e5;
  --accent: #0f766e;
  --accent-soft: #e0f2ef;
  --receita: #15803d;
  --despesa: #b91c1c;
  --ok: #16a34a;
  --atencao: #ca8a04;
  --alerta: #ea580c;
  --estouro: #dc2626;
  --sombra: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --card: #17201d;
    --text: #e8efec;
    --muted: #93a39d;
    --line: #26332e;
    --accent: #2dd4bf;
    --accent-soft: #123631;
    --receita: #4ade80;
    --despesa: #f87171;
    --sombra: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.topo {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent); color: #fff;
}
@media (prefers-color-scheme: dark) { .topo { background: #0b3b36; } }
.topo h1 { font-size: 18px; margin: 0; font-weight: 650; }
.topo button { background: none; border: 0; color: #fff; font-size: 14px; opacity: .9; padding: 6px 0; }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.abas button {
  background: none; border: 0; padding: 8px 0 10px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.abas button span { font-size: 22px; line-height: 1; }
.abas button.ativa { color: var(--accent); font-weight: 650; }

.card { background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--sombra); margin-bottom: 14px; }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }

.tipo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tipo button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tipo button.ativo[data-tipo=despesa] { background: var(--card); color: var(--despesa); box-shadow: var(--sombra); }
.tipo button.ativo[data-tipo=receita] { background: var(--card); color: var(--receita); box-shadow: var(--sombra); }

.valor { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 4px 0 16px; }
.valor small { font-size: 22px; color: var(--muted); }
.valor input {
  width: 100%; max-width: 200px; border: 0; background: none; outline: none;
  font-size: 44px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums;
}

.rotulo { font-size: 13px; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 7px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11.5px; text-align: center; line-height: 1.15;
}
.chip b { font-size: 20px; font-weight: 400; }
.chip.ativo { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.chips.linha { display: flex; flex-wrap: wrap; }
.chips.linha .chip { flex-direction: row; padding: 8px 14px; font-size: 14px; }

.campo { display: block; width: 100%; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); outline: none; }
.campo:focus { border-color: var(--accent); }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.botao {
  display: block; width: 100%; margin-top: 18px; padding: 15px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 17px;
}
@media (prefers-color-scheme: dark) { .botao { color: #062a26; } }
.botao:disabled { opacity: .5; }
.botao.sec { background: var(--card); color: var(--text); border: 1.5px solid var(--line); font-weight: 600; }
.botao.perigo { background: none; color: var(--despesa); border: 1.5px solid var(--despesa); font-weight: 600; }

.mes { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.mes button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--sombra); font-size: 20px; }
.mes strong { font-size: 18px; }

.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.numeros .card { margin: 0; padding: 14px; }
.numeros .card.saldo { grid-column: 1 / -1; }
.numeros span { display: block; font-size: 13px; color: var(--muted); }
.numeros b { font-size: 20px; font-variant-numeric: tabular-nums; }
.numeros .saldo b { font-size: 28px; }
.pos { color: var(--receita); } .neg { color: var(--despesa); }

.aviso { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; font-size: 14px; }
.aviso.n50 { background: color-mix(in srgb, var(--atencao) 15%, transparent); }
.aviso.n75 { background: color-mix(in srgb, var(--alerta) 15%, transparent); }
.aviso.n100 { background: color-mix(in srgb, var(--estouro) 16%, transparent); }

.cat { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cat:last-child { border-bottom: 0; }
.cat .l1 { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; }
.cat .l1 b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat .l2 { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; }
.barra { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 6px; }
.barra i { display: block; height: 100%; border-radius: 4px; background: var(--ok); }
.barra i.n50 { background: var(--atencao); } .barra i.n75 { background: var(--alerta); } .barra i.n100 { background: var(--estouro); }

.dia { font-size: 13px; color: var(--muted); font-weight: 600; margin: 16px 0 6px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 6px; box-shadow: var(--sombra); width: 100%; border: 0; text-align: left; }
.item .ic { font-size: 22px; width: 32px; text-align: center; }
.item .tx { flex: 1; min-width: 0; }
.item .tx div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tx small { color: var(--muted); font-size: 12.5px; }
.item .vl { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.meta-linha { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.meta-linha:last-child { border-bottom: 0; }
.meta-linha span { flex: 1; }
.meta-linha input { width: 130px; text-align: right; padding: 10px; }

.hist { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.hist div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.hist .bars { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.hist .bars i { width: 40%; border-radius: 3px 3px 0 0; }
.hist .r { background: var(--receita); } .hist .d { background: var(--despesa); }
.hist small { font-size: 11px; color: var(--muted); }
.legenda { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.vazio { text-align: center; color: var(--muted); padding: 30px 10px; }

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 28px 22px; }
.login h1 { margin: 0 0 4px; font-size: 24px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.login .campo { margin-bottom: 10px; }
.erro { color: var(--despesa); font-size: 14px; min-height: 20px; margin-top: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #17201d; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14.5px;
  opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); z-index: 20; text-align: center;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.forte { background: var(--estouro); }

/* plano de contas da planilha */
.rolagem { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.rolagem::-webkit-scrollbar { display: none; }
.rolagem .chip { flex: 0 0 auto; flex-direction: row; padding: 8px 12px; font-size: 13.5px; white-space: nowrap; }
#cats .chip { padding: 10px 6px; font-size: 13px; justify-content: center; min-height: 48px; }
.dica { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13.5px; }
.dica .chip { padding: 6px 10px; font-size: 13px; flex-direction: row; }
.ajuda { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.sub { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.conta { display: flex; gap: 10px; align-items: center; width: 100%; padding: 11px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.conta:last-child { border-bottom: 0; }
.conta .st { width: 22px; text-align: center; font-size: 16px; }
.conta .tx { flex: 1; min-width: 0; }
.conta .tx div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conta .tx small { color: var(--muted); font-size: 12px; }
.conta .vl { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.conta.pago { opacity: .55; }
.conta.atrasado .tx small { color: var(--despesa); }
.grupo { cursor: pointer; }
.seta { color: var(--muted); }
.sub-contas { margin-top: 8px; padding: 6px 0 0 10px; border-left: 2px solid var(--line); }
.conta-linha { font-size: 13.5px; padding: 4px 0; }
.conta-linha small { color: var(--muted); }
.tag { font-size: 10.5px; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 6px; }
.card h2 small { font-weight: 400; }
.meta-linha small { color: var(--muted); font-size: 12px; }
.meta-linha span { font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; }
.numeros .card > span:last-child { margin-top: 2px; font-size: 12px; }

/* instalar como aplicativo */
.instalar-topo { max-width: 560px; margin: 0 auto; padding: 12px 16px 0; }
.instalar-topo:empty { display: none; }
.banner-instalar { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--accent); border-radius: 14px; padding: 10px 10px 10px 12px; box-shadow: var(--sombra); text-align: left; }
.banner-instalar img { width: 40px; height: 40px; border-radius: 10px; }
.banner-instalar div { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; }
.banner-instalar small { color: var(--muted); font-size: 12px; }
.bi-sim { border: 0; background: var(--accent); color: #fff; font-weight: 700; padding: 9px 14px; border-radius: 10px; }
@media (prefers-color-scheme: dark) { .bi-sim { color: #062a26; } }
.bi-nao { border: 0; background: none; color: var(--muted); font-size: 16px; padding: 6px; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal-caixa { background: var(--card); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
.modal-caixa h2 { margin: 0 0 12px; font-size: 19px; }
.passos { list-style: none; padding: 0; margin: 0 0 8px; }
.passos li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.passos li:last-child { border-bottom: 0; }
.passos span { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.passos p { margin: 3px 0 0; font-size: 15px; }
.passos svg { vertical-align: -5px; }
