*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --heading: #1b145d;
  --body: rgba(71,67,104,0.8);
  --accent: #3B82F6;
  --accent-dark: #2563eb;
  --accent-light: #dbeafe;
  --accent-bg: #eff6ff;
  --gray-300: #e5e7eb;
  --gray-200: #f3f4f6;
  --gray-100: #f9fafb;
  --gray-600: #64748b;
  --gray-700: #374151;
  --white: #fff;
}
body { font-family: 'Plus Jakarta Sans', sans-serif; color: var(--gray-700); background: var(--gray-100); line-height: 1.6; }
a { text-decoration: none; color: inherit; }

/* Onboarding layout */
.onboarding { max-width: 600px; margin: 80px auto; background: var(--white); border-radius: 16px; padding: 48px; border: 1px solid var(--gray-300); }
.onboarding h1 { color: var(--heading); font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.onboarding .subtitle { color: var(--body); margin-bottom: 32px; font-size: 16px; }
.progress-bar { display: flex; gap: 8px; margin-bottom: 32px; }
.progress-bar .step { flex: 1; height: 4px; background: var(--gray-300); border-radius: 4px; }
.progress-bar .step.active { background: var(--accent); }
.form-group { margin-bottom: 24px; }
.form-group label { display: block; font-weight: 600; color: var(--heading); margin-bottom: 8px; font-size: 14px; }
.form-group select, .form-group input[type="text"] { width: 100%; padding: 12px 16px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; }
.form-group select:focus, .form-group input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 12px; }
.checkbox-group label { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--gray-700); cursor: pointer; padding: 8px 16px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; transition: all 0.15s; }
.checkbox-group label:hover { border-color: var(--accent); }
.checkbox-group input:checked + span { color: var(--accent); }
.checkbox-group label:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }
.checkbox-group input { accent-color: var(--accent); }

/* Tag grid */
.tag-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.tag-grid .tag { padding: 10px 18px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; cursor: pointer; transition: all 0.15s; user-select: none; }
.tag-grid .tag:hover { border-color: var(--accent); }
.tag-grid .tag.selected { background: var(--accent); color: white; border-color: var(--accent); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; border: none; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-row { display: flex; justify-content: space-between; margin-top: 32px; }

/* Location suggestions */
.location-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.location-suggestions .loc { padding: 6px 14px; border: 1px solid var(--gray-300); border-radius: 20px; font-size: 13px; cursor: pointer; transition: all 0.15s; }
.location-suggestions .loc:hover, .location-suggestions .loc.selected { background: var(--accent); color: white; border-color: var(--accent); }

/* Celebration */
.celebration { text-align: center; margin-top: 32px; padding: 24px; background: var(--accent-bg); border-radius: 12px; }
.celebration h2 { color: var(--heading); font-size: 20px; margin-bottom: 8px; }
.celebration p { color: var(--body); margin-bottom: 16px; }

/* Sidebar */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--white); border-right: 1px solid var(--gray-300); padding: 24px 16px; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 10; }
.sidebar .logo { font-size: 22px; font-weight: 800; color: var(--heading); padding: 0 8px 24px; }
.sidebar .logo span { color: var(--accent); }
.sidebar nav { flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--gray-600); margin-bottom: 4px; transition: all 0.15s; }
.sidebar nav a:hover { background: var(--gray-200); color: var(--heading); }
.sidebar nav a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sidebar nav a i { font-size: 18px; }
.sidebar .usage { padding: 16px 12px; border-top: 1px solid var(--gray-300); margin-top: auto; }
.sidebar .usage .usage-text { font-size: 12px; color: var(--gray-600); margin-bottom: 8px; }
.sidebar .usage .usage-bar { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.sidebar .usage .usage-bar .fill { height: 100%; background: var(--accent); border-radius: 3px; }
.sidebar .usage .btn { width: 100%; justify-content: center; }

/* Main content */
.main { margin-left: 240px; flex: 1; padding: 32px; }
.main h1 { color: var(--heading); font-size: 24px; font-weight: 700; margin-bottom: 24px; }

/* Search bar */
.search-bar { display: flex; align-items: center; gap: 12px; background: var(--white); border: 1px solid var(--gray-300); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.search-bar i { color: var(--gray-600); font-size: 18px; }
.search-bar input { flex: 1; border: none; outline: none; font-size: 14px; font-family: inherit; }

/* Filter row */
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filter-row select { padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 13px; font-family: inherit; outline: none; background: var(--white); cursor: pointer; }
.filter-row select:focus { border-color: var(--accent); }
.toggle-wrap { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-700); }
.toggle { width: 36px; height: 20px; background: var(--gray-300); border-radius: 10px; cursor: pointer; position: relative; transition: background 0.2s; }
.toggle.on { background: var(--accent); }
.toggle::after { content: ''; position: absolute; width: 16px; height: 16px; background: white; border-radius: 50%; top: 2px; left: 2px; transition: transform 0.2s; }
.toggle.on::after { transform: translateX(16px); }

/* Results count */
.results-count { font-size: 14px; color: var(--body); margin-bottom: 16px; }

/* Table */
.table-wrap { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--gray-100); }
th { text-align: left; padding: 12px 16px; font-weight: 600; color: var(--heading); font-size: 13px; border-bottom: 1px solid var(--gray-300); }
td { padding: 12px 16px; border-bottom: 1px solid var(--gray-200); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-100); }
.service-tag { display: inline-block; padding: 2px 8px; background: var(--accent-bg); color: var(--accent); border-radius: 4px; font-size: 12px; font-weight: 500; margin: 1px 2px; }
.stars { color: #f59e0b; }
.email-count { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 600; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; padding: 20px; }
.pagination button { width: 36px; height: 36px; border: 1px solid var(--gray-300); background: var(--white); border-radius: 8px; font-family: inherit; font-size: 13px; cursor: pointer; }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:hover:not(.active) { border-color: var(--accent); }

/* Toast */
.toast { position: fixed; bottom: 32px; right: 32px; background: var(--heading); color: white; padding: 14px 24px; border-radius: 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; transform: translateY(100px); opacity: 0; transition: all 0.3s; z-index: 999; }
.toast.show { transform: translateY(0); opacity: 1; }

/* Agency detail */
.agency-header { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 32px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; }
.agency-header .info { display: flex; gap: 20px; align-items: center; }
.agency-header .logo-placeholder { width: 64px; height: 64px; background: var(--accent-bg); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: var(--accent); }
.agency-header .meta { font-size: 14px; color: var(--body); }
.agency-header .meta h1 { margin-bottom: 4px; }
.agency-header .actions { display: flex; gap: 8px; }

.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
.card { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 24px; margin-bottom: 24px; }
.card h2 { color: var(--heading); font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--gray-200); font-size: 14px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--gray-600); }
.verified { color: #10b981; font-size: 12px; }
.review { padding: 16px 0; border-bottom: 1px solid var(--gray-200); }
.review:last-child { border-bottom: none; }
.review .review-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.review p { font-size: 14px; color: var(--body); }
.similar-agency { padding: 12px 0; border-bottom: 1px solid var(--gray-200); }
.similar-agency:last-child { border-bottom: none; }
.similar-agency .name { font-weight: 600; color: var(--heading); font-size: 14px; }
.similar-agency .meta { font-size: 13px; color: var(--gray-600); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--gray-300); margin-bottom: 24px; }
.tabs button { padding: 12px 20px; background: none; border: none; border-bottom: 2px solid transparent; font-family: inherit; font-size: 14px; font-weight: 500; color: var(--gray-600); cursor: pointer; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover:not(.active) { color: var(--heading); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Settings form */
.settings-form .field { margin-bottom: 20px; }
.settings-form .field label { display: block; font-size: 13px; font-weight: 600; color: var(--heading); margin-bottom: 6px; }
.settings-form .field input { width: 100%; max-width: 400px; padding: 10px 14px; border: 1px solid var(--gray-300); border-radius: 8px; font-size: 14px; font-family: inherit; outline: none; }
.settings-form .field input:focus { border-color: var(--accent); }
.plan-card { display: flex; justify-content: space-between; align-items: center; padding: 20px; background: var(--accent-bg); border-radius: 12px; margin-bottom: 20px; }
.plan-card .plan-info h3 { color: var(--heading); font-size: 18px; }
.plan-card .plan-info p { color: var(--body); font-size: 14px; }
.api-key-wrap { display: flex; align-items: center; gap: 8px; }
.api-key-wrap code { padding: 10px 14px; background: var(--gray-100); border: 1px solid var(--gray-300); border-radius: 8px; font-size: 13px; letter-spacing: 1px; }
.integration-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.integration-item { display: flex; justify-content: space-between; align-items: center; padding: 16px; border: 1px solid var(--gray-300); border-radius: 10px; }
.integration-item .int-name { font-weight: 600; color: var(--heading); font-size: 14px; }
.integration-item .int-desc { font-size: 12px; color: var(--gray-600); }

/* Saved search card */
.saved-search-card { background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 20px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.saved-search-card:hover { border-color: var(--accent); }
.saved-search-card .ss-info h3 { color: var(--heading); font-size: 15px; font-weight: 600; }
.saved-search-card .ss-info p { color: var(--gray-600); font-size: 13px; }
.saved-search-card .ss-meta { display: flex; gap: 16px; align-items: center; font-size: 13px; color: var(--gray-600); }
.saved-search-card .ss-actions { display: flex; gap: 8px; align-items: center; }
.new-badge { background: #10b981; color: white; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }

/* Credits bar */
.credits { display: flex; justify-content: space-between; align-items: center; background: var(--white); border: 1px solid var(--gray-300); border-radius: 12px; padding: 20px; margin-bottom: 24px; }
.credits .credits-info { font-size: 14px; color: var(--body); }
.credits .credits-info strong { color: var(--heading); }
.credits-bar-lg { width: 200px; height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.credits-bar-lg .fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* Confetti canvas */
#confetti { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

/* Mobile responsive */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; padding: 12px 16px; flex-direction: row; align-items: center; }
  .sidebar .logo { margin-bottom: 0; }
  .sidebar nav { display: flex; flex-direction: row; gap: 0; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .sidebar .usage { display: none; }
  .main { margin-left: 0; padding: 16px; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 600px; }
  .filter-row { flex-wrap: wrap; }
  .filter-row select { flex: 1 1 120px; }
  .onboarding { margin: 20px auto; padding: 24px; }
  .stats-row { grid-template-columns: repeat(2, 1fr) !important; }
  h1 { font-size: 20px; }
}

@media (max-width: 480px) {
  .sidebar nav a span { display: none; }
  .stats-row { grid-template-columns: 1fr !important; }
}
