:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #151826;
  --muted: #6b7185;
  --line: #e5e7ef;
  --primary: #4f46e5;
  --primary-soft: #eceafd;
  --in: #12a150;
  --in-soft: #e3f6ea;
  --out: #e5484d;
  --out-soft: #fdeaea;
  --goal: #d97706;
  --shadow: 0 1px 2px rgba(20, 24, 50, .05), 0 6px 24px rgba(20, 24, 50, .06);
  --radius: 18px;
  --nav-w: 232px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1019;
    --surface: #171a27;
    --surface-2: #1f2333;
    --text: #eceef7;
    --muted: #8b91a8;
    --line: #272b3d;
    --primary: #8b85ff;
    --primary-soft: #25254a;
    --in: #3ddc84;
    --in-soft: #12301f;
    --out: #ff6b70;
    --out-soft: #3a1a1d;
    --goal: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { color-scheme: light dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.in-c { color: var(--in); }
.out-c { color: var(--out); }
svg { display: block; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; }
.nav {
  position: fixed; z-index: 20; display: flex; gap: 4px;
  background: var(--surface); border: 0 solid var(--line);
}
.nav .brand { display: none; }
.nav button {
  background: none; border: 0; color: var(--muted);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; font-weight: 600;
}
.nav button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav button.active { color: var(--primary); background: var(--primary-soft); }
.nav button:hover:not(.active) { background: var(--surface-2); }

.view { max-width: 980px; margin: 0 auto; padding: 18px 16px 120px; }

/* mobile: barra inferior */
@media (max-width: 859px) {
  .nav {
    left: 0; right: 0; bottom: 0; justify-content: space-around;
    border-top-width: 1px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .nav button { flex-direction: column; gap: 2px; padding: 6px 10px; font-size: 11.5px; flex: 1; }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 16px; }
}
/* desktop: barra lateral */
@media (min-width: 860px) {
  .nav { top: 0; bottom: 0; left: 0; width: var(--nav-w); flex-direction: column; border-right-width: 1px; padding: 20px 14px; }
  .nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--primary); padding: 4px 10px 18px; }
  .nav .brand span { color: var(--text); }
  .view { margin-left: var(--nav-w); max-width: none; padding: 28px 36px 120px; }
  .view > * { max-width: 940px; margin-left: auto; margin-right: auto; }
  .fab { bottom: 28px; right: 32px; }
}

.fab {
  position: fixed; z-index: 25; display: flex; align-items: center; gap: 8px;
  background: var(--primary); color: #fff; border: 0; border-radius: 999px;
  padding: 14px 22px 14px 18px; font-weight: 700; box-shadow: 0 8px 24px rgba(79, 70, 229, .4);
  transition: transform .12s;
}
.fab:active { transform: scale(.96); }
.fab svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }

/* ---------- componentes ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 859px) { .grid.cols-2.stack { grid-template-columns: 1fr; } }
.stack-gap > * + * { margin-top: 14px; }
.card h3 { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 12px; text-transform: none; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 10px 16px; font-weight: 600; transition: background .12s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn.in { background: var(--in-soft); color: var(--in); border-color: transparent; }
.btn.out { background: var(--out-soft); color: var(--out); border-color: transparent; }
.btn.danger { background: var(--out-soft); color: var(--out); border-color: transparent; }
.btn.block { width: 100%; padding: 13px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.datenav { display: flex; align-items: center; gap: 8px; }
.datenav .label { position: relative; font-weight: 700; font-size: 17px; padding: 6px 12px; border-radius: 10px; min-width: 150px; text-align: center; }
.datenav .label:hover { background: var(--surface-2); }
.datenav .label input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.datenav .label input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.pill { 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(--muted); }
.pill.in { background: var(--in-soft); color: var(--in); }
.pill.out { background: var(--out-soft); color: var(--out); }
.pill.goal { background: color-mix(in srgb, var(--goal) 16%, transparent); color: var(--goal); }

/* hero da meta diária */
.hero { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
@media (max-width: 520px) { .hero { grid-template-columns: 1fr; justify-items: center; text-align: center; } .hero .actions { justify-content: center; } }
.ring { position: relative; width: 168px; height: 168px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--primary); transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1), stroke .3s; }
.ring.done .fg { stroke: var(--in); }
.ring .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .pct { font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.ring .sub { font-size: 12px; color: var(--muted); margin-top: -2px; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.hero .of { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.hero .remain { font-size: 15px; margin-bottom: 14px; }
.hero .remain b { font-size: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.love { margin: 0; padding: 12px 16px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 14px; text-align: center; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin-top: 2px; }
.stat .v.sm { font-size: 18px; }
.stat { padding: 16px; }

.bar { height: 10px; background: var(--surface-2); border-radius: 99px; position: relative; overflow: visible; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar > i.done { background: var(--in); }
.bar > u { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--goal); border-radius: 2px; }

/* lista de lançamentos */
.list { display: flex; flex-direction: column; }
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-radius: 12px; cursor: pointer; border: 0; background: none; text-align: left; width: 100%; }
.tx:hover { background: var(--surface-2); }
.tx + .tx { border-top: 1px solid var(--line); }
.tx:hover + .tx, .tx:hover { border-color: transparent; }
.tx .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.tx .ico svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tx .ico.in { background: var(--in-soft); color: var(--in); }
.tx .ico.out { background: var(--out-soft); color: var(--out); }
.tx .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .t2 { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .amt { font-weight: 700; white-space: nowrap; }
.daygroup { margin-top: 18px; }
.daygroup:first-child { margin-top: 0; }
.dayhead { display: flex; justify-content: space-between; padding: 0 6px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* controles */
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.seg.type button.on[data-t="in"] { color: var(--in); }
.seg.type button.on[data-t="out"] { color: var(--out); }
input[type=text], input[type=password], input[type=date], input[type=search], textarea, select {
  width: 100%; background: var(--surface-2); border: 1.5px solid transparent; border-radius: 12px;
  padding: 12px 14px; outline: none; transition: border-color .12s, background .12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: var(--surface); }
label.f { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--line); background: none; border-radius: 99px; padding: 5px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* modal (bottom sheet no mobile) */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 24, .5); display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(2px); animation: fade .15s; }
.modal[hidden] { display: none; }
.sheet { background: var(--surface); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0; padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 94vh; overflow: auto; animation: up .2s cubic-bezier(.2, .8, .2, 1); }
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 24px; } }
.sheet .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet .head h2 { font-size: 18px; }
.amount-in { font-size: 34px !important; font-weight: 800; letter-spacing: -.02em; text-align: center; padding: 14px !important; font-variant-numeric: tabular-nums; }
.amount-wrap { position: relative; }
.amount-wrap .cur { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .foot { display: flex; gap: 10px; margin-top: 20px; }
.sheet .foot .btn { flex: 1; }
.err { color: var(--out); font-size: 13.5px; margin: 8px 0 0; font-weight: 600; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

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

/* gráficos */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: color-mix(in srgb, var(--primary) 7%, transparent); }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--text); color: var(--bg); border-radius: 10px; padding: 8px 11px; font-size: 12.5px; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -100%); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.dash { height: 0; width: 14px; border-top: 2px dashed var(--goal); border-radius: 0; vertical-align: 3px; }

.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-wrap .dl { width: 100%; } }
.dl .it { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; }
.dl .it i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dl .it .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl .it .pc { color: var(--muted); font-size: 12.5px; width: 38px; text-align: right; }
.hbar { display: flex; flex-direction: column; gap: 12px; }
.hbar .top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; gap: 10px; }
.hbar .top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .tr { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hbar .tr i { display: block; height: 100%; border-radius: 99px; background: var(--in); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; text-align: center; padding: 32px 26px; }
.login-card .logo { color: var(--primary); display: inline-block; margin-bottom: 10px; }
.login-card h1 { font-size: 26px; }
.login-card p.muted { margin: 4px 0 20px; }
.login-card input { margin-bottom: 12px; text-align: center; }
.login-card .err { margin: -2px 0 12px; }

.skeleton { height: 140px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
