/* ── токены ───────────────────────────────────────────────── */
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* топливо — единая палитра для карты, фильтров, карточки */
  --f92: #16a34a;
  --f95: #dc2626;
  --f98: #2563eb;
  --f100: #1e40af;
  --fdt: #111827;

  /* статусы */
  --st-yes: #16a34a;
  --st-queue: #f59e0b;
  --st-limit: #f97316;
  --st-no: #ef4444;
  --st-closed: #94a3b8;
  --st-unknown: #94a3b8;

  --accent: #16a34a;
  --accent-ink: #ffffff;
  --radius: 16px;
}

/* светлая тема интерфейса (по умолчанию — под светлые стили карты) */
:root, [data-map="light"] {
  --bg: #f4f2ee;
  --glass: rgba(255, 255, 255, 0.86);
  --glass-solid: rgba(255, 255, 255, 0.97);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --hover: rgba(15, 23, 42, 0.05);
  --soft: rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 2px 6px rgba(15, 23, 42, 0.06), 0 24px 60px rgba(15, 23, 42, 0.18);
  --accent-soft: rgba(22, 163, 74, 0.1);
}
[data-map="dark"] {
  --bg: #0b0f17;
  --glass: rgba(17, 22, 33, 0.84);
  --glass-solid: rgba(17, 22, 33, 0.97);
  --text: #eef2f7;
  --text-2: #cbd5e1;
  --muted: #8b98ab;
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.3);
  --hover: rgba(148, 163, 184, 0.1);
  --soft: rgba(148, 163, 184, 0.07);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --accent-soft: rgba(34, 197, 94, 0.14);
  --fdt: #0b0f17;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: var(--font); }

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}
.glass-solid {
  background: var(--glass-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

#map { position: fixed; inset: 0; background: var(--bg); }

/* ── контролы MapLibre ────────────────────────────────────── */
.maplibregl-ctrl-group {
  background: var(--glass) !important; border: 1px solid var(--border) !important;
  border-radius: 14px !important; box-shadow: var(--shadow) !important;
  backdrop-filter: blur(16px); overflow: hidden;
}
.maplibregl-ctrl-group button { width: 42px; height: 42px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--border) !important; }
[data-map="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1) brightness(0.9); }
.maplibregl-ctrl-bottom-left { margin: 0 0 16px 6px; }
.maplibregl-ctrl-attrib.maplibregl-compact { background: var(--glass); color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted); }

/* ── верхняя панель ───────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px 0 13px; border-radius: 14px;
  color: var(--accent); user-select: none; white-space: nowrap;
}
.brand-name { font-size: 17px; color: var(--text); font-weight: 400; letter-spacing: -0.01em; }
.brand-name b { font-weight: 800; }

.fuel-filters {
  display: flex; gap: 4px; padding: 4px; border-radius: 14px; height: 44px; align-items: center;
}
.fchip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.15s;
  font-variant-numeric: tabular-nums;
}
.fchip .fdot { width: 9px; height: 9px; border-radius: 50%; background: var(--fc); flex: none; }
.fchip:hover { background: var(--hover); color: var(--text); }
.fchip.on { background: var(--fc); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--fc) 40%, transparent); }
.fchip.on .fdot { background: #fff; }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 14px;
  color: var(--text); cursor: pointer; transition: all 0.15s;
}
.icon-btn:not(.glass) { border: 1px solid var(--border); background: var(--soft); }
.icon-btn:hover { color: var(--accent); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.icon-btn.ghost { background: transparent; border-color: transparent; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); }
.icon-btn.ghost:hover { background: var(--hover); color: var(--text); }
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; border: 2px solid var(--glass-solid);
  font-size: 10px; font-weight: 800; line-height: 14px; text-align: center;
}

.tg-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: 14px;
  color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.15s;
}
.tg-btn:hover, .tg-btn.linked { color: #229ed9; }

/* меню стиля карты */
.style-wrap { position: relative; }
.style-menu {
  position: absolute; top: 52px; right: 0; z-index: 1200;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  border-radius: 14px; min-width: 180px;
}
.style-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left;
}
.style-opt:hover { background: var(--hover); }
.style-opt.on { border-color: var(--accent); color: var(--accent); }
.style-swatch { width: 26px; height: 26px; border-radius: 8px; flex: none; border: 1px solid var(--border); }
.sw-liberty { background: linear-gradient(135deg, #f2efe9 50%, #aad3df 50%); }
.sw-positron { background: linear-gradient(135deg, #fafafa 50%, #d4dadc 50%); }
.sw-dark { background: linear-gradient(135deg, #1c1f24 50%, #0e2a3a 50%); }

/* ── сводка по видимой области ────────────────────────────── */
.summary {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 900;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px 8px 12px; border-radius: 999px;
  font-size: 14px; color: var(--text-2); white-space: nowrap;
}
.summary b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.summary .pulse {
  width: 10px; height: 10px; border-radius: 50%; background: var(--st-yes); flex: none;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); animation: pulse 2s infinite;
}
.summary.muted .pulse { background: var(--muted); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* ── легенда ──────────────────────────────────────────────── */
.legend {
  position: fixed; left: 16px; bottom: 120px; z-index: 900;
  display: flex; flex-direction: column; gap: 7px;
  padding: 10px 12px; border-radius: 14px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.legend-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lg-fuel {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: var(--fc); color: #fff; font-size: 11px; font-weight: 800;
}
.lg-item { display: inline-flex; align-items: center; gap: 5px; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }

/* ── FAB ──────────────────────────────────────────────────── */
.fab-stack {
  position: fixed; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 1000;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.fab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 48px; height: 48px; padding: 0 12px; border-radius: 16px;
  color: var(--text); cursor: pointer; transition: all 0.15s;
  font-size: 14px; font-weight: 700;
}
.fab:hover { color: var(--accent); }
.fab-accent {
  background: var(--accent); color: #fff; border: none; padding: 0 18px 0 14px;
  box-shadow: 0 6px 20px rgba(22, 163, 74, 0.38);
}
.fab-accent:hover { color: #fff; filter: brightness(1.06); transform: translateY(-1px); }

/* ── панели ───────────────────────────────────────────────── */
.panel {
  position: fixed; top: 74px; right: 16px; z-index: 1100;
  width: 380px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 94px);
  display: flex; flex-direction: column;
  border-radius: 20px;
  animation: slideIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } }

.st-head { display: flex; align-items: center; gap: 12px; padding: 18px 16px 12px 18px; }
.st-logo {
  width: 48px; height: 48px; border-radius: 14px; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--border);
  font-size: 20px; font-weight: 800; color: #fff;
}
.st-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.st-title { flex: 1; min-width: 0; }
.st-title h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.st-title p { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }

.st-status {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px; padding: 11px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--sc) 11%, transparent);
  color: color-mix(in srgb, var(--sc) 75%, var(--text));
  font-size: 14.5px; font-weight: 700;
}
.st-status .sdot { width: 10px; height: 10px; border-radius: 50%; background: var(--sc); flex: none; }
.st-status .when { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.panel-body { padding: 12px 16px 6px; overflow-y: auto; }
.panel-actions {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  padding: 12px 16px 16px;
}
.panel-actions .btn { min-width: 0; padding: 0 8px; }
#zonesPanel .panel-actions { grid-template-columns: 1fr; }

.fuel-grid { display: flex; flex-direction: column; gap: 6px; }
.fuel-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--soft); border: 1px solid transparent;
  font-size: 14px;
}
.fuel-row.avail { background: color-mix(in srgb, var(--st-yes) 7%, transparent); border-color: color-mix(in srgb, var(--st-yes) 22%, transparent); }
.fuel-row.gone { opacity: 0.6; }
.fbadge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 26px; padding: 0 8px; border-radius: 8px;
  background: var(--fc); color: #fff; font-size: 13px; font-weight: 800; flex: none;
}
.fuel-row .favail { font-size: 13px; font-weight: 600; color: var(--muted); }
.fuel-row.avail .favail { color: var(--st-yes); }
.fuel-row .fprice { margin-left: auto; text-align: right; line-height: 1.15; }
.fuel-row .fprice b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fuel-row .fprice small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.src-note { margin: 12px 2px 2px; font-size: 12px; color: var(--muted); }
.zones-empty { color: var(--muted); font-size: 14px; line-height: 1.5; padding: 6px 2px; }

/* ── кнопки ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--text); font-size: 14px; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }

/* ── конструктор зоны ─────────────────────────────────────── */
.zone-builder {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1100;
  width: 380px; max-width: calc(100vw - 32px);
  padding: 16px 18px; border-radius: 20px;
}
.zb-title { font-size: 14px; font-weight: 700; color: var(--text-2); text-align: center; }
.zb-controls label { display: block; font-size: 14px; font-weight: 600; margin-top: 12px; }
.zb-controls input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--accent); }
.zb-fuels { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.zb-fuels .fchip { border-color: var(--border); }
.zb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }

/* ── список зон ───────────────────────────────────────────── */
.zone-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 14px; margin-bottom: 8px; border-radius: 12px;
  background: var(--soft); border: 1px solid var(--border);
}
.zone-item .z-info { flex: 1; min-width: 0; }
.zone-item .z-name { font-weight: 700; font-size: 14px; }
.zone-item .z-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.zone-item .icon-btn { width: 34px; height: 34px; border-radius: 10px; flex: none; }

/* ── модалки rzUI ─────────────────────────────────────────── */
.rz-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.16s; padding: 16px;
}
.rz-overlay.rz-in { opacity: 1; }
.rz-overlay.rz-out { opacity: 0; }
.rz-modal {
  width: 400px; max-width: 100%; max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 22px; border-radius: 20px;
  background: var(--glass-solid); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); color: var(--text);
  transform: translateY(8px) scale(0.98); transition: transform 0.18s;
}
.rz-overlay.rz-in .rz-modal { transform: none; }
.rz-modal-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.01em; }
.rz-modal-msg { font-size: 14px; color: var(--muted); line-height: 1.5; }
.rz-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.rz-btn {
  height: 42px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer;
}
.rz-btn:hover { background: var(--hover); }
.rz-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rz-btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.rz-btn-danger { background: var(--st-no); border-color: var(--st-no); color: #fff; }
.rz-input {
  width: 100%; margin-top: 12px; height: 44px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--soft); color: var(--text); font-size: 15px; font-family: var(--font);
}
.rz-input:focus { outline: none; border-color: var(--accent); }

/* форма отметки */
.mark-form .seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0; }
.seg-btn {
  height: 44px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--text); font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.seg-btn:hover { background: var(--hover); }
.seg-btn.on-yes { background: var(--st-yes); border-color: var(--st-yes); color: #fff; }
.seg-btn.on-queue { background: var(--st-queue); border-color: var(--st-queue); color: #fff; }
.seg-btn.on-limit { background: var(--st-limit); border-color: var(--st-limit); color: #fff; }
.seg-btn.on-no { background: var(--st-no); border-color: var(--st-no); color: #fff; }
.mark-form .fuel-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.mark-form .fuel-pick .fchip { border-color: var(--border); }
.mark-form .price-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.mark-form .price-row input {
  width: 110px; height: 38px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--soft);
  color: var(--text); font-size: 14px; font-family: var(--font);
}
.mark-hint { font-size: 12.5px; color: var(--muted); margin-top: 12px; line-height: 1.45; }

/* ── тосты ────────────────────────────────────────────────── */
.toasts {
  position: fixed; left: 50%; top: 122px; transform: translateX(-50%);
  z-index: 2100; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.rz-toast {
  padding: 12px 18px; border-radius: 14px; max-width: min(520px, calc(100vw - 32px));
  background: var(--glass-solid); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-8px); transition: all 0.22s;
  pointer-events: auto;
}
.rz-toast.rz-in { opacity: 1; transform: none; }
.rz-toast.rz-out { opacity: 0; }
.rz-toast-alert { border-left: 4px solid var(--st-yes); }
.rz-toast-error { border-left: 4px solid var(--st-no); }

/* ── мобильная адаптация ──────────────────────────────────── */
@media (max-width: 860px) {
  .legend { display: none; }
  .tg-btn span { display: none; }
  .tg-btn { width: 44px; padding: 0; justify-content: center; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .fuel-filters { order: 3; width: 100%; justify-content: space-between; }
  .fchip { flex: 1; justify-content: center; padding: 0 6px; }
  .brand-name { display: none; }
  .summary { top: 120px; font-size: 13px; }
  .toasts { top: 168px; }
  .panel {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-width: 100%;
    border-radius: 22px 22px 0 0; max-height: 72vh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .fab-accent span { display: none; }
  .fab-accent { padding: 0; width: 52px; }
}
