/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
}
a { color: inherit; text-decoration: none; }

/* ── Site header ──────────────────────────────────────────────── */
.site-header {
  background: #1f2937;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.header-brand a { color: #fff; }
.header-nav { display: flex; gap: 20px; align-items: center; }
.header-nav a {
  font-size: 13px;
  color: #9ca3af;
  transition: color .15s;
  display: flex;
  align-items: center;
}
.header-nav a:hover { color: #fff; }
.header-user-email {
  font-size: 12px;
  color: #6b7280;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-info-btn {
  background: none;
  border: 1.5px solid #6b7280;
  color: #9ca3af;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color .15s, color .15s;
}
.header-info-btn:hover { border-color: #fff; color: #fff; }

/* ── Hamburger toggle (mobile only) ──────────────────────────── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
  width: 32px;
  height: 32px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #9ca3af;
  border-radius: 2px;
  transition: background .15s;
}
.nav-toggle:hover span { background: #fff; }

@media (max-width: 640px) {
  .header-inner {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding: 0 16px;
    gap: 0;
  }
  .header-brand {
    height: 48px;
    display: flex;
    align-items: center;
    flex: 1;
  }
  .nav-toggle { display: flex; }
  .header-nav {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    width: 100%;
    border-top: 1px solid #374151;
    padding: 6px 0 10px;
  }
  .header-nav.open { display: flex; }
  .header-nav a,
  .header-nav .header-user-email {
    padding: 9px 2px;
    width: 100%;
    border-bottom: 1px solid rgba(255,255,255,.05);
  }
  .header-nav .header-info-btn {
    margin: 9px 0;
  }
  .header-nav .btn-ghost,
  .header-nav .btn-sm {
    margin: 8px 0 2px;
    width: 100%;
    justify-content: center;
  }
  .header-user-email {
    max-width: 100%;
  }
}

/* ── Info dialog ─────────────────────────────────────────────── */
#info-dialog { max-width: 480px; }
.info-section { margin-bottom: 16px; }
.info-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  margin: 0 0 4px;
}
.info-section p {
  font-size: 12.5px;
  color: #6b7280;
  margin: 0 0 8px;
  line-height: 1.5;
}
.info-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-size: 12.5px;
  margin: 0;
}
.info-dl dt { color: #6b7280; font-weight: 600; }
.info-dl dd { color: #111827; margin: 0; }
.info-warning {
  background: #fef3c7;
  border-radius: 6px;
  padding: 10px 12px;
}
.info-warning h4 { color: #92400e; }
.info-warning p { color: #78350f; }

/* ── Rate-limit warning banner ───────────────────────────────── */
.rate-limit-banner {
  max-width: 860px;
  margin: 8px auto 0;
  padding: 8px 14px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 13px;
  color: #92400e;
}

/* ── Toolbar (feed page) ─────────────────────────────────────── */
.toolbar {
  max-width: 860px;
  margin: 12px auto 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.status-text { font-size: 12px; color: #6b7280; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Location toggle ─────────────────────────────────────────── */
.loc-toggle { display: flex; gap: 4px; }
.loc-btn {
  padding: 5px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.loc-btn--mesa.active  { background: #2563eb; border-color: #2563eb; color: #fff; }
.loc-btn--phoenix.active { background: #d97706; border-color: #d97706; color: #fff; }

/* ── Sort select ─────────────────────────────────────────────── */
.sort-select {
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  background: #fff;
  cursor: pointer;
}

/* ── Feed search bar ─────────────────────────────────────────── */
.feed-search {
  max-width: 860px;
  margin: 8px auto 0;
  padding: 0 16px;
}
.feed-search input {
  width: 100%;
  max-width: 320px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #1f2937;
}
.feed-search input:focus { outline: none; border-color: #2563eb; }

/* ── Bid filter ──────────────────────────────────────────────── */
.bid-filter {
  max-width: 860px;
  margin: 8px auto 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.bid-filter-label { font-size: 12px; color: #6b7280; white-space: nowrap; min-width: 100px; }
.bid-filter-slider { flex: 1; accent-color: #2563eb; cursor: pointer; }

/* ── Feed tabs ───────────────────────────────────────────────── */
.feed-tabs {
  max-width: 860px;
  margin: 10px auto 0;
  padding: 0 16px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.feed-tabs::-webkit-scrollbar { display: none; }
.feed-tabs .tab-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: #374151;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.feed-tabs .tab-btn:hover { background: #f9fafb; }
.feed-tabs .tab-btn.active {
  background: #1f2937;
  color: #fff;
  border-color: #1f2937;
}
.tab-count { font-weight: 400; opacity: .75; font-size: 12px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost {
  background: #fff;
  color: #374151;
  border-color: #d1d5db;
}
.btn-ghost:hover { background: #f9fafb; }
.btn-ghost[aria-pressed="true"] {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger {
  background: #fff;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

.badge {
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Feed container ──────────────────────────────────────────── */
.feed-container {
  max-width: 860px;
  margin: 12px auto 40px;
  padding: 0 16px;
}

/* ── Category group ──────────────────────────────────────────── */
.category-group { margin-bottom: 28px; }
.category-header {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 10px 0 6px;
  border-top: 2px solid #d1d5db;
  margin-bottom: 10px;
}
.category-header:first-of-type { border-top: none; }
.category-meta {
  font-weight: 400;
  font-size: 11px;
  color: #9ca3af;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Label section ───────────────────────────────────────────── */
.label-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  align-items: start;
}
.label-header {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 5px 12px;
  background: #e5e7eb;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.label-header--paused { opacity: 0.55; font-style: italic; border-radius: 4px; }
.label-pause-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
  cursor: pointer;
  padding: 2px 7px;
  opacity: 0;
  transition: opacity .15s, background .12s;
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: 0;
}
.label-header-btns { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.label-section:hover .label-pause-btn { opacity: 1; }
.label-section:hover .label-negkw-btn { opacity: 1; }
.label-pause-btn:hover { background: #f3f4f6; color: #374151; border-color: #9ca3af; }
.label-negkw-btn {
  background: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  color: #9ca3af;
  cursor: pointer;
  padding: 1px 6px;
  opacity: 0;
  transition: opacity .15s, background .12s;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1;
}
.label-negkw-btn:hover { background: #f3f4f6; color: #374151; border-color: #9ca3af; }
.label-resume-btn {
  font-size: 10px;
  font-weight: 600;
  color: #374151;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  opacity: 1;
}

/* ── Item card ───────────────────────────────────────────────── */
.item-card {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow .15s;
}
.item-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.10); }

.item-image-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #e5e7eb;
  overflow: hidden;
}
.item-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.item-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: #e5e7eb;
}

.item-title {
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
  line-height: 1.4;
  display: block;
  padding: 10px 10px 6px;
}
.item-title:hover { text-decoration: underline; }
.item-meta {
  font-size: 11px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 6px 10px 10px;
}
.item-bid { color: #16a34a; font-weight: 700; }
.item-location-flag {
  font-size: 10px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border-radius: 3px;
  padding: 1px 5px;
}

.item-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
}
.heart-btn {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  cursor: pointer;
  color: #d1d5db;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, transform .1s;
}
.heart-btn:hover { color: #f87171; transform: scale(1.15); }
.heart-btn.active { color: #dc2626; }
.suggest-btn {
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 16px;
  color: #d1d5db;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.suggest-btn:hover { color: #374151; }

/* ── Item label tag (shown in flat sort mode) ────────────────── */
.item-label-tag {
  font-size: 10px;
  font-weight: 600;
  color: #6b7280;
  background: #e5e7eb;
  border-radius: 3px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.feed-container.grouped .item-label-tag { display: none; }

/* ── Hot Finds section heading ───────────────────────────────── */
.hot-finds-heading {
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .7px;
  padding: 8px 0 6px;
  border-top: 2px solid #d1d5db;
  margin: 16px 0 10px;
}
.hot-finds-heading:first-of-type { border-top: none; margin-top: 0; }

/* ── Flat sort section ───────────────────────────────────────── */
.flat-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-items: start;
}

/* ── Empty / loading states ──────────────────────────────────── */
.empty-state {
  text-align: center;
  color: #9ca3af;
  padding: 40px 16px;
  font-size: 14px;
}

/* ── Page content (watchlist / proposals) ────────────────────── */
.page-content {
  max-width: 860px;
  margin: 20px auto 40px;
  padding: 0 16px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-header h1 { margin: 0; font-size: 20px; }
.page-subtitle { margin: -10px 0 16px; color: #6b7280; font-size: 13px; }

/* ── Category tabs ───────────────────────────────────────────── */
.cat-tabs, .tab-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tab-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid #d1d5db;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
}
.tab-btn.active {
  background: #1f2937;
  color: #fff;
  border-color: #1f2937;
}

/* ── Watchlist table ─────────────────────────────────────────── */
.wl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.wl-table th {
  text-align: left;
  padding: 8px 10px;
  background: #f3f4f6;
  border-bottom: 2px solid #e5e7eb;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6b7280;
}
.wl-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}
.wl-table tr:hover td { background: #f9fafb; }
.wl-keyword { font-family: monospace; font-size: 12px; color: #374151; }
.wl-neg { font-size: 11px; color: #9ca3af; }
.wl-table tr.wl-disabled td { opacity: 0.45; }
.wl-table tr.wl-disabled .wl-toggle-btn { opacity: 1; }
.wl-options-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-actions-cell { white-space: nowrap; }

/* ── Watchlist search bar ────────────────────────────────────── */
.wl-search-bar { margin-bottom: 12px; }
.wl-search-bar input {
  width: 100%;
  max-width: 320px;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #1f2937;
}
.wl-search-bar input:focus { outline: none; border-color: #2563eb; }

/* ── Proposals list ──────────────────────────────────────────── */
.proposal-item {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.proposal-keyword {
  font-size: 14px;
  font-weight: 700;
  font-family: monospace;
  color: #1f2937;
}
.proposal-scope {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}
.proposal-source {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
  font-style: italic;
}
.proposal-meta { flex: 1; min-width: 0; }
.proposal-actions { display: flex; gap: 6px; flex-shrink: 0; }
.proposal-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}
.proposal-status.pending { background: #fef9c3; color: #854d0e; }
.proposal-status.accepted { background: #dcfce7; color: #166534; }
.proposal-status.rejected { background: #fee2e2; color: #991b1b; }

/* ── Card / form ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.form-card h3 { margin: 0 0 12px; font-size: 15px; }
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  flex: 1;
  min-width: 140px;
}
.form-label input,
.form-label select {
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
}
.form-label input:focus,
.form-label select:focus {
  outline: none;
  border-color: #2563eb;
}
.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── Suggest dialog ──────────────────────────────────────────── */
dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  max-width: 420px;
  width: 90vw;
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 24px; }
dialog h3 { margin: 0 0 16px; font-size: 16px; font-weight: 600; }
#negkw-input, #negkw-category { width: 100%; }
.suggest-source {
  font-size: 12px;
  color: #6b7280;
  margin: 0 0 12px;
  font-style: italic;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.chip.selected {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 600;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .label-section,
  .flat-section {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 540px) {
  /* Hide Category (col 2) and Options (col 3) on mobile, keep Keyword + Actions */
  .wl-table th:nth-child(2),
  .wl-table td:nth-child(2),
  .wl-table th:nth-child(3),
  .wl-table td:nth-child(3) { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .toolbar-actions { flex-wrap: wrap; }
}
