/* =================================================================
   Live map section (#network). Not in the hand-off (decision D3): a .panel
   card using the design's field, button and list styles. Element ids are
   owned by static/js/public_map.js; classes here are prefixed mp-.
   ================================================================= */

.mp { display: flex; flex-direction: column; gap: 16px; padding: 24px; }

.mp__controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 16px;
}
.mp__search { position: relative; }
.mp__search input { padding-left: 42px; }
.mp__search svg {
  position: absolute; left: 14px; bottom: 13px;
  width: 20px; height: 20px; color: var(--grey-300); pointer-events: none;
}
.field select {
  appearance: none; -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.mp__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font-size: 14px; font-weight: 500; color: var(--grey-400);
}
.mp__bar strong { color: var(--grey-500); font-weight: 600; }
.mp__actions { display: flex; gap: 8px; align-items: center; }
.mp__actions .btn { height: 40px; padding-inline: 20px; font-size: 14px; }

.mp__stage { position: relative; }
.mp__map {
  height: 70vh; min-height: 420px; max-height: 720px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--grey-100);
  border: 1px solid var(--grey-200);
}

/* OSM fallback tiles (no MAP_TILE_URL) are busy; desaturate them so the BEV/H2
   markers carry the colour. The Stadia basemap is already light and gets no filter. */
.mp__map--osm .leaflet-tile-pane { filter: grayscale(1) brightness(1.04); }
.mp__loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 14px; color: var(--grey-400);
}
.mp__loading span {
  display: block; width: 36px; height: 36px; margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid var(--midnight-100); border-top-color: var(--midnight-300);
  animation: mp-spin 1s linear infinite;
}
@keyframes mp-spin { to { transform: rotate(360deg); } }

.mp__overlay { position: absolute; top: 12px; right: 12px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.mp__iconbtn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--grey-200); border-radius: var(--r-sm);
  background: var(--white); color: var(--grey-500); cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.mp__iconbtn:hover { background: var(--midnight-100); border-color: var(--midnight-300); }
.mp__iconbtn svg { width: 20px; height: 20px; }

.mp__legend {
  position: absolute; bottom: 12px; left: 12px; z-index: 1000;
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--grey-200); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, .92);
  font-size: 13px; font-weight: 500; color: var(--grey-500);
}
.mp__legend span { display: inline-flex; align-items: center; gap: 8px; }
.mp__dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.mp__dot--bev { background: var(--midnight-300); }
.mp__dot--h2 { background: var(--midnight-500); box-shadow: 0 0 0 2px var(--midnight-200); }

/* --- list view --- */
.mp__list { overflow-x: auto; border: 1px solid var(--grey-200); border-radius: var(--r-md); background: var(--white); }
.mp__table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mp__table th {
  padding: 12px 16px; text-align: left;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--grey-400); background: #f6f8f8; border-bottom: 1px solid var(--grey-200);
}
.mp__table td { padding: 12px 16px; border-bottom: 1px solid var(--grey-100); vertical-align: top; }
.mp__table tr:last-child td { border-bottom: 0; }
.mp-row__name { font-weight: 600; color: var(--grey-500); }
.mp-row__sub { font-size: 13px; color: var(--grey-400); }
.mp-linkbtn { background: none; border: 0; padding: 0; color: var(--midnight-300); font-weight: 600; cursor: pointer; }
.mp-linkbtn:hover { color: var(--midnight-500); text-decoration: underline; }
.mp-muted { color: var(--grey-300); }

/* --- tag, key/value rows, tiles (popup + modal) --- */
.mp-tag {
  display: inline-block; margin-left: 8px; padding: 2px 8px;
  border-radius: var(--r-pill); font-size: 11px; font-weight: 600; vertical-align: middle;
}
.mp-tag--bev { background: var(--midnight-100); color: var(--midnight-500); }
.mp-tag--h2 { background: var(--midnight-500); color: var(--midnight-100); }
.mp-kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.mp-kv span:first-child { color: var(--grey-400); }
.mp-kvs { display: flex; flex-direction: column; gap: 4px; }
.mp-h { font-size: 14px; font-weight: 600; color: var(--grey-500); margin-bottom: 8px; }
.mp-p { font-size: 14px; color: var(--grey-400); }
.mp-block { margin-top: 20px; }
.mp-block:first-child { margin-top: 0; }
.mp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 14px; }
.mp-cols p { margin: 0; }
.mp-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; text-align: center; }
.mp-tiles--1 { grid-template-columns: 1fr; }
.mp-tile { padding: 12px; border-radius: var(--r-sm); background: #f6f8f8; border: 1px solid var(--grey-100); }
.mp-tile__v { font-size: 24px; font-weight: 600; color: var(--midnight-300); letter-spacing: -.02em; }
.mp-tile__l { font-size: 13px; color: var(--grey-400); }
.mp-rows { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.mp-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; border-radius: 8px; background: #f6f8f8; }
.mp-rows li span:first-child { font-weight: 500; }
.mp-rows li span:last-child { color: var(--grey-400); }
.mp-popup { padding: 12px; }
.mp-popup__title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.mp-popup__addr { font-size: 13px; color: var(--grey-400); margin-bottom: 8px; }
.mp-popup .btn { width: 100%; height: 40px; margin-top: 12px; font-size: 14px; }
.mp-modal__actions { margin-top: 20px; }
.mp-modal__actions .btn { width: 100%; }

/* --- modal --- */
.mp-modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(2, 34, 42, .55);
}
.mp-modal[hidden] { display: none; }
.mp-modal__box {
  width: 100%; max-width: 640px; max-height: 90vh;
  display: flex; flex-direction: column;
  border-radius: var(--r-lg); background: var(--white);
  box-shadow: var(--shadow-3); overflow: hidden;
}
.mp-modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--grey-200);
}
.mp-modal__head h3 { font-size: 18px; font-weight: 600; }
.mp-modal__body { padding: 24px; overflow-y: auto; }

/* --- markers (moved from public_map.js) --- */
.mp-marker {
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .3);
  color: var(--white); font-size: 11px; font-weight: 700;
}
.mp-marker--bev { background: var(--midnight-300); }
.mp-marker--h2 { background: var(--midnight-500); box-shadow: 0 0 0 2px var(--midnight-200), 0 2px 4px rgba(0, 0, 0, .3); }
.mp-marker span { transform: rotate(45deg); display: block; }

.marker-cluster { background-color: rgba(158, 232, 250, .55); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.marker-cluster-medium { background-color: rgba(5, 79, 97, .35); }
.marker-cluster-large { background-color: rgba(2, 34, 42, .45); }
.marker-cluster div {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--white); color: var(--midnight-500); font-weight: 600; font-size: 12px;
}
.user-location-marker { width: 20px; height: 20px; background: #4285f4; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.custom-popup .leaflet-popup-content-wrapper { border-radius: var(--r-sm); padding: 0; font-family: inherit; }
.custom-popup .leaflet-popup-content { margin: 0; }
.leaflet-container { font-family: inherit; }

@media (max-width: 1024px) {
  .mp__controls { grid-template-columns: 1fr 1fr; }
  .mp__search { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .mp { padding: 12px; }
  .mp__controls { grid-template-columns: 1fr; }
  .mp__map { height: 60vh; }
  .mp-cols, .mp-tiles { grid-template-columns: 1fr; }
  .mp__legend { display: none; }
}
