:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #f6f7fb;
  color: #1b1f2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 32px 24px 64px;
}

.breadcrumb {
  margin-bottom: 16px;
}

.breadcrumb a {
  font-size: 14px;
  color: #6b7280;
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumb a:hover {
  color: #4338ca;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  margin: 0 0 8px;
  color: #6b7280;
}

h1 {
  font-size: 36px;
  margin: 0 0 12px;
}

.subhead {
  margin: 0;
  max-width: 640px;
  color: #374151;
  line-height: 1.5;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 20px 24px;
  min-width: 220px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.stat-card h2 {
  margin: 0 0 6px;
  font-size: 32px;
}

.stat-card p {
  margin: 0;
  color: #6b7280;
}

.stat-card span {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 600;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: #111827;
}

input,
select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 14px;
}

input[type="range"] {
  padding: 0;
  accent-color: #4338ca;
}

.line-filter {
  display: grid;
  gap: 8px;
}

.line-filter-title {
  font-weight: 600;
  color: #111827;
}

.line-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.line-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}

.line-option input {
  margin: 0;
}

.weights {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(260px, 1fr);
  gap: 24px;
  margin-bottom: 28px;
  background: white;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.weight-card h3 {
  margin: 0 0 8px;
}

.weight-card p {
  margin: 0;
  color: #4b5563;
  line-height: 1.6;
}

.weight-controls {
  display: grid;
  gap: 16px;
}

.weight-controls label {
  font-weight: 600;
  color: #111827;
}

.weight-value {
  font-size: 12px;
  color: #6b7280;
}

.weight-total {
  font-size: 14px;
  color: #111827;
  background: #f3f4f6;
  padding: 8px 12px;
  border-radius: 10px;
  width: fit-content;
}

.table-wrapper {
  background: white;
  border-radius: 16px;
  padding: 16px;
  overflow-x: auto;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}

th {
  color: #6b7280;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.number {
  text-align: right;
}

.sortable {
  padding: 8px 10px;
}

.spending-header-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.spending-select {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 4px 6px;
  background: white;
  cursor: pointer;
}

.sort-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #4338ca;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  min-width: 24px;
}

.sort-arrow:hover {
  background: #e0e7ff;
}

.sort-arrow:empty::after {
  content: "\25B6";
  color: #9ca3af;
  font-size: 10px;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  font-weight: 700;
  background: #111827;
  color: white;
}

.lines {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.line-chip {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.line-blue { background: #2563eb; }
.line-red { background: #dc2626; }
.line-brown { background: #92400e; }
.line-green { background: #16a34a; }
.line-orange { background: #ea580c; }
.line-purple { background: #7c3aed; }
.line-pink { background: #db2777; }
.line-yellow { background: #ca8a04; }

.ada {
  font-weight: 600;
  color: #0f766e;
}

.methodology {
  margin-top: 32px;
}

.methodology h2 {
  font-size: 24px;
  margin: 0 0 16px;
}

.method-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-bottom: 20px;
}

.method-card {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.method-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #4338ca;
}

.method-card p {
  margin: 0;
  color: #4b5563;
  line-height: 1.6;
  font-size: 14px;
}

.method-note {
  background: white;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.method-note h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.method-note p,
.method-note li {
  color: #4b5563;
  line-height: 1.6;
  font-size: 14px;
}

.method-note ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

footer {
  margin-top: 32px;
  color: #6b7280;
  font-size: 14px;
}

/* ── View Toggle ── */
.view-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: #e5e7eb;
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}

.view-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.view-btn.active {
  background: white;
  color: #4338ca;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.view-btn:hover:not(.active) {
  color: #374151;
}

/* ── Map Section ── */
.map-section {
  margin-bottom: 24px;
}

.map-layout {
  display: flex;
  gap: 16px;
}

.map-container {
  flex: 1;
  height: 600px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
  z-index: 1;
}

/* ── Comparison Panel ── */
.comparison-panel {
  width: 340px;
  min-width: 340px;
  background: white;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  max-height: 600px;
}

.panel-header {
  margin-bottom: 12px;
}

.panel-header h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.marker-mode-toggle {
  display: flex;
  gap: 0;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 3px;
}

.mode-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn.active {
  background: white;
  color: #4338ca;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-placeholder {
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
  margin-top: 40px;
}

.clear-btn {
  margin-top: 12px;
  padding: 8px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.15s ease;
}

.clear-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

/* ── Station Detail Card ── */
.station-detail {
  background: #f9fafb;
  border-radius: 10px;
  padding: 12px;
  position: relative;
}

.station-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.station-detail-name {
  font-weight: 700;
  font-size: 14px;
  margin: 0;
}

.station-detail-rank {
  font-size: 12px;
  color: #6b7280;
  margin: 2px 0 0;
}

.station-detail-close {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: #e5e7eb;
  color: #6b7280;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.station-detail-close:hover {
  background: #d1d5db;
  color: #374151;
}

.station-detail-lines {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.station-detail-lines .line-chip {
  font-size: 11px;
  padding: 2px 6px;
}

.station-detail-scores {
  display: grid;
  gap: 6px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.score-label {
  width: 85px;
  flex-shrink: 0;
  color: #6b7280;
  text-transform: capitalize;
}

.score-bar-track {
  flex: 1;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.score-value {
  width: 28px;
  text-align: right;
  font-weight: 600;
  color: #374151;
}

.station-detail-meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #6b7280;
}

/* ── Custom Map Markers ── */
.custom-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: white;
  border: 3px solid #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #1b1f2a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.custom-marker:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.custom-marker.selected {
  box-shadow: 0 0 0 3px #f59e0b, 0 4px 12px rgba(0, 0, 0, 0.3);
}

.custom-marker.score-mode {
  color: white;
  border-color: transparent;
}

.custom-marker.score-mode.light-bg {
  color: #1b1f2a;
}

/* Marker line colors */
.custom-marker.marker-blue { border-color: #2563eb; }
.custom-marker.marker-red { border-color: #dc2626; }
.custom-marker.marker-brown { border-color: #92400e; }
.custom-marker.marker-green { border-color: #16a34a; }
.custom-marker.marker-orange { border-color: #ea580c; }
.custom-marker.marker-purple { border-color: #7c3aed; }
.custom-marker.marker-pink { border-color: #db2777; }
.custom-marker.marker-yellow { border-color: #ca8a04; }

@media (max-width: 768px) {
  .map-section {
    position: relative;
  }

  .map-layout {
    flex-direction: column;
    position: relative;
  }

  .map-container {
    height: 55vh;
    min-height: 300px;
    border-radius: 12px;
  }

  /* Bottom drawer panel on mobile */
  .comparison-panel {
    width: 100%;
    min-width: 0;
    max-height: 45vh;
    border-radius: 16px 16px 12px 12px;
    margin-top: -12px;
    position: relative;
    z-index: 10;
    padding: 12px;
  }

  .panel-header h3 {
    font-size: 14px;
    margin: 0 0 8px;
  }

  .marker-mode-toggle {
    padding: 2px;
  }

  .mode-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .panel-content {
    gap: 8px;
  }

  .station-detail {
    padding: 10px;
  }

  .station-detail-name {
    font-size: 13px;
  }

  .station-detail-rank {
    font-size: 11px;
  }

  .score-row {
    font-size: 11px;
    gap: 6px;
  }

  .score-label {
    width: 70px;
  }

  .station-detail-meta {
    font-size: 11px;
    margin-top: 6px;
    padding-top: 6px;
  }

  /* Smaller markers on mobile */
  .custom-marker {
    width: 26px;
    height: 26px;
    font-size: 9px;
    border-width: 2.5px;
  }

  .view-toggle {
    margin-bottom: 16px;
  }

  .view-btn {
    padding: 6px 16px;
    font-size: 13px;
  }

  .clear-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 24px 16px 48px;
  }

  h1 {
    font-size: 28px;
  }

  .weights {
    grid-template-columns: 1fr;
  }

  .map-container {
    height: 50vh;
    min-height: 280px;
    border-radius: 10px;
  }

  .comparison-panel {
    max-height: 40vh;
    padding: 10px;
  }

  .custom-marker {
    width: 24px;
    height: 24px;
    font-size: 8px;
    border-width: 2px;
  }
}
