/* Paleta OFI: grafite, off-white, preto e um terroso discreto */
:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #efece6;
  --border: #e3dfd7;
  --ink: #1c1c1e;
  --ink-2: #4a4744;
  --muted: #8b857d;
  --accent: #1c1c1e;          /* botões principais */
  --accent-ink: #f5f3ef;
  --accent-soft: #efece6;
  --earth: #8a6f52;           /* destaque terroso */
  --earth-soft: #f1ebe3;
  --good: #3f6b4f;
  --good-soft: #e9efe9;
  --warn: #9a6b2f;
  --warn-soft: #f5ede0;
  --bad: #a3442f;
  --bad-soft: #f6e6e1;
  --track: #e8e4dd;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 28, 30, .04);
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1b1b1c;
    --surface-2: #242425;
    --border: #2f2e2c;
    --ink: #eeebe5;
    --ink-2: #bdb8b0;
    --muted: #8b857d;
    --accent: #eeebe5;
    --accent-ink: #151515;
    --accent-soft: #262523;
    --earth: #c4a582;
    --earth-soft: #2a241e;
    --good: #8fb79a;
    --good-soft: #1c2620;
    --warn: #d6a86a;
    --warn-soft: #2b2419;
    --bad: #e08a72;
    --bad-soft: #2f1f1b;
    --track: #2c2b29;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 15.5px/1.45 -apple-system, "SF Pro Text", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; letter-spacing: -.005em;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(var(--nav-h) + 90px + env(safe-area-inset-bottom));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
[hidden] { display: none !important; }

.shell { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 6px; padding-top: calc(14px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; letter-spacing: .14em; }
.sync {
  border: 0; background: transparent; padding: 6px; border-radius: 999px; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.sync::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.sync.ok::before { background: var(--good); }
.sync.saving::before { background: var(--warn); }
.sync.error::before { background: var(--bad); }

main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 8px 0 16px; }

/* cartões */
.card {
  background: var(--surface); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card.tap { cursor: pointer; transition: transform .08s; }
.card.tap:active { transform: scale(.985); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* herói */
.hero { text-align: center; padding: 26px 18px 20px; }
.hero .label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.hero .big { font-size: clamp(2.6rem, 13vw, 3.3rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.05; margin: 6px 0 4px; }
.hero .mood { display: inline-flex; gap: 6px; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; margin-top: 8px; }
.mood.good { background: var(--good-soft); color: var(--good); }
.mood.warn { background: var(--warn-soft); color: var(--warn); }
.mood.bad { background: var(--bad-soft); color: var(--bad); }
.meter { height: 6px; background: var(--track); border-radius: 6px; overflow: hidden; margin: 16px 0 6px; }
.meter > div { height: 100%; border-radius: 0 6px 6px 0; background: var(--earth); transition: width .3s; }
.meter.warn > div { background: var(--warn); }
.meter.bad > div { background: var(--bad); }

.line-card { display: flex; align-items: center; gap: 12px; }
.emoji-badge {
  width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
}
.ic { display: block; flex: none; }
.ic-letter { font-weight: 700; color: var(--ink-2); line-height: 1; }
.line-card .t { font-weight: 650; }
.line-card .s { font-size: 13.5px; color: var(--muted); }
.chev { color: var(--muted); font-size: 20px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 8px 12px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
.chip.over { border-color: var(--bad); color: var(--bad); }

.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.cat-tile {
  border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 12px;
  display: grid; gap: 6px; text-align: left;
}
.cat-tile .top-line { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.cat-tile .name { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tile .val { font-weight: 700; }
.mini-meter { height: 6px; background: var(--track); border-radius: 4px; overflow: hidden; }
.mini-meter > div { height: 100%; background: var(--earth); border-radius: 0 4px 4px 0; }
.mini-meter.bad > div { background: var(--bad); }

/* listas */
.day-label { font-size: 13px; font-weight: 650; color: var(--muted); margin: 6px 4px 2px; text-transform: uppercase; letter-spacing: .04em; }
.tx {
  display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 12px; width: 100%;
  border: 0; background: transparent; text-align: left;
}
.tx:active, .tx:hover { background: var(--surface-2); }
.tx .d { flex: 1; min-width: 0; }
.tx .d b { display: block; font-weight: 580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .d small { color: var(--muted); font-size: 13px; }
.tx .v { font-weight: 650; }

.month-switch { display: flex; align-items: center; justify-content: space-between; }
.month-switch b { font-size: 1.05rem; }
.icon-btn {
  border: 0; background: var(--surface); width: 40px; height: 40px; border-radius: 12px; font-size: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}

/* botões */
.btn {
  border: 1px solid var(--border); background: var(--surface); padding: 12px 16px; border-radius: 14px;
  font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: default; }

/* FAB + nav */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0; z-index: 20; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}
.fab:active { transform: translateX(-50%) scale(.94); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 19;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; max-width: 140px; height: var(--nav-h); border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; align-content: center; gap: 2px; font-size: 12px; font-weight: 600;
}
.nav button.active { color: var(--ink); }

/* sheet (painel de baixo) */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); animation: fade .15s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; animation: up .2s ease-out; display: grid; gap: 14px;
}
.sheet::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--border); justify-self: center; }
.sheet h3 { font-size: 1.15rem; text-align: center; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 11px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg button.on.out { color: var(--bad); }
.seg button.on.in { color: var(--good); }

.amount {
  text-align: center; font-size: 2.8rem; font-weight: 800; letter-spacing: -.03em; padding: 4px 0;
}
.amount.zero { color: var(--muted); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button {
  border: 0; background: var(--surface-2); border-radius: 14px; height: 54px; font-size: 22px; font-weight: 600;
}
.keypad button:active { background: var(--border); }

.picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pick {
  border: 2px solid transparent; background: var(--surface-2); border-radius: 14px; padding: 8px 4px;
  display: grid; justify-items: center; gap: 2px; font-size: 11.5px; color: var(--ink-2);
}
.pick .e { color: var(--ink-2); display: grid; place-items: center; height: 26px; }
.pick span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick.on { border-color: var(--ink); background: var(--surface); color: var(--ink); font-weight: 600; }
.pick.on .e { color: var(--ink); }

.field { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); font-weight: 550; }
.input {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; min-width: 0;
}
.input.big { font-size: 1.6rem; font-weight: 700; text-align: center; padding: 14px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--earth); outline-offset: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }

/* dívidas */
.ring-wrap { display: grid; place-items: center; position: relative; }
.ring-wrap .center { position: absolute; text-align: center; }
.ring-wrap .center b { font-size: 2rem; font-weight: 800; display: block; letter-spacing: -.02em; }
.slider { width: 100%; accent-color: var(--earth); height: 32px; }
.live { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat small { color: var(--muted); font-size: 12.5px; display: block; }
.stat b { font-size: 1.15rem; }
.gain { text-align: center; font-weight: 600; padding: 10px; border-radius: 12px; background: var(--good-soft); color: var(--good); }
.gain.bad { background: var(--bad-soft); color: var(--bad); }
.bar { height: 8px; background: var(--track); border-radius: 5px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; background: var(--good); border-radius: 0 5px 5px 0; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--earth-soft); color: var(--earth); text-transform: uppercase; letter-spacing: .06em; }
.chart svg { width: 100%; height: auto; display: block; }
.chart-tip {
  position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--bg);
  padding: 6px 9px; border-radius: 8px; font-size: 13px; white-space: nowrap;
}

/* mais */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 18px 14px;
  display: grid; gap: 8px; text-align: left; box-shadow: var(--shadow);
}
.tile .e { color: var(--ink-2); }
.tile b { font-size: 15px; }
.tile small { color: var(--muted); font-size: 12.5px; }
.back { border: 0; background: transparent; font-weight: 600; color: var(--ink-2); padding: 4px 0; justify-self: start; }

.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; font-size: 15px; }
.drop {
  display: block; border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px 16px; text-align: center;
  background: var(--surface); cursor: pointer;
}
.drop.over { border-color: var(--earth); background: var(--earth-soft); }
.imp-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.imp-row:last-child { border-bottom: 0; }
.imp-row.dup { opacity: .5; }
.imp-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ink); }
.imp-row .grow { overflow: hidden; }
.imp-row select { margin-top: 4px; width: 100%; max-width: 220px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 6px; font-size: 13px; }

/* onboarding */
.onb { min-height: 70vh; display: grid; align-content: center; gap: 18px; text-align: center; }
.onb .e { font-size: 56px; }
.onb h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.dots i.on { background: var(--ink); width: 22px; border-radius: 4px; }
.quick-list { display: grid; gap: 8px; text-align: left; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 92px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px); opacity: 0; transition: .2s; z-index: 70;
  background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 14px;
  display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); font-size: 15px; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast button { border: 0; background: transparent; color: var(--accent); font-weight: 700; padding: 6px 8px; }
#toast:not(:has(button)) { padding-right: 16px; }

/* confete */
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 80; pointer-events: none; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .8; } }
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .sheet, .sheet-backdrop { animation: none; }
}

/* Capi, o mascote 3D */
.mascote { display: block; flex: none; object-fit: contain; user-select: none; }
.m-feliz, .m-calmo { animation: bob 3.2s ease-in-out infinite; }
.m-festa { animation: hop .9s ease-in-out infinite; }
.m-preocupado { animation: wobble 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
@keyframes hop { 0%, 100% { transform: translateY(0) rotate(0); } 30% { transform: translateY(-10px) rotate(-4deg); } 60% { transform: translateY(0) rotate(3deg); } }
@keyframes wobble { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .mascote { animation: none !important; } }
.float { display: grid; place-items: center; }

.say { display: flex; align-items: flex-end; gap: 10px; text-align: left; }
.bubble {
  position: relative; background: var(--surface-2); color: var(--ink); border-radius: 18px 18px 18px 6px;
  padding: 12px 14px; font-size: 15px; line-height: 1.4; flex: 1; min-width: 0;
}
.bubble::before {
  content: ""; position: absolute; left: -7px; bottom: 10px; width: 14px; height: 14px;
  background: inherit; transform: rotate(45deg); border-radius: 3px;
}
.hero-mascot { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 6px; }
.hero-mascot .mood { margin-top: 0; }

/* tour guiado */
#tour { position: fixed; inset: 0; z-index: 90; }
.tour-spot {
  position: fixed; border-radius: 20px; box-shadow: 0 0 0 9999px rgba(8, 12, 18, .66);
  outline: 2px solid var(--earth); outline-offset: 2px; transition: all .25s ease; pointer-events: none;
}
.tour-dim { position: fixed; inset: 0; background: rgba(8, 12, 18, .66); }
.tour-card {
  position: fixed; left: 50%; translate: -50% 0; width: min(420px, calc(100vw - 32px));
  background: var(--surface); border-radius: 20px; padding: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  animation: up .2s ease-out;
}

.chips.wrap { flex-wrap: wrap; justify-content: center; overflow: visible; }
.emoji-badge.sm { width: 40px; height: 40px; font-size: 20px; border-radius: 12px; }
.chip-input {
  flex: 1 0 140px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 8px 12px; font-size: 14px; min-width: 120px;
}
.chip { position: relative; }
.date-hidden { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.big[disabled] { background: var(--surface-2); color: var(--muted); border-color: var(--border); opacity: 1; }

#toast span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* acabamento corporativo */
.mood { font-weight: 600; font-size: 12.5px !important; letter-spacing: .02em; }
.card { box-shadow: none; }
.btn.primary { letter-spacing: .01em; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.gain { background: var(--good-soft); color: var(--good); font-weight: 500; }
.ring-wrap circle[stroke="var(--good)"] { stroke: var(--earth); }
.bar > div { background: var(--earth); }

/* ---- bloqueio ---- */
html[data-locked] .shell, html[data-locked] .fab, html[data-locked] .nav, html[data-locked] .sheet-wrap { visibility: hidden; }
.lock { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; padding: 24px; overflow: auto; }
.lock[hidden] { display: none; }
.lock-in { width: min(320px, 100%); display: grid; justify-items: center; gap: 12px; text-align: center; }
.lock-img { border-radius: 50%; }
.lock h1 { font-size: 1.25rem; margin: 0; }
.lock p { margin: 0; min-height: 1.4em; }
.pin-dots { display: flex; gap: 14px; margin: 6px 0 10px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink-2); transition: background .12s; }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.shake { animation: pinshake .35s; }
@keyframes pinshake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.lock-pad { width: 100%; }
.lock-pad button { display: grid; place-items: center; color: var(--ink); }
.lock.busy .lock-pad { opacity: .4; pointer-events: none; }
