:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0891b2;
  --bg: #f1f5f9;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #2563eb;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* SIDEBAR */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: 240px; height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
}
.sidebar-brand {
  padding: 20px 16px;
  color: #fff; font-size: 1.1rem; font-weight: 700;
  border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand span { font-size: 1.4rem; }
.sidebar nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 16px 4px; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .08em; color: #475569; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: var(--sidebar-text);
  text-decoration: none; font-size: .875rem;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(37,99,235,.15); color: #fff;
}
.nav-link.active { border-left: 3px solid var(--sidebar-active); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid #1e293b; }
.sidebar-user { color: #94a3b8; font-size: .8rem; }
.sidebar-user strong { display: block; color: #e2e8f0; margin-bottom: 8px; }

/* MAIN */
.main { margin-left: 240px; min-height: 100vh; }
.topbar {
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.content { padding: 24px; }

/* CARDS */
.card {
  background: var(--card-bg); border-radius: 10px;
  border: 1px solid var(--border); padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-size: .875rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.card-value { font-size: 1.75rem; font-weight: 700; }
.card-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; }
.card-header h5 { font-size: 1rem; font-weight: 600; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: 10px; border: 1px solid var(--border);
  padding: 20px; display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card .icon { font-size: 1.5rem; }
.stat-card .val { font-size: 1.5rem; font-weight: 700; }
.stat-card .lbl { font-size: .8rem; color: var(--text-muted); margin-bottom: 4px; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--text-muted) !important; }

/* TABLES */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { background: #f8fafc; text-align: left; padding: 10px 12px;
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* BADGES */
.badge { display: inline-block; padding: 3px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info { background: #e0f2fe; color: #0891b2; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-primary { background: #dbeafe; color: #2563eb; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px; font-size: .875rem; font-weight: 500;
  border: none; cursor: pointer; text-decoration: none; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-warning { background: var(--warning); color: #fff; }

/* FORMS */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: .8rem; font-weight: 500; color: var(--text-muted); }
.form-control {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: .875rem; outline: none; background: #fff;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control { cursor: pointer; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .875rem; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 95%; max-width: 680px;
  max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; }
.modal-header h4 { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #94a3b8; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* TABS */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 8px 16px; font-size: .875rem; font-weight: 500; cursor: pointer;
  border: none; background: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* PROGRESS */
.progress { background: #e2e8f0; border-radius: 99px; height: 8px; }
.progress-bar { height: 100%; border-radius: 99px; background: var(--primary); }

/* LOGIN */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 380px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .icon { font-size: 2.5rem; }
.login-logo h2 { font-size: 1.4rem; font-weight: 700; margin-top: 8px; }
.login-logo p { color: var(--text-muted); font-size: .875rem; }

/* UTILS */
.mt-0{margin-top:0} .mt-1{margin-top:8px} .mt-2{margin-top:16px} .mt-3{margin-top:24px}
.mb-0{margin-bottom:0} .mb-1{margin-bottom:8px} .mb-2{margin-bottom:16px} .mb-3{margin-bottom:24px}
.d-flex{display:flex} .align-center{align-items:center} .justify-between{justify-content:space-between}
.gap-1{gap:8px} .gap-2{gap:16px} .flex-wrap{flex-wrap:wrap}
.text-right{text-align:right} .text-center{text-align:center}
.w-100{width:100%} .fw-600{font-weight:600} .fs-sm{font-size:.8rem}
.receita-color{color:var(--success)} .despesa-color{color:var(--danger)}
.chip { display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:99px;font-size:.75rem;background:var(--bg); }

/* RESPONSIVE */
@media(max-width:768px){
  .sidebar{transform:translateX(-100%);}
  .main{margin-left:0;}
  .stats-grid{grid-template-columns:1fr 1fr;}
  .form-grid{grid-template-columns:1fr;}
}

/* ── MOBILE FIRST ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 300; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0 !important; }
  .topbar { padding: 0 12px; }
  .content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .stat-card { padding: 14px 12px; }
  .stat-card .val { font-size: 1.1rem; }
  table { font-size: .78rem; }
  th, td { padding: 8px 6px; }
  .modal { padding: 16px; }
  .form-grid { grid-template-columns: 1fr !important; }
  .btn { padding: 8px 12px; font-size: .82rem; }
  /* FAB - botão flutuante para novo lançamento no mobile */
  .fab {
    position: fixed; bottom: 20px; right: 20px;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 1.6rem; border: none; cursor: pointer;
    box-shadow: 0 4px 16px rgba(37,99,235,.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
  }
  .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
  .fab { display: none; }
  .show-mobile { display: none !important; }
}

/* HAMBURGER */
.hamburger {
  display: none; background: none; border: none;
  font-size: 1.4rem; cursor: pointer; padding: 4px 8px;
}
@media (max-width: 768px) { .hamburger { display: block; } }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 299;
}
.sidebar-overlay.open { display: block; }

/* LOGO sidebar */
.sidebar-logo { width: 36px; height: 36px; border-radius: 6px; object-fit: contain; background: #fff; padding: 2px; }

/* ECONOMIA card verde especial */
.stat-card.economia { background: linear-gradient(135deg,#065f46,#059669); color:#fff; }
.stat-card.economia .lbl, .stat-card.economia .val { color: #fff; }

/* BUSCA lançamentos */
.search-box { position: relative; }
.search-box input { padding-left: 32px; }
.search-box .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .9rem; }

/* Ícones dos stat-cards com setas */
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.receita { background: #dcfce7; }
.stat-icon.despesa { background: #fee2e2; }
.stat-icon.saldo   { background: #dbeafe; }
.stat-icon.invest  { background: #e0f2fe; }
.arrow-up   { display:inline-block; width:0; height:0; border-left:8px solid transparent; border-right:8px solid transparent; border-bottom:12px solid #16a34a; }
.arrow-down { display:inline-block; width:0; height:0; border-left:8px solid transparent; border-right:8px solid transparent; border-top:12px solid #dc2626; }
