:root {
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --text-primary: #1C1C1E;
  --text-secondary: #8E8E93;
  --accent: #007AFF;
  --success: #34C759;
  --border: rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.08);
  --radius-card: 16px;
  --radius-pill: 999px;
  --radius-sheet: 20px 20px 0 0;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 100px;
}

/* App header */
app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: block;
}

.app-header {
  background: rgba(242,242,247,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 0.5px solid rgba(0,0,0,0.1);
  padding: 12px 16px 8px;
}

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

.app-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.41px;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.offline-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #FF9500;
  background: rgba(255,149,0,0.12);
  border-radius: var(--radius-pill);
  padding: 3px 8px;
}

.refresh-btn {
  width: 34px;
  height: 34px;
  background: rgba(0,0,0,0.05);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.refresh-btn:disabled { opacity: 0.4; cursor: default; }

.meta-row {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 4px;
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 0.8s linear infinite; }

/* Station list */
station-list { display: block; }

.station-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Skeleton */
.skeleton {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.skeleton-line {
  background: #E5E5EA;
  border-radius: 6px;
  margin-bottom: 8px;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Station card */
.station-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.33,1,0.68,1);
}

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

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

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

.station-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.41px;
  color: var(--text-primary);
  flex: 1;
}

.station-distance {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: 8px;
  padding-top: 2px;
}

.card-row-2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.station-address {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.card-row-3 {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.price-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 72px;
  font-variant-numeric: tabular-nums;
}

.price-chip.best { border-color: var(--success); }

.price-chip-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.price-chip-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

.price-chip.best .price-chip-value { color: var(--success); }

.best-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
  margin-top: 2px;
}

.price-delta {
  font-size: 10px;
  font-weight: 600;
  color: #FF3B30;
  margin-top: 2px;
}

/* Expanded card */
.card-expanded {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.expanded-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.all-prices { display: flex; gap: 8px; flex-wrap: wrap; }

.map-buttons { display: flex; gap: 8px; }

.map-btn {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font);
}

.map-btn.gmaps { background: #E8F0FE; color: #1A73E8; }
.map-btn.waze  { background: #FFF3E0; color: #F4811F; }

/* Filter sheet */
filter-sheet { display: block; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sheet-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.filter-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--surface);
  border-radius: var(--radius-sheet);
  padding: 12px 16px 40px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32,0.72,0,1);
  max-height: 85dvh;
  overflow-y: auto;
}

.filter-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 5px;
  background: #D1D1D6;
  border-radius: var(--radius-pill);
  margin: 0 auto 16px;
}

.sheet-section { margin-bottom: 20px; }

.sheet-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.sheet-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.sheet-clear-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: var(--font);
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.brand-filter-pill {
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  font-family: var(--font);
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-filter-pill.selected { outline-color: var(--accent); }

.brand-filter-pill.brand-unknown {
  font-style: italic;
  opacity: 0.6;
}

.gas-type-row { display: flex; gap: 8px; flex-wrap: wrap; }

.gas-pill {
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text-primary);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s;
  font-family: var(--font);
}

.gas-pill.selected {
  background: #EBF4FF;
  color: var(--accent);
  border-color: var(--accent);
}

.distance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.distance-val { color: var(--accent); font-size: 15px; font-weight: 700; }

.distance-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: var(--radius-pill);
  background: #E5E5EA;
  outline: none;
  cursor: pointer;
}

.distance-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
}

.distance-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  border: none;
}

.segmented-control {
  display: flex;
  background: #E5E5EA;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-option {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.2s;
  font-family: var(--font);
}

.seg-option.active {
  background: white;
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* Filter FAB */
.filter-fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 150;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,122,255,0.4);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon { font-size: 48px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.empty-sub { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.empty-hint {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 14px;
}

.clear-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  font-family: var(--font);
}

/* Geolocation denied */
.location-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60dvh;
  text-align: center;
  padding: 32px;
  gap: 16px;
}

.retry-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
