/* ================================================================== */
/* Atlas Studio V6 — módulo de medición y geodesia                    */
/* ================================================================== */

/* ---------- HUD de coordenadas ---------- */
.mm-hud {
  position: absolute; left: var(--mm-hud-left, 14px); bottom: var(--mm-hud-bottom, 14px); z-index: 9;
  display: flex; align-items: flex-end; gap: 6px;
  max-width: calc(100% - var(--mm-hud-left, 14px) - 14px);
  font-family: "DM Sans", sans-serif;
}
.mm-hud-card {
  position: relative; min-width: 0;
  display: grid; gap: 1px; padding: 5px 6px 6px;
  border: 1px solid rgba(159, 210, 220, .2); border-radius: 12px;
  background: rgba(5, 20, 31, .78);
  backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3), inset 0 1px rgba(255, 255, 255, .04);
}
.mm-hud-row {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  border: 0; background: transparent; color: #e3eef2; cursor: pointer;
  padding: 3px 5px; border-radius: 7px; text-align: left;
  font: 600 11.5px/1.2 "DM Sans", sans-serif; font-variant-numeric: tabular-nums;
  transition: background .15s ease;
}
.mm-hud-row:hover { background: rgba(255, 255, 255, .06); }
.mm-hud-row.mm-grid { color: #aac0ca; font-size: 10.5px; font-weight: 500; }
.mm-tag {
  flex: none; min-width: 34px; padding: 2px 5px; border-radius: 5px; text-align: center;
  font: 800 8.5px/1.3 Manrope, sans-serif; letter-spacing: .06em;
  color: #49d6c5; background: rgba(73, 214, 197, .1); border: 1px solid rgba(73, 214, 197, .22);
}
.mm-grid .mm-tag { color: #f2b84b; background: rgba(242, 184, 75, .09); border-color: rgba(242, 184, 75, .22); }
.mm-val { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.mm-elev {
  flex: none; margin-left: 2px; padding-left: 8px; border-left: 1px solid rgba(159, 210, 220, .18);
  color: #f5d38c; font-weight: 700;
}
.mm-elev.depth { color: #7cc3f2; }
.mm-elev[hidden] { display: none; }
.mm-src {
  position: absolute; right: 9px; top: -8px; padding: 0 5px; border-radius: 99px;
  font: 700 7.5px/13px Manrope, sans-serif; letter-spacing: .1em; text-transform: uppercase;
  color: #8fa8b5; background: #0a1b28; border: 1px solid rgba(159, 210, 220, .16);
  pointer-events: none;
}
.mm-hud-actions { display: grid; gap: 5px; }
.mm-icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid rgba(159, 210, 220, .2); border-radius: 10px; color: #cfe1e7;
  background: rgba(5, 20, 31, .78); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28); transition: .15s ease;
}
.mm-icon-btn svg { width: 15px; height: 15px; }
.mm-icon-btn:hover, .mm-icon-btn.active { color: #49d6c5; border-color: rgba(73, 214, 197, .45); background: rgba(8, 34, 46, .9); }
.mm-icon-btn.busy svg { animation: mmPulse 1s ease-in-out infinite; color: #49d6c5; }
@keyframes mmPulse { 50% { opacity: .35; transform: scale(.85); } }

/* ---------- Ir a coordenadas ---------- */
.mm-goto {
  position: absolute; left: 0; bottom: calc(100% + 8px); width: var(--mm-goto-w, min(340px, calc(100vw - 40px)));
  padding: 11px 12px 10px; border-radius: 13px;
  border: 1px solid rgba(73, 214, 197, .32); background: rgba(6, 22, 33, .95);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .42);
  animation: mmIn .16s ease;
}
.mm-goto[hidden] { display: none; }
@keyframes mmIn { from { opacity: 0; transform: translateY(6px); } }
.mm-goto label { display: block; margin-bottom: 7px; color: #cfe2ea; font: 800 9.5px Manrope, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.mm-goto-row { display: flex; gap: 6px; }
.mm-goto input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px; border-radius: 9px;
  color: var(--ink, #eaf3f7); background: rgba(0, 0, 0, .22); border: 1px solid rgba(157, 190, 205, .24);
  font: 500 13px "DM Sans", sans-serif;
}
.mm-goto input[aria-invalid="true"] { border-color: rgba(255, 123, 123, .7); }
.mm-go {
  flex: none; width: 38px; height: 36px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 9px; color: #06222a; background: #49d6c5; font-weight: 800;
}
.mm-go svg { width: 16px; height: 16px; }
.mm-go:hover { filter: brightness(1.08); }
.mm-goto small { display: block; margin-top: 8px; color: #8fa8b5; font-size: 10.5px; line-height: 1.55; }
.mm-goto small.error { color: #ff9b9b; }
.mm-goto small button {
  border: 0; padding: 0; background: none; cursor: pointer; color: #9fe6dc;
  font: 600 10.5px "DM Sans", sans-serif; text-decoration: underline dotted; text-underline-offset: 2px;
}
.mm-goto-foot { display: flex; justify-content: flex-end; }
.mm-link {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 3px 6px; cursor: pointer;
  border: 0; border-radius: 6px; background: rgba(255, 255, 255, .05); color: #cfe1e7; font-size: 10.5px;
}
.mm-link svg { width: 12px; height: 12px; }
.mm-link[hidden] { display: none; }

/* ---------- Panel de medición (ampliación del núcleo) ---------- */
.map-board.mm-has-hud #measurementPanel { bottom: var(--mm-panel-bottom, 92px); }
#measurementPanel {
  width: min(320px, calc(100% - 28px)); left: 14px;
  max-height: calc(100% - var(--mm-panel-bottom, 92px) - 20px); overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(157, 190, 205, .24) transparent;
}
.mm-extra[hidden] { display: none; }
.mm-extra { margin-top: 8px; display: grid; gap: 9px; }
.mm-dl { margin: 0; display: grid; gap: 4px; }
.mm-dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 5px; border-top: 1px solid var(--line, rgba(157,190,205,.14)); }
.mm-dl dt { color: var(--muted, #91a6b4); font-size: 11px; }
.mm-dl dd { margin: 0; color: #e7f2f5; font: 700 12.5px Manrope, sans-serif; text-align: right; }
.mm-dl dd span { color: #f2b84b; font: 600 11px "DM Sans", sans-serif; }

.mm-segments { border: 1px solid var(--line, rgba(157,190,205,.14)); border-radius: 9px; background: rgba(255, 255, 255, .02); }
.mm-segments summary { cursor: pointer; padding: 6px 9px; color: #cfe2ea; font: 800 9.5px Manrope, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.mm-segments ol { list-style: none; margin: 0; padding: 0 9px 6px; max-height: 128px; overflow-y: auto; }
.mm-segments li { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: baseline; padding: 3px 0; border-top: 1px dashed rgba(157, 190, 205, .12); font-size: 11px; font-variant-numeric: tabular-nums; }
.mm-seg-n { color: #617887; font-weight: 700; }
.mm-seg-d { color: #e7f2f5; font-weight: 600; }
.mm-seg-a { color: #f2b84b; }

.mm-profile { border: 1px solid rgba(73, 214, 197, .18); border-radius: 10px; padding: 7px 8px 8px; background: rgba(73, 214, 197, .03); }
.mm-profile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 3px; }
.mm-profile-head span { color: #cfe2ea; font: 800 9.5px Manrope, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.mm-profile-head small { display: inline-flex; align-items: center; gap: 5px; color: #617887; font-size: 9.5px; }
.mm-profile-head .mini-spinner { width: 10px; height: 10px; }
.mm-chart { min-height: 96px; }
.mm-chart-svg { display: block; width: 100%; height: auto; touch-action: none; overflow: visible; }
.mm-chart-skeleton { height: 108px; border-radius: 8px; background: linear-gradient(90deg, rgba(255,255,255,.03), rgba(73,214,197,.09), rgba(255,255,255,.03)); background-size: 200% 100%; animation: mmShimmer 1.2s linear infinite; }
@keyframes mmShimmer { to { background-position: -200% 0; } }
.mm-chart-msg { margin: 0; padding: 26px 8px; text-align: center; color: #ff9b9b; font-size: 11px; }
.mm-chart-svg .mm-grid line { stroke: rgba(157, 190, 205, .1); stroke-width: 1; }
.mm-chart-svg .mm-axis text { fill: #7f97a4; font: 500 8.5px "DM Sans", sans-serif; font-variant-numeric: tabular-nums; }
.mm-chart-svg .mm-vertex-lines line { stroke: rgba(242, 184, 75, .35); stroke-dasharray: 2 3; }
.mm-chart-svg .mm-line { fill: none; stroke: #49d6c5; stroke-width: 1.6; stroke-linejoin: round; }
.mm-chart-svg .mm-sea { stroke: #5aa8e0; stroke-dasharray: 4 3; stroke-width: 1; }
.mm-chart-svg .mm-sea-label { fill: #7cc3f2; font: 600 8px "DM Sans", sans-serif; }
.mm-chart-svg .mm-extreme { stroke: #06131e; stroke-width: 1; }
.mm-chart-svg .mm-extreme.max { fill: #f2b84b; }
.mm-chart-svg .mm-extreme.min { fill: #7cc3f2; }
.mm-chart-svg .mm-hit { fill: transparent; cursor: crosshair; }
.mm-chart-svg .mm-cursor { pointer-events: none; }
.mm-chart-svg .mm-cursor line { stroke: rgba(255, 248, 207, .75); stroke-width: 1; }
.mm-chart-svg .mm-cursor circle { fill: #fff8cf; stroke: #0b3f4b; stroke-width: 1.5; }
.mm-chart-svg .mm-tip rect { fill: rgba(4, 14, 22, .94); stroke: rgba(73, 214, 197, .4); }
.mm-chart-svg .mm-tip text { fill: #eaf3f7; font: 700 9.5px Manrope, sans-serif; }
.mm-chart-svg .mm-tip text.sub { fill: #8fa8b5; font: 500 8.5px "DM Sans", sans-serif; }
.mm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 5px; }
.mm-stats div { min-width: 0; padding: 4px 5px; border-radius: 6px; background: rgba(255, 255, 255, .03); }
.mm-stats div.wide { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.mm-stats span { display: block; color: #617887; font-size: 8.5px; text-transform: uppercase; letter-spacing: .06em; }
.mm-stats div.wide span { display: inline; }
.mm-stats strong { display: block; color: #e7f2f5; font: 700 11px Manrope, sans-serif; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mm-stats div.wide strong { display: inline; }
.mm-stats strong.up { color: #f5a36b; }
.mm-stats strong.down { color: #7cc3f2; }

.mm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 8px; cursor: pointer;
  border: 1px solid rgba(157, 190, 205, .22); border-radius: 9px; background: rgba(255, 255, 255, .04);
  color: #dbe9ee; font: 600 11px "DM Sans", sans-serif; white-space: nowrap;
}
.mm-btn svg { width: 13px; height: 13px; color: #49d6c5; flex: none; }
.mm-btn:hover { border-color: rgba(73, 214, 197, .45); background: rgba(73, 214, 197, .08); }

/* ---------- Elementos sobre el mapa (capa ampliada) ---------- */
.mm-seg-label {
  fill: #fff2a8; font-family: "DM Sans", sans-serif; font-weight: 700; text-anchor: middle;
  paint-order: stroke; stroke: rgba(6, 19, 30, .92); stroke-linejoin: round; pointer-events: none;
}
.mm-centroid { pointer-events: none; }
.mm-centroid-ring { fill: rgba(242, 184, 75, .18); stroke: #f2b84b; stroke-width: 1.6; }
.mm-centroid-cross { stroke: #f2b84b; stroke-width: 1.8; stroke-linecap: round; }
.mm-centroid-label { fill: #ffe3a6; font: 700 10px "DM Sans", sans-serif; paint-order: stroke; stroke: rgba(6, 19, 30, .9); stroke-width: 3px; }
.mm-profile-cursor { fill: #f2b84b; stroke: #06131e; pointer-events: none; filter: drop-shadow(0 0 4px rgba(242, 184, 75, .8)); }

.mm-pin { cursor: pointer; }
.mm-pin-shape { fill: #f2b84b; stroke: #3a2508; stroke-width: 1.2; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .45)); }
.mm-pin.gps .mm-pin-shape { fill: #49d6c5; stroke: #06303a; }
.mm-pin-dot { fill: #06131e; }
.mm-pin-accuracy { fill: rgba(73, 214, 197, .14); stroke: rgba(73, 214, 197, .6); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.mm-pin-label { fill: #fff8e4; font: 700 11px "DM Sans", sans-serif; paint-order: stroke; stroke: rgba(6, 19, 30, .92); stroke-width: 3.2px; stroke-linejoin: round; }
.mm-pin:hover .mm-pin-shape { fill: #ffd27a; }

/* ---------- Escala gráfica y flecha del norte (SVG, se exportan) ---------- */
.mm-overlay { pointer-events: none; }
.mm-overlay-card { fill: rgba(5, 18, 29, .82); stroke: rgba(160, 210, 228, .22); stroke-width: 1; }
.mm-scale-label { fill: #e6f0f4; font: 700 9px "DM Sans", sans-serif; font-variant-numeric: tabular-nums; }
.mm-scale-text { fill: #e6f0f4; font: 800 10.5px Manrope, sans-serif; }
.mm-scale-sub { fill: #8fa8b5; font: 500 8px "DM Sans", sans-serif; letter-spacing: .04em; }
.mm-north-label { fill: #f2b84b; font: 800 9.5px Manrope, sans-serif; }

/* ---------- Teléfonos ---------- */
@media (max-width: 720px) {
  .mm-hud { max-width: calc(100% - 16px); gap: 4px; }
  .mm-hud-card { padding: 4px 4px 5px; }
  .mm-hud-row { font-size: 10.5px; gap: 5px; padding: 2px 4px; }
  .mm-hud-row.mm-grid { font-size: 9.5px; }
  .mm-tag { min-width: 28px; font-size: 7.5px; padding: 1px 4px; }
  .mm-icon-btn { width: 30px; height: 30px; }
  .map-board.mm-has-hud #measurementPanel { left: 8px; width: calc(100% - 16px); }
}
@media (max-width: 400px) {
  .mm-elev { padding-left: 5px; }
  .mm-actions { grid-template-columns: 1fr; }
}

/* ---------- Contraer panel ---------- */
.mm-collapse {
  position: absolute; top: 9px; right: 9px; width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid rgba(157, 190, 205, .2); border-radius: 8px; background: rgba(255, 255, 255, .04); color: #9fb4bf;
}
.mm-collapse svg { width: 14px; height: 14px; transition: transform .2s ease; }
.mm-collapse:hover { color: #49d6c5; border-color: rgba(73, 214, 197, .4); }
#measurementPanel.mm-collapsed .mm-collapse svg { transform: rotate(180deg); }
#measurementPanel.mm-collapsed #measurementHint,
#measurementPanel.mm-collapsed .mm-dl,
#measurementPanel.mm-collapsed .mm-segments,
#measurementPanel.mm-collapsed .mm-profile { display: none; }
#measurementPanel.mm-collapsed #measurementTitle { margin-bottom: 6px; }
