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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --sidebar-width: 260px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --radius: 12px;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
}

.logo-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.sidebar-toggle { display: none; background: none; border: none; color: #fff; cursor: pointer; }

.nav-menu {
  list-style: none;
  padding: 0 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  margin-bottom: 4px;
  color: rgba(255,255,255,.7);
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.15); color: #fff; }

.sidebar-links {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: auto;
}

.sidebar-links-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: rgba(255,255,255,.4);
  margin-bottom: 10px;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  transition: all .2s;
  margin-bottom: 4px;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: .7;
}

.sidebar-link:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  color: rgba(255,255,255,.5);
}

/* Main */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 0 32px 32px;
  min-height: 100vh;
}

.top-bar {
  padding: 24px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar h1 {
  font-size: 24px;
  font-weight: 700;
}

.mobile-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

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

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

.stat-value { font-size: 28px; font-weight: 700; display: block; }
.stat-label { font-size: 13px; color: var(--text-light); }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Views */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); }

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

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }

.btn-success { background: var(--success); color: #fff; }

/* Inputs */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color .2s;
  background: var(--card);
}
.input:focus { outline: none; border-color: var(--primary); }

.textarea { resize: vertical; }

.input-color {
  width: 50px; height: 40px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
}

.input-file {
  width: 100%;
  padding: 8px;
  font-size: 13px;
}

.select-filter {
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  min-width: 200px;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

/* Pages Grid */
.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.page-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.page-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.page-card-header {
  padding: 20px;
  color: #fff;
  position: relative;
}

.page-card-header h3 { font-size: 18px; margin-bottom: 4px; }
.page-card-header .page-business { font-size: 13px; opacity: .85; }

.page-card-body {
  padding: 16px 20px;
}

.page-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-light);
}

.page-meta span { display: flex; align-items: center; gap: 4px; }

.page-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.page-status.active { background: #ecfdf5; color: #059669; }
.page-status.inactive { background: #fef2f2; color: #dc2626; }

.page-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.page-actions .btn { flex: 1; justify-content: center; font-size: 12px; padding: 8px; }

/* Leads */
.leads-container { overflow-x: auto; }

.leads-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.leads-table th {
  background: #f1f5f9;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: .5px;
}

.leads-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.leads-table tr:hover td { background: #f8fafc; }

.lead-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* Recent Leads */
.recent-leads .lead-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.recent-leads .lead-item:last-child { border-bottom: none; }

.lead-info { flex: 1; }
.lead-info strong { font-size: 14px; }
.lead-info small { color: var(--text-light); font-size: 12px; display: block; margin-top: 2px; }

/* Fields Builder */
.fields-section {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
}

.fields-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.fields-header h3 { margin-bottom: 0; }

.field-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 8px;
}

.field-item .input { margin-bottom: 0; }
.field-item select { padding: 8px 12px; border: 2px solid var(--border); border-radius: 8px; font-size: 13px; }

.field-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.field-required-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-light);
  flex-shrink: 0;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
}

.modal-sm { max-width: 500px; }

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

.modal-header h2 { font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: #f1f5f9; }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .mobile-toggle { display: block; }

  .main-content {
    margin-left: 0;
    padding: 0 16px 16px;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .pages-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }

  .modal { max-height: 95vh; margin: 10px; }
}

/* Lead detail */
.lead-detail-table {
  width: 100%;
}
.lead-detail-table td {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.lead-detail-table td:first-child {
  font-weight: 600;
  color: var(--text-light);
  width: 40%;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
