/* =========================================================================
   Meu Financeiro — sistema visual
   Cena: fim da noite, celular na mão, luz baixa. Fundo neutro profundo,
   um cobalto luminoso como instrumento e um âmbar como brasa.
   ========================================================================= */

:root {
  /* Schibsted Grotesk: grotesca de jornal — quente, algarismos bem desenhados
     e acentuação completa para o português. Se não carregar, cai numa pilha
     de sistema que mantém a mesma métrica. */
  --font: "Schibsted Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  /* --- claro --- */
  --bg:            oklch(1 0 0);
  --surface:       oklch(0.977 0 0);
  --surface-2:     oklch(0.955 0 0);
  --surface-3:     oklch(0.925 0 0);
  --line:          oklch(0.905 0 0);
  --line-soft:     oklch(0.938 0 0);
  --ink:           oklch(0.205 0 0);
  --ink-2:         oklch(0.375 0 0);
  --muted:         oklch(0.505 0 0);
  --faint:         oklch(0.66 0 0);

  --brand:         oklch(0.505 0.175 258);
  --brand-solid:   oklch(0.525 0.172 258);
  --brand-ink:     oklch(0.99 0 0);
  --brand-wash:    oklch(0.955 0.028 258);
  --brand-line:    oklch(0.855 0.055 258);

  --accent:        oklch(0.60 0.135 68);
  --accent-wash:   oklch(0.955 0.038 78);

  --pos:           oklch(0.475 0.125 156);
  --pos-wash:      oklch(0.955 0.035 156);
  --neg:           oklch(0.535 0.185 26);
  --neg-wash:      oklch(0.958 0.028 26);
  --warn:          oklch(0.545 0.13 75);
  --warn-wash:     oklch(0.958 0.04 80);

  --grid:          oklch(0.925 0 0);
  --track:         oklch(0.93 0 0);
  --overlay:       oklch(0.20 0 0 / 0.42);
  --shadow-1:      0 1px 2px oklch(0.2 0 0 / .05), 0 1px 3px oklch(0.2 0 0 / .05);
  --shadow-2:      0 4px 16px oklch(0.2 0 0 / .08), 0 1px 3px oklch(0.2 0 0 / .05);
  --shadow-3:      0 18px 48px oklch(0.2 0 0 / .16), 0 2px 8px oklch(0.2 0 0 / .06);
  --shadow-fab:    0 8px 24px oklch(0.525 0.172 258 / .38);

  /* raios */
  --r-xs: 7px; --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 26px; --r-full: 999px;

  /* espaço */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
  --s6: 24px; --s7: 28px; --s8: 32px; --s10: 40px; --s12: 52px;

  /* camadas */
  --z-nav: 100; --z-fab: 120; --z-bar: 130; --z-backdrop: 200;
  --z-sheet: 210; --z-toast: 300; --z-lock: 400;

  /* movimento */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
  --d1: 140ms; --d2: 220ms; --d3: 340ms;

  /* Áreas que o sistema ocupa: relógio e notificações em cima, barra de
     gestos embaixo, entalhe nas laterais quando o celular está deitado. */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --tabbar-h: 62px;

  /* margem lateral do conteúdo, já respeitando o entalhe */
  --gutter: var(--s5);
  --pad-l: max(var(--gutter), var(--safe-l));
  --pad-r: max(var(--gutter), var(--safe-r));
}

:root[data-theme="dark"] {
  --bg:            oklch(0.115 0 0);
  --surface:       oklch(0.163 0 0);
  --surface-2:     oklch(0.205 0 0);
  --surface-3:     oklch(0.255 0 0);
  --line:          oklch(0.278 0 0);
  --line-soft:     oklch(0.225 0 0);
  --ink:           oklch(0.968 0 0);
  --ink-2:         oklch(0.835 0 0);
  --muted:         oklch(0.702 0 0);
  --faint:         oklch(0.545 0 0);

  --brand:         oklch(0.755 0.135 258);
  --brand-solid:   oklch(0.525 0.178 258);
  --brand-ink:     oklch(0.99 0 0);
  --brand-wash:    oklch(0.278 0.058 258);
  --brand-line:    oklch(0.375 0.085 258);

  --accent:        oklch(0.815 0.135 78);
  --accent-wash:   oklch(0.30 0.055 72);

  --pos:           oklch(0.775 0.145 158);
  --pos-wash:      oklch(0.278 0.052 158);
  --neg:           oklch(0.715 0.155 24);
  --neg-wash:      oklch(0.288 0.06 24);
  --warn:          oklch(0.815 0.135 78);
  --warn-wash:     oklch(0.30 0.055 72);

  --grid:          oklch(0.255 0 0);
  --track:         oklch(0.245 0 0);
  --overlay:       oklch(0.06 0 0 / .62);
  --shadow-1:      0 1px 2px oklch(0 0 0 / .35);
  --shadow-2:      0 6px 20px oklch(0 0 0 / .42);
  --shadow-3:      0 22px 56px oklch(0 0 0 / .60);
  --shadow-fab:    0 10px 26px oklch(0.30 0.10 258 / .55);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  -webkit-text-size-adjust: 100%;
  /* trava de segurança: nada de barra horizontal, mesmo que um dia entre
     algum elemento largo demais. "clip" não cria área de rolagem, então
     não atrapalha a barra de cima que fica grudada no topo. */
  overflow-x: clip;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  /* mata o zoom do toque duplo (o pinça-para-ampliar continua funcionando) */
  touch-action: manipulation;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: none; border: 0; padding: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-xs); }
::selection { background: var(--brand-wash); color: var(--ink); }

/* Nesta fonte o algarismo tabular também alarga o ponto e a vírgula, e
   "R$ 2 . 311 , 80" fica arejado demais. Como todo valor tem duas casas e as
   listas são alinhadas à direita, o proporcional alinha igual e lê melhor. */
.num { font-variant-numeric: proportional-nums; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.ic { width: 20px; height: 20px; display: block; flex: none; }
.ic--sm { width: 16px; height: 16px; }
.ic--md { width: 24px; height: 24px; }
.ic--lg { width: 28px; height: 28px; }

/* ---------- boot ---------- */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: var(--z-lock);
}
.boot__mark, .rail__mark, .auth__mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(150deg, var(--brand-solid), oklch(0.44 0.16 272));
  position: relative; flex: none;
}
.boot__mark::after, .rail__mark::after, .auth__mark::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(var(--brand-ink), var(--brand-ink)) 9px 19px / 3.5px 7px no-repeat,
    linear-gradient(var(--brand-ink), var(--brand-ink)) 15px 14px / 3.5px 12px no-repeat,
    linear-gradient(var(--brand-ink), var(--brand-ink)) 21px 10px / 3.5px 16px no-repeat;
  opacity: .95; border-radius: inherit;
}
.boot__mark { animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: .35; transform: scale(.94); } 50% { opacity: 1; transform: scale(1); } }

/* =========================================================================
   ENTRAR
   ========================================================================= */
.auth {
  position: fixed; inset: 0; z-index: var(--z-lock);
  display: grid; place-items: center;
  padding: calc(var(--s6) + var(--safe-t)) max(var(--s6), var(--safe-r))
           calc(var(--s6) + var(--safe-b)) max(var(--s6), var(--safe-l));
  background: var(--bg); overflow-y: auto;
}
.auth__box { width: 100%; max-width: 360px; }
.auth__mark { margin-bottom: var(--s6); }
.auth__title { font-size: 26px; font-weight: 650; letter-spacing: -.022em; }
.auth__sub { color: var(--muted); font-size: 14px; margin-top: var(--s2); }
.auth__form { margin-top: var(--s7); display: grid; gap: var(--s4); }
.auth__err {
  margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md);
  background: var(--neg-wash); color: var(--neg); font-size: 13.5px; font-weight: 500;
  border: 1px solid color-mix(in oklab, var(--neg) 30%, transparent);
}
.auth__foot { margin-top: var(--s6); font-size: 13.5px; color: var(--muted); text-align: center; }
.auth__link { color: var(--brand); font-weight: 550; }
.auth__note {
  margin-top: var(--s6); padding: var(--s4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted); line-height: 1.55;
}

/* =========================================================================
   BLOQUEIO / PIN
   ========================================================================= */
.lock {
  position: fixed; inset: 0; z-index: var(--z-lock);
  display: grid; place-items: center; background: var(--bg);
  padding: calc(var(--s6) + var(--safe-t)) max(var(--s6), var(--safe-r))
           calc(var(--s6) + var(--safe-b)) max(var(--s6), var(--safe-l));
  overflow-y: auto;
}
.lock__inner { width: 100%; max-width: 300px; text-align: center; }
.lock__badge {
  width: 52px; height: 52px; margin: 0 auto var(--s5); border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: var(--brand-wash); color: var(--brand);
}
.lock__title { font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.lock__hint { font-size: 13.5px; color: var(--muted); margin-top: var(--s1); min-height: 20px; }
.lock.is-wrong .lock__hint { color: var(--neg); }
.lock__alt { margin-top: var(--s6); font-size: 13.5px; color: var(--brand); font-weight: 550; }

.pin { display: flex; justify-content: center; gap: var(--s3); margin: var(--s6) 0 var(--s8); }
.pin i {
  width: 11px; height: 11px; border-radius: var(--r-full);
  background: transparent; border: 1.6px solid var(--line);
  transition: background var(--d1) var(--ease), border-color var(--d1) var(--ease), transform var(--d1) var(--ease);
}
.pin i.on { background: var(--brand); border-color: var(--brand); transform: scale(1.12); }
.lock.is-wrong .pin { animation: shake 400ms var(--ease); }
.lock.is-wrong .pin i.on { background: var(--neg); border-color: var(--neg); }
@keyframes shake {
  0%,100% { transform: translateX(0); } 18% { transform: translateX(-8px); }
  38% { transform: translateX(7px); } 58% { transform: translateX(-4px); } 78% { transform: translateX(3px); }
}

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); }
.key {
  height: 62px; border-radius: var(--r-lg); font-size: 22px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--line-soft);
  display: grid; place-items: center;
  transition: background var(--d1) var(--ease), transform var(--d1) var(--ease);
}
.key:active { background: var(--surface-3); transform: scale(.96); }
.key--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.key--ghost:active { background: var(--surface-2); }

/* =========================================================================
   ONBOARDING
   ========================================================================= */
.onboard {
  position: fixed; inset: 0; z-index: var(--z-lock); background: var(--bg);
  overflow-y: auto;
  padding: calc(var(--s10) + var(--safe-t)) max(var(--s6), var(--safe-r))
           calc(var(--s8) + var(--safe-b)) max(var(--s6), var(--safe-l));
}
.onboard__box { max-width: 420px; margin: 0 auto; }
.onboard__step { font-size: 12px; font-weight: 600; color: var(--brand); letter-spacing: .01em; }
.onboard__title { font-size: 27px; font-weight: 650; letter-spacing: -.025em; margin-top: var(--s2); text-wrap: balance; }
.onboard__text { color: var(--muted); margin-top: var(--s3); line-height: 1.6; font-size: 14.5px; }
.onboard__body { margin-top: var(--s7); display: grid; gap: var(--s4); }
.onboard__actions { margin-top: var(--s8); display: grid; gap: var(--s3); }

/* =========================================================================
   ESTRUTURA
   ========================================================================= */
.app { display: flex; min-height: 100dvh; }
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

.rail { display: none; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-bar);
  padding-top: var(--safe-t);
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d2) var(--ease);
}
/* Faixa opaca atrás do relógio e das notificações: sem ela, o conteúdo
   rolando por baixo aparece borrado em cima da barra do sistema. */
.topbar::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0;
  height: var(--safe-t); background: var(--bg);
}
.topbar.is-stuck { border-bottom-color: var(--line-soft); }
.topbar__row {
  height: 54px;
  padding-left: var(--pad-l); padding-right: var(--pad-r);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.topbar__title { font-size: 21px; font-weight: 650; letter-spacing: -.024em; }
.topbar__actions { display: flex; align-items: center; gap: var(--s2); }
.iconbtn {
  position: relative;
  width: 38px; height: 38px; border-radius: var(--r-full);
  display: grid; place-items: center; color: var(--ink-2);
  transition: background var(--d1) var(--ease), color var(--d1) var(--ease);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn:active { background: var(--surface-3); }
.iconbtn.is-on { background: var(--brand-wash); color: var(--brand); }
/* A bolinha precisa do pai posicionado, senão ela escapa e cai sobre o texto. */
.iconbtn__dot {
  position: absolute; top: 6px; right: 5px; margin: 0;
  width: 8px; height: 8px; border-radius: var(--r-full);
  border: 1.5px solid var(--bg);
}

.monthbar {
  display: flex; align-items: center; gap: var(--s1);
  padding: 0 var(--pad-r) var(--s3) var(--pad-l);
}
.monthbar__nav {
  width: 34px; height: 34px; border-radius: var(--r-full); color: var(--muted);
  display: grid; place-items: center;
  transition: background var(--d1) var(--ease), color var(--d1) var(--ease);
}
.monthbar__nav:hover { background: var(--surface-2); color: var(--ink); }
.monthbar__label {
  flex: 1; min-width: 0; height: 34px; border-radius: var(--r-sm);
  font-size: 14.5px; font-weight: 550; letter-spacing: -.01em;
  white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: background var(--d1) var(--ease);
}
.monthbar__label:hover { background: var(--surface-2); }
.monthbar__label small { color: var(--muted); font-weight: 450; font-size: 12.5px; }

/* Coluna com gap: sem isto os primeiros blocos ficavam colados, porque só
   as seções (.sect) tinham margem e os painéis do topo não. */
.view {
  flex: 1;
  display: flex; flex-direction: column; gap: var(--s4);
  padding: var(--s4) var(--pad-r) calc(var(--tabbar-h) + var(--s12) + var(--safe-b)) var(--pad-l);
  max-width: 760px; width: 100%; margin: 0 auto;
  min-width: 0;
}
.view > * { min-width: 0; }
.view:focus { outline: none; }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l); padding-right: var(--safe-r);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line-soft);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 10.5px; font-weight: 550; letter-spacing: .002em;
  transition: color var(--d1) var(--ease);
  position: relative;
}
.tab .ic { transition: transform var(--d2) var(--ease); }
.tab.is-on { color: var(--brand); }
.tab.is-on .ic { transform: translateY(-1px); }
.tab:active .ic { transform: scale(.9); }

.fab {
  position: fixed; right: max(var(--s5), var(--safe-r)); z-index: var(--z-fab);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s4));
  width: 54px; height: 54px; border-radius: var(--r-xl);
  background: var(--brand-solid); color: var(--brand-ink);
  display: grid; place-items: center;
  box-shadow: var(--shadow-fab);
  transition: transform var(--d2) var(--ease), box-shadow var(--d2) var(--ease);
}
.fab:hover { transform: translateY(-2px); }
.fab:active { transform: scale(.93); }
/* Sai da frente quando você desce a lista, para não tapar valores. */
.fab.is-away { transform: translateY(96px) scale(.85); opacity: 0; pointer-events: none; }

/* =========================================================================
   PEÇAS
   ========================================================================= */
/* minmax(0,1fr) em toda grade de uma coluna: impede que um filho teimoso
   (input, tabela, palavra longa) estique o container além da tela. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.stack--tight { gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* o gap da coluna já dá 16px; a seção acrescenta 12 para virar 28 */
.sect { margin-top: var(--s3); }
.sect:first-child { margin-top: 0; }
.sect__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s3); padding: 0 var(--s1);
}
.sect__title { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: .006em; }
.sect__action { font-size: 13px; font-weight: 550; color: var(--brand); }

.panel {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: var(--s5);
}
.panel--flush { padding: 0; overflow: hidden; }
.panel--quiet { background: transparent; border-color: var(--line); }

/* saldo do mês */
.balance { padding: var(--s6) var(--s5) var(--s5); }
.balance__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.balance__value {
  font-size: clamp(34px, 11vw, 44px); font-weight: 640; letter-spacing: -.038em;
  line-height: 1.05; margin-top: var(--s2); display: block;
}
.balance__value.is-neg { color: var(--neg); }
.balance__delta { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 550; margin-top: var(--s3); color: var(--muted); }
.balance__delta b { font-weight: 600; }
.balance__delta.up b { color: var(--pos); }
.balance__delta.down b { color: var(--neg); }

.splitbar { display: flex; height: 6px; border-radius: var(--r-full); overflow: hidden; background: var(--track); margin-top: var(--s5); gap: 2px; }
.splitbar i {
  display: block; height: 100%; border-radius: var(--r-full);
  transform-origin: left center;
}
/* Cresce por transform, não por width: não recalcula layout a cada quadro.
   E só ao entrar na tela — senão as barras recresciam a cada sincronização,
   que era metade da "piscada". */
@keyframes crescer { from { transform: scaleX(0); } }
.view.is-entering .splitbar i,
.view.is-entering .meter i { animation: crescer var(--d3) var(--ease) both; }
.splitbar .in { background: var(--pos); }
.splitbar .out { background: var(--neg); }
/* Grade que quebra sozinha: com três valores em tela estreita, o terceiro
   desce em vez de escrever por cima do vizinho. */
.splitlegend {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: var(--s3) var(--s4); margin-top: var(--s4);
  /* sem o teto, numa tela larga os dois valores ficam nas pontas opostas */
  max-width: 520px;
}
.splitlegend > div { min-width: 0; }
.splitlegend dt { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.splitlegend dt::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; flex: none; }
.splitlegend .in dt { color: var(--pos); }
.splitlegend .out dt { color: var(--neg); }
.splitlegend dd {
  margin: 3px 0 0; font-size: 16.5px; font-weight: 600;
  letter-spacing: -.024em; color: var(--ink); white-space: nowrap;
}

/* mini cartões */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
.tile {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); padding: var(--s4);
  text-align: left; display: block; width: 100%;
  transition: border-color var(--d1) var(--ease), transform var(--d1) var(--ease);
}
button.tile:active { transform: scale(.985); }
button.tile:hover { border-color: var(--line); }
.tile__top { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.tile__top .ic { width: 15px; height: 15px; }
.tile__value { font-size: 19px; font-weight: 620; letter-spacing: -.026em; margin-top: var(--s2); }
.tile__foot { font-size: 12px; color: var(--faint); margin-top: 3px; }
.tile__value.pos { color: var(--pos); }
.tile__value.neg { color: var(--neg); }

/* linhas de lista */
.list { display: grid; }
.item {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); width: 100%; text-align: left;
  border-radius: var(--r-md);
  transition: background var(--d1) var(--ease);
}
button.item:hover { background: var(--surface-2); }
button.item:active { background: var(--surface-3); }
.panel--flush .item { border-radius: 0; padding: var(--s4); }
.panel--flush .item + .item { box-shadow: inset 0 1px 0 var(--line-soft); }

/* linha com ação rápida ao lado (marcar como pago) */
.item--split { padding: 0 var(--s2) 0 0; gap: 0; }
.panel--flush .item--split { padding: 0 var(--s2) 0 0; }
.item__hit {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4); text-align: left; border-radius: var(--r-md);
  transition: background var(--d1) var(--ease);
}
.item__hit:hover { background: var(--surface-2); }
.item__hit:active { background: var(--surface-3); }
.item--split > .iconbtn { color: var(--muted); border: 1px solid var(--line); width: 34px; height: 34px; }
.item--split > .iconbtn:hover { background: var(--pos-wash); color: var(--pos); border-color: transparent; }

.avatar {
  width: 38px; height: 38px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; font-size: 15px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
}
.avatar--tint { background: var(--tint-wash, var(--surface-2)); color: var(--tint, var(--ink-2)); }
.item__main { flex: 1; min-width: 0; }
/* também precisa de block: em linha, o "…" de texto longo não funciona */
.item__title {
  display: block; font-size: 14.5px; font-weight: 520; letter-spacing: -.008em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item__sub {
  font-size: 12.5px; color: var(--muted); margin-top: 1px;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.item__sub .ic { width: 13px; height: 13px; }
.item__side { text-align: right; flex: none; }
.item__amount { display: block; font-size: 15px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
.item__amount.pos { color: var(--pos); }
.item__amount.neg { color: var(--ink); }
.item__note { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; white-space: nowrap; }

.daygroup + .daygroup { margin-top: var(--s5); }
.daygroup__head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 var(--s2) var(--s2); gap: var(--s3);
}
.daygroup__date { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
/* capitalize só no dia da semana — na frase inteira vira "16 De Setembro" */
.daygroup__dow { color: var(--faint); font-weight: 450; text-transform: capitalize; }
.daygroup__sum { font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* chips */
.chips {
  display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none;
  padding: var(--s1) var(--pad-r) var(--s3) var(--pad-l);
  margin-left: calc(var(--pad-l) * -1); margin-right: calc(var(--pad-r) * -1);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px var(--s3); border-radius: var(--r-full);
  font-size: 13px; font-weight: 520; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line-soft); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--d1) var(--ease), color var(--d1) var(--ease), border-color var(--d1) var(--ease);
}
.chip:active { transform: scale(.96); }
.chip.is-on { background: var(--brand-solid); border-color: var(--brand-solid); color: var(--brand-ink); }
.chip .ic { width: 14px; height: 14px; }

/* faixa de aviso clicável (contas em atraso) */
.alerta {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%; margin-top: var(--s4); text-align: left;
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  background: var(--neg-wash); color: var(--neg);
  font-size: 13.5px; font-weight: 500; line-height: 1.4;
  transition: background var(--d1) var(--ease);
}
.alerta b { font-weight: 650; }
.alerta:hover { background: color-mix(in oklab, var(--neg-wash) 84%, var(--neg)); }
.alerta:active { transform: scale(.99); }
.alerta .ic { flex: none; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: var(--r-xs);
  font-size: 11px; font-weight: 600; letter-spacing: .004em;
  background: var(--surface-2); color: var(--muted);
}
.badge .ic { width: 11px; height: 11px; }
.badge--warn { background: var(--warn-wash); color: var(--warn); }
.badge--neg  { background: var(--neg-wash); color: var(--neg); }
.badge--pos  { background: var(--pos-wash); color: var(--pos); }
.badge--brand{ background: var(--brand-wash); color: var(--brand); }

/* barras de progresso */
.meter { height: 5px; border-radius: var(--r-full); background: var(--track); overflow: hidden; }
.meter i {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--tint, var(--brand));
  transform-origin: left center;
}
.meter.over i { background: var(--neg); }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 46px; padding: 0 var(--s5); border-radius: var(--r-md);
  font-size: 15px; font-weight: 560; letter-spacing: -.008em;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid transparent;
  transition: background var(--d1) var(--ease), transform var(--d1) var(--ease), opacity var(--d1) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn--primary { background: var(--brand-solid); color: var(--brand-ink); }
.btn--primary:hover { background: color-mix(in oklab, var(--brand-solid) 88%, white); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--danger { background: var(--neg-wash); color: var(--neg); }
.btn--danger:hover { background: color-mix(in oklab, var(--neg-wash) 82%, var(--neg)); }
.btn--block { width: 100%; }
.btn--sm { height: 36px; padding: 0 var(--s4); font-size: 13.5px; border-radius: var(--r-sm); }
.btn__spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* campos */
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; }
.field__label { font-size: 12.5px; font-weight: 550; color: var(--muted); padding-left: 2px; }
.field__help { font-size: 12px; color: var(--faint); padding-left: 2px; line-height: 1.45; }
.field__err { font-size: 12.5px; color: var(--neg); font-weight: 500; padding-left: 2px; }
.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 var(--s4);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 15.5px; color: var(--ink);
  transition: border-color var(--d1) var(--ease), background var(--d1) var(--ease);
  appearance: none;
}
.textarea { height: auto; min-height: 84px; padding: var(--s3) var(--s4); resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); background: var(--bg); }
/* Um anel só: o contorno padrão desenhava um segundo retângulo em volta. */
.input:focus-visible, .select:focus-visible, .textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 22%, transparent);
}
.field.has-err .input, .field.has-err .select { border-color: var(--neg); }
.select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 21px, calc(100% - 14px) 21px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: var(--s10); color: var(--ink);
}
.select option { background: var(--surface); color: var(--ink); }

.money {
  display: flex; align-items: baseline; gap: var(--s2);
  min-width: 0;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-md); padding: var(--s3) var(--s4);
  transition: border-color var(--d1) var(--ease);
}
/* O anel de foco fica na caixa inteira; sem isto o input desenha um segundo
   anel por dentro e vira caixa dentro de caixa. */
.money:focus-within {
  border-color: var(--brand); background: var(--bg);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 22%, transparent);
}
.money__in:focus-visible { outline: none; }
.money__cur { font-size: 16px; font-weight: 550; color: var(--muted); flex: none; }
/* width:100% + min-width:0 são obrigatórios: sem eles o input impõe a largura
   de ~20 caracteres (446px a 30px de fonte) e arrasta a folha inteira. */
.money__in {
  flex: 1 1 0; width: 100%; min-width: 0;
  border: 0; background: none; padding: 0;
  font-size: 30px; font-weight: 620; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.money__in::placeholder { color: var(--faint); }
.money.is-in .money__in { color: var(--pos); }
.money.is-out .money__in { color: var(--ink); }

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border-radius: var(--r-md); padding: 3px; gap: 3px;
}
.segmented button {
  height: 38px; border-radius: 11px; font-size: 14px; font-weight: 550; color: var(--muted);
  transition: background var(--d2) var(--ease), color var(--d2) var(--ease), box-shadow var(--d2) var(--ease);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button.is-on { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented button.is-on[data-tone="in"] { color: var(--pos); }
.segmented button.is-on[data-tone="out"] { color: var(--neg); }

.optgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.opt {
  padding: var(--s3); border-radius: var(--r-md); text-align: center;
  background: var(--surface); border: 1px solid var(--line-soft);
  font-size: 12.5px; font-weight: 520; color: var(--ink-2);
  display: grid; gap: 6px; justify-items: center;
  transition: border-color var(--d1) var(--ease), background var(--d1) var(--ease), color var(--d1) var(--ease);
}
.opt .ic { color: var(--muted); }
.opt.is-on { border-color: var(--brand); background: var(--brand-wash); color: var(--brand); }
/* herda: quando a categoria pinta o botão com a cor dela, o ícone acompanha */
.opt.is-on .ic { color: inherit; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); width: 100%; padding: var(--s3) 0; }
/* display:block é obrigatório: <span> é elemento em linha e o subtítulo
   grudava no título ("Todo mêsRepete automaticamente..."). */
.switch__text { text-align: left; min-width: 0; }
.switch__title { display: block; font-size: 14.5px; font-weight: 500; }
.switch__sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
/* bloco de opções: interruptores empilhados com uma linha separando */
.opcoes { padding: 2px var(--s4); }
.opcoes > * + * { box-shadow: inset 0 1px 0 var(--line-soft); }
.opcoes .switch { padding: var(--s4) 0; }
.opcoes .field { padding-bottom: var(--s4); }

.switch__box {
  width: 46px; height: 28px; border-radius: var(--r-full); flex: none;
  background: var(--surface-3); position: relative;
  transition: background var(--d2) var(--ease);
}
.switch__box::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-1);
  transition: transform var(--d2) var(--ease);
}
.switch.is-on .switch__box { background: var(--brand-solid); }
.switch.is-on .switch__box::after { transform: translateX(18px); }

/* =========================================================================
   SHEET (formulários)
   ========================================================================= */
/* O navegador aplica width/height: fit-content no <dialog>. Sem fixar a
   altura, um painel posicionado por absolute não conta como conteúdo, o
   diálogo fica com 0 de altura e o formulário some para fora da tela — só o
   fundo escuro aparece. Por isso aqui é altura cheia + flex. */
.sheet {
  border: 0; padding: 0; margin: 0;
  width: 100%; height: 100%;
  max-width: 100%; max-height: 100%;
  position: fixed; inset: 0;
  background: transparent; color: var(--ink);
  overflow: hidden; z-index: var(--z-sheet);
}
.sheet[open] { display: flex; align-items: flex-end; justify-content: center; }
.sheet::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
/* plano B para navegador sem <dialog> nativo: fundo desenhado à mão */
.sheet--simples { background: var(--overlay); }
.sheet--simples.is-closing { background: transparent; transition: background var(--d2); }

.sheet__panel {
  position: relative; width: 100%;
  max-height: 92vh; max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  border-top: 1px solid var(--line-soft);
  animation: sheetUp var(--d3) var(--ease);
}
.sheet.is-closing .sheet__panel { animation: sheetDown var(--d2) var(--ease-in) forwards; }
.sheet.is-closing::backdrop { opacity: 0; transition: opacity var(--d2); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
.sheet__grip { width: 38px; height: 4px; border-radius: var(--r-full); background: var(--surface-3); margin: var(--s2) auto 0; flex: none; }
.sheet__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) max(var(--s5), var(--safe-r)) var(--s3) max(var(--s5), var(--safe-l));
  flex: none;
}
.sheet__title { font-size: 17px; font-weight: 620; letter-spacing: -.018em; flex: 1; }
.sheet__body {
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: var(--s2) max(var(--s5), var(--safe-r)) var(--s5) max(var(--s5), var(--safe-l));
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4);
  -webkit-overflow-scrolling: touch;
}
/* campos que só aparecem em certos casos (cartão, parcelas) deixam um div
   vazio ocupando uma linha da grade — some com ele em vez de abrir um vão */
.sheet__body > div:empty { display: none; }
.sheet__foot {
  padding: var(--s4) max(var(--s5), var(--safe-r)) calc(var(--s5) + var(--safe-b)) max(var(--s5), var(--safe-l));
  display: grid; gap: var(--s2); flex: none;
  background: var(--bg); box-shadow: 0 -1px 0 var(--line-soft);
}
.sheet__foot--2 { grid-template-columns: auto 1fr; }

/* =========================================================================
   TOAST
   ========================================================================= */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: var(--z-toast);
  /* acima do botão +, senão o aviso fica atrás dele */
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 82px);
  display: grid; gap: var(--s2); width: max-content; max-width: calc(100vw - var(--s8)); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); border-radius: var(--r-full);
  background: var(--ink); color: var(--bg);
  font-size: 13.5px; font-weight: 520; box-shadow: var(--shadow-3);
  animation: toastIn var(--d2) var(--ease);
  pointer-events: auto;
}
.toast.out { animation: toastOut var(--d2) var(--ease-in) forwards; }
.toast--err { background: var(--neg); color: oklch(0.99 0 0); }
.toast__act { font-weight: 620; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px) scale(.97); } }

/* =========================================================================
   GRÁFICOS
   ========================================================================= */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); font-variant-numeric: proportional-nums; }
.chart .lbl { font-size: 10.5px; fill: var(--faint); font-weight: 500; }
.chart .lbl--on { fill: var(--ink-2); font-weight: 600; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar { transition: opacity var(--d1) var(--ease); }
.chart .bar-in { fill: var(--pos); }
.chart .bar-out { fill: var(--neg); }
.chart .bar-brand { fill: var(--brand-solid); }
.chart .bar-track { fill: var(--track); }
.chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: var(--brand); opacity: .12; }
.chart .dot { fill: var(--brand); }
.chart .zero { stroke: var(--line); stroke-width: 1; }

.donut { display: flex; align-items: center; gap: var(--s5); }
.donut__svg { width: 118px; height: 118px; flex: none; }
.donut__legend { flex: 1; min-width: 0; display: grid; gap: 9px; }
.dleg { display: flex; align-items: center; gap: var(--s2); font-size: 13px; }
.dleg i { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.dleg b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.dleg span { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* =========================================================================
   ESTADOS
   ========================================================================= */
.empty { text-align: center; padding: var(--s10) var(--s5); }
.empty__icon {
  width: 52px; height: 52px; margin: 0 auto var(--s4); border-radius: var(--r-lg);
  display: grid; place-items: center; background: var(--surface-2); color: var(--faint);
}
.empty__title { font-size: 16px; font-weight: 600; letter-spacing: -.014em; }
.empty__text { font-size: 13.5px; color: var(--muted); margin-top: var(--s2); line-height: 1.55; max-width: 34ch; margin-inline: auto; }
.empty__act { margin-top: var(--s5); }

.skel { background: var(--surface-2); border-radius: var(--r-sm); animation: skel 1.3s ease-in-out infinite; }
@keyframes skel { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

.syncdot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.syncdot.ok { background: var(--pos); }
.syncdot.off { background: var(--faint); }
.syncdot.err { background: var(--neg); }
.syncdot.busy { background: var(--accent); animation: pulse 1s var(--ease) infinite; }

/* =========================================================================
   ENTRADA (stagger discreto na troca de aba)
   Só com a classe is-entering, posta ao NAVEGAR. Sem isso a animação
   reexecutava a cada sincronização e a tela parecia recarregar sozinha.
   ========================================================================= */
.view.is-entering > * { animation: rise var(--d3) var(--ease) both; }
.view.is-entering > *:nth-child(2) { animation-delay: 24ms; }
.view.is-entering > *:nth-child(3) { animation-delay: 48ms; }
.view.is-entering > *:nth-child(4) { animation-delay: 68ms; }
.view.is-entering > *:nth-child(n+5) { animation-delay: 84ms; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } }

/* =========================================================================
   TELAS MAIORES
   ========================================================================= */
@media (min-width: 900px) {
  :root { --tabbar-h: 0px; }
  .tabbar, .monthbar__nav ~ .sr { display: none; }
  .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: var(--s2);
    width: 236px; flex: none; padding: var(--s6) var(--s4);
    border-right: 1px solid var(--line-soft); background: var(--surface);
    position: sticky; top: 0; height: 100dvh;
  }
  .rail__brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s6); }
  .rail__name { font-size: 14.5px; font-weight: 620; letter-spacing: -.018em; }
  .rail__nav { display: grid; gap: 2px; }
  .rail__foot { margin-top: auto; }
  .rail__item {
    display: flex; align-items: center; gap: var(--s3);
    padding: 10px var(--s3); border-radius: var(--r-sm);
    font-size: 14px; font-weight: 520; color: var(--muted); width: 100%;
    transition: background var(--d1) var(--ease), color var(--d1) var(--ease);
  }
  .rail__item:hover { background: var(--surface-2); color: var(--ink); }
  .rail__item.is-on { background: var(--brand-wash); color: var(--brand); font-weight: 560; }
  .view { padding: var(--s4) var(--s8) var(--s12); max-width: 900px; }
  .topbar__row { height: 62px; padding: 0 var(--s8); }
  .topbar__title { font-size: 24px; }
  .monthbar { padding: 0 var(--s8) var(--s4); max-width: 400px; }
  .fab { right: var(--s8); bottom: var(--s8); }
  .toasts { bottom: var(--s8); }
  .sheet[open] { align-items: center; }
  .sheet__panel {
    width: min(520px, 92vw);
    border-radius: var(--r-xl); border: 1px solid var(--line-soft);
    max-height: 86vh; max-height: 86dvh;
    animation: popIn var(--d2) var(--ease);
  }
  .sheet.is-closing .sheet__panel { animation: popOut var(--d1) var(--ease-in) forwards; }
  @keyframes popIn { from { opacity: 0; transform: scale(.97) translateY(10px); } }
  @keyframes popOut { to { opacity: 0; transform: scale(.98); } }
  .sheet__grip { display: none; }
  .sheet__foot { padding-bottom: var(--s5); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .chips { padding-inline: var(--s8); margin-inline: calc(var(--s8) * -1); }
}

@media (min-width: 620px) and (max-width: 899px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}

/* =========================================================================
   MOVIMENTO REDUZIDO
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  /* zera tudo de uma vez; não precisa de regra por elemento */
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .tabbar, .fab, .rail, .topbar__actions { display: none !important; }
}
