/* ============================================================
   Habitat Lot Tracker — UI Styles
   Blue/white palette matching the email digest
   ============================================================ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #212121;
  line-height: 1.5;
}

/* ── Site Header ── */
.site-header {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
  color: #fff;
  padding: 0 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

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

.logo-icon { font-size: 28px; }

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .3px;
}

.header-sub {
  font-size: 12px;
  opacity: .75;
}

.header-nav { display: flex; gap: 8px; }

/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-error   { background: #ffebee; border-left: 4px solid #c62828; color: #b71c1c; }
.alert-info    { background: #e3f2fd; border-left: 4px solid #1565c0; color: #0d47a1; }
.alert-stale   { background: #fff8e1; border-left: 4px solid #f9a825; color: #795548; }

.alert a { color: inherit; font-weight: 600; }

/* ── Card ── */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
  padding: 28px 32px;
  margin-bottom: 24px;
}

.card-title { font-size: 18px; font-weight: 700; color: #1565c0; margin-bottom: 8px; }
.card-desc  { color: #555; margin-bottom: 20px; }

/* ── Search Form ── */
.search-card { max-width: 680px; }

.form-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #333;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #bbb;
  border-radius: 5px;
  font-size: 14px;
  background: #fafafa;
  transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #1565c0;
  background: #fff;
}

.hint {
  font-weight: 400;
  font-size: 11px;
  color: #888;
}

/* Advanced filters */
.advanced-filters {
  background: #f5f7fa;
  border: 1px solid #dde;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.advanced-filters summary {
  font-weight: 600;
  font-size: 13px;
  color: #1565c0;
  cursor: pointer;
  user-select: none;
}

/* Form actions */
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background .15s, box-shadow .15s;
}

.btn-primary {
  background: #1565c0;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.btn-primary:hover { background: #0d47a1; }
.btn-primary:disabled { background: #90a4ae; cursor: not-allowed; }

.btn-secondary {
  background: #eceff1;
  color: #37474f;
  border: 1px solid #cfd8dc;
}
.btn-secondary:hover { background: #cfd8dc; }

.btn-outline {
  background: transparent;
  color: #1565c0;
  border: 1px solid #1565c0;
}
.btn-outline:hover { background: #e3f2fd; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Spinner state */
.btn-spinner { display: none; }
.btn--loading .btn-label  { display: none; }
.btn--loading .btn-spinner { display: inline; }

/* ── How It Works ── */
.how-it-works {
  background: #fff;
  border-radius: 8px;
  padding: 20px 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  max-width: 680px;
}
.how-it-works h3 { font-size: 14px; font-weight: 700; color: #555; margin-bottom: 10px; }
.how-it-works ol { padding-left: 18px; color: #555; line-height: 1.8; font-size: 13px; }

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  background: #1565c0;
  color: #fff;
  border-radius: 8px;
  padding: 20px 28px;
  margin-bottom: 20px;
}

.stat-item { text-align: center; flex: 1; min-width: 80px; }
.stat-value { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { display: block; font-size: 11px; opacity: .8; margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }

.run-meta {
  font-size: 12px;
  color: #777;
  margin-bottom: 24px;
}

/* ── Sections ── */
.section { margin-bottom: 36px; }

.section-title {
  font-size: 17px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 6px 6px 0 0;
  margin-bottom: 16px;
  border-bottom: 3px solid transparent;
}

.section-title--green  { background: #e8f5e9; color: #1b5e20; border-color: #388e3c; }
.section-title--blue   { background: #e3f2fd; color: #0d47a1; border-color: #1565c0; }
.section-title--purple { background: #ede7f6; color: #4527a0; border-color: #7b1fa2; }

.section-desc { font-size: 13px; color: #666; margin: -8px 0 12px; }

.count-badge {
  display: inline-block;
  background: rgba(0,0,0,.12);
  color: inherit;
  border-radius: 12px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}

/* ── AI Top Picks ── */
.top-picks-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.top-pick-card {
  flex: 1;
  min-width: 240px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #c8e6c9;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  padding: 16px;
}

.top-pick-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.pick-rank-circle {
  background: #1565c0;
  color: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  min-width: 28px;
  line-height: 28px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.pick-meta { flex: 1; }
.pick-address { font-weight: 600; font-size: 13px; }
.pick-id { font-size: 11px; color: #888; }
.pick-id a { color: #1565c0; text-decoration: none; }

.ai-score-badge {
  background: #2e7d32;
  color: #fff;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.ai-score-badge.score-10, .ai-score-badge.score-9 { background: #1b5e20; }
.ai-score-badge.score-8,  .ai-score-badge.score-7 { background: #2e7d32; }
.ai-score-badge.score-6,  .ai-score-badge.score-5 { background: #f57f17; }
.ai-score-badge.score-4,  .ai-score-badge.score-3, .ai-score-badge.score-2, .ai-score-badge.score-1 { background: #b71c1c; }

.pick-summary {
  font-size: 12px;
  color: #444;
  margin-bottom: 10px;
  line-height: 1.5;
}

.pick-details { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.detail-chip {
  background: #e3f2fd;
  color: #0d47a1;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.detail-chip.zoning  { background: #f3e5f5; color: #4a148c; }
.detail-chip.owner-type { background: #e8f5e9; color: #1b5e20; }

.pick-pros {
  padding-left: 16px;
  font-size: 12px;
  color: #444;
  line-height: 1.7;
}

/* ── Map ── */
.map-container {
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  text-align: center;
}

.parcel-map {
  max-width: 100%;
  border-radius: 4px;
  border: 1px solid #ddd;
  display: block;
  margin: 0 auto;
}

/* ── Tables ── */
.table-scroll {
  overflow-x: auto;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.parcel-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

.parcel-table thead th {
  background: #1565c0;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.section-title--purple ~ .table-scroll .parcel-table thead th {
  background: #6a1b9a;
}

.parcel-table tbody tr { border-bottom: 1px solid #eee; }
.parcel-table tbody tr:hover { background: #f5f7ff; }
.parcel-table tbody td { padding: 8px 12px; vertical-align: middle; }

.td-rank { width: 40px; text-align: center; }
.td-pid  { white-space: nowrap; font-size: 11px; }
.td-addr { min-width: 180px; }
.td-num  { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.td-owner { max-width: 160px; }
.td-zoning { white-space: nowrap; }
.td-ai { white-space: nowrap; text-align: center; }

.rank-circle {
  display: inline-block;
  background: #1565c0;
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.rank-circle:hover { background: #0d47a1; }

.parcel-id-link {
  color: #1565c0;
  text-decoration: none;
  font-size: 11px;
}
.parcel-id-link:hover { text-decoration: underline; }

/* ── Badges ── */
.badge {
  display: inline-block;
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.badge-owner   { background: #e8f5e9; color: #1b5e20; }
.badge-zoning  { background: #ede7f6; color: #4527a0; }
.badge-infill  { background: #e3f2fd; color: #0d47a1; }
.badge-cluster { background: #f3e5f5; color: #6a1b9a; }

.badge-strong      { background: #1b5e20; color: #fff; }
.badge-investigate { background: #e65100; color: #fff; }
.badge-pass        { background: #607d8b; color: #fff; }

/* ── Export bar ── */
.export-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid #dde;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #777;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .container  { padding: 0 12px; margin: 16px auto; }
  .card       { padding: 20px 16px; }
  .stats-bar  { padding: 16px; }
  .stat-value { font-size: 20px; }
  .top-picks-grid { flex-direction: column; }
  .parcel-table { font-size: 12px; }
  .parcel-table thead th,
  .parcel-table tbody td { padding: 6px 8px; }
}
