/* === Тема: берём цвета из Telegram WebApp (адаптив под тёмную/светлую) === */
:root {
  --bg:        var(--tg-theme-bg-color, #ffffff);
  --text:      var(--tg-theme-text-color, #000000);
  --hint:      var(--tg-theme-hint-color, #999999);
  --link:      var(--tg-theme-link-color, #2481cc);
  --btn:       var(--tg-theme-button-color, #2481cc);
  --btn-text:  var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f4f4f5);
  --section:   rgba(0, 0, 0, 0.04);
  --separator: rgba(0, 0, 0, 0.08);
  --danger:    #e53935;
  --ok:        #2e7d32;
  --warn:      #fb8c00;
}

/* На тёмной теме — инвертируем полупрозрачные фоны */
@media (prefers-color-scheme: dark) {
  :root {
    --section:   rgba(255, 255, 255, 0.05);
    --separator: rgba(255, 255, 255, 0.10);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px calc(env(safe-area-inset-bottom, 0px) + 16px);
}

/* === Шапка === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  background: var(--bg);
  margin-left: -12px;
  margin-right: -12px;
  padding-left: 12px;
  padding-right: 12px;
  border-bottom: 1px solid var(--separator);
  padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
}
.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--link);
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.icon-btn:active { background: var(--section); }

/* === Сетка лаунчера === */
.launcher-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px 0;
}
.tile {
  background: var(--secondary-bg);
  border: 0;
  border-radius: 14px;
  padding: 18px 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  min-height: 96px;
  transition: transform .1s, background .15s;
  text-align: left;
  font-family: inherit;
}
.tile:active { transform: scale(.97); background: var(--section); }
.tile .emoji { font-size: 28px; line-height: 1; }
.tile .label { font-size: 15px; font-weight: 600; }
.tile .sub   { font-size: 12px; color: var(--hint); font-weight: 400; }

/* === Карточки АЗС (экран статуса) === */
.station-list { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 24px; }
.station {
  background: var(--secondary-bg);
  border-radius: 14px;
  padding: 12px 14px;
}
.station-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.dot.online  { background: var(--ok); }
.dot.offline { background: var(--hint); }
.station-name { font-weight: 600; font-size: 15px; flex: 1; }
.station-addr { font-size: 12px; color: var(--hint); margin-top: 2px; }
.fuels { display: flex; flex-wrap: wrap; gap: 6px; }
.fuel-chip {
  background: var(--section);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 500;
}
.fuel-chip .price { color: var(--hint); margin-left: 4px; font-weight: 400; }
.empty-fuels { font-size: 13px; color: var(--hint); font-style: italic; }

/* === Состояния === */
.state {
  padding: 32px 16px;
  text-align: center;
  color: var(--hint);
}
.state h2 { color: var(--text); margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.state .big { font-size: 40px; margin-bottom: 8px; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--separator);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.about { padding: 14px 0; line-height: 1.55; font-size: 15px; }
.about h3 { margin: 18px 0 6px; font-size: 15px; }
.about ul { padding-left: 18px; margin: 4px 0; }
.about li { margin-bottom: 4px; }

/* === Overlay (ошибки) === */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 24px;
}
.overlay .box {
  background: var(--bg);
  border-radius: 14px;
  padding: 20px;
  max-width: 320px;
  text-align: center;
}
.overlay .box h3 { margin: 0 0 8px; }
.overlay .box p  { margin: 0 0 16px; color: var(--hint); font-size: 14px; }

/* Утилиты */
.hidden { display: none !important; }
.muted { color: var(--hint); }
