/* FuelDash R98 — scoped consistency layer loaded after R97. */
:root {
  --fd-r98-page: #f5f5f7;
  --fd-r98-map: #ececef;
  --fd-r98-surface: #ffffff;
  --fd-r98-control: #f1f1f4;
  --fd-r98-control-soft: #f7f7f9;
  --fd-r98-border: #d4d4da;
  --fd-r98-text: #171719;
  --fd-r98-muted: #74747b;
  --fd-r98-red: #ff3b30;
}

/* Exact light PWA/page surface. System chrome receives the same theme color from R98 JS. */
html[data-fd-theme="light"],
html[data-fd-theme="light"] body,
html[data-fd-theme="light"] #app,
html[data-fd-theme="light"] #app .app-shell,
html[data-fd-theme="light"] #app .app-content {
  background-color: var(--fd-r98-page) !important;
  background-image: none !important;
}
html[data-fd-theme="light"] #app .brand-header {
  background: var(--fd-r98-page) !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

/* Dashboard best-price map now matches the light detail map instead of a dark glass hero. */
html[data-fd-theme="light"] #app .fd-best {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-map) !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: 0 5px 16px rgba(24, 24, 28, .055) !important;
}
html[data-fd-theme="light"] #app .fd-best__map {
  background: var(--fd-r98-map) !important;
  opacity: 1 !important;
  filter: none !important;
}
html[data-fd-theme="light"] #app .fd-best__map .leaflet-container {
  background: var(--fd-r98-map) !important;
}
html[data-fd-theme="light"] #app .fd-best__map .leaflet-tile-pane,
html[data-fd-theme="light"] #app .detail-map .leaflet-tile-pane,
html[data-fd-theme="light"] #app .station-mini-map .leaflet-tile-pane {
  filter: invert(.92) grayscale(1) saturate(.12) brightness(1.14) contrast(.78) !important;
}
html[data-fd-theme="light"] #app .fd-best::after {
  display: block !important;
  content: "" !important;
  background: linear-gradient(90deg, rgba(255,255,255,.72) 0%, rgba(255,255,255,.52) 52%, rgba(255,255,255,.10) 100%) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html[data-fd-theme="light"] #app .fd-best__label,
html[data-fd-theme="light"] #app .fd-best__station {
  color: var(--fd-r98-text) !important;
  text-shadow: none !important;
}
html[data-fd-theme="light"] #app .fd-best__meta,
html[data-fd-theme="light"] #app .fd-best__trend,
html[data-fd-theme="light"] #app .fd-best__trend i,
html[data-fd-theme="light"] #app .fd-best__chevron {
  color: var(--fd-r98-muted) !important;
  text-shadow: none !important;
}

/* Search sorting: light parent surface and consistent button family. */
html[data-fd-theme="light"] #app .station-sort {
  padding: 4px !important;
  border: 1px solid var(--fd-r98-border) !important;
  border-radius: 18px !important;
  background: var(--fd-r98-control-soft) !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}
html[data-fd-theme="light"] #app .station-sort button {
  min-height: 42px !important;
  border: 1px solid var(--fd-r98-border) !important;
  border-radius: 14px !important;
  background: var(--fd-r98-surface) !important;
  color: #4f4f56 !important;
  box-shadow: none !important;
}
html[data-fd-theme="light"] #app .station-sort button:is(.is-active,[aria-pressed="true"],[aria-selected="true"]) {
  border-color: var(--fd-r98-red) !important;
  background: var(--fd-r98-red) !important;
  color: #fff !important;
}

/* More-menu values use the same thin hierarchy as “Aktiv”. */
#app .menu-card button em {
  font-style: normal !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
}
#app .menu-card button.about-build em { font-weight: 400 !important; }

/* Appearance and Tankbook: header is outside the scroll container. */
.fd-feature-page {
  overflow: hidden !important;
}
.fd-feature-shell {
  display: flex !important;
  flex-direction: column !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
.fd-feature-header {
  position: relative !important;
  top: auto !important;
  flex: 0 0 auto !important;
  z-index: 20 !important;
}
.fd-feature-content {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
}
html[data-fd-theme="light"] .fd-feature-header {
  background: var(--fd-r98-page) !important;
  border-bottom: 1px solid rgba(28,28,32,.08) !important;
  box-shadow: none !important;
}

/* Price alerts keep a physically fixed header and receive the light surface language. */
.fd-alert-head { position: fixed !important; }
html[data-fd-theme="light"] .fd-alert-modal {
  background: var(--fd-r98-page) !important;
  color: var(--fd-r98-text) !important;
}
html[data-fd-theme="light"] .fd-alert-head {
  background: var(--fd-r98-page) !important;
  border-bottom-color: rgba(28,28,32,.08) !important;
  color: var(--fd-r98-text) !important;
}
html[data-fd-theme="light"] .fd-alert-close,
html[data-fd-theme="light"] .fd-alert-row,
html[data-fd-theme="light"] .fd-alert-station,
html[data-fd-theme="light"] .fd-alert-empty,
html[data-fd-theme="light"] .fd-alert-status {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-surface) !important;
  color: var(--fd-r98-text) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}
html[data-fd-theme="light"] .fd-alert-row :where(small),
html[data-fd-theme="light"] .fd-alert-station small,
html[data-fd-theme="light"] .fd-alert-note { color: var(--fd-r98-muted) !important; }
html[data-fd-theme="light"] .fd-alert-row :where(select,input[type="time"],input[type="number"]) {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-control-soft) !important;
  color: var(--fd-r98-text) !important;
}

/* Tankbook cloud card and account dialog. */
.fd-account-card {
  display: grid !important;
  gap: 16px !important;
  border-radius: 24px !important;
  padding: 20px !important;
}
.fd-account-card__copy { min-width: 0; }
.fd-account-card__eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fd-account-card__eyebrow > small {
  color: var(--fd-r98-red) !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: .16em !important;
}
.fd-account-card__eyebrow > span {
  flex: 0 0 auto;
  color: var(--fd-r98-muted);
  font-size: 10px;
  font-weight: 400;
}
.fd-account-card h2 { margin: 7px 0 0 !important; }
.fd-account-card p { margin: 10px 0 0 !important; line-height: 1.5 !important; }
.fd-account-card > button,
.fd-account-card__action {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  width: 100% !important;
  min-height: 48px !important;
  padding: 11px 14px !important;
  border: 1px solid var(--fd-r98-border) !important;
  border-radius: 16px !important;
  background: var(--fd-r98-control) !important;
  background-image: none !important;
  color: #4f4f56 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}
.fd-account-card__action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html[data-fd-theme="light"] .fd-account-card {
  border: 1px solid var(--fd-r98-border) !important;
  background: var(--fd-r98-surface) !important;
  box-shadow: 0 5px 16px rgba(24,24,28,.05) !important;
}

body.fd-account-open { overflow: hidden !important; }
.fd-account-sheet {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483200 !important;
  display: grid !important;
  align-items: end !important;
  justify-items: center !important;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)) !important;
  box-sizing: border-box !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .16s ease, visibility .16s ease;
}
.fd-account-sheet.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto !important;
}
.fd-account-sheet__backdrop {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: rgba(0,0,0,.42) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
}
.fd-account-sheet__panel {
  position: relative !important;
  z-index: 1 !important;
  width: min(calc(100vw - 16px), 560px) !important;
  max-width: calc(100vw - 16px) !important;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))) !important;
  box-sizing: border-box !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 20px !important;
  border: 1px solid rgba(255,255,255,.1) !important;
  border-radius: 26px !important;
  background: #111114 !important;
  color: #fff !important;
  box-shadow: 0 24px 60px rgba(0,0,0,.48) !important;
  transform: translateY(18px);
  transition: transform .18s cubic-bezier(.22,.72,.25,1);
}
.fd-account-sheet.is-visible .fd-account-sheet__panel { transform: translateY(0); }
.fd-account-sheet__panel > header {
  position: sticky;
  top: -20px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: -20px -20px 0;
  padding: 20px 20px 14px;
  background: #111114;
}
.fd-account-sheet__panel > header small {
  color: var(--fd-r98-red);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
}
.fd-account-sheet__panel > header h2 { margin: 5px 0 0; font-size: 24px; }
.fd-account-sheet__panel > header > button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  background: #242428;
  color: #fff;
  font-size: 24px;
}
.fd-auth-form { max-width: 100%; }
.fd-auth-form input { max-width: 100%; }
.fd-auth-secondary {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: #242428;
  color: #fff;
}

.fd-account-sheet__panel .fd-auth-switch button {
  min-height: 40px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
}
.fd-account-sheet__panel .fd-auth-form > label > span {
  font-size: 12px !important;
  font-weight: 600 !important;
}
.fd-account-sheet__panel .fd-auth-form > label > small,
.fd-account-sheet__panel .fd-auth-explanation {
  font-size: 11px !important;
}
.fd-account-sheet__panel .fd-auth-form input {
  min-height: 48px !important;
  font-size: 15px !important;
  border-radius: 15px !important;
}
.fd-account-sheet__panel .fd-auth-primary,
.fd-account-sheet__panel .fd-auth-secondary {
  min-height: 48px !important;
  font-size: 14px !important;
  font-weight: 650 !important;
}

html[data-fd-theme="light"] .fd-account-sheet__panel,
html[data-fd-theme="light"] .fd-account-sheet__panel > header {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-surface) !important;
  color: var(--fd-r98-text) !important;
}
html[data-fd-theme="light"] .fd-account-sheet__panel { box-shadow: 0 24px 60px rgba(24,24,28,.20) !important; }
html[data-fd-theme="light"] .fd-account-sheet__panel > header > button,
html[data-fd-theme="light"] .fd-auth-secondary {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-control) !important;
  color: #4f4f56 !important;
}
html[data-fd-theme="light"] .fd-auth-switch {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-control-soft) !important;
}
html[data-fd-theme="light"] .fd-auth-form input {
  border-color: var(--fd-r98-border) !important;
  background: var(--fd-r98-control-soft) !important;
  color: var(--fd-r98-text) !important;
}

@media (max-width: 360px) {
  .fd-account-sheet__panel { padding: 16px !important; border-radius: 22px !important; }
  .fd-account-sheet__panel > header { top: -16px; margin: -16px -16px 0; padding: 16px 16px 12px; }
}
