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

:root {
  --blue: #0052CC;
  --blue-light: #E6EDFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --green: #059669;
  --red: #DC2626;
  --orange: #D97706;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: var(--gray-800);
}

/* ── Wizard shell ── */
.wizard {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 640px;
  overflow: hidden;
}

/* ── Progress bar ── */
.progress {
  height: 4px;
  background: var(--gray-100);
}
.progress-bar {
  height: 100%;
  background: var(--blue);
  transition: width 0.4s ease;
  width: 25%;
}
[data-step="2"] .progress-bar { width: 50%; }
[data-step="3"] .progress-bar { width: 75%; }
[data-step="4"] .progress-bar, [data-step="results"] .progress-bar { width: 100%; }

/* ── Count badge ── */
.count-badge {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--blue-light);
  padding: 12px 32px;
  border-bottom: 1px solid var(--gray-200);
}
.count-badge-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
}
.count-badge-label {
  font-size: 14px;
  color: var(--gray-600);
}

/* ── Steps ── */
.step { padding: 40px 32px 32px; }
.step.hidden { display: none; }

.step-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.step-header h1 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
}
.step-sub {
  font-size: 15px;
  color: var(--gray-600);
  margin-bottom: 32px;
}

.step-body { margin-bottom: 32px; }

.step-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Inputs ── */
.text-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: white;
  color: var(--gray-800);
}
.text-input:focus { border-color: var(--blue); }
.text-input + .text-input,
.text-input + .select-input { margin-top: 12px; }

.select-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  outline: none;
  background: white;
  color: var(--gray-800);
  cursor: pointer;
}
.select-input:focus { border-color: var(--blue); }

/* ── Mode toggle ── */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}
.mode-btn {
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover { border-color: var(--blue); color: var(--blue); }
.mode-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

/* ── Location label ── */
.location-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* ── State grid ── */
.state-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ── Pills ── */
.pill {
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px solid var(--gray-200);
  background: white;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  transition: all 0.15s;
}
.pill:hover { border-color: var(--blue); color: var(--blue); }
.pill.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

/* ── Management level section ── */
.level-section {
  padding-bottom: 20px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--gray-100);
}
.title-group-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  margin-bottom: 12px;
}

/* ── Job title accordion ── */
.title-group { border-bottom: 1px solid var(--gray-100); }
.title-group:first-child { border-top: 1px solid var(--gray-100); }

.title-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.title-group-header:hover { background: var(--gray-50); }

.title-group-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}
.title-group-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}
.title-group-count {
  font-size: 12px;
  font-weight: 600;
  color: white;
  background: var(--blue);
  padding: 2px 8px;
  border-radius: 999px;
}
.title-group-chevron {
  font-size: 18px;
  color: var(--gray-400);
  transition: transform 0.2s;
  display: inline-block;
}
.title-group-header.open .title-group-chevron {
  transform: rotate(90deg);
}
.title-pills-wrap {
  padding: 4px 4px 16px;
}
.title-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Buttons ── */
.btn-primary {
  padding: 12px 24px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: #003fa3; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  padding: 12px 20px;
  background: white;
  color: var(--gray-600);
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s;
}
.btn-secondary:hover { border-color: var(--gray-400); }

.btn-ghost {
  padding: 12px 20px;
  background: transparent;
  color: var(--gray-400);
  border: none;
  font-size: 14px;
  cursor: not-allowed;
  margin-left: auto;
}

/* ── Review card ── */
.review-card {
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.review-row {
  display: flex;
  padding: 16px 20px;
  gap: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.review-row:last-child { border-bottom: none; }
.review-row-count { background: var(--gray-50); }
.review-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-width: 130px;
  padding-top: 2px;
}
.review-value {
  font-size: 15px;
  color: var(--gray-800);
  line-height: 1.5;
}
.review-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
}

/* ── Warning / zero state ── */
.warning {
  margin-top: 16px;
  padding: 12px 16px;
  background: #FEF3C7;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--orange);
  font-weight: 500;
}
.zero-state {
  margin-top: 16px;
  padding: 12px 16px;
  background: #FEE2E2;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--red);
  font-weight: 500;
}

/* ── Results table ── */
#results-table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
}
tr:last-child td { border-bottom: none; }

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-msg { font-size: 15px; color: var(--gray-600); }

/* ── Fade transition ── */
.step { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Login card ── */
.login-card { max-width: 440px; }
.login-card .step-body { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

/* ── User chip / logout ── */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 32px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  font-size: 13px;
  color: var(--gray-600);
}
.user-bar .user-email { font-weight: 600; color: var(--gray-800); }
.user-bar a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}
.user-bar a:hover { text-decoration: underline; }

/* ── Inline error banner (replaces alert()) ── */
.inline-error {
  margin: 0 32px 16px;
  padding: 12px 16px;
  background: #FEE2E2;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--red);
  font-weight: 500;
}

/* ── Autocomplete dropdown ── */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
}
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.ac-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
  background: white;
  border: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.ac-logo-placeholder {
  background: var(--gray-100);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--gray-50); }
.autocomplete-empty {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--gray-400);
  text-align: center;
}
.ac-main { flex: 1; min-width: 0; }
.ac-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-domain {
  color: var(--blue);
  font-weight: 500;
}

/* ── Company confirmation card ── */
.company-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--blue-light);
  border: 2px solid var(--blue);
  border-radius: var(--radius);
}
.company-card-logo {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
  border: 1px solid white;
  flex-shrink: 0;
}
.company-card-main { flex: 1; min-width: 0; }
.company-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}
.company-card-sub {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 4px;
}
.company-card-change {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
}
.company-card-change:hover { text-decoration: underline; }

/* ── Step 3 keyword section ── */
.title-keyword-section {
  padding-bottom: 20px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--gray-100);
}
.optional-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 6px;
}

/* ── Title suggestions (multi-select rows) ── */
.title-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.title-suggestion.selected {
  background: var(--blue-light);
}
.title-suggestion.selected::before {
  content: "✓";
  color: var(--blue);
  font-weight: 700;
  margin-right: 6px;
}
.title-suggestion-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  flex: 1;
}
.title-suggestion-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  background: var(--gray-50);
  padding: 2px 8px;
  border-radius: 999px;
}

/* ── Selected title chips ── */
.title-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.title-chip-row:empty { margin-top: 0; }
.title-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 12px;
  background: var(--blue);
  color: white;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.title-chip-x {
  background: rgba(255,255,255,0.25);
  color: white;
  border: none;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.title-chip-x:hover { background: rgba(255,255,255,0.4); }

/* ── Hidden utility ── */
.hidden { display: none !important; }
