:root {
  --primary: #00A651;
  --primary-dark: #007A3D;
  --primary-light: #E6F7ED;
  --red: #e63329;
  --primary-border: #8FDCB3;
  --gradient: linear-gradient(135deg, #00A651 0%, #00C863 100%);
  --red-light: #fef2f2;
  --white: #ffffff;
  --bg: #f0f2f5;
  --sidebar-bg: #0D0D0D;
  --sidebar-text: #a0a0a0;
  --sidebar-active: #00A651;
  --card-border: #e8ecf0;
  --text: #1e2d3d;
  --text-muted: #8a9ab5;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon { font-size: 28px; }
.sidebar-logo .logo-name {
  font-size: 18px;
  font-weight: 800;
  color: white;
  line-height: 1.2;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--sidebar-text);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  border-radius: 0;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.nav-item.active {
  background: rgba(0,166,81,0.15);
  color: var(--primary);
  border-right: 3px solid var(--primary);
}

.nav-icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  font-weight: 700;
}

.admin-info { flex: 1; }
.admin-name { font-size: 13px; font-weight: 600; color: white; }
.admin-role { font-size: 11px; color: var(--sidebar-text); }

/* Main content */
.main {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: white;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content {
  padding: 28px;
  flex: 1;
}

/* Cards de stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--primary-light); }
.stat-icon.blue { background: #eff6ff; }
.stat-icon.purple { background: #faf5ff; }
.stat-icon.orange { background: #fff7ed; }

.stat-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Cards genéricos */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-body { padding: 24px; }

/* Tabela */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--card-border);
}

tbody tr {
  border-bottom: 1px solid #f0f3f7;
  transition: background 0.15s;
}

tbody tr:hover { background: #fafbfc; }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 16px;
  color: var(--text);
}

.td-muted { color: var(--text-muted); font-size: 13px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: var(--primary-light); color: var(--primary-dark); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-gray { background: #f0f3f7; color: var(--text-muted); }
.badge-blue { background: #eff6ff; color: #1d4ed8; }

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--card-border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--red); }

/* Form */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--card-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  background: white;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,166,81,0.15);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 16px;
}

/* Search / filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .form-control {
  max-width: 240px;
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--primary-border); }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--card-border);
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-btns { display: flex; gap: 6px; }
.pagination-btns .btn { padding: 6px 12px; font-size: 13px; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0D0D0D 0%, #007A3D 100%);
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

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

.login-logo .logo-icon { font-size: 48px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text); margin-top: 10px; }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* Chart area */
.chart-container {
  position: relative;
  height: 200px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--card-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
}

/* Hidden pages */
.page { display: none; }
.page.active { display: block; }

/* Utility */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Tablet: sidebar recolhida */
@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
  .sidebar-logo .logo-name { font-size: 15px; }
  .nav-item { padding: 10px 14px; font-size: 13px; }
  .content { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Botão WhatsApp na tabela de leads */
.btn-whatsapp {
  background: #25D366;
  color: #fff !important;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}
.btn-whatsapp:hover { background: #1ebe57; color: #fff; }
.btn-whatsapp svg { width: 15px; height: 15px; fill: currentColor; flex-shrink: 0; }
