/* ============================================================
   ServoSpy — Cockpit Clarity Design System v3
   Full UX/UI audit implementation
   ============================================================ */

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

:root {
  /* Base palette */
  --bg: #0a0a12;
  --bg-raised: #0f0f1c;
  --surface: #151524;
  --surface-2: #1c1c34;
  --surface-3: #24243e;
  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(0, 212, 170, 0.4);

  /* Text */
  --text: #eaeaf2;
  --text-secondary: #9595b2;
  --text-tertiary: #5c5c7a;

  /* Accent */
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --accent-glow: rgba(0, 212, 170, 0.25);

  /* Markup colours */
  --green: #00c853;
  --green-bg: rgba(0, 200, 83, 0.12);
  --green-border: rgba(0, 200, 83, 0.35);
  --yellow: #ffd600;
  --yellow-bg: rgba(255, 214, 0, 0.12);
  --yellow-border: rgba(255, 214, 0, 0.3);
  --red: #ff1744;
  --red-bg: rgba(255, 23, 68, 0.10);
  --red-border: rgba(255, 23, 68, 0.3);

  /* Shared */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-display: 'Bricolage Grotesque', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'DM Mono', 'SF Mono', Consolas, monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --header-h: auto;
  --bottom-bar-h: 56px;
}

/* ---- Skip Link ---- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 10000;
  padding: 12px 20px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 12px;
}

/* ---- Grain Texture Overlay ---- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* ---- Base ---- */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 212, 170, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 212, 170, 0.02) 0%, transparent 50%);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  position: relative;
}

/* ============================================================
   Global Focus-Visible Styles
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Override for specific components that style their own focus */
#location-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ============================================================
   Search Header
   ============================================================ */
#search-bar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top, 0) 0 0;
}

.search-inner {
  padding: 14px 16px 14px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* ---- Brand ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.logo-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-dim);
}

.logo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.3;
  animation: pulse-ring 3s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.08); opacity: 0.15; }
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--text);
}

.brand-accent {
  color: var(--accent);
}

/* ---- Fuel Toggle (Segmented Control) ---- */
.fuel-toggle {
  position: relative;
  display: flex;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}

.fuel-btn {
  position: relative;
  z-index: 1;
  padding: 10px 18px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: calc(var(--radius) - 3px);
  transition: color 0.25s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fuel-btn.active {
  color: var(--bg);
}

.fuel-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: calc(var(--radius) - 3px);
  transition: transform 0.35s var(--ease-spring);
  box-shadow: 0 2px 8px rgba(0, 212, 170, 0.25);
}

.fuel-toggle[data-active="DL"] .fuel-slider {
  transform: translateX(100%);
}

/* ---- Search Input ---- */
.typeahead-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
  transition: color 0.2s;
}

.typeahead-wrap:focus-within .search-icon {
  color: var(--accent);
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-2);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.clear-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.clear-btn.hidden {
  display: none !important;
}

#location-input {
  width: 100%;
  padding: 13px 52px 13px 42px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  outline: none;
  transition: border-color 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), background 0.25s;
  -webkit-appearance: none;
  min-height: 48px;
}

#location-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

#location-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--bg-raised);
}

/* ---- Typeahead Dropdown ---- */
#suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  max-height: min(280px, 40vh);
  overflow-y: auto;
  z-index: 1001;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: dropdown-in 0.2s var(--ease-out);
  overscroll-behavior: contain;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#suggestions li {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

#suggestions li:last-child {
  border-bottom: none;
}

#suggestions li:hover,
#suggestions li.active {
  background: var(--surface-2);
}

#suggestions li.active {
  background: var(--accent-dim);
}

#suggestions li.no-results {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  cursor: default;
  justify-content: center;
}

#suggestions li .suburb-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text);
}

#suggestions li .suburb-name .match {
  color: var(--accent);
  font-weight: 700;
}

#suggestions li .suburb-postcode {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-weight: 400;
  flex-shrink: 0;
}

/* ============================================================
   Hero / Welcome State
   ============================================================ */
#hero {
  padding: 48px 24px 56px;
  text-align: center;
  animation: hero-in 0.8s var(--ease-out) both;
}

@keyframes hero-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hide hero when results, error, or empty states are visible */
#app:has(#wholesale-bar:not(.hidden)) #hero,
#app:has(#error:not(.hidden)) #hero,
#app:has(#empty:not(.hidden)) #hero {
  display: none;
}

/* When loading alongside hero, hide the skeleton cards */
#app:has(#hero:not([style*="display: none"])) #loading .skeleton-cards {
  display: none;
}

#app:has(#hero:not([style*="display: none"])) #loading {
  padding-top: 0;
}

#app:has(#hero:not([style*="display: none"])) #loading .loading-content {
  margin-bottom: 0;
}

/* Radar Visual */
.radar-visual {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 36px;
}

.radar-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--accent);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.radar-ring-1 {
  width: 60px;
  height: 60px;
  opacity: 0.25;
  animation: radar-pulse 3s ease-out infinite;
}

.radar-ring-2 {
  width: 110px;
  height: 110px;
  opacity: 0.15;
  animation: radar-pulse 3s ease-out 0.5s infinite;
}

.radar-ring-3 {
  width: 160px;
  height: 160px;
  opacity: 0.08;
  animation: radar-pulse 3s ease-out 1s infinite;
}

@keyframes radar-pulse {
  0% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.3; }
  50% { transform: translate(-50%, -50%) scale(1); opacity: 0.08; }
  100% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.3; }
}

.radar-sweep {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  transform-origin: 0 0;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(0, 212, 170, 0.12) 40deg, transparent 80deg);
  animation: radar-spin 4s linear infinite;
  border-radius: 0 80px 0 0;
}

@keyframes radar-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.radar-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid rgba(0, 212, 170, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: 0 0 24px rgba(0, 212, 170, 0.1);
}

.radar-blip {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: blip-fade 3s ease-in-out infinite;
}

.radar-blip-1 {
  top: 28%;
  right: 22%;
  animation-delay: 0.2s;
}

.radar-blip-2 {
  bottom: 32%;
  left: 18%;
  animation-delay: 1.2s;
}

.radar-blip-3 {
  top: 52%;
  right: 12%;
  animation-delay: 2s;
}

@keyframes blip-fade {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 0.9; transform: scale(1.2); }
}

.hero-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 12px;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 320px;
  margin: 0 auto 32px;
  line-height: 1.55;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 36px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hero-stat-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent);
}

.hero-stat-label {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.hero-stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.hero-quick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hero-quick-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.hero-quick-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.hero-quick-chips::-webkit-scrollbar {
  display: none;
}

.quick-chip {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.quick-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 12px rgba(0, 212, 170, 0.08);
}

.quick-chip:active {
  transform: scale(0.96);
}

/* ============================================================
   Wholesale Context Bar
   ============================================================ */
#wholesale-bar {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-raised) 0%, var(--bg) 100%);
}

.wholesale-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wholesale-label {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 500;
}

.wholesale-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  opacity: 0.85;
  font-size: 0.72rem;
}

.wholesale-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 12px;
  border-radius: 100px;
}

/* ============================================================
   Colour Legend
   ============================================================ */
#colour-legend {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.legend-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.legend-label {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  white-space: nowrap;
}

.legend-scale {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 240px;
}

.legend-end {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.legend-arrow {
  font-weight: 700;
  margin-right: 2px;
}

.legend-gradient {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    hsl(140, 80%, 55%) 0%,
    hsl(70, 80%, 55%) 50%,
    hsl(0, 80%, 55%) 100%
  );
  min-width: 60px;
}

/* ============================================================
   View Toggle Bar
   ============================================================ */
#view-toggle {
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

#view-toggle.hidden {
  display: none !important;
}

.toggle-bar-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-group {
  position: relative;
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}

.toggle-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 3px);
  transition: color 0.25s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.toggle-btn svg {
  opacity: 0.7;
}

.toggle-btn.active {
  color: var(--text);
}

.toggle-btn.active svg {
  opacity: 1;
}

.toggle-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--surface-3);
  border-radius: calc(var(--radius-sm) - 3px);
  transition: transform 0.3s var(--ease-spring);
}

.toggle-group[data-active="list"] .toggle-slider {
  transform: translateX(100%);
}

/* ---- Sort Toggle ---- */
.sort-group {
  display: flex;
  gap: 4px;
}

.sort-btn {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 12px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.sort-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.sort-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.sort-btn:not(:disabled):hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
}

#station-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ============================================================
   Map
   ============================================================ */
#map-container {
  height: calc(100dvh - 160px);
  min-height: 350px;
  position: relative;
}

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

/* ---- Locate Button ---- */
.locate-btn {
  position: absolute;
  bottom: 24px;
  right: 12px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.locate-btn:hover {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent);
}

.locate-btn.has-location {
  color: var(--accent);
}

/* Leaflet overrides */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border);
  padding: 0;
}

.leaflet-popup-tip {
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.leaflet-popup-content {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.5;
  min-width: 220px;
}

/* Larger close button for accessibility */
.leaflet-popup-close-button {
  width: 32px !important;
  height: 32px !important;
  font-size: 20px !important;
  line-height: 32px !important;
  color: var(--text-tertiary) !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.leaflet-popup-close-button:hover {
  color: var(--text) !important;
}

.popup-card {
  padding: 14px 16px;
}

.popup-name {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 2px;
  color: var(--text);
  padding-right: 20px;
}

.popup-addr {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.popup-prices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.popup-price-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.popup-price-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 500;
}

.popup-price-val {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.popup-markup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.popup-markup-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  font-weight: 500;
}

.popup-markup-badge {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

/* Directions link in popup */
.popup-directions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  padding: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.15s;
  border-radius: 0 0 var(--radius) var(--radius);
  margin: 12px -16px -14px;
  padding: 10px 16px;
  min-height: 44px;
}

.popup-directions:hover {
  background: var(--accent-dim);
}

/* Marker cluster overrides for dark theme */
.marker-cluster {
  background: rgba(0, 212, 170, 0.2) !important;
}

.marker-cluster div {
  background: var(--accent) !important;
  color: var(--bg) !important;
  font-family: var(--font-mono) !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  width: 32px !important;
  height: 32px !important;
  margin-left: 4px !important;
  margin-top: 4px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.marker-cluster-small {
  background: rgba(0, 212, 170, 0.2) !important;
}

.marker-cluster-medium {
  background: rgba(255, 214, 0, 0.2) !important;
}

.marker-cluster-medium div {
  background: #c5a600 !important;
}

.marker-cluster-large {
  background: rgba(255, 23, 68, 0.15) !important;
}

.marker-cluster-large div {
  background: var(--red) !important;
  color: #fff !important;
}

.leaflet-container {
  background: var(--bg) !important;
  font-family: var(--font-body);
}

/* ============================================================
   List View
   ============================================================ */
#list-container {
  padding: 12px 16px 24px;
}

/* Station Card */
.station-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  transition: border-color 0.2s, transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
  animation: card-in 0.4s var(--ease-out) both;
  cursor: default;
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: auto 140px;
}

.station-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  border-left-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.station-card:active {
  transform: scale(0.995);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.station-name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 3px;
}

.station-address {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.station-distance {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Markup badge */
.station-markup {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.markup-icon {
  font-size: 0.85em;
  font-style: normal;
}

/* Price row */
.card-prices {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.price-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  font-weight: 500;
}

.price-retail {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.price-wholesale {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.2;
}

.price-unit {
  font-size: 0.65em;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-left: 2px;
}

/* Directions link on card */
.card-directions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
  min-height: 44px;
}

.card-directions:hover {
  opacity: 0.8;
}

.card-directions svg {
  flex-shrink: 0;
}

/* Best deal indicator */
.station-card.best-deal {
  border-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(0, 200, 83, 0.04) 100%);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.station-card.best-deal:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.best-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.best-tag::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: best-pulse 2s ease-in-out infinite;
}

@keyframes best-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ---- Load More Button ---- */
.load-more-btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  min-height: 48px;
  margin-top: 4px;
  margin-bottom: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.load-more-btn:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
}

/* ============================================================
   Loading
   ============================================================ */
#loading {
  padding: 48px 16px 24px;
}

.loading-content {
  text-align: center;
  margin-bottom: 32px;
}

.spinner {
  position: relative;
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.spinner-ring-2 {
  inset: 5px;
  border-top-color: transparent;
  border-right-color: var(--accent);
  animation-duration: 1.4s;
  animation-direction: reverse;
  opacity: 0.4;
}

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

.loading-text {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Skeleton cards */
.skeleton-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
  max-width: 640px;
  margin: 0 auto;
}

.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.sk-line {
  height: 12px;
  background: var(--surface-2);
  border-radius: 6px;
}

.sk-badge {
  width: 52px;
  height: 28px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sk-w35 { width: 35%; }
.sk-w40 { width: 40%; }
.sk-w45 { width: 45%; }
.sk-w50 { width: 50%; }
.sk-w60 { width: 60%; }
.sk-w70 { width: 70%; }
.sk-w75 { width: 75%; }
.sk-w80 { width: 80%; }

/* ============================================================
   Error / Empty States
   ============================================================ */
#error, #empty {
  text-align: center;
  padding: 64px 24px;
  animation: state-in 0.4s var(--ease-out) both;
}

@keyframes state-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.state-illustration {
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

#error .state-illustration {
  color: var(--red);
}

.state-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.state-desc {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  max-width: 260px;
  margin: 0 auto;
}

.empty-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  position: relative;
  margin-top: 16px;
}

footer::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 100%);
  pointer-events: none;
}

.footer-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 16px 36px;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.logo-mark-sm {
  width: 18px;
  height: 18px;
}

.logo-mark-sm .logo-dot {
  width: 5px;
  height: 5px;
}

.logo-mark-sm .logo-ring {
  border-width: 1.5px;
  animation: none;
  opacity: 0.2;
}

.footer-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  letter-spacing: -0.3px;
}

footer p {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.6;
}

footer strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.footer-note {
  margin-top: 2px;
}

.coverage {
  margin-top: 10px;
  font-weight: 600;
  font-size: 0.7rem !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ============================================================
   Utility
   ============================================================ */
.hidden {
  display: none !important;
}

/* ============================================================
   Mobile — Fixed bottom toggle bar
   ============================================================ */
@media (max-width: 899px) {
  #view-toggle:not(.hidden) {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-top: 1px solid var(--border);
    border-bottom: none;
    background: rgba(10, 10, 18, 0.92);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* Content padding to avoid overlap with bottom bar */
  #list-container {
    padding-bottom: 72px;
  }

  #map-container {
    height: calc(100dvh - 120px);
  }

  .toggle-bar-inner {
    flex-wrap: wrap;
  }

  /* Sort group inline with toggle on mobile */
  .sort-group {
    order: 2;
  }

  #station-count {
    order: 3;
    width: 100%;
    text-align: center;
    font-size: 0.68rem;
    padding-top: 2px;
  }
}

/* ============================================================
   Desktop layout — side-by-side map + list
   ============================================================ */
@media (min-width: 900px) {
  #app {
    max-width: 1200px;
  }

  .search-inner {
    padding: 16px 24px;
  }

  .wholesale-inner,
  .toggle-bar-inner {
    max-width: none;
    padding-left: 24px;
    padding-right: 24px;
  }

  .legend-inner {
    max-width: none;
    padding-left: 24px;
    padding-right: 24px;
  }

  .footer-inner {
    max-width: none;
    padding-left: 24px;
    padding-right: 24px;
  }

  #hero {
    padding: 64px 24px 72px;
  }

  .hero-title {
    font-size: 2.6rem;
    letter-spacing: -1px;
  }

  .hero-subtitle {
    font-size: 1.05rem;
    max-width: 400px;
  }

  .radar-visual {
    width: 220px;
    height: 220px;
    margin-bottom: 42px;
  }

  /* When showing results, use split layout */
  #app.split-view #hero {
    display: none;
  }

  #app.split-view {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
    max-width: none;
    margin: 0;
  }

  #app.split-view #map-container {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    width: 55%;
    height: 100dvh;
    z-index: 1;
  }

  #app.split-view #search-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
  }

  #app.split-view #wholesale-bar,
  #app.split-view #colour-legend,
  #app.split-view #view-toggle {
    flex-shrink: 0;
  }

  #app.split-view #search-bar,
  #app.split-view #wholesale-bar,
  #app.split-view #colour-legend,
  #app.split-view #main-content {
    margin-left: 0;
    margin-right: 55%;
    max-width: none;
  }

  #app.split-view #main-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #app.split-view #list-container {
    padding: 12px 24px 24px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  #app.split-view footer {
    display: none;
  }

  #app.split-view .toggle-group {
    display: none;
  }

  #app.split-view #station-count {
    font-size: 0.82rem;
  }

  #list-container {
    padding-left: 24px;
    padding-right: 24px;
  }

  .skeleton-cards {
    padding: 0 24px;
  }

  #map-container {
    height: calc(100dvh - 180px);
  }

  .station-card {
    padding: 20px 24px;
  }

  .station-card:hover {
    transform: translateY(-2px);
  }
}

/* Wider desktop */
@media (min-width: 1200px) {
  #app.split-view #map-container {
    width: 50%;
  }

  #app.split-view #search-bar,
  #app.split-view #wholesale-bar,
  #app.split-view #colour-legend,
  #app.split-view #main-content {
    margin-left: 0;
    margin-right: 50%;
  }
}

/* Small mobile tweaks */
@media (max-width: 380px) {
  .brand h1 {
    font-size: 1.2rem;
  }

  .fuel-btn {
    padding: 10px 12px;
    font-size: 0.75rem;
  }

  #location-input {
    font-size: 0.9rem;
    padding: 12px 48px 12px 38px;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .hero-stats {
    gap: 14px;
  }

  .hero-stat-value {
    font-size: 0.95rem;
  }

  .sort-group {
    gap: 2px;
  }

  .sort-btn {
    padding: 6px 8px;
    font-size: 0.68rem;
  }
}

/* Touch device hover prevention */
@media (hover: none) {
  .station-card:hover {
    border-color: var(--border);
    box-shadow: none;
    transform: none;
  }
}

/* ============================================================
   Reduced Motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .radar-sweep,
  .radar-ring,
  .radar-blip,
  .logo-ring,
  .spinner-ring,
  .best-tag::before {
    animation: none !important;
  }

  .station-card {
    animation: none !important;
  }
}
