/* Site Analysis - Global Styles */

/* Dark theme (default) */
:root {
  --bg-primary: #0c1524;
  --bg-secondary: #111b2f;
  --bg-tertiary: #1a2744;
  --border-color: #2a3f5f;
  --text-primary: #e8edf7;
  --text-secondary: #9fb1d0;
  --text-muted: #6b7d9a;
  --accent: #4f8bff;
  --accent-hover: #2f6fe6;
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --height-low: #93c5fd;
  --height-medium: #3b82f6;
  --height-high: #1d4ed8;
  --height-very-high: #1e3a8a;
  --sidebar-bg: rgba(17, 27, 47, 0.88);
  --section-bg: rgba(26, 39, 68, 0.6);
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #ca8a04;
  --error: #dc2626;
  --height-low: #bfdbfe;
  --height-medium: #60a5fa;
  --height-high: #3b82f6;
  --height-very-high: #2563eb;
  --sidebar-bg: rgba(255, 255, 255, 0.92);
  --section-bg: rgba(241, 245, 249, 0.8);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* Layout */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.map-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100vh;
}

#map {
  width: 100%;
  height: 100%;
}

/* Floating Frosted Glass Sidebar (Desktop) */
.sidebar {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 380px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

/* Step Indicator */
.step-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  position: relative;
}

/* Theme Toggle */
.theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 6px;
}

.step.upcoming .step-circle {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-muted);
}

.step.current .step-circle {
  background: var(--accent);
  border: 2px solid var(--accent);
  color: white;
  box-shadow: 0 0 0 4px rgba(79, 139, 255, 0.2);
}

.step.completed .step-circle {
  background: var(--success);
  border: 2px solid var(--success);
  color: white;
}

.step-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.step.current .step-label {
  color: var(--accent);
}

.step.completed .step-label {
  color: var(--success);
}

.step.disabled {
  opacity: 0.4;
}

.step:not(.disabled):hover .step-circle {
  transform: scale(1.1);
}

.step:not(.disabled):hover .step-label {
  color: var(--text-primary);
}

/* Step connector lines */
.step-connector {
  position: absolute;
  top: 14px;
  left: calc(50% + 20px);
  width: calc(100% - 12px);
  height: 2px;
  background: var(--border-color);
}

.step:last-child .step-connector {
  display: none;
}

.step.completed .step-connector {
  background: var(--success);
}

/* Header (now smaller, below stepper) */
.sidebar-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
}

.tab {
  flex: 1;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Panel */
.panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.panel-section {
  margin-bottom: 12px;
}

/* Section cards with clear backgrounds - HIGH CONTRAST */
.panel-section.section-card {
  background: rgba(18, 28, 46, 0.98);
  border: 1px solid rgba(79, 139, 255, 0.4);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Building Envelope Section - BLUE TINT */
.panel-section.envelope-section {
  background: rgba(20, 30, 58, 0.98);
  border: 1px solid rgba(79, 139, 255, 0.5);
  box-shadow: 0 6px 20px rgba(79, 139, 255, 0.15);
}

/* Plot Analysis Section - GREEN TINT */
.panel-section.plot-section {
  background: rgba(15, 36, 30, 0.98);
  border: 1px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.15);
}

/* Light theme section cards - HIGH CONTRAST */
[data-theme="light"] .panel-section.section-card {
  background: rgba(232, 238, 247, 1);
  border: 1px solid rgba(37, 99, 235, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Building Envelope Section - BLUE TINT (Light) */
[data-theme="light"] .panel-section.envelope-section {
  background: rgba(224, 236, 255, 1);
  border: 1px solid rgba(37, 99, 235, 0.4);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
}

/* Ensure envelope section text is dark enough in light mode */
[data-theme="light"] .panel-section.envelope-section .section-header p,
[data-theme="light"] .panel-section.envelope-section .stat-label,
[data-theme="light"] .panel-section.envelope-section {
  color: #0f172a;
}

[data-theme="light"] .panel-section.envelope-section .stat-label {
  color: #475569;
}

/* Plot Analysis Section - GREEN TINT (Light) */
[data-theme="light"] .panel-section.plot-section {
  background: rgba(220, 252, 231, 1);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12);
}

/* Ensure plot section text is dark enough in light mode */
[data-theme="light"] .panel-section.plot-section .section-header p,
[data-theme="light"] .panel-section.plot-section .stat-label,
[data-theme="light"] .panel-section.plot-section {
  color: #0f172a;
}

[data-theme="light"] .panel-section.plot-section .stat-label {
  color: #475569;
}

.panel-section.section-card + .panel-section.section-card {
  margin-top: 12px;
}

.panel-section h2 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.panel-section h3 {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

/* Info box */
.info-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.info-box.warning {
  border-color: var(--warning);
  background: rgba(234, 179, 8, 0.1);
}

.info-box.error {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
}

.stat-card.highlight {
  background: rgba(79, 139, 255, 0.08);
  border-color: rgba(79, 139, 255, 0.3);
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
}

.stat-value.small {
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

/* Form elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.slider-value {
  min-width: 50px;
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Compact controls row */
.compact-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-compact {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-compact .slider {
  flex: 1;
}

.slider-value-compact {
  min-width: 45px;
  text-align: right;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.btn-compact {
  width: 40px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Location display */
.location-display {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.location-label {
  color: var(--text-muted);
}

.location-coords {
  color: var(--text-secondary);
  font-family: monospace;
}

/* Results section */
.results-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}

.results-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.result-row:last-child {
  border-bottom: none;
}

.result-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.result-value {
  font-size: 13px;
  font-weight: 500;
}

/* Confidence badge */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.confidence-badge.high {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.confidence-badge.medium {
  background: rgba(234, 179, 8, 0.2);
  color: var(--warning);
}

.confidence-badge.low {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
}

/* Progress bar */
.progress-container {
  margin-top: 8px;
}

.progress-bar {
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

.toast.info {
  border-color: var(--accent);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 21, 36, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* Light mode loading overlay */
[data-theme="light"] .loading-overlay {
  background: rgba(248, 250, 252, 0.85);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Map controls */
.map-overlay {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
}

.site-info-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.site-info-card .label {
  color: var(--text-muted);
  margin-bottom: 4px;
}

.site-info-card .value {
  font-weight: 500;
}

/* Grid preview on map */
.grid-preview {
  stroke: white;
  stroke-width: 2;
  stroke-dasharray: 6, 4;
  fill: none;
}

/* MapLibre popup styling */
.maplibregl-popup-content {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px !important;
  padding: 12px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* Light mode popup - lighter shadow */
[data-theme="light"] .maplibregl-popup-content {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12) !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--bg-secondary) !important;
}

.popup-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}

.popup-row .label {
  color: var(--text-muted);
}

/* Recovery modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px 14px;
  overflow: auto;
}

/* Light mode modal overlay */
[data-theme="light"] .modal-overlay {
  background: rgba(15, 23, 42, 0.5);
}

/* Welcome modal */
.welcome-modal {
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
}

.welcome-modal-media {
  margin: 10px 0 12px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  max-height: 45vh;
}

.welcome-modal-gif {
  display: block;
  width: 100%;
  height: auto;
  max-height: 45vh;
  object-fit: contain;
}

.welcome-modal-links {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-tertiary);
}

.welcome-modal-links-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.welcome-modal-links-list {
  margin: 0;
  padding-left: 16px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.welcome-modal-links-list a {
  color: var(--accent);
  text-decoration: none;
}

.welcome-modal-links-list a:hover {
  text-decoration: underline;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn {
  flex: 1;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
}

/* Floating Search Bar */
.floating-search {
  position: absolute;
  top: 16px;
  left: calc(50% + 200px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 8px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Top overlay (Search + LinkedIn + data sources bar) */
.top-overlay {
  position: absolute;
  top: 16px;
  left: calc(50% + 200px);
  transform: translateX(-50%);
  z-index: 60;
  width: min(560px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top-overlay-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 8px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.top-overlay-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
}

.top-overlay-input::placeholder {
  color: var(--text-muted);
}

.top-overlay-btn,
.top-overlay-linkedin-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.top-overlay-btn {
  background: var(--accent);
  color: white;
}

.top-overlay-btn:hover {
  background: var(--accent-hover);
}

.top-overlay-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.top-overlay-linkedin-btn {
  background: rgba(0, 119, 181, 0.12);
  color: #0077b5;
  border: 1px solid rgba(0, 119, 181, 0.25);
}

.top-overlay-linkedin-btn:hover {
  background: #0077b5;
  color: white;
  border-color: #0077b5;
  transform: translateY(-1px);
}

.top-overlay-subrow {
  display: flex;
  justify-content: center;
}

.data-pill {
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.22);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme="light"] .data-pill {
  background: rgba(248, 250, 252, 0.75);
  border-color: rgba(148, 163, 184, 0.28);
  color: rgba(15, 23, 42, 0.72);
}

.data-pill:hover {
  color: var(--text-primary);
  border-color: rgba(148, 163, 184, 0.35);
  transform: translateY(-1px);
}

/* Popover backdrop + LinkedIn popover */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: transparent; /* click-anywhere-to-close without dimming */
}

.linkedin-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 70;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.data-popover {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 8px);
  z-index: 70;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.data-popover-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.data-popover-item {
  padding: 10px 10px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.data-popover-label {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.data-popover-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.data-popover-meta a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.data-popover-meta a:hover {
  color: var(--text-primary);
}

.popover-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.popover-close:hover {
  color: var(--text-primary);
  border-color: rgba(148, 163, 184, 0.35);
}

.linkedin-popover-title {
  font-weight: 700;
  font-size: 13px;
  margin-right: 34px; /* space for X */
  margin-bottom: 8px;
}

.linkedin-popover-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.linkedin-popover-actions {
  display: flex;
}

.floating-search-input {
  width: 180px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
}

.floating-search-input::placeholder {
  color: var(--text-muted);
}

.floating-search-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.floating-search-btn:hover {
  background: var(--accent-hover);
}

.floating-search-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.search-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* LinkedIn Link - responsive */
.linkedin-link {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 12px 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: #0077b5;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  white-space: nowrap;
}

.linkedin-link:hover,
.linkedin-link.expanded {
  background: #0077b5;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 119, 181, 0.3);
}

.linkedin-icon {
  flex-shrink: 0;
}

.linkedin-text {
  display: inline;
  opacity: 1;
  max-width: 400px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile: circular button, expands on click */
@media (max-width: 768px) {
  .top-overlay {
    left: 50%;
    width: calc(100vw - 24px);
  }

  .top-overlay-row {
    border-radius: 16px;
  }

  .linkedin-popover {
    right: 0;
    left: 0;
    width: auto;
  }

  .data-popover {
    left: 50%;
    transform: translateX(-50%);
    width: auto;
  }

  .linkedin-link {
    top: 22px;
    right: auto;
    left: calc(50% + 140px);
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    max-width: 36px;
  }

  .linkedin-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
  }

  .linkedin-link.expanded {
    width: auto;
    max-width: calc(100vw - 32px);
    border-radius: 20px;
    padding: 8px 14px;
  }

  .linkedin-link.expanded .linkedin-text {
    opacity: 1;
    max-width: 300px;
    margin-left: 6px;
  }
}

/* Data Attribution - info icon */
.data-attribution {
  position: absolute;
  top: 16px;
  right: 60px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  white-space: nowrap;
}

.data-attribution:hover,
.data-attribution.expanded {
  background: var(--bg-secondary);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.attribution-icon {
  flex-shrink: 0;
  color: var(--accent);
}

.attribution-content {
  display: block;
  opacity: 1;
  max-width: 350px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.4;
}

/* Mobile: circular button, expands on click */
@media (max-width: 768px) {
  .data-attribution {
    top: 22px;
    right: auto;
    left: calc(50% + 185px);
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    max-width: 36px;
  }

  .attribution-content {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
  }

  .data-attribution.expanded {
    width: auto;
    max-width: calc(100vw - 32px);
    border-radius: 12px;
    padding: 10px 14px;
    left: 16px;
    right: 16px;
  }

  .data-attribution.expanded .attribution-content {
    opacity: 1;
    max-width: 300px;
    margin-left: 8px;
  }
}

/* Map Data Legend - bottom left */
.map-legend {
  position: absolute;
  bottom: 24px;
  left: 16px;
  z-index: 50;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.map-legend-title {
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

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

.map-legend-box {
  width: 20px;
  height: 12px;
  border-radius: 2px;
  border: 2px solid;
}

.map-legend-box.osm {
  background: transparent;
  border-color: #3b82f6;
}

.map-legend-box.tum {
  background: transparent;
  border-color: #8b5cf6;
}

.map-legend-box.merged {
  background: transparent;
  border-color: #ffffff;
}

[data-theme="light"] .map-legend-box.merged {
  border-color: #64748b;
}

/* Instruction overlay - below search bar (accounts for left sidebar) */
.instruction-overlay {
  position: absolute;
  /* Below the top overlay (search + data pill) */
  top: 110px;
  left: calc(50% + 200px); /* Offset for 380px sidebar on left */
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
}

/* On mobile, center horizontally */
@media (max-width: 768px) {
  .instruction-overlay {
    left: 50%;
    top: 110px;
  }
}

.instruction-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(17, 27, 47, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  font-size: 13px;
}

/* Light mode instruction card */
[data-theme="light"] .instruction-card {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.instruction-card .instruction-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.instruction-card .instruction-icon svg {
  width: 18px;
  height: 18px;
}

.instruction-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.instruction-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.instruction-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Floating results card */
.results-card {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(17, 27, 47, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  min-width: 360px;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.results-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 8px;
}

.results-card-tabs {
  display: flex;
  gap: 4px;
}

.results-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.results-tab:hover:not(:disabled) {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.results-tab.active {
  color: var(--accent);
  background: var(--bg-tertiary);
}

.results-tab:disabled {
  cursor: not-allowed;
}

.results-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.draw-plot-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #10b981;
  border: none;
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.draw-plot-btn:hover {
  background: #059669;
}

.finish-plot-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #10b981;
  border: none;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.results-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.results-card-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.results-card-dismiss:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.results-card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.results-card-metric {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 12px;
}

.results-card-metric-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.results-card-metric-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}

.results-card-confidence {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
}

/* Percentile Chart */
.percentile-chart {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
}

.percentile-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.percentile-chart-max {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.percentile-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.percentile-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.percentile-label {
  width: 32px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.percentile-label.quartile {
  color: var(--accent);
}

.percentile-label.median {
  color: var(--text-primary);
  font-weight: 600;
}

.percentile-bar-container {
  flex: 1;
  height: 18px;
  background: var(--bg-secondary);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.percentile-highlight-zone {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(79, 139, 255, 0.1);
  border-left: 1px dashed var(--accent);
  border-right: 1px dashed var(--accent);
  pointer-events: none;
}

.percentile-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.percentile-bar.outer {
  background: linear-gradient(90deg, var(--bg-tertiary), #64748b);
}

.percentile-bar.quartile {
  background: linear-gradient(90deg, var(--accent), #6ba3ff);
}

.percentile-bar.median {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.percentile-value {
  width: 48px;
  text-align: right;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.percentile-value.quartile {
  color: var(--accent);
}

.percentile-value.median {
  color: #22c55e;
  font-weight: 600;
}

.percentile-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.percentile-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.percentile-legend-marker {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.percentile-legend-marker.quartile {
  background: var(--accent);
}

.percentile-legend-marker.median {
  background: #22c55e;
}

/* Plot drawing styles */
.plot-controls {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.plot-button {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plot-card {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(17, 27, 47, 0.95);
  border: 2px solid #10b981;
  border-radius: 12px;
  padding: 20px;
  min-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
}

.plot-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.plot-card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: #10b981;
}

/* Minimized results indicator */
.results-minimized {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(17, 27, 47, 0.95);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.results-minimized:hover {
  background: var(--bg-tertiary);
}

.results-minimized span {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* Drawer handle - hidden on desktop */
.drawer-handle {
  display: none;
}

/* Mobile Bottom Sheet */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
    position: relative;
  }

  .map-container {
    flex: 1;
    height: 100vh;
    position: relative;
  }

  /* Sidebar becomes bottom sheet */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 85vh;
    border-left: none;
    border-top: 1px solid var(--border-color);
    border-radius: 16px 16px 0 0;
    z-index: 100;
    transition: transform 0.3s ease-out;
    /* Collapsed: show handle + nav + primary action (Load & Analyze) */
    transform: translateY(calc(100% - 220px));
  }

  .sidebar.drawer-half {
    transform: translateY(50%);
  }

  .sidebar.drawer-full {
    transform: translateY(0);
  }

  /* Drawer handle */
  .drawer-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px 8px;
    cursor: grab;
    touch-action: none;
  }

  .drawer-handle:active {
    cursor: grabbing;
  }

  .drawer-handle-bar {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-bottom: 8px;
  }

  .drawer-handle-text {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* Mobile panel navigation */
  .mobile-panel-nav {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid var(--border-color);
  }

  .mobile-panel-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-panel-btn.active {
    background: rgba(79, 139, 255, 0.15);
    border-color: var(--accent);
    color: var(--accent);
  }

  .mobile-panel-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }

  .mobile-panel-btn:not(:disabled):active {
    transform: scale(0.95);
  }

  .mobile-panel-icon {
    font-size: 16px;
    line-height: 1;
  }

  .mobile-panel-label {
    font-size: 10px;
    line-height: 1;
  }

  /* Hide regular header and step indicator on mobile, use drawer handle instead */
  .sidebar-header,
  .step-indicator {
    display: none;
  }

  /* Tabs take full width */
  .tabs {
    padding: 0 8px;
  }

  .tab {
    padding: 14px 12px;
    font-size: 14px;
    min-height: 48px; /* Touch target */
  }

  /* Panel content */
  .panel {
    padding: 16px;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Buttons touch-friendly */
  .btn {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 14px;
  }

  /* Form inputs touch-friendly */
  .form-input {
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px; /* Prevents iOS zoom */
  }

  /* Slider touch-friendly */
  .slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .slider {
    height: 6px;
  }

  /* Hide floating results card on mobile - content merged into sidebar */
  .results-card,
  .results-minimized {
    display: none;
  }

  /* Floating search on mobile */
  .floating-search {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    margin-left: 0;
    width: calc(100vw - 24px);
    max-width: 320px;
  }

  .floating-search-input {
    flex: 1;
    width: auto;
  }

  /* Instruction overlay below search on mobile */
  .instruction-overlay {
    /* Keep this below the top overlay (search + data pill) */
    top: 110px;
    left: 50%;
    transform: translateX(-50%);
  }

  .instruction-overlay.initial {
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .instruction-card.initial {
    padding: 24px 32px;
  }

  .instruction-card.initial .instruction-text {
    font-size: 16px;
  }

  .instruction-card {
    padding: 10px 16px;
    max-width: calc(100vw - 32px);
  }

  .instruction-text {
    font-size: 13px;
    white-space: normal;
  }

  /* Stats grid single column on very small screens */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Modal full width on mobile */
  .modal {
    width: 95%;
    max-width: none;
    margin: 16px;
  }

  /* Remove toast "pills" on mobile (they overlap the bottom sheet & map controls) */
  .toast-container {
    display: none;
  }
}

/* Very small screens (< 390px) */
@media (max-width: 389px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .tab {
    font-size: 12px;
    padding: 12px 8px;
  }
}
