/* Minhas Despesas: celular primeiro, coluna central no PC. Cores em tokens; claro e escuro
   automáticos (ou escolhidos em Ajustes, via data-tema); 3 cores de destaque (data-cor). */
:root {
  --bg: #eef2ef; --surface: #ffffff; --surface2: #f3f6f4;
  --ink: #12201b; --muted: #566660; --line: #dce4df;
  --acc-l: #0b7a62; --acc-d: #3fcfa6; --acc: var(--acc-l); --on-acc: #ffffff;
  --casa: #c4701a; --carro: #3566cf; --pos: #7c4fcb; --cartoes: #c43a6e; --tag: #4d6b66;
  --ok: #14724a; --warn: #8a5a00; --bad: #b3302a;
  --s1: #2f5d62; --s2: #7fa0a5; --s3: #c3d3d1;
  --scrim: rgba(0, 0, 0, .5);
  --f-display: 'Bricolage Grotesque', ui-rounded, system-ui, sans-serif;
  --f-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --acesso-fundo: rgba(238, 242, 239, .98); --acesso-cartao: var(--surface); --acesso-texto: var(--ink);
  --acesso-fraco: var(--muted); --acesso-destaque: var(--acc); --acesso-texto-botao: var(--on-acc);
  --acesso-borda: var(--line); --acesso-erro: var(--bad); --acesso-fonte: var(--f-body);
  color-scheme: light;
}
:root[data-cor="indigo"] { --acc-l: #4a56e2; --acc-d: #9aa3ff; }
:root[data-cor="coral"] { --acc-l: #cb4536; --acc-d: #ff9484; }
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #0c1210; --surface: #151d1a; --surface2: #1c2723;
    --ink: #e8f0ec; --muted: #9db0a8; --line: #27332f;
    --acc: var(--acc-d); --on-acc: #08130f;
    --casa: #f0a24f; --carro: #7aa2f7; --pos: #b595f2; --cartoes: #f27aa5; --tag: #8fb3ab;
    --ok: #5fd69d; --warn: #f0bd5c; --bad: #ff8c82;
    --s1: #5fb0b8; --s2: #3d6a70; --s3: #2a4448;
    --acesso-fundo: rgba(12, 18, 16, .97);
    color-scheme: dark;
  }
}
:root[data-tema="escuro"] {
  --bg: #0c1210; --surface: #151d1a; --surface2: #1c2723;
  --ink: #e8f0ec; --muted: #9db0a8; --line: #27332f;
  --acc: var(--acc-d); --on-acc: #08130f;
  --casa: #f0a24f; --carro: #7aa2f7; --pos: #b595f2; --cartoes: #f27aa5; --tag: #8fb3ab;
  --ok: #5fd69d; --warn: #f0bd5c; --bad: #ff8c82;
  --s1: #5fb0b8; --s2: #3d6a70; --s3: #2a4448;
  --acesso-fundo: rgba(12, 18, 16, .97);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; font-family: var(--f-display); letter-spacing: -.01em; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }

/* ---------- estrutura ---------- */
.app { max-width: 640px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(120px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 16px; }
.tela { display: flex; flex-direction: column; gap: 16px; }
@media (prefers-reduced-motion: no-preference) { .tela { animation: entra .25s ease; } }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 6px; }
.topo-acoes { display: flex; align-items: center; gap: 8px; flex: none; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--f-display); font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; text-wrap: balance; }
h2 { font-family: var(--f-display); font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.sec-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.sec-h small { color: var(--muted); font-size: 12.5px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.pill .ic { width: 15px; height: 15px; }
button.pill:hover { border-color: var(--acc); }
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 30%, var(--surface)); }
.pill.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 32%, var(--surface)); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 30%, var(--surface)); }
.icobtn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.icobtn:hover { border-color: var(--acc); }
.icobtn .ic { width: 19px; height: 19px; }

/* ---------- destaque da tela inicial ---------- */
.hero { background: var(--acc); color: var(--on-acc); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero small { opacity: .85; font-size: 12.5px; font-weight: 600; }
.hero .big { display: block; font-family: var(--f-display); font-weight: 800; font-size: clamp(24px, 7.4vw, 34px); letter-spacing: -.02em; line-height: 1.05; margin-block: 2px 4px; white-space: nowrap; }
.hero-row > div:first-child { min-width: 0; }
.hero p { font-size: 13px; opacity: .92; }
.hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid color-mix(in srgb, var(--on-acc) 22%, transparent); padding-top: 12px; }
.hero-stats b { display: block; font-family: var(--f-display); font-size: 16px; font-weight: 700; }
.ringwrap { color: var(--on-acc); flex: none; }
.vazio { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 22px 16px; }
.vazio h2 { font-size: 19px; }
.vazio p { color: var(--muted); max-width: 40ch; }
.vazio .ic { width: 38px; height: 38px; color: var(--acc); }
.linha-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* ---------- dívidas ---------- */
.debts { display: flex; flex-direction: column; gap: 10px; }
.debt { --c: var(--tag); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.debt.home { --c: var(--casa); } .debt.car { --c: var(--carro); } .debt.cap { --c: var(--pos); } .debt.card { --c: var(--cartoes); } .debt.tool { --c: var(--s1); }
.debt-head { display: flex; align-items: center; gap: 12px; width: 100%; }
.ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--acc)) 15%, var(--surface)); color: var(--c, var(--acc)); flex: none; }
.debt-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.debt-t b { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.debt-t small, .debt-v small { color: var(--muted); font-size: 12px; }
.debt-v { text-align: right; display: flex; flex-direction: column; }
.debt-v b { font-family: var(--f-display); font-size: 17px; font-weight: 700; }
.bar { height: 8px; border-radius: 99px; background: var(--surface2); overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; background: var(--c, var(--acc)); border-radius: 99px; }
.debt-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.debt-meta b { color: var(--ink); font-weight: 600; }
.debt-det { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.debt-det span { display: block; font-size: 12px; color: var(--muted); }
.debt-det b { font-family: var(--f-display); font-size: 15px; font-weight: 700; }
.debt-det .full { grid-column: 1 / -1; display: flex; gap: 16px; flex-wrap: wrap; }
.link { color: var(--acc); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.link .ic { width: 16px; height: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--acc); color: var(--on-acc); font-weight: 700; padding: 12px 18px; border-radius: 14px; min-height: 44px; }
.btn .ic { width: 18px; height: 18px; }
.btn.sec { background: var(--surface2); color: var(--ink); border: 1px solid var(--line); }
.btn.perigo { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 35%, var(--surface)); }
.btn.cheio { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }

/* ---------- gráficos ---------- */
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; }
svg text { font-family: var(--f-body); fill: var(--muted); font-size: 10px; }
.legenda { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--c); margin-right: 5px; }
.leitura { margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface2); font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.leitura b.num { font-size: 16px; }
.stack { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--surface2); gap: 2px; }
.stack i { display: block; height: 100%; }

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); width: 100%; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row:last-child { padding-bottom: 2px; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.row .grow small { color: var(--muted); font-size: 12px; }
.row .val { font-family: var(--f-display); font-weight: 700; font-size: 15px; text-align: right; white-space: nowrap; }
.dayb { width: 42px; height: 46px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; flex: none; }
.dayb b { font-family: var(--f-display); font-size: 17px; }
.dayb small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.soon { color: var(--warn); font-weight: 700; }
.insights { display: flex; flex-direction: column; gap: 12px; }
.ins { display: flex; gap: 12px; align-items: flex-start; }
.ins .ic { color: var(--acc); width: 20px; height: 20px; margin-top: 1px; }
.ins p { font-size: 13.5px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; margin-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.tg { width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; }
.tg::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.tg[aria-checked="true"] { background: var(--acc); }
.tg[aria-checked="true"]::after { transform: translateX(18px); background: var(--on-acc); }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: transparent; }
.check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.check .ic { width: 14px; height: 14px; }
.budget .over .bar i { background: var(--bad); }
.budget .over .val { color: var(--bad); }
.budget .bar i { background: var(--acc); }

/* ---------- simulador e formulários ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.in { background: var(--surface2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; width: 100%; min-width: 0; min-height: 44px; }
.in:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
textarea.in { min-height: 96px; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--acc); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpi { background: var(--surface2); border-radius: 12px; padding: 10px; min-width: 0; }
.kpi small { display: block; font-size: 11.5px; color: var(--muted); }
.kpi b { display: block; font-family: var(--f-display); font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; border: 1px solid var(--line); }
.verdict.ok { background: color-mix(in srgb, var(--ok) 11%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 30%, var(--surface)); }
.verdict.warn { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 32%, var(--surface)); }
.verdict.bad { background: color-mix(in srgb, var(--bad) 11%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 30%, var(--surface)); }
.verdict > div > b { font-family: var(--f-display); font-size: 16px; display: block; }
.verdict.ok > div > b { color: var(--ok); } .verdict.warn > div > b { color: var(--warn); } .verdict.bad > div > b { color: var(--bad); }
.verdict p { font-size: 13px; margin-top: 2px; }
.rank { display: flex; flex-direction: column; gap: 10px; }
.rank-i { display: grid; grid-template-columns: 22px 1fr auto; gap: 4px 10px; align-items: center; }
.rank-i .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.rank-i .bar { grid-column: 2 / 4; }
.rank-i small { color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--acc); color: var(--on-acc); border-color: var(--acc); }
.chip.ico-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; }
.chip .ic { width: 17px; height: 17px; }
.mes-nav { display: flex; align-items: center; gap: 8px; }
.mes-nav .ic { width: 18px; height: 18px; }
.aviso-nota { font-size: 12.5px; color: var(--muted); }

/* ---------- barra de baixo, janela, aviso ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.nav-in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr 74px 1fr 1fr; align-items: end; }
.nav button.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.nav button.tab[aria-current="page"] { color: var(--acc); }
.fab { width: 58px; height: 58px; margin: -32px auto 0; border-radius: 50%; background: var(--acc); color: var(--on-acc); display: grid; place-items: center; box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--acc) 70%, black), 0 0 0 5px var(--bg); }
.fab .ic { width: 27px; height: 27px; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet { position: fixed; left: 50%; bottom: 0; z-index: 41; width: 100%; max-width: 640px; max-height: 92%; overflow-y: auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px max(16px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); transform: translate(-50%, 105%); transition: transform .25s ease; display: flex; flex-direction: column; gap: 14px; visibility: hidden; overscroll-behavior: contain; }
.sheet-open .scrim { opacity: 1; pointer-events: auto; }
.sheet-open .sheet { transform: translate(-50%, 0); visibility: visible; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto; flex: none; }
.sheet-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.seg { display: flex; background: var(--surface2); border: 1px solid var(--line); border-radius: 99px; padding: 3px; }
.seg button { flex: 1; padding: 7px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: center; }
.seg button[aria-pressed="true"] { background: var(--acc); color: var(--on-acc); }
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 14px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.found { background: var(--surface2); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.item-imp { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.item-imp:first-child { border-top: 0; }
.item-imp .grow { flex: 1; min-width: 0; }
.item-imp .grow b { display: block; font-weight: 600; overflow-wrap: anywhere; }
.item-imp small { color: var(--muted); font-size: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.tag.dup { color: var(--warn); }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 60; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 600; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.erro { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim, .toast, .tg, .tg::after { transition: none; } }
@media (min-width: 900px) { .app { padding-top: 28px; } h1 { font-size: 32px; } }
.leitura span[style*="--c"] { white-space: nowrap; }
