/* Tema escuro. Vermelho = dinheiro saindo / situação ruim · Verde = dinheiro entrando / saudável ·
   Âmbar = futuro ou pendente · Cor de categoria só em marcadores pequenos (ponto, barra fina). */
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #161618;
  --surface-2: #1f1f23;
  --surface-3: #2a2a30;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #f2f2f3;
  --text-2: #a1a1aa;
  --muted: #898781;
  --pos: #22c55e;
  --neg: #f87171;
  --warn: #fab219;
  --pos-bg: rgba(34, 197, 94, 0.13);
  --neg-bg: rgba(248, 113, 113, 0.13);
  --warn-bg: rgba(250, 178, 25, 0.13);
  --track: rgba(255, 255, 255, 0.07);
  --radius: 18px;
  --tab-h: 62px;
}

* { box-sizing: border-box; }
/* touch-action: manipulation tira o atraso de toque (espera do "duplo toque para zoom"). */
html { -webkit-text-size-adjust: 100%; background: var(--bg); touch-action: manipulation; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body.sheet-open { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; text-align: inherit; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
svg { display: block; }
[hidden] { display: none !important; }

.app {
  max-width: 720px; margin: 0 auto;
  /* +30px abaixo da barra de status: o iOS desfoca/esmaece o conteúdo encostado nela (efeito de borda). */
  padding: calc(env(safe-area-inset-top, 0px) + 30px) 16px calc(var(--tab-h) + env(safe-area-inset-bottom) + 28px);
  transition: opacity .15s ease;
}
/* Troca de aba: só opacidade (barato para a GPU, sem recalcular layout). */
.app.enter { animation: tabIn .16s ease-out; }
@keyframes tabIn { from { opacity: .35; } }
.app.dim { opacity: .55; pointer-events: none; }

/* Retorno ao toque: a linha/botão reage na hora. */
.tx, .person, .plan, .catrow, .list-row, .bill-row, .kpi, .meter-card { transition: opacity .12s ease; }
.tx:active, .person:active, .plan:active, .catrow:active, .list-row:active, .bill-row:active, .kpi:active, .meter-card:active { opacity: .55; }
.btn, .chip, .icon-btn, .more, .seg button, .tabs button { transition: transform .1s ease, opacity .1s ease; }
.btn:active, .chip:active, .icon-btn:active, .seg button:active { transform: scale(.96); }
.tabs button:active svg { transform: scale(.88); }

/* Cabeçalho */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 2px 4px; }
.topbar h1 { font-size: 28px; line-height: 1.1; letter-spacing: -0.02em; margin: 0; font-weight: 750; }
.hello { margin: 0 0 2px; color: var(--text-2); font-size: 14px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text); flex: none; }
.icon-btn:disabled { opacity: .5; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fresh { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin: 6px 2px 16px; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--pos); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--neg); }

/* Superfícies */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.flush { padding: 2px 14px; }
.section { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 2px 10px; font-size: 17px; font-weight: 680; letter-spacing: -0.01em; }
.section .aside { font-size: 13px; font-weight: 500; color: var(--text-2); }

/* KPIs */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-width: 0; }
.meter-card { display: block; width: 100%; text-align: left; }
.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.kpi-label svg { width: 15px; height: 15px; color: var(--muted); }
.kpi-value { font-size: clamp(17px, 5.1vw, 22px); font-weight: 720; letter-spacing: -0.02em; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { color: var(--text-2); font-size: 12px; margin-top: 3px; line-height: 1.35; }

/* Texto semântico */
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 10.5px; font-weight: 650; line-height: 1; padding: 4px 7px; border-radius: 7px; background: var(--surface-3); color: var(--text-2); vertical-align: 1px; white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.neg { background: var(--neg-bg); color: var(--neg); }
.pill.pos { background: var(--pos-bg); color: var(--pos); }

/* Barras (marcas finas, pontas arredondadas) */
.bar { position: relative; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--text-2); min-width: 4px; }
.bar > span[style*="width:0.00%"] { min-width: 0; }
.bar.ok > span { background: var(--pos); }
.bar.warn > span { background: var(--warn); }
.bar.bad > span { background: var(--neg); }

/* Medidor da fatura com marcas dos alertas */
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.meter { position: relative; height: 8px; border-radius: 4px; background: var(--track); margin-bottom: 22px; }
.meter > .fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--text-2); }
.meter > .fill.warn { background: var(--warn); }
.meter > .fill.bad { background: var(--neg); }
.meter > .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.meter > .tick-label { position: absolute; top: 14px; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* Pessoas / cartões */
.person { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 12px 0; }
.person + .person, .person-wrap + .person-wrap { border-top: 1px solid var(--line); }
.person-wrap { padding-bottom: 12px; }
.person-wrap .person { padding-bottom: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-weight: 700; font-size: 14px; }
.p-main, .p-right { display: flex; flex-direction: column; min-width: 0; }
.p-right { align-items: flex-end; }
.p-name { font-weight: 600; }
.p-sub { font-size: 12px; color: var(--text-2); }
.p-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.p-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.link { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }

/* Chips e segmentado */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); font-size: 13px; font-weight: 550; }
.chip.on { background: var(--text); color: #0b0b0c; border-color: transparent; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; text-align: center; border-radius: 9px; padding: 8px; color: var(--text-2); font-size: 14px; font-weight: 550; }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* Extrato */
.day { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 4px 6px; font-size: 13px; }
.day b { font-weight: 650; color: var(--text-2); }
.day span { color: var(--muted); font-size: 12px; }
.tx { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 11px 0; }
.tx + .tx { border-top: 1px solid var(--line); }
.ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.ico svg { width: 18px; height: 18px; }
.ico.out { background: var(--neg-bg); color: var(--neg); }
.ico.in { background: var(--pos-bg); color: var(--pos); }
.tx-main, .tx-right { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.tx-right { align-items: flex-end; }
.tx-title { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.in { color: var(--pos); }
.tx-inst { font-size: 11.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cat { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.cat i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.more { width: 100%; text-align: center; padding: 12px; border-radius: 14px; background: var(--surface-2); color: var(--text-2); font-weight: 550; margin-top: 6px; }

/* Painéis de categoria (modelo Cash Flow) */
.month-nav { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 10px; margin: 10px 0 14px; text-align: center; }
.month-nav strong { display: block; font-size: 16px; font-weight: 650; }
.month-nav span { font-size: 12px; color: var(--text-2); }
.panel-head { padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ph-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.ph-label svg { width: 16px; height: 16px; }
.ph-value { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; margin-top: 6px; }
.ph-sub { font-size: 12.5px; color: var(--muted); }
.catrow { display: block; width: 100%; padding: 10px 0 6px; }
.catrow-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 14px; }
.catrow-top span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catrow-top .num { color: var(--text); }
.toggle-all { display: block; width: 100%; text-align: center; color: var(--text-2); font-size: 13px; padding: 10px 0 2px; }

/* Parcelamentos */
.plan { display: block; width: 100%; padding: 13px 0; }
.plan + .plan { border-top: 1px solid var(--line); }
.plan-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.plan-top small { color: var(--muted); font-weight: 500; font-size: 12px; }
.plan-sub { font-size: 12.5px; color: var(--text-2); margin: 3px 0 9px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan-sub i { width: 7px; height: 7px; border-radius: 50%; }
.plan-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.bill-row { display: block; width: 100%; padding: 12px 0; }
.bill-row + .bill-row, .bill-items + .bill-row { border-top: 1px solid var(--line); }
.bill-row .plan-top { margin-bottom: 8px; }
.bill-items { padding: 0 0 10px; }
.bill-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 5px 0; color: var(--text-2); }
.bill-item span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Formulários e botões */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 18px; border-radius: 13px; background: var(--text); color: #0b0b0c; font-weight: 650; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--neg-bg); color: var(--neg); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.field label { font-size: 13px; color: var(--text-2); }
input, select { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 11px 12px; font-size: 16px; min-width: 0; }
input:focus, select:focus { outline: 2px solid rgba(255, 255, 255, .35); outline-offset: 1px; }
.row-input { display: flex; gap: 8px; }
.row-input input { flex: 1; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); margin: 10px 0; }
.check input { width: 20px; height: 20px; flex: none; accent-color: #f2f2f3; }
.cad { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 16px); }
.cad-head { display: flex; align-items: center; gap: 12px; }
.note { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 10px 0 0; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; margin: 0; }
code.block { display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0 12px; font-size: 12px; word-break: break-all; user-select: all; }

/* Linhas de detalhe e listas simples */
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv > span:first-child { color: var(--text-2); flex: none; }
.kv > span:last-child { text-align: right; min-width: 0; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row .tx-main { flex: 1; }

/* Barra inferior */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 6px 6px env(safe-area-inset-bottom);
  background: rgba(11, 11, 12, 0.86); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tabs button { flex: 1; max-width: 140px; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 10.5px; font-weight: 600; text-align: center; }
.tabs button svg { width: 23px; height: 23px; }
.tabs button.on { color: var(--text); }

/* Folha inferior (detalhes) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.55); animation: fadein .18s ease-out; transition: opacity .19s ease; }
.sheet-backdrop.closing { opacity: 0; }
@keyframes fadein { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 720px; margin: 0 auto;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--line-2); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .26s cubic-bezier(.2, .85, .25, 1);
  transition: transform .26s cubic-bezier(.2, .85, .25, 1);
}
.sheet.closing { transform: translate3d(0, 100%, 0) !important; transition: transform .19s ease-in; }
@keyframes up { from { transform: translate3d(0, 100%, 0); } }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet-back { display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-size: 14px; margin: -4px 0 10px -6px; padding: 4px 6px; border-radius: 8px; }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 18px; line-height: 1.25; }
.sheet-head .amt { font-size: 22px; }
.sheet-close { margin-left: auto; }

/* Extrato: busca, dias fora da tela não são desenhados até chegar perto (rolagem leve). */
.search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; margin-bottom: 10px; color: var(--muted); }
.search input { flex: 1; background: none; border: 0; padding: 10px 0; font-size: 16px; color: var(--text); outline: none; }
.search input::placeholder { color: var(--muted); }
.stmt-day { content-visibility: auto; contain-intrinsic-size: auto 320px; }
.more-loading { text-align: center; color: var(--muted); font-size: 13px; padding: 16px 0 4px; }
.link-btn { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }
.tx-title.wrap { white-space: normal; }
.pills { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.list-row { width: 100%; }
.gap { height: 8px; }
.gap.lg { height: 14px; }
.btn.sm { height: 34px; padding: 0 12px; }

/* Esqueleto de carregamento (só na primeira vez; depois as telas vêm do cache). */
.sk { background: var(--surface); border-radius: var(--radius); margin-bottom: 12px; animation: skPulse 1.1s ease-in-out infinite; }
.sk-title { height: 30px; width: 46%; border-radius: 10px; margin: 18px 2px 18px; }
.sk-card { height: 104px; margin: 0; }
.sk-block { height: 150px; }
.sk-block.short { height: 90px; }
.sk-row { height: 54px; border-radius: 12px; margin: 10px 0; }
@keyframes skPulse { 50% { opacity: .5; } }

/* Barra fina no topo enquanto atualiza em segundo plano. */
.busy { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30; pointer-events: none; opacity: 0; transition: opacity .2s; overflow: hidden; }
.busy::after { content: ''; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); animation: busyMove 1s ease-in-out infinite; }
.busy.on { opacity: 1; }
@keyframes busyMove { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Puxar para atualizar. */
.ptr { position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 50%; z-index: 25; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-2);
  transform: translate3d(-50%, -60px, 0); opacity: 0; transition: opacity .15s; pointer-events: none; }
.ptr.show { opacity: 1; }
.ptr.ready { color: var(--text); }
.ptr.spin { transform: translate3d(-50%, 18px, 0); transition: transform .2s, opacity .15s; }
.ptr.spin svg { animation: spin .8s linear infinite; }

/* Aviso rápido. */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 11px 14px; border-radius: 14px;
  background: #2a2a30; color: var(--text); font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); animation: toastIn .18s ease-out; }
.toast-action { color: #0b0b0c; background: var(--text); border-radius: 9px; padding: 6px 10px; font-weight: 650; font-size: 13px; flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Login */
.login { max-width: 400px; margin: 0 auto; padding: max(16vh, env(safe-area-inset-top)) 20px 40px; }
.login-logo { border-radius: 14px; margin-bottom: 14px; }
.login h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 18px; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login label { font-size: 13px; color: var(--text-2); }
.login input { width: 100%; }
.login .note:empty { display: none; }

@media (min-width: 640px) {
  .duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  .duo > .card { margin-bottom: 0; }
}

/* Titular com teto: fatura inteira (cheia) + reservado aos adicionais (listrado) */
.bar.stack > span:first-child { border-radius: 3px 0 0 3px; }
.bar.stack > span.resv { min-width: 0; border-radius: 0 3px 3px 0; opacity: .75;
  background: repeating-linear-gradient(135deg, var(--text-2) 0 3px, transparent 3px 6px); }

/* Botão (i): textos longos abrem numa folha */
.sec-t { display: inline-flex; align-items: center; gap: 2px; }
.info-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin: -8px -6px -8px 0;
  border-radius: 50%; color: var(--muted); vertical-align: middle; text-transform: none; }
.info-btn:active { background: var(--surface-2); }
.ph-label .info-btn { margin-left: auto; margin-right: -8px; }
.info-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; padding: 4px 0; }
section.card + .info-link, .info-link:last-child { margin: 8px 2px 0; }
.info-body p { color: var(--text-2); font-size: 14.5px; line-height: 1.5; margin: 12px 0 0; }
.info-body p:first-child { margin-top: 4px; }
.info-body .kv + p { margin-top: 16px; }
.kv.sub { padding: 6px 0 6px 14px; font-size: 13px; border-top: 0; }
.kv.total { border-top: 1px solid var(--line-2, var(--line)); font-weight: 650; }
.kv.total > span:first-child { color: var(--text); }
.field label .info-btn { margin: -8px 0; width: 26px; height: 26px; }
.p-foot .info-link { padding: 0; font-size: 12px; }

/* Ritmo do mês: risquinho na barra marca onde o gasto "deveria" estar hoje */
.bar > span.pace { width: 2px; min-width: 0; margin-left: -1px; border-radius: 1px; background: var(--text); opacity: .85; }
.bar > span:first-child { transition: background-color .3s ease; }
.meter > .pace-mark { position: absolute; top: -9px; width: 0; height: 0; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom: 0; border-top: 6px solid var(--text); }

/* Gastos: resumido por grupo, com as categorias de dentro */
.ph-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mini-toggle { flex: none; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 6px 11px; }
.mini-toggle[aria-pressed="true"] { color: var(--text); background: var(--surface-3); }
.grp { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.grp-n { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }
.chev { display: inline-flex; color: var(--muted); transition: transform .15s ease; }
.chev.open { transform: rotate(90deg); }
.subcats { margin: 0 0 6px 20px; padding-left: 10px; border-left: 1px solid var(--line-2); }
.catrow.sub { padding: 7px 0 4px; }
.catrow.sub .catrow-top { font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.catrow.sub .bar { height: 4px; }

/* Foto de perfil */
.avatar { overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-row { display: flex; align-items: center; gap: 14px; margin: 2px 0 14px; }
.photo-row .btn.sm { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.cad-head .avatar { width: 52px; height: 52px; font-size: 18px; }
.duo.solo { grid-template-columns: 1fr; }

/* Gastos fixos (Pix) */
.fixed-kpi { display: block; width: 100%; text-align: left; padding: 14px; margin-bottom: 12px; }
.fk-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.fk-top .kpi-sub { margin: 0; text-align: right; }
.fk-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-bottom: 10px; }
.fk-side { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--text-2); gap: 2px; }
.fix-row { text-align: left; }
.fix-day { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.fix-day b { font-size: 15px; }
.fix-day small { font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.fix-row.overdue .fix-day { background: var(--neg-bg); color: var(--neg); }
.fix-row.paid .fix-day { background: var(--pos-bg); color: var(--pos); }
.fix-row .tx-main { flex: 1; min-width: 0; }
.pill:has(svg) { display: inline-flex; align-items: center; gap: 3px; }
.pill svg { flex: none; }
.strike { text-decoration: line-through; }
.kv .wrap { white-space: normal; word-break: break-all; }

/* Orçamento do mês: cartão + fixos × renda */
.budget { display: block; width: 100%; text-align: left; padding: 14px; margin-bottom: 12px; }
.budget-bar { height: 8px; border-radius: 4px; }
.budget-bar > span:first-child { border-radius: 4px 0 0 4px; }
.budget-bar > span.seg2 { min-width: 0; border-radius: 0 4px 4px 0; }
.budget-bar.over { box-shadow: 0 0 0 1px var(--neg-bg); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.budget-table { margin: 4px 0 6px; font-size: 13.5px; }
.bt-head, .bt-row { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.1fr; gap: 8px; padding: 9px 0; align-items: center; }
.bt-head { color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.bt-head span:not(:first-child), .bt-row span:not(:first-child) { text-align: right; }
.bt-row + .bt-row { border-top: 1px solid var(--line); }
.bt-row.cur { font-weight: 650; }

/* Três quadros no topo: no celular, o 3º (fixos) ocupa a linha inteira; na tela larga, ficam lado a lado */
.kpis > .kpi:nth-child(3) { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .kpis { grid-template-columns: 1fr 1fr 1fr; }
  .kpis > .kpi:nth-child(3) { grid-column: auto; }
}
.pix-pick { text-align: left; }
