/* FuelDash R101 — one component contract for feature pages and price alerts. */
:root {
  --fd-r101-red: #ff3b30;
  --fd-r101-light-page: #f5f5f7;
  --fd-r101-light-surface: #ffffff;
  --fd-r101-light-control: #f0f0f3;
  --fd-r101-light-border: #d4d4da;
  --fd-r101-light-text: #171719;
  --fd-r101-light-muted: #74747b;
  --fd-r101-dark-page: #050505;
  --fd-r101-dark-surface: #141416;
  --fd-r101-dark-control: #242428;
  --fd-r101-dark-border: rgba(255,255,255,.11);
  --fd-r101-dark-text: #f7f7f8;
  --fd-r101-dark-muted: #99999f;
  --fd-r101-card-radius: 24px;
  --fd-r101-control-radius: 16px;
  --fd-r101-control-height: 48px;
}

/* A feature page owns the viewport. Only its content column scrolls. */
body.fd-feature-open,
body.fd-account-open { overflow: hidden !important; }
.fd-feature-page {
  overflow: hidden !important;
  overscroll-behavior: none !important;
  background-image: none !important;
}
.fd-feature-page::before,
.fd-feature-page::after,
.fd-feature-shell::before,
.fd-feature-shell::after,
.fd-feature-content::before,
.fd-feature-content::after {
  content: none !important;
  display: none !important;
}
.fd-feature-shell {
  display: flex !important;
  flex-direction: column !important;
  width: min(100%, 480px) !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  padding: 0 !important;
  overflow: hidden !important;
}
.fd-feature-header {
  position: relative !important;
  inset: auto !important;
  z-index: 30 !important;
  flex: 0 0 auto !important;
  display: grid !important;
  grid-template-columns: 48px minmax(0,1fr) !important;
  align-items: start !important;
  gap: 14px !important;
  padding: calc(14px + env(safe-area-inset-top)) 20px 16px !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}
.fd-feature-content {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain !important;
  padding: 16px 20px calc(40px + env(safe-area-inset-bottom)) !important;
  background-image: none !important;
  -webkit-overflow-scrolling: touch !important;
}
html[data-fd-theme="light"],
html[data-fd-theme="light"] body,
html[data-fd-theme="light"] #app,
html[data-fd-theme="light"] .fd-feature-page,
html[data-fd-theme="light"] .fd-feature-shell,
html[data-fd-theme="light"] .fd-feature-header,
html[data-fd-theme="light"] .fd-feature-content {
  background-color: var(--fd-r101-light-page) !important;
  background-image: none !important;
}
html[data-fd-theme="dark"],
html[data-fd-theme="dark"] body,
html[data-fd-theme="dark"] #app,
html[data-fd-theme="dark"] .fd-feature-page,
html[data-fd-theme="dark"] .fd-feature-shell,
html[data-fd-theme="dark"] .fd-feature-header,
html[data-fd-theme="dark"] .fd-feature-content {
  background-color: var(--fd-r101-dark-page) !important;
  background-image: none !important;
}

/* Every navigation control uses the same circle and never keeps the iOS focus halo. */
#app .brand-header .round-button.detail-close,
.fd-feature-back,
.fd-alert-close,
.fd-account-sheet__panel > header > button {
  box-sizing: border-box !important;
  display: grid !important;
  place-items: center !important;
  flex: 0 0 48px !important;
  width: 48px !important;
  min-width: 48px !important;
  max-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  max-height: 48px !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 50% !important;
  outline: none !important;
  box-shadow: none !important;
  filter: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  -webkit-tap-highlight-color: transparent !important;
}
#app .brand-header .round-button.detail-close:focus,
#app .brand-header .round-button.detail-close:focus-visible,
.fd-feature-back:focus,
.fd-feature-back:focus-visible,
.fd-alert-close:focus,
.fd-alert-close:focus-visible,
.fd-account-sheet__panel > header > button:focus,
.fd-account-sheet__panel > header > button:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.fd-feature-back svg,
#app .brand-header .round-button.detail-close svg {
  width: 22px !important;
  height: 22px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
}
html[data-fd-theme="light"] :is(#app .brand-header .round-button.detail-close,.fd-feature-back,.fd-alert-close,.fd-account-sheet__panel > header > button) {
  border: 1px solid var(--fd-r101-light-border) !important;
  background: var(--fd-r101-light-control) !important;
  color: #505057 !important;
}
html[data-fd-theme="dark"] :is(#app .brand-header .round-button.detail-close,.fd-feature-back,.fd-alert-close,.fd-account-sheet__panel > header > button) {
  border: 1px solid var(--fd-r101-dark-border) !important;
  background: var(--fd-r101-dark-control) !important;
  color: var(--fd-r101-dark-text) !important;
}

/* One action hierarchy: red = commit/setup, gray = secondary/export/test. */
.fd-tank-submit,
.fd-account-card__action,
.fd-auth-primary,
.fd-alert-enable {
  box-sizing: border-box !important;
  width: 100% !important;
  min-height: var(--fd-r101-control-height) !important;
  height: var(--fd-r101-control-height) !important;
  padding: 0 16px !important;
  border: 1px solid var(--fd-r101-red) !important;
  border-radius: var(--fd-r101-control-radius) !important;
  background: var(--fd-r101-red) !important;
  background-image: none !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  box-shadow: none !important;
  filter: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.fd-backup-actions button,
.fd-auth-secondary,
.fd-alert-test {
  box-sizing: border-box !important;
  width: 100% !important;
  min-height: var(--fd-r101-control-height) !important;
  height: var(--fd-r101-control-height) !important;
  padding: 0 14px !important;
  border-radius: var(--fd-r101-control-radius) !important;
  background-image: none !important;
  font-size: 13px !important;
  font-weight: 650 !important;
  line-height: 1.2 !important;
  box-shadow: none !important;
  filter: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
html[data-fd-theme="light"] :is(.fd-backup-actions button,.fd-auth-secondary,.fd-alert-test) {
  border: 1px solid var(--fd-r101-light-border) !important;
  background: var(--fd-r101-light-control) !important;
  color: #4f4f56 !important;
}
html[data-fd-theme="dark"] :is(.fd-backup-actions button,.fd-auth-secondary,.fd-alert-test) {
  border: 1px solid var(--fd-r101-dark-border) !important;
  background: var(--fd-r101-dark-control) !important;
  color: var(--fd-r101-dark-text) !important;
}
.fd-account-card__action { justify-content: center !important; }
.fd-account-card__action svg { display: none !important; }

/* Tankbook field rhythm. No phantom status row or oversized gap. */
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-tank-form {
  gap: 12px !important;
  margin-top: 16px !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-tank-extras {
  grid-column: 1 / -1 !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-tank-extras summary {
  display: flex !important;
  align-items: center !important;
  min-height: 40px !important;
  margin: 0 !important;
  padding: 0 2px !important;
  font-size: 15px !important;
  line-height: 1.25 !important;
  cursor: pointer !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-tank-extras > div {
  display: grid !important;
  grid-template-columns: repeat(2,minmax(0,1fr)) !important;
  gap: 12px !important;
  padding-top: 12px !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-tank-extras .fd-field:last-child { grid-column: 1 / -1 !important; }
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-form-status:empty,
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-backup-status:empty { display: none !important; }
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-form-status:not(:empty),
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-backup-status:not(:empty) {
  min-height: 0 !important;
  margin: 0 !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] :is(.fd-field input,.fd-field select,.fd-field textarea) {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  border-radius: var(--fd-r101-control-radius) !important;
  box-shadow: none !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] :is(.fd-field input,.fd-field select) {
  min-height: var(--fd-r101-control-height) !important;
  height: var(--fd-r101-control-height) !important;
}
.fd-feature-page[data-fd-feature-view="tankbook"] .fd-field textarea { min-height: 96px !important; }

/* Price alerts: one internal scroll area, stationary header, identical cards and controls. */
.fd-alert-modal {
  box-sizing: border-box !important;
  overflow: hidden !important;
  padding: 0 !important;
  background-image: none !important;
}
.fd-alert-sheet {
  box-sizing: border-box !important;
  display: block !important;
  width: min(100%,560px) !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  max-height: 100dvh !important;
  margin: 0 auto !important;
  padding: 0 14px calc(120px + env(safe-area-inset-bottom)) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior-y: contain !important;
  scroll-padding-top: calc(92px + env(safe-area-inset-top)) !important;
  -webkit-overflow-scrolling: touch !important;
}
.fd-alert-head {
  position: sticky !important;
  top: 0 !important;
  left: auto !important;
  transform: none !important;
  z-index: 40 !important;
  box-sizing: border-box !important;
  width: auto !important;
  height: auto !important;
  min-height: calc(78px + env(safe-area-inset-top)) !important;
  margin: 0 -2px 12px !important;
  padding: calc(14px + env(safe-area-inset-top)) 2px 14px !important;
  background-image: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}
.fd-alert-head h2 { font-size: 28px !important; }
.fd-alert-grid { display: grid !important; gap: 10px !important; }
.fd-alert-row,
.fd-alert-station,
.fd-alert-empty,
.fd-alert-status {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  border-radius: 20px !important;
  background-image: none !important;
  box-shadow: none !important;
  filter: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.fd-alert-row {
  min-height: 72px !important;
  padding: 12px 14px !important;
}
.fd-alert-station {
  min-height: 70px !important;
  padding: 11px 14px !important;
}
.fd-alert-stations { gap: 10px !important; }
.fd-alert-station-section { margin-top: 18px !important; }
.fd-alert-station-section > header {
  padding: 0 2px 10px !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
}
.fd-alert-station-section h3 { font-size: 19px !important; }
.fd-alert-row :is(select,input[type="time"],input[type="number"]) {
  box-sizing: border-box !important;
  flex: 0 0 auto !important;
  min-height: var(--fd-r101-control-height) !important;
  height: var(--fd-r101-control-height) !important;
  padding: 0 12px !important;
  border-radius: 14px !important;
  box-shadow: none !important;
  font-size: 15px !important;
  line-height: 1 !important;
}
.fd-alert-row select { width: 136px !important; max-width: 136px !important; }
.fd-alert-row input[type="time"] { width: 112px !important; min-width: 112px !important; max-width: 112px !important; text-align: center !important; }
.fd-alert-row input[type="number"] { width: 72px !important; min-width: 72px !important; max-width: 72px !important; text-align: center !important; }
.fd-alert-row input[type="time"]::-webkit-date-and-time-value { text-align: center !important; }
.fd-alert-modal input[type="checkbox"] {
  box-sizing: border-box !important;
  flex: 0 0 24px !important;
  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
  height: 24px !important;
  min-height: 24px !important;
  max-height: 24px !important;
  margin: 0 0 0 auto !important;
  padding: 0 !important;
  border-radius: 7px !important;
  outline: none !important;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}
.fd-alert-modal input[type="checkbox"]::after {
  display: block !important;
  width: 7px !important;
  height: 12px !important;
  margin: 3px auto 0 !important;
  content: "" !important;
  border: solid #fff !important;
  border-width: 0 2px 2px 0 !important;
  opacity: 0 !important;
  transform: rotate(45deg) !important;
}
.fd-alert-modal input[type="checkbox"]:checked {
  border-color: var(--fd-r101-red) !important;
  background: var(--fd-r101-red) !important;
}
.fd-alert-modal input[type="checkbox"]:checked::after { opacity: 1 !important; }
.fd-alert-actions {
  display: grid !important;
  grid-template-columns: minmax(0,1.3fr) minmax(0,1fr) !important;
  gap: 10px !important;
  margin-top: 16px !important;
}
.fd-alert-actions button {
  min-height: var(--fd-r101-control-height) !important;
  height: var(--fd-r101-control-height) !important;
  padding: 0 12px !important;
  border-radius: var(--fd-r101-control-radius) !important;
  box-shadow: none !important;
  transform: none !important;
}
.fd-alert-note { margin: 16px 2px 0 !important; }

html[data-fd-theme="light"] :is(.fd-alert-modal,.fd-alert-sheet,.fd-alert-head) {
  background-color: var(--fd-r101-light-page) !important;
  color: var(--fd-r101-light-text) !important;
}
html[data-fd-theme="light"] .fd-alert-head { border-bottom: 1px solid rgba(28,28,32,.08) !important; }
html[data-fd-theme="light"] :is(.fd-alert-row,.fd-alert-station,.fd-alert-empty,.fd-alert-status) {
  border: 1px solid var(--fd-r101-light-border) !important;
  background: var(--fd-r101-light-surface) !important;
  color: var(--fd-r101-light-text) !important;
}
html[data-fd-theme="light"] .fd-alert-row :is(select,input[type="time"],input[type="number"]) {
  border: 1px solid var(--fd-r101-light-border) !important;
  background: var(--fd-r101-light-control) !important;
  color: var(--fd-r101-light-text) !important;
}
html[data-fd-theme="light"] .fd-alert-modal input[type="checkbox"] {
  border: 1px solid var(--fd-r101-light-border) !important;
  background: var(--fd-r101-light-control) !important;
}
html[data-fd-theme="light"] .fd-alert-modal input[type="checkbox"]:checked {
  border-color: var(--fd-r101-red) !important;
  background: var(--fd-r101-red) !important;
}
html[data-fd-theme="dark"] :is(.fd-alert-modal,.fd-alert-sheet,.fd-alert-head) {
  background-color: var(--fd-r101-dark-page) !important;
  color: var(--fd-r101-dark-text) !important;
}
html[data-fd-theme="dark"] .fd-alert-head { border-bottom: 1px solid rgba(255,255,255,.07) !important; }
html[data-fd-theme="dark"] :is(.fd-alert-row,.fd-alert-station,.fd-alert-empty,.fd-alert-status) {
  border: 1px solid var(--fd-r101-dark-border) !important;
  background: var(--fd-r101-dark-surface) !important;
  color: var(--fd-r101-dark-text) !important;
}
html[data-fd-theme="dark"] .fd-alert-row :is(select,input[type="time"],input[type="number"]) {
  border: 1px solid var(--fd-r101-dark-border) !important;
  background: var(--fd-r101-dark-control) !important;
  color: var(--fd-r101-dark-text) !important;
}
html[data-fd-theme="dark"] .fd-alert-modal input[type="checkbox"] {
  border: 1px solid var(--fd-r101-dark-border) !important;
  background: var(--fd-r101-dark-control) !important;
}
html[data-fd-theme="dark"] .fd-alert-modal input[type="checkbox"]:checked {
  border-color: var(--fd-r101-red) !important;
  background: var(--fd-r101-red) !important;
}

@media (max-width: 360px) {
  .fd-feature-header { grid-template-columns: 46px minmax(0,1fr) !important; gap: 12px !important; padding-inline: 16px !important; }
  .fd-feature-content { padding-inline: 16px !important; }
  .fd-feature-back,
  .fd-alert-close { width: 46px !important; min-width: 46px !important; max-width: 46px !important; height: 46px !important; min-height: 46px !important; max-height: 46px !important; }
  .fd-alert-sheet { padding-inline: 12px !important; }
  .fd-alert-row input[type="time"] { width: 104px !important; min-width: 104px !important; max-width: 104px !important; }
  .fd-alert-actions { grid-template-columns: 1fr !important; }
}
/* Theme-specific specificity guard: account setup is a primary action in both themes. */
html[data-fd-theme="light"] .fd-account-card .fd-account-card__action,
html[data-fd-theme="dark"] .fd-account-card .fd-account-card__action {
  border-color: var(--fd-r101-red) !important;
  background: var(--fd-r101-red) !important;
  color: #fff !important;
}
html[data-fd-theme="light"] .fd-feature-page .fd-backup-actions button,
html[data-fd-theme="dark"] .fd-feature-page .fd-backup-actions button {
  min-height: var(--fd-r101-control-height) !important;
  height: var(--fd-r101-control-height) !important;
  padding: 0 14px !important;
  border-radius: var(--fd-r101-control-radius) !important;
}
.fd-alert-station-section {
  background: transparent !important;
  background-image: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
@media (max-width: 360px) {
  .fd-feature-header { grid-template-columns: 48px minmax(0,1fr) !important; }
  .fd-feature-back,
  .fd-alert-close { width: 48px !important; min-width: 48px !important; max-width: 48px !important; height: 48px !important; min-height: 48px !important; max-height: 48px !important; }
}
