:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --tg-fallback-bg: #ffffff;
  --tg-fallback-surface: #f4f4f5;
  --tg-fallback-text: #111827;
  --tg-fallback-muted: #707579;
  --tg-fallback-link: #2481cc;
  --tg-fallback-button: #2481cc;
  --tg-fallback-button-text: #ffffff;
  --bg: var(--tg-theme-bg-color, var(--tg-fallback-bg));
  --surface: var(--tg-theme-secondary-bg-color, var(--tg-fallback-surface));
  --section: var(--tg-theme-section-bg-color, var(--surface));
  --text: var(--tg-theme-text-color, var(--tg-fallback-text));
  --muted: var(--tg-theme-hint-color, var(--tg-fallback-muted));
  --link: var(--tg-theme-link-color, var(--tg-fallback-link));
  --button: var(--tg-theme-button-color, var(--tg-fallback-button));
  --button-text: var(--tg-theme-button-text-color, var(--tg-fallback-button-text));
  --border: var(--tg-theme-section-separator-color, color-mix(in srgb, var(--text) 12%, transparent));
  --control: color-mix(in srgb, var(--button) 12%, var(--surface));
  --control-hover: color-mix(in srgb, var(--button) 18%, var(--surface));
  --active-surface: color-mix(in srgb, var(--button) 12%, var(--surface));
  --shadow: rgb(0 0 0 / 18%);
  --green: #31a24c;
  --red: #e53935;
  --amber: #f2a900;
  --gray: #8a8f98;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tg-fallback-bg: #17212b;
    --tg-fallback-surface: #232e3c;
    --tg-fallback-text: #f5f5f5;
    --tg-fallback-muted: #708499;
    --tg-fallback-link: #6ab3f3;
    --tg-fallback-button: #5288c1;
    --tg-fallback-button-text: #ffffff;
    --shadow: rgb(0 0 0 / 36%);
  }
}

html[data-theme="dark"] {
  --tg-fallback-bg: #17212b;
  --tg-fallback-surface: #232e3c;
  --tg-fallback-text: #f5f5f5;
  --tg-fallback-muted: #708499;
  --tg-fallback-link: #6ab3f3;
  --tg-fallback-button: #5288c1;
  --tg-fallback-button-text: #ffffff;
  --shadow: rgb(0 0 0 / 36%);
}

* {
  box-sizing: border-box;
}

/* Critical Leaflet layout fallback in case CDN CSS is unavailable. */
.leaflet-container {
  background: var(--surface);
  overflow: hidden;
  position: relative;
  touch-action: pan-x pan-y;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  left: 0;
  position: absolute;
  top: 0;
}

.more--wrap {
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 9999;
}

.hidden {
  display: none !important;
}

.leaflet-tile {
  border: 0;
  height: 256px;
  user-select: none;
  width: 256px;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-map-pane canvas,
.leaflet-map-pane svg {
  z-index: 400;
}

.leaflet-control {
  clear: both;
  float: left;
  pointer-events: auto;
  position: relative;
  z-index: 800;
}

.leaflet-top,
.leaflet-bottom {
  pointer-events: none;
  position: absolute;
  z-index: 1000;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-right .leaflet-control {
  float: right;
  margin-right: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-control-zoom a {
  background: var(--section);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  display: block;
  font-size: 18px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  width: 30px;
}

.leaflet-control-zoom a:first-child {
  border-radius: 4px 4px 0 0;
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0;
  border-radius: 0 0 4px 4px;
}

.leaflet-popup {
  margin-bottom: 20px;
  position: absolute;
  text-align: center;
}

.leaflet-popup-content-wrapper {
  background: var(--section);
  border-radius: 6px;
  box-shadow: 0 2px 10px var(--shadow);
  padding: 1px;
  text-align: left;
}

.leaflet-popup-content {
  line-height: 1.4;
  margin: 12px;
}

.leaflet-popup-tip-container {
  height: 20px;
  left: 50%;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  width: 40px;
}

.leaflet-popup-tip {
  background: var(--section);
  box-shadow: 0 2px 10px var(--shadow);
  height: 14px;
  margin: -8px auto 0;
  transform: rotate(45deg);
  width: 14px;
}

html,
body,
.app {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  flex: none;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.header-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

button {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 8px 10px;
}

button:hover {
  background: var(--control-hover);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.summary div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--section);
  padding: 10px;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.station-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.station-item {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--section);
  margin-bottom: 10px;
  padding: 12px;
  text-align: left;
}

.station-item:hover,
.station-item.active {
  border-color: var(--button);
  background: var(--active-surface);
}

.station-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.station-title strong {
  overflow-wrap: anywhere;
}

.pill {
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px;
  white-space: nowrap;
}

.pill.green {
  background: var(--green);
}

.pill.red {
  background: var(--red);
}

.pill.amber {
  background: var(--amber);
}

.pill.gray {
  background: var(--gray);
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.map-wrap,
#map {
  min-width: 0;
  flex: 1;
  min-height: 0;
  height: 100%;
  overscroll-behavior: none;
}

.leaflet-tile.tile-error {
  background: var(--surface);
}

.station-marker {
  align-items: center;
  display: flex;
  justify-content: center;
}

.station-marker-icon {
  align-items: center;
  background: var(--section);
  border: 2px solid var(--gray);
  border-radius: 999px;
  box-shadow: 0 3px 10px var(--shadow);
  color: var(--gray);
  display: flex;
  height: 34px;
  justify-content: center;
  position: relative;
  width: 34px;
}

.station-marker.favorite .station-marker-icon {
  border-color: currentColor;
  box-shadow:
    0 0 0 4px #f2c94c,
    0 0 0 7px rgb(242 201 76 / 34%),
    0 4px 12px var(--shadow);
}

.station-marker.green .station-marker-icon {
  border-color: var(--green);
  color: var(--green);
}

.station-marker.red .station-marker-icon {
  border-color: var(--red);
  color: var(--red);
}

.station-marker.amber .station-marker-icon {
  border-color: var(--amber);
  color: var(--amber);
}

.station-marker-icon svg {
  display: block;
  height: 21px;
  width: 21px;
}

.station-marker-favorite {
  align-items: center;
  background: #f2c94c;
  border: 1px solid #fff8d6;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgb(0 0 0 / 28%);
  color: #3b2f00;
  display: flex;
  font-size: 11px;
  font-weight: 800;
  height: 17px;
  justify-content: center;
  line-height: 1;
  position: absolute;
  right: -7px;
  top: -7px;
  width: 17px;
}

.popup {
  min-width: 210px;
}

.popup h2 {
  font-size: 16px;
  margin: 0 0 8px;
}

.popup p {
  margin: 5px 0;
}

.popup a {
  color: var(--link);
}

.report-panel {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 10px;
}

.report-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 8px 0 6px;
  text-transform: uppercase;
}

.report-fuel-grid {
  display: grid;
  gap: 6px;
}

.report-fuel-row {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-columns: 34px 1fr 1fr;
}

.report-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.report-panel button {
  background: var(--control);
  font-size: 12px;
  line-height: 1;
  padding: 7px 8px;
}

.report-panel button.success,
.report-panel button.success:hover {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.report-panel button.danger,
.report-panel button.danger:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.report-save {
  margin-top: 8px;
  width: 100%;
}

.report-message {
  color: var(--muted);
  font-size: 12px;
  min-height: 17px;
  padding-top: 7px;
}

.fuel-status-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 8px 0;
}

.fuel-status-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--gray);
  border-radius: 7px;
  display: grid;
  gap: 3px;
  padding: 7px;
}

.fuel-status-card.green {
  border-left-color: var(--green);
}

.fuel-status-card.red {
  border-left-color: var(--red);
}

.fuel-status-card.amber {
  border-left-color: var(--amber);
}

.fuel-status-card strong {
  color: var(--text);
  font-size: 13px;
}

.fuel-status-card span {
  color: var(--text);
  font-size: 12px;
}

.fuel-status-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.price-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 8px 0;
}

.price-card {
  background: var(--section);
  border: 1px solid var(--border);
  border-radius: 7px;
  display: grid;
  gap: 3px;
  padding: 7px;
}

.price-card strong {
  color: var(--text);
  font-size: 13px;
}

.price-card span {
  color: var(--green);
  font-size: 15px;
  font-weight: 700;
}

.price-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.favorite-button {
  margin-bottom: 8px;
  width: 100%;
}

.favorite-button.active {
  background: color-mix(in srgb, var(--amber) 18%, var(--section));
  border-color: var(--amber);
}

.popup-routes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.popup-routes a {
  background: var(--control);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  font-size: 13px;
  line-height: 1;
  padding: 8px 10px;
  text-decoration: none;
}

.menu-button {
  width: 40px;
  height: 40px;
}

.menu-button svg,
.menu-button svg path {
  color: var(--text);
  fill: currentColor !important;
  stroke: currentColor !important;
}

.theme-icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-icon-moon {
  display: block;
}

.menu-button svg {
  width: 100%;
  height: 100%;
}
.menu-button-close-wrap {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.menu--main {
  background: var(--bg);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px;
}

.menu-toggle {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--control);
  color: var(--text);
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
}

.menu-toggle input {
  accent-color: var(--button);
  flex: none;
  height: 18px;
  margin: 0;
  width: 18px;
}

.station-cluster {
  align-items: center;
  display: flex;
  justify-content: center;
}

.station-cluster-ring {
  align-items: center;
  background: var(--cluster-gradient, conic-gradient(currentColor 0 100%));
  border: 3px solid rgb(255 255 255 / 92%);
  border-radius: 999px;
  box-shadow: 0 5px 16px rgb(15 23 42 / 34%);
  color: var(--gray);
  display: flex;
  height: 48px;
  justify-content: center;
  padding: 5px;
  width: 48px;
}

.station-cluster-count {
  align-items: center;
  background: #0f1729;
  border-radius: 999px;
  color: #fff;
  display: flex;
  font-size: 15px;
  font-weight: 800;
  height: 32px;
  justify-content: center;
  min-width: 32px;
  padding: 0 4px;
}

.station-cluster.green .station-cluster-ring {
  color: var(--green);
}

.station-cluster.red .station-cluster-ring {
  color: var(--red);
}

.station-cluster.amber .station-cluster-ring {
  color: var(--amber);
}

.station-cluster.favorite .station-cluster-ring {
  box-shadow:
    0 0 0 4px #f2c94c,
    0 5px 16px rgb(15 23 42 / 34%);
}

.menu-toggle span {
  font-size: 14px;
  line-height: 1.25;
}

.panel-heading {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}

.panel-heading h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.panel-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.station-detail-wrap {
  overflow: auto;
}

.station-detail-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 14px 18px;
}

.station-detail {
  display: grid;
  gap: 12px;
}

.station-detail-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 4px 0 12px;
}

.station-detail-header h2 {
  font-size: 22px;
  line-height: 1.15;
  margin: 0;
  overflow-wrap: anywhere;
}

.station-detail-header p {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

.station-detail-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.station-detail-section h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

.station-detail-section p {
  margin: 5px 0;
}

.support-content {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 14px;
}

.support-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--section);
  display: grid;
  gap: 10px;
  padding: 12px;
}

.support-section h3 {
  font-size: 15px;
  margin: 0;
}

.support-stars {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.support-star-button,
.support-link {
  align-items: center;
  background: var(--button);
  border: 1px solid var(--button);
  border-radius: 7px;
  color: var(--button-text);
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 10px 12px;
  text-align: center;
  text-decoration: none;
}

.support-star-button:hover,
.support-link:hover {
  background: color-mix(in srgb, var(--button) 88%, var(--text));
}

.stats-content {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 14px;
}

.stats-section {
  display: grid;
  gap: 10px;
}

.stats-section h3 {
  font-size: 15px;
  margin: 0;
}

.stats-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--section);
  padding: 10px;
}

.stats-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.25;
}

.stats-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
  margin-top: 5px;
}
@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 44% 56%;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .header {
    padding: 14px;
  }

  .header-actions {
    flex-direction: column;
  }

  .summary, .summary-top {
    padding: 10px 14px;
  }
}
