:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --series-1: #2a78d6;
  --track: #e8e7e3;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --neutral: #8a8984;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2f2f2c;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #96958c;
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --series-1: #3987e5;
    --track: #2a2a28;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-block { width: 100%; padding: 12px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; }
main { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
.error { color: var(--critical); font-size: 14px; margin: 8px 0 0; }
.error:empty { display: none; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* Entrar / e-mail */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.narrow { width: 100%; max-width: 400px; text-align: center; }
.narrow h1 { font-size: 20px; margin: 0 0 8px; }
.narrow p { color: var(--text-secondary); margin: 0 0 16px; }
.field { display: grid; gap: 4px; text-align: left; margin-bottom: 12px; }
.field label { font-size: 14px; color: var(--text-secondary); }
.field input { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px; }

/* Assinatura */
.sub-status { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.sub-detail { color: var(--text-secondary); font-size: 14px; margin: 4px 0 12px; }

/* Mês */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav strong { font-size: 17px; }
.month-nav .btn { min-width: 44px; min-height: 44px; }

/* Números */
.hero .label { font-size: 14px; color: var(--text-secondary); }
.hero .value { font-size: 40px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.pair .label { font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.pair .value { font-size: 20px; font-weight: 600; }

/* Gastos por categoria: barras horizontais */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar-head .v { font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.bar-track { height: 10px; border-radius: 5px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }

/* Lançamentos */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.tx:last-child { border-bottom: none; }
.tx .desc { font-weight: 500; overflow-wrap: anywhere; }
.tx .meta { font-size: 13px; color: var(--text-muted); grid-column: 1; }
.tx .amount { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.empty { color: var(--text-muted); text-align: center; padding: 16px 0; margin: 0; }
.load-more { margin-top: 8px; }
#dot-in { background: var(--good); }
#dot-out { background: var(--critical); }
