:root {
  --bg: #f4f3ee;
  --card: #ffffff;
  --ink: #16201d;
  --muted: #6b7570;
  --line: #e6e4dc;
  --brand: #0f3d35;
  --brand-2: #1b6b5a;
  --accent: #f2b33d;
  --out: #d9483b;
  --in: #1f9d61;
  --chip: #eeece4;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 8px 24px rgba(16, 24, 20, .06);
  --r: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1412; --card: #16201d; --ink: #edf1ee; --muted: #94a39c; --line: #25312d;
    --brand: #13574b; --brand-2: #2a8f78; --chip: #1f2a27; --out: #f06b5f; --in: #3ccf86;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif; min-height: 100dvh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }

/* ---------- botões ---------- */
.btn { border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 700; background: var(--chip); transition: transform .08s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.danger { background: transparent; color: var(--out); border: 1.5px solid currentColor; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 11px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { border: 0; background: var(--chip); width: 38px; height: 38px; border-radius: 12px; font-size: 18px; display: grid; place-items: center; }

/* ---------- login ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, #1b6b5a 0%, #0f3d35 60%, #0a2924 100%); }
.auth-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 26px; padding: 32px 24px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 28px; margin-top: 12px; }
.auth-card form { display: grid; gap: 10px; margin-top: 18px; }
.brand-mark { width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; background: var(--brand); color: var(--accent); font-weight: 800; font-size: 34px; display: grid; place-items: center; }
.field, .auth input { width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg); outline: none; }
.field:focus, .auth input:focus { border-color: var(--brand-2); }

/* ---------- layout ---------- */
#view { padding: 0 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 2px 12px; }
.topbar h2 { font-size: 22px; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 20px 2px 8px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 6px calc(6px + var(--safe-b)); z-index: 20; }
.tabbar button { border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--muted); border-radius: 12px; }
.tabbar .ti { font-size: 20px; line-height: 1; }
.tabbar button.active { color: var(--brand-2); background: var(--chip); }

/* ---------- início ---------- */
.hero { background: linear-gradient(150deg, #1b6b5a 0%, #0f3d35 70%); color: #fff; border-radius: 24px; padding: 20px; margin-top: 4px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(242, 179, 61, .16); }
.hero .label { opacity: .8; font-size: 13px; font-weight: 600; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 2px 0 14px; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: relative; z-index: 1; }
.hero-grid div { background: rgba(255,255,255,.1); border-radius: 14px; padding: 9px 10px; }
.hero-grid small { display: block; opacity: .75; font-size: 11px; font-weight: 600; }
.hero-grid b { font-size: 15px; }
.hero .saldo { position: relative; z-index: 1; display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; opacity: .9; }

.capture { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 22px 0 6px; }
.mic { width: 96px; height: 96px; border-radius: 50%; border: 0; background: radial-gradient(circle at 35% 30%, #ffd27a, var(--accent) 55%, #d9901c); color: #3b2a05; font-size: 38px; box-shadow: 0 10px 26px rgba(217, 144, 28, .45), inset 0 -4px 0 rgba(0,0,0,.08); justify-self: center; transition: transform .1s; }
.mic:active { transform: scale(.94); }
.side-btn { border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 18px; padding: 12px 8px; display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 700; }
.side-btn span { font-size: 22px; }
.capture-hint { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.textbar { display: flex; gap: 8px; margin: 12px 0 0; }
.textbar input { flex: 1; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); outline: none; }
.textbar input:focus { border-color: var(--brand-2); }
.textbar button { border: 0; border-radius: 14px; background: var(--brand); color: #fff; width: 50px; font-size: 18px; }

/* ---------- listas ---------- */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.item { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.item:last-child { border-bottom: 0; }
.item .ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; }
.item .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .v { font-weight: 800; white-space: nowrap; }
.v.out { color: var(--out); } .v.in { color: var(--in); }
.day-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 4px 6px; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .e { font-size: 38px; }

/* ---------- filtros ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 6px; margin-bottom: 12px; }
.month-nav b { text-transform: capitalize; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.search { width: 100%; margin: 10px 0 4px; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); outline: none; }
.sum-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.sum-row div { background: var(--card); border-radius: 14px; padding: 10px; box-shadow: var(--shadow); }
.sum-row small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.sum-row b { font-size: 15px; }

/* ---------- gráficos ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: 16px; padding: 13px; box-shadow: var(--shadow); }
.kpi small { color: var(--muted); font-weight: 600; font-size: 12px; }
.kpi b { display: block; font-size: 20px; letter-spacing: -.02em; }
.kpi .d { font-size: 12px; font-weight: 700; }
.d.up { color: var(--out); } .d.down { color: var(--in); }
.chart-box { position: relative; height: 230px; }
.chart-box.tall { height: 260px; }
.bars { display: grid; gap: 10px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.bar-row .track { grid-column: 1 / -1; height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 12px; padding: 4px; margin-bottom: 10px; }
.seg button { border: 0; background: none; padding: 8px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- ajustes ---------- */
.set-row { display: flex; gap: 8px; margin-top: 8px; }
.set-row .field { flex: 1; }
.cat-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-child { border-bottom: 0; }
.cat-dot { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; }
.help { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.help a { color: var(--brand-2); font-weight: 700; }
.status-pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--chip); }
.status-pill.ok { background: color-mix(in srgb, var(--in) 18%, transparent); color: var(--in); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 18, 15, .72); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 50; padding: 24px; }
.rec-box, .busy-box { background: var(--card); border-radius: 26px; padding: 28px 22px; width: 100%; max-width: 340px; text-align: center; }
.rec-pulse { width: 110px; height: 110px; margin: 0 auto; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 44px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(242,179,61,.6); } 70% { box-shadow: 0 0 0 28px rgba(242,179,61,0); } 100% { box-shadow: 0 0 0 0 rgba(242,179,61,0); } }
.rec-time { font-size: 30px; font-weight: 800; margin: 16px 0 4px; font-variant-numeric: tabular-nums; }
.rec-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.spinner { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%; border: 5px solid var(--chip); border-top-color: var(--brand-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-box p { margin: 0; font-weight: 700; }

/* ---------- folha ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(8, 18, 15, .5); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; z-index: 41; padding: 10px 16px calc(18px + var(--safe-b)); animation: up .22s ease-out; max-width: 640px; margin: 0 auto; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { font-size: 19px; }
.transcript { background: var(--card); border-radius: 14px; padding: 10px 12px; font-size: 13px; color: var(--muted); margin: 10px 0; font-style: italic; }
.entry-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; display: grid; gap: 10px; position: relative; }
.entry-card .remove { position: absolute; right: 10px; top: 10px; }
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 12px; padding: 4px; max-width: 240px; }
.type-toggle button { border: 0; background: none; border-radius: 9px; padding: 7px; font-weight: 700; font-size: 13px; color: var(--muted); }
.type-toggle button.on.out { background: var(--out); color: #fff; }
.type-toggle button.on.in { background: var(--in); color: #fff; }
.money { display: flex; align-items: center; gap: 6px; font-size: 30px; font-weight: 800; }
.money input { border: 0; background: none; font-size: 30px; font-weight: 800; width: 100%; outline: none; padding: 0; letter-spacing: -.02em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lbl { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; display: block; }
.badge-new { display: inline-block; background: var(--accent); color: #3b2a05; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: middle; }
.pay-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pay-chips .chip { padding: 6px 11px; font-size: 12px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; position: sticky; bottom: 0; padding-top: 8px; background: var(--bg); }

.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--out); color: #fff; }
.toast.ok { background: var(--in); color: #fff; }
