:root {
  color-scheme: light;
  --bg: #f3f3f1;
  --surface: #fcfcfb;
  --surface-2: #efeeeb;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7974;
  --primary: #1c5cab;
  --primary-ink: #ffffff;
  --rec: #2a78d6;   /* série 1 (receitas) */
  --desp: #eb6834;  /* série 2 (despesas) */
  --pos: #0b7a3b;
  --neg: #c4302b;
  --grid: #e6e5e0;
  --parc: #2a78d6;    /* projeção: parcelas */
  --assin: #8a4fd3;   /* projeção: assinaturas */
  --avista: #a9a8a2;  /* projeção: compras à vista */
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --radius: 16px;
  --nav-w: 220px;
  --tap: 52px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #252523;
    --border: #2f2f2c;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #918f86;
    --primary: #3987e5;
    --rec: #3987e5;
    --desp: #d95926;
    --pos: #4cc27e;
    --neg: #f07470;
    --grid: #2c2c29;
    --parc: #3987e5; --assin: #a87ef0; --avista: #6c6b66;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #252523; --border: #2f2f2c;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #918f86; --primary: #3987e5;
  --rec: #3987e5; --desp: #d95926; --pos: #4cc27e; --neg: #f07470; --grid: #2c2c29;
  --parc: #3987e5; --assin: #a87ef0; --avista: #6c6b66;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.nav {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  width: var(--nav-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px; padding: 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; padding: 8px 12px 24px; color: var(--primary); }
.brand svg { width: 28px; height: 28px; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  min-height: var(--tap); padding: 0 16px; border: 0; border-radius: 12px;
  background: none; color: var(--text-2); font-size: 17px; font-weight: 500; text-align: left;
}
.nav-item.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 600; }

.main { flex: 1; min-width: 0; padding: 0 28px 120px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 20px 0 16px; background: var(--bg);
}
.topbar h1 { margin: 0; font-size: 28px; }

.month-picker { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px; }
.month-label { border: 0; background: none; min-width: 170px; height: 44px; font-weight: 600; font-size: 17px; border-radius: 10px; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--text-2); }
.icon-btn:active, .month-label:active { background: var(--surface-2); }

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ---------- tiles & cards ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.tile, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile { padding: 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile-label { color: var(--text-2); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tile-value { font-size: clamp(24px, 3.2vw, 34px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { color: var(--text-3); font-size: 14px; min-height: 1.4em; }
.tile-saldo .tile-value.pos { color: var(--pos); }
.tile-saldo .tile-value.neg { color: var(--neg); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.dot-rec { background: var(--rec); }
.dot-desp { background: var(--desp); }
.dot-parc { background: var(--parc); }
.dot-assin { background: var(--assin); }
.dot-avista { background: var(--avista); }

.cards { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.card { padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.legend { display: flex; gap: 16px; color: var(--text-2); font-size: 14px; }
.legend span { display: flex; align-items: center; gap: 6px; }

/* ---------- gráficos ---------- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; stroke: none; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 13px; }
.chart .axis-label.atual { fill: var(--text); font-weight: 700; }
.chart .bar-rec { fill: var(--rec); }
.chart .bar-desp { fill: var(--desp); }
.chart .bar-parc { fill: var(--parc); }
.chart .bar-assin { fill: var(--assin); }
.chart .bar-avista { fill: var(--avista); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.on { fill: color-mix(in srgb, var(--text) 5%, transparent); }

.cat-bars { display: flex; flex-direction: column; gap: 14px; }
.cat-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 12px; font-size: 15px; }
.cat-row .track { grid-column: 1 / -1; }
.cat-row .nome { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row .track { height: 10px; border-radius: 0 4px 4px 0; overflow: hidden; }
.cat-row .fill { height: 100%; background: var(--desp); border-radius: 0 4px 4px 0; min-width: 3px; transition: width .3s ease; }
.cat-row .val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.cat-row .pct { color: var(--text-3); font-weight: 400; font-size: 13px; margin-left: 4px; }

.empty { color: var(--text-3); text-align: center; padding: 32px 12px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; opacity: 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 14px;
  transition: opacity .1s; min-width: 160px;
}
.tooltip.show { opacity: 1; }
.tooltip b { display: block; margin-bottom: 4px; text-transform: capitalize; }
.tooltip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .row span { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .row strong { font-variant-numeric: tabular-nums; }

/* ---------- lançamentos ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg { border: 0; background: none; min-height: 44px; padding: 0 18px; border-radius: 9px; color: var(--text-2); font-weight: 500; }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.search { flex: 1; min-width: 200px; }
.filtro-cat { width: auto; min-width: 200px; max-width: 280px; }
.filtro-cat.ativo { border-color: var(--primary); color: var(--primary); font-weight: 600; }
.list-summary { color: var(--text-2); font-size: 14px; margin: 4px 4px 10px; font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list:empty { display: none; }
.list li + li { border-top: 1px solid var(--border); }
.lanc { display: flex; align-items: center; gap: 14px; padding: 12px 16px; min-height: 72px; }
.lanc-main { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.lanc-desc { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lanc-meta { color: var(--text-3); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.lanc-meta .badge { background: var(--surface-2); color: var(--text-2); padding: 1px 8px; border-radius: 6px; }
.lanc-meta .pend { background: color-mix(in srgb, #eda100 20%, transparent); color: var(--text); }
.lanc-valor { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; cursor: pointer; }
.lanc-valor.rec { color: var(--pos); }
.lanc-valor.desp { color: var(--text); }
.lanc-tipo { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.lanc-tipo svg { width: 20px; height: 20px; }
.lanc-tipo.rec { background: color-mix(in srgb, var(--rec) 15%, transparent); color: var(--rec); }
.lanc-tipo.desp { background: color-mix(in srgb, var(--desp) 15%, transparent); color: var(--desp); }

.check-btn { width: 48px; height: 48px; border: 0; background: none; display: grid; place-items: center; flex-shrink: 0; border-radius: 12px; }
.check-btn .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--text-3); display: grid; place-items: center; }
.check-btn .box svg { width: 16px; height: 16px; stroke-width: 3; opacity: 0; color: #fff; }
.check-btn.on .box { background: var(--pos); border-color: var(--pos); }
.check-btn.on .box svg { opacity: 1; }

.list-flat li { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); padding: 0 8px 0 16px; cursor: pointer; }
.list-flat li:active { background: var(--surface-2); }
.list-flat li svg { color: var(--text-3); width: 20px; height: 20px; }
.cat-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.cat-cols .list { box-shadow: none; border-radius: 12px; }

/* ---------- cartões ---------- */
.cartoes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.cc {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; text-align: left; min-width: 0;
}
.cc:active { transform: scale(.99); }
.cc-top { display: flex; align-items: center; gap: 12px; }
.cc-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.cc-nome { font-weight: 700; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-label { color: var(--text-2); font-size: 14px; }
.cc-valor { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.cc-meta { color: var(--text-3); font-size: 14px; }
.cc-alerta { font-size: 14px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, #eda100 16%, transparent); color: var(--text); }
.cc-alerta.vencida { background: color-mix(in srgb, var(--neg) 16%, transparent); }
.limite-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.limite-bar > div { height: 100%; background: var(--primary); border-radius: 4px; }
.limite-bar.alto > div { background: var(--neg); }
.limite-txt { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cc-novo { border: 2px dashed var(--border); background: none; box-shadow: none; align-items: center; justify-content: center;
  color: var(--primary); font-weight: 600; min-height: 180px; }
.cc-novo svg { width: 32px; height: 32px; }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-aberta { color: var(--primary); }
.status-fechada { color: #b07800; }
.status-vencida { color: var(--neg); }
.status-paga { color: var(--pos); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .status-fechada { color: #eda100; } }
:root[data-theme="dark"] .status-fechada { color: #eda100; }

.detalhe-top { display: flex; justify-content: space-between; align-items: center; margin: -4px -12px 8px; }
.btn-voltar { display: inline-flex; align-items: center; gap: 4px; padding-left: 8px; }
.fatura-card { margin-bottom: 16px; }
.fatura-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -8px -8px 12px; }
.fatura-titulo { text-align: center; display: flex; flex-direction: column; }
.fatura-titulo small { color: var(--text-3); font-size: 13px; }
.fatura-titulo strong { font-size: 18px; }
.fatura-corpo { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.fatura-total { font-size: clamp(30px, 4vw, 40px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.fatura-datas { color: var(--text-2); font-size: 15px; }
.fatura-acoes { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.parc { background: color-mix(in srgb, var(--primary) 14%, transparent) !important; color: var(--primary) !important; font-weight: 600; }
.lanc-sub { display: block; color: var(--text-3); font-size: 13px; font-weight: 400; text-align: right; }
.badge-cartao { display: inline-flex; align-items: center; gap: 4px; }
.badge-cartao svg { width: 13px; height: 13px; color: var(--primary); }

.assin-card { margin-top: 16px; }
.assin-card h2 svg { width: 18px; height: 18px; color: var(--primary); }
.assin-card .list { box-shadow: none; border-radius: 12px; }
.hint-sm { font-size: 14px; margin: -4px 0 12px; }
.cc-assin { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 14px; }
.cc-assin svg { width: 15px; height: 15px; color: var(--primary); }

/* ---------- projeção ---------- */
.proj-cols { margin-top: 16px; }
.segmented[hidden] { display: none; }
#view-projecao .segmented { max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#view-projecao .seg { flex-shrink: 0; white-space: nowrap; }
.proj-meses { display: flex; flex-direction: column; }
.proj-mes + .proj-mes { border-top: 1px solid var(--border); }
.proj-mes summary {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 12px 4px; cursor: pointer; list-style: none; min-height: var(--tap);
}
.proj-mes summary::-webkit-details-marker { display: none; }
.proj-mes-nome { font-weight: 600; }
.proj-mes-total { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.proj-mes-partes { grid-column: 1 / -1; display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.proj-mes-partes span { display: inline-flex; align-items: center; gap: 6px; }
.proj-mes[open] summary { color: var(--primary); }
.proj-mes .list { box-shadow: none; border-radius: 12px; margin: 0 0 12px; }

/* ---------- fixas ---------- */
.hint { color: var(--text-2); margin: 0 4px 16px; max-width: 70ch; }
.tiles-sm .tile-value { font-size: clamp(22px, 2.6vw, 28px); }
.fixa-item { gap: 12px; padding: 10px 12px 10px 16px !important; min-height: 68px !important; }
.fixa-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fixa-info .lanc-desc { font-size: 16px; }
.fixa-valor { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fixa-item.encerrada .fixa-info, .fixa-item.encerrada .fixa-valor { opacity: .55; }
.badge-fixa { display: inline-flex; align-items: center; gap: 4px; }
.badge-fixa svg { width: 12px; height: 12px; color: var(--primary); }
.nota { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--text-2); font-size: 14px; }
.nota svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--primary); margin-top: 1px; }
.nota[hidden], .field[hidden] { display: none; }
.field small { color: var(--text-3); font-weight: 400; }

/* ---------- login / sair ---------- */
.form-sair[hidden] { display: none !important; }
.form-sair-nav { margin-top: auto; }
.form-sair-nav .nav-item { width: 100%; }
.form-sair-topo { display: none; margin-left: auto; }
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 24px; }
.login-brand { display: flex !important; justify-content: center; padding: 0 0 20px !important; }
.login-brand span { display: inline !important; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .form-error { margin: 0; }

/* ---------- botões & formulários ---------- */
.btn { min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: none; color: var(--primary); }
.btn-danger { background: none; color: var(--neg); }
.btn:active { filter: brightness(.92); }
.btn[disabled] { opacity: .5; }

.fab {
  position: fixed; right: 28px; bottom: 28px; z-index: 10;
  width: 64px; height: 64px; border-radius: 20px; border: 0;
  background: var(--primary); color: #fff; box-shadow: 0 6px 20px rgba(28,92,171,.4);
  display: grid; place-items: center;
}
.fab svg { width: 30px; height: 30px; }
.fab:active { transform: scale(.95); }
.fab.hidden { display: none; }

.input {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font-size: 17px;
}
textarea.input { padding: 12px 14px; resize: vertical; }
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.input-valor { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.sheet {
  border: 0; padding: 0; border-radius: 20px; width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.sheet-sm { width: min(460px, calc(100vw - 32px)); }
.sheet::backdrop { background: rgba(0,0,0,.4); }
.sheet[open] { animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(12px); } }
.sheet form { padding: 20px 24px 24px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { margin: 0; font-size: 22px; }
.segmented-lg { display: flex; margin-bottom: 16px; }
.segmented-lg .seg { flex: 1; min-height: 48px; font-size: 17px; }
#form-tipo .seg.active[data-tipo="despesa"] { color: var(--desp); }
#form-tipo .seg.active[data-tipo="receita"] { color: var(--rec); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--text-2); font-size: 14px; font-weight: 500; }
.field-full { grid-column: 1 / -1; }
.field-check { flex-direction: row; align-items: center; gap: 12px; align-self: end; min-height: var(--tap); cursor: pointer; }
.field-check input { width: 26px; height: 26px; accent-color: var(--pos); margin: 0; }
.field-check span { font-size: 17px; color: var(--text); }
.form-error { color: var(--neg); min-height: 1.4em; margin: 12px 0 0; font-size: 15px; }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.spacer { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .2s; font-weight: 500; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsivo ---------- */

/* Tablet retrato / telas menores: navegação inferior */
@media (max-width: 899px) {
  .app { flex-direction: column; }
  .nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 20;
    width: auto; height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--border);
  }
  .brand { display: none; }
  .form-sair-nav { display: none; }
  .form-sair-topo { display: block; }
  .nav-item { flex: 1; flex-direction: column; gap: 2px; justify-content: center; font-size: 13px; min-height: 60px; padding: 0; text-align: center; }
  .main { padding: 0 20px 140px; }
  .fab { bottom: calc(96px + env(safe-area-inset-bottom)); right: 20px; }
  .cards { grid-template-columns: 1fr; }
  #view-fixas .cat-cols { grid-template-columns: 1fr; }
  .nav-item { font-size: 12px; }
  .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
}

/* Celular */
@media (max-width: 599px) {
  .main { padding: 0 16px 140px; }
  .topbar h1 { font-size: 24px; }
  .month-picker { width: 100%; justify-content: space-between; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 12px; }
  .tile-saldo { grid-column: 1 / -1; }
  .tiles-sm .tile-label { font-size: 13px; }
  .tile { padding: 16px; }
  .cat-cols { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .sheet form { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .lanc { gap: 10px; padding: 10px 12px; }
  .lanc-tipo { display: none; }
  .cartoes-grid { grid-template-columns: 1fr; }
  .fatura-acoes { width: 100%; justify-content: space-between; }
  .segmented:not(.segmented-lg) { width: 100%; }
  .filtro-cat { width: 100%; max-width: none; }
  .segmented:not(.segmented-lg) .seg { flex: 1; padding: 0 8px; }
}

/* Tablet paisagem: sidebar compacta quando a largura é limitada */
@media (min-width: 900px) and (max-width: 1100px) {
  :root { --nav-w: 88px; }
  .brand span { display: none; }
  .brand { justify-content: center; padding: 8px 0 24px; }
  .nav-item { flex-direction: column; gap: 4px; justify-content: center; padding: 10px 0; font-size: 12px; min-height: 68px; }
}
