/* Vertere Grana — iOS escuro, azul-marinho */
:root {
  --bg: #0A1428;
  --bg-deep: #050B18;
  --surface: #12203A;
  --surface-2: #1A2B4A;
  --line: #24365A;
  --text: #F2F5FB;
  --soft: #C9D3E6;
  --muted: #8E9BB5;
  --faint: #5B6B8C;
  --accent: #2F6BFF;
  --accent-deep: #1F4FD1;
  --link: #7FB0FF;
  --green: #34C77B;
  --green-text: #5EDB98;
  --red: #FF6B6B;
  --amber: #FFB547;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.35;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-decoration: none; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- estrutura ---------- */
#app { max-width: 520px; margin: 0 auto; min-height: 100%; }
.screen {
  display: flex; flex-direction: column; gap: 18px;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 110px) max(16px, env(safe-area-inset-left, 0px));
}
.title { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.4px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 700; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.section-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.section-head a, .link-btn { font-size: 15px; background: none; border: 0; color: var(--link); padding: 0; }
.caption { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; padding: 0 4px; }

.group { background: var(--surface); border-radius: var(--radius); }
.group > .item + .item { border-top: 0.5px solid var(--line); }
.pad { padding: 16px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px; width: 100%; background: none; border: 0; text-align: left; color: var(--text); }
button.item:active, a.item:active { background: var(--surface-2); }
.item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .grow > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.chev { color: var(--faint); flex: none; }
.avatar { width: 36px; height: 36px; border-radius: 18px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.avatar.sq { border-radius: 10px; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex: none; }

.icon-btn { width: 40px; height: 40px; border-radius: 20px; border: 0; background: var(--surface); color: var(--soft); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; }

.btn { height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; padding: 0 18px; width: 100%; }
.btn:disabled { opacity: 0.5; }
.btn.ghost { background: var(--surface-2); color: var(--link); }
.btn.danger { background: rgba(255, 107, 107, 0.14); color: var(--red); }
.pill-btn { height: 32px; padding: 0 12px; border-radius: 16px; border: 0; background: var(--surface-2); color: var(--link); font-size: 14px; font-weight: 600; flex: none; }

.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.aberta { color: var(--link); background: rgba(77, 141, 255, 0.14); }
.badge.fechada { color: var(--amber); background: rgba(255, 181, 71, 0.14); }
.badge.vencida { color: var(--red); background: rgba(255, 107, 107, 0.14); }
.badge.paga { color: var(--green-text); background: rgba(52, 199, 123, 0.14); }

.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 8px; }
.month-nav span { font-size: 16px; font-weight: 600; min-width: 150px; text-align: center; }
.month-nav button { width: 40px; height: 40px; border: 0; background: none; color: var(--link); display: inline-flex; align-items: center; justify-content: center; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border-radius: 10px; padding: 2px; }
.segmented button { height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--soft); font-size: 14px; }
.segmented button[aria-pressed="true"] { background: var(--line); color: var(--text); font-weight: 600; }
.segmented.kind button[aria-pressed="true"][data-v="despesa"] { color: #FF8A8A; }
.segmented.kind button[aria-pressed="true"][data-v="receita"] { color: var(--green-text); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { background: var(--surface); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 15px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- início ---------- */
.hero { background: var(--accent); border-radius: 24px; padding: 22px 20px; display: flex; flex-direction: column; gap: 18px; color: #fff; }
.hero .label { font-size: 13px; color: rgba(255, 255, 255, 0.85); font-weight: 500; }
.hero .big { font-size: 36px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; }
.hero .sub { font-size: 13px; color: rgba(255, 255, 255, 0.85); }
.hero .split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hero .split > div { background: rgba(255, 255, 255, 0.14); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hero .split b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hello { display: flex; align-items: center; justify-content: space-between; }
.donut-row { display: flex; align-items: center; gap: 18px; }
.donut-row svg { flex: none; }
.legend { flex: 1; display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.legend .row { gap: 8px; font-size: 14px; }
.legend .row span:nth-child(2) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- lista de lançamentos ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 12px; padding: 0 12px; height: 42px; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 16px; min-width: 0; }
.day-head { display: flex; justify-content: space-between; padding: 0 4px; font-size: 13px; color: var(--muted); }
.day-head b { font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.status { font-size: 11px; }
.status.pendente { color: var(--amber); }

/* ---------- cartão ---------- */
.plastic { border-radius: 18px; padding: 18px; min-height: 176px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; }
.plastic .big { font-size: 24px; font-weight: 800; }

/* ---------- gráficos ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid { stroke: var(--line); }
.legend-inline { display: flex; gap: 12px; font-size: 12px; color: var(--soft); }
.legend-inline span { display: inline-flex; align-items: center; gap: 5px; }
.legend-inline i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* ---------- barra de abas ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(10, 20, 40, 0.94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--line);
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 8px) max(8px, env(safe-area-inset-left, 0px));
}
.tabbar nav { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 500; padding-top: 2px; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabbar .fab { width: 54px; height: 54px; margin: -16px auto 0; border-radius: 27px; background: var(--accent); color: #fff; border: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(47, 107, 255, 0.35); }
.tabbar .fab svg { width: 26px; height: 26px; }

/* ---------- folha (modal) ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(2, 6, 14, 0.6); z-index: 40; animation: fade 0.18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 520px; margin: 0 auto;
  max-height: calc(100% - env(safe-area-inset-top, 0px) - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); border-radius: 14px 14px 0 0;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 16px; animation: up 0.24s cubic-bezier(.2, .8, .2, 1);
}
.grabber { width: 36px; height: 5px; border-radius: 3px; background: #3A4A6A; align-self: center; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; background: var(--bg); padding: 4px 0; z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-head button { background: none; border: 0; color: var(--link); font-size: 17px; min-width: 72px; padding: 8px 0; }
.sheet-head button:last-child { text-align: right; font-weight: 600; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .backdrop { animation: none; } }

/* ---------- formulários ---------- */
.amount { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.amount label { font-size: 13px; color: var(--muted); }
.amount .wrap { display: flex; align-items: baseline; gap: 6px; }
.amount .cur { font-size: 26px; font-weight: 700; color: var(--muted); }
.amount input { width: 9ch; max-width: 70vw; background: none; border: 0; outline: none; text-align: left; font-size: 44px; font-weight: 800; letter-spacing: -1px; }
.amount input.despesa { color: var(--red); }
.amount input.receita { color: var(--green); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 36px; padding: 0 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); color: var(--soft); display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.chip[aria-pressed="true"] { border-color: var(--chip, var(--accent)); color: var(--text); background: var(--surface-2); }
.field { display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 16px; }
.field + .field { border-top: 0.5px solid var(--line); }
.field label { flex: none; min-width: 96px; }
.field input, .field select, .field textarea { flex: 1; min-width: 0; background: none; border: 0; outline: none; text-align: right; color: var(--soft); font-size: 16px; padding: 12px 0; }
.field select {
  appearance: none; -webkit-appearance: none; text-align-last: right; padding-right: 20px; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6B8C' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right center;
}
.field select:disabled { opacity: 0.6; cursor: default; }
.field select option { background: var(--surface); color: var(--text); }
.field textarea { text-align: left; resize: none; min-height: 60px; }
.field.col { flex-direction: column; align-items: stretch; gap: 0; padding-top: 12px; }
.field.col textarea { padding-top: 6px; }
.field input[type="date"] { color-scheme: dark; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 14px; background: #fff; transition: transform 0.2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: 8px; height: 34px; }
.stepper button { width: 36px; height: 34px; border: 0; background: none; font-size: 20px; }
.stepper output { min-width: 34px; text-align: center; font-weight: 600; }
.hint { padding: 10px 16px; font-size: 13px; color: var(--muted); border-top: 0.5px solid var(--line); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
.swatches button { width: 32px; height: 32px; border-radius: 16px; border: 2px solid transparent; }
.swatches button[aria-pressed="true"] { border-color: var(--text); }
.error { color: var(--red); font-size: 14px; text-align: center; }
.confirm { display: flex; flex-direction: column; gap: 8px; }

/* ---------- entrada ---------- */
.auth { min-height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: calc(env(safe-area-inset-top, 0px) + 32px) max(20px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 32px) max(20px, env(safe-area-inset-left, 0px)); max-width: 440px; margin: 0 auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.brand img { width: 72px; height: 72px; border-radius: 18px; }
.brand h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.4px; }
.brand p { margin: 0; color: var(--muted); font-size: 15px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth .field input { text-align: left; }
.auth .foot { text-align: center; font-size: 13px; color: var(--faint); }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); transform: translateX(-50%); background: var(--surface-2); color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); max-width: calc(100% - 32px); animation: fade 0.2s ease; }
.loading { padding: 80px 16px; text-align: center; color: var(--muted); }
.blur-values .money { filter: blur(7px); }
