/* VerdeMais - App Styles */
:root {
  /* Core palette (Design System VerdeMais) */
  --bg-primary:   #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary:  #111827;
  --verde: #208040;
  --verde-claro: #2FBF71;
  --verde-dark:  #059669;
  --accent-blue: #3B82F6;
  --accent-amber:#F59E0B;
  --accent-rose: #F43F5E;
  --bg: #0f0f1a;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-green: rgba(47,191,113,0.25);
  --text: #F8FAFC;
  --text-muted: #64748B;
  --text-secondary: #94A3B8;
  --sidebar-w: 240px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 50px rgba(0,0,0,0.5);
  --shadow-green: 0 8px 24px rgba(47,191,113,0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(47,191,113,0.3); border-radius: 3px; }

/* AUTH PAGES */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(47,191,113,0.06) 0%, var(--bg) 60%);
  padding: 20px;
}

.auth-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-green);
  border-radius: 24px;
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  backdrop-filter: blur(20px);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #2FBF71, #208040);
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem; margin-bottom: 12px;
}

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.85rem; color: #aaa; margin-bottom: 8px; font-weight: 500; }

.form-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: white;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-input:focus { border-color: var(--verde-claro); background: rgba(255,255,255,0.08); }
.form-input::placeholder { color: #555; }

.form-select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: white;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
}
.form-select option { background: #1a1a2e; color: white; }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #2FBF71, #208040);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(47,191,113,0.35); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: white;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--verde-claro); }

.btn-danger {
  background: rgba(255,80,80,0.1);
  border: 1px solid rgba(255,80,80,0.3);
  color: #ff6b6b;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.btn-danger:hover { background: rgba(255,80,80,0.2); }

.btn-success {
  background: rgba(47,191,113,0.1);
  border: 1px solid rgba(47,191,113,0.3);
  color: #2FBF71;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.btn-success:hover { background: rgba(47,191,113,0.2); }

/* APP LAYOUT */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: rgba(255,255,255,0.02);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #2FBF71, #208040);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(47,191,113,0.12); color: var(--verde-claro); border: 1px solid rgba(47,191,113,0.2); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 1rem; }

.sidebar-user {
  margin-top: auto;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}
.sidebar-user:hover { border-color: var(--border-green); }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(15,15,26,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
}

.page-content { padding: 32px; flex: 1; }

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  transition: all 0.2s;
}
.card:hover { border-color: var(--border-green); }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 24px;
  transition: all 0.2s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-green); }

.stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; }
.stat-change { font-size: 0.78rem; margin-top: 4px; }
.positive { color: var(--verde-claro); }
.negative { color: #ff6b6b; }
.neutral { color: var(--text-muted); }

/* TABLE */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 12px 16px;
  color: var(--text-muted); font-size: 0.78rem;
  font-weight: 600; letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.88rem;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td { border-bottom: none; }

/* BADGE */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 50px;
  font-size: 0.72rem; font-weight: 600;
}
.badge-green { background: rgba(47,191,113,0.12); color: #2FBF71; border: 1px solid rgba(47,191,113,0.25); }
.badge-red { background: rgba(255,80,80,0.1); color: #ff6b6b; border: 1px solid rgba(255,80,80,0.2); }
.badge-yellow { background: rgba(255,196,0,0.1); color: #ffc400; border: 1px solid rgba(255,196,0,0.2); }
.badge-blue { background: rgba(100,180,255,0.1); color: #64b4ff; border: 1px solid rgba(100,180,255,0.2); }

/* PROGRESS BAR */
.progress-bar { height: 8px; background: rgba(255,255,255,0.08); border-radius: 50px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2FBF71, #208040); border-radius: 50px; transition: width 0.5s ease; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
  /* Desktop: overflow oculto — modal rola por conta própria */
  overflow: hidden;
}
.modal {
  background: #16213e;
  border: 1px solid var(--border-green);
  border-radius: 24px;
  padding: 32px;
  width: 100%; max-width: 520px;
  /* Desktop: altura máxima com scroll interno */
  max-height: 90vh;
  overflow-y: auto;
  /* Scroll suave em iOS */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  animation: slideUp 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* TOAST */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1a2740;
  border-radius: 12px;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
  font-size: 0.88rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  border-left: 3px solid #2FBF71;
  animation: slideInRight 0.3s ease;
  min-width: 280px; max-width: 380px;
}
.toast.error { border-left-color: #ff6b6b; }
.toast.warning { border-left-color: #ffc400; }
@keyframes slideInRight { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* SCORE RING */
.score-ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }

/* CATEGORY COLORS */
.cat-alimentacao { color: #ff8c42; }
.cat-transporte { color: #4ecdc4; }
.cat-saude { color: #ff6b6b; }
.cat-educacao { color: #a29bfe; }
.cat-lazer { color: #fd79a8; }
.cat-moradia { color: #74b9ff; }
.cat-outros { color: #b2bec3; }

/* GRADIENT TEXT */
.gradient-text {
  background: linear-gradient(135deg, #2FBF71, #208040);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 20px 16px; }
}

/* SECTION HEADER */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.section-title { font-size: 1.3rem; font-weight: 700; }

/* EMPTY STATE */
.empty-state {
  text-align: center; padding: 60px 20px;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; }

/* LOADING */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* GRID */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.tab-bar {
  display: flex; gap: 4px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px; padding: 4px;
  margin-bottom: 24px;
}
.tab {
  flex: 1; padding: 9px 16px; border-radius: 10px;
  border: none; cursor: pointer;
  font-size: 0.85rem; font-weight: 600;
  background: transparent; color: var(--text-muted);
  transition: all 0.2s;
}
.tab.active { background: rgba(47,191,113,0.15); color: #2FBF71; }

/* ══════════════════════════════════════════════════════════
   DESIGN SYSTEM PREMIUM — card-premium, input-premium, button-premium
   ══════════════════════════════════════════════════════════ */

/* card-premium: glassmorphism com borda verde suave */
.card-premium {
  background: linear-gradient(135deg, rgba(30,41,59,0.9) 0%, rgba(15,23,42,0.95) 100%);
  border: 1px solid rgba(47,191,113,0.18);
  border-radius: var(--radius-xl);
  padding: 28px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}
.card-premium::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(47,191,113,0.5), transparent);
}
.card-premium:hover {
  border-color: rgba(47,191,113,0.35);
  box-shadow: 0 0 0 1px rgba(47,191,113,0.1), var(--shadow-md);
  transform: translateY(-2px);
}

/* card-premium--highlight: versão destaque */
.card-premium--highlight {
  background: linear-gradient(135deg, rgba(47,191,113,0.08) 0%, rgba(5,150,105,0.04) 100%);
  border-color: rgba(47,191,113,0.3);
}

/* card-premium--danger */
.card-premium--danger {
  border-color: rgba(244,63,94,0.25);
}
.card-premium--danger::before {
  background: linear-gradient(90deg, transparent, rgba(244,63,94,0.4), transparent);
}

/* input-premium: campo de formulário premium */
.input-premium {
  width: 100%;
  background: rgba(15,23,42,0.8);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  color: var(--text);
  font-size: 0.93rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.input-premium:focus {
  border-color: #2FBF71;
  background: rgba(15,23,42,0.95);
  box-shadow: 0 0 0 3px rgba(47,191,113,0.12);
}
.input-premium::placeholder { color: var(--text-muted); }
.input-premium:disabled { opacity: 0.5; cursor: not-allowed; }

/* select-premium */
.select-premium {
  width: 100%;
  background: rgba(15,23,42,0.8);
  border: 1.5px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  color: var(--text);
  font-size: 0.93rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}
.select-premium:focus {
  border-color: #2FBF71;
  box-shadow: 0 0 0 3px rgba(47,191,113,0.12);
}
.select-premium option { background: #1E293B; }

/* button-premium: botão principal verde com shimmer */
.button-premium {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 24px;
  background: linear-gradient(135deg, #2FBF71 0%, #059669 100%);
  color: #fff;
  font-size: 0.93rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(47,191,113,0.3);
  letter-spacing: 0.2px;
}
.button-premium::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}
.button-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-green);
}
.button-premium:hover::after { opacity: 1; }
.button-premium:active { transform: translateY(0); }
.button-premium:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

/* button-premium--outline */
.button-premium--outline {
  background: transparent;
  border: 1.5px solid rgba(47,191,113,0.5);
  color: #2FBF71;
  box-shadow: none;
}
.button-premium--outline:hover {
  background: rgba(47,191,113,0.08);
  border-color: #2FBF71;
  box-shadow: none;
}

/* button-premium--danger */
.button-premium--danger {
  background: linear-gradient(135deg, #F43F5E, #be123c);
  box-shadow: 0 4px 14px rgba(244,63,94,0.3);
}

/* button-premium--sm */
.button-premium--sm {
  padding: 8px 16px;
  font-size: 0.82rem;
  border-radius: 10px;
}

/* ══════════════════════════════════════════════════════════
   ACHIEVEMENT TOAST — notificação de conquista desbloqueada
   ══════════════════════════════════════════════════════════ */
.achievement-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  z-index: 9999;
  background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  border: 1px solid rgba(255,196,0,0.4);
  border-radius: 20px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 320px;
  max-width: 480px;
  box-shadow: 0 0 40px rgba(255,196,0,0.15), var(--shadow-lg);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s;
  opacity: 0;
  pointer-events: none;
}
.achievement-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.achievement-toast-icon {
  font-size: 2.2rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(255,196,0,0.5));
  animation: achievement-pulse 2s ease-in-out infinite;
}
@keyframes achievement-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
.achievement-toast-content { flex: 1; }
.achievement-toast-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
}
.achievement-toast-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
}
.achievement-toast-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.achievement-toast-points {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fbbf24;
  white-space: nowrap;
}

/* Confetti particles */
@keyframes confetti-fall {
  0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(80px) rotate(720deg); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════
   METRICS DASHBOARD (admin KPIs)
   ══════════════════════════════════════════════════════════ */
.metric-kpi {
  background: linear-gradient(135deg, rgba(30,41,59,0.9), rgba(15,23,42,0.95));
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}
.metric-kpi::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.metric-kpi--green::after  { background: linear-gradient(90deg, #10B981, #059669); }
.metric-kpi--blue::after   { background: linear-gradient(90deg, #3B82F6, #1D4ED8); }
.metric-kpi--amber::after  { background: linear-gradient(90deg, #F59E0B, #D97706); }
.metric-kpi--rose::after   { background: linear-gradient(90deg, #F43F5E, #BE123C); }
.metric-kpi--purple::after { background: linear-gradient(90deg, #8B5CF6, #6D28D9); }

.metric-kpi-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.metric-kpi-value {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}
.metric-kpi-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-kpi-trend {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 50px;
}
.metric-kpi-trend--up   { background: rgba(16,185,129,0.12); color: #10B981; }
.metric-kpi-trend--down { background: rgba(244,63,94,0.12);  color: #F43F5E; }

/* Progress ring (SVG) */
.progress-ring-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.progress-ring-track { fill: none; stroke: rgba(255,255,255,0.06); }
.progress-ring-fill  { fill: none; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }

/* ══════════════════════════════════════════════════════════
   BUDGET CARD (orçamento por categoria)
   ══════════════════════════════════════════════════════════ */
.budget-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: all 0.2s;
}
.budget-card:hover { border-color: var(--border-green); }
.budget-bar {
  height: 6px;
  background: rgba(255,255,255,0.07);
  border-radius: 50px;
  overflow: hidden;
  margin: 10px 0 6px;
}
.budget-bar-fill {
  height: 100%;
  border-radius: 50px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.budget-bar-fill--ok       { background: linear-gradient(90deg, #10B981, #059669); }
.budget-bar-fill--attention { background: linear-gradient(90deg, #F59E0B, #D97706); }
.budget-bar-fill--exceeded  { background: linear-gradient(90deg, #F43F5E, #BE123C); }

/* ══════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.3); }
  50%  { opacity: 1; transform: scale(1.08); }
  70%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.anim-fadeInUp   { animation: fadeInUp  0.4s ease forwards; }
.anim-scaleIn    { animation: scaleIn   0.3s ease forwards; }
.anim-slideInLeft{ animation: slideInLeft 0.35s ease forwards; }
.anim-bounceIn   { animation: bounceIn  0.5s cubic-bezier(0.34,1.56,0.64,1) forwards; }

/* Stagger children */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

/* ══════════════════════════════════════════════════════════
   MISC IMPROVEMENTS
   ══════════════════════════════════════════════════════════ */

/* Scrollbar mais elegante */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(47,191,113,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(47,191,113,0.45); }

/* Chip / tag inline */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid;
  transition: all 0.15s;
}

/* Tooltip simples */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,23,42,0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Focus ring acessível */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(47,191,113,0.6);
  outline-offset: 2px;
}

/* Mobile melhorias */
@media (max-width: 480px) {
  .card-premium { padding: 18px 16px; }
  .button-premium { padding: 12px 18px; font-size: 0.88rem; }
  .metric-kpi-value { font-size: 1.6rem; }
}

/* ══════════════════════════════════════════════════════════
   BLOCO 9 — RESPONSIVIDADE MOBILE COMPLETA
   Breakpoint principal: 768px
   ══════════════════════════════════════════════════════════ */

/* ── Touch Targets (mínimo 44px conforme Apple HIG) ─────── */
.nav-item,
button,
.btn-primary,
.btn-secondary,
a[onclick] {
  min-height: 44px;
  min-width: 44px;
}
.nav-item {
  display: flex;
  align-items: center;
}

/* ── Sidebar overlay (fundo escuro ao abrir no mobile) ──── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 998;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Bottom Navigation Bar ───────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: rgba(15,23,42,0.98);
  border-top: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 900;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  min-height: 56px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 12px;
  background: none;
  border: none;
  color: #666;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: color 0.2s, background 0.2s;
  text-transform: uppercase;
}
.bottom-nav-item i {
  font-size: 1.2rem;
  transition: transform 0.2s;
}
.bottom-nav-item.active {
  color: #2FBF71;
}
.bottom-nav-item.active i {
  transform: scale(1.15);
}
.bottom-nav-item:hover { color: #2FBF71; }

/* ── Bottom Sheet Modals ─────────────────────────────────── */
@media (max-width: 768px) {
  /* Overlay mobile: alinha ao fundo e permite scroll do próprio modal */
  #modal-container .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    overflow-y: auto !important;
    /* Garante que o overlay cubra tudo incluindo area segura */
    padding-bottom: 0 !important;
  }

  /* Modal vira bottom sheet */
  #modal-container .modal {
    position: relative !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    /* Altura máxima respeitando a bottom nav (64px) + safe area */
    max-height: calc(92vh - 64px) !important;
    border-radius: 20px 20px 0 0 !important;
    transform: none !important;
    animation: slideUpSheet 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    /* Scroll interno do modal */
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    /* Padding inferior: bottom nav + safe area */
    padding: 24px 20px !important;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 12px)) !important;
    /* Margem superior: deixa ver que tem overlay atrás */
    margin-top: 8vh;
    flex-shrink: 0;
  }

  /* Handle visual (alça do bottom sheet) */
  #modal-container .modal::before {
    content: '';
    display: block;
    width: 44px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 0 auto 20px;
    flex-shrink: 0;
  }

  /* Reduzir padding e espaçamentos internos nos forms */
  #modal-container .modal .form-group {
    margin-bottom: 14px !important;
  }

  #modal-container .modal .form-label {
    font-size: 0.82rem !important;
    margin-bottom: 5px !important;
  }

  #modal-container .modal .form-input,
  #modal-container .modal .form-select,
  #modal-container .modal .form-textarea {
    font-size: 16px !important; /* Evita zoom automático iOS */
    padding: 10px 12px !important;
    min-height: 44px !important; /* Touch target mínimo */
  }

  /* Botões de ação: largos e com boa altura para toque */
  #modal-container .modal .btn-primary,
  #modal-container .modal .btn-secondary {
    min-height: 48px !important;
    font-size: 0.95rem !important;
    border-radius: 12px !important;
  }

  /* Grid 2 colunas vira 1 coluna dentro de modais */
  #modal-container .modal [style*="grid-template-columns:1fr 1fr"],
  #modal-container .modal [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Título do modal menor */
  #modal-container .modal h3 {
    font-size: 1rem !important;
  }
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); opacity: 0.8; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Layout principal mobile ─────────────────────────────── */
@media (max-width: 768px) {
  /* Esconder sidebar por padrão e mostrar com .open */
  .sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    z-index: 999;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.visible {
    display: block;
  }

  /* Main content ocupa tela cheia */
  .main-content {
    margin-left: 0 !important;
    padding-bottom: 72px; /* espaço para bottom nav */
  }

  /* Topbar ajustada */
  .topbar {
    padding: 12px 16px !important;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15,23,42,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  /* Botão hamburguer: garantir visibilidade */
  #menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    color: #ccc !important;
    font-size: 1.1rem !important;
  }

  /* Page content */
  .page-content {
    padding: 16px 12px !important;
  }

  /* Bottom nav visível */
  .bottom-nav {
    display: flex !important;
  }

  /* Grids: tudo em coluna única */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Cards menores */
  .stat-card {
    padding: 14px 16px !important;
  }

  /* Tabelas com scroll horizontal */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Formulários full-width */
  .form-group { width: 100%; }
  .form-input, .form-select { font-size: 16px !important; } /* previne zoom no iOS */

  /* Botões de ação lado a lado */
  .action-buttons {
    flex-direction: column;
    gap: 8px;
  }

  /* Section header empilhado em telas muito pequenas */
  .section-header {
    flex-wrap: wrap;
    gap: 10px;
  }
  .section-header .section-title {
    font-size: 1.1rem;
  }

  /* Ocultar textos secundários */
  .hide-mobile { display: none !important; }
  .show-mobile { display: flex !important; }

  /* Dashboard stats 2 colunas */
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Charts menores */
  canvas { max-height: 200px; }
}

/* ── Ajustes para telas muito pequenas (< 390px) ─────────── */
@media (max-width: 390px) {
  .page-content { padding: 12px 8px !important; }
  .bottom-nav-item { font-size: 0.58rem; }
  .bottom-nav-item i { font-size: 1.1rem; }
  .stat-card { padding: 12px !important; }
}

/* ── Landscape mobile ────────────────────────────────────── */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar { width: 220px !important; }
  .page-content { padding: 10px 12px !important; }
}

/* ── iOS safe area (notch) ───────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    height: calc(64px + env(safe-area-inset-bottom));
  }
  .main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* ── BLOCO 6.5: Widget de Chat Flutuante ──────────────────── */
#chat-widget {
  display: none;
  flex-direction: column;
}

#chat-widget.open {
  display: flex !important;
}

.chat-sugestao-btn {
  background: var(--bg-main, #f1f5f9);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
  color: var(--text-main, #1e293b);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.chat-sugestao-btn:hover {
  background: #d1fae5;
  border-color: #10B981;
  color: #065f46;
}

#chat-fab {
  transition: transform 0.2s, box-shadow 0.2s;
}

#chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5) !important;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-color, #e2e8f0);
  border-radius: 4px;
}

/* Mobile: chat ocupa mais espaço */
@media (max-width: 768px) {
  #chat-widget {
    width: calc(100vw - 32px) !important;
    bottom: 80px !important;
    right: 16px !important;
    left: 16px !important;
    max-height: 70vh !important;
  }
  #chat-fab {
    bottom: 80px !important;
    right: 16px !important;
  }
}

/* ── modal-card (usado pelo showModal genérico) ──────────── */
.modal-card {
  background: #16213e;
  border: 1px solid var(--border-green);
  border-radius: 24px;
  padding: 28px;
  width: 100%; max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  animation: slideUp 0.3s ease;
}

@media (max-width: 768px) {
  /* modal-card também vira bottom sheet */
  #modal-container .modal-card {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(88vh - 64px) !important;
    border-radius: 20px 20px 0 0 !important;
    animation: slideUpSheet 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    padding: 20px 18px !important;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 12px)) !important;
    margin-top: 8vh;
  }

  /* Overlay do modal-card alinha ao fundo */
  #modal-container .modal-overlay:has(.modal-card) {
    align-items: flex-end !important;
    padding: 0 !important;
    overflow-y: auto !important;
  }
}

/* ── Scrollbar fina dentro dos modais ────────────────────── */
.modal::-webkit-scrollbar,
.modal-card::-webkit-scrollbar {
  width: 4px;
}
.modal::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}

/* ── Garantia: inputs dentro de modal não disparam zoom iOS ─ */
@media (max-width: 768px) {
  #modal-container input[type="text"],
  #modal-container input[type="number"],
  #modal-container input[type="email"],
  #modal-container input[type="password"],
  #modal-container input[type="date"],
  #modal-container select,
  #modal-container textarea {
    font-size: 16px !important;
    min-height: 44px !important;
  }
}
