:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1e2740;
  --line: #2a3350;
  --text: #e7ecf5;
  --muted: #93a0b8;
  --accent: #4f8cff;
  --yes: #22c55e;
  --maybe: #f59e0b;
  --no: #ef4444;
  --unknown: #64748b;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; height: 100vh; overflow: hidden; position: relative; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 360px;
  min-width: 360px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.panel { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all .12s ease;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.state-yes.active { background: var(--yes); border-color: var(--yes); }
.chip.state-maybe.active { background: var(--maybe); border-color: var(--maybe); color:#1a1200; }
.chip.state-no.active { background: var(--no); border-color: var(--no); }
.chip.state-unknown.active { background: var(--unknown); border-color: var(--unknown); }

#search {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.brand-chips { max-height: 132px; overflow-y: auto; }
.chip .count {
  display: inline-block;
  min-width: 18px;
  margin-left: 7px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  vertical-align: middle;
}
.chip.active .count { background: rgba(0, 0, 0, .22); color: #fff; }

.price-row { display: flex; gap: 6px; align-items: center; }
#max-price {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  outline: none;
}
#max-price:focus { border-color: var(--accent); }
.mini-btn {
  width: 34px; height: 34px; flex: none;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; font-size: 16px; cursor: pointer;
}
.mini-btn:hover { border-color: var(--accent); color: var(--text); }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; }

.st-price { font-size: 12px; color: var(--yes); font-weight: 600; margin-top: 2px; }

.sources .src-list { display: flex; flex-direction: column; gap: 4px; }
.src-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.src-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--no); flex: none; }
.src-dot.ok { background: var(--yes); }
.src-name { flex: 1; }
.src-count { color: var(--muted); }

.list-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.count-badge { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.station-list { overflow-y: auto; margin: 8px -16px -12px; padding: 0 8px; flex: 1; }

.st-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.st-item:hover { background: var(--panel-2); }
.st-item.active { background: var(--panel-2); border-color: var(--accent); }
.st-prob {
  width: 42px; height: 42px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
}
.st-main { min-width: 0; flex: 1; }
.st-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-addr { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-fuels { font-size: 11px; color: var(--muted); margin-top: 2px; }

.foot { padding: 10px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- Map ---------- */
#map { flex: 1; height: 100%; background: #0b0f18; }

.marker {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11px;
}
.marker-active {
  border: 3px solid #fff;
  font-size: 14px;
  box-shadow: 0 0 0 4px rgba(79,140,255,.65), 0 4px 14px rgba(0,0,0,.6);
  animation: marker-pulse 1.6s ease-out infinite;
}
@keyframes marker-pulse {
  0%   { box-shadow: 0 0 0 3px rgba(79,140,255,.75), 0 4px 14px rgba(0,0,0,.6); }
  70%  { box-shadow: 0 0 0 12px rgba(79,140,255,0), 0 4px 14px rgba(0,0,0,.6); }
  100% { box-shadow: 0 0 0 3px rgba(79,140,255,0), 0 4px 14px rgba(0,0,0,.6); }
}

/* ---------- Detail drawer ---------- */
.detail {
  position: absolute; top: 0; right: 0; height: 100%;
  width: 420px; max-width: 92vw;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0,0,0,.4);
  z-index: 1200;
  overflow-y: auto;
  transition: transform .22s ease, visibility .22s;
}
.detail.hidden { transform: translateX(105%); visibility: hidden; pointer-events: none; }
.detail-close {
  position: absolute; top: 10px; right: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer;
}
#detail-body { padding: 20px 20px 40px; }

.d-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; padding-right: 30px; }
.d-prob {
  width: 60px; height: 60px; flex: none; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
}
.d-prob .pct { font-size: 18px; }
.d-prob .lbl { font-size: 10px; opacity: .9; }
.d-title { font-size: 18px; font-weight: 700; }
.d-brand { font-size: 12px; color: var(--muted); }
.d-addr { font-size: 13px; color: var(--muted); margin-top: 3px; }

.d-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 8px; }

.fuel-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.fuel-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.fuel-name { font-weight: 700; font-size: 14px; }
.fuel-price { margin-left: auto; font-size: 13px; color: var(--text); }
.pbar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; flex: 1; }
.pbar > span { display: block; height: 100%; }
.pchip { font-size: 11px; padding: 2px 7px; border-radius: 999px; color:#fff; font-weight:600; }
.src-lines { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.src-line { display: flex; font-size: 12px; gap: 8px; }
.src-line .s-src { width: 74px; color: var(--muted); flex: none; text-transform: capitalize; }
.src-line .s-val { flex: 1; }
.src-line .s-age { color: var(--muted); font-size: 11px; }

.kv { display: flex; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.kv .k { width: 130px; color: var(--muted); flex: none; }
.kv .v { flex: 1; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: #fff; border-color: var(--yes); background: rgba(34,197,94,.15); }

/* ---------- Mobile controls (hidden on desktop) ---------- */
.menu-toggle,
.sidebar-close { display: none; }
.scrim { display: none; }

@media (max-width: 780px) {
  /* Map fills the screen; the sidebar becomes a slide-in overlay. */
  #sidebar {
    position: absolute;
    top: 0; left: 0;
    height: 100%;
    width: min(86vw, 360px);
    min-width: 0;
    z-index: 1250;
    transform: translateX(-101%);
    transition: transform .24s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, .5);
  }
  #app.sidebar-open #sidebar { transform: translateX(0); }

  /* On phones the whole sidebar scrolls (not just the station list),
     otherwise the filters consume all the height. */
  #sidebar { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .list-panel { flex: none; }
  .station-list { overflow: visible; margin-bottom: 0; flex: none; }

  /* Dimmed backdrop behind the open sidebar. */
  .scrim {
    display: block;
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1240;
    opacity: 0; pointer-events: none;
    transition: opacity .24s ease;
  }
  #app.sidebar-open .scrim { opacity: 1; pointer-events: auto; }

  /* Floating "Фильтры" button (open). */
  .menu-toggle {
    display: inline-flex; align-items: center; gap: 7px;
    position: absolute; top: 12px; left: 12px;
    z-index: 1200;
    background: var(--accent); color: #fff;
    border: none; border-radius: 999px;
    padding: 10px 16px; font-size: 14px; font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
    cursor: pointer;
  }
  .menu-toggle .mt-icon { font-size: 16px; line-height: 1; }
  #app.sidebar-open .menu-toggle { display: none; }

  /* Close (×) inside the sidebar header. */
  .sidebar-close {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 12px; right: 12px;
    width: 32px; height: 32px;
    background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
    border-radius: 8px; font-size: 20px; cursor: pointer;
  }
  .brand { position: relative; padding-right: 54px; }

  /* Detail drawer takes the full width on small screens. */
  .detail { width: 100%; max-width: 100%; }

  /* Slightly denser list touch targets. */
  .st-item { padding: 11px 8px; }
}
