* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: 300px;
  flex-shrink: 0;
  padding: 20px;
  background: #1f2933;
  color: #e4e7eb;
  overflow-y: auto;
}

#sidebar h1 {
  font-size: 20px;
  margin-bottom: 6px;
}

.hint {
  font-size: 13px;
  color: #9aa5b1;
  margin-bottom: 18px;
  line-height: 1.4;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa5b1;
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 14px;
}

/* --- Легенда-фильтр --- */
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 14px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  color: #e4e7eb;
}

.legend-row input {
  cursor: pointer;
  accent-color: #2f80ed;
}

/* Цветной кружок в легенде и списке */
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

button {
  width: 100%;
  padding: 9px;
  margin-bottom: 8px;
  border: none;
  border-radius: 6px;
  background: #2f80ed;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover {
  background: #2668c4;
}

#map {
  flex: 1;
  height: 100%;
  background: #0e1116;
}

/* Элементы только для админ-страницы (/admin) */
.admin-only {
  display: none;
}
body.admin .admin-only {
  display: block;
}

/* Курсор в режиме постановки метки */
.leaflet-container.placing-cursor {
  cursor: crosshair;
}

/* --- Экран входа админа --- */
#admin-gate {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #0e1116;
  display: flex;
  align-items: center;
  justify-content: center;
}
#admin-gate[hidden] {
  display: none;
}
#admin-gate-box {
  width: 320px;
  max-width: 90vw;
  padding: 26px 24px;
  background: #1f2933;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
}
#admin-gate-box h2 {
  font-size: 20px;
  margin-bottom: 6px;
}
#gate-pass {
  width: 100%;
  padding: 10px;
  margin: 14px 0 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 15px;
}
#gate-error {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 8px;
  min-height: 16px;
}

/* --- Метки-кружки и кластеры --- */
/* Убираем белую подложку у divIcon по умолчанию. */
.leaflet-div-icon {
  background: transparent;
  border: none;
}
.marker-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
  box-sizing: border-box;
}
.cluster-badge {
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
}

/* Активная кнопка «Добавить метку» (режим включён) */
#btn-add.active {
  background: #c0392b;
}
#btn-add.active:hover {
  background: #a93226;
}

/* --- Модальная форма --- */
#modal-backdrop,
#cat-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#modal-backdrop[hidden],
#cat-modal-backdrop[hidden] {
  display: none;
}

#modal,
#cat-modal {
  width: 340px;
  max-width: 90vw;
  background: #1f2933;
  color: #e4e7eb;
  border: 1px solid #3e4c59;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

#modal h2,
#cat-modal h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #cbd2d9;
  margin-bottom: 14px;
}

#modal label,
#cat-modal label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9aa5b1;
  margin: 10px 0 5px;
}

#modal input,
#modal textarea,
#cat-modal input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #3e4c59;
  border-radius: 6px;
  background: #323f4b;
  color: #e4e7eb;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
#cat-modal input[type="color"] {
  height: 38px;
  padding: 2px;
}
#cat-modal .modal-cat input {
  width: auto;
}

/* Список категорий в админке */
.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 14px;
}
.cat-row .cat-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-row button {
  width: auto;
  margin: 0;
  padding: 3px 7px;
  font-size: 13px;
  background: #52606d;
}
.cat-row button:hover {
  background: #3e4c59;
}

#m-media {
  padding: 6px;
  font-size: 13px;
}

.muted {
  color: #9aa5b1;
  text-transform: none;
  letter-spacing: normal;
  font-size: 11px;
}

#m-upload {
  margin-top: 10px;
}
#m-upload progress {
  width: 100%;
  height: 8px;
  accent-color: #2f80ed;
}
#m-upload-text {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #9aa5b1;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions button {
  margin-bottom: 0;
}

.modal-actions .secondary {
  background: #52606d;
}
.modal-actions .secondary:hover {
  background: #3e4c59;
}

/* --- Тёмная тема для элементов Leaflet --- */
.leaflet-bar a,
.leaflet-bar a:hover {
  background: #1f2933;
  color: #e4e7eb;
  border-bottom-color: #3e4c59;
}

.leaflet-bar a:hover {
  background: #323f4b;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #1f2933;
  color: #e4e7eb;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content a {
  color: #6ab0ff;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #9aa5b1;
}

.leaflet-control-attribution {
  background: rgba(31, 41, 51, 0.85) !important;
  color: #9aa5b1;
}

/* Убираем флажок Украины из копирайта Leaflet */
.leaflet-attribution-flag {
  display: none !important;
}

.leaflet-control-attribution a {
  color: #6ab0ff;
}

.popup-cat {
  font-size: 12px;
  color: #9aa5b1;
}

.popup-meta {
  margin-top: 4px;
  font-size: 11px;
  color: #9aa5b1;
}

.tg-embed {
  display: block;
  width: 100%;
  height: 320px;
  border: 0;
  margin-top: 6px;
  border-radius: 8px;
  background: #16202b;
}

.popup-tg {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}

.popup-del {
  margin-top: 8px;
  width: auto;
  padding: 5px 10px;
  background: #c0392b;
  font-size: 12px;
}

.popup-del:hover {
  background: #a93226;
}

/* --- Голосование по метке (подтвердить / опровергнуть) --- */
.popup-votes {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}
.vote-count.confirm {
  color: #27ae60;
}
.vote-count.deny {
  color: #e74c3c;
}

.status-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.status-actions .st-btn {
  width: auto;
  margin-bottom: 0;
  padding: 4px 10px;
  font-size: 12px;
}

.st-btn.confirm {
  background: #27ae60;
}
.st-btn.confirm:hover {
  background: #1f8f4d;
}
.st-btn.deny {
  background: #52606d;
}
.st-btn.deny:hover {
  background: #3e4c59;
}

/* Выбранная пользователем кнопка и заблокированные после голоса */
.st-btn.chosen {
  outline: 2px solid #fff;
  outline-offset: 1px;
}
.st-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.st-btn.deny:disabled:hover {
  background: #52606d;
}
.st-btn.confirm:disabled:hover {
  background: #27ae60;
}

.vote-note {
  margin-top: 6px;
  font-size: 11px;
  color: #9aa5b1;
}

#admin-box {
  padding: 12px;
  background: #16202b;
  border: 1px solid #3e4c59;
  border-radius: 8px;
}

#admin-status {
  font-size: 13px;
  margin-bottom: 8px;
  color: #cbd2d9;
}

#admin-box button {
  margin-bottom: 0;
  background: #52606d;
}

#admin-box button:hover {
  background: #3e4c59;
}

#cat-hint {
  margin: 6px 0 0;
}

/* --- Мобильная версия: карта на весь экран + выезжающая панель --- */
.menu-toggle {
  display: none; /* показывается только на узких экранах */
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1200;
  width: 46px;
  height: 46px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  background: #1f2933;
  color: #e4e7eb;
  font-size: 22px;
  line-height: 46px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.menu-toggle:hover {
  background: #323f4b;
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1150;
}

@media (max-width: 640px) {
  .menu-toggle {
    display: block;
  }

  /* Карта занимает весь экран */
  #map {
    height: 100%;
    width: 100%;
  }

  /* Панель — выезжающая шторка слева */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 82%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1180;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.5);
  }

  body.drawer-open #sidebar {
    transform: translateX(0);
  }
  body.drawer-open .drawer-backdrop {
    display: block;
  }
}
