:root {
  --bg: #111318;
  --panel: rgba(22, 25, 32, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --ink: #eceff4;
  --muted: #8c94a0;
  --accent: #3c96ff;
  --up: #5ad282;
  --down: #f55f5f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 14px/1.35 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overflow: hidden; }
#map { position: absolute; inset: 0; background: var(--bg); }
/* светлая карта OSM → тёмная: инверсия + разворот оттенков (вода остаётся синеватой) */
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.92) saturate(0.55); }
body.tiny .pin { font-size: 0 !important; }
body.tiny .pin .tr { display: none; }

/* ---------- верхняя панель ---------- */
#top { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
#tariffs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px; pointer-events: auto; backdrop-filter: blur(6px); }
#tariffs button { flex: 1; border: 0; border-radius: 9px; padding: 8px 4px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; }
#tariffs button.on { background: var(--accent); color: #fff; }
#meta { align-self: flex-start; display: flex; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px; font-size: 13px; pointer-events: auto; }
#meta b { color: #fff; }
#upd { color: var(--muted); }

/* ---------- кнопки справа ---------- */
#tools { position: absolute; right: 8px; top: 96px; z-index: 1000; display: flex; flex-direction: column; gap: 6px; }
.tool { width: 52px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); font-size: 20px; padding: 6px 0 4px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tool span { font-size: 10px; color: var(--muted); }
.tool.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tool.on span { color: var(--accent); }

/* ---------- инфо внизу ---------- */
#info { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 1000; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.chip { align-self: flex-start; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 5px 9px; font-size: 12.5px; pointer-events: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#legend { position: absolute; right: 8px; bottom: 8px; z-index: 999; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
#legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
body.has-info #legend { bottom: auto; top: 96px; right: 68px; }

/* ---------- значки точек ---------- */
.pin-wrap { background: none; border: 0; }
.pin { position: relative; border-radius: 50%; background: var(--c); border: 2px solid #fff;
  box-shadow: 0 0 0 4px var(--g), 0 2px 8px rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; color: #0d0f13; font-weight: 800; font-size: 13px; }
.pin.zero { background: #2a2f3a; border: 2px solid #5a6170; box-shadow: none; color: #9aa1ad; font-weight: 600; font-size: 11px; }
.pin .tr { position: absolute; top: -9px; right: -14px; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 8px; background: #111318; border: 1px solid var(--line); }
.pin .tr.up { color: var(--up); }
.pin .tr.down { color: var(--down); }
.lbl { display: none; position: absolute; left: 50%; transform: translateX(-50%); top: 100%; margin-top: 3px; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; pointer-events: none; }
body.z15 .lbl { display: block; }
.emo { font-size: 24px; filter: drop-shadow(0 1px 3px #000); }
.emo.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }
.hexnum { color: #fff; font-size: 10px; font-weight: 700; text-shadow: 0 0 3px #000; text-align: center; display: none; }
body.z15 .hexnum { display: block; }
.me { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(60,150,255,.3); }

/* ---------- всплывашки ---------- */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #1b1f27; color: var(--ink); box-shadow: 0 4px 16px rgba(0,0,0,.6); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13.5px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pp-name { font-size: 16px; font-weight: 700; }
.pp-sub { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.pp-kef { font-size: 26px; font-weight: 800; }
.pp-row { margin: 2px 0; }
.up { color: var(--up); } .down { color: var(--down); }
.btn { border: 0; border-radius: 10px; padding: 9px 12px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; width: 100%; margin-top: 8px; }
.btn.ghost { background: #262b35; color: var(--ink); }
.leaflet-control-attribution { background: rgba(17,19,24,.7) !important; color: #6c7380 !important; font-size: 9px; }
.leaflet-control-attribution a { color: #8c94a0 !important; }

/* ---------- окно районов ---------- */
#sheet { position: absolute; inset: 0; z-index: 2000; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; }
.sheet-card { width: 100%; background: #1b1f27; border-radius: 16px 16px 0 0; padding: 16px 16px 22px; max-height: 80%; overflow: auto; }
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-sub { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
#sheetList label { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
#sheetList input { width: 20px; height: 20px; accent-color: var(--accent); }
.sheet-btns { display: flex; gap: 8px; }

#msg { position: absolute; left: 16px; right: 16px; top: 40%; z-index: 3000; background: #1b1f27; border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-align: center; font-size: 15px; }
#busy { position: absolute; left: 50%; top: 100px; transform: translateX(-50%); z-index: 1500; background: var(--panel); border-radius: 10px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }
