* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a1a; color: #e8e8e8;
  height: 100vh; overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; background: #2a2a2a;
  border-bottom: 1px solid #3a3a3a; flex-shrink: 0;
}
.part-select { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.part-select select {
  padding: 6px 10px; background: #3a3a3a; color: #e8e8e8;
  border: 1px solid #4a4a4a; border-radius: 4px; font-size: 14px; cursor: pointer;
}
.edit-btn {
  padding: 8px 14px; border: 1px solid #4a4a4a; border-radius: 4px;
  background: #3a3a3a; color: #e8e8e8; cursor: pointer; font-size: 14px;
}
.edit-btn:hover { background: #4a4a4a; }
.edit-btn.active { background: #27ae60; border-color: #27ae60; }
.counter { margin-left: auto; color: #888; font-size: 13px; }

.main { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 300px; background: #222; border-right: 1px solid #3a3a3a;
  display: flex; flex-direction: column; overflow: hidden;
}
.filters, .marker-list { padding: 12px; overflow-y: auto; }
.filters { border-bottom: 1px solid #3a3a3a; max-height: 50%; }
.marker-list { flex: 1; }
.sidebar h3 {
  font-size: 13px; margin-bottom: 10px; color: #aaa;
  text-transform: uppercase; letter-spacing: 0.5px;
}

#categoryFilters { display: flex; flex-direction: column; gap: 6px; }
.cat-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: #2a2a2a; border-radius: 4px; cursor: pointer;
  user-select: none; font-size: 14px;
}
.cat-item:hover { background: #333; }
.cat-item input { cursor: pointer; accent-color: #27ae60; }
.cat-count { margin-left: auto; color: #888; font-size: 12px; }
.cat-icon { font-size: 16px; }

#markerList { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.marker-item {
  padding: 8px 10px; background: #2a2a2a; border-radius: 4px;
  cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: center;
}
.marker-item:hover { background: #333; }
.marker-item .level {
  background: #3a3a3a; padding: 2px 6px; border-radius: 3px;
  font-size: 11px; color: #aaa;
}
.marker-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-list { color: #666; font-size: 13px; padding: 8px; text-align: center; }

#map { flex: 1; background: #111; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 10000;
}
.modal.hidden { display: none; }
.modal-content {
  background: #2a2a2a; border-radius: 8px; padding: 24px;
  width: 400px; max-width: 90%; border: 1px solid #4a4a4a;
}
.modal-content h2 { margin-bottom: 16px; font-size: 18px; }
.modal-content form { display: flex; flex-direction: column; gap: 12px; }
.modal-content label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #bbb; }
.modal-content input, .modal-content select {
  padding: 8px 10px; background: #1a1a1a; color: #e8e8e8;
  border: 1px solid #4a4a4a; border-radius: 4px; font-size: 14px;
}
.modal-actions { display: flex; gap: 8px; margin-top: 8px; }
.modal-actions button {
  padding: 8px 14px; border: 1px solid #4a4a4a; border-radius: 4px;
  background: #3a3a3a; color: #e8e8e8; cursor: pointer; font-size: 14px;
}
.modal-actions button:hover { background: #4a4a4a; }
.modal-actions .primary { background: #27ae60; border-color: #27ae60; }
.modal-actions .primary:hover { background: #2ecc71; }
.modal-actions .danger { margin-left: auto; background: #c0392b; border-color: #c0392b; }
.modal-actions .danger:hover { background: #e74c3c; }
.hidden { display: none !important; }

.marker-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid white; box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  font-size: 18px;
}

.leaflet-container { background: #111; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: #2a2a2a; color: #e8e8e8;
}
.leaflet-popup-content { margin: 12px; font-size: 13px; }
.leaflet-popup-content button {
  padding: 4px 10px; background: #3a3a3a; color: #e8e8e8;
  border: 1px solid #4a4a4a; border-radius: 3px; cursor: pointer; font-size: 12px;
}
.leaflet-popup-content button:hover { background: #4a4a4a; }
.leaflet-popup-content button.danger { background: #c0392b; border-color: #c0392b; }
.leaflet-popup-close-button { color: #888 !important; }
/* ========== Аккордеон категорий ========== */
.categories { padding: 12px; overflow-y: auto; flex: 1; }

.cat-section {
  background: #2a2a2a;
  border-radius: 4px;
  margin-bottom: 6px;
  overflow: hidden;
}
.cat-section.expanded { background: #2f2f2f; }

.cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}
.cat-header:hover { background: #333; }
.cat-arrow { width: 12px; color: #888; font-size: 12px; text-align: center; }
.cat-header input[type=checkbox] { accent-color: #27ae60; cursor: pointer; }
.cat-name { flex: 1; }
.cat-section.expanded .cat-name { color: #fff; font-weight: 500; }
.cat-count { color: #888; font-size: 12px; }

.cat-marker-list {
  list-style: none;
  padding: 0 10px 10px 30px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.cat-marker-list .marker-item {
  padding: 6px 8px;
  background: #222;
  border-radius: 3px;
  font-size: 12px;
}
.cat-marker-list .marker-item:hover { background: #383838; }
.cat-marker-list .marker-item .level {
  background: #3a3a3a;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  color: #aaa;
}
.cat-marker-list .empty-list {
  color: #666; font-size: 12px; padding: 6px; text-align: center;
}
/* ========== Фильтр по уровню ========== */
.level-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #bbb;
}
.level-filter input {
  width: 70px;
  padding: 6px 8px;
  background: #3a3a3a;
  color: #e8e8e8;
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}
.level-filter input:focus {
  outline: none;
  border-color: #27ae60;
}
.level-filter input::-webkit-outer-spin-button,
.level-filter input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.level-filter input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}