/* Карта — design/work/maps.html */

.map-status-help {
  margin: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  padding: 0;
}

.map-status-help summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  color: #3a5a38;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  list-style: none;
}

.map-status-help summary::-webkit-details-marker {
  display: none;
}

.map-status-help summary svg {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.map-status-help[open] summary svg {
  transform: rotate(180deg);
}

.map-status-help ul {
  margin: 0;
  padding: 0 1rem 0.85rem 1.75rem;
  color: #6b7280;
  font-size: 0.8125rem;
  line-height: 1.55;
}

.map-status-help li + li {
  margin-top: 0.35rem;
}

/* Статистика */
.map-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.map-stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.map-stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #f9fafb;
  color: #6b7280;
}

.map-stat-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

.map-stat-icon--green {
  background: #e8f5e9;
  color: #3a5a38;
}

.map-stat-icon--yellow {
  background: #fef3c7;
  color: #d97706;
}

.map-stat-icon--grey {
  background: #f3f4f6;
  color: #6b7280;
}

.map-stat-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: block;
}

.map-stat-dot--green {
  background: #3a5a38;
}

.map-stat-dot--yellow {
  background: #d97706;
}

.map-stat-dot--grey {
  background: #9ca3af;
}

.map-stat-info h4 {
  margin: 0 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
}

.map-stat-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.2;
}

.map-stat-note {
  font-size: 0.75rem;
  font-weight: 500;
  color: #d97706;
}

/* Фильтры */
.map-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  padding: 1rem 1.15rem !important;
  margin: 0 !important;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.map-filters > label:not(.map-cluster-label) {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
}

.map-filters select,
.map-filters input:not([type="checkbox"]) {
  width: 100%;
  height: 38px;
  padding: 0 2rem 0 0.75rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.875rem;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  appearance: none;
  color: #1f2937;
}

.map-filters label.map-cluster-label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  height: 38px;
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #2c4c3b;
  cursor: pointer;
  user-select: none;
  padding: 0 0.25rem;
}

.map-filters label.map-cluster-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-width: 0;
  max-width: 1rem;
  margin: 0;
  padding: 0;
  background-image: none;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  cursor: pointer;
}

.map-filters #map-reset {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 38px;
  padding: 0 1.1rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #3a5a38;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}

.map-filters #map-reset:hover {
  background: #f9fafb;
}

/* Карта + список — фиксированная высота, прокрутка только в сайдбаре */
.map-container {
  --map-block-height: 420px;
  display: flex;
  align-items: stretch;
  height: var(--map-block-height);
  max-height: var(--map-block-height);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.map-view.map-stage {
  position: relative;
  flex: 1 1 0%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  border: none;
  border-radius: 0;
  background: #dbeafe;
  margin: 0;
  overflow: hidden;
}

#maplibre {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-basemap-status {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 2;
  margin: 0;
  max-width: min(22rem, calc(100% - 5rem));
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 2px 10px rgba(31, 41, 55, 0.12);
  pointer-events: none;
}

.map-basemap-status--loading,
.map-basemap-status--fallback {
  background: rgba(255, 255, 255, 0.94);
  color: #3a5a38;
  border: 1px solid rgba(58, 90, 56, 0.18);
}

.map-basemap-status--ok {
  background: rgba(232, 245, 233, 0.95);
  color: #2e4a3e;
  border: 1px solid rgba(58, 90, 56, 0.22);
}

.map-basemap-status--error {
  background: rgba(254, 242, 242, 0.96);
  color: #991b1b;
  border: 1px solid rgba(185, 28, 28, 0.25);
}

#maplibre .maplibregl-map,
#maplibre .maplibregl-canvas-container,
#maplibre canvas.maplibregl-canvas {
  width: 100% !important;
  height: 100% !important;
}

.map-sidebar {
  width: min(350px, 38vw);
  flex: 0 0 min(350px, 38vw);
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  background: #fff;
  overflow: hidden;
}

.map-sidebar-header {
  flex: 0 0 auto;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.8125rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.4;
}

.map-sidebar-search {
  flex: 0 0 auto;
  display: block;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fafbfa;
}

.map-sidebar-search .ui-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.8125rem;
  padding: 0.45rem 0.65rem;
  border-color: #e5e7eb;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.map-sidebar-header svg {
  flex-shrink: 0;
  color: #3a5a38;
}

.map-sidebar-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0.85rem;
  background: #fff;
}

.map-sidebar-empty {
  margin: 0;
  padding: 0.75rem 0.35rem;
  color: #9ca3af;
  font-size: 0.875rem;
}

.map-list-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.8rem 0.85rem;
  margin-bottom: 0.65rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.map-list-item:hover {
  border-color: #c5d9c3;
  box-shadow: 0 2px 8px rgba(58, 90, 56, 0.08);
}

.map-list-item:last-child {
  margin-bottom: 0;
}

.map-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.map-item-id {
  font-weight: 700;
  color: #3a5a38;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

.map-item-name {
  font-weight: 600;
  color: #1f2937;
  font-size: 0.9rem;
  line-height: 1.35;
  margin: 0 0 0.2rem;
}

.map-item-region {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  color: #6b7280;
  line-height: 1.4;
}

.map-item-country {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #374151;
}

.map-item-country--empty {
  color: #9ca3af;
}

.map-item-kicker {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
  margin-right: 0.15rem;
}

.map-item-country-value {
  font-weight: 600;
  color: #2e4a3e;
}

.map-item-country-note {
  display: inline-block;
  margin-left: 0.15rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 0.6875rem;
  font-weight: 500;
  vertical-align: middle;
}

.map-item-hint {
  margin: 0 0 0.45rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.6875rem;
  line-height: 1.4;
}

.map-item-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  background: #f3f4f6;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}

.map-item-tag-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.map-item-tag.status-valid {
  background: #e8f5e9;
  color: #2e7d32;
}

.map-item-tag.status-missing,
.map-item-tag.status-zero_zero {
  background: #f3f4f6;
  color: #6b7280;
}

.map-item-tag.status-invalid_range {
  background: #fdecec;
  color: #9f1239;
}

.map-item-tag.status-suspected_swap {
  background: #fef3c7;
  color: #92400e;
}

.map-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.map-btn-open {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 0.75rem;
  color: #6b7280;
  text-decoration: none;
  background: #fff;
  transition: background-color 0.2s ease;
}

.map-btn-open:hover {
  background: #f9fafb;
  color: #3a5a38;
}

.map-item-details {
  margin: 0;
  font-size: 0.75rem;
}

.map-item-details summary {
  color: #3a5a38;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.map-item-details summary::-webkit-details-marker {
  display: none;
}

.map-item-details .muted {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .map-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .map-container {
    --map-block-height: auto;
    flex-direction: column;
    height: auto;
    max-height: none;
  }

  .map-view.map-stage {
    min-height: 380px;
  }

  #maplibre {
    position: absolute;
    inset: 0;
  }

  .map-sidebar {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: none;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  .map-sidebar-list {
    max-height: 360px;
  }
}

@media (max-width: 640px) {
  .map-stats-grid {
    grid-template-columns: 1fr;
  }

  .map-filters > label:not(.map-cluster-label) {
    flex: 1 1 100%;
  }
}
