/* ========== Fonte ========== */
@import url('https://fonts.googleapis.com/css2?family=Anek+Latin:wght@400;500;600;700;800&display=swap');

/* ========== Reset / base ========== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  /* Paleta bordô */
  --bordo: #6e1423;
  --bordo-2: #8b1e30;
  --bordo-3: #4a0d18;
  --bordo-claro: #fbeef0;
  --verde: #2f7d57;
  --vermelho: #c0392b;
  --azul: #3498db;
  --texto: #1a1a1a;
  --texto-2: #6b7280;
  --texto-3: #9ca3af;
  --bg: #f6f7f8;
  --bg-card: #ffffff;
  --borda: #eaecef;
  --borda-2: #d1d5db;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.12);
  --r-card: 14px;
  --r-btn: 10px;
  --r-pill: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

html, body {
  font-family: 'Anek Latin', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--texto);
  background: var(--bg);
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
input, button, select, textarea { font-family: inherit; font-size: 16px; }
button { cursor: pointer; border: none; background: none; }
.oculto { display: none !important; }

/* ========== Login ========== */
.tela-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--bordo) 0%, var(--bordo-2) 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--r-card);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-2);
  text-align: center;
}
.login-logo { font-size: 56px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-sub { color: var(--texto-2); font-size: 14px; margin-bottom: 20px; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--borda);
  border-radius: var(--r-btn);
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--bordo); }
.login-erro {
  margin-top: 12px;
  background: #fce8eb;
  color: var(--bordo);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
}

/* ========== Header ========== */
.topo {
  background: linear-gradient(135deg, var(--bordo) 0%, var(--bordo-2) 100%);
  color: #fff;
  padding-top: var(--safe-top);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(110,20,35,0.3);
}
.topo-conteudo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}
.topo h1 { font-size: 18px; font-weight: 800; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #fff;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.15); }

/* ========== Filtro ========== */
.filtro-wrap { padding: 12px 16px 0; }
.select-filtro {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-btn);
  border: 1.5px solid var(--borda);
  background: var(--bg-card);
  font-weight: 600;
  color: var(--texto);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e1423' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
}

/* ========== Card total ========== */
.card-total {
  margin: 12px 16px;
  background: linear-gradient(135deg, var(--bordo) 0%, var(--bordo-2) 100%);
  border-radius: var(--r-card);
  padding: 18px 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 14px rgba(110,20,35,0.35);
}
.total-label { font-size: 12px; opacity: 0.9; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.total-valor { font-size: 32px; font-weight: 800; margin-top: 4px; }
.total-qtd { font-size: 13px; opacity: 0.9; margin-top: 2px; }

/* ========== Cards genéricos ========== */
.card {
  margin: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--r-card);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--texto-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.vazio { text-align: center; color: var(--texto-3); padding: 18px 8px; font-size: 14px; }

/* ========== Lista categorias resumo (com barras) ========== */
.cat-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--borda);
}
.cat-row:last-child { border-bottom: none; }
.cat-row-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}
.cat-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cat-icone { font-size: 18px; }
.cat-nome { font-weight: 600; font-size: 14px; }
.cat-qtd { font-size: 11px; color: var(--texto-3); }
.cat-valores { text-align: right; }
.cat-valor { font-weight: 700; font-size: 14px; }
.cat-pct { font-size: 11px; color: var(--texto-2); }
.cat-barra-bg {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.cat-barra {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}

/* ========== Lista de gastos ========== */
.gasto-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--borda);
  cursor: pointer;
  transition: background .12s;
}
.gasto-item:active { background: var(--bg); }
.gasto-item:last-child { border-bottom: none; }
.gasto-icone-wrap {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.gasto-info { flex: 1; min-width: 0; }
.gasto-cat { font-weight: 600; font-size: 14px; }
.gasto-meta { font-size: 12px; color: var(--texto-2); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gasto-valor { font-weight: 700; font-size: 15px; color: var(--vermelho); }

/* ========== FAB ========== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bot));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bordo) 0%, var(--bordo-2) 100%);
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  box-shadow: 0 6px 16px rgba(110,20,35,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  transition: transform .15s;
}
.fab:active { transform: scale(0.92); }

/* ========== Modais ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
  padding: 0;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s cubic-bezier(.16,1,.3,1);
  padding-bottom: var(--safe-bot);
}
@keyframes slideUp { from { transform: translateY(100%);} to { transform: translateY(0);} }
.modal-pequeno { max-height: 70vh; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--borda);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-header .icon-btn { color: var(--texto-2); width: 32px; height: 32px; font-size: 18px; }
.modal-corpo {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-rodape {
  padding: 14px 20px;
  border-top: 1px solid var(--borda);
  display: flex;
  gap: 10px;
}
.modal-rodape > button { flex: 1; }

/* desktop: centraliza modal */
@media (min-width: 720px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { border-radius: var(--r-card); max-height: 85vh; }
}

/* ========== Campos ========== */
.campo {
  display: block;
  margin-bottom: 14px;
}
.campo > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--texto-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.campo > span small { color: var(--texto-3); font-weight: 500; text-transform: none; letter-spacing: 0; }
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--borda);
  border-radius: var(--r-btn);
  outline: none;
  background: #fff;
  color: var(--texto);
  transition: border-color .15s;
  font-size: 16px; /* evita zoom no iOS */
  font-family: inherit;
}
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--bordo); }
.campo textarea { resize: none; }
.campo input[type="color"] { height: 48px; padding: 4px; cursor: pointer; }

/* ========== Botões ========== */
.btn-primario {
  background: linear-gradient(135deg, var(--bordo) 0%, var(--bordo-2) 100%);
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--r-btn);
  font-weight: 700;
  font-size: 15px;
  width: 100%;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 2px 8px rgba(110,20,35,0.35);
}
.btn-primario:active { transform: scale(0.98); }
.btn-secundario {
  background: var(--bg);
  color: var(--texto);
  padding: 12px 16px;
  border-radius: var(--r-btn);
  font-weight: 600;
  border: 1.5px solid var(--borda);
}
.btn-perigo {
  background: #fff;
  color: var(--vermelho);
  border: 1.5px solid var(--vermelho);
  padding: 14px 18px;
  border-radius: var(--r-btn);
  font-weight: 700;
}
.btn-bloco { width: 100%; margin-top: 8px; }

/* ========== Menu (lista de itens) ========== */
.item-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px;
  border-radius: var(--r-btn);
  font-size: 15px;
  font-weight: 500;
  color: var(--texto);
  text-align: left;
  transition: background .12s;
}
.item-menu:hover { background: var(--bg); }
.item-menu span { font-size: 20px; }

/* ========== Edit categorias ========== */
.lista-categorias-edit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.cat-edit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-btn);
  background: var(--bg);
  cursor: pointer;
  transition: background .12s;
}
.cat-edit-item:hover { background: #eef0f3; }
.cat-edit-item .badge-cor {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cat-edit-item .nome { flex: 1; font-weight: 600; font-size: 14px; }
.cat-edit-item .seta { color: var(--texto-3); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  animation: toastIn .25s ease;
  max-width: 90%;
}
.toast.erro { background: var(--vermelho); }
.toast.sucesso { background: var(--verde); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px);} to { opacity:1; transform: translate(-50%, 0);} }
