/* SF · estilos. Tokens da UX-ESPECIFICACAO-v0.1 §6. Mobile-first; ≥1024px = barra lateral. */
:root {
  --bg: #F6F7F9; --surface: #FFFFFF; --surface-2: #F0F2F5;
  --ink: #14171F; --ink-2: #5B6270; --line: #E4E7EC;
  --accent: #3B5BDB; --accent-ink: #FFFFFF; --accent-soft: #E7ECFF;
  --income: #0F7B53; --alert: #C92A2A; --warn: #B26A00;
  --sombra: 0 1px 2px rgba(20,23,31,.06), 0 4px 14px rgba(20,23,31,.06);
  --r-card: 12px; --r-campo: 10px;
  --nav-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #0E1116; --surface: #171B22; --surface-2: #1F242D;
    --ink: #E8EAF0; --ink-2: #9AA3B2; --line: #2A303B;
    --accent: #7C97FF; --accent-ink: #0E1116; --accent-soft: #232C4A;
    --income: #3DD6A0; --alert: #FF8A8A; --warn: #F2B24C;
    --sombra: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-tema="escuro"] {
  --bg: #0E1116; --surface: #171B22; --surface-2: #1F242D;
  --ink: #E8EAF0; --ink-2: #9AA3B2; --line: #2A303B;
  --accent: #7C97FF; --accent-ink: #0E1116; --accent-soft: #232C4A;
  --income: #3DD6A0; --alert: #FF8A8A; --warn: #F2B24C;
  --sombra: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.2; }
h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.mudo { color: var(--ink-2); }
.pos { color: var(--income); }
.neg { color: var(--alert); }
.oculto { display: none !important; }

/* ---------- casca ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.lateral { display: none; }
.conteudo { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topo {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topo h1 { font-size: 17px; }
#vista { padding: 14px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 880px; width: 100%; margin: 0 auto; }

.inferior {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--surface); border-top: 1px solid var(--line);
}
.inferior a, .lateral a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 48px; color: var(--ink-2); text-decoration: none; font-size: 11px;
}
.inferior a[aria-current="page"], .lateral a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fab {
  justify-self: center; width: 52px; height: 52px; margin-top: -18px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--sombra); display: grid; place-items: center;
}
.fab .ic { width: 26px; height: 26px; stroke-width: 2.2; }

@media (min-width: 1024px) {
  .shell { flex-direction: row; }
  .inferior { display: none; }
  .lateral {
    display: flex; flex-direction: column; gap: 4px; width: 224px; flex: none; position: sticky; top: 0; height: 100dvh;
    padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line);
  }
  .lateral .marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 16px; }
  .lateral .marca img { width: 28px; height: 28px; border-radius: 8px; }
  .lateral a { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 14px; min-height: 40px; }
  .lateral a:hover { background: var(--surface-2); }
  .lateral a[aria-current="page"] { background: var(--accent-soft); }
  .lateral .espaco { flex: 1; }
  .topo { padding-top: 10px; }
  #vista { padding: 20px 28px 40px; }
}

/* ---------- elementos ---------- */
.cartao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px; }
.cartao + .cartao, .secao + .secao { margin-top: 12px; }
.secao-tit { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 2px 8px; }
.secao-tit h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; }
.grade2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (min-width: 1024px) { .colunas { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r-campo); background: var(--surface); font-weight: 600;
}
.btn.primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.perigo { color: var(--alert); }
.btn.texto { border-color: transparent; background: transparent; color: var(--accent); padding: 0 8px; min-height: 36px; }
.btn.pequeno { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.bloco { width: 100%; }

.campo { display: block; margin-bottom: 12px; }
.campo > span { display: block; margin-bottom: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.campo input, .campo select, .input {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid color-mix(in srgb, var(--ink-2) 40%, var(--line)); border-radius: var(--r-campo);
  background: var(--bg); color: var(--ink);
}
.campo input:focus, .campo select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.campo .erro-campo { color: var(--alert); font-size: 12px; margin-top: 4px; }
.erro { color: var(--alert); font-size: 13px; margin: 0 0 10px; min-height: 0; }

.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--surface); font-size: 13px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.rolavel { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.segmentos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.segmentos button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; color: var(--ink-2); }
.segmentos button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sombra); }

/* ---------- listas ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.dia { margin: 14px 2px 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: capitalize; display: flex; justify-content: space-between; }
.lin {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; width: 100%;
  min-height: 52px; padding: 8px 10px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent;
}
.lin:last-child { border-bottom: 0; }
.lista.caixa { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.lin .ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 13px; }
.lin .ico.receita { color: var(--income); } .lin .ico.despesa { color: var(--ink); }
.lin .txt { min-width: 0; }
.lin .txt strong, .lin .txt small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lin .txt strong { font-weight: 600; font-size: 14px; }
.lin .txt small, .lin .val small { color: var(--ink-2); font-size: 12px; }
.lin .val { text-align: right; font-weight: 600; white-space: nowrap; }
.lin .val small { display: block; font-weight: 400; }
.selo { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.selo.previsto { background: var(--accent-soft); color: var(--accent); }
.selo.atraso { background: color-mix(in srgb, var(--alert) 15%, transparent); color: var(--alert); }

.saldo-grande { font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.resumo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.resumo .cartao small { display: block; color: var(--ink-2); font-size: 12px; }
.resumo .cartao strong { font-size: 18px; }
.barra-cat { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 10px 0; font-size: 13px; }
.barra-cat .trilho { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.barra-cat .trilho i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.vazio { text-align: center; padding: 28px 16px; color: var(--ink-2); }
.vazio .btn { margin-top: 12px; }

.mes-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mes-nav strong { text-transform: capitalize; }
.icone-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; border-radius: 10px; color: var(--ink); }
.icone-btn:hover { background: var(--surface-2); }

/* ---------- folha (lançamento rápido, formulários) ---------- */
.fundo { position: fixed; inset: 0; z-index: 20; background: rgba(10, 12, 18, .5); display: flex; align-items: flex-end; justify-content: center; }
.folha {
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--surface);
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--sombra);
  animation: sobe .16s ease-out;
}
@keyframes sobe { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { .fundo { align-items: center; } .folha { border-radius: 18px; } }
.folha-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.valor-grande {
  width: 100%; border: 0; background: transparent; text-align: center; font-size: 40px; font-weight: 700; letter-spacing: -.02em;
  padding: 12px 0; color: var(--ink); font-variant-numeric: tabular-nums;
}
.valor-grande:focus { outline: none; }
.valor-grande::placeholder { color: var(--ink-2); opacity: .5; }
.valor-wrap { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.valor-wrap span { font-size: 18px; color: var(--ink-2); font-weight: 600; }
.acoes { display: flex; gap: 8px; margin-top: 14px; }
.acoes .btn { flex: 1; }
.linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.aviso { font-size: 12px; color: var(--ink-2); margin: -4px 0 10px; }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
@media (min-width: 1024px) { #toasts { bottom: 24px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: min(92vw, 420px); padding: 10px 14px;
  background: var(--ink); color: var(--bg); border-radius: 12px; box-shadow: var(--sombra); font-size: 13px;
}
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; text-decoration: underline; padding: 4px; }
.toast.erro-t { background: var(--alert); color: #fff; }

/* ---------- telas de entrada ---------- */
.entrada { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.entrada .cartao { width: 100%; max-width: 380px; padding: 22px; }
.entrada .logo { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 12px; }
.entrada h1 { margin-bottom: 4px; }
.entrada p { margin: 0 0 16px; color: var(--ink-2); }
.faixa-offline { background: var(--warn); color: #fff; text-align: center; font-size: 12px; padding: 4px; }

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