:root {
  --bg: #F6F3EC;
  --surface: #FFFFFF;
  --ink: #16241F;
  --muted: #6B7570;
  --border: #E4DFD3;
  --accent: #0E3B36;
  --accent-2: #B08D2B;
  --accent-soft: #E7E1CF;
  --positive: #2F6F4E;
  --negative: #A23E30;
  --radius: 14px;
  --font-serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-top: 64px;
  padding-bottom: 78px;
  min-height: 100vh;
}

button, input, select {
  font-family: inherit;
  font-size: 1rem;
}

.money, .card-valor, .card-valor-sm, .hero-valor, .item-valor, .cat-valor {
  font-variant-numeric: tabular-nums;
}

/* ---------- Topbar ---------- */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
}

.topbar-brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.mes-seletor {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 600;
}

.mes-arrow {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mes-arrow:active { background: rgba(255,255,255,0.24); }

/* ---------- Conteúdo ---------- */

.content {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
}

.titulo {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin: 4px 0 4px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  padding: 6px 0;
  margin-bottom: 4px;
  cursor: pointer;
}

.hero-sub {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 4px 0 16px;
}

.empty-hint {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ---------- Hero (saldo) ---------- */

.hero {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 20px 18px;
  margin-bottom: 14px;
}
.hero-label {
  font-size: 0.85rem;
  opacity: 0.8;
  margin-bottom: 4px;
}
.hero-valor {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  line-height: 1.1;
  margin-bottom: 12px;
}
.hero-valor.saldo-neg { color: #F0B3A8; }
.hero .hero-sub {
  color: rgba(255,255,255,0.75);
  margin: 8px 0 0;
}
.hero .bar { background: rgba(255,255,255,0.2); }

/* ---------- Grids e cards ---------- */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  cursor: default;
}
.card[data-nav] { cursor: pointer; }
.card.small { padding: 12px; }
.card-label { color: var(--muted); font-size: 0.8rem; margin-bottom: 4px; }
.card-valor { font-size: 1.3rem; font-weight: 700; }
.card-valor-sm { font-size: 1.05rem; font-weight: 700; }
.card-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.card-hint.ok { color: var(--positive); }
.card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.muted-card { background: var(--accent-soft); border: none; }

.alert-card { border-color: var(--accent-2); }
.alert-item {
  font-size: 0.9rem;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  margin: 0;
}
.alert-item:first-of-type { border-top: none; }

.banner-arquivado {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
}

/* ---------- Categorias / barras ---------- */

.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  font-size: 0.92rem;
}
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-nome { flex: 1; }
.cat-valor { font-weight: 600; display: flex; align-items: center; gap: 6px; }

.bar {
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0 8px;
}
.bar-fill { height: 100%; border-radius: 4px; transition: width .3s ease; }

.delta { font-size: 0.78rem; font-weight: 700; padding: 1px 0; }
.delta-up { color: var(--negative); }
.delta-down { color: var(--positive); }

/* ---------- Formulários ---------- */

.form-card input, .form-card select,
.inline-form input, .inline-form select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
  color: var(--ink);
}
.form-card input:focus, .form-card select:focus,
.inline-form input:focus, .inline-form select:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}
.field-label { font-size: 0.8rem; color: var(--muted); display: block; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; margin: 4px 0 10px; color: var(--muted); }
.check input { width: auto; margin: 0; }

.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.inline-form input { margin-bottom: 0; flex: 1; }
.inline-form select { margin-bottom: 0; width: auto; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: #0a2926; }
.btn-outline { background: none; border: 1px solid var(--accent); color: var(--accent); }
.btn-danger-outline { border-color: var(--negative); color: var(--negative); }
.btn-block { width: 100%; display: block; margin: 6px 0 16px; }

/* ---------- Listas de itens ---------- */

.lista { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.item-main { flex: 1; min-width: 0; }
.item-titulo { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.item-valor { font-weight: 700; white-space: nowrap; }

.tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 4px;
  text-transform: none;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
}
.icon-btn:active { color: var(--negative); }

.status-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.status-btn.is-pago { background: var(--positive); color: #fff; border-color: var(--positive); }

.cat-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.78rem;
  background: #fff;
  color: var(--ink);
  max-width: 108px;
}

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 6px; margin: 12px 0 16px; }
.tab {
  flex: 1;
  padding: 10px 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
}
.tab.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.82rem;
}

/* ---------- Menu (Ajustes) ---------- */

.menu-lista { gap: 6px; }
.menu-item {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.menu-item.danger { color: var(--negative); }
.versao { text-align: center; margin-top: 18px; }

/* ---------- Upload / spinner ---------- */

.upload-card { text-align: center; }
.upload-card input[type=file] { margin-top: 10px; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 14px auto 0;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Orçamento ---------- */

.orc-row .orc-limite { margin-top: 6px; }

/* ---------- Bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 70px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}

.navbtn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 4px 10px;
}
.navbtn svg { width: 22px; height: 22px; }
.navbtn.is-active { color: var(--accent); }

.navbtn-central {
  background: var(--accent-2);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin-top: -26px;
  box-shadow: 0 3px 10px rgba(176,141,43,0.4);
  justify-content: center;
}
.navbtn-central svg { width: 24px; height: 24px; }
.navbtn-central span { display: none; }

/* ---------- Sheet (menu Lançar) ---------- */

.sheet-overlay {
  position: fixed; inset: 0;
  background: rgba(22,36,31,0.45);
  display: flex; align-items: flex-end;
  z-index: 30;
}
.sheet {
  background: var(--surface);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 10px 14px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-item {
  background: none;
  border: none;
  text-align: left;
  padding: 14px 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.sheet-item:last-of-type, .sheet-cancel { border-bottom: none; }
.sheet-cancel { color: var(--muted); text-align: center; margin-top: 4px; }

/* ---------- Responsivo ---------- */

@media (min-width: 640px) {
  .content { padding: 24px; }
}
