:root {
  /* Centralized theme tokens keep the glass-panel styling consistent across the app. */
  --bg: #08111f;
  --panel: rgba(8, 16, 30, 0.88);
  --panel-solid: #0c1729;
  --panel-light: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --text-soft: #cbd5e1;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --panel-width: 430px;
  --transition: 0.28s ease;
}

* {
  /* Strip default browser spacing so every component opts into its own layout. */
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  /* The app behaves like a map canvas, so the page itself stays locked to the viewport. */
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  /* Establishes the positioning context for the full-screen map and floating overlays. */
  position: relative;
  width: 100%;
  height: 100%;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #0f172a;
}

.topbar {
  /* The wrapper ignores clicks so only the visible brand card captures pointer events. */
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 1200;
  pointer-events: none;
}

.brand-block {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(8, 16, 30, 0.72);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.brand-block h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.05;
}

.brand-block p {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 13px;
}

.panel-toggle,
.panel-collapse-btn,
.modal-close {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  cursor: pointer;
}

.side-panel {
  /* This is an overlay panel, not document flow content, which keeps the map full-screen. */
  position: absolute;
  top: 108px;
  left: 18px;
  bottom: 18px;
  width: var(--panel-width);
  max-width: calc(100vw - 36px);
  z-index: 1100;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  transition: transform var(--transition), opacity var(--transition);
  padding: 18px;
}

.side-panel.is-collapsed {
  /* Slide off-canvas instead of removing the panel so the DOM and event wiring stay intact. */
  transform: translateX(calc(-100% - 18px));
  opacity: 0;
  pointer-events: none;
}

.side-panel::-webkit-scrollbar {
  width: 8px;
}

.side-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

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

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.panel-header h2 {
  font-size: 24px;
  font-weight: 800;
}

.panel-section {
  /* Shared card styling for every logical block inside the side panel. */
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title-row h3 {
  font-size: 15px;
  font-weight: 700;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-group {
  margin-bottom: 14px;
}

.form-grid {
  /* Compact two-column grid for paired numeric inputs. */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.text-input,
.text-area {
  /* Inputs reuse the translucent panel treatment so they feel part of the same surface. */
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
}

.text-input:focus,
.text-area:focus {
  border-color: rgba(59, 130, 246, 0.7);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.14);
}

.text-input::placeholder,
.text-area::placeholder {
  color: var(--text-muted);
}

.text-area {
  min-height: 140px;
  resize: vertical;
}

.inline-field {
  display: flex;
  gap: 10px;
}

.inline-field .registration-input {
  flex: 1;
}

.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  /* Strong contrast marks the primary actions such as lookup and search. */
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--panel-border);
}

.btn-outline {
  background: transparent;
  color: #93c5fd;
  border: 1px solid rgba(147, 197, 253, 0.32);
}

.button-row + .filter-accordion {
  margin-top: 12px;
}

.helper-text {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}

.vehicle-summary-empty {
  color: var(--text-muted);
  font-size: 14px;
}

.vehicle-summary-grid {
  /* Vehicle facts are presented as a quick-scan pill grid once lookup data exists. */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-pill {
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
}

.summary-pill-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.summary-pill-value {
  font-size: 15px;
  font-weight: 700;
}

.vehicle-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vehicle-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.vehicle-reg {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #facc15, #fbbf24);
  color: #111827;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 18px;
  margin-bottom: 10px;
}

.vehicle-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.vehicle-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.vehicle-source-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
}

.vehicle-source-badge.is-live {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.25);
  color: #86efac;
}

.vehicle-source-badge.is-mock {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

.hidden {
  display: none !important;
}

.slider-group input[type="range"] {
  width: 100%;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-value {
  font-size: 14px;
  font-weight: 700;
  color: #93c5fd;
}

.range-stats,
.summary-grid {
  /* Both metric blocks use the same stat-card grid pattern. */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.range-stat-card,
.dashboard-stat {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
}

.range-stat-label,
.dashboard-stat-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.range-stat-value,
.dashboard-stat-value {
  font-size: 22px;
  font-weight: 800;
}

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.subtab {
  flex: 1;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-weight: 700;
}

.subtab.is-active {
  /* Active state mirrors the accent color so context switches are obvious. */
  background: rgba(59, 130, 246, 0.18);
  color: white;
  border-color: rgba(59, 130, 246, 0.35);
}

.subtab-panel {
  display: none;
}

.subtab-panel.is-active {
  display: block;
}

.route-placeholder-card {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.18);
}

.route-placeholder-card h4 {
  margin-bottom: 6px;
}

.station-list {
  /* Results get their own scroll area so the whole panel does not jump while browsing cards. */
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.station-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.station-item h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.station-item p {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 5px;
}

.station-card-actions {
  margin-top: 12px;
}

.chart-shell {
  /* Fixed height keeps Chart.js canvases stable as data changes. */
  height: 280px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  padding: 12px;
}

.modal {
  /* Modals need their own stacking context above both the map and the side panel. */
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  z-index: 2001;
  width: min(1000px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  margin: 12px auto;
  background: #08111f;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 18px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  font-size: 22px;
}

.modal-header p {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 14px;
}

.modal-body {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.modal-chart-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.live-location-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1d4ed8;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 6px rgba(29, 78, 216, 0.18);
  position: relative;
}

.live-location-marker::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(29, 78, 216, 0.35);
  animation: liveLocationPulse 1.8s ease-out infinite;
}

@keyframes liveLocationPulse {
  0% {
    transform: scale(0.9);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

.location-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 42px;
}

.location-btn.is-active-location {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(96, 165, 250, 0.14);
  color: #dbeafe;
}

.location-btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.fuel-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  position: relative;
}

.fuel-marker::after {
  content: "⛽";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
}

.fuel-marker--cheap {
  background: #16a34a;
}

.fuel-marker--mid {
  background: #f59e0b;
}

.fuel-marker--expensive {
  background: #dc2626;
}

.selected-station-card {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.selected-station-card.empty {
  opacity: 0.92;
}

.selected-station-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.selected-station-top h4 {
  margin: 0 0 0.2rem 0;
}

.selected-station-top p {
  margin: 0;
  opacity: 0.75;
}

.selected-station-price {
  font-size: 1.4rem;
  font-weight: 700;
  white-space: nowrap;
}

.selected-station-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.selected-station-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.selected-station-label {
  font-size: 0.78rem;
  opacity: 0.7;
}

.selected-station-value {
  font-size: 0.95rem;
  font-weight: 500;
}

.station-item.is-selected {
  outline: 2px solid rgba(59, 130, 246, 0.9);
  outline-offset: 2px;
}

.mapboxgl-popup {
  z-index: 20;
}

.mapboxgl-popup-content {
  background-color: rgba(8, 16, 30, 0.96) !important;
  background: rgba(8, 16, 30, 0.96) !important;
  color: var(--text) !important;
  border: 1px solid var(--panel-border) !important;
  border-radius: 18px !important;
  padding: 0 !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden !important;
}

.mapboxgl-popup-tip {
  border-top-color: rgba(8, 16, 30, 0.96) !important;
  border-bottom-color: rgba(8, 16, 30, 0.96) !important;
  border-left-color: rgba(8, 16, 30, 0.96) !important;
  border-right-color: rgba(8, 16, 30, 0.96) !important;
}

.mapboxgl-popup-close-button {
  top: 8px;
  right: 10px;
  color: rgba(226, 232, 240, 0.75) !important;
  background: transparent !important;
  font-size: 1.1rem;
  line-height: 1;
}

.mapboxgl-popup-close-button:hover {
  color: #ffffff !important;
  background: transparent !important;
}

.station-popup {
  min-width: 240px;
  max-width: 280px;
  padding: 1rem;
  color: var(--text) !important;
}

.station-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.station-popup-title-block {
  min-width: 0;
}

.station-popup-title {
  margin: 0 0 0.2rem 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text) !important;
}

.station-popup-brand {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-soft) !important;
}

.station-popup-price {
  flex-shrink: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

.station-popup-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.station-popup-item {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.station-popup-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted) !important;
}

.station-popup-value {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text) !important;
}

.station-popup-address {
  padding-top: 0.85rem;
  border-top: 1px solid var(--panel-border);
}

.station-popup-address .station-popup-value {
  color: var(--text-soft) !important;
}

@media (max-width: 900px) {
  /* On smaller screens the panel widens and all dashboard grids collapse to one column. */
  .side-panel {
    width: calc(100vw - 24px);
    left: 12px;
    right: 12px;
    top: 78px;
    bottom: 12px;
    max-width: none;
  }

  .form-grid,
  .range-stats,
  .summary-grid,
  .vehicle-summary-grid,
  .selected-station-grid,
  .station-popup-grid {
    grid-template-columns: 1fr;
  }

  .brand-block {
    max-width: calc(100vw - 24px);
  }
}

.filter-accordion {
  margin-top: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.filter-accordion-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
  color: var(--text);
}

.filter-accordion-summary::-webkit-details-marker {
  display: none;
}

.filter-summary-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
}

.filter-accordion-body {
  padding: 0 16px 16px 16px;
  border-top: 1px solid var(--panel-border);
}

.station-item-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.station-item-button:hover {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(172, 34, 34, 0.07);
}

.station-item-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--text) !important;
}

.station-item-button h3 {
  color: var(--text) !important;
}

.station-item-button p {
  color: var(--text-soft) !important;
}


.refine-group {
  display: flex;
  flex-direction: column;
  gap: 8px; /* this is the key spacing fix */
}

.refine-group label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}

.refine-group select {
  width: 100%;
  height: 46px;
  padding: 0 42px 0 14px;
  border: 1px solid #dbe2ea;
  border-radius: 14px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.95rem;
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.refine-group select:hover {
  border-color: #cbd5e1;
}

.refine-group select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

@media (min-width: 768px) {
  .refine-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }
}

.chart-shell-large {
  height: 720px;
}

.station-popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 0.9rem;
  margin-bottom: 0.9rem;
}

.station-popup-item {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}

.station-popup-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted) !important;
}

.station-popup-value {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text) !important;
  word-break: break-word;
}

.station-popup-address,
.station-popup-comparison {
  padding-top: 0.85rem;
  border-top: 1px solid var(--panel-border);
}

.station-popup-address .station-popup-value {
  color: var(--text-soft) !important;
}

.station-popup-comparison .station-popup-value {
  color: #93c5fd !important;
  font-weight: 700;
}

@media (max-width: 900px) {
  .station-popup-grid {
    grid-template-columns: 1fr;
  }
}