/* Cores, fonte e sombras vêm de tokens.css (marca). Aqui só se usam variáveis. */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 var(--mo-fonte);
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}
a { color: var(--green); text-decoration: underline; text-decoration-color: var(--muted); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
/* Barra do app: ícone no lugar do nome, título da tela e ações à direita. */
.appbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: var(--s2);
  min-height: 56px; padding: calc(var(--s2) + env(safe-area-inset-top)) var(--gutter) var(--s2);
  background: var(--panel); box-shadow: var(--sombra-leve);
}
/* logo da marca (mesma da landing) + título da tela, à direita */
.appbar-logo { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text); text-decoration: none; flex: none; }
.appbar-logo b { font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; }
.appbar-title { flex: 1; min-width: 0; margin: 0; font-size: .9rem; font-weight: 600; color: var(--muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-icon { width: 34px; height: 34px; flex: none; }
button.icon-btn {
  background: transparent; color: var(--text); border: 0; border-radius: 12px;
  min-width: 44px; min-height: 44px; padding: 0; display: inline-grid; place-items: center; flex: none;
}
button.icon-btn:hover { background: var(--line); }
.icon-btn svg, .drawer-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Gaveta de navegação: lateral, com ícone e rótulo em cada item. */
dialog.drawer {
  margin: 0; top: 0; left: 0; right: auto; height: 100dvh; max-height: 100dvh;
  width: min(320px, 86vw); border-radius: 0 var(--radius) var(--radius) 0; border-left: 0;
  display: none; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
dialog.drawer[open] { display: flex; }
.drawer-nav { display: flex; flex-direction: column; gap: var(--s1); padding: var(--s3); }
.drawer-nav a {
  display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: 0 var(--s4);
  border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600;
}
.drawer-nav a:hover { background: var(--line); }
.drawer-nav a[aria-current="page"] { background: var(--line); color: var(--green); }
.drawer-nav .badge { margin-left: auto; }
.drawer-foot { margin-top: auto; padding: var(--s4); display: grid; gap: var(--s3); }
.spinner {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--green);
  animation: spin .8s linear infinite;
}
/* O giro é indicador de progresso: continua mesmo com movimento reduzido. */
@media (prefers-reduced-motion: reduce) { .spinner { animation: spin 1.5s linear infinite !important; } }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: var(--s3); padding: var(--s5) 0; color: var(--muted); }
.busy {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s4);
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--sombra-leve);
}
.drawer-help { color: var(--blue); font-weight: 600; text-align: center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.drawer-foot button { width: 100%; }
.conn { color: var(--muted); font-size: 12px; }
.conn.on { color: var(--green); }
.conn.off { color: var(--red); }
nav { margin-left: auto; display: flex; gap: 12px; flex-wrap: wrap; }
nav a { text-decoration: none; font-size: 14px; }
nav a.active { font-weight: 700; }
.view { padding: var(--gutter); max-width: 720px; margin: 0 auto; }
.muted { color: var(--muted); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--sombra-leve);
  padding: var(--s4); margin-bottom: var(--s3);
}
.card > h2, .card > h3 { margin: 0 0 var(--s2); }
.card > p, .dlg-body > p { margin: 0 0 var(--s3); }
.card > :last-child, .dlg-body > :last-child { margin-bottom: 0; }
/* linhas de texto dentro de um card (meta, saldo, legenda) respiram entre si */
.card > div + div { margin-top: var(--s1); }
/* card clicável (envelope) mantém o padding interno do card */
.card.tx-row { padding: var(--s4); border: 1px solid var(--line); border-radius: var(--radius); }
.card.tx-row + .card.tx-row { margin-top: 0; }
.view > :first-child { margin-top: 0; }
h1, h2 { font-weight: 800; }
h3 { font-size: 1rem; font-weight: 600; }
.hero { font-size: 2rem; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
/* Campos: linha fina e sombra suave, sem contorno escuro. Em prefers-contrast: more, a borda volta a ficar forte (tokens.css). */
input:not([type="radio"]):not([type="checkbox"]), select { box-shadow: var(--sombra-leve); }
/* minmax(0, 1fr): a coluna nunca passa da largura da tela, mesmo com texto longo. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.grid > * { margin: 0; min-width: 0; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); } }
.env.locked { opacity: .85; }
.env .label { font-size: 13px; color: var(--muted); }
.env .value { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.env.caixa-pro { background: var(--mo-caixa-pro-bg); border-color: transparent; }
.env.caixa-giro { background: var(--mo-caixa-giro-bg); border-color: transparent; }
.env.caixa-custos { background: var(--mo-caixa-custos-bg); border-color: transparent; }
.env.caixa-blindada { background: var(--mo-caixa-blindada-bg); border-color: transparent; }
.env.caixa-pro .label { color: var(--mo-caixa-pro-text); }
.env.caixa-giro .label { color: var(--mo-caixa-giro-text); }
.env.caixa-custos .label { color: var(--mo-caixa-custos-text); }
.env.caixa-blindada .label { color: var(--mo-caixa-blindada-text); }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.bar > span { display: block; height: 100%; background: var(--green); width: 0; transition: width .4s ease; }
.bar.warn > span { background: var(--amber); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); } .neg { color: var(--red); }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, button {
  font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 44px; max-width: 100%;
}
button { background: var(--action); color: var(--on-action); font-weight: 700; border: 0; border-radius: 999px; cursor: pointer; }
button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toast {
  /* no meio da tela: o retorno de cada ação de formulário aparece no campo de visão */
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--line); padding: 12px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); box-shadow: var(--sombra); font-weight: 600;
  display: flex; gap: 10px; align-items: center; z-index: 60;
  pointer-events: none; /* não bloqueia toques enquanto está na tela */
}
.toast::before { content: "✓"; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; background: var(--green); color: var(--mo-white); font-size: 13px; flex: none; }
.toast[data-tipo="aviso"] { background: var(--aviso-bg); color: var(--amber); border-color: transparent; }
.toast[data-tipo="aviso"]::before { content: "!"; background: var(--amber); }
.toast[data-tipo="erro"] { background: var(--erro-bg); color: var(--red); border-color: transparent; }
.toast[data-tipo="erro"]::before { content: "✕"; background: var(--red); }
.chart-wrap { position: relative; height: 220px; }
.empty { text-align: center; padding: 24px 8px; }
/* Mensagem de erro dentro da tela: bloco com ícone e cor, sem borda grossa. */
.error {
  color: var(--red); background: var(--erro-bg); border-radius: 12px; padding: 10px 12px; margin: var(--s2) 0;
  display: flex; gap: var(--s2); align-items: flex-start; font-weight: 600;
}
.error::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 999px; background: var(--red); color: var(--mo-white); font-size: 12px; }
[hidden] { display: none !important; }

/* ---- v2: classificação, relatórios e configuração em modal ---- */
.cfg { margin-left: auto; padding: 8px 12px; min-height: 36px; font-size: 14px; }
nav { margin-left: 0; }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; font-size: 12px;
  background: var(--badge-bg); color: var(--badge-text); text-align: center; font-weight: 700;
}
dialog {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: 20px; box-shadow: var(--sombra);
  background: var(--panel); color: var(--text);
}
dialog::backdrop { background: var(--overlay); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 1.1rem; }
.dlg-body { padding: 16px; overflow-y: auto; max-height: calc(100dvh - 150px); }
/* Configurações é uma tela (/configurar/<aba>): abas em links, que quebram linha em telas estreitas. */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0 0; border-bottom: 1px solid var(--line); overflow: visible; }
.tabs a[role="tab"] {
  background: transparent; color: var(--muted); border: 0; border-bottom: 3px solid transparent; text-decoration: none;
  border-radius: 0; padding: 10px 8px; min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; white-space: nowrap;
}
.tabs a[role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--green); }
.tabs a[role="tab"]:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.config-body { padding: var(--s4) 0; }
.back { margin: 0 0 var(--s3); font-size: 14px; }
.explain { box-shadow: var(--sombra-leve); }
.explain h3 { margin: 0 0 4px; font-size: 1rem; }
.explain p { margin: 0 0 var(--s2); font-size: 14px; }
.explain p:last-child { margin-bottom: 0; }
.explain .example { color: var(--muted); font-size: 13px; }
.mix-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.mix-row input { width: 96px; text-align: right; }
.sum { font-weight: 700; font-variant-numeric: tabular-nums; }
.sum.ok { color: var(--green); } .sum.bad { color: var(--red); }
.cat-group { margin: 12px 0 4px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cat-list { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
@media (max-width: 480px) { .cat-list { grid-template-columns: 1fr; } }
.cat-list label { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 8px; border: 1px solid var(--line); border-radius: 10px; min-height: 44px; }
.cat-list input { min-height: 0; width: 18px; height: 18px; padding: 0; }
.tx-row { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); cursor: pointer; background: none; color: var(--text); width: 100%; text-align: left; font-weight: 400; min-height: 44px; border-radius: 0; }
.tx-row:hover { background: var(--line); }
.tx-row .meta { font-size: 13px; color: var(--muted); }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); margin: 2px 4px 0 0; color: var(--muted); }
.chip.none { border-style: dashed; color: var(--amber); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
/* lançamento manual: campos com 16px (iOS não amplia) e área de toque de 48px */
.lancamento { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.lancamento .campo { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.lancamento input, .lancamento select { font: inherit; font-size: 16px; min-height: 48px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: inherit; }
.tipo-grupo { border: 0; margin: 0; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.tipo-grupo legend { font-weight: 600; margin-bottom: 6px; }
.tipo-opcao { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.tipo-opcao input { width: 20px; height: 20px; margin: 0; }
.seg button { background: transparent; color: var(--muted); border: 0; border-radius: 0; min-height: 40px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--line); color: var(--text); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-bottom: var(--s3); }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } }
.kpis .card { margin: 0; text-align: center; }
.kpis .label { font-size: 12px; color: var(--muted); }
.kpis .value { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chart-tall { position: relative; height: 260px; }
.chart-bars { position: relative; height: max(160px, calc(var(--n, 4) * 34px)); }
.note { font-size: 13px; color: var(--muted); }
.empty-chart { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-align: center; padding: 12px; }
.danger { background: var(--red-fill); color: var(--on-fill); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 var(--s4); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600;
}
/* Botão de ação: fundo verde e texto branco, mesmo com a classe .btn por cima. */
.btn.btn-green { background: var(--action); color: var(--on-action); border-color: transparent; }
.btn.btn-green:hover { background: var(--mo-action-hover); }
.danger:disabled { background: var(--line); color: var(--muted); }

/* ---- acessibilidade ---- */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
#view:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: var(--gutter); top: -100px; z-index: 10; background: var(--panel); color: var(--text); padding: 10px 14px; border: 1px solid var(--blue); border-radius: 10px; text-decoration: none; }
.skip-link:focus { top: 10px; }
.seg button { min-height: 44px; }
/* Movimento reduzido: sem transições nem animações (também poupa bateria e CPU). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* ---- importação: área de arrastar e soltar ---- */
.dropzone {
  display: grid; justify-items: center; gap: var(--s2); text-align: center;
  border: 1px dashed var(--borda-campo); border-radius: var(--radius); padding: var(--s5) var(--s4);
}
.dropzone.over { border-color: var(--green); background: var(--line); }
.dropzone p { margin: 0; }
.dz-title { font-weight: 700; }
.dz-pick {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 var(--s4); border-radius: 999px; background: var(--action); color: var(--on-action);
  font-weight: 700; cursor: pointer;
}
.dropzone label:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }

.demo-banner { background: var(--aviso-bg); color: var(--amber); border-color: transparent; }

/* ---- marca ---- */

/* ---- tela de entrada ---- */
.login { max-width: 440px; margin: 0 auto; display: grid; gap: var(--s5); justify-items: center; text-align: center; }
.login-logo { width: 104px; height: auto; }
.login h1 { font-size: 1.8rem; margin: 0; line-height: 1.2; }
.login-lead { color: var(--muted); margin: 0; font-size: 1.05rem; }
.login-card { width: 100%; text-align: left; margin: 0; }
.login-card h2 { font-size: 1rem; margin: 0 0 var(--s3); }
.login-card ol, .login-card ul { margin: 0; padding-left: 20px; display: grid; gap: var(--s2); }
.login-card li { color: var(--text); }
.login-card li span { color: var(--muted); }
/* botão oficial "Continuar com o Google": cores exigidas pelo guia da Google, em qualquer tema (exceção à marca) */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--s3);
  width: 100%; min-height: 48px; padding: 0 var(--s4);
  background: #ffffff; color: #1f1f1f; border: 1px solid #747775; border-radius: 10px;
  font: 500 16px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-decoration: none;
}
.google-btn:hover { background: #f8f9fa; }
.google-btn svg { width: 18px; height: 18px; flex: none; }
.login-links { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); justify-content: center; font-size: 14px; }

/* identificação de quem está logado, no topo do menu */
.me { padding: var(--s4); border-bottom: 1px solid var(--line); }
.me-label { margin: 0 0 var(--s1); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.me-name { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.me-email { margin: var(--s1) 0 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.me-link { display: inline-block; margin-top: var(--s2); font-size: 14px; color: var(--blue); }

/* Dica (tooltip) acessível: botão com texto visível; o balão é ligado ao botão. */
.tip { position: relative; display: inline-block; max-width: 100%; }
.tip-btn {
  background: transparent; color: var(--blue); padding: 0 var(--s1); min-height: 44px;
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px; border-radius: 0;
}
.tip-btn:hover { color: var(--text); }
.tip-panel {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; width: min(320px, 80vw);
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  padding: var(--s3) var(--s4); font-size: 14px; line-height: 1.5; font-weight: 400;
  box-shadow: var(--sombra-leve); text-align: left;
}

/* Aviso de erro no meio da tela: calmo, claro, fecha com "Entendi" ou Escape. */
.erro-central {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: var(--s4); background: var(--overlay);
}
.erro-cartao {
  width: min(380px, 100%); background: var(--panel); color: var(--text);
  border: 0; border-radius: 20px;
  padding: var(--s5) var(--s5) var(--s4); box-shadow: var(--sombra);
}
.erro-titulo { font-size: 1.05rem; margin: 0 0 var(--s2); }
.erro-texto { margin: 0 0 var(--s4); color: var(--muted); line-height: 1.5; }
.erro-ok { width: 100%; }
/* Convites na tela Assinatura */
.convite-item { list-style: none; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.convite-item code { display: block; overflow-wrap: anywhere; font-size: 14px; margin-bottom: var(--s2); }
.convite-item.usado { color: var(--muted); }
.convites-lista { padding: 0; margin: var(--s3) 0; }

/* Cartões de plano na landing (no lugar de tabela: lê bem em qualquer largura). */
.plano h3 { margin-bottom: 8px; }
.plano-preco { font-size: 1.6rem; font-weight: 800; margin: 0 0 8px; }
.plano p { margin: 0 0 8px; }

/* Planos da landing: destaque de desconto e do melhor custo por mês. */
.planos-cartoes { margin-top: var(--s4); }
.plano { position: relative; display: flex; flex-direction: column; gap: var(--s2); }
.plano-destaque { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.selo {
  align-self: flex-start; margin: 0; padding: 4px 10px; border-radius: 999px;
  background: var(--action); color: var(--on-action); font-size: 12px; font-weight: 800;
}
.chip-desconto {
  align-self: flex-start; margin: 0; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--green); color: var(--green); font-size: 13px; font-weight: 700;
}
.plano-motivo { margin: 0; font-size: 14px; color: var(--muted); }
.beneficios-plano { margin-top: var(--s5); }
@media (min-width: 900px) { .planos-cartoes { grid-template-columns: repeat(4, 1fr); } }

/* Recibo: marca no topo e impressão só do recibo (ver renderRecibo em js/app.js). */
.recibo-topo { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.recibo-linha { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recibo-rodape { margin-top: 16px; font-size: 13px; }
.pagamentos { list-style: none; padding: 0; margin: 12px 0 0; }
.pagamento-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
@media print {
  body * { visibility: hidden; }
  .recibo, .recibo * { visibility: visible; }
  .recibo { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: 0; }
  .no-print { display: none !important; }
}

/* ---------- casca de aplicativo (PWA): abas no rodapé, folha "Mais", transições ---------- */
/* Comportamento de app nativo: sem puxar para atualizar do navegador, sem brilho de toque,
   sem zoom ao focar campo (16px), áreas seguras do celular respeitadas. */
html, body { overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font-size: 16px; }
body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.appbar {
  position: sticky; top: 0; z-index: 20;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel); box-shadow: var(--sombra-leve);
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end;
  width: 100%; max-width: 720px; margin: 0 auto;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: var(--panel); box-shadow: var(--sombra-tab);
  user-select: none; -webkit-user-select: none;
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 56px; padding: 6px 2px; border: 0; border-radius: 14px;
  background: none; color: var(--muted); font-family: inherit; font-size: 11px; font-weight: 600;
  text-decoration: none; cursor: pointer; transition: transform .12s ease, color .15s ease;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.tab:active { transform: scale(.94); }
.tab-lancar .tab-disco {
  display: flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; margin-top: -26px; border-radius: 50%;
  background: var(--cta); color: var(--cta-text); box-shadow: 0 8px 20px var(--sombra);
}
.tab-lancar .tab-disco svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.4; }
.tab-lancar.active { color: var(--muted); }
.tab-lancar.active .tab-disco { box-shadow: 0 0 0 3px var(--accent), 0 8px 20px var(--sombra); }
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto;
  width: min(560px, 100%); max-width: 100%; max-height: 86vh; overflow: auto;
  border: 0; border-radius: 22px 22px 0 0;
  padding: 0 0 calc(14px + env(safe-area-inset-bottom));
  background: var(--panel); color: var(--text);
  box-shadow: 0 -12px 40px var(--sombra);
}
dialog.sheet[open] { animation: sheetUp .22s ease-out; }
dialog.sheet::backdrop { background: var(--overlay); }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sheet .dlg-head { padding: 10px 20px 6px; }
.sheet .me { margin: 0 20px 8px; }
.sheet-list { list-style: none; margin: 0; padding: 4px 8px; }
.sheet-item {
  display: flex; align-items: center; width: 100%; min-height: 52px; padding: 0 14px;
  border: 0; border-radius: 14px; background: none; color: var(--text);
  font-family: inherit; font-size: 16px; text-align: left; text-decoration: none; cursor: pointer;
}
.sheet-item:active, .sheet-item:hover { background: var(--bg); }
.sheet-foot { padding: 10px 20px 4px; }
.sheet-foot button { width: 100%; min-height: 50px; }
.view > * { animation: viewIn .2s ease-out both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sugestao { color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .view > *, dialog.sheet[open], .tab { animation: none; transition: none; }
}

/* últimos lançamentos com estorno */
.lista-lancamentos { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.linha-lanc { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.linha-lanc strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-lanc .pos { color: var(--accent); font-weight: 700; }
.linha-lanc .neg { color: var(--red); font-weight: 700; }
.linha-lanc button { min-height: 44px; white-space: nowrap; }

/* Aviso do mês no vermelho: texto explicativo, sem alarme (o saldo negativo é o fluxo, não uma dívida). */
.aviso { margin: var(--s3) 0 0; padding: var(--s3); border-radius: 12px; background: var(--aviso-bg); color: var(--amber); font-size: 0.95rem; }

/* Ícone de ajuda: discreto, fora do caminho do toque no cartão, com área de toque de 44 px. */
.com-ajuda { position: relative; }
.com-ajuda > .ajuda-icone { position: absolute; top: 8px; right: 8px; }
.ajuda-icone {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 22px; height: 22px; margin-left: 6px; border-radius: 50%;
  border: 1px solid var(--muted); color: var(--muted); font-weight: 700; font-size: 12px; line-height: 1; font-family: inherit;
  text-decoration: none; opacity: .85; position: relative;
}
.ajuda-icone::after { content: ""; position: absolute; inset: -11px; } /* área de toque de 44 px */
.ajuda-icone:hover, .ajuda-icone:focus-visible { opacity: 1; color: var(--green); border-color: var(--green); }

/* Cartão de instalação: destaque sem alarme, no topo do painel. */
.instalar { border-left: 0; background: var(--panel); }
.instalar h3 { margin: 0 0 var(--s1); }
.instalar .row { align-items: center; justify-content: space-between; }

/* Perguntas frequentes: cada resposta traz onde ver o assunto, com um link direto para a pergunta. */
.faq-onde { margin: var(--s2) 0 0; font-size: 14px; color: var(--muted); }
.faq-onde a { font-weight: 600; }

/* Vídeo da jornada: um bloco simples, com link para o YouTube (sem player embutido). */
.video-jornada { margin: var(--s4) 0; padding: var(--s4); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.video-jornada h2 { margin: 0 0 var(--s2); font-size: 1.25rem; }
.video-jornada p { margin: 0 0 var(--s2); }

/* Mensagem de erro vazia não aparece: nada de bloco vermelho sem texto. */
.error:empty { display: none; }

/* Campos seguem a largura do bloco em que estão, em qualquer tela. */
input, select, textarea { box-sizing: border-box; width: 100%; max-width: 100%; }

/* Resumo do mês: de onde vem o saldo. Linhas com respiro, sem bordas pesadas, cores da marca. */
.mes-resumo { margin-top: var(--s4); padding-top: var(--s3); border-top: 1px solid var(--line); display: grid; gap: var(--s3); }
.mes-linha { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); font-size: 15px; }
.mes-linha b { font-weight: 700; font-variant-numeric: tabular-nums; }
.mes-nome { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text); }
.mes-ponto { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

/* Painel: acabamento dos cartões, do saldo e das caixas (padrão dos prints). */
.card { border-radius: 20px; box-shadow: var(--sombra); }
.hero { font-size: 2.6rem; letter-spacing: -.02em; line-height: 1.1; }
.env { border: none; border-radius: 20px; padding: var(--s4) var(--s4) 18px; }
.env .label { font-size: .875rem; font-weight: 600; text-wrap: balance; }
.env .value { font-size: 1.1rem; margin-top: 6px; letter-spacing: -.01em; padding-right: 28px; white-space: nowrap; }
/* Ritmo dos cartões: títulos e controles não grudam no texto seguinte. */
.card h2, .card h3 { margin: 0 0 var(--s2); }
.row > h2, .row > h3 { margin: 0; }
.card > .row + p, .card > .seg + p { margin-top: var(--s3); }
.row:has(> .seg) { flex: 1 1 100%; }
.seg { display: flex; width: 100%; max-width: 100%; }
.seg button { flex: 1 1 0; min-width: 0; white-space: nowrap; padding: 0 var(--s1); font-size: 14px; }
.pct-campo { flex-wrap: nowrap; align-items: center; gap: var(--s2); }
.pct-campo input { width: 88px; flex: none; }
.bar { height: 12px; }
.bar > span { border-radius: 999px; background: var(--mo-caixa-pro); }
.bar.warn > span { background: var(--amber); }
.com-ajuda:has(.caixa-pro, .caixa-giro, .caixa-custos, .caixa-blindada) > .ajuda-icone { top: auto; bottom: 10px; right: 10px; }

/* ---------- desktop (≥ 900px) com menu: lateral fixa, barra inferior some, conteúdo mais largo ---------- */
/* Só vale quando o menu está visível (usuário logado): login e páginas sem menu seguem como antes. */
@media (min-width: 900px) {
  body:has(#nav:not([hidden])) {
    display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto 1fr;
    min-height: 100dvh; padding-bottom: 0;
  }
  body:has(#nav:not([hidden])) > .appbar { grid-column: 2; grid-row: 1; position: static; }
  body:has(#nav:not([hidden])) > main#view { grid-column: 2; grid-row: 2; min-width: 0; }
  #nav.tabbar:not([hidden]) {
    grid-column: 1; grid-row: 1 / span 2; position: sticky; top: 0; height: 100dvh;
    display: flex; flex-direction: column; align-items: stretch; gap: var(--s1);
    width: auto; max-width: none; margin: 0; padding: var(--s5) var(--s3);
    background: var(--panel); border-right: 1px solid var(--line); box-shadow: none;
  }
  #nav.tabbar:not([hidden]) .tab {
    flex-direction: row; justify-content: flex-start; gap: var(--s3); min-height: 48px;
    padding: 0 var(--s4); border-radius: 12px; font-size: 15px; color: var(--muted);
  }
  #nav.tabbar:not([hidden]) .tab:hover { background: var(--bg); color: var(--text); }
  #nav.tabbar:not([hidden]) .tab.active { background: var(--bg); color: var(--accent); }
  #nav.tabbar:not([hidden]) .tab svg { width: 22px; height: 22px; flex: none; }
  #nav.tabbar:not([hidden]) .tab-lancar { margin-top: var(--s3); }
  #nav.tabbar:not([hidden]) .tab-lancar .tab-disco { width: 22px; height: 22px; margin: 0; box-shadow: none; background: none; color: var(--accent); }
  #nav.tabbar:not([hidden]) .tab-lancar .tab-disco svg { width: 22px; height: 22px; stroke-width: 2; }
  #nav.tabbar:not([hidden]) .tab-lancar.active .tab-disco { box-shadow: none; }
  #nav.tabbar:not([hidden]) .tab-lancar::after { content: none; }
  #nav.tabbar:not([hidden]) .badge { margin-left: auto; }
  #nav.tabbar:not([hidden]) .tab > span:not(.badge):not(.tab-disco) { flex: 1; text-align: left; }
  #nav.tabbar:not([hidden]) .tab-disco { flex: none; }
  body:has(#nav:not([hidden])) .view { max-width: 1040px; padding: var(--s5) var(--s5) var(--s5); }
}
@media (min-width: 1100px) {
  body:has(#nav:not([hidden])) .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.aviso-texto { margin: 0; }
.aviso-texto .ajuda-icone { margin-left: var(--s2); vertical-align: middle; }
