/* Gestor de Bolso PRO · visual do app. Sem framework: tokens no :root, tema escuro automático ou escolhido. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #64748b;
  --line: #e2e8f0;
  --brand: #1d4ed8;
  --brand-2: #2563eb;
  --brand-soft: #e8eefc;
  --brand-ink: #ffffff;
  --ok: #059669;
  --ok-soft: #e6f6ef;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .18);
  --r: 12px;
  --r-lg: 18px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --ink: #e8eef8; --ink-2: #b4c0d4; --ink-3: #8b98ad;
    --line: #22304a; --brand: #6d9bff; --brand-2: #8db4ff; --brand-soft: #1a2a4d; --brand-ink: #0b1120;
    --ok: #34d399; --ok-soft: #10352a; --warn: #fbbf24; --warn-soft: #3a2c0d; --bad: #f87171; --bad-soft: #3d1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --ink: #e8eef8; --ink-2: #b4c0d4; --ink-3: #8b98ad;
  --line: #22304a; --brand: #6d9bff; --brand-2: #8db4ff; --brand-soft: #1a2a4d; --brand-ink: #0b1120;
  --ok: #34d399; --ok-soft: #10352a; --warn: #fbbf24; --warn-soft: #3a2c0d; --bad: #f87171; --bad-soft: #3d1717;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 10px 40px rgba(0, 0, 0, .5); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; border-radius: 6px; }

/* ---------- telas de entrada (login, bloqueio, carregando) ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 28px 22px; box-shadow: var(--shadow); }
.gate-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.logo-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; flex: none; }
:root[data-theme="dark"] .logo-mark { color: #0b1120; }
.gate h1 { font-size: 1.45rem; line-height: 1.2; letter-spacing: -.01em; }
.gate p.lead { color: var(--ink-2); margin-top: 8px; }
.gate .stack { display: grid; gap: 12px; margin-top: 22px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gate-foot { margin-top: 18px; text-align: center; font-size: .85rem; color: var(--ink-3); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 650; text-decoration: none; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: var(--bad-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-google { background: var(--surface); }
.iconbtn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2); }
.iconbtn:hover { background: var(--surface-2); }
.i { width: 20px; height: 20px; flex: none; }

.field { display: grid; gap: 6px; }
.field > span { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-money { font-size: 1.9rem; font-weight: 800; text-align: right; letter-spacing: -.01em; min-height: 62px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; }
.check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--brand); }
.form-error { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: .9rem; font-weight: 600; }
.form-note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .88rem; color: var(--ink-2); }

.seg { display: flex; padding: 4px; background: var(--surface-2); border-radius: 12px; gap: 4px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; color: var(--ink-2); font-size: .9rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); }

/* ---------- estrutura do app ---------- */
.app { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.1rem; flex: 1; }
.monthnav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.monthnav .lbl { min-width: 128px; text-align: center; font-weight: 700; border: 0; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; text-transform: capitalize; }
.content { max-width: 1080px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.demo-band { background: var(--warn-soft); color: var(--warn); font-size: .85rem; font-weight: 650; text-align: center; padding: 8px 12px; }
.demo-band a, .demo-band button { color: inherit; }

.nav { position: fixed; inset: auto 0 0 0; z-index: 30; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.nav a, .nav button.navlink { display: grid; justify-items: center; gap: 3px; padding: 8px 0; color: var(--ink-3); font-size: .7rem; font-weight: 650; text-decoration: none; border: 0; background: none; }
.nav a[aria-current="page"] { color: var(--brand); }
.nav .fab { justify-self: center; width: 54px; height: 54px; border-radius: 18px; border: 0; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 40%, transparent); transform: translateY(-14px); }
.nav .fab .i { width: 26px; height: 26px; }
.nav .brand-side, .nav .side-only { display: none; }

@media (min-width: 900px) {
  .app { padding-bottom: 0; padding-left: 240px; }
  .nav { inset: 0 auto 0 0; width: 240px; height: auto; display: flex; flex-direction: column; align-items: stretch; gap: 4px; padding: 18px 14px; border-top: 0; border-right: 1px solid var(--line); background: var(--surface); }
  .nav .brand-side { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; }
  .nav .side-only { display: flex; }
  .nav .brand-side { order: -2; }
  .nav a, .nav button.navlink { display: flex; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 10px; font-size: .95rem; color: var(--ink-2); }
  .nav a:hover { background: var(--surface-2); }
  .nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
  .nav .fab { order: -1; width: 100%; height: 48px; border-radius: 12px; transform: none; display: flex; gap: 8px; font-weight: 700; margin-bottom: 14px; }
  .nav .fab::after { content: "Novo lançamento"; }
  .nav .mobile-only { display: none; }
  .content { padding: 24px 28px 40px; }
  .topbar { padding: 12px 28px; }
}

/* ---------- cartões e listas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card h2 { font-size: 1rem; }
.card-head a, .card-head button { font-size: .85rem; font-weight: 650; }
.cols { display: grid; gap: 16px; }
@media (min-width: 900px) { .cols { grid-template-columns: 1.15fr 1fr; align-items: start; } .cols-3 { grid-template-columns: repeat(3, 1fr); } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpis.fit { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.kpis.fit .kpi b { font-size: 1.05rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.kpi small { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; }
.kpi b { display: block; margin-top: 4px; font-size: 1.2rem; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi em { display: block; font-style: normal; font-size: .78rem; color: var(--ink-3); margin-top: 2px; }
.hero { background: linear-gradient(140deg, var(--brand) 0%, #1e3a8a 100%); color: #fff; border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
:root[data-theme="dark"] .hero { background: linear-gradient(140deg, #1e3a8a, #172554); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: linear-gradient(140deg, #1e3a8a, #172554); } }
.hero small { opacity: .85; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.hero .big { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; }
.hero-row { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; font-size: .9rem; }
.hero-row span { opacity: .9; }

.list { display: grid; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); min-width: 0; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.item:last-child { border-bottom: 0; }
button.item:hover { background: var(--surface-2); border-radius: 10px; }
.ico { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-size: 1.15rem; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .main b { display: block; font-weight: 650; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main span { display: block; font-size: .8rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .val { font-weight: 750; white-space: nowrap; text-align: right; }
.item .val small { display: block; font-weight: 500; font-size: .75rem; color: var(--ink-3); }
.day { font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 14px 4px 4px; display: flex; justify-content: space-between; }
.item .main .tag, .tag { display: inline-block; font-size: .7rem; font-weight: 750; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); vertical-align: middle; }
.tag-plan { background: var(--warn-soft); color: var(--warn); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; color: var(--ink-3); padding: 26px 10px; font-size: .92rem; }
.empty .btn { margin-top: 12px; }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.bar.ok > i { background: var(--ok); } .bar.alerta > i { background: var(--warn); } .bar.estourado > i, .bar.risco > i { background: var(--bad); }

.health { display: grid; gap: 12px; }
.ind { display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 10px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); }
.dot.bom { background: var(--ok); } .dot.atencao { background: var(--warn); } .dot.risco { background: var(--bad); }
.ind p { grid-column: 2 / 4; font-size: .82rem; color: var(--ink-3); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 750; padding: 4px 10px; border-radius: 999px; }
.status-pill.bom { background: var(--ok-soft); color: var(--ok); } .status-pill.atencao { background: var(--warn-soft); color: var(--warn); } .status-pill.risco { background: var(--bad-soft); color: var(--bad); }

.chart-box { position: relative; height: 240px; }
.filters { display: grid; gap: 10px; }
@media (min-width: 700px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink-2); font-weight: 650; font-size: .9rem; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.menu-grid { display: grid; gap: 10px; }
.menu-grid a { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 650; }

/* ---------- janelas (sheet) ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 23, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); animation: up .2s ease; }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sheet-head h2 { flex: 1; font-size: 1.15rem; }
.sheet form, .sheet .body { display: grid; gap: 14px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 650; font-size: .9rem; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); }
@media (min-width: 900px) { .toast { bottom: 24px; left: calc(50% + 120px); } }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table td.r, .table th.r { text-align: right; }
.scroll-x { overflow-x: auto; }
