/* Live entity maps: polygon overlay + category legend + call markers. */
.elm-layout {
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  width: 100%;
  background: #0f1419;
  color: #e6edf3;
}

.elm-top {
  padding: 0.7rem 1rem;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
  align-items: center;
  z-index: 500;
}

.elm-top h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.elm-meta {
  color: #8b949e;
  font-size: 0.88rem;
  flex: 1 1 12rem;
}

.elm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.elm-actions button,
.elm-actions a.btn,
.elm-sheet button {
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 650;
  background: #21262d;
  color: #c9d1d9;
  font-family: inherit;
}

.elm-actions button.primary,
.elm-sheet button.primary {
  background: #1f6feb;
  color: #fff;
  border-color: #1f6feb;
}

.elm-search {
  padding: 0.38rem 0.6rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #0d1117;
  color: #e6edf3;
  font-size: 0.88rem;
  min-width: 11rem;
}

.elm-status {
  display: inline-flex;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #21262d;
  color: #c9d1d9;
}

.elm-status.working { background: #12203a; color: #58a6ff; }
.elm-status.ok { background: #12261e; color: #3fb950; }
.elm-status.warn { background: #2a2410; color: #d29922; }

.elm-error {
  flex: 1 1 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #3d1214;
  border: 1px solid #f85149;
  color: #f85149;
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}

.elm-stage {
  display: flex;
  min-height: 0;
  min-width: 0;
  height: 100%;
}

.elm-legend {
  width: 220px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(22, 27, 34, 0.94);
  border-right: 1px solid #30363d;
  overflow: hidden;
  transition: width 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), border-width 0.24s;
}

.elm-legend.is-closed {
  width: 0;
  border-right-width: 0;
}

.elm-legend-inner {
  width: 220px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 8px;
}

.elm-legend-head {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
}

.elm-legend-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.elm-legend-hint {
  margin: 2px 0 0;
  color: #8b949e;
  font-size: 11px;
  font-weight: 600;
}

.elm-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #e6edf3;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex: 0 0 auto;
}

.elm-legend-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.elm-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 8px;
  background: transparent;
  color: #e6edf3;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.elm-legend-row.is-on {
  border-color: #fff;
  border-width: 2px;
  padding: 7px;
}

.elm-legend-row:disabled,
.elm-legend-row.is-off {
  opacity: 0.55;
}

.elm-legend-row:disabled { cursor: default; }

.elm-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1.5px solid #fff;
  flex: 0 0 auto;
}

.elm-legend-copy { flex: 1; min-width: 0; }
.elm-legend-label,
.elm-legend-meta { display: block; }
.elm-legend-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}
.elm-legend-meta {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.8;
}

.elm-cat-block {
  flex: 0 1 auto;
  max-height: 42%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #30363d;
}

.elm-cat-block h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
}

.elm-cat-scroll {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  min-height: 0;
}

.elm-cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #e6edf3;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 6px;
}

.elm-cat-row.is-off { opacity: 0.45; }
.elm-cat-label { flex: 1; font-size: 12px; font-weight: 700; min-width: 0; }
.elm-cat-count { font-size: 12px; font-weight: 700; color: #8b949e; }

.elm-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #161b22;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  flex: 0 0 auto;
}

.elm-map-pane {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.elm-map-pane #map {
  position: absolute;
  inset: 0;
}

.elm-tab {
  position: absolute;
  left: 0;
  top: 72px;
  z-index: 450;
  width: 72px;
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: rgba(22, 27, 34, 0.96);
  border: 1.5px solid #58a6ff;
  border-left-width: 0;
  border-radius: 0 14px 14px 0;
  color: #58a6ff;
  cursor: pointer;
  font-family: inherit;
}

.elm-tab-dots { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.elm-tab-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #fff;
}
.elm-tab-label { color: #e6edf3; font-size: 11px; font-weight: 800; }

.elm-card {
  position: absolute;
  left: 16px;
  right: 168px;
  bottom: 16px;
  z-index: 460;
  background: rgba(255, 255, 255, 0.96);
  color: #1a202c;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.elm-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 2px;
}

.elm-card-title .elm-card-name { flex: 1; min-width: 0; }
.elm-card-meta { margin: 2px 0; font-size: 14px; font-weight: 600; color: #2d3748; }
.elm-card-meta a { color: #2b6cb0; }
.elm-card-close {
  border: 0;
  background: transparent;
  color: #4a5568;
  font-size: 18px;
  cursor: pointer;
  padding: 0 0 0 8px;
}

.elm-empty {
  position: absolute;
  inset: 0;
  z-index: 420;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(15, 20, 25, 0.55);
  color: #e6edf3;
  font-size: 15px;
  pointer-events: none;
}

.elm-scrim {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(1, 4, 9, 0.62);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 16px 16px;
}

.elm-sheet {
  width: min(440px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: #161b22;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.elm-sheet-head,
.elm-sheet-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
}

.elm-sheet-head { border-bottom: 1px solid #30363d; }
.elm-sheet-foot { border-top: 1px solid #30363d; justify-content: flex-end; }
.elm-sheet-head h2 { margin: 0; font-size: 1.05rem; }
.elm-sheet-head p { margin: 2px 0 0; color: #8b949e; font-size: 0.8rem; }
.elm-sheet-head .grow { flex: 1; }

.elm-sheet-body {
  overflow: auto;
  padding: 8px 14px 14px;
}

.elm-section {
  border: 1px solid #30363d;
  border-radius: 10px;
  margin-top: 10px;
  background: #0d1117;
}

.elm-section > button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #e6edf3;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}

.elm-section > button strong { display: block; font-size: 0.92rem; }
.elm-section > button span { color: #8b949e; font-size: 0.78rem; font-weight: 600; }

.elm-section.is-collapsed .elm-section-body { display: none; }
.elm-section-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }

.elm-ms-btn {
  width: 100%;
  text-align: left;
  background: #161b22 !important;
  color: #e6edf3 !important;
  border: 1px solid #30363d !important;
  border-radius: 8px;
  padding: 8px 10px !important;
  cursor: pointer;
  font: inherit;
  display: flex !important;
  justify-content: space-between;
  gap: 8px;
}

.elm-ms-btn em {
  font-style: normal;
  color: #8b949e;
  font-weight: 650;
  font-size: 0.82rem;
}

.elm-ms-panel {
  border: 1px solid #30363d;
  border-radius: 8px;
  background: #161b22;
  padding: 8px;
}

.elm-ms-panel input {
  width: 100%;
  margin-bottom: 6px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #e6edf3;
}

.elm-ms-list {
  max-height: 180px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.elm-ms-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  padding: 4px 2px;
  cursor: pointer;
}

.elm-hint { margin: 4px 0 0; color: #8b949e; font-size: 0.75rem; }

.elm-scrim[hidden],
.elm-tab[hidden],
.elm-empty[hidden],
.elm-card[hidden],
.elm-error[hidden],
.elm-ms-panel[hidden] {
  display: none !important;
}

.leaflet-container { background: #0d1117; font-family: inherit; }

.leaflet-div-icon.elm-school-pin {
  background: transparent;
  border: none;
}

.elm-school-pin-face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #1f6feb;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  color: #fff;
}

.elm-school-popup-wrap .leaflet-popup-content-wrapper {
  background: #161b22;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 12px;
}

.elm-school-popup-wrap .leaflet-popup-tip {
  background: #161b22;
}

.elm-school-popup-wrap .leaflet-popup-content {
  margin: 12px 14px;
}

.elm-school-popup-name {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
  max-width: 240px;
}

.elm-school-popup-meta {
  margin: 0 0 8px;
  color: #8b949e;
  font-size: 13px;
  font-weight: 600;
}

.elm-school-popup-actions {
  display: flex;
  gap: 8px;
}

.elm-school-edit,
.elm-school-delete {
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #e6edf3;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
}

.elm-school-edit {
  border-color: #1f6feb;
  color: #58a6ff;
}

.elm-school-delete {
  border-color: #f85149;
  color: #f85149;
}

.elm-school-edit:disabled,
.elm-school-delete:disabled {
  opacity: 0.55;
  cursor: default;
}

.elm-school-popup-msg {
  margin-top: 8px;
  color: #f85149;
  font-size: 12px;
  font-weight: 600;
}

.elm-school-pin.is-selected .elm-school-pin-face {
  background: #da3633;
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.55);
}

.master-only { display: none; }
body.portal-is-master .elm-actions .master-only,
body.portal-is-master .elm-school-popup-actions .master-only {
  display: inline-flex;
}

.elm-legend-search {
  width: 100%;
  margin-top: 8px;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #e6edf3;
  font: inherit;
  font-size: 0.85rem;
}

.elm-editor {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 800;
  max-height: min(52vh, 460px);
  overflow: auto;
  background: rgba(22, 27, 34, 0.97);
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 0.9rem 1rem 1rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.elm-editor h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.elm-editor-hint {
  margin: 0 0 0.7rem;
  color: #d29922;
  font-size: 0.82rem;
}

.elm-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.55rem 0.7rem;
}

.elm-editor-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #8b949e;
}

.elm-editor-field input,
.elm-editor-field select {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #0d1117;
  color: #e6edf3;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
}

.elm-editor-error {
  margin: 0.65rem 0 0;
  color: #f85149;
  font-size: 0.82rem;
  font-weight: 700;
}

.elm-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.elm-editor-actions button {
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #30363d;
  background: #21262d;
  color: #e6edf3;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.elm-editor-actions button.ok {
  background: #238636;
  border-color: #238636;
  color: #fff;
}

.elm-editor-actions button:disabled {
  opacity: 0.55;
  cursor: default;
}

body.elm-school-editing .elm-card {
  display: none !important;
}

@media (max-width: 720px) {
  .elm-card { right: 16px; }
  .elm-legend { width: 180px; }
  .elm-legend-inner { width: 180px; }
}
