:root {
  --bg: #0B0D10;
  --surface: #14171C;
  --surface-2: #1C2027;
  --line: #262B33;
  --text: #F3F5F8;
  --muted: #8B94A3;
  --faint: #5E6776;
  --accent: #9BE15D;
  --accent-ink: #0B0D10;
  --danger: #FF6B6B;
  --r: 18px;
  --r-sm: 12px;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}
body.locked { overflow: hidden; }
input, select, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
strong, b, .val { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Cabeçalho */
.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(11, 13, 16, .86);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.top-inner { max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; font-weight: 750; }
.month { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.month button { width: 32px; height: 32px; border-radius: 50%; font-size: 22px; line-height: 1; color: var(--muted); }
.month button:active { background: var(--surface-2); }
.month span { min-width: 108px; text-align: center; font-weight: 650; font-size: 14px; }

main { padding: 4px 16px calc(var(--safe-bottom) + 100px); max-width: 560px; margin: 0 auto; }

/* Blocos */
.section { margin-top: 26px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 4px 10px; }
.section-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0; font-weight: 650; }
.link { color: var(--accent); font-weight: 650; font-size: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.pad { padding: 14px; }

.hero {
  padding: 20px;
  background: radial-gradient(120% 140% at 100% 0%, rgba(155, 225, 93, .16), transparent 55%), var(--surface);
}
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 550; }
.big { display: block; font-size: 40px; font-weight: 750; letter-spacing: -.035em; margin: 2px 0 16px; }
.split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.split > div { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px; min-width: 0; }
.split span { display: block; color: var(--muted); font-size: 12px; }
.split b { font-size: 14px; white-space: nowrap; }
.split.two { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
.split.two b { font-size: 16px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.tile { padding: 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c); }
.tile-name { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; font-weight: 600; }
.tile strong { display: block; font-size: 22px; margin: 6px 0 2px; letter-spacing: -.02em; }
.tile small { color: var(--faint); font-size: 12px; line-height: 1.35; display: block; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
.stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; gap: 2px; margin: 2px 0 4px; background: var(--surface-2); }
.stack i { background: var(--c); display: block; min-width: 3px; }

/* Linhas */
.rows { display: flex; flex-direction: column; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; width: 100%; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
button.row:active { background: var(--surface-2); }
.ic {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-weight: 750; font-size: 15px;
  color: var(--c); background: rgba(255, 255, 255, .06);
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small { color: var(--muted); font-size: 13px; }
.row-val { font-weight: 650; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-val small { display: block; color: var(--muted); font-weight: 450; font-size: 12px; }
.row .chev { color: var(--faint); font-size: 18px; }
.file-row { position: relative; cursor: pointer; }
.file-row:active { background: var(--surface-2); }
/* Invisível mas presente: display:none impede o iOS de abrir o seletor. */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

.badge { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 650; white-space: nowrap; }
.badge.open { background: rgba(155, 225, 93, .15); color: var(--accent); }
.pos { color: var(--accent); }
.neg { color: var(--danger); }
.muted { color: var(--muted); }

/* Chips */
.chips { display: flex; gap: 8px; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; font-size: 14px; color: var(--muted);
}
.chip.on, .chip:has(input:checked) {
  border-color: var(--c, var(--accent)); color: var(--text);
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--surface));
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip.swatch { width: 34px; height: 34px; padding: 0; background: var(--c); border: 2px solid transparent; }
.chip.swatch:has(input:checked) { border-color: var(--text); box-shadow: inset 0 0 0 3px var(--surface); }

/* Fatura */
.invoice { padding: 18px; margin-top: 12px; border-top: 3px solid var(--c); }
.invoice-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.invoice .big { margin: 4px 0 6px; }
.invoice-dates { color: var(--muted); font-size: 13px; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--c, var(--accent)); }
.row-main .meter { display: block; margin: 6px 0 4px; }
.meter.warn i { background: #F7B32B; }
.meter.over i { background: var(--danger); }
.meter.goal i { background: #4EA8FF; }
.goal-line { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 2px; }
.goal-line strong { font-size: 26px; letter-spacing: -.02em; }
.goal-status { display: block; margin-top: 8px; font-size: 13px; }
.plan { display: block; width: 100%; text-align: left; padding: 14px 14px 12px; }
.plan-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.plan .bars { height: 90px; padding: 12px 0 8px; }
.plan-text { display: block; font-size: 13px; color: var(--muted); line-height: 1.45; }
.plan-text b { color: var(--text); }
.bars.tall { height: 160px; gap: 6px; }
.bars em { font-style: normal; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.legend b { color: var(--text); font-weight: 600; }

/* Barra inferior */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  padding: 8px 8px calc(var(--safe-bottom) + 8px);
  background: rgba(15, 17, 21, .9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--faint); font-weight: 600; padding: 4px 0; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--text); }
.tab.active svg { color: var(--accent); }
.fab {
  justify-self: center; width: 54px; height: 54px; border-radius: 18px; margin-top: -20px;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(155, 225, 93, .28);
}
.fab:active { transform: scale(.96); }
.fab svg { width: 26px; height: 26px; }

/* Folha (modal) */
#sheet-root { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .58); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: calc(100dvh - var(--safe-top) - 24px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line);
  padding: 0 16px calc(var(--safe-bottom) + 20px);
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet-head { position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 18px 0 12px; }
.sheet-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 14px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Formulários */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; color: var(--muted); font-weight: 600; padding: 0; }
.field > legend { margin-bottom: 8px; }
input, select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; width: 100%; min-height: 48px;
  appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type="date"] { display: block; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { appearance: auto; -webkit-appearance: auto; width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); }
.amount { display: flex; flex-direction: column; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.amount span { font-size: 13px; color: var(--muted); font-weight: 600; }
.amount input { font-size: 36px; font-weight: 750; letter-spacing: -.03em; background: none; border: 0; padding: 2px 0; border-radius: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 13px; }
.seg label { position: relative; text-align: center; padding: 9px; border-radius: 10px; font-weight: 650; color: var(--muted); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .45); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.hint { margin: 0; color: var(--muted); font-size: 13px; background: var(--surface-2); padding: 10px 12px; border-radius: var(--r-sm); }
.hint:empty { display: none; }
.hint b { color: var(--text); }
.actions { display: flex; gap: 10px; margin-top: 4px; }
.btn { flex: 1; min-height: 50px; border-radius: 14px; font-weight: 700; font-size: 16px; padding: 0 14px; }
.btn:active { opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; margin-top: 10px; }

/* Vazios e avisos */
.empty { text-align: center; padding: 36px 20px; }
.empty h3 { margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 0 18px; color: var(--muted); }
.steps { text-align: left; margin: 18px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.steps button { width: 100%; display: flex; gap: 12px; align-items: center; padding: 14px; text-align: left; }
.steps .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 750; flex: none; }
.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; margin-top: 12px;
  border-radius: var(--r); background: rgba(247, 179, 43, .1); border: 1px solid rgba(247, 179, 43, .3); font-size: 14px;
}
.banner button { color: #F7B32B; font-weight: 700; white-space: nowrap; }
.note { color: var(--faint); font-size: 13px; text-align: center; margin: 18px 8px 0; }

/* Gráfico de aportes */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding: 16px 14px 12px; }
.bars > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bars i { width: 100%; max-width: 36px; background: var(--accent); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.bars i.zero { background: var(--surface-2); }
.bars span { font-size: 11px; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 92px); z-index: 30;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 650; font-size: 14px;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
