/* ===========================================================
   11 · POLISH — PORTE FIEL DO MOCKUP (Apple premium).
   O mockup é CONTIDO: tiles de ícone neutros, barras lime
   monocromáticas (cor só onde tem função: donut/ganho-perda),
   card raio 22, sombras de luz, tipografia precisa. Camada por cima.
   =========================================================== */

/* ---------- CARDS (material do mockup: glass no topo + sombra de luz) ---------- */
.card, .card.ikpi, .rz-card, .rz-kpi {
  background:
    linear-gradient(180deg, rgba(255,255,255,.022), rgba(255,255,255,0) 38%),
    var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-xl) !important;
  /* corner-shape já era herdado do .card de 03-cards-hero.css (camada anterior) —
     explícito aqui pq é ESTA camada (11-polish) que de fato vence o border-radius. */
  corner-shape: superellipse(2);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.045),
    0 1px 2px rgba(0,0,0,.18),
    0 24px 50px -28px rgba(0,0,0,.8) !important;
  padding: 16px 18px;
}
:root[data-theme="light"] .card,
:root[data-theme="light"] .card.ikpi,
:root[data-theme="light"] .rz-card,
:root[data-theme="light"] .rz-kpi {
  background:
    linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,0) 42%),
    var(--bg-elevated) !important;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    0 1px 2px rgba(120,100,70,.05),
    0 16px 32px -18px rgba(90,80,60,.22) !important;
}

/* ---------- HEROES: raio generoso + brilho de borda ---------- */
.rz-hero {
  border-radius: var(--radius-2xl) !important;
  corner-shape: superellipse(2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), var(--shadow) !important;
}

/* ---------- TIPOGRAFIA (valores do mockup) ---------- */
/* números grandes: peso e tracking caprichados */
.rz-hero-amt {
  font-weight: 800 !important; letter-spacing: -.04em !important;
}
.ikpi-v, .rz-kpi-v {
  font-weight: 800 !important; letter-spacing: -.03em !important;
}
/* PADRÃO inegociável: todo valor numérico em Geist Mono (consistência no app inteiro) */
.ikpi-v,
.rz-kpi-v,
.inv-asset-val,
.ticker-val,
.exp-cat-amt {
  font-family: 'Geist Mono', monospace !important;
}
/* títulos de card */
.card-head h3 { font-weight: 700 !important; letter-spacing: -.01em !important; }
/* micro-labels uppercase — tracking do mockup (.09em) */
.ikpi-k,
.card-head .meta,
.rz-kpi-l {
  letter-spacing: .09em !important; font-weight: 700;
}

/* ---------- CONTENÇÃO: categorias do mockup (despesas) ----------
   tiles NEUTROS + barra LIME monocromática + % discreto.
   (cor reservada pra donut/ganho-perda — disciplina Apple) */
.exp-cat-icon {
  background: var(--bg-elevated-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--ink-2) !important;
  border-radius: 10px !important;
}
.exp-cat-row:hover .exp-cat-icon {
  transform: none !important;
  background: var(--bg-elevated-3) !important;
}
.exp-cat-name { font-size: var(--fs-body) !important; color: var(--ink) !important; font-weight: 600; }
.exp-cat-bar {
  height: 6px !important;
  background: var(--bg-elevated-2) !important;
  border-radius: 999px !important;
}
.exp-cat-row:not(.over-budget) .exp-cat-bar i {
  background: linear-gradient(90deg, var(--purple-deep), var(--purple)) !important;
  box-shadow: none !important;
  border-radius: 999px !important;
}
/* a maior categoria ganha um glow lime sutil (igual o "top" do mockup) */
.exp-cat-row:not(.over-budget):first-of-type .exp-cat-bar i {
  background: linear-gradient(90deg, var(--purple), var(--purple-light)) !important;
  box-shadow: 0 0 14px -2px var(--purple-glow) !important;
}
.exp-cat-pct { color: var(--ink-3) !important; }
.exp-cat-amt { color: var(--ink) !important; }

/* ---------- RESPIRO + DIVISORES ---------- */
.cat-list .exp-cat-row { padding: 7px 0 !important; }
/* card-head mais enxuto */
.card-head { margin-bottom: 12px !important; }
.exp-cat-icon { width: 30px !important; height: 30px !important; }
.exp-cat-icon .icn { width: 15px !important; height: 15px !important; }

/* ---------- HOVER tátil (sutil) ---------- */
@media (hover: hover) and (pointer: fine) {
  .card, .card.ikpi, .rz-kpi {
    transition: transform .4s var(--ease-out), box-shadow .4s var(--ease-out), border-color .4s ease;
  }
  .card:hover, .card.ikpi:hover, .rz-kpi:hover {
    transform: translateY(-2px);
    border-color: var(--border-2) !important;
    box-shadow:
      inset 0 1px 0 rgba(255,255,255,.06),
      0 2px 4px rgba(0,0,0,.2),
      0 34px 60px -30px rgba(0,0,0,.85) !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  .card:hover, .card.ikpi:hover, .rz-kpi:hover { transform: none; }
  /* DS audit M-3: cobertura TOTAL — os blocos pontuais não alcançavam as 44 animações
     (spin/scan/pulse/breathing/drift continuavam rodando). Mata tudo de uma vez. */
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* DS audit M-3: foco de teclado visível (não existia NENHUM :focus-visible no app).
   Anel lime só via teclado — clique/touch não mostra. */
:is(button, a, input, select, textarea, [tabindex], summary):focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
  border-radius: var(--radius-sm, 8px);
}
.exp-table tbody tr:focus-visible { outline: 2px solid var(--purple); outline-offset: -2px; }

/* DS audit (componentes): classes pros inline styles estáticos do app.js */
.err-pop-body { white-space: pre-wrap; word-break: break-word; font-family: 'Geist Mono', monospace; font-size: var(--fs-micro); line-height: 1.5; background: color-mix(in oklab, var(--bg) 60%, transparent); border: 1px solid var(--border); border-radius: 10px; padding: var(--sp-3); max-height: 300px; overflow: auto; color: var(--ink-2); margin: 0; }
.pill-count { display: inline-block; padding: 2px 7px; background: var(--purple-soft); color: var(--purple-light); border-radius: 8px; font-size: 10px; font-weight: 700; margin-left: 6px; font-family: 'Geist Mono', monospace; }

/* DS (aprovado no provador): skeleton shimmer — números viram blocos pulsantes no sync */
.skel { color: transparent !important; border-radius: 8px; user-select: none; pointer-events: none;
  background: linear-gradient(100deg, var(--bg-elevated-2) 40%, var(--bg-elevated-3) 50%, var(--bg-elevated-2) 60%);
  background-size: 200% 100%; animation: skel-shimmer 1.4s linear infinite; }
.skel * { visibility: hidden; }
@keyframes skel-shimmer { to { background-position: -200% 0; } }

@keyframes val-updating-pulse { 50% { opacity: .32; } }

/* DS (aprovado no provador): tooltip de termo técnico (TWR, CDI...) — hover/focus, CSS puro */
.tip-term { position: relative; border-bottom: 1px dashed currentColor; cursor: help; }
/* ancorado à ESQUERDA do termo (não centralizado): o "TWR" fica na borda
   esquerda do hero, que tem overflow:hidden — centralizar estourava pra fora
   e cortava o tooltip por cima do número. Ancorado, abre pra direita, dentro do card. */
.tip-term::after { content: attr(data-tip); position: absolute; bottom: 130%; left: 0;
  transform: translateY(4px); width: max-content; max-width: 260px; white-space: normal;
  background: var(--bg-elevated-3); border: 1px solid var(--border-strong); color: var(--ink);
  font: 500 11px/1.5 Inter, system-ui, sans-serif; letter-spacing: 0; text-transform: none;
  padding: 7px 11px; border-radius: 9px; box-shadow: var(--shadow-lg); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .18s var(--ease-out), transform .18s var(--ease-out); }
.tip-term:hover::after, .tip-term:focus-visible::after { opacity: 1; transform: translateY(0); }


/* Histórico anual em popup (pedido do dono) */
#historyModal .yearly-table { width: 100%; }

/* Pedido da Flávia: toggle Fixas/Variáveis ao lado da busca (segmented compacto) */
/* B redesign — unified iOS segmented control (shared with .rz-seg, .range-toggle).
   Neutral track + raised neutral "thumb" on the active segment (NOT accent-colored). */
.exp-nat-filter { display: inline-flex; height: 34px; gap: 0; padding: 2px; background: var(--bg-elevated-2); border: none; border-radius: 10px; flex-shrink: 0; }
.exp-nat-filter button { display: inline-flex; align-items: center; justify-content: center; border: none; background: transparent; color: var(--ink-3); font: 600 13px/1 Inter, system-ui, sans-serif; padding: 0 14px; border-radius: 8px; cursor: pointer; transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out); white-space: nowrap; }
.exp-nat-filter button:hover { color: var(--ink); }
.exp-nat-filter button.on { background: var(--bg-elevated-3); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.28); }

/* Filtros — opção 1 (escolha do dono): toolbar refinada.
   Busca protagonista (atalho "/"), selects viram chips com chevron que acendem
   em lime quando têm filtro ativo, CSV vira ícone-só. Alturas alinhadas (~32px). */
.exp-table-tools { gap: var(--sp-2); }
.exp-search { flex: 1 1 220px; }
.srch-kbd { font: 600 10px 'Geist Mono', monospace; background: color-mix(in oklab, var(--ink-3) 10%, transparent); border: 1px solid var(--border); border-radius: 5px; padding: 2px 6px; color: var(--ink-3); flex-shrink: 0; }
@media (hover: none) { .srch-kbd { display: none; } }   /* touch não tem teclado à vista */
.exp-filter {
  appearance: none; -webkit-appearance: none;
  background-color: transparent; border: 1px solid var(--border-2); border-radius: 9px;
  padding: 7px 26px 7px 11px; font: 600 11.5px Inter, system-ui, sans-serif; color: var(--ink-2);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9c90' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 11px;
}
.exp-filter:hover { border-color: var(--border-strong); color: var(--ink); }
.exp-filter.on { border-color: color-mix(in oklab, var(--purple) 45%, transparent); background-color: color-mix(in oklab, var(--purple) 10%, transparent); color: var(--purple); }
/* botão "Limpar filtros" (pedido do dono) — chip discreto que só aparece com filtro ativo */
.exp-filter-clear { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 1px solid color-mix(in oklab, var(--loss) 30%, transparent); border-radius: 9px; padding: 7px 11px; color: var(--loss); font: 600 11.5px Inter, system-ui, sans-serif; cursor: pointer; white-space: nowrap; transition: background .15s; }
.exp-filter-clear:hover { background: var(--loss-soft); }
.exp-filter-clear[hidden] { display: none; }
.btn-csv { width: 32px; height: 32px; padding: 0 !important; justify-content: center; border-radius: 9px; }
.btn-csv span { display: none; }
/* P4 (v9.9): no mobile os filtros colapsam atrás de um ícone (ver media query ≤480) */
.exp-filters-pop { display: contents; }
.exp-filter-toggle { display: none; }

/* DS Fase 3: alvos de toque ≥44px nas ações frequentes do mobile */
@media (max-width: 719.98px) {
  .month-nav button, .exp-monthnav button, .imp-monthsel-nav button { width: 44px; height: 44px; }
  .contrib-edit, .contrib-del { width: 40px; height: 40px; }
}

/* ===========================================================
   BENTO da aba Despesas (≥900px) — igual o mockup:
   hero (saldo) + coluna de stats lado a lado; depois
   "Por categoria" + "Todas as despesas" lado a lado.
   Escopo em #moduleExpenses.active pra não quebrar o show/hide.
   =========================================================== */
@media (min-width: 900px) {
  #moduleExpenses.active {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--sp-4);
    align-items: start;   /* cada card na altura natural — sem esticar/vazar */
  }
  /* por padrão tudo é full-width (blinda contra filhos não previstos) */
  #moduleExpenses.active > * { grid-column: 1 / -1; margin: 0; }
  /* linha 2: categoria (5) + tabela (7) */
  /* v11.2 (escolha do dono): os dois cards EXATAMENTE da mesma altura. Categorias (top 7,
     natural) DEFINE a altura; o card de lançamentos é igualado por JS (syncPanelHeights) e a
     lista clipa com FADE embaixo (sem scrollbar), com "Ver todas" fixo no rodapé. */
  #moduleExpenses.active > .exp-g-cat   { grid-column: span 5; margin: 0; align-self: start; }
  #moduleExpenses.active > .exp-g-cat .cat-list { display: flex; flex-direction: column; gap: 3px; }
  #moduleExpenses.active > .exp-g-cat .exp-cat-more { margin-top: 8px; }
  #moduleExpenses.active > .exp-g-table { grid-column: span 7; margin: 0; align-self: start; }
  /* a lista usa max-height (setado por JS = altura das categorias) + clip; NÃO flex (flex-basis:0
     colapsava a lista pra zero). Só no Painel desktop. */
  #moduleExpenses.active:not(.view-lancamentos):not(.view-ganhos):not(.view-categorias) > .exp-g-table .table-wrap { overflow: hidden; }
  #moduleExpenses.active:not(.view-lancamentos):not(.view-ganhos):not(.view-categorias) > .exp-g-table .table-wrap.is-clipped { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 22px), transparent); }
}

/* popup "Todas as categorias" (v11) — lista rolável reusando .exp-cat-row */
#catAllModal .cd-scroll#catAllList { display: flex; flex-direction: column; gap: 4px; padding: 2px 2px 0; }
#catAllModal .exp-cat-row { animation: none; }
/* "Ver todas (N)" da tabela de despesas — mostra as primeiras, expande o resto */
.exp-row-extra { display: none !important; }
.exp-row-more-tr td { padding: 0 !important; border: 0 !important; background: transparent !important; }
.exp-row-more {
  width: 100%; margin-top: 6px; padding: 11px; border: 0; border-top: 1px solid var(--border);
  background: transparent; color: var(--ink-3); cursor: pointer;
  font: 700 11px Inter, system-ui, sans-serif; letter-spacing: .07em; text-transform: uppercase;
  transition: color .15s;
}
.exp-row-more:hover { color: var(--purple); }
/* v11.2: "Ver todas" como rodapé FIXO do card de lançamentos (Painel) */
.exp-panel-more { flex: 0 0 auto; width: 100%; margin-top: 6px; padding: 12px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--ink-3); cursor: pointer; font: 700 11px Inter, system-ui, sans-serif; letter-spacing: .07em; text-transform: uppercase; transition: color .15s; }
.exp-panel-more:hover { color: var(--purple); }
.exp-panel-more[hidden] { display: none; }
/* ===== Resumo por forma de pagamento (faixa da aba Despesas/Lançamentos) ===== */
#paySummary { display: none; }
#moduleExpenses.view-lancamentos > #paySummary:not([hidden]) { display: block; }
/* Opção A minimal (escolha do dono): SEM caixa de card — faixa inline acima da lista */
.pay-summary { padding: 2px 2px 14px; margin-bottom: 4px; }
.pay-lbl { font: 700 10px Inter, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 9px; }
/* v11.34.3: os totais viraram cartõezinhos (.pay-tile, seção do seletor de pessoa e cartão em 16-leve.css);
   o .pay-ic abaixo fica porque Contas a pagar usa a mesma classe */
.pay-ic { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; flex-shrink: 0;
  position: relative; overflow: hidden;
  color: var(--pay-c); background: color-mix(in oklab, var(--pay-c) 15%, transparent);
  transition: background .2s ease, color .2s ease; }
.pay-ic svg { width: 11px; height: 11px; }

/* v9 — Conferência: o total do título conta o que pede conferência no mês. Alerta só em âmbar. */
.pay-sum { font: 700 11px Inter, system-ui, sans-serif; color: var(--warn); letter-spacing: 0; text-transform: none; }
/* bloco "Para conferir" dentro do drill-down (#catDetailModal) */
.cd-confer > td { padding: 2px 0 10px !important; }
.cf-h { font: 700 10px Inter, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 2px 2px 8px; }
.cf-flag { border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--bg-elevated-3); }
.cf-flag.sev-dica { border-left-color: var(--ink-3); }
.cf-t { font-size: 13px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cf-delta { font: 700 10.5px 'Geist Mono', monospace; color: var(--warn); background: var(--warn-soft); border-radius: 5px; padding: 1px 6px; }
.cf-d { font-size: 12px; color: var(--ink-2); margin: 5px 0 2px; line-height: 1.45; }
.cf-mem { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-top: 5px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 12px; }
.cf-mem:hover { border-color: var(--ink-3); }
.cf-mem.manter { border-left: 3px solid var(--gain); }
.cf-mem .cf-md { color: var(--ink-3); font-size: 11px; min-width: 68px; flex-shrink: 0; }
.cf-mem .cf-mdesc { flex: 1; min-width: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-mem .cf-mtag { font: 700 9px Inter, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); flex-shrink: 0; }
.cf-mem.manter .cf-mtag { color: var(--gain); }
.cf-mem .cf-mv { font-weight: 700; flex-shrink: 0; }
.cf-acts { margin-top: 9px; }
.cf-btn { font: 600 11.5px Inter, system-ui, sans-serif; border: 1px solid var(--border); background: var(--bg-elevated); color: var(--ink-2); border-radius: 999px; padding: 5px 13px; cursor: pointer; }
.cf-btn:hover { color: var(--ink); border-color: var(--ink-3); }

/* v9 — Revisar duplicados (Faxina): entrada abaixo da faixa + modal + soft-delete reversível */
.dup-entry { display: none; align-items: center; gap: 9px; width: 100%; text-align: left; background: var(--bg-elevated-3); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin: 4px 0 2px; cursor: pointer; }
#moduleExpenses.view-lancamentos > #dupEntry:not([hidden]) { display: flex; }
.dup-entry:hover { border-color: var(--ink-3); }
.dup-entry .dup-entry-ic { width: 18px; height: 18px; display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; }
.dup-entry .dup-entry-ic svg { width: 16px; height: 16px; }
.dup-entry .dup-entry-lbl { font: 600 13px Inter, system-ui, sans-serif; color: var(--ink); }
.dup-entry .dup-entry-badge { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font: 700 11px 'Geist Mono', monospace; color: var(--ink-2); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; }
.dup-entry .dup-entry-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--warn); }
.dup-scope { display: flex; gap: 4px; background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin: 0 0 6px; width: fit-content; max-width: 100%; flex-wrap: wrap; }
/* min-height 38px (era ~27px) pra alvo de toque nos filtros de escopo da Faxina */
.dup-scope button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; font: 600 12px Inter, system-ui, sans-serif; color: var(--ink-3); background: transparent; border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.dup-scope button.on { background: var(--bg-elevated); color: var(--ink); }
.dup-scroll { max-height: 56vh; }
.du-empty { text-align: center; color: var(--ink-2); padding: 28px 12px; font-size: 13px; }
.du-empty-sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.du-clu { border: 1px solid var(--border); border-radius: 12px; margin: 9px 0; overflow: hidden; background: var(--bg-elevated); }
/* v9.22 — Faxina enxerga o par fixa×real (caso MYS) + contadores por escopo nos pills */
.du-conf.info { color: var(--warn); }
.du-row.info { opacity: .78; }
.du-tag.prev { background: var(--bg-elevated-3); color: var(--ink-2); border-radius: 5px; padding: 1px 7px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.du-open-tpl { margin-left: auto; flex-shrink: 0; border: 1px solid var(--border-2); background: transparent; color: var(--accent); font: 600 12px Inter, system-ui, sans-serif; border-radius: 8px; padding: 5px 10px; cursor: pointer; transition: background var(--t-fast) ease; }
.du-open-tpl:hover { background: var(--accent-soft); }
.du-n { margin-left: 6px; min-width: 17px; padding: 1px 5px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font: 700 10.5px 'Geist Mono', monospace; display: inline-grid; place-items: center; }
/* v9.3 — vereditos do casal: "Não é duplicado"/"Dispensar" + linha de dispensado com Desfazer */
.du-notdup { margin-left: auto; flex-shrink: 0; border: 1px solid var(--border); background: transparent; color: var(--ink-3); font: 600 11.5px Inter, system-ui, sans-serif; border-radius: 8px; padding: 4px 9px; cursor: pointer; transition: all var(--t-fast) ease; }
.du-notdup:hover { color: var(--ink); border-color: var(--border-2); background: var(--bg-elevated-2); }
.du-notdup + .du-open-tpl, .du-notdup + .du-save { margin-left: 8px; }   /* o auto fica no notdup quando ele existe */
.du-dismissed { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-size: 12.5px; color: var(--ink-3); }
.du-undo-dis { border: none; background: transparent; color: var(--accent); font: 600 12.5px Inter, system-ui, sans-serif; cursor: pointer; padding: 2px 4px; }
/* v9.3 — banner de auto-update (aparece só quando não é seguro recarregar sozinho) */
.upd-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 210; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; background: var(--bg-elevated-2); border: 1px solid var(--border-2); border-radius: 14px; box-shadow: var(--shadow-lg); font-size: 13px; color: var(--ink); max-width: min(92vw, 420px); }
.upd-banner button { border: none; border-radius: 9px; background: var(--accent); color: var(--on-accent); font: 600 12.5px Inter, system-ui, sans-serif; padding: 8px 14px; cursor: pointer; flex-shrink: 0; }
.upd-banner button:hover { background: var(--accent-hover); }
.dup-scope button.on .du-n { background: var(--on-accent); color: var(--accent); }
.du-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--bg-elevated-3); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.du-conf { display: inline-flex; align-items: center; gap: 5px; font: 700 9px Inter, system-ui, sans-serif; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.du-conf .du-mk { width: 9px; height: 9px; border-radius: 999px; }
.du-conf.hi .du-mk { background: var(--warn); }
.du-conf.lo .du-mk { box-shadow: inset 0 0 0 1.5px var(--ink-3); }
.du-mer { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.du-kind { font-size: 11px; color: var(--ink-3); }
.du-save { margin-left: auto; font-weight: 700; font-size: 12.5px; color: var(--loss); }
.du-why { font-size: 11.5px; color: var(--ink-3); padding: 8px 12px 4px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.du-delta { font: 700 10.5px 'Geist Mono', monospace; color: var(--warn); background: var(--warn-soft); border-radius: 5px; padding: 1px 6px; }
.du-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 12.5px; cursor: pointer; }
.du-row + .du-row { border-top: 1px solid var(--border); }
.du-row .du-d { color: var(--ink-3); font-size: 11px; min-width: 70px; flex-shrink: 0; }
.du-row .du-ds { flex: 1; min-width: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.du-row .du-tag { font: 700 9px Inter, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .03em; flex-shrink: 0; }
.du-row .du-v { font-weight: 700; color: var(--ink); flex-shrink: 0; }
.du-row .du-chk { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--warn); cursor: pointer; }
.du-row .du-chk-sp { width: 18px; flex-shrink: 0; }
.du-row.keep { background: color-mix(in srgb, var(--gain) 7%, transparent); border-left: 3px solid var(--gain); }
.du-row.keep .du-tag { color: var(--gain); }
.du-row.rem .du-tag { color: var(--warn); }
.du-row.rem.checked .du-ds, .du-row.rem.checked .du-v { text-decoration: line-through; opacity: .55; }
.du-row.rem:not(.checked) { opacity: .62; }
.dup-foot { flex-wrap: wrap; gap: 10px; }
/* min-height 38px (era ~29px) pra alvo de toque em "Selecionar todos sugeridos" */
.dup-sel { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; font: 600 12px Inter, system-ui, sans-serif; color: var(--ink-2); background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.dup-sel:hover { color: var(--ink); }
.dup-tally { font-weight: 700; font-size: 13px; color: var(--ink); }
.dup-undo-last { font: 600 12px Inter, system-ui, sans-serif; color: var(--ink-3); background: transparent; border: 0; text-decoration: underline; cursor: pointer; }
/* z-index: 1 degrau acima do --z-toast normal — este toast de undo pode aparecer
   por cima do fluxo de revisão de duplicados (que já usa modal/overlay em z alto). */
.dup-undo-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); border-radius: 12px; padding: 11px 16px; font-size: 13px; display: none; align-items: center; gap: 14px; z-index: calc(var(--z-toast) + 1); box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); }
.dup-undo-toast.show { display: flex; }
.dup-undo-toast .du-toast-undo { background: transparent; border: 1px solid color-mix(in srgb, var(--bg) 45%, transparent); color: var(--bg); border-radius: 999px; padding: 4px 12px; font: 600 12px Inter, system-ui, sans-serif; cursor: pointer; flex-shrink: 0; }
@media (max-width: 899.98px) {
  .pay-ic { width: 28px; height: 28px; border-radius: 8px; }
  .pay-ic svg { width: 14px; height: 14px; }
}

/* ===== Sub-abas de Despesas (Painel | Lançamentos | Categorias) ===== */
/* B redesign — underline tab bar (Painel | Despesas | Ganhos | Categorias).
   Inactive label ink-3, active label ink with a 2px accent-blue underline indicator. */
.exp-subnav { display: inline-flex; gap: var(--sp-2); padding: 0; margin-bottom: 18px; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.exp-subnav button { border: 0; background: transparent; color: var(--ink-3); font: 600 13px Inter, system-ui, sans-serif; padding: 9px 4px; border-radius: 0; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out); }
.exp-subnav button:hover { color: var(--ink); }
.exp-subnav button.on { background: transparent; color: var(--ink); border-bottom-color: var(--accent); box-shadow: none; }
/* foco: sem caixa no TOQUE (o focus-ring seguia o border-radius e virava caixa arredondada
   sobre a aba ativa no iOS); anel limpo só no teclado via :focus-visible. */
.exp-subnav button:focus { outline: none; }
.exp-subnav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* DS audit QW-3 (escolha do dono: opção B) — no celular a pílula estourava (~380px) e
   "Categorias" ficava clipada. Vira grade 2×2: tudo visível, alvo de toque grande. */
@media (max-width: 480px) {
  /* P6 (v9.9): sub-abas viram linha única com sublinhado lime (rolável) */
  .exp-subnav { display: flex; width: 100%; gap: 2px; padding: 0; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .exp-subnav button { flex: 0 0 auto; padding: 9px 12px; border-radius: 0 !important; text-align: center; white-space: nowrap; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .exp-subnav button.on { background: transparent; color: var(--ink); border-bottom-color: var(--accent); box-shadow: none; }
  .exp-subnav-row { gap: 10px; }
  .exp-monthnav { width: 100%; justify-content: center; }
}
/* Mobile (pedido do dono): sub-abas + mês FIXOS no topo ao rolar. v11.35.1: o fundo é sólido, da cor da página,
   e a faixa termina num degradê curto, como a barra de baixo. Antes ela era translúcida com desfoque e crescia
   8 px para baixo: parada, cobria o topo do que vinha depois ("Despesas · Ganhos" em Lançamentos, o primeiro
   cartão de Saldos); rolando, o conteúdo aparecia por trás do mês. Agora a caixa acaba no último controle e o
   bloco seguinte dá o próprio respiro (10 ou 12 px, onde o degradê de 8 px cabe). O id vence a margem da regra
   geral, que vem depois no arquivo. */
@media (max-width: 719.98px) {
  #moduleExpenses .exp-subnav-row {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 60;
    background: var(--bg);
    padding: calc(var(--sp-2) + 4px) var(--sp-2) 0; margin: calc(-1 * var(--sp-2) - 4px) calc(-1 * var(--sp-2)) 0;
  }
  #moduleExpenses .exp-subnav-row::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 8px; background: linear-gradient(to bottom, var(--bg), transparent); pointer-events: none; }
  /* tiles de Investimentos: 3 lado a lado cortava o "Dólar" — 2+1 (último inteiro) */
  .inv-kpis.three { grid-template-columns: 1fr 1fr !important; }
  .inv-kpis.three > .card:last-child { grid-column: 1 / -1; }
  /* .exp-subnav-row cresce ~8px pra cada lado (padding + negative margin acima) e,
     por ser sticky, sua borda inferior clipava o topo do rótulo "Resumo por forma
     de pagamento" logo abaixo (Despesas › Lançamentos, em repouso). Dá respiro. */
  .pay-summary { margin-top: 14px; }
}

/* editor de categorias só na sub-aba Categorias */
#moduleExpenses > #expCategorias { display: none; }
/* Lançamentos: só a tabela */
#moduleExpenses:is(.view-lancamentos, .view-ganhos) > .exp-g-cat,
#moduleExpenses:is(.view-lancamentos, .view-ganhos) > .grid-2 { display: none !important; }
/* Categorias: só o editor */
#moduleExpenses.view-categorias > .exp-g-cat,
#moduleExpenses.view-categorias > .exp-g-table,
#moduleExpenses.view-categorias > .grid-2 { display: none !important; }
#moduleExpenses.view-categorias > #expCategorias { display: block !important; }
@media (min-width: 900px) {
  #moduleExpenses.active:is(.view-lancamentos, .view-ganhos) > .exp-g-table { grid-column: 1 / -1 !important; }
}
#expCategorias .cat-view-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
/* sub-aba é tela cheia: expande tudo, sem barra de rolagem interna */
#expCategorias .cat-edit-list { max-height: none !important; overflow: visible !important; padding-right: 0; gap: 9px; }
/* ícones neutros (padrão da contenção) — a cor fica no seletor de cor à direita */
.cat-edit-ic { color: var(--ink-2); }

/* ===== Aba Investimentos — PORTE DO HERO DO MOCKUP =====
   hero full-width com 5 mini-KPIs DENTRO (Lucro TWR · Dividendos · Reservas ·
   Previdência · Aportes) + sparkline à direita + pill "no mês"; abaixo 3 tiles
   (Variação · Aplicado · Dólar). Volta ao flex-column do 02-layout (sem grid). */
.inv-kpis.three { grid-template-columns: repeat(3, 1fr) !important; }
.hero-mini-kpis { display: flex; gap: 30px; flex-wrap: wrap; margin-top: 20px; position: relative; z-index: 1; }
.hero-mini-kpis .k { font-size: var(--fs-caption); color: var(--hero-label); font-weight: 600; }
.hero-mini-kpis .v { font-size: var(--fs-value); font-weight: 700; font-family: 'Geist Mono', monospace; margin-top: 3px; color: var(--hero-ink); }

.hstat { flex: 1 1 21%; padding: 0 18px; border-left: 1px solid rgba(255,255,255,.14); min-width: 120px; }
.hstat:first-child { border-left: 0; padding-left: 0; }
@media (max-width: 719.98px) { .hstat { border-left: 0; padding: 0; } }


.hero-pill { position: absolute; top: 24px; right: 26px; z-index: 2; background: rgba(255,255,255,.16); color: var(--hero-ink); backdrop-filter: blur(8px); font-weight: 700; font-size: var(--fs-body); padding: 6px 12px; border-radius: var(--radius-pill); }
.ikpi.tile .ikpi-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 7px; font-weight: 500; min-height: 1px; }
.ikpi.tile .ikpi-v { font-size: var(--fs-display); }
.ikpi.tile .ikpi-v.pos { color: var(--gain) !important; }
.ikpi.tile .ikpi-v.neg { color: var(--loss) !important; }

/* ===== Investimentos: carteira pareada c/ donut, dividendos no topo, Análise igual ===== */
@media (min-width: 1000px) {
  /* Análise: cards 2×2 todos da MESMA altura, sem vão (o .card tinha margin-bottom:14px) */
  #moduleInvestments .inv-charts { align-items: stretch; grid-auto-rows: 1fr; }
}

/* ===== Carteira A (escolha do dono): donut+legenda = CABEÇALHO do card da carteira ===== */
.inv-asset { display: flex; align-items: center; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.inv-asset:last-child { border-bottom: 0; }
.inv-tk { width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px; background: var(--bg-elevated-2); border: 1px solid var(--border); display: grid; place-items: center; font: 700 11px 'Geist Mono', monospace; color: var(--ink-2); }
.inv-asset-mid { flex: 1; min-width: 0; }
.inv-asset-nm { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.inv-asset-q { font-size: var(--fs-caption); color: var(--ink-3); margin-top: 2px; }
.inv-asset-rt { text-align: right; }
.inv-asset-val { font-family: 'Geist Mono', monospace; font-weight: 700; font-size: 14.5px; color: var(--ink); }
.inv-asset-chg { font-family: 'Geist Mono', monospace; font-weight: 600; font-size: 12.5px; margin-top: 2px; }
.inv-asset-chg.pos { color: var(--gain); }
.inv-asset-chg.neg { color: var(--loss); }

/* ===========================================================
   RESUMO — PORTE DO MOCKUP: gauge + 4 KPIs + ganhos×saídas +
   onde foi o dinheiro (donut) + patrimônio/ano + meta.
   =========================================================== */

/* BUG FIX: o modal de confirmação (excluir) abria ATRÁS do modal de despesa
   (mesmo z-index 100 + vinha antes no DOM). Sobe ele pra cima de tudo. */
#confirmModal.modal-bg { z-index: 160 !important; }

/* Aba/modal Importações — histórico com desfazer por lote */
.imports-list { display: flex; flex-direction: column; gap: 9px; margin: 4px 0 8px; max-height: 56vh; overflow-y: auto; }
.imports-empty { color: var(--ink-3); font-size: var(--fs-body); text-align: center; padding: 30px 10px; }
.imports-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated-2); }
.imports-item.is-gone { opacity: .55; }
.imports-ic { width: 38px; height: 38px; border-radius: 10px; background: color-mix(in oklab, var(--ink-3) 10%, transparent); display: flex; align-items: center; justify-content: center; color: var(--ink-2); flex-shrink: 0; }   /* ícone SVG neutro (DS: sem emoji) — renomeado de .imports-emoji (nome desatualizado, não é mais emoji) */
.imports-info { flex: 1; min-width: 0; }
.imports-t { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.imports-m { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.imports-m b { color: var(--ink-2); font-weight: 600; }
.imports-undo { flex-shrink: 0; font: 600 12px Inter, system-ui, sans-serif; border: 1px solid color-mix(in oklab, var(--loss) 38%, transparent); color: var(--loss); background: transparent; border-radius: 9px; padding: 7px 14px; cursor: pointer; transition: background .15s, color .15s; }
.imports-undo:hover:not([disabled]) { background: var(--loss); color: #fff; }
.imports-undo[disabled] { opacity: .5; cursor: default; border-color: var(--border); color: var(--ink-3); }

/* ===========================================================
   ESCALA TIPOGRÁFICA CANÔNICA (DS v9) — padroniza os tipos
   recorrentes pra acabar com as quase-duplicatas (12/12.5/13…).
   =========================================================== */
/* título de card (H4) — 15px / 700 em TODA aba */
.card-head h3 {
  font-size: var(--fs-title) !important; font-weight: 700 !important; letter-spacing: -.01em !important;
}
/* micro-labels / eyebrows (UPPERCASE) — 11px / .08em */
.ikpi-k,
.rz-kpi-l,
.rz-dc-a,
.mt-table th,
.mr-table th,
.yearly-table th,
.exp-table th,
.modal .field label {
  font-size: var(--fs-micro) !important; letter-spacing: .08em !important;
}
/* meta / captions / subs — 12px */
.card-head .meta,
.meta,
.ikpi-sub,
.ikpi.tile .ikpi-sub,
.inv-asset-q,
.exp-cat-pct,
.rz-hero-sub,
.imports-m {
  font-size: var(--fs-caption) !important;
}

/* ===== Nav de meses na sub-aba Lançamentos ===== */
/* barra: sub-abas + navegação de mês (prominente e FIXA em todas as sub-abas) */
.exp-subnav-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: 18px; }
.exp-subnav-row .exp-subnav { margin-bottom: 0; }
.exp-monthnav { display: inline-flex; align-items: center; gap: var(--sp-1); background: var(--bg-elevated); border: 1px solid var(--border-2); border-radius: 999px; padding: 5px; box-shadow: var(--shadow-sm); }
.exp-monthnav button { border-radius: 999px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-size: var(--fs-value); line-height: 1; transition: color .15s, background .15s; }
/* 34px só no desktop — no mobile a regra de 44px (linha ~232, DS Fase 3) precisa vencer;
   antes esta regra vinha DEPOIS no source e ganhava por ordem (mesma especificidade),
   deixando os botões travados em 34px mesmo abaixo de 719.98px. */
@media (min-width: 720px) {
  .exp-monthnav button { width: 34px; height: 34px; }
}
.exp-monthnav button:hover { color: var(--on-accent); background: var(--purple); }
.exp-monthnav .current { min-width: 130px; text-align: center; font-weight: 700; font-size: var(--fs-body-lg); color: var(--ink); font-family: 'Geist Mono', monospace; letter-spacing: .01em; }

/* ===========================================================
   UX aprovado (jun/2026) — auditoria sênior: 16 melhorias
   =========================================================== */
/* U6: cabeçalho de dia com subtotal (sub-abas Gastos/Ganhos) */
.exp-day-tr td { padding: 0 !important; border: 0 !important; background: transparent !important; }
.exp-day-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0 4px; padding: 6px 12px; background: var(--bg-elevated-2); border-radius: 9px; font: 700 10.5px 'Geist Mono', monospace; letter-spacing: .06em; color: var(--ink-2); }
.exp-day-head .mono { color: var(--ink-3); }
/* M5: termo da busca destacado */
mark.hl { background: color-mix(in oklab, var(--purple) 32%, transparent); color: var(--ink); border-radius: 3px; padding: 0 1px; }
/* M1: linha recém-salva acende e apaga */
@keyframes rowFlash { 0% { background: color-mix(in oklab, var(--purple) 20%, transparent); } 100% { background: transparent; } }
tr.row-flash td { animation: rowFlash 1.4s ease both; }
/* P-fixa: quando a categoria muda em CASCATA (escopo "todas"/"próximas"), as pills
   afetadas pulsam na cor NOVA — feedback de que mudou em várias de uma vez. */
@keyframes catFlash {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 55%, transparent); }
  28%  { box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 28%, transparent); background: color-mix(in oklab, var(--accent) 40%, transparent); }
  100% { box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
.exp-cat-pill.cat-flash { animation: catFlash 1s var(--ease-out, ease) 1; }
@media (prefers-reduced-motion: reduce) { .exp-cat-pill.cat-flash { animation: none; } }
/* U4: menu rápido de categoria */
#quickCatMenu { position: absolute; z-index: 130; display: none; flex-direction: column; gap: 2px; width: 220px; max-height: 300px; overflow-y: auto; background: var(--bg-elevated-3); border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px; box-shadow: var(--shadow-lg); }
#quickCatMenu.show { display: flex; }
#quickCatMenu button { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; color: var(--ink-2); font: 600 var(--fs-caption) Inter, system-ui, sans-serif; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
#quickCatMenu button:hover { background: var(--accent-soft); color: var(--ink); }
#quickCatMenu .qc-ic { display: inline-flex; color: var(--ink-2); }
#quickCatMenu .qc-ic svg, #quickCatMenu .qc-ic .icn { width: 14px; height: 14px; }
.exp-cat-pill[data-quickcat]:not([data-quickcat=""]), .exp-cat-pill[data-fixacat] { cursor: pointer; transition: background .15s ease, color .15s ease; }
/* Hover A (opção do dono): a pill clicável "acende" no hover → fica óbvio que dá pra clicar */
.exp-cat-pill[data-quickcat]:not([data-quickcat=""]):hover, .exp-cat-pill[data-fixacat]:hover { background: var(--accent-soft); color: var(--accent); }
/* U5: grade de meses */
#monthPicker { position: absolute; z-index: 130; display: none; width: 242px; background: var(--bg-elevated-3); border: 1px solid var(--border-strong); border-radius: 14px; padding: 10px; box-shadow: var(--shadow-lg); }
#monthPicker.show { display: block; }
#monthPicker .mp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
#monthPicker .mp-head b { font-size: var(--fs-body-lg); }
#monthPicker .mp-head button { width: 30px; height: 30px; border: 0; background: transparent; color: var(--ink-2); border-radius: 8px; font-size: 16px; cursor: pointer; }
#monthPicker .mp-head button:hover { background: var(--bg-elevated-2); color: var(--purple); }
#monthPicker .mp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
#monthPicker .mp-grid button { border: 1px solid var(--border); background: transparent; color: var(--ink-2); font-size: var(--fs-caption); font-weight: 600; padding: 8px 0; border-radius: 8px; cursor: pointer; }
#monthPicker .mp-grid button:hover { color: var(--ink); border-color: var(--border-strong); }
#monthPicker .mp-grid button.on { background: var(--purple); color: var(--on-accent); border-color: var(--purple); }
.exp-monthnav .current { cursor: pointer; }
/* Auditoria 2026-07-07: FAB flutuante e "+" da ilha REMOVIDOS de vez (código apagado) —
   os botões Ganho / + Nova despesa no topo da aba cobrem o fluxo. Fica só o ajuste de
   padding dos botões da ilha no mobile (compensava o espaço do antigo "+"). */
@media (max-width: 719.98px) {
  .mode-switch button[data-mode] { padding: 10px 16px !important; }
}
/* U2: deslize visual na troca de mês por swipe */
@keyframes swipeL { from { opacity: .4; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes swipeR { from { opacity: .4; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
#moduleExpenses.swipe-l > .exp-g-table, #moduleExpenses.swipe-l > .exp-g-cat { animation: swipeL .22s var(--ease-out); }
#moduleExpenses.swipe-r > .exp-g-table, #moduleExpenses.swipe-r > .exp-g-cat { animation: swipeR .22s var(--ease-out); }
/* M4: toque tátil — linhas e cards respondem ao dedo */
.exp-table tbody tr[data-id], .exp-table tbody tr[data-recurring-id] { transition: background .12s; }
.exp-table tbody tr[data-id]:active td, .exp-table tbody tr[data-recurring-id]:active td { background: var(--bg-elevated-2); }
.imports-item, .exp-recent-row { transition: transform .12s var(--ease-out); }
.imports-item:active, .exp-recent-row:active { transform: scale(.985); }
/* U3: botão DESFAZER no toast */
.toast .toast-undo { border: 0; background: transparent; color: var(--purple); font: 700 var(--fs-caption) Inter, system-ui, sans-serif; letter-spacing: .04em; cursor: pointer; margin-left: 10px; }
.toast.has-undo { pointer-events: auto; }
/* DS audit: toast (bottom:28px, 08-modals-mobile.css) colidia com a ilha .mode-switch
   no mobile (ilha ocupa de ~24px até ~74px + safe-area a partir do fundo). Sobe o toast
   pra cima da ilha reaproveitando o MESMO cálculo de safe-area que a ilha usa. */
@media (max-width: 719.98px) {
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)) !important; }
}
/* M6: indicador do pull-to-refresh */
.ptr-ind { height: 0; overflow: hidden; text-align: center; font: 600 11px 'Geist Mono', monospace; color: var(--ink-3); transition: height .2s var(--ease-out); }
/* P3: marca no vazio */
.exp-empty .empty-mark { width: 52px; height: 52px; color: var(--purple); opacity: .32; margin-bottom: 8px; }
.exp-empty .exp-empty-cta { margin-top: 14px; }

/* ===========================================================
   REFINO COSMÉTICO (v9.3) — o último 1% (auditoria sênior).
   Tudo cosmético: nenhuma mudança de layout ou comportamento.
   =========================================================== */

/* C1 — tabular-nums onde ainda faltava: números param de "dançar" ao atualizar/contar */
.mono,
td.mono,
.exp-row-amt,
.exp-row-date,
.ikpi-v,
.ticker-val,
.inv-asset-val,
.exp-total-val,
.rz-cat-v,
.rz-cat-pct,
.rz-top-v,
.imp-val {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}


/* C3 — divisores com fade nas pontas (acabamento de vidro). Tabela: linha pintada no
   tr (cruza todas as colunas). Listas grid: border-image. */
.exp-table tbody td { border-bottom: 0 !important; }
.exp-table tbody tr:not(:last-child):not(.exp-day-tr):not(.exp-row-more-tr) {
  background-image: linear-gradient(90deg, transparent, color-mix(in oklab, var(--ink-3) 20%, transparent) 5%, color-mix(in oklab, var(--ink-3) 20%, transparent) 95%, transparent);
  background-size: 100% 1px; background-position: 0 100%; background-repeat: no-repeat;
}
.rz-top:not(:last-child), .rz-cat:not(:last-child) {
  border-bottom-color: transparent !important;
  border-image: linear-gradient(90deg, transparent, color-mix(in oklab, var(--ink-3) 22%, transparent) 8%, color-mix(in oklab, var(--ink-3) 22%, transparent) 92%, transparent) 1 !important;
}

/* C4 — micro-labels uppercase no tracking canônico (.09em); some os .06/.13 avulsos */
.rz-dc-a, .exp-total-bar .exp-total-lbl, .exp-day-head, .exp-cat-more {
  letter-spacing: .09em !important;
}

/* C5 — raios de canto na régua (sm 8 · tile 10 · caixa 12 · base 14 · pill 999) */
.exp-nat-filter button, .card-collapse { border-radius: var(--radius-sm) !important; }
.exp-fixa-badge { border-radius: 6px !important; }
.inv-tk { border-radius: 10px !important; }
.err-pop-body { border-radius: 12px !important; }
/* .exp-subnav button SAIU daqui: esse 12px !important global sobrescrevia o border-radius:0
   do estilo mobile (sub-abas viram underline reto ≤480px), deixando o sublinhado curvado numa
   "tacinha". Desktop mantém 12px pela regra base (.exp-subnav button acima). */

/* C6 — timing em 3 degraus: hovers de UI coesos no mesmo easing */
.exp-filter,
.exp-nat-filter button,
.btn-csv,
.pill-count,
.exp-filter-clear,
.imports-item,
.mode-switch button,
.card-collapse {
  transition: color var(--t-base) var(--ease-out), background var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out), transform var(--t-fast) var(--ease-out) !important;
}

/* C7 — pills com altura óptica igual (mesmo x-height quando vizinhas) */
.exp-owner-chip { padding-top: 3px !important; padding-bottom: 3px !important; }
.exp-fixa-badge { padding: 3px 7px !important; }
.pill-count { padding: 3px 8px !important; }

/* C8 — cor cruza suave (250ms) em vez de pular, ao virar ganho↔perda ou trocar de mês */
.ikpi-v,
.rz-kpi-v,
.exp-row-amt,
.hero-pill,
.exp-cat-amt {
  transition: color var(--t-base) var(--ease-out), background-color var(--t-base) var(--ease-out);
}

/* C9 — sinais +/− e setas: o render já emite "+ "/"↑ "/"↓ " com espaço; nada a forçar
   aqui (mantido como referência da decisão). */

/* ===========================================================
   DRILL-DOWN DE CATEGORIA (pedido do dono) — clicar numa categoria
   abre popup com todos os lançamentos dela no mês + soma de conferência.
   =========================================================== */
.exp-cat-clickable { cursor: pointer; border-radius: 10px; transition: background var(--t-fast) var(--ease-out); }
.exp-cat-clickable:hover { background: color-mix(in oklab, var(--ink-3) 7%, transparent); }
.exp-cat-clickable:active { transform: scale(.99); }
.exp-cat-clickable:hover .exp-cat-name { color: var(--ink) !important; }

.modal.cd-modal { max-width: min(540px, 94vw); }   /* especificidade vence .modal.modal-wide + nunca estoura o viewport */
.cd-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cd-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--bg-elevated-3); color: var(--ink-2); }
.cd-icon svg, .cd-icon .icn { width: 19px; height: 19px; }
.cd-head-txt h3 { margin: 0; }
.cd-head-txt .sub { margin: 2px 0 0; }
.cd-scroll { max-height: 52vh; overflow-y: auto; }
.cd-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-caption); }
.cd-table thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-elevated);
  text-align: left; padding: 6px 10px 8px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-muted); }
.cd-table th.cd-th-val { text-align: right; }
.cd-row { cursor: pointer; transition: background var(--t-fast) var(--ease-out); }
.cd-row td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cd-row:last-child td { border-bottom: 0; }
.cd-row:hover td { background: var(--bg-elevated-2); }
.cd-row:active td { background: var(--bg-elevated-3); }
.cd-date { color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cd-desc-main { font-weight: 600; color: var(--ink); }
.cd-src { font-size: 10px; color: var(--ink-muted); margin-top: 2px; }
.cd-val { text-align: right; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cd-empty { padding: 26px; text-align: center; color: var(--ink-muted); }
.cd-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-strong); }
.cd-foot-count { font-size: var(--fs-caption); color: var(--ink-3); }
.cd-foot-total { font-size: var(--fs-caption); color: var(--ink-2); display: inline-flex; align-items: baseline; gap: 6px; }
.cd-foot-total b { font-size: var(--fs-value); color: var(--purple-light); font-variant-numeric: tabular-nums; }
.cd-hint { font-size: var(--fs-micro); color: var(--ink-muted); }
@media (max-width: 480px) { .cd-hint { display: none; } .cd-scroll { max-height: 58vh; } }

/* ===========================================================
   RESPONSIVIDADE (v9.5) — mobile hardening (auditoria 6 áreas).
   ≤720 = mobile geral; ≤400 = estreito; ≤374 = iPhone SE/mini.
   Telas ≥375px (layout já validado pelo dono) ficam intactas.
   =========================================================== */
@media (max-width: 719.98px) {
  /* Toolbar de filtros: nada estoura — busca ocupa a linha toda, resto encolhe e quebra */
  .exp-table-tools > * { min-width: 0; }
  .exp-search { flex: 1 1 100% !important; }
  .exp-filter { flex: 1 1 auto; max-width: 100%; }
  /* mini-KPIs do hero: gap 30px vazava → respira sem estourar */
  .hero-mini-kpis { gap: 14px 18px; }
  /* iOS NÃO dá zoom ao focar input se a fonte for ≥16px */
  .modal input, .modal select, .modal textarea,
  .exp-search input, #recEditVal, #recEditCat { font-size: 16px !important; }
}
@media (max-width: 400px) {
  /* Tiles de Investimentos: 1 coluna (o 2+1 ainda apertava "Dólar/Aplicado") */
  .inv-kpis.three { grid-template-columns: 1fr !important; }
  .inv-kpis.three > .card:last-child { grid-column: auto !important; }
  /* Modal: padding lateral menor pra ganhar largura útil */
  .modal { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 374px) {
  .rz-hero-amt { font-size: 30px !important; }
  .page { padding-left: 12px; padding-right: 12px; }
  /* sub-abas e chips mais compactos */
  .exp-subnav button { padding: 9px 4px; font-size: 12px; }
}

/* ===========================================================
   DIÁLOGO DE ESCOPO da fixa — A bottom-sheet (mobile) / B modal radio (desktop).
   =========================================================== */
.scope-bg { padding: 0; }   /* review: sem o padding 20px do .modal-bg, o sheet encosta na borda inferior */
.scope-bg.show { align-items: flex-end; }   /* mobile: cola embaixo (bottom-sheet) */
.scope-card { width: 100%; background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); position: relative;
  box-shadow: 0 -20px 50px rgba(0,0,0,.5); animation: scopeUp .3s var(--ease-out); }
@keyframes scopeUp { from { transform: translateY(100%); } to { transform: none; } }
.scope-grab { width: 38px; height: 4px; border-radius: 999px; background: var(--ink-3); opacity: .4; margin: 8px auto 14px; }
.scope-card h3 { margin: 0 0 3px; font-size: 16px; }
.scope-card .sub { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-3); }
.scope-opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--bg-elevated-2);
  border: 1px solid var(--border); border-radius: 14px; padding: 13px 14px; margin-bottom: 8px; cursor: pointer; color: var(--ink);
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out); }
.scope-opt:hover { border-color: color-mix(in oklab, var(--purple) 45%, transparent); background: var(--bg-elevated-3); }
.scope-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in oklab, var(--purple) 12%, transparent); color: var(--purple); }
.scope-tx { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.scope-tx .tt { font-weight: 600; font-size: 13.5px; }
.scope-tx .ds { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.scope-rd { display: none; }
.scope-foot { display: flex; gap: 8px; margin-top: 6px; }
.scope-foot .btn-primary, .scope-foot .btn-secondary { flex: 1; }
@media (max-width: 719.98px) {
  #scopeApply { display: none; }   /* toque na opção resolve direto */
}
@media (min-width: 720px) {        /* desktop: modal central com radio + Aplicar */
  .scope-bg.show { align-items: center; }
  .scope-card { max-width: 380px; border-radius: 18px; padding: 20px; animation: modalUp .3s var(--ease-back); box-shadow: var(--shadow-lg); }
  .scope-grab { display: none; }
  .scope-rd { display: block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink-3); flex-shrink: 0; position: relative; }
  .scope-opt.sel .scope-rd { border-color: var(--purple); }
  .scope-opt.sel .scope-rd::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--purple); }
  .scope-opt.sel { border-color: color-mix(in oklab, var(--purple) 45%, transparent); }
}

/* ===========================================================
   SUPER-RESPONSIVIDADE (v9.6) — auditoria 16 agentes (132 achados).
   Foco: grupos de botões que quebram com ÓRFÃO + overflow + toque.
   Vem depois do v9.5 (vence por ordem nas larguras que se sobrepõem).
   =========================================================== */
/* --- defensivos globais (qualquer largura): nada vaza nem quebra dado --- */
.ikpi-v, .ikpi.tile .ikpi-v { white-space: nowrap; }   /* (removido overflow:hidden que CORTAVA o valor — review do dono) */
.inv-asset-rt { flex-shrink: 0; min-width: 72px; white-space: nowrap; }
.inv-asset-val { white-space: nowrap; }
.inv-asset-nm, .inv-asset-q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.exp-owner-opt, .exp-nat-opt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-subnav button { white-space: nowrap; }

@media (max-width: 719.98px) {
  .imp-row select { min-height: 44px; padding: 8px; font-size: 13px; }   /* toque + sem zoom iOS */
}

@media (max-width: 480px) {
  /* escolha do dono (grade 2×2): Importações|Importar em cima, +Ganho|+Nova despesa
     embaixo. Os 2 sub-grupos resolvem o caso de "Importações" oculto (3 botões) sem órfão. */
  /* P6 (v9.9): topo do Painel — Importar/Importações viram ícones ao lado do título;
     Ganho | Despesa num par limpo embaixo. */
  .section-head { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 12px 8px; }
  .section-head > div:first-child { grid-column: 1; }
  .exp-add-group { display: contents; }
  .exp-add-secondary { grid-column: 2; grid-row: 1; display: flex; gap: 6px; }
  .exp-add-secondary button { flex: 0 0 auto; width: 38px; height: 38px; min-height: 0; padding: 0; justify-content: center; }
  .exp-add-secondary button span { display: none; }
  .exp-add-primary { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .exp-add-primary button { width: 100%; min-height: 44px; white-space: nowrap; padding: 11px 14px; justify-content: center; }
  /* QUEBRA: toolbar de filtros — busca full, selects 2-col, nat-filter linha própria, toque 40px */
  .exp-filter { flex: 1 1 calc(50% - 3px); max-width: none; padding: 7px 22px 7px 9px; font-size: 11px; min-height: 40px; }
  .exp-nat-filter { width: 100%; height: auto; display: flex; flex-wrap: wrap; justify-content: space-between; }
  .exp-nat-filter button { flex: 1 1 auto; min-height: 40px; }
  .exp-filter-clear { min-height: 40px; }
  .btn-csv { width: 40px; height: 40px; }
  /* P4 (v9.9): toolbar minimal — busca + ícone de filtro; o resto abre na folha */
  .exp-search { flex: 1 1 auto !important; }
  .exp-filter-toggle { display: grid; place-items: center; position: relative; width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer; }
  .exp-filter-toggle.on { border-color: color-mix(in oklab, var(--purple) 45%, transparent); color: var(--purple); }
  .exp-filter-toggle .ff-cnt { position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: var(--purple); color: var(--on-accent); font: 700 10px 'Geist Mono', monospace; display: grid; place-items: center; }
  .exp-filter-toggle .ff-cnt[hidden] { display: none; }   /* zero filtros: o display:grid acima vencia o hidden e o badge "0" ficava visível */
  .exp-filters-pop { display: none; flex-basis: 100%; width: 100%; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding: 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; }
  .exp-filters-pop.open { display: flex; }
  /* QUEBRA: tiles de KPI — valor não quebra, label trunca */
  .ikpi.tile .ikpi-v { font-size: 20px; }
  .ikpi-k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero-mini-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }   /* 2 colunas (encurta o hero) */
  .hero-mini-kpis .k { font-size: 10px; } .hero-mini-kpis .v { font-size: 16px; }
  .hero-actions { gap: 6px; flex-wrap: wrap; }
  .hero-actions .btn-ghost { padding: 6px 10px; font-size: 11px; }
  .rz-donut { width: 120px !important; height: 120px !important; flex-shrink: 0; }
  /* QUEBRA: tabela de lançamentos — pill blindada, valor não vaza, padding menor */
  .exp-table td, .exp-table th { padding: 10px 8px; }
  .exp-cat-pill { flex-shrink: 0; white-space: nowrap; }
  .exp-row-desc-cell { min-width: 0; }
  .exp-row-amt { white-space: nowrap; font-size: 12px; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* seletor de mês não fica órfão */
  .exp-monthnav, .month-nav { min-width: 0; }
  .exp-monthnav .current { min-width: 90px; font-size: 11px; }
  .exp-subnav-row { flex-direction: column; gap: 10px; }
  /* FEIO: breakdown de categoria — nome trunca, valor não vaza */
  .exp-cat-row { gap: 10px; }
  .exp-cat-v { flex-shrink: 0; max-width: 100px; }
  .exp-cat-row.has-budget .exp-cat-v { max-width: 150px; }   /* review: "R$ X de R$ Y" precisa de mais espaço */
  .exp-cat-amt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* topbar: nome trunca, botões compactos, nada estoura */
  .topbar-actions { gap: 8px; }
  .theme-toggle { width: 32px; height: 32px; }
  .theme-toggle svg { width: 16px; height: 16px; }
  .user-pill { max-width: 160px; padding: 5px 10px 5px 5px; gap: 8px; }
  #userName { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
  .brand { flex-shrink: 1; min-width: 0; }
}
/* QUEBRA: rodapés de modais — Excluir full embaixo, Cancelar|Salvar 50/50 (sem órfão) */
@media (max-width: 420px) {
  .modal .modal-foot { flex-wrap: wrap; gap: 8px; }
  .modal .modal-foot .spacer { display: none; }
  .modal .modal-foot .btn-danger, .modal .modal-foot .btn-danger.ghost { flex: 1 1 100%; order: 3; }
  .modal .modal-foot .btn-secondary, .modal .modal-foot .btn-primary { flex: 1 1 calc(50% - 4px); min-width: 0; padding: 11px 16px; }
}
@media (max-width: 390px) {
  .ikpi-k { font-size: 9px; letter-spacing: .04em; }
  .inv-tk { width: 36px; height: 36px; } .inv-asset { padding: 8px; }
}
@media (max-width: 375px) {
  .imp-cat { min-width: 0; }
  .imp-row { grid-template-columns: 20px 44px minmax(0,1fr) auto; padding: 6px 8px; gap: 6px; }
  .imp-desc { white-space: normal; }
  .modal.modal-wide { padding: 16px; }
}
@media (max-width: 374px) {
  /* !important obrigatório: sem ele esta regra de encolher PERDE pros !important de base
     (01-base.css: .mode-switch padding 6px + button font-size; e o padding 10px 16px do
     .mode-switch button[data-mode] acima) e a ilha estoura ~8,5px de cada lado a 360px.
     O seletor button[data-mode] também é necessário — especificidade maior que .mode-switch
     button, então só a versão simples continuaria perdendo o padding. */
  .mode-switch { padding: 4px !important; }
  .mode-switch button, .mode-switch button[data-mode] { padding: 8px 16px !important; font-size: 11px !important; }
}
@media (max-width: 360px) {
  .exp-owner-seg, .exp-nat-seg { gap: 3px; padding: 3px; }
  .exp-owner-opt, .exp-nat-opt { padding: 7px 6px; font-size: 10px; }
  .exp-cat-name { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-text .tag { display: none; }
}

/* ===========================================================
   CONSERTOS MOBILE (v9.7) — escolhas do dono (propostas-mobile-fix).
   1=lançamentos viram cartão · 2=botões 2×2 (acima) · 3=tiles 1-col.
   =========================================================== */
/* 3 · Tiles de Investimentos: 1 coluna, horizontal (label/sub à esquerda, valor à
   direita) — o número grande NUNCA corta nem vaza (col auto = tamanho do valor). */
@media (max-width: 719.98px) {
  .inv-kpis.three { grid-template-columns: 1fr !important; }
  .inv-kpis.three > .card:last-child { grid-column: auto !important; }
  .ikpi.tile { display: grid; grid-template-columns: minmax(0,1fr) auto; grid-template-areas: "k val" "sub val"; column-gap: 14px; align-items: center; }
  .ikpi.tile .ikpi-k { grid-area: k; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ikpi.tile .ikpi-v { grid-area: val; align-self: center; font-size: 22px; text-align: right; }
  .ikpi.tile .ikpi-sub { grid-area: sub; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ikpi.tile .ikpi-sub:empty { display: none; }
}
/* 1 · Lista de lançamentos vira CARTÃO no celular: descrição + valor na 1ª linha
   (valor nunca corta), pill + data na 2ª. Reflow da <table> via grid no <tr>. */
@media (max-width: 600px) {
  .exp-table thead { display: none; }
  .exp-table tbody tr[data-id], .exp-table tbody tr[data-recurring-id] {
    display: grid; grid-template-columns: minmax(0,1fr) auto; column-gap: 10px; row-gap: 6px;
    padding: 12px 6px; align-items: start;
  }
  .exp-table tbody tr[data-id] > td, .exp-table tbody tr[data-recurring-id] > td {
    display: block; padding: 0; border: 0 !important;
  }
  .exp-row-desc-cell { grid-column: 1; grid-row: 1; min-width: 0; }
  .exp-row-amt { grid-column: 2; grid-row: 1; text-align: right; font-size: 14px; white-space: nowrap; align-self: baseline; }
  .exp-row-cat-cell { grid-column: 1; grid-row: 2; align-self: center; }
  .exp-row-date { grid-column: 2; grid-row: 2; text-align: right; align-self: center; color: var(--ink-3); font-size: 11px; }
  .exp-table tbody tr.exp-day-tr, .exp-table tbody tr.exp-row-more-tr { display: block; }
  .exp-table tbody tr.exp-day-tr > td, .exp-table tbody tr.exp-row-more-tr > td { display: block; padding: 0; border: 0; }
}

/* Botão "atualizar cotação" no modal de dólar + aviso de cotação velha */
/* DS audit: alvo de toque — era 22x22 (menor de todos os ícone-só do app). Cresce a
   caixa clicável (font-size do glifo "↻" mantido em 13px, centralizado por grid). */
.fx-refresh { display: inline-grid; place-items: center; width: 36px; height: 36px; margin-left: 4px; border: 0; border-radius: 50%; background: var(--bg-elevated-2); color: var(--purple); font-size: 13px; cursor: pointer; vertical-align: middle; transition: background .15s; }
.fx-refresh:hover { background: var(--bg-elevated-3); }
.fx-refresh.spin { animation: fxspin .8s linear infinite; }
@keyframes fxspin { to { transform: rotate(360deg); } }
.fx-stale { color: var(--warn); font-size: 11px; margin-top: 4px; }
