:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #232733;
  --text: #e8eaed;
  --muted: #9aa0ac;
  --green: #2ecc71;
  --orange: #f39316;
  --yellow: #f4c020;
  --red: #e74c3c;
  --gray: #8b929e;
  --accent: #3aa0ff;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden;
}

#map { position: absolute; inset: 0; top: 52px; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--panel);
  border-bottom: 1px solid #00000040;
}
.brand { font-weight: 700; font-size: 17px; margin: 0; }
.brand span { color: var(--accent); }
.info-btn { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.big { width: 16px; height: 16px; }
.dot.green { background: var(--green); }
.dot.orange { background: var(--orange); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }
.dot.gray { background: var(--gray); }

/* Floating action button */
.fab {
  position: fixed; right: 14px; bottom: calc(20px + var(--safe-bottom)); z-index: 900;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--panel-2); color: var(--text); font-size: 20px;
  box-shadow: 0 4px 16px #0008; cursor: pointer;
}

/* Updated pill */
.updated-pill {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 800;
  background: var(--panel); color: var(--muted); font-size: 12px;
  padding: 5px 12px; border-radius: 999px; box-shadow: 0 2px 10px #0006;
}

/* Bottom sheet */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100;
  background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + var(--safe-bottom));
  box-shadow: 0 -6px 30px #000a;
  transform: translateY(0); transition: transform .25s ease;
  max-height: 80vh; overflow-y: auto;
}
.sheet.hidden { transform: translateY(110%); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: #4a4f5a; margin: 6px auto 10px; }
.sheet-close {
  position: absolute; right: 12px; top: 10px; background: none; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer;
}
.sheet-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.st-name { font-size: 18px; font-weight: 700; }
.st-address { font-size: 13px; color: var(--muted); }

.freshness {
  font-size: 13px; color: var(--muted); margin: 4px 0 12px;
  padding: 8px 12px; background: var(--panel-2); border-radius: 10px;
}
.freshness b { color: var(--text); }

.fuels { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fuel-chip {
  font-size: 13px; padding: 6px 10px; border-radius: 999px;
  background: var(--panel-2); display: flex; align-items: center; gap: 6px;
}
.fuel-chip.available { box-shadow: inset 0 0 0 1.5px var(--green); }
.fuel-chip.unavailable { box-shadow: inset 0 0 0 1.5px var(--red); }
.fuel-chip .age { color: var(--muted); font-size: 11px; }

.report-box { border-top: 1px solid #ffffff14; padding-top: 12px; }
.report-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.fuel-select { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fuel-opt {
  font-size: 13px; padding: 6px 10px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); border: 1.5px solid transparent;
}
.fuel-opt.active { border-color: var(--accent); color: var(--accent); }

.report-actions { display: flex; gap: 10px; }
.btn {
  flex: 1; padding: 13px; border: none; border-radius: 12px; font-size: 15px;
  font-weight: 600; cursor: pointer; color: #fff;
}
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn:active { transform: scale(.98); }
.report-msg { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 18px; }

/* Текущий статус + переподтверждение */
.st-status { margin: 4px 0 14px; }
.st-status .ss-card { padding: 13px 14px; border-radius: 14px; background: var(--panel-2); }
.st-status .ss-label { font-size: 18px; font-weight: 700; }
.st-status .ss-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.st-status .ss-badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; margin-top: 8px; }
.st-status .ss-fuels { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.st-status .ss-fuel { font-size: 12px; font-weight: 700; color: var(--green); background: rgba(46,204,113,.14); border: 1px solid rgba(46,204,113,.3); border-radius: 8px; padding: 2px 8px; }
.st-status .ss-confirm { display: flex; gap: 8px; margin-top: 12px; }
.st-status .ss-confirm button { flex: 1; padding: 10px; border-radius: 10px; font-size: 13px; font-weight: 600; border: 1px solid var(--border, #2a2f3a); background: var(--panel-2); color: var(--text); cursor: pointer; }
.st-status .ss-yes { box-shadow: inset 0 0 0 1px rgba(46,204,113,.5); color: var(--green); }

/* Сетка из 4 статусов */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.status-opt { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--panel-2); border: 1.5px solid transparent; color: var(--text); font-size: 14px; font-weight: 600; font-family: inherit; }
.status-opt .so-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.status-opt.active { border-color: currentColor; }
.status-opt[data-status="available"].active { color: var(--green); }
.status-opt[data-status="queue"].active { color: var(--orange); }
.status-opt[data-status="low"].active { color: var(--yellow); }
.status-opt[data-status="unavailable"].active { color: var(--red); }

/* Уточнения (follow-ups) */
.followups { margin: 4px 0 0; }
.fu-group { margin-top: 12px; }
.fu-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.fu-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fu-chip { font-size: 13px; padding: 7px 11px; border-radius: 10px; cursor: pointer;
  background: var(--panel-2); border: 1.5px solid transparent; color: var(--text); }
.fu-chip.on { border-color: var(--accent); color: var(--accent); }

.btn-submit { width: 100%; margin-top: 14px; padding: 14px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-submit:active { transform: scale(.99); }

/* Info overlay */
.info-overlay {
  position: fixed; inset: 0; z-index: 1300;
  background: #000a; display: flex; align-items: flex-end; justify-content: center;
}
.info-overlay.hidden { display: none; }
.info-card {
  position: relative; background: var(--panel); color: var(--text);
  width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(28px + var(--safe-bottom));
}
.info-card h2 { font-size: 17px; margin: 18px 0 6px; }
.info-card h2:first-child { margin-top: 6px; }
.info-card h3 { font-size: 14px; margin: 12px 0 4px; color: var(--accent); }
.info-card p, .info-card li { font-size: 14px; line-height: 1.55; color: #d4d8df; }
.info-card ul { margin: 6px 0 6px 18px; padding: 0; }

@media (min-width: 720px) {
  .info-overlay { align-items: center; }
  .info-card { border-radius: 18px; max-height: 85vh; }
}

/* Toast */
.toast {
  position: fixed; bottom: calc(90px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: #000d; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 1200; transition: opacity .3s;
}
.hidden { display: none; }

@media (min-width: 720px) {
  .sheet { left: auto; right: 16px; bottom: 16px; width: 380px; border-radius: 20px; }
  .updated-pill { left: auto; right: 16px; transform: none; }
}

/* Кнопка «Рядом со мной» + панель ближайших АЗС */
.nearby-btn {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + var(--safe-bottom)); z-index: 900;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 18px; border: none; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
  box-shadow: 0 6px 18px #0007; cursor: pointer;
}
.nearby-btn:active { transform: translateX(-50%) scale(.97); }

.nearby {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1150;
  background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + var(--safe-bottom));
  box-shadow: 0 -6px 30px #000a; transition: transform .25s ease;
  max-height: 72vh; overflow-y: auto;
}
.nearby.hidden { transform: translateY(110%); }
.nearby-title { font-size: 16px; font-weight: 700; margin: 4px 0 12px; }
.nearby-list { display: flex; flex-direction: column; gap: 10px; }
.nb-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--panel-2); cursor: pointer; }
.nb-item:active { background: #2a2f3a; }
.nb-logo { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; background: #2a2f3a; }
.nb-main { flex: 1; min-width: 0; }
.nb-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-addr { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nb-status { font-size: 12px; font-weight: 600; margin-top: 5px; }
.nb-right { text-align: right; flex-shrink: 0; }
.nb-dist { font-size: 15px; font-weight: 700; }
.nb-empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 12px; line-height: 1.5; }

@media (min-width: 720px) {
  .nearby { left: auto; right: 16px; bottom: 16px; width: 380px; border-radius: 18px; }
  .nearby-btn { bottom: 16px; }
}

/* ============ Адаптив: размеры экрана и тип ввода ============ */
/* Легенда: на узких прячем подписи, оставляем цветные точки */
.legend .lg { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 540px) { .legend { gap: 7px; font-size: 11px; } }
@media (max-width: 440px) { .legend .lg-t { display: none; } .legend { gap: 9px; } }

/* Мышь — ховер-состояния; палец — крупнее тапы */
@media (hover: hover) and (pointer: fine) {
  .fab:hover, .info-btn:hover, .nearby-btn:hover { filter: brightness(1.12); }
  .nb-item:hover { background: #2a2f3a; }
  .status-opt:hover { border-color: #3a3f4a; }
  .fu-chip:hover, .btn:hover, .btn-submit:hover { filter: brightness(1.08); }
}
@media (pointer: coarse) {
  .fab { width: 52px; height: 52px; }
  .fu-chip { padding: 9px 13px; }
  .status-opt { padding: 14px; }
}

/* Планшет: панель-карточка справа уже с 720px (см. выше). Десктоп — крупнее и аккуратнее. */
@media (min-width: 1024px) {
  .sheet, .nearby { width: 400px; max-height: 82vh; right: 20px; bottom: 20px; }
  .nearby-btn { left: auto; right: 20px; bottom: 84px; transform: none; }
  .nearby-btn:active { transform: scale(.97); }
  .updated-pill { right: 20px; }
  .fab { right: 20px; }
}
