:root {
  --fundo: #f4f6f8; --superficie: #ffffff; --texto: #0f172a; --suave: #64748b; --borda: #e2e8f0;
  --marca: #0f766e; --marca-2: #14b8a6; --pos: #15803d; --neg: #dc2626; --alerta: #d97706;
  --raio: 14px; --sombra: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
}
@media (prefers-color-scheme: dark) {
  :root { --fundo: #0b1220; --superficie: #131c2e; --texto: #e2e8f0; --suave: #94a3b8; --borda: #23304a;
    --pos: #4ade80; --neg: #f87171; --alerta: #fbbf24; --sombra: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fundo); color: var(--texto); }
a { color: var(--marca); text-decoration: none; }
h1 { font-size: 1.4rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--suave); }
small { color: var(--suave); font-size: .8rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .alerta { color: var(--alerta); font-weight: 600; }

/* topo e menus */
.topo { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  padding-top: calc(.6rem + env(safe-area-inset-top)); background: var(--superficie); border-bottom: 1px solid var(--borda); }
.marca { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--texto); }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--marca), var(--marca-2)); }
.logo.grande { width: 64px; height: 64px; border-radius: 18px; font-size: 2rem; }
.quem { margin-left: auto; color: var(--suave); font-size: .9rem; }
.menu-desktop { display: none; gap: .25rem; }
.menu-desktop a { padding: .4rem .8rem; border-radius: 8px; color: var(--suave); }
.menu-desktop a.ativo, .menu-desktop a:hover { background: var(--fundo); color: var(--texto); }
.menu-celular { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--superficie); border-top: 1px solid var(--borda); padding-bottom: env(safe-area-inset-bottom); }
.menu-celular a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .45rem 0; font-size: .7rem; color: var(--suave); }
.menu-celular a.ativo { color: var(--marca); font-weight: 600; }
.menu-celular .ico { font-size: 1.25rem; line-height: 1; }
.menu-celular a.destaque .ico { display: grid; place-items: center; width: 42px; height: 42px; margin-top: -18px; border-radius: 50%;
  color: #fff; background: linear-gradient(135deg, var(--marca), var(--marca-2)); box-shadow: var(--sombra); }
.conteudo { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
@media (min-width: 820px) {
  .menu-desktop { display: flex; } .menu-celular { display: none; } .conteudo { padding-bottom: 2rem; }
  .grade-painel { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
}

/* blocos */
.bloco, .cartao-form, .em-breve { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 1rem; margin-bottom: 1rem; box-shadow: var(--sombra); }
.ola { margin: .2rem 0 .6rem; color: var(--suave); }
.destaque-saldo { display: flex; flex-direction: column; padding: 1.1rem 1.2rem; margin-bottom: 1rem; border-radius: var(--raio);
  color: #fff; background: linear-gradient(135deg, var(--marca), #115e59); }
.destaque-saldo small { color: #ccfbf1; } .destaque-saldo b { font-size: 2rem; letter-spacing: -.02em; }
.destaque-saldo b.neg { color: #fecaca; }
.resumo3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: 1rem; }
.resumo3 > div { background: var(--superficie); border: 1px solid var(--borda); border-radius: 12px; padding: .6rem .7rem; }
.resumo3 small { display: block; } .resumo3 b { font-size: .98rem; white-space: nowrap; }
.vazio { color: var(--suave); text-align: center; padding: 1rem; }
.dica { color: var(--suave); font-size: .82rem; margin: .75rem 0 0; }
.aviso { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; background: #ccfbf1; color: #134e4a; }
.aviso-erro { background: #fee2e2; color: #7f1d1d; }
.titulo-acao { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* listas */
.lista { display: flex; flex-direction: column; background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); overflow: visible; margin-bottom: 1rem; }
.bloco .lista { border: 0; margin: 0; }
.item { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border-bottom: 1px solid var(--borda); color: var(--texto); position: relative; }
.item:last-child { border-bottom: 0; }
.item.inativo { opacity: .5; }
.item-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--texto); }
.item-texto strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-texto em { font-style: normal; font-size: .75rem; color: var(--suave); background: var(--fundo); padding: 0 .35rem; border-radius: 6px; }
.item-valor { text-align: right; font-weight: 600; white-space: nowrap; display: flex; flex-direction: column; }
.bolinha { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ico-cat { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--fundo); font-size: 1.1rem; }
.dia { margin: 1rem 0 .4rem .2rem; }
.menu-item summary { list-style: none; cursor: pointer; padding: 0 .3rem; color: var(--suave); font-size: 1.2rem; }
.menu-item summary::-webkit-details-marker { display: none; }
.menu-item > div { position: absolute; right: .5rem; top: 2.6rem; z-index: 5; display: flex; flex-direction: column; gap: .4rem;
  background: var(--superficie); border: 1px solid var(--borda); border-radius: 10px; padding: .6rem .8rem; box-shadow: var(--sombra); }
.menu-item form { margin: 0; }
.link-perigo { background: none; border: 0; padding: 0; color: var(--neg); font: inherit; cursor: pointer; }
.selo { font-size: .75rem; padding: .15rem .5rem; border-radius: 99px; background: var(--fundo); color: var(--suave); white-space: nowrap; }
.selo-paga { background: #dcfce7; color: #166534; } .selo-vencida { background: #fee2e2; color: #991b1b; }
.selo-fechada { background: #fef3c7; color: #92400e; } .selo-aberta { background: #e0f2fe; color: #075985; }

/* formulários */
.cartao-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--suave); margin-bottom: .8rem; }
input, select { font: inherit; color: var(--texto); background: var(--fundo); border: 1px solid var(--borda); border-radius: 10px;
  padding: .65rem .75rem; width: 100%; min-height: 44px; }
input:focus, select:focus { outline: 2px solid var(--marca-2); outline-offset: 0; border-color: transparent; }
input[type=color] { padding: .2rem; } input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--texto); }
.linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.valor-grande { font-size: 1.6rem; font-weight: 700; }
.acoes { display: flex; flex-wrap: wrap; gap: .5rem; }
.botao { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .55rem 1rem; border-radius: 10px;
  border: 1px solid var(--borda); background: var(--superficie); color: var(--texto); font: inherit; font-weight: 600; cursor: pointer; }
.botao.primario { background: var(--marca); border-color: var(--marca); color: #fff; }
.botao.largo { width: 100%; } .botao.mini { min-height: 32px; padding: .25rem .7rem; font-size: .85rem; }
.abas-tipo { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; background: var(--fundo); padding: .25rem; border-radius: 12px; margin-bottom: 1rem; }
.abas-tipo label { margin: 0 !important; }
.abas-tipo input { position: absolute; opacity: 0; pointer-events: none; }
.abas-tipo span { display: block; text-align: center; padding: .55rem 0; border-radius: 9px; font-weight: 600; color: var(--suave); cursor: pointer; }
.abas-tipo input:checked + span { background: var(--superficie); box-shadow: var(--sombra); }
.aba-despesa input:checked + span { color: var(--neg); } .aba-receita input:checked + span { color: var(--pos); }
.aba-transferencia input:checked + span { color: var(--marca); }
.filtros { margin-bottom: 1rem; } .filtros summary { cursor: pointer; color: var(--suave); margin-bottom: .5rem; }
.linha-filtros { display: grid; gap: .5rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .linha-filtros { grid-template-columns: 2fr 1.5fr 1.5fr 1.2fr auto; } }

/* navegação por mês */
.navega-mes { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.navega-mes a { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--superficie);
  border: 1px solid var(--borda); font-size: 1.5rem; color: var(--texto); }
.navega-mes strong { text-align: center; }

/* cartões de crédito */
.grade-cartoes { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-bottom: 1rem; }
.cc { --cor: #7c3aed; display: flex; flex-direction: column; gap: .5rem; padding: 1rem 1.1rem; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--cor), color-mix(in srgb, var(--cor) 55%, #000)); box-shadow: var(--sombra); margin-bottom: 1rem; }
.grade-cartoes .cc { margin: 0; }
.cc small { color: rgba(255,255,255,.8); } .cc.inativo { filter: grayscale(1); opacity: .6; }
.cc-topo { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .85rem; }
.cc-topo .selo { background: rgba(255,255,255,.9); }
.cc-fatura { display: flex; flex-direction: column; } .cc-fatura b { font-size: 1.6rem; }
.cc-acoes { display: flex; gap: 1rem; } .cc-acoes a { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.barra { height: 8px; border-radius: 99px; background: rgba(127,127,127,.25); overflow: hidden; }
.barra span { display: block; height: 100%; border-radius: 99px; background: #fff; }
.barra-cat { display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; margin-bottom: .7rem; font-size: .9rem; }
.barra-cat .barra { grid-column: 1 / -1; background: var(--fundo); }
.resumo-pessoas { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.resumo-pessoas span { background: var(--superficie); border: 1px solid var(--borda); border-radius: 99px; padding: .3rem .8rem; font-size: .85rem; }

/* login */
.login { max-width: 380px; margin: 8vh auto 0; }
.login-marca { text-align: center; margin-bottom: 1.5rem; } .login-marca h1 { margin: .6rem 0 .2rem; } .login-marca p { color: var(--suave); margin: 0; }
.primeiros-passos ol { margin: 0; padding-left: 1.2rem; } .primeiros-passos li { margin-bottom: .4rem; }
.em-breve p { color: var(--suave); margin: 0; }

/* lançamento: mostra/esconde campos conforme o tipo */
form[data-tipo=transferencia] .nao-transf, form:not([data-tipo=transferencia]) .so-transf { display: none !important; }
form:not([data-onde=cartao]) .so-cartao, form[data-tipo=transferencia] .so-cartao { display: none !important; }
form:not([data-tipo=despesa]) .so-despesa { display: none !important; }

/* importação */
.legenda { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0 0 .6rem; font-size: .8rem; }
.legenda label.check { margin: 0 0 0 auto; font-size: .85rem; }
.item-imp { align-items: flex-start; }
.item-imp .marca { margin-top: .2rem; flex: none; }
.item-imp .item-texto strong { white-space: normal; }
.item-imp select { margin-top: .4rem; min-height: 38px; padding: .35rem .5rem; font-size: .9rem; }
.barra-fixa { position: sticky; bottom: calc(4.2rem + env(safe-area-inset-bottom)); background: var(--fundo); padding: .6rem 0; z-index: 4; }
@media (min-width: 820px) { .barra-fixa { bottom: 0; } }
.ajuda summary { cursor: pointer; font-weight: 600; }
.ajuda ul { padding-left: 1.1rem; margin: .7rem 0 0; } .ajuda li { margin-bottom: .4rem; }

/* compras online */
.abas { display: flex; gap: .3rem; background: var(--superficie); border: 1px solid var(--borda); border-radius: 12px; padding: .25rem; margin-bottom: 1rem; }
.abas a { flex: 1; text-align: center; padding: .5rem 0; border-radius: 9px; color: var(--suave); font-weight: 600; font-size: .9rem; }
.abas a.ativo { background: var(--fundo); color: var(--texto); }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--marca); cursor: pointer; text-align: left; }
.menu-item > div a, .menu-item > div button { white-space: nowrap; }
.item.compra { align-items: flex-start; }
.item.compra .item-texto small { display: block; }
textarea { font: inherit; color: var(--texto); background: var(--fundo); border: 1px solid var(--borda); border-radius: 10px; padding: .65rem .75rem; width: 100%; resize: vertical; }
fieldset.produtos { border: 1px dashed var(--borda); border-radius: 12px; padding: .7rem; margin: 0 0 .9rem; }
fieldset.produtos legend { font-size: .85rem; color: var(--suave); padding: 0 .3rem; }
.produto-linha { display: grid; grid-template-columns: 1fr 3.6rem 6.2rem; gap: .4rem; margin-bottom: .4rem; }
.produto-linha input { min-height: 40px; padding: .45rem .55rem; }

/* notas fiscais */
#camera video { width: 100%; max-height: 60vh; border-radius: 12px; background: #000; margin-top: .8rem; object-fit: cover; }
.produto-cab { display: grid; grid-template-columns: 1fr 3.6rem 6.2rem; gap: .4rem; font-size: .75rem; color: var(--suave); margin-bottom: .2rem; }
label.check.opcao { align-items: flex-start; background: var(--fundo); border-radius: 10px; padding: .6rem .7rem; margin-bottom: .5rem; }
label.check.opcao input { margin-top: .15rem; flex: none; }
form:not([data-gasto=novo]) .so-novo { display: none; }
.linha-info { display: flex; flex-wrap: wrap; gap: .3rem .9rem; color: var(--suave); font-size: .85rem; margin: 0 0 .6rem; }
label.botao.arquivo { position: relative; overflow: hidden; cursor: pointer; margin: 0; color: var(--texto); }
label.botao.arquivo input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.quem { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.quem .familia { font-size: .72rem; }
.texto-longo h2 { margin-top: 1.2rem; } .texto-longo li { margin-bottom: .4rem; }

/* código de recuperação */
.codigo-rec .codigo { font: 700 1.25rem ui-monospace, Consolas, monospace; letter-spacing: .06em; margin: .5rem 0; padding: .5rem .7rem;
  background: var(--superficie); border: 1px dashed var(--marca); border-radius: 8px; word-break: break-all; user-select: all; }
