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

:root {
  --bg: #09090b;
  --text: #fafafa;
  --text-dim: #a1a1aa;
  --text-faint: #71717a;
  --text-fainter: #52525b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --surface: rgba(9, 9, 11, 0.78);
  --surface-solid: #09090b;
  --accent: #ff385c;
  --accent-soft: rgba(255, 56, 92, 0.12);

  /* light search + sheet */
  --s-bg: #ffffff;
  --s-text: #111827;
  --s-text-dim: #484848;
  --s-text-muted: #717171;
  --s-text-faint: #a8a8a8;
  --s-border: #dddddd;
  --s-border-light: #ebebeb;
  --s-surface: #f7f7f7;
}

html,
body {
  height: 100%;
}

body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
}

/* ==== Search bar (top center, Airbnb style) ==== */
.search-container {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  width: min(680px, calc(100vw - 48px));
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--s-bg);
  border: 1.5px solid var(--s-border);
  border-radius: 999px;
  padding: 14px 14px 14px 22px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 4px 16px rgba(0, 0, 0, 0.08);
  transition:
    box-shadow 0.18s,
    border-color 0.18s;
}

.search-bar:hover {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.1);
}

.search-bar.focus-within {
  border-color: #222222;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.1),
    0 0 0 3px rgba(34, 34, 34, 0.06);
}

.search-icon {
  color: var(--s-text-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--s-text);
  letter-spacing: -0.01em;
}

.search-input::placeholder {
  color: var(--s-text-faint);
  font-weight: 400;
}

.search-clear {
  background: var(--s-surface);
  border: none;
  color: var(--s-text-muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s;
}

.search-clear.visible {
  display: inline-flex;
}
.search-clear:hover {
  background: #ebebeb;
  color: var(--s-text);
}

/* ==== Sheet result cards (Airbnb style) ==== */
.drawer-results-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 24px;
  min-height: 0;
}

#drawerResultsList {
  column-count: 4;
  column-gap: 12px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 1200px) {
  #drawerResultsList {
    column-count: 3;
  }
}

@media (max-width: 860px) {
  #drawerResultsList {
    column-count: 2;
  }
}

@media (max-width: 560px) {
  #drawerResultsList {
    column-count: 1;
  }
}

.drawer-results-body::-webkit-scrollbar {
  width: 6px;
}
.drawer-results-body::-webkit-scrollbar-track {
  background: transparent;
}
.drawer-results-body::-webkit-scrollbar-thumb {
  background: #e0e0e0;
  border-radius: 3px;
}

.result-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 4px 14px rgba(0, 0, 0, 0.07);
  transition:
    box-shadow 0.18s,
    transform 0.18s;
  cursor: default;
  break-inside: avoid;
  margin-bottom: 12px;
}

.result-card:hover {
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.09),
    0 8px 28px rgba(0, 0, 0, 0.11);
  transform: translateY(-1px);
}

.result-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.result-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--s-text);
  letter-spacing: -0.015em;
  line-height: 1.3;
  flex: 1;
  text-transform: capitalize;
}

.result-score {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--s-text-faint);
  padding: 3px 7px;
  background: var(--s-surface);
  border: 1px solid var(--s-border-light);
  border-radius: 6px;
  flex-shrink: 0;
  font-weight: 500;
}

.result-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 9px;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.result-badge.prototype {
  background: #f3e8ff;
  color: #7c3aed;
}
.result-badge.validation {
  background: #dbeafe;
  color: #1d4ed8;
}
.result-badge.earlytraction {
  background: #fef3c7;
  color: #b45309;
}
.result-badge.scaling {
  background: #d1fae5;
  color: #047857;
}
.result-badge.default {
  background: var(--s-surface);
  color: var(--s-text-muted);
}

.result-industry {
  font-size: 12px;
  color: var(--s-text-muted);
}

.result-industry-sep {
  color: var(--s-text-faint);
  margin: 0 3px;
}

.result-address {
  font-size: 12px;
  color: var(--s-text-muted);
  margin-bottom: 9px;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.result-address svg {
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.45;
  color: var(--s-text-muted);
}

.result-description {
  font-size: 13px;
  color: var(--s-text-dim);
  line-height: 1.58;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--s-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s;
}

.result-link:hover {
  color: #e31c44;
}

.result-link.disabled {
  color: var(--s-text-faint);
  cursor: default;
  pointer-events: none;
  font-weight: 400;
}

.result-link svg {
  transition: transform 0.15s;
}
.result-link:hover svg {
  transform: translate(2px, -2px);
}

.result-sector-tag {
  font-size: 10.5px;
  color: var(--s-text-faint);
  font-family: "JetBrains Mono", monospace;
  background: var(--s-surface);
  padding: 2px 7px;
  border-radius: 999px;
}

.empty-state,
.loading-state,
.error-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--s-text-muted);
  font-size: 13px;
}

.empty-icon {
  font-size: 28px;
  margin-bottom: 10px;
  opacity: 0.35;
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}

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

/* ==== Sheet tab strip (lives inside header row) ==== */
.drawer-tabs {
  display: flex;
  gap: 4px;
  margin-left: auto;
  margin-right: 10px;
}

.drawer-tab {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--s-text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  transition:
    background 0.15s,
    color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.drawer-tab:hover {
  background: var(--s-surface);
  color: var(--s-text);
}

.drawer-tab.active {
  background: var(--s-text);
  color: #ffffff;
}

.drawer-tab-count {
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.18);
  padding: 1px 6px;
  border-radius: 999px;
}

.drawer-tab:not(.active) .drawer-tab-count {
  background: var(--s-border-light);
  color: var(--s-text-muted);
}

/* ==== Map legend (top right) ==== */
.map-legend {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1050;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  max-width: 220px;
}

.map-legend-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.map-legend-subtitle {
  font-size: 10.5px;
  color: var(--text-fainter);
  font-family: "JetBrains Mono", monospace;
  margin-top: 2px;
  margin-bottom: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 11px;
  margin-bottom: 4px;
}

.legend-row:last-child {
  margin-bottom: 0;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.full {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}
.legend-dot.fallback {
  background: #f97316;
  box-shadow: 0 0 6px rgba(249, 115, 22, 0.5);
}

/* ==== Chart FAB (bottom right) ==== */
.chart-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 1050;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 18px 11px 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition:
    background 0.18s,
    border-color 0.18s,
    transform 0.18s;
}

.chart-fab:hover {
  background: rgba(9, 9, 11, 0.92);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.chart-fab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(255, 56, 92, 0.6);
}

/* ==== Chart drawer (bottom slide-up, light theme) ==== */
.chart-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1080;
  background: #ffffff;
  color: #111;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chart-drawer.visible {
  transform: translateY(0);
}

.chart-drawer-handle {
  width: 36px;
  height: 4px;
  background: #d4d4d8;
  border-radius: 2px;
  margin: 10px auto 0;
}

.chart-drawer-header {
  padding: 14px 28px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e4e4e7;
}

.chart-drawer-title-block h2 {
  font-size: 16px;
  font-weight: 600;
  color: #111;
  letter-spacing: -0.02em;
}

.chart-drawer-title-block p {
  font-size: 11px;
  color: #71717a;
  font-family: "JetBrains Mono", monospace;
  margin-top: 2px;
}

.chart-drawer-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: #52525b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chart-drawer-close:hover {
  background: #f4f4f5;
  color: #111;
}

.chart-drawer-body {
  padding: 20px 28px 28px;
  display: flex;
  gap: 28px;
  overflow-y: auto;
  flex: 1;
}

.chart-area {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
}

.chart-canvas-wrap {
  background: #fafafa;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  padding: 18px 18px 12px;
}

.chart-note {
  font-size: 10.5px;
  color: #a1a1aa;
  margin-top: 10px;
  text-align: center;
  font-family: "JetBrains Mono", monospace;
}

.stats-area {
  flex: 1;
  min-width: 0;
}

.stats-title {
  font-size: 13px;
  font-weight: 600;
  color: #111;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stats-title-meta {
  font-size: 10.5px;
  color: #a1a1aa;
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 4px;
}

.stat-item {
  background: #f9f9f9;
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  transition: background 0.12s;
}

.stat-item:hover {
  background: #f4f4f5;
}

.stat-label {
  color: #52525b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.stat-value {
  color: #111;
  font-weight: 600;
  font-family: "JetBrains Mono", monospace;
  flex-shrink: 0;
}

/* ==== Leaflet popup ==== */
.leaflet-popup-content-wrapper {
  background: #fff;
  color: #111;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
}
.leaflet-popup-tip {
  background: #fff;
}
.popup-content {
  max-width: 280px;
  font-family: "Inter", system-ui, sans-serif;
}
.popup-content h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #111;
  line-height: 1.3;
}
.popup-content .address {
  margin: 0 0 6px;
  font-size: 11px;
  color: #555;
  line-height: 1.5;
}
.popup-content .meta {
  margin: 0;
  font-size: 10px;
  color: #888;
}

/* ==== Responsive ==== */
@media (max-width: 768px) {
  .search-container {
    width: calc(100vw - 32px);
    top: 14px;
  }
  .search-bar {
    padding: 12px 12px 12px 18px;
  }
  .search-input {
    font-size: 14px;
  }
  .map-legend {
    top: auto;
    bottom: 78px;
    right: 14px;
    max-width: 180px;
  }
  .chart-fab {
    bottom: 14px;
    right: 14px;
    padding: 10px 14px 10px 12px;
    font-size: 12px;
  }
  .chart-drawer-body {
    flex-direction: column;
    padding: 16px;
    gap: 16px;
  }
  .chart-area {
    flex: none;
  }
  .stats-grid {
    grid-template-columns: repeat(
      auto-fill,
      minmax(150px, 1fr)
    );
  }
  .drawer-results-body {
    padding: 12px 14px 20px;
  }
  .result-card {
    padding: 14px 16px;
  }
}
