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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f1114;
  color: #e1e4e8;
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #161920;
  border-bottom: 1px solid #2d333b;
  padding: 16px 20px;
}

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

h1 {
  font-size: 1.3rem;
  font-weight: 600;
  color: #f0f3f6;
}

.rated-count {
  font-size: 0.8rem;
  color: #8b949e;
  margin-right: 8px;
}

#refresh-btn {
  background: #238636;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

#refresh-btn:hover { background: #2ea043; }
#refresh-btn:disabled { background: #2d333b; cursor: wait; }

.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#search {
  flex: 1;
  background: #0d1117;
  border: 1px solid #2d333b;
  color: #e1e4e8;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

#search:focus { border-color: #388bfd; }
#search::placeholder { color: #6e7681; }

select {
  background: #0d1117;
  border: 1px solid #2d333b;
  color: #e1e4e8;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

.subreddit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sub-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #2d333b;
  background: #0d1117;
  color: #8b949e;
  transition: all 0.15s;
}

.sub-tag.active {
  background: #1f2a3d;
  border-color: #388bfd;
  color: #58a6ff;
}

.sub-tag.source-reddit.active { background: #1f2a3d; border-color: #58a6ff; color: #58a6ff; }
.sub-tag.source-hn.active { background: #3d2a1a; border-color: #ff6600; color: #ff6600; }
.sub-tag.source-devto.active { background: #1a2d3d; border-color: #3b49df; color: #8b9cf7; }

/* Status */
.status {
  text-align: center;
  padding: 20px;
  color: #8b949e;
  font-size: 0.9rem;
}

/* Leads grid */
.leads-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: #21262d;
  max-width: 900px;
  margin: 0 auto;
}

.lead-card {
  background: #161920;
  padding: 16px 20px;
  transition: background 0.12s;
  color: inherit;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.lead-card:hover { background: #1c2028; }
.lead-card.dismissed { opacity: 0.4; }

.lead-link {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  display: block;
}

.lead-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  padding-top: 2px;
}

.rate-btn {
  background: none;
  border: 1px solid #2d333b;
  border-radius: 6px;
  color: #6e7681;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.rate-btn:hover { border-color: #8b949e; color: #e1e4e8; }
.rate-btn.like.active { border-color: #238636; color: #3fb950; background: #1a3d2a; }
.rate-btn.dislike.active { border-color: #da3633; color: #f85149; background: #3d1a1a; }

.lead-score {
  background: #1a2d1a;
  color: #3fb950;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.7rem;
}

.lead-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.75rem;
  color: #8b949e;
}

.lead-source {
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.lead-source.source-reddit { background: #1f2a3d; color: #58a6ff; }
.lead-source.source-hn { background: #3d2a1a; color: #ff6600; }
.lead-source.source-devto { background: #1a2d3d; color: #8b9cf7; }

.lead-flair {
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.7rem;
}

.lead-flair.hiring {
  background: #1a3d2a;
  color: #3fb950;
}

.lead-flair.forhire {
  background: #3d2a1a;
  color: #d29922;
}

.lead-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: #f0f3f6;
  margin-bottom: 6px;
  line-height: 1.4;
}

.lead-body {
  font-size: 0.82rem;
  color: #8b949e;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lead-budget {
  display: inline-block;
  margin-top: 8px;
  background: #2a1f3d;
  color: #bc8cff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Responsive */
@media (min-width: 700px) {
  header { padding: 16px 24px; }
  .leads-grid { margin: 16px auto; border-radius: 8px; overflow: hidden; border: 1px solid #21262d; }
}

@media (max-width: 500px) {
  .controls { flex-wrap: wrap; }
  select { flex: 1; min-width: 0; }
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #2d333b;
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* Logo link */
.logo-link { text-decoration: none; color: inherit; }

/* Auth UI in header */
.auth-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-email {
  font-size: 0.8rem;
  color: #8b949e;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-plan {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.auth-plan.free { background: #1f2a3d; color: #58a6ff; }
.auth-plan.pro { background: #1a3d2a; color: #3fb950; }

.auth-btn {
  background: none;
  border: 1px solid #2d333b;
  color: #8b949e;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.auth-btn:hover { border-color: #8b949e; color: #e1e4e8; }

.auth-signin {
  background: #238636;
  color: #fff;
  border-color: #238636;
}

.auth-signin:hover { background: #2ea043; border-color: #2ea043; }

/* Sign-in Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background: #161920;
  border: 1px solid #2d333b;
  border-radius: 16px;
  padding: 36px;
  max-width: 420px;
  width: 100%;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: #6e7681;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover { color: #e1e4e8; }

.modal-content h2 {
  color: #f0f3f6;
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.modal-desc {
  color: #8b949e;
  font-size: 0.85rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

#signin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#signin-email {
  background: #0d1117;
  border: 1px solid #2d333b;
  color: #e1e4e8;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
}

#signin-email:focus { border-color: #388bfd; }
#signin-email::placeholder { color: #6e7681; }

#signin-form .btn-primary {
  background: #238636;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#signin-form .btn-primary:hover { background: #2ea043; }
#signin-form .btn-primary:disabled { background: #2d333b; cursor: wait; }

.signin-status {
  font-size: 0.85rem;
  min-height: 20px;
  margin-top: 8px;
}

.signin-status.success { color: #3fb950; }
.signin-status.error { color: #f85149; }

/* Bookmark button */
.rate-btn.bookmark.active { border-color: #d29922; color: #d29922; background: #3d2a1a; }

/* Freshness badges */
.lead-fresh {
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lead-fresh.new { background: #1a3d2a; color: #3fb950; }
.lead-fresh.stale { background: #2d333b; color: #6e7681; }

/* Saved searches */
.saved-searches-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.saved-search-item {
  display: flex;
  align-items: center;
  gap: 2px;
}

.saved-search-btn {
  padding: 3px 10px;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #2d333b;
  background: #0d1117;
  color: #bc8cff;
  transition: all 0.15s;
}

.saved-search-btn:hover { border-color: #bc8cff; background: #2a1f3d; }

.saved-search-delete {
  background: none;
  border: none;
  color: #6e7681;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 2px 4px;
}

.saved-search-delete:hover { color: #f85149; }

/* Save search tag */
.save-search-tag {
  border-style: dashed !important;
  color: #6e7681 !important;
}

.save-search-tag:hover { color: #bc8cff !important; border-color: #bc8cff !important; }

/* Bookmark source tag */
.sub-tag.source-bookmark { border-color: #d29922; color: #d29922; }
.sub-tag.source-bookmark.active { background: #3d2a1a; border-color: #d29922; color: #d29922; }

/* Upgrade toast */
.upgrade-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #1a2d1a 0%, #161920 100%);
  border: 1px solid #238636;
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: #e1e4e8;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(35,134,54,0.3);
  animation: slideUp 0.3s ease;
  max-width: 520px;
  width: calc(100% - 32px);
}

.upgrade-toast .toast-msg { flex: 1; }

.upgrade-toast .toast-upgrade-btn {
  background: #238636;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.upgrade-toast .toast-upgrade-btn:hover { background: #2ea043; }

.upgrade-toast .toast-close {
  background: none;
  border: none;
  color: #6e7681;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  flex-shrink: 0;
}

.upgrade-toast .toast-close:hover { color: #e1e4e8; }

@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #6e7681;
  font-size: 0.9rem;
}

/* Welcome banner */
.welcome-banner {
  max-width: 900px;
  margin: 16px auto 0;
  padding: 0 16px;
  animation: slideDown 0.4s ease;
}

.welcome-inner {
  background: #1a2d1a;
  border: 1px solid #238636;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.85rem;
  color: #e1e4e8;
}

.welcome-inner strong { color: #3fb950; }

.welcome-inner p {
  margin: 4px 0 0;
  color: #8b949e;
  font-size: 0.8rem;
  line-height: 1.4;
}

.welcome-icon { font-size: 1.5rem; flex-shrink: 0; }

.welcome-inner button {
  background: none;
  border: none;
  color: #6e7681;
  cursor: pointer;
  font-size: 1rem;
  margin-left: auto;
  flex-shrink: 0;
}

.welcome-inner button:hover { color: #e1e4e8; }

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Alert settings button */
.alert-settings-btn {
  background: none;
  border: 1px solid #2d333b;
  color: #8b949e;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.alert-settings-btn:hover { border-color: #58a6ff; color: #58a6ff; }

.alert-settings-btn svg { flex-shrink: 0; }

/* Alert settings modal */
.alert-modal-content {
  max-width: 460px;
}

.alert-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.alert-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-field label {
  font-size: 0.85rem;
  color: #e1e4e8;
  font-weight: 500;
}

.alert-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
}

.alert-field select option:disabled {
  color: #484f58;
}

.alert-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #2d333b;
  outline: none;
}

.alert-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #238636;
  cursor: pointer;
  border: 2px solid #0f1114;
}

.alert-field input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #238636;
  cursor: pointer;
  border: 2px solid #0f1114;
}

.alert-hint {
  font-size: 0.75rem;
  color: #6e7681;
  line-height: 1.4;
}

.alert-pro-hint {
  font-size: 0.75rem;
  color: #d29922;
  line-height: 1.4;
}

.alert-pro-hint a { color: #d29922; }
.alert-pro-hint a:hover { color: #e3b341; }

.alert-toggle-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #2d333b;
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #e1e4e8;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #238636;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.alert-save-btn {
  background: #238636;
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.alert-save-btn:hover { background: #2ea043; }

/* Upgrade button in auth bar */
.auth-upgrade {
  background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
  color: #fff !important;
  border-color: #238636 !important;
  font-weight: 600;
}

.auth-upgrade:hover { background: linear-gradient(135deg, #2ea043 0%, #3fb950 100%); }

/* Upgrade Modal */
.upgrade-modal-content {
  max-width: 480px;
  text-align: center;
}

.upgrade-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}

.upgrade-icon {
  font-size: 1.5rem;
}

.upgrade-comparison {
  text-align: left;
  margin: 20px 0;
}

.upgrade-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrade-feature {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: #e1e4e8;
  line-height: 1.4;
}

.upgrade-check {
  color: #3fb950;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.upgrade-price {
  margin: 20px 0 4px;
}

.upgrade-amount {
  font-size: 2.5rem;
  font-weight: 700;
  color: #f0f3f6;
}

.upgrade-period {
  font-size: 1rem;
  color: #8b949e;
}

.upgrade-note {
  font-size: 0.78rem;
  color: #6e7681;
  margin-bottom: 20px;
}

.upgrade-cta {
  width: 100%;
  padding: 14px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 10px;
  background: linear-gradient(135deg, #238636 0%, #2ea043 100%);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.upgrade-cta:hover { background: linear-gradient(135deg, #2ea043 0%, #3fb950 100%); transform: translateY(-1px); }
.upgrade-cta:disabled { background: #2d333b; cursor: wait; transform: none; }

/* CSV export button */
.export-csv-btn {
  background: #0d1117;
  border: 1px solid #2d333b;
  color: #8b949e;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.export-csv-btn:hover { border-color: #58a6ff; color: #58a6ff; }
