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

:root {
  --bg-deep: #f5f7fa;
  --bg-base: #ffffff;
  --bg-surface: #ffffff;
  --bg-elevated: #f8f9fb;
  --border: rgba(0, 0, 0, 0.06);
  --border-light: rgba(0, 0, 0, 0.1);
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a78;
  --text-muted: #8a8aa0;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --purple: #8b5cf6;
  --gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --gradient-soft: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(139,92,246,0.08));
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.06);
  --red: #ef4444;
  --orange: #f97316;
  --yellow: #ca8a04;
  --green: #16a34a;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page { min-height: 100vh; }

/* ===== GLASS EFFECT ===== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

/* ===== UTILITIES ===== */
.muted { color: var(--text-secondary); }
.small { font-size: 0.8rem; }
.accent-text { color: var(--accent); font-weight: 700; }
.unit { color: var(--text-muted); font-weight: 400; }

/* ===== LOGIN PAGE ===== */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(139,92,246,0.06) 0%, transparent 50%),
    var(--bg-deep);
  padding: 1.5rem;
}

.login-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo {
  margin-bottom: 2rem;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--gradient-soft);
  border: 1px solid var(--glass-border);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.login-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.login-card {
  background: var(--bg-base);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.login-field {
  margin-bottom: 1.25rem;
  text-align: left;
}

.login-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-field input {
  width: 100%;
  padding: 0.875rem 1rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.login-field input::placeholder {
  color: var(--text-muted);
}

#login-btn {
  width: 100%;
  padding: 0.875rem;
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

#login-btn:hover { opacity: 0.9; }
#login-btn:active { transform: scale(0.98); }

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

.login-footer {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ===== HEADER ===== */
header {
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-logout {
  padding: 0.4rem 0.85rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* ===== MAIN ===== */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ===== SEARCH CARD ===== */
.search-card {
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.section-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.section-subheading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

#address-input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#address-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

#address-input::placeholder { color: var(--text-muted); }

/* Slider */
#radius-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
}

#radius-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  background: var(--gradient);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
  transition: transform 0.15s;
}

#radius-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Primary Button */
.btn-primary {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: var(--gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 0.25rem;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== RECENT SCANS ===== */
.recent-scans {
  margin-top: 1.5rem;
}

.recent-list {
  display: grid;
  gap: 0.5rem;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.recent-item:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.recent-info {
  min-width: 0;
  flex: 1;
}

.recent-address {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.scan-status {
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.scan-status.complete { background: #dcfce7; color: var(--green); }
.scan-status.scanning { background: #fef3c7; color: var(--yellow); }
.scan-status.error { background: #fecaca; color: var(--red); }
.scan-status.pending { background: #f1f5f9; color: var(--text-muted); }

/* ===== PROGRESS ===== */
.progress-card {
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
}

.progress-icon {
  margin-bottom: 1.25rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

.progress-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin: 1.25rem 0 0.75rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-stats {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ===== RESULTS ===== */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.results-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.results-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-secondary {
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(59,130,246,0.06);
  border-color: var(--accent);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
}

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

.results-list {
  display: grid;
  gap: 0.6rem;
}

.result-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--shadow-sm);
}

.result-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.result-thumb {
  width: 130px;
  height: 95px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: #e2e8f0;
}

.result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-address {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-type { background: #dbeafe; color: #1e40af; }
.badge-severity-low { background: #fef3c7; color: #92400e; }
.badge-severity-medium { background: #fed7aa; color: #9a3412; }
.badge-severity-high { background: #fecaca; color: #991b1b; }

.result-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-coords {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* No results */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.no-results h3 {
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-content {
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  position: relative;
  background: var(--bg-base);
  box-shadow: var(--shadow-lg);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  color: white;
  cursor: pointer;
  z-index: 1;
  transition: background 0.2s;
}

.modal-close:hover { background: rgba(0,0,0,0.6); }

#modal-image {
  width: 100%;
  display: block;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.modal-body h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.modal-badges {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.coords {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  main { padding: 1rem; }
  .search-card { padding: 1.5rem; }
  .result-card { flex-direction: column; }
  .result-thumb { width: 100%; height: 180px; }
  #map { height: 300px; }
  .results-header { flex-direction: column; }
  .results-actions { width: 100%; }
  .results-actions button { flex: 1; }
}
