:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-hover: #334155;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: #10b981;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-green: #10b981;
  --accent-green-dark: #059669;
  --accent-green-light: #34d399;
  --accent-amber: #f59e0b;
  --accent-orange: #f97316;
  --accent-blue: #3b82f6;
  --accent-gold: #fbbf24;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-width: 440px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
}

/* App Structure */
.app-container {
  display: flex;
  width: 100vw;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100dvh;
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-inline-end: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-lg);
}

.sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
}

/* Header */
.sidebar-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-block-end: 1px solid var(--border-color);
}

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

.brand-logo {
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #10b981, #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #f8fafc, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text .subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

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

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  inline-size: 34px;
  block-size: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Stats Ticker */
.stats-ticker {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: rgba(30, 41, 59, 0.5);
  border-block-end: 1px solid var(--border-color);
  overflow-x: auto;
  font-size: 0.75rem;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-full);
  white-space: nowrap;
  color: var(--text-secondary);
}

.stat-badge strong {
  color: var(--text-primary);
}

.stat-badge.stat-green strong {
  color: var(--accent-green-light);
}

.pulse-dot {
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background-color: var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Nav Tabs */
.nav-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.5rem 1.25rem;
  gap: 0.5rem;
  border-block-end: 1px solid var(--border-color);
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  background-color: var(--bg-secondary);
  color: var(--accent-green-light);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Tab Panels */
.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.tab-panel.active {
  display: block;
}

/* Form */
.route-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.input-group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.coord-dot {
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  display: inline-block;
}

.start-dot { background-color: var(--accent-blue); box-shadow: 0 0 6px var(--accent-blue); }
.end-dot { background-color: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  inline-size: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.65rem 2.2rem 0.65rem 0.85rem;
  font-size: 0.875rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.btn-input-action {
  position: absolute;
  right: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.btn-input-action:hover {
  color: var(--accent-blue);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  box-shadow: var(--shadow-lg);
  max-height: 220px;
  overflow-y: auto;
}

.autocomplete-dropdown.hidden {
  display: none;
}

.autocomplete-item {
  padding: 0.6rem 0.85rem;
  font-size: 0.825rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover, .autocomplete-item.selected {
  background-color: var(--bg-hover);
}

.autocomplete-item .item-title {
  font-weight: 500;
  color: var(--text-primary);
}

.autocomplete-item .item-sub {
  font-size: 0.725rem;
  color: var(--text-muted);
}

/* Swap Button */
.swap-wrapper {
  display: flex;
  justify-content: center;
  margin: -0.35rem 0;
  position: relative;
  z-index: 2;
}

.swap-btn {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  inline-size: 28px;
  block-size: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.swap-btn:hover {
  background-color: var(--bg-hover);
  color: var(--accent-green-light);
  transform: rotate(180deg);
}

/* Vehicle Drawer */
.vehicle-options-drawer {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.drawer-summary {
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.drawer-summary .summary-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drawer-summary .chevron {
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.vehicle-options-drawer[open] .chevron {
  transform: rotate(180deg);
}

.drawer-content {
  padding: 0.85rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field label {
  font-size: 0.725rem;
  color: var(--text-secondary);
}

.field input {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.45rem 0.65rem;
  font-size: 0.825rem;
  outline: none;
}

.slider-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.slider-label strong {
  color: var(--accent-green-light);
}

input[type="range"] {
  accent-color: var(--accent-green);
  cursor: pointer;
  inline-size: 100%;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: all 0.2s;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  font-size: 0.825rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Route Results */
.route-results-container {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.route-results-container.hidden {
  display: none;
}

.route-summary-card {
  background: var(--bg-card);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-md);
}

.summary-main {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  text-align: center;
}

.summary-metric {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-val {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.savings-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.05));
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.savings-icon {
  font-size: 1.4rem;
}

.savings-amount {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.savings-amount strong {
  color: var(--accent-green-light);
  font-size: 1rem;
}

.savings-sub {
  font-size: 0.725rem;
  color: var(--text-secondary);
}

/* Sections */
.results-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-title h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.badge-star {
  font-size: 0.9rem;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.section-header-row h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.corridor-filter-pills {
  display: flex;
  gap: 0.35rem;
}

.pill {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.pill.active {
  background: var(--accent-green-dark);
  color: white;
  border-color: var(--accent-green);
}

/* Cards */
.recommended-stop-card {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), rgba(30, 41, 59, 0.95));
  border: 1.5px solid rgba(251, 191, 36, 0.5);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.15);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.recommended-stop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(251, 191, 36, 0.25);
}

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

.stop-tag {
  background: var(--accent-gold);
  color: #1e293b;
  font-size: 0.675rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-transform: uppercase;
}

.station-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.25rem;
}

.station-loc {
  font-size: 0.775rem;
  color: var(--text-secondary);
}

.price-box {
  text-align: right;
}

.price-main {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-green-light);
  line-height: 1;
}

.price-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  text-align: center;
}

.metric-item-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.metric-item-val {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.action-btn {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

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

.action-btn.nav-waze:hover {
  border-color: #33ccff;
  color: #33ccff;
}

.action-btn.nav-maps:hover {
  border-color: #4285f4;
  color: #4285f4;
}

/* Corridor Stations List */
.corridor-stations-list, .explore-stations-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 400px;
  overflow-y: auto;
}

.station-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.station-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--bg-secondary);
}

.station-card-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-inline-size: 70%;
}

.station-brand-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.station-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-pop {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.pop-highway {
  background: rgba(249, 115, 22, 0.2);
  color: var(--accent-orange);
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.pop-road {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.station-card-sub {
  font-size: 0.725rem;
  color: var(--text-secondary);
}

.station-card-detour {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.station-card-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.station-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-green-light);
}

/* Explore Panel Controls */
.explore-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.search-box input {
  inline-size: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.65rem;
  font-size: 0.85rem;
  outline: none;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.checkbox-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input {
  accent-color: var(--accent-green);
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.825rem;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-block-start: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.8);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-text:hover {
  color: var(--accent-green-light);
  background: rgba(255, 255, 255, 0.05);
}

/* Map Viewport */
.map-viewport {
  flex: 1;
  position: relative;
  height: 100dvh;
  width: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background-color: #1a202c;
}

/* Floating Map Overlay Controls */
.map-overlay-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.map-btn {
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  inline-size: 40px;
  block-size: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s;
}

.map-btn:hover {
  background-color: var(--bg-hover);
  transform: scale(1.05);
}

#map-btn-sidebar-toggle {
  display: none;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.725rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-color {
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  display: inline-block;
}

.color-green { background: #10b981; }
.color-teal { background: #06b6d4; }
.color-orange { background: #f97316; }

/* Custom Leaflet Marker Pins */
.price-pill-marker {
  background-color: #10b981;
  color: white;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  border: 1.5px solid white;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.15s ease-out;
}

.price-pill-marker:hover {
  transform: scale(1.15);
  z-index: 1000 !important;
}

.price-pill-marker.price-tier-cheap {
  background-color: #059669;
}

.price-pill-marker.price-tier-mid {
  background-color: #0284c7;
}

.price-pill-marker.price-tier-high {
  background-color: #ea580c;
}

.price-pill-marker.is-recommended {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #fef08a;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.8);
  font-weight: 800;
  transform: scale(1.1);
}

/* Custom Leaflet Popups */
.leaflet-popup-content-wrapper {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1.4 !important;
}

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

.station-popup {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-inline-size: 260px;
}

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

.popup-brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.popup-city {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.popup-price-tag {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-green-light);
}

.popup-details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.775rem;
  color: var(--text-secondary);
}

.popup-services {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.service-tag {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.popup-nav-links {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.popup-nav-links a {
  flex: 1;
  text-align: center;
  padding: 0.35rem;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
}

.popup-nav-links a:hover {
  background: var(--accent-green-dark);
}

/* Toast */
.toast {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Bottom Sheet Components (Hidden by default on Desktop & Tablet)
   ========================================================================== */
.sheet-drag-handle {
  display: none;
  width: 100%;
  padding: 10px 0 6px 0;
  cursor: grab;
  touch-action: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.sheet-handle-pill {
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background-color: rgba(255, 255, 255, 0.3);
  transition: background-color 0.2s, width 0.2s;
}

.sheet-drag-handle:active .sheet-handle-pill {
  background-color: var(--accent-green);
  width: 52px;
}

.mobile-peek-bar {
  display: none;
  padding: 0.35rem 1rem 0.75rem 1rem;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}

.peek-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.peek-content.hidden {
  display: none !important;
}

.peek-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
}

.peek-logo {
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-md);
  border: 1px solid rgba(16, 185, 129, 0.3);
  flex-shrink: 0;
}

.peek-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.peek-main {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peek-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.peek-action-btn {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green-light);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.peek-savings-pill {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--accent-green-light);
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--accent-green);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Modal Dialog */
.modal-dialog {
  margin: auto;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  color: var(--text-primary);
  max-width: 420px;
  width: 90vw;
  padding: 0;
  backdrop-filter: blur(12px);
  outline: none;
}

.modal-dialog:modal {
  overscroll-behavior: contain;
}

.modal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-desc {
  font-size: 0.825rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.lan-url-box {
  display: flex;
  gap: 0.4rem;
}

.lan-url-box input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-green-light);
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  outline: none;
}

.copy-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-top: 0.25rem;
}

.qr-container img {
  border-radius: 4px;
}

.qr-sub {
  font-size: 0.75rem;
  color: #334155;
  text-align: center;
  font-weight: 500;
}

/* ==========================================================================
   Multi-Fuel Selector & Grid Styles
   ========================================================================== */
.fuel-selector-container {
  padding: 0.6rem 1rem 0.4rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.fuel-selector-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.fuel-selector-bar {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.fuel-selector-bar::-webkit-scrollbar {
  display: none;
}

.fuel-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.65rem;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.fuel-pill:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.fuel-pill.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-green);
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.35);
}

.fuel-pill-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  line-height: 1.2;
}

.fuel-badge-e85 {
  background: linear-gradient(135deg, #10b981, #0284c7);
  color: #ffffff;
}

.fuel-badge-e10 {
  background: #10b981;
  color: #042f2e;
}

.fuel-badge-sp98 {
  background: #047857;
  color: #ecfdf5;
}

.fuel-badge-sp95 {
  background: #16a34a;
  color: #ffffff;
}

.fuel-badge-gazole {
  background: #f59e0b;
  color: #451a03;
}

.fuel-badge-gplc {
  background: #0284c7;
  color: #ffffff;
}

.fuel-pill-price {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-primary);
}

.fuel-pill.active .fuel-pill-price {
  color: var(--accent-green-light);
}

/* Explore Panel Fuel Selector Bar */
.explore-fuel-selector-wrapper {
  margin-bottom: 0.75rem;
}

.explore-fuel-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.4rem;
}

.explore-fuel-bar {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.explore-fuel-bar::-webkit-scrollbar {
  display: none;
}

.explore-fuel-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.explore-fuel-pill:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.explore-fuel-pill.active {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--accent-green);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.explore-pill-price {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-primary);
}

.explore-fuel-pill.active .explore-pill-price {
  color: var(--accent-green-light);
}

/* Floating Map Fuel Bar (Interactive overlay when viewing the map) */
.map-fuel-bar-container {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  z-index: 850;
  max-width: calc(100% - 90px);
  pointer-events: auto;
}

.map-fuel-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.45rem;
  background-color: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.map-fuel-bar::-webkit-scrollbar {
  display: none;
}

.map-fuel-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.map-fuel-pill:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.map-fuel-pill.active {
  background: rgba(16, 185, 129, 0.28);
  border-color: var(--accent-green);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.45);
}

.map-pill-price {
  font-weight: 700;
  font-size: 0.72rem;
  color: #cbd5e1;
}

.map-fuel-pill.active .map-pill-price {
  color: #6ee7b7;
}

/* Multi-fuel grid in station popups and cards */
.fuels-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  margin: 0.6rem 0;
}

.fuel-tag {
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: center;
  transition: all 0.2s;
}

.fuel-tag-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.fuel-tag-val {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-primary);
}

.fuel-tag.selected {
  background: rgba(16, 185, 129, 0.22);
  border-color: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.35);
}

.fuel-tag.selected .fuel-tag-name {
  color: var(--accent-green-light);
}

.fuel-tag.selected .fuel-tag-val {
  color: #ffffff;
}

.fuel-tag.empty {
  opacity: 0.35;
}

.fuel-tag.empty .fuel-tag-val {
  font-weight: 400;
  color: var(--text-muted);
}

/* Vehicle select input */
.select-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background-color: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* ==========================================================================
   Real-Time Shortage / Rupture Styles
   ========================================================================== */
.stat-badge.stat-red {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.price-pill-marker.price-tier-rupture {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #ffffff !important;
  border-color: #fca5a5 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5) !important;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.price-pill-marker.price-tier-seche {
  background: #7f1d1d !important;
  color: #fecaca !important;
  border-color: #ef4444 !important;
  opacity: 0.85;
}

/* Fuel Tag Rupture states */
.fuel-tag.rupture-temp {
  background: rgba(245, 158, 11, 0.18) !important;
  border-color: rgba(245, 158, 11, 0.5) !important;
}

.fuel-tag.rupture-temp .fuel-tag-name {
  color: #fbbf24 !important;
}

.fuel-tag.rupture-temp .fuel-tag-val {
  color: #fde047 !important;
  font-size: 0.72rem !important;
  font-weight: 700;
}

.fuel-tag.rupture-def {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  opacity: 0.7;
}

.fuel-tag.rupture-def .fuel-tag-name {
  color: #f87171 !important;
}

.fuel-tag.rupture-def .fuel-tag-val {
  color: #fca5a5 !important;
  font-size: 0.68rem !important;
}

.badge-rupture {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-rupture-temp {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid #f59e0b;
  color: #fde047;
}

.badge-rupture-total {
  background: rgba(239, 68, 68, 0.25);
  border: 1px solid #ef4444;
  color: #fca5a5;
}

.rupture-notice-box {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin: 0.4rem 0;
  font-size: 0.75rem;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.total-verify-container {
  margin-top: 8px;
}

.btn-total-verify {
  width: 100%;
  padding: 6px 10px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fca5a5;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-total-verify:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
}

/* ==========================================================================
   Responsive Breakpoints & Multi-Device Adaptation (Loaded Last to Win Cascade)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Mobile Phones (< 768px portrait & small screens): Multi-State Bottom Sheet
   -------------------------------------------------------------------------- */
@media (max-width: 767px) and (orientation: portrait), (max-width: 500px) {
  .app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    background-color: var(--bg-primary);
  }

  /* Default / Half state (Map 35dvh, Drawer 65dvh) */
  .map-viewport {
    order: 1;
    width: 100%;
    height: 35dvh;
    min-height: 35dvh;
    position: relative;
    flex-shrink: 0;
    transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
  }

  .sidebar {
    order: 2;
    flex: 1 1 auto;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 65dvh !important;
    min-height: 65dvh !important;
    max-height: 65dvh !important;
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    border-radius: 20px 20px 0 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(15, 23, 42, 0.98);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  /* Peek State (Collapsed to 68px: Map takes 100dvh - 68px) */
  .app-container.sheet-peek .map-viewport,
  .app-container.map-fullscreen .map-viewport {
    height: calc(100dvh - 68px) !important;
    min-height: calc(100dvh - 68px) !important;
  }

  .app-container.sheet-peek .sidebar,
  .app-container.map-fullscreen .sidebar {
    flex: none !important;
    height: 68px !important;
    min-height: 68px !important;
    max-height: 68px !important;
  }

  .app-container.sheet-peek .sidebar .mobile-peek-bar,
  .app-container.map-fullscreen .sidebar .mobile-peek-bar {
    display: flex !important;
  }

  .app-container.sheet-peek .sidebar > :not(.sheet-drag-handle):not(.mobile-peek-bar),
  .app-container.map-fullscreen .sidebar > :not(.sheet-drag-handle):not(.mobile-peek-bar) {
    display: none !important;
  }

  /* Full / Expanded State (Map 14dvh, Drawer 86dvh) */
  .app-container.sheet-full .map-viewport {
    height: 14dvh !important;
    min-height: 14dvh !important;
  }

  .app-container.sheet-full .sidebar {
    flex: none !important;
    height: 86dvh !important;
    min-height: 86dvh !important;
    max-height: 86dvh !important;
  }

  .app-container.sheet-full .map-fuel-bar-container {
    opacity: 0;
    pointer-events: none;
  }

  .sheet-drag-handle {
    display: flex;
    padding: 8px 0 4px 0;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    background: transparent;
    touch-action: none;
  }

  .mobile-peek-bar {
    display: none;
    padding: 0.3rem 0.85rem 0.6rem 0.85rem;
    cursor: pointer;
    flex-shrink: 0;
    user-select: none;
  }

  /* Compact sidebar header in mobile sheet */
  .sidebar-header {
    padding: 0.35rem 0.85rem;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }

  .brand-text .subtitle {
    display: none;
  }

  /* On mobile portrait: Hide redundant fuel bar inside sidebar to save vertical space.
     The floating map fuel bar right above the sheet handles quick fuel switching! */
  .fuel-selector-container {
    display: none !important;
  }

  /* Hide fixed sidebar footer on mobile portrait to ensure form fits completely */
  .sidebar-footer {
    display: none !important;
  }

  /* Compact Ticker */
  .stats-ticker {
    padding: 0.2rem 0.85rem;
    font-size: 0.7rem;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .stats-ticker::-webkit-scrollbar {
    display: none;
  }

  .stat-badge {
    padding: 0.18rem 0.42rem;
  }

  /* Compact Tabs */
  .nav-tabs {
    padding: 0.25rem 0.85rem;
    gap: 0.35rem;
  }

  .tab-btn {
    padding: 0.42rem 0.6rem;
    font-size: 0.8rem;
    gap: 0.35rem;
  }

  .tab-panel {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.45rem 0.85rem;
  }

  /* Chevron on mobile rotates down to indicate collapse */
  #btn-toggle-sidebar svg {
    transform: rotate(-90deg);
  }

  /* Form spacing tuned to fit completely on small screens */
  .route-form {
    gap: 0.32rem;
  }

  .input-group {
    gap: 0.2rem;
    margin-bottom: 0.2rem;
  }

  .input-group label {
    font-size: 0.72rem;
    margin-bottom: 0;
  }

  .input-wrapper input {
    font-size: 16px; /* Avoid iOS auto-zoom */
    padding: 0.52rem 2.2rem 0.52rem 0.75rem;
    min-height: 42px;
  }

  .swap-wrapper {
    margin: -0.22rem 0;
    height: 24px;
  }

  .swap-btn {
    width: 30px;
    height: 30px;
  }

  .btn-input-action {
    width: 32px;
    height: 32px;
  }

  .vehicle-options-drawer {
    margin: 0.2rem 0;
    padding: 0.35rem 0.65rem;
  }

  .drawer-summary {
    font-size: 0.75rem;
  }

  .btn-primary {
    min-height: 44px;
    font-size: 0.92rem;
    margin-top: 0.3rem;
  }

  /* Overlay Controls on Mobile Map */
  .map-overlay-controls {
    top: max(8px, env(safe-area-inset-top, 0px)) !important;
    right: max(8px, env(safe-area-inset-right, 0px)) !important;
    gap: 0.4rem;
  }

  .map-btn {
    width: 38px;
    height: 38px;
  }

  #map-btn-sidebar-toggle {
    display: none !important;
  }

  /* Floating Map Fuel Bar on mobile: safe area padded with smooth horizontal swipe and right fade mask */
  .map-fuel-bar-container {
    top: max(8px, env(safe-area-inset-top, 0px)) !important;
    left: max(8px, env(safe-area-inset-left, 0px)) !important;
    right: 52px !important;
    max-width: calc(100vw - 60px) !important;
  }

  .map-fuel-bar {
    padding: 0.2rem 0.35rem;
    gap: 0.3rem;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 4px;
    mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent 100%);
  }

  .map-fuel-pill {
    padding: 0.22rem 0.45rem;
    font-size: 0.68rem;
    gap: 0.28rem;
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  .map-pill-price {
    font-size: 0.68rem;
  }

  /* Map Legend: docked cleanly below top fuel bar on mobile, eliminating all bottom collisions */
  .map-legend {
    top: max(46px, calc(env(safe-area-inset-top, 0px) + 42px)) !important;
    left: max(8px, env(safe-area-inset-left, 0px)) !important;
    bottom: auto !important;
    right: auto !important;
    padding: 0.16rem 0.5rem;
    font-size: 0.62rem;
    gap: 0.4rem;
    max-width: calc(100vw - 70px);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    z-index: 850;
  }
  .map-legend::-webkit-scrollbar {
    display: none;
  }

  /* Leaflet zoom controls at bottom-right above attribution */
  .leaflet-bottom.leaflet-right {
    bottom: 22px !important;
    right: 8px !important;
  }

  .summary-main {
    gap: 0.35rem;
  }

  .metric-val {
    font-size: 0.95rem;
  }
}

/* --------------------------------------------------------------------------
   Mobile Landscape (< 550px height): Ergonomic Side Drawer
   -------------------------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 550px) {
  .app-container {
    display: flex !important;
    flex-direction: row !important;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    order: 1 !important;
    position: relative !important;
    width: 320px !important;
    min-width: 280px !important;
    max-width: 44vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border-top: none !important;
    border-right: 1px solid var(--border-color) !important;
    transform: none !important;
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.collapsed {
    transform: translateX(-100%) !important;
    position: absolute !important;
  }

  .map-viewport {
    order: 2 !important;
    flex: 1 !important;
    width: auto !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
  }

  .sheet-drag-handle,
  .mobile-peek-bar {
    display: none !important;
  }

  #btn-toggle-sidebar svg {
    transform: none !important;
  }

  #map-btn-sidebar-toggle {
    display: flex !important;
  }

  .sidebar-header {
    padding: 0.35rem 0.75rem;
  }

  .fuel-selector-container {
    display: none !important; /* Managed via floating map fuel bar */
  }

  .stats-ticker {
    padding: 0.2rem 0.75rem;
    font-size: 0.7rem;
  }

  .nav-tabs {
    padding: 0.25rem 0.75rem;
  }

  .tab-panel {
    padding: 0.4rem 0.75rem;
    overflow-y: auto;
  }

  .sidebar-footer {
    display: none !important;
  }

  .map-fuel-bar-container {
    top: max(8px, env(safe-area-inset-top, 0px)) !important;
    left: 10px !important;
    max-width: calc(100% - 110px) !important;
  }

  .map-overlay-controls {
    top: max(8px, env(safe-area-inset-top, 0px)) !important;
    right: max(8px, env(safe-area-inset-right, 0px)) !important;
  }

  .leaflet-bottom.leaflet-right {
    bottom: 22px !important;
    right: 8px !important;
  }

  .map-legend {
    bottom: 22px !important;
    right: 56px !important;
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }
}

/* --------------------------------------------------------------------------
   Tablets (768px - 1024px with height > 550px): Floating Glassmorphism Left Card
   -------------------------------------------------------------------------- */
@media (min-width: 768px) and (min-height: 551px) and (max-width: 1024px) {
  .app-container {
    position: relative;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
  }

  .map-viewport {
    position: absolute;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 1;
  }

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

  .sidebar {
    position: absolute;
    top: max(16px, env(safe-area-inset-top, 0px));
    left: max(16px, env(safe-area-inset-left, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    width: 380px;
    max-width: 44vw;
    height: auto;
    max-height: calc(100dvh - 32px);
    border-radius: 20px;
    background-color: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.collapsed {
    transform: translateX(calc(-100% - 24px));
    position: absolute;
  }

  #map-btn-sidebar-toggle {
    display: flex;
  }

  .sheet-drag-handle,
  .mobile-peek-bar {
    display: none !important;
  }

  .map-overlay-controls {
    top: max(16px, env(safe-area-inset-top, 0px));
    right: max(16px, env(safe-area-inset-right, 0px));
  }

  /* Position floating fuel bar so it starts right after the sidebar */
  .sidebar:not(.collapsed) ~ .map-viewport .map-fuel-bar-container,
  .map-fuel-bar-container {
    top: max(16px, env(safe-area-inset-top, 0px)) !important;
    left: calc(380px + 32px) !important;
    max-width: calc(100vw - 380px - 140px) !important;
  }

  .sidebar.collapsed ~ .map-viewport .map-fuel-bar-container {
    left: 70px !important;
    max-width: calc(100vw - 160px) !important;
  }

  .leaflet-bottom.leaflet-right {
    bottom: 16px !important;
    right: 16px !important;
  }

  .map-legend {
    bottom: 16px !important;
    right: 64px !important;
  }
}

/* --------------------------------------------------------------------------
   Desktop & Large Screens (> 1024px with height > 550px): Split Layout
   -------------------------------------------------------------------------- */
@media (min-width: 1025px) and (min-height: 551px) {
  .sheet-drag-handle,
  .mobile-peek-bar {
    display: none !important;
  }

  .map-fuel-bar-container {
    top: 1.25rem !important;
    left: 1.25rem !important;
    max-width: calc(100% - 100px) !important;
  }

  .leaflet-bottom.leaflet-right {
    bottom: 1.5rem !important;
    right: 1.5rem !important;
  }

  .map-legend {
    bottom: 1.5rem !important;
    right: 64px !important;
  }
}

/* --------------------------------------------------------------------------
   Coarse Pointer / Touch Screens: Minimum 44px Hit Targets (WCAG 2.5.5)
   -------------------------------------------------------------------------- */
@media (pointer: coarse) {
  :root {
    --target-size: 44px;
  }

  .icon-btn,
  .map-btn,
  .swap-btn,
  .btn-input-action {
    min-inline-size: 44px;
    min-block-size: 44px;
  }

  .tab-btn,
  .btn-primary,
  .btn-secondary {
    min-block-size: 44px;
  }

  .fuel-pill,
  .map-fuel-pill,
  .explore-fuel-pill {
    min-block-size: 38px;
    position: relative;
  }

  .fuel-pill::after,
  .map-fuel-pill::after,
  .explore-fuel-pill::after {
    content: "";
    position: absolute;
    inset: -4px 0;
  }

  .autocomplete-item {
    min-block-size: 44px;
  }
}

