/* ===================== bak35 · фирменный стиль Avapt ===================== */
:root {
  --canvas: #F8FAFC;
  --surface: #FFFFFF;
  --pale-mint: #F0FDF4;
  --fog: #F1F5F9;
  --border: #E2E8F0;

  --ink: #1E293B;
  --muted: #64748B;
  --ash: #94A3B8;

  --brand: #46971E;
  --brand-hover: #3a7d18;
  --brand-accent: #BBF7D0;
  --brand-grad: linear-gradient(135deg, #54a826, #3c8417);

  --st-has: #46971E;
  --st-none: #ef4444;
  --st-queue: #f59e0b;
  --st-stale: #94A3B8;

  --shadow-card: 0 4px 15px -3px rgba(0,0,0,.05), 0 2px 6px -2px rgba(0,0,0,.03);
  --shadow-hover: 0 10px 30px -6px rgba(0,0,0,.12), 0 4px 10px -3px rgba(0,0,0,.06);
  --shadow-btn: 0 6px 16px -4px rgba(70,151,30,.45);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, b, strong { letter-spacing: -0.005em; }

/* ===================== Карта ===================== */
#map { position: absolute; inset: 0; width: 100%; height: 100%; }
.maplibregl-ctrl-attrib { font-size: 10px; opacity: .7; }
.maplibregl-ctrl-bottom-left { display: none; }

/* ===================== Шапка ===================== */
.topbar {
  position: absolute;
  top: calc(12px + var(--safe-top));
  left: 12px; right: 12px;
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 12px;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 9px;
  background: var(--brand-grad);
  box-shadow: 0 3px 8px -2px rgba(70,151,30,.5);
}
.brand-text { font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text b { font-weight: 800; }
.brand-sub { color: var(--muted); font-weight: 500; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s, transform .1s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--fog); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn.is-locating { color: var(--brand); border-color: var(--brand-accent); background: var(--pale-mint); }

/* ===================== Чипы-фильтры ===================== */
.filters {
  position: absolute;
  top: calc(66px + var(--safe-top));
  left: 0; right: 0;
  z-index: 19;
  display: flex; gap: 8px;
  padding: 6px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 15px;
  font-family: inherit;
  font-size: 14px; font-weight: 600;
  color: var(--ink);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 9999px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.chip:active { transform: scale(0.97); }
.chip.is-active {
  color: #fff;
  background: var(--brand-grad);
  border-color: transparent;
  box-shadow: var(--shadow-btn);
}

/* ===================== Легенда ===================== */
.legend {
  position: absolute;
  right: 12px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 15;
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-card);
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 9999px; display: inline-block; }
.legend .lg-pin { display: block; flex: none; }

/* ===================== Сетевая ошибка ===================== */
.net-error {
  position: absolute;
  top: calc(112px + var(--safe-top));
  left: 50%; transform: translateX(-50%);
  z-index: 25;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  box-shadow: var(--shadow-hover);
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.net-error[hidden] { display: none; }
.net-error button {
  font-family: inherit; font-weight: 700; font-size: 13px;
  color: #fff; background: var(--brand-grad);
  border: none; border-radius: 9999px;
  padding: 6px 14px; cursor: pointer;
}

/* ===================== Нижняя шторка ===================== */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(15,23,42,.28);
  backdrop-filter: blur(1px);
  opacity: 0; transition: opacity .28s ease;
}
.sheet-scrim.is-open { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -12px 40px -8px rgba(15,23,42,.2);
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,.72,0,1);
  padding-bottom: var(--safe-bottom);
}
.sheet.is-open { transform: translateY(0); }
.sheet.is-dragging { transition: none; }

.sheet-grip {
  flex: 0 0 auto;
  padding: 10px 0 6px;
  display: grid; place-items: center;
  cursor: grab; touch-action: none;
}
.sheet-grip::before {
  content: ""; width: 42px; height: 5px;
  border-radius: 9999px; background: var(--border);
}
.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 18px calc(20px + var(--safe-bottom));
  overscroll-behavior: contain;
}

/* --- Заголовок станции --- */
.st-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.st-title { min-width: 0; flex: 1; }
.st-name { font-size: 20px; font-weight: 800; margin: 0 0 3px; line-height: 1.2; }
.st-brand { font-size: 13px; font-weight: 600; color: var(--brand); }
.st-addr { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.35; }

.badge {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 9999px;
  font-size: 13px; font-weight: 700;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 9999px; background: currentColor; }

.st-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 13px; color: var(--muted);
  margin-bottom: 16px;
}
.meta-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  background: var(--fog);
  border-radius: 9999px;
  font-weight: 600; color: var(--muted);
}
.meta-pill.mint { background: var(--pale-mint); color: var(--brand); }
.meta-pill.warn { background: #fff7ed; color: #d97706; }

/* --- Секции --- */
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--ash);
  margin: 18px 0 10px;
}

/* --- Список топлива --- */
.fuel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fuel-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.fuel-name { font-size: 14px; font-weight: 700; }
.fuel-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 9999px;
  font-size: 12px; font-weight: 700;
}
.fuel-badge .dot { width: 6px; height: 6px; border-radius: 9999px; background: currentColor; }

/* --- Лента комментариев --- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  padding: 12px 14px;
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.feed-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.feed-time { font-size: 12px; font-weight: 600; color: var(--ash); }
.feed-text { font-size: 14px; color: var(--ink); line-height: 1.4; }
.feed-fuels { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.feed-tag {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 9999px;
}
.flag-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--ash);
  background: none; border: none; cursor: pointer;
  padding: 2px 4px;
}
.flag-btn:hover { color: var(--st-none); }
.flag-btn:disabled { opacity: .5; cursor: default; }

.empty-state {
  text-align: center;
  padding: 22px 16px;
  color: var(--muted);
  font-size: 14px;
  background: var(--pale-mint);
  border-radius: var(--r-md);
  line-height: 1.4;
}
.empty-state b { color: var(--brand); display: block; margin-bottom: 2px; font-weight: 700; }

/* --- Кнопки --- */
.btn {
  font-family: inherit; font-size: 15px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform .1s, background .15s, box-shadow .15s, border-color .15s;
  min-height: 44px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  width: 100%;
  color: #fff; font-weight: 700;
  background: var(--brand-grad);
  border: none;
  box-shadow: var(--shadow-btn);
  padding: 13px;
}
.btn-primary:disabled { opacity: .55; box-shadow: none; cursor: default; }
.btn-secondary {
  background: var(--surface);
  color: var(--ink); font-weight: 600;
  border: 1px solid var(--border);
  padding: 12px;
}
.btn-secondary:hover { background: var(--fog); }
.btn-ghost {
  background: transparent; border: none; color: var(--muted); font-weight: 600;
  padding: 12px;
}
.btn-ghost:hover { background: var(--fog); }

.sheet-cta { margin-top: 20px; }

/* ===================== Форма отметки ===================== */
.form-row { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.form-hint { font-size: 12px; color: var(--muted); font-weight: 500; }

/* тумблер есть/нет для топлива */
.fuel-toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
}
.fuel-toggle .fuel-name { font-size: 14px; }
.tri {
  display: inline-flex;
  background: var(--fog);
  border-radius: 9999px;
  padding: 3px;
  gap: 2px;
}
.tri button {
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  border: none; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 9999px; cursor: pointer;
  min-height: 32px;
  transition: background .15s, color .15s;
}
.tri button[aria-pressed="true"][data-v="yes"] { background: var(--st-has); color: #fff; }
.tri button[aria-pressed="true"][data-v="no"] { background: var(--st-none); color: #fff; }
.tri button[aria-pressed="true"][data-v="skip"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

.seg {
  display: flex; gap: 6px;
}
.seg button {
  flex: 1;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  padding: 11px 6px; border-radius: var(--r-sm); cursor: pointer;
  min-height: 44px;
  transition: background .15s, color .15s, border-color .15s;
}
.seg button[aria-pressed="true"] {
  background: var(--pale-mint); color: var(--brand); border-color: var(--brand-accent);
}

.input {
  width: 100%;
  font-family: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-accent);
}
textarea.input { resize: vertical; min-height: 78px; line-height: 1.4; }

.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.form-actions .btn-secondary { flex: 0 0 auto; width: 44%; }
.form-actions .btn-primary { flex: 1; }

/* ===================== Тосты ===================== */
.toast-wrap {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  max-width: 90vw;
  padding: 11px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 9999px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-hover);
  opacity: 0; transform: translateY(12px);
  transition: opacity .25s, transform .25s;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast.ok { background: linear-gradient(135deg,#3c8417,#2f6a12); }
.toast.err { background: #dc2626; }
.toast svg { flex: 0 0 auto; }

/* spinner */
.spin {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 9999px;
  animation: spin .7s linear infinite;
}
.load-inline {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 30px; color: var(--muted); font-size: 14px; font-weight: 600;
}
.load-inline .spin { border-color: var(--border); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* маркеры-кластеры не используют DOM; всё через circle-layer */

@media (min-width: 640px) {
  .sheet { left: 50%; right: auto; width: 440px; transform: translate(-50%, 100%); border-radius: var(--r-lg); bottom: 16px; }
  .sheet.is-open { transform: translate(-50%, 0); }
  .topbar { left: 50%; transform: translateX(-50%); width: 440px; }
  .filters { left: 50%; transform: translateX(-50%); width: 440px; }
}
