:root {
  --bg: #14110f;
  --panel: #1c1916;
  --panel-2: #24201c;
  --line: #342e28;
  --text: #e9e1d4;
  --muted: #9b8f80;
  --accent: #d9a441;
  --accent-ink: #1a1306;
  --radius: 8px;
  --sb-w: 330px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; overflow: hidden; }

button, input { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- боковая панель ---------- */
#sidebar {
  width: var(--sb-w); flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line); z-index: 1000;
}
.sb-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.brand { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.brand span { color: var(--accent); font-weight: 600; }
.regions { display: flex; gap: 6px; margin-top: 10px; }
.regions button { flex: 1; white-space: nowrap; padding: 6px 8px; font-size: 13.5px; }
.regions button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.sb-tools { padding: 10px 14px; border-bottom: 1px solid var(--line); }
#search {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
}
.tool-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; margin-left: auto; }

.results { max-height: 40vh; overflow: auto; border-bottom: 1px solid var(--line); }
.results .res {
  display: flex; gap: 8px; align-items: center; width: 100%; text-align: left;
  border: 0; border-radius: 0; background: none; padding: 6px 14px; font-size: 13px;
}
.results .res:hover { background: var(--panel-2); }
.results .res small { color: var(--muted); margin-left: auto; white-space: nowrap; }
.results .empty { padding: 10px 14px; color: var(--muted); font-size: 13px; }

.groups { flex: 1; overflow: auto; padding: 4px 0 10px; }
.group { border-bottom: 1px solid var(--line); }
.group-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer; user-select: none;
  position: sticky; top: 0; background: var(--panel); z-index: 1;
}
.group-head .caret { width: 10px; color: var(--muted); transition: transform .15s; }
.group.closed .caret { transform: rotate(-90deg); }
.group-head .gname { font-weight: 600; flex: 1; }
.group-head .gcount { color: var(--muted); font-size: 12px; }
.group.closed .cats { display: none; }

.cat {
  display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 18px; cursor: pointer; font-size: 13.5px;
}
.cat:hover { background: var(--panel-2); }
.cat input { margin: 0; accent-color: var(--accent); }
.cat .ico {
  width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid; display: grid; place-items: center;
  background: #0d0b0a;
}
.cat .ico img { width: 16px; height: 16px; object-fit: contain; }
.cat .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cat .only { opacity: 0; font-size: 11px; padding: 1px 6px; }
.cat:hover .only { opacity: 1; }
.cat.off .name { color: var(--muted); }

.sb-foot { border-top: 1px solid var(--line); padding: 10px 14px; font-size: 13px; }
.mine { display: flex; gap: 6px; align-items: center; }
.mine span { flex: 1; }
.hint { color: var(--muted); margin: 8px 0 0; font-size: 12px; line-height: 1.4; }

/* ---------- карта ---------- */
#map { flex: 1; height: 100%; background: #0b0a09; }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; min-width: 230px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-zoom a { background: var(--panel); color: var(--text); border-color: var(--line) !important; }

.pp-head { display: flex; gap: 10px; align-items: center; }
.pp-head .ico { width: 34px; height: 34px; border-radius: 50%; border: 2px solid; display: grid; place-items: center; background: #0d0b0a; flex: none; }
.pp-head .ico img { width: 24px; height: 24px; object-fit: contain; }
.pp-cat { font-weight: 600; }
.pp-label { margin-top: 8px; line-height: 1.35; }
.pp-meta { margin-top: 8px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pp-actions { display: flex; gap: 6px; margin-top: 10px; }
.pp-actions button { flex: 1; font-size: 13px; }
.pp-actions button.found { background: #2c4a2c; border-color: #4f8a4f; }
.pp-form input, .pp-form textarea {
  width: 100%; margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); resize: vertical;
}
.pp-colors { display: flex; gap: 6px; margin-top: 8px; }
.pp-colors button { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.pp-colors button.on { border-color: #fff; }

.user-pin {
  width: 18px; height: 18px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2px solid #fff; box-shadow: 0 1px 4px #000a;
}

.cursor-info {
  position: fixed; right: 12px; bottom: 12px; z-index: 1000; pointer-events: none;
  background: #1c1916e6; border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted);
}
.cursor-info b { color: var(--text); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 6px; font-weight: 600;
}

@media (max-width: 760px) {
  :root { --sb-w: 100%; }
  body { flex-direction: column; }
  #sidebar { height: 45%; border-right: 0; border-bottom: 1px solid var(--line); }
}
