/* ============================================================
   Bússola Financeira — página única, tema claro premium
   Tokens: fundo #f7f5f1 / cartões brancos / dourado #a07f35
   Verde = avanço · Vermelho = queda · Variações em %
   ============================================================ */

:root {
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-2: #f4f1eb;
  --surface-3: #eae6dd;
  --line: #e7e3d9;
  --text: #2b2721;
  --text-dim: #7c7568;
  --text-faint: #a59d8e;
  --gold: #a07f35;
  --gold-soft: rgba(160, 127, 53, 0.12);
  --red: #cc3b36;
  --red-soft: rgba(204, 59, 54, 0.10);
  --green: #1e8e5a;
  --green-soft: rgba(30, 142, 90, 0.10);
  --radius: 16px;
  --shadow: 0 1px 2px rgba(43, 39, 33, 0.04), 0 4px 16px rgba(43, 39, 33, 0.05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

/* ---------- Cabeçalho ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: rgba(247, 245, 241, 0.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--gold); display: flex; font-size: 20px; }
.ic { width: 1em; height: 1em; display: block; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }
.brand-name em { font-style: normal; color: var(--gold); }
.head-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.period-seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.pseg-btn {
  background: none; border: none; color: var(--text-dim); font: inherit;
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.pseg-btn.active { background: var(--gold-soft); color: var(--gold); }
.month-nav { display: flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px 5px; }
.month-label { font-size: 13px; font-weight: 600; color: var(--gold); min-width: 84px; text-align: center; text-transform: capitalize; white-space: nowrap; }
@media (max-width: 460px) { .brand-name { display: none; } }
.icon-btn {
  background: none; border: none; color: var(--text-dim); font-size: 17px;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active, .icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Página ---------- */
.page { max-width: 640px; margin: 0 auto; padding: 14px 14px calc(100px + var(--safe-bottom)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.card-title .sub { font-size: 11px; letter-spacing: 0; text-transform: none; font-weight: 500; color: var(--text-dim); }

/* ---------- Variação (%) ---------- */
.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: 1px;
}
.delta.up { color: var(--green); background: var(--green-soft); }
.delta.down { color: var(--red); background: var(--red-soft); }
.delta.flat { color: var(--text-dim); background: var(--surface-2); }

/* ---------- Resumo ---------- */
.hero { text-align: center; padding: 22px 18px; }
.hero-label { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-faint); }
.hero-value { font-size: 36px; font-weight: 800; letter-spacing: -0.02em; margin: 4px 0 10px; }
.hero-value.neg { color: var(--red); }
.hero-value.pos { color: var(--green); }
.hero-split { display: flex; justify-content: center; gap: 22px; font-size: 13px; flex-wrap: wrap; }
.hero-split b { font-variant-numeric: tabular-nums; }
.hs-in b { color: var(--green); }
.hs-out b { color: var(--red); }
.hero-note { margin-top: 12px; font-size: 12px; color: var(--text-dim); }
.hero-note b { color: var(--gold); }

/* ---------- Categorias (% linear) ---------- */
.catbar { padding: 9px 0; }
.catbar-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.catbar-ic { width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.catbar-name { flex: 1; font-size: 14px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catbar-val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.catbar-pct { font-size: 13px; font-weight: 700; color: var(--gold); width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.fill { height: 100%; border-radius: 999px; background: var(--gold); transition: width 0.35s ease; }
.stackbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; margin-bottom: 16px; background: var(--surface-3); }
.stackbar div { height: 100%; }

/* ---------- Fixos ---------- */
.fix-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fix-ic { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.fix-row:last-child { border-bottom: none; }
.fix-name { flex: 1; font-size: 14px; }
.fix-meta { font-size: 11px; color: var(--text-faint); }
.fix-val { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--red); }
.fix-val.income { color: var(--green); }
.link { background: none; border: none; color: var(--gold); font: inherit; font-size: 12.5px; cursor: pointer; padding: 0; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--red); }

/* ---------- Lançamentos ---------- */
.filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim);
  font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.chip.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); font-weight: 600; }
.tx-day-head {
  display: flex; justify-content: space-between; font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint);
  padding: 12px 2px 5px;
}
.tx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-radius: 10px; cursor: pointer;
}
.tx-item:hover { background: var(--surface-2); }
.tx-ic { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; background: var(--surface-2); }
.tx-body { flex: 1; min-width: 0; }
.tx-desc { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 11px; color: var(--text-faint); }
.tx-val { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13.5px; color: var(--red); }
.tx-val.income { color: var(--green); }
.badge { display: inline-block; font-size: 9.5px; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-dim); margin-left: 5px; vertical-align: 1px; }

/* ---------- Dados ---------- */
.data-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.hint { font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }

/* ---------- Botões ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  border: none; border-radius: 12px; padding: 12px 20px; cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-gold { background: var(--gold); color: #fffdf8; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 8px 14px; font-size: 12.5px; border-radius: 10px; }

.fab {
  position: fixed; bottom: calc(20px + var(--safe-bottom)); right: 20px; z-index: 30;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--gold); color: #fffdf8; border: none;
  font-size: 30px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(160, 127, 53, 0.35);
}
.fab:active { transform: scale(0.95); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(43, 39, 33, 0.35); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(24px + var(--safe-bottom));
  width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  animation: slideup 0.22s ease;
}
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-title { font-size: 16px; font-weight: 700; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.seg-btn { flex: 1; background: none; border: none; color: var(--text-dim); font: inherit; font-size: 14px; font-weight: 600; padding: 10px; border-radius: 9px; cursor: pointer; }
.seg-btn.active.seg-despesa { background: var(--red-soft); color: var(--red); }
.seg-btn.active.seg-receita { background: var(--green-soft); color: var(--green); }

.amount-input-wrap { display: flex; align-items: baseline; gap: 8px; justify-content: center; padding: 4px 0 14px; }
.amount-prefix { font-size: 17px; color: var(--text-faint); }
.amount-input {
  background: none; border: none; color: var(--text);
  font-size: 38px; font-weight: 800; width: 210px; text-align: center;
  border-bottom: 2px solid var(--line); font-variant-numeric: tabular-nums;
}
.amount-input:focus { outline: none; border-color: var(--gold); }

.cat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.cat-opt {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 2px 7px; text-align: center; cursor: pointer; font: inherit; color: var(--text-dim);
}
.cat-opt .e { font-size: 18px; display: flex; justify-content: center; }
.cat-opt .n { font-size: 9.5px; display: block; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-opt.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-full { grid-column: 1 / -1; }
.field label { font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.field input, .field select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; color: var(--text); font: inherit; font-size: 14px; width: 100%;
  appearance: none; -webkit-appearance: none;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.options-row { flex-direction: row; gap: 18px; align-items: center; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--gold); }
.mini-select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font: inherit; font-size: 13px; padding: 4px 8px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-gold { flex: 1; }

/* ---------- Login (conta do casal) ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 70;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-box {
  width: 100%; max-width: 360px; text-align: center;
  display: flex; flex-direction: column; gap: 10px;
}
.login-mark { justify-content: center; font-size: 40px; margin-bottom: 4px; }
.login-title { font-weight: 700; font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase; }
.login-title em { font-style: normal; color: var(--gold); }
.login-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; line-height: 1.5; }
.login-box input {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; color: var(--text); font: inherit; font-size: 15px; width: 100%;
}
.login-box input:focus { outline: none; border-color: var(--gold); }
.login-msg { font-size: 12.5px; color: var(--text-dim); min-height: 18px; }

/* ---------- Toast / util ---------- */
.toast {
  position: fixed; bottom: calc(92px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fffdf8;
  padding: 10px 20px; border-radius: 999px; font-size: 13px; z-index: 60; white-space: nowrap;
  box-shadow: 0 8px 28px rgba(43, 39, 33, 0.25);
}
.empty { text-align: center; color: var(--text-faint); padding: 22px 12px 10px; font-size: 13.5px; }
.empty .big { font-size: 30px; display: flex; justify-content: center; margin-bottom: 8px; color: var(--text-faint); }
.hidden { display: none !important; }

@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
  .page { padding-top: 20px; }
}

