/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple: #F5C200;
  --purple-light: #FFFBE6;
  --purple-dark: #B8920A;
  --purple-darker: #7A5F00;
  --teal: #1D9E75;
  --teal-light: #E1F5EE;
  --teal-dark: #0F6E56;
  --green: #0F6E56;
  --green-light: #E1F5EE;
  --red: #D85A30;
  --red-light: #FAECE7;
  --red-dark: #993C1D;
  --amber: #EF9F27;
  --amber-light: #FAEEDA;
  --amber-dark: #854F0B;
  --gray: #888780;
  --gray-light: #F1EFE8;
  --bg: #F4F3FB;
  --card: #FFFFFF;
  --text: #1a1a1a;
  --text-muted: #888;
  --border: rgba(0,0,0,0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== LOGIN ===== */
.login-bg {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  background: var(--card);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
  border: 0.5px solid var(--border);
  box-shadow: var(--shadow);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--purple);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 1.5rem; }
.login-link { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 1rem; }
.login-link a { color: var(--purple); text-decoration: none; }

/* ===== FORM FIELDS ===== */
.field { margin-bottom: 1rem; }
.field label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 5px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus { border-color: var(--purple); }

/* ===== BUTTONS ===== */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-cancel {
  flex: 1;
  padding: 11px;
  background: var(--gray-light);
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-logout {
  width: 100%;
  margin-top: 1.5rem;
  padding: 12px;
  background: var(--red-light);
  color: var(--red-dark);
  border: 0.5px solid #F0997B;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn-ia {
  width: 100%;
  margin-top: 1rem;
  padding: 12px;
  background: var(--purple-light);
  color: var(--purple-dark);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple-dark);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* ===== AVATAR ===== */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple-darker);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar-lg { width: 50px; height: 50px; font-size: 18px; }

/* ===== PAGE WRAP ===== */
.page-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  min-height: 100vh;
}
.page-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 2rem;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--text); }
.page-sub { font-size: 13px; color: var(--text-muted); }

/* ===== SELEÇÃO DE CARTEIRA ===== */
.carteira-list { display: flex; flex-direction: column; gap: 10px; }
.carteira-item {
  background: var(--card);
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.carteira-item:hover { box-shadow: 0 2px 8px rgba(245,194,0,0.12); }
.carteira-add { border-style: dashed; }
.carteira-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}
.ci-purple { background: var(--purple-light); color: var(--purple-darker); }
.ci-teal { background: var(--teal-light); color: var(--teal-dark); }
.ci-gray { background: var(--gray-light); color: var(--gray); }
.ci-green { background: var(--green-light); color: var(--green); }
.ci-amber { background: var(--amber-light); color: var(--amber-dark); }
.carteira-info { flex: 1; }
.ci-name { font-size: 14px; font-weight: 500; color: var(--text); }
.ci-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== APP SHELL ===== */
.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== APP HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 0;
  flex-shrink: 0;
}
.ah-left { display: flex; align-items: center; gap: 10px; }
.ah-name { font-size: 15px; font-weight: 600; color: var(--text); }
.ah-carteira { font-size: 12px; color: var(--purple); font-weight: 500; }
.ah-right { display: flex; gap: 8px; }

/* ===== APP CONTENT ===== */
.app-content { flex: 1; overflow-y: auto; padding: 0 1.25rem 6rem; }
.tab-content { display: none; padding-top: 1.25rem; }
.tab-content.active { display: block; }

/* ===== SALDO HERO ===== */
.saldo-hero {
  text-align: center;
  padding: 1.5rem 0 1.25rem;
}
.saldo-label { font-size: 13px; color: #1a1a1a; margin-bottom: 6px; font-weight: 500; }
.saldo-valor { font-size: 32px; font-weight: 600; color: #1a1a1a; letter-spacing: -0.5px; }
.saldo-mes { font-size: 13px; color: #1a1a1a; margin-top: 4px; font-weight: 500; }

/* ===== METRICS ===== */
.metrics-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.5rem; }
.metric-card {
  border-radius: var(--radius);
  padding: 14px;
  border: 0.5px solid var(--border);
  background: var(--card);
}
.mc-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.mc-green .mc-icon { background: var(--green-light); color: var(--green); }
.mc-red .mc-icon { background: var(--red-light); color: var(--red); }
.mc-label { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.mc-valor { font-size: 16px; font-weight: 600; }
.mc-green .mc-valor { color: var(--green); }
.mc-red .mc-valor { color: var(--red-dark); }

/* ===== SECTION TITLE ===== */
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }

/* ===== TX LIST ===== */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.tx-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-cat { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tx-val { font-size: 13px; font-weight: 600; flex-shrink: 0; }
.val-pos { color: var(--green); }
.val-neg { color: var(--red-dark); }

/* ===== CAT BARS ===== */
.cat-bars { display: flex; flex-direction: column; gap: 10px; }
.cat-bar-row { display: flex; align-items: center; gap: 10px; }
.cb-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cb-name { font-size: 13px; color: var(--text-muted); width: 90px; flex-shrink: 0; }
.cb-track { flex: 1; height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.cb-fill { height: 100%; border-radius: 4px; }
.cb-pct { font-size: 12px; color: var(--text-muted); width: 32px; text-align: right; flex-shrink: 0; }

/* ===== GRÁFICOS ===== */
.graf-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 1rem;
}
.mes-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple);
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.mes-label { font-size: 15px; font-weight: 600; color: #1a1a1a; }
.tab-pills { display: flex; gap: 8px; margin-bottom: 1.5rem; }
.pill {
  padding: 7px 16px;
  border-radius: 20px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--gray-light);
  color: var(--text-muted);
}
.pill.active { background: var(--purple); color: white; }
.donut-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.donut-total-label { font-size: 11px; color: var(--text-muted); }
.donut-total-val { font-size: 16px; font-weight: 600; color: var(--text); }
.cat-legend { display: flex; flex-direction: column; gap: 10px; }
.cl-row { display: flex; align-items: center; gap: 10px; }
.cl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cl-name { flex: 1; font-size: 13px; color: var(--text-muted); }
.cl-val { font-size: 13px; font-weight: 500; color: var(--text); }
.cl-pct { font-size: 12px; color: var(--text-muted); width: 32px; text-align: right; }

/* ===== TRANSAÇÕES ===== */
.tx-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  margin-bottom: 12px;
}
.tx-search input {
  border: none;
  background: transparent;
  font-size: 13px;
  outline: none;
  flex: 1;
  color: var(--text);
}
.tx-filter { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 0.5px solid var(--border);
  background: var(--card);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.filter-btn.active { background: var(--purple); color: white; border-color: var(--purple); }

/* ===== DRE ===== */
.dre-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  padding: 1.25rem;
}
.dre-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; }
.dre-section-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.dre-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); padding: 6px 0; border-bottom: 0.5px solid var(--border); }
.dre-total { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--text); padding: 10px 0 0; }
.dre-pos { color: var(--green); }
.dre-neg { color: var(--red-dark); }
.dre-resultado {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 0.5px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.dre-res-val { display: flex; align-items: center; gap: 8px; }
.dre-badge {
  background: var(--green-light);
  color: var(--green);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.ia-box {
  background: var(--purple-light);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 13px;
  color: var(--purple-darker);
  line-height: 1.7;
  margin-top: 1rem;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-top: 0.5px solid var(--border);
  display: flex;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
}
.bn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.15s;
}
.bn-btn.active { color: var(--purple); }

/* ===== FAB ===== */
.fab {
  position: fixed;
  bottom: 72px;
  right: calc(50% - 220px);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--purple);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245,194,0,0.4);
  z-index: 101;
  transition: transform 0.15s;
}
.fab:hover { transform: scale(1.05); }
@media (max-width: 500px) { .fab { right: 20px; } }

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 1.5rem 1.25rem 2rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 10px; margin-top: 1rem; }
.tipo-pills { display: flex; gap: 8px; }
.tipo-pill {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.tipo-pill.active { background: var(--purple); color: white; border-color: var(--purple); }

/* ===== CONFIG ===== */
.config-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1.5rem;
}
.back-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gray-light);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  flex-shrink: 0;
}
.config-user {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 1.75rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  border: 0.5px solid var(--border);
}
.cu-name { font-size: 15px; font-weight: 600; color: var(--text); }
.cu-email { font-size: 12px; color: var(--text-muted); }
.config-section-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 1.25rem 0 8px; }
.config-menu {
  background: var(--card);
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  overflow: hidden;
}
.config-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.config-item:hover { background: var(--bg); }
.config-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ci-text { flex: 1; }
.ci-title { font-size: 13px; font-weight: 500; color: var(--text); }
.ci-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
