:root {
  --bg-dark: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --color-operational: #10b981;
  --color-construction: #f59e0b;
  --color-planned: #3b82f6;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header & Navigation */
header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  z-index: 1000;
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  font-weight: 400;
}

/* Summary Metric Badges */
.metric-badges {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}
}

.metric-pill {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.6);
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.metric-pill strong {
  font-size: 0.95rem;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-surface-hover);
  border-color: #475569;
}

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

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

/* Main Layout */
.app-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 65px);
  position: relative;
  overflow: hidden;
}

/* Map View Container */
#map-container {
  flex: 1;
  height: 100%;
  position: relative;
  background: #090d16;
}

#map,
.leaflet-container {
  width: 100%;
  height: 100%;
  z-index: 10;
  background: #242830 !important;
}

/* Map Overlay Controls */
.map-controls-overlay {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  width: calc(100% - 2rem);
  pointer-events: none;
}

.map-controls-card {
  pointer-events: auto;
  background: rgba(30, 41, 59, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.search-box {
  width: 100%;
  display: flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  gap: 0.5rem;
}

.search-box input {
  background: transparent;
  border: none;
  color: white;
  font-size: 0.85rem;
  width: 100%;
  outline: none;
}

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

.filter-chips {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.filter-chip {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: #0f172a;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.filter-chip.active {
  background: var(--bg-surface-hover);
  color: white;
  border-color: #64748b;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-op {
  background: var(--color-operational);
}

.dot-con {
  background: var(--color-construction);
}

.dot-plan {
  background: var(--color-planned);
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 1.5rem;
  left: 1rem;
  z-index: 999;
  background: rgba(30, 41, 59, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.legend-title {
  font-weight: 600;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-size: 0.65rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

/* Sidebar / Drawer for Location Metadata */
.details-drawer {
  width: 420px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.25s ease;
  z-index: 1000;
  position: relative;
}

.details-drawer.closed {
  display: none;
}

.drawer-header {
  padding: 1.25rem 1.5rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.drawer-title-group h2 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.4rem;
}

.drawer-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}

.drawer-close-btn:hover {
  color: white;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-operational {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-construction {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-planned {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.drawer-content {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.spec-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
}

.spec-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.spec-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.meta-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.4rem;
}

.meta-row span:first-child {
  color: var(--text-muted);
}

.meta-row span:last-child {
  font-weight: 500;
  text-align: right;
}

.notes-box {
  background: #0f172a;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.source-action {
  margin-top: auto;
  padding-top: 1rem;
}

.source-action a {
  display: block;
  text-align: center;
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid #475569;
  text-decoration: none;
  padding: 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
}

.source-action a:hover {
  background: #475569;
}

/* Modal for Adding / Exporting Data */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-input,
.form-select,
.form-textarea {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: white;
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.json-code-box {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.75rem;
  color: #38bdf8;
  max-height: 250px;
  overflow: auto;
  white-space: pre;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border-radius: 8px !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
  padding: 0.2rem !important;
}

.leaflet-popup-tip {
  background: var(--bg-surface) !important;
}

.popup-box {
  font-size: 0.8rem;
  line-height: 1.4;
}

.popup-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: white;
}

.popup-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 0.4rem;
}

@media (max-width: 900px) {
  .details-drawer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 360px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .metric-badges {
    display: none;
  }
}