/* ============================================================
   CONTROLE FINANCEIRO — UI moderna (mobile-first)
   Design: cards suaves, hero de saldo, gestão por gestos e
   lançamento rápido (pensado para usar na rua).
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg: #f3f6fb;
  --bg-grad-1: #eef3fa;
  --bg-grad-2: #e6f6ef;
  --card: #ffffff;
  --card-soft: #f8fafc;
  --border: #e7ecf3;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #10b981;
  --primary-strong: #047857;
  --primary-soft: #d1fae5;
  --green: #166534;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #f59e0b;
  --amber-bg: #fef3c7;
  --blue: #3b82f6;
  --ring: rgba(16, 185, 129, .35);
  --hero-a: #065f46;
  --hero-b: #064e3b;
  --sel-a: #047857;   /* fundo de item selecionado: mais escuro p/ texto branco passar AA */
  --sel-b: #065f46;
  --amber-btn-a: #b45309;
  --amber-btn-b: #92400e;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px rgba(15, 23, 42, .04);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .05);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, .18);
  --toast-bg: #0f172a;
}

:root[data-tema="escuro"] {
  --bg: #0b1220;
  --bg-grad-1: #0e1626;
  --bg-grad-2: #0c1f1a;
  --card: #111a2c;
  --card-soft: #0e1626;
  --border: #1f2b41;
  --text: #e6edf7;
  --muted: #8ea0b8;
  --primary: #34d399;
  --primary-strong: #34d399;
  --primary-soft: #064e3b;
  --green: #4ade80;
  --green-bg: #14532d;
  --red: #f87171;
  --red-bg: #7f1d1d;
  --amber: #fbbf24;
  --amber-bg: #78350f;
  --blue: #60a5fa;
  --ring: rgba(52, 211, 153, .4);
  --hero-a: #115e59;
  --hero-b: #134e4a;
  --sel-a: #0f766e;
  --sel-b: #115e59;
  --amber-btn-a: #b45309;
  --amber-btn-b: #92400e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
  --toast-bg: #e6edf7;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

body[data-auth="locked"] .topo,
body[data-auth="locked"] .visualizacao,
body[data-auth="locked"] main,
body[data-auth="locked"] .fab,
body[data-auth="locked"] #toast {
  display: none;
}

/* ---------- acesso privado ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(16, 185, 129, .14), transparent 60%),
    var(--bg);
}
.auth-overlay[hidden] { display: none; }
.auth-card {
  width: min(100%, 400px);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
}
.auth-card[hidden] { display: none; }
.auth-marca {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  font-weight: 900;
  letter-spacing: -.5px;
}
.auth-card h2 { font-size: 1.45rem; letter-spacing: -.35px; }
.auth-sub {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: .91rem;
}
.auth-campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.auth-campo input {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: var(--card-soft);
  color: var(--text);
  font-size: 1rem;
}
.auth-campo input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.auth-entrar { width: 100%; min-height: 48px; margin-top: 2px; }
.auth-entrar:disabled { opacity: .65; cursor: wait; }
.auth-link {
  display: block;
  margin: 12px auto 0;
  padding: 6px;
  border: none;
  background: transparent;
  color: var(--primary-strong);
  font-size: .82rem;
  font-weight: 750;
  cursor: pointer;
}
.auth-link:disabled { opacity: .6; cursor: wait; }
.auth-message {
  margin: 2px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--red-bg);
  color: var(--red);
  font-size: .84rem;
  font-weight: 650;
}
.auth-message[data-kind="success"] {
  background: var(--green-bg);
  color: var(--green);
}
.auth-message[hidden] { display: none; }
.auth-privado {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: .75rem;
  text-align: center;
}
.auth-user {
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-user[hidden], .btn-sair[hidden] { display: none; }
.btn-sair {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
  cursor: pointer;
}
.btn-sair:disabled { opacity: .55; cursor: wait; }

/* ---------- header (fixo: título + seletor de mês) ---------- */
.topo {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--card);
  color: var(--text);
  padding: calc(8px + env(safe-area-inset-top)) 16px 0;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(15, 23, 42, .06);
}
:root[data-tema="escuro"] .topo { box-shadow: 0 2px 14px rgba(0, 0, 0, .45); }
.topo-linha {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 760px;
  margin: 0 auto;
}
.topo h1 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -.1px;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sync-status {
  font-size: .76rem;
  font-weight: 700;
  color: var(--primary-strong);
  animation: pulse 1.1s ease-in-out infinite;
  white-space: nowrap;
}
.sync-status[hidden] { display: none; }
@keyframes pulse { 50% { opacity: .4; } }

/* ícones: SVG de traço fino (a interface não usa emojis) */
.icone {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icone.cheio { fill: currentColor; stroke: none; }

.btn-tema {
  background: transparent;
  border: none;
  border-radius: 12px;
  width: 44px; height: 44px;
  flex-shrink: 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.btn-tema:active { background: var(--card-soft); color: var(--text); }

/* ---------- navegação (Financeiro / Arrecadação) ---------- */
.visualizacao {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  width: calc(100% - 32px);
  max-width: 728px;
  margin: 10px auto 0;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.viz-btn {
  padding: 9px 10px;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.viz-btn.ativo {
  background: var(--card);
  color: var(--primary-strong);
  box-shadow: var(--shadow-sm);
}
.viz-btn[data-viz="cha"].ativo { color: var(--amber-btn-a); }
:root[data-tema="escuro"] .viz-btn[data-viz="cha"].ativo { color: var(--amber); }
.viz-btn:active { transform: scale(.98); }

/* ---------- layout principal ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- avisos ---------- */
.aviso {
  background: var(--amber-bg);
  border: 1px solid rgba(245, 158, 11, .35);
  color: #b45309;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .86rem;
  font-weight: 500;
}
:root[data-tema="escuro"] .aviso { color: #fbbf24; }
.aviso-erro { background: var(--red-bg); border-color: rgba(239, 68, 68, .35); color: #b91c1c; }
:root[data-tema="escuro"] .aviso-erro { color: #fca5a5; }
.aviso code { background: rgba(0, 0, 0, .08); padding: 1px 6px; border-radius: 6px; }

/* ---------- cartões ---------- */
.cartao {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.cartao h2 {
  font-size: .8rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- hero saldo ---------- */
.saldo {
  background:
    radial-gradient(400px 180px at 100% 0%, rgba(255, 255, 255, .16), transparent 60%),
    linear-gradient(120deg, var(--hero-a), var(--hero-b));
  border: none;
  color: #fff;
  text-align: left;
  padding: 16px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.saldo::after {
  content: "";
  position: absolute;
  width: 220px; height: 220px;
  right: -70px; top: -90px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  pointer-events: none;
}
.saldo-rotulo { font-size: .8rem; font-weight: 600; opacity: .85; letter-spacing: .3px; text-transform: uppercase; }
.saldo-valor {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin: 4px 0 14px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .12);
}
.saldo-valor.positivo { color: #fff; }
.saldo-valor.negativo { color: #ffe1e1; }

.saldo-por-conta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255, 255, 255, .10);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 14px;
  overflow: hidden;
}
.saldo-item {
  min-width: 0;
  background: rgba(255, 255, 255, .04);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.saldo-item-nome { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; opacity: .95; }
.saldo-item-valor { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.saldo-item-valor.positivo { color: #d7fff0; }
.saldo-item-valor.negativo { color: #ffefef; }
.saldo-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
.tag {
  padding: 0;
  border: none;
  background: none;
  font-weight: 700;
  font-size: .78rem;
  color: #fff;
  opacity: .92;
  font-variant-numeric: tabular-nums;
}
.tag-saida { opacity: .78; }

/* ---------- dashboard (resumo do mês) ---------- */
.resumo-topo { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.resumo-topo h2 { margin-bottom: 10px; }
.resumo-comp {
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* proporção entradas x saídas: 10px de altura no lugar da antiga rosca */
.resumo-barra {
  display: flex;
  gap: 2px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}
.resumo-fatia-e { background: var(--green); }
.resumo-fatia-s { background: var(--red); }
.resumo-legenda {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: .78rem;
  color: var(--muted);
}
.resumo-legenda b { font-variant-numeric: tabular-nums; }
.resumo-legenda .e { color: var(--green); }
.resumo-legenda .s { color: var(--red); }
.resumo-legenda .vazio { font-weight: 600; }

.resumo-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  margin-top: 14px;
  background: var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.resumo-kpis[hidden] { display: none; }
.kpi {
  background: var(--card);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.kpi-rot {
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-val {
  font-size: .92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-sub {
  font-size: .76rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi.neg .kpi-val { color: var(--red); }
.kpi.pos .kpi-val { color: var(--green); }

/* ---------- meses (chips no topo, sempre visíveis) ---------- */
.meses {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
  padding: 2px 0 8px;
}
.meses-list {
  display: flex; gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.meses-list::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border);
  background: var(--card-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 16px;
  min-height: 44px;
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s;
  scroll-snap-align: start;
}
.chip:active { transform: scale(.95); }
.chip.ativo {
  background: linear-gradient(120deg, var(--sel-a), var(--sel-b));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, .28);
}
.btn-mes-novo {
  border: 1.5px dashed var(--muted);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  width: 44px; height: 44px;
  font-size: 1.25rem; font-weight: 700;
  cursor: pointer; flex-shrink: 0;
  transition: all .15s;
}
.btn-mes-novo:active { transform: scale(.9); }

/* ---------- ações / filtros ---------- */
.acoes { display: flex; flex-direction: column; gap: 10px; }
.btn-primario {
  background: linear-gradient(120deg, var(--hero-a), var(--hero-b));
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: .98rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(5, 150, 105, .3);
  transition: transform .12s, filter .15s;
}
.btn-primario:active { transform: scale(.98); }
.btn-primario:hover { filter: brightness(1.06); }
.btn-primario:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; }

.filtros { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filtros input, .filtros select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
  font-size: .9rem;
  background: var(--card);
  color: var(--text);
  width: 100%;
  appearance: none;
}
.filtros select:focus-visible, .filtros input:focus-visible,
.btn-tema:focus-visible, .chip:focus-visible,
.btn-mes-novo:focus-visible, .viz-btn:focus-visible, .lanc-mais:focus-visible,
.chip-rapido:focus-visible, .tipo-btn:focus-visible, .cha-tipo-btn:focus-visible,
.btn-primario:focus-visible, .btn-secundario:focus-visible, .btn-ver-mais:focus-visible,
.acao-item:focus-visible {
  outline: 3px solid var(--primary-strong);
  outline-offset: 2px;
}
.filtros select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---------- gráfico por categoria ---------- */
.barra-linha {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 78px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.barra-linha:last-child { border-bottom: none; }
.barra-rotulo { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-pista { background: var(--card-soft); border-radius: 999px; height: 6px; overflow: hidden; }
.barra-preenchida { height: 100%; background: var(--red); border-radius: 999px; min-width: 3px; transition: width .3s; }
.barra-valor { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.vazio { color: var(--muted); font-size: .88rem; text-align: center; padding: 14px 6px; }

/* ---------- extrato ---------- */
.extrato { padding: 14px 14px 12px; }
.extrato .contador {
  background: none;
  border: none;
  color: var(--muted);
  border-radius: 0;
  padding: 0;
  font-size: .8rem;
  font-weight: 700;
  vertical-align: middle;
}
.lanc {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto 44px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.lanc:last-child { border-bottom: none; }
.lanc-data {
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.2px;
}
.lanc-num {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1px;
}
.lanc-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lanc-desc { font-weight: 650; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lanc-det { color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lanc-valor { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; font-size: .92rem; white-space: nowrap; }
.lanc-valor.entrada { color: var(--green); }
.lanc-valor.saida { color: var(--red); }
.lanc-mais {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 12px;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.lanc-mais:active { background: var(--card-soft); color: var(--text); }
.marcado-rot { color: var(--green); font-weight: 800; }

/* "ver mais": evita rolar centenas de lançamentos de uma vez */
.btn-ver-mais {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  min-height: 44px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--card-soft);
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-ver-mais:active { background: var(--border); }

/* ---------- modal (bottom-sheet no celular) ---------- */
dialog {
  border: none;
  border-radius: 20px;
  padding: 0;
  width: min(94vw, 430px);
  /* o reset universal (*) zera o margin: auto que o navegador usa para centralizar */
  margin: auto;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; } }
dialog::backdrop { background: rgba(2, 6, 23, .55); backdrop-filter: blur(3px); }
@media (max-width: 560px) {
  dialog {
    width: 100%;
    max-width: 100%;
    margin: auto auto 0;
    border-radius: 20px 20px 0 0;
  }
  dialog[open] { animation: sheet .26s cubic-bezier(.2, .8, .25, 1); }
  @keyframes sheet { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
}
#form-lancamento { padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
#form-lancamento h3 { font-size: 1.12rem; font-weight: 800; }
#form-lancamento > label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: .76rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
}
#form-lancamento input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: var(--card-soft);
  color: var(--text);
  width: 100%;
  transition: border .15s, box-shadow .15s;
}
#form-lancamento input:focus {
  outline: none;
  border-color: var(--primary-strong);
  box-shadow: 0 0 0 4px var(--ring);
  background: var(--card);
}
#f-valor { font-size: 1.5rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; }

/* toggle Entrada / Saída */
.tipo-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tipo-btn {
  border: 1px solid var(--border);
  background: var(--card-soft);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
  font-weight: 800;
  font-size: .95rem;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
}
.tipo-btn:active { transform: scale(.97); }
.tipo-btn[data-tipo="entrada"].ativo { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.tipo-btn[data-tipo="saida"].ativo { border-color: var(--red); background: var(--red-bg); color: var(--red); }
:root[data-tema="escuro"] .tipo-btn[data-tipo="saida"].ativo { color: #fca5a5; }

/* chips rápidos (conta/categoria com 1 toque) */
.chips-rapido-box { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 2px; }
.chips-rapido-box[hidden] { display: none; }
.chip-rapido {
  border: 1px solid var(--border);
  background: var(--card-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .12s;
}
.chip-rapido:active { transform: scale(.94); }
.chip-rapido.ativo { background: var(--primary-soft); border-color: var(--primary-strong); color: var(--primary-strong); }

.modal-acoes { display: flex; gap: 10px; margin-top: 4px; }
.modal-acoes .btn-primario { flex: 1.4; font-size: 1.02rem; }
.btn-secundario {
  flex: 1;
  background: var(--card-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  font-size: .95rem;
}

/* ---------- folha de ações da linha do extrato ---------- */
.acoes-corpo { padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
.acoes-corpo h3 { font-size: 1rem; font-weight: 800; }
.acoes-det { color: var(--muted); font-size: .78rem; margin: 2px 0 12px; }
.acoes-lista { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.acao-item {
  display: block;
  width: 100%;
  padding: 14px 16px;
  min-height: 52px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: .95rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.acao-item:last-child { border-bottom: none; }
.acao-item:active { background: var(--card-soft); }
.acao-item[hidden] { display: none; }
.acao-perigo { color: var(--red); }
.acao-cancelar { display: block; width: 100%; margin-top: 10px; }

/* ---------- botão flutuante (novo lançamento) ---------- */
.fab {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--hero-a), var(--hero-b));
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(5, 150, 105, .4);
  z-index: 50;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }
.fab:disabled { background: #9ca3af; box-shadow: none; cursor: not-allowed; }
.fab:focus-visible { outline: 3px solid var(--primary-strong); outline-offset: 3px; }
/* alinha o FAB à borda direita do conteúdo (main = 760px, padding 16px) */
@media (min-width: 760px) { .fab { right: calc(50vw - 364px); } }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom));
  background: var(--toast-bg);
  color: var(--card);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  opacity: 0;
  transition: opacity .22s;
  max-width: 92vw;
  text-align: center;
}
.toast.visivel { opacity: 1; }
@media (min-width: 720px) { .toast { bottom: 24px; } }

/* ============ aba Arrecadação ============ */
.chaveiros .cha-dica { font-size: .82rem; color: var(--muted); margin: 0 0 14px; }
.chaveiros h3 { font-size: .92rem; margin: 8px 0 6px; }

/* grade única de produtos (cabeçalho Produto | Levou | Voltou) */
.cha-produtos { margin-bottom: 12px; }
.cha-produtos[hidden] { display: none; }
.cha-grade {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--card-soft);
}
.cha-grade-topo, .cha-linha {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 64px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}
.cha-grade-topo {
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.cha-grade-topo span:not(:first-child) { text-align: center; }
.cha-linha { border-bottom: 1px solid var(--border); }
.cha-linha:last-child { border-bottom: none; }
.cha-linha-nome { font-size: .88rem; font-weight: 650; display: flex; flex-direction: column; min-width: 0; }
.cha-linha-nome small { font-size: .76rem; font-weight: 600; color: var(--muted); }
.cha-linha input, .cha-valor input, .cha-custo input {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: .95rem;
  font-weight: 700;
}
.cha-linha input { text-align: center; }
.cha-custo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: .76rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cha-custo input { width: 96px; }

/* totais do dia: Nome ocupa a linha toda, valores em 2×2 */
.cha-totais { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.cha-valor {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .76rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cha-valor:first-child { grid-column: 1 / -1; }

/* resumo do cálculo: rótulo + valor por linha */
.cha-resumo {
  margin: 12px 0;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card-soft);
}
.cha-resumo[hidden] { display: none; }
.cha-resumo .linha {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.cha-resumo .linha:last-child { border-bottom: none; }
.cha-resumo .linha-rot {
  display: flex;
  flex-direction: column;
  font-size: .76rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cha-resumo .linha-rot small { font-size: .76rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
.cha-resumo .linha-val { font-size: .92rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cha-resumo .tot .linha-rot { color: var(--text); }
.cha-resumo .lucro-positivo { color: var(--green); font-weight: 800; }
.cha-resumo .lucro-negativo { color: var(--red); font-weight: 800; }
.cha-lancar { margin-top: 2px; }

/* telas estreitas (<=340px): recupera largura para a descrição do extrato */
@media (max-width: 340px) {
  .extrato { padding: 12px 10px 10px; }
  .lanc { grid-template-columns: 44px minmax(0, 1fr) auto 44px; gap: 6px; }
  .auth-user { display: none; }
}

/* ---------- telas médias ---------- */
@media (min-width: 640px) {
  .filtros { grid-template-columns: repeat(4, 1fr); }
  #f-valor { font-size: 1.8rem; }
  .cha-totais { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .cha-valor:first-child { grid-column: 1 / -1; }
}

/* fundo do input de data no escuro */
:root[data-tema="escuro"] input[type="date"] { color-scheme: dark; }

/* ============ seletor da arrecadação (chaveiros / brownie) ============ */
.cha-tipo { display: flex; gap: 8px; margin-bottom: 10px; }
.cha-tipo-btn {
  flex: 1;
  padding: 11px 8px;
  min-height: 44px;
  border: 1px solid var(--border);
  background: var(--card-soft);
  color: var(--muted);
  border-radius: 14px;
  font-weight: 800;
  font-size: .92rem;
  cursor: pointer;
  transition: all .15s;
}
.cha-tipo-btn:active { transform: scale(.97); }
.cha-tipo-btn[data-cha-tipo="chaveiros"].ativo { background: var(--amber-btn-a); color: #fff; border-color: transparent; }
.cha-tipo-btn[data-cha-tipo="brownie"].ativo { background: #854d0e; color: #fff; border-color: transparent; }

/* ---------- acessibilidade ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
