/* Contas — verde-musgo sobre neutros esverdeados; layout de uma coluna pensado para o polegar */
:root {
  --bg: #EEF3F0;
  --surface: #FFFFFF;
  --surface-2: #E4ECE7;
  --line: #D2DDD7;
  --fg: #13201B;
  --muted: #587068;
  --accent: #0F766E;
  --accent-fg: #FFFFFF;
  --ok: #15803D;
  --ok-bg: #DCF2E3;
  --warn: #8F5400;
  --warn-bg: #FCEFD3;
  --bad: #B42318;
  --bad-bg: #FBE3E0;
  --on-bad: #FFFFFF;
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1411;
    --surface: #151F1B;
    --surface-2: #1F2C27;
    --line: #2A3A32;
    --fg: #E6EFEA;
    --muted: #94A89E;
    --accent: #2DD4BF;
    --accent-fg: #05211D;
    --ok: #4ADE80;
    --ok-bg: #12301E;
    --warn: #FBBF24;
    --warn-bg: #3A2C0C;
    --bad: #F87171;
    --bad-bg: #3D1816;
    --on-bad: #2A0B09;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

/* topo */
.topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 8px; }
.mes { display: flex; align-items: center; gap: 2px; min-width: 0; }
.mes h1 { margin: 0; font-size: 1.0625rem; font-weight: 650; padding: 0 6px; text-align: center; min-width: 9.5em; }
.icone {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; flex: none;
}
.icone:hover { background: var(--surface-2); }

/* resumo */
.resumo {
  --on: var(--accent-fg);
  background: var(--accent);
  color: var(--on);
  border-radius: 20px;
  padding: 20px;
  margin: 6px 0 14px;
}
.resumo.neg { background: var(--bad); --on: var(--on-bad); }
.resumo .rotulo { margin: 0; font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; opacity: .85; }
.resumo .saldo { margin: 2px 0 16px; font-size: 2.25rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mini span { display: block; font-size: .75rem; opacity: .85; }
.mini b { display: block; font-size: .9375rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mini .bloco { padding: 0; border: 0; background: transparent; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.nota-form { margin: 0 0 14px; }
.barra { height: 8px; border-radius: 99px; margin-top: 18px; overflow: hidden; background: color-mix(in srgb, var(--on) 28%, transparent); }
.barra i { display: block; height: 100%; border-radius: 99px; background: var(--on); }
.legenda { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 0; font-size: .8125rem; font-variant-numeric: tabular-nums; }

/* convite para instalar */
.instalar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 6px 0 14px; }
.instalar p { margin: 0 0 12px; font-weight: 500; }
.instalar .acoes { margin-top: 0; }

/* avisos */
.aviso { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin: 0 0 14px; font-size: .9375rem; font-weight: 500; }
.aviso svg { flex: none; margin-top: 1px; }
.aviso.bad { background: var(--bad-bg); color: var(--bad); }
.aviso.warn { background: var(--warn-bg); color: var(--warn); }
.aviso.dica { background: var(--surface-2); color: var(--muted); font-weight: 400; }

/* lista */
.lista-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 20px 0 8px; }
.lista-topo h2 { margin: 0; font-size: .8125rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lista-topo output { font-weight: 650; font-variant-numeric: tabular-nums; }
.nota { margin: 0 0 8px; font-size: .8125rem; color: var(--muted); }
.lista { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: grid; grid-template-columns: auto 1fr; align-items: center; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.check { width: 54px; min-height: 64px; border: 0; background: transparent; display: grid; place-items: center; }
.check span {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted);
  display: grid; place-items: center; color: transparent;
}
.item.ok .check span { background: var(--ok); border-color: var(--ok); color: #fff; }
.corpo {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; text-align: left;
  width: 100%; min-width: 0; min-height: 64px; padding: 10px 14px 10px 0; border: 0; background: transparent;
}
.nome { display: block; font-weight: 600; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; font-size: .8125rem; color: var(--muted); }
.valor { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lapis { color: var(--muted); display: grid; place-items: center; }
.item.ok .nome { color: var(--muted); text-decoration: line-through; }
.item.ok .valor { color: var(--muted); }
.chip { padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.neutro { background: var(--surface-2); color: var(--muted); }
.chip.cartao { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.cartoes { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.cartoes li { display: flex; gap: 8px; align-items: baseline; padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; font-size: .875rem; }
.cartoes span { color: var(--muted); font-weight: 600; }
.cartoes b { font-variant-numeric: tabular-nums; }
.vazio-lista { padding: 28px 16px; text-align: center; color: var(--muted); }

/* mês sem dados */
.vazio { margin-top: 24px; padding: 24px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.vazio h2 { margin: 0 0 6px; font-size: 1.125rem; }
.vazio p { margin: 0 0 18px; color: var(--muted); }
.vazio .acoes { flex-direction: column; }

/* navegação inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 5; }
.nav-in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.nav button {
  min-height: 60px; padding: 8px 4px; border: 0; background: transparent; color: var(--muted);
  display: grid; justify-items: center; gap: 2px; font-size: .8125rem; font-weight: 600;
}
.nav button[aria-current="page"] { color: var(--accent); }
.nav .rot { display: inline-flex; align-items: center; gap: 6px; }
.cont { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--fg); font-size: .6875rem; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.novo {
  position: fixed; z-index: 6; right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  height: 52px; padding: 0 20px 0 16px; border: 0; border-radius: 99px;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 650;
  background: var(--accent); color: var(--accent-fg); box-shadow: 0 6px 18px rgb(0 0 0 / .22);
}

/* folha (formulário e menu) */
dialog {
  width: 100%; max-width: 640px; max-height: 92dvh; margin: auto auto 0; padding: 0; overflow: auto;
  border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--fg);
}
dialog::backdrop { background: rgb(5 12 9 / .55); }
.folha {
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.folha h2 { margin: 0 0 16px; font-size: 1.1875rem; }
.campo { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.campo label { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.campo input, .campo select {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 1rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.campo select { color: inherit; }
#f-nome, #f-cat, #f-forma, #c-nome { text-transform: uppercase; }
.rot { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.tipo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tipo label { position: relative; font-size: 1rem; color: var(--fg); }
.tipo input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.tipo span { display: grid; place-items: center; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-weight: 650; }
.tipo input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.tipo input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.lista-cartoes { list-style: none; margin: 0 0 14px; padding: 0; }
.cartao-linha { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.cartao-linha:first-child { border-top: 0; }
.cartao-nome { font-weight: 650; overflow-wrap: anywhere; }
.btn-mini { flex: none; min-height: 40px; padding: 0 12px; font-size: .8125rem; }
.dica-campo { font-size: .8125rem; color: var(--muted); }
.duas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; font-weight: 600; }
.chk input { width: 22px; height: 22px; accent-color: var(--accent); }
.erro { margin: 0 0 12px; color: var(--bad); font-weight: 600; }
.acoes { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1; min-height: 48px; padding: 0 16px; border: 0; border-radius: 12px; font-weight: 650;
  background: var(--accent); color: var(--accent-fg);
}
.btn.sec { background: var(--surface-2); color: var(--fg); }
.btn.perigo { background: var(--bad-bg); color: var(--bad); }
.menu { display: grid; gap: 4px; }
.menu .linha {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  min-height: 52px; padding: 8px 12px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-weight: 600;
}
.menu .linha:hover { background: var(--surface-2); }
.menu small { display: block; font-weight: 400; color: var(--muted); }
.menu input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.rodape-nota { margin: 14px 12px 0; font-size: .8125rem; color: var(--muted); }

#toast {
  position: fixed; z-index: 20; left: 50%; bottom: calc(136px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 99px;
  background: var(--fg); color: var(--bg); font-size: .875rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.on { opacity: 1; }

@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
