/* =========================================================
   RedControl · Mapa / credenciales V13
   ========================================================= */

/* Acciones permanentes dentro del workspace: siguen visibles en fullscreen. */
.map-workspace-actions {
    position: sticky;
    top: 0;
    z-index: 8;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--rc-surface) 94%, transparent);
    border-bottom: 1px solid var(--rc-border);
    backdrop-filter: blur(8px);
}
.map-workspace-actions .rz-button { width: 100%; justify-content: center; }

.map-help-text {
    margin: 6px 0 2px;
    color: var(--rc-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

.map-selection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}

.map-symbol-preview,
.map-managed-icon {
    --item-color: var(--rc-primary);
    display: inline-grid;
    place-items: center;
    color: #fff;
    background: var(--item-color);
    border: 2px solid color-mix(in srgb, #fff 78%, transparent);
    box-shadow: 0 2px 7px color-mix(in srgb, var(--item-color) 35%, transparent);
}
.map-symbol-preview {
    width: 30px;
    height: 30px;
    border-radius: 9px 9px 9px 2px;
}
.map-symbol-preview.line-symbol { border-radius: 50%; }
.map-symbol-preview .rz-icon { font-size: 16px; }

.route-help-stack {
    display: grid;
    gap: 5px;
}
.route-help-stack > span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.route-help-stack .rz-icon { color: var(--rc-primary); font-size: 14px; }
.route-point-count {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 8px 0 10px;
    padding: 7px 9px;
    border-radius: 7px;
    background: var(--rc-surface-soft);
    color: var(--rc-muted);
    font-size: 10.5px;
    font-weight: 650;
}
.route-point-count .rz-icon { color: var(--rc-primary); }

/* Gestión compacta de marcadores y rutas. */
.map-management-section { padding-bottom: 12px; }
.map-managed-group + .map-managed-group { margin-top: 12px; }
.map-managed-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 6px;
    color: var(--rc-muted);
    font-size: 10px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .045em;
}
.map-managed-title b {
    min-width: 22px;
    padding: 2px 6px;
    text-align: center;
    border-radius: 999px;
    color: var(--rc-text);
    background: var(--rc-surface-soft);
}
.map-managed-list {
    display: grid;
    gap: 4px;
    max-height: 190px;
    overflow: auto;
    padding-right: 2px;
}
.map-managed-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 7px;
    padding: 5px 6px;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: background .15s ease, border-color .15s ease;
}
.map-managed-row:hover {
    background: var(--rc-surface-soft);
    border-color: var(--rc-border);
}
.map-managed-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
}
.map-managed-icon .rz-icon { font-size: 14px; }
.map-managed-name,
.map-managed-action {
    border: 0;
    background: transparent;
    color: var(--rc-text);
    cursor: pointer;
}
.map-managed-name {
    min-width: 0;
    display: grid;
    gap: 1px;
    padding: 0;
    text-align: left;
}
.map-managed-name b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 650;
}
.map-managed-name small { color: var(--rc-muted); font-size: 9.5px; }
.map-managed-action {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
}
.map-managed-action:hover { background: color-mix(in srgb, var(--rc-primary) 10%, transparent); color: var(--rc-primary); }
.map-managed-action .rz-icon { font-size: 15px; }
.map-managed-empty { display: block; color: var(--rc-muted); font-size: 10.5px; padding: 4px 0; }

/* Icono visual al centro de enlaces y rutas. */
.network-line-icon-wrap { background: transparent !important; border: 0 !important; }
.network-line-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--line-color);
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 3px 10px rgba(15, 23, 42, .32);
}
.network-line-icon .rzi { font-size: 15px; }

/* Barra flotante: con las nuevas acciones puede crecer sin tapar el mapa. */
.map-floating-tools { max-height: calc(100% - 28px); overflow: visible; }
.map-workspace:fullscreen .map-tools {
    height: 100vh;
    overflow: auto;
}
.map-workspace:fullscreen .map-workspace-actions { top: 0; }

/* Editor de iconos de catálogos. */
.catalog-map-icon-editor {
    display: flex;
    align-items: center;
    gap: 8px;
}
.catalog-map-icon-editor .rz-dropdown { flex: 1; min-width: 0; }
.catalog-map-icon-preview,
.catalog-map-icon-cell {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    color: #fff;
    background: var(--icon-color, var(--rc-primary));
    box-shadow: 0 2px 6px color-mix(in srgb, var(--icon-color, var(--rc-primary)) 30%, transparent);
}
.catalog-map-icon-preview .rz-icon,
.catalog-map-icon-cell .rz-icon { font-size: 16px; }

/* Credenciales de equipos. */
.credential-section-head {
    align-items: flex-start;
}
.credential-section-head > div:first-child { display: grid; gap: 2px; }
.credential-section-head span:not(.rz-icon) { color: var(--rc-muted); font-size: 10.5px; font-weight: 450; }
.credential-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, #16a34a 10%, transparent);
    color: #15803d !important;
    font-size: 10px !important;
    font-weight: 700 !important;
}
.credential-status .rz-icon { font-size: 13px; }
.credential-password-input {
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--rc-border);
    border-radius: 5px;
    background: var(--rc-surface);
    color: var(--rc-text);
    outline: 0;
}
.credential-password-input:focus {
    border-color: var(--rc-primary);
    box-shadow: 0 0 0 3px var(--rc-focus-ring);
}
.credential-password-input:disabled { opacity: .55; cursor: not-allowed; }
.credential-remove-option {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    min-height: 28px;
    color: var(--rc-muted);
    font-size: 10.5px;
}

.equipment-access-card { margin-top: 14px; }
.equipment-access-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}
.equipment-access-head > div:first-child { display: flex; align-items: flex-start; gap: 9px; }
.equipment-access-head h2 { margin: 0; }
.equipment-access-head p { margin: 3px 0 0; color: var(--rc-muted); font-size: 11px; }
.credential-view-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.credential-view-grid > div {
    position: relative;
    min-width: 0;
    display: grid;
    gap: 4px;
    padding: 10px 38px 10px 11px;
    border: 1px solid var(--rc-border);
    border-radius: 9px;
    background: var(--rc-surface-soft);
}
.credential-view-grid span { color: var(--rc-muted); font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .045em; }
.credential-view-grid strong { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.credential-secret { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.icon-copy-button {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--rc-muted);
    cursor: pointer;
}
.icon-copy-button:hover { background: color-mix(in srgb, var(--rc-primary) 10%, transparent); color: var(--rc-primary); }
.icon-copy-button .rz-icon { font-size: 14px; }

@media (max-width: 760px) {
    .map-workspace-actions { position: static; }
    .credential-view-grid { grid-template-columns: 1fr; }
    .equipment-access-head { align-items: stretch; flex-direction: column; }
}

/* =========================================================
   RedControl · Mapa V15
   - Vista inmersiva sin Fullscreen API para que los diálogos
     de Radzen sigan siendo utilizables.
   - Panel lateral plegable.
   - Mejor interacción de rutas y clusters.
   ========================================================= */

body.map-immersive-open {
    overflow: hidden !important;
}

.map-workspace.map-immersive {
    position: fixed !important;
    inset: 0 !important;
    z-index: 900 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: none !important;
    display: grid !important;
    grid-template-columns: minmax(320px, 360px) minmax(0, 1fr) !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--rc-surface) !important;
    box-shadow: none !important;
}

.map-workspace.map-immersive .map-tools {
    width: auto !important;
    height: 100dvh !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    border-right: 1px solid var(--rc-border);
    background: var(--rc-surface);
}

.map-workspace.map-immersive .map-canvas-wrap,
.map-workspace.map-immersive .network-map {
    min-width: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    border-radius: 0 !important;
}

.map-workspace.map-immersive.map-panel-collapsed {
    grid-template-columns: 0 minmax(0, 1fr) !important;
}

.map-workspace.map-panel-collapsed .map-tools {
    display: none !important;
}

.map-workspace.map-immersive .map-floating-tools {
    top: 16px;
    right: 16px;
}

.map-workspace.map-immersive .map-workspace-actions {
    position: sticky;
    top: 0;
    z-index: 20;
}

/* Los diálogos, dropdowns y confirmaciones deben quedar por encima del mapa. */
.rz-dialog-mask,
.rz-dialog-wrapper {
    z-index: 3200 !important;
}
.rz-popup,
.rz-dropdown-panel,
.rz-autocomplete-panel,
.rz-context-menu {
    z-index: 3400 !important;
}

/* El botón de agrupación ahora comunica claramente su estado. */
.map-floating-tools button[data-cmd="clustering"].active::before {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    border: 1px solid rgba(255,255,255,.9);
}

/* Mejor área de agarre para editar rutas. */
.route-vertex {
    width: 30px !important;
    height: 30px !important;
    font-size: 11px !important;
    border-width: 3px !important;
    touch-action: none;
}
.route-vertex.selected {
    transform: scale(1.18) !important;
}

/* Spiderfy más legible cuando varios puntos comparten exactamente posición. */
.leaflet-marker-icon.marker-cluster-spider-leg,
.leaflet-marker-pane .leaflet-marker-icon {
    transition: opacity .15s ease;
}
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform .22s ease-out, opacity .22s ease-in !important;
}

/* En pantalla pequeña el modo inmersivo prioriza el mapa y el panel puede
   mostrarse/ocultarse desde la barra flotante. */
@media (max-width: 820px) {
    .map-workspace.map-immersive {
        grid-template-columns: minmax(280px, 82vw) minmax(0, 1fr) !important;
    }
    .map-workspace.map-immersive.map-panel-collapsed {
        grid-template-columns: 0 minmax(0, 1fr) !important;
    }
}

/* =========================================================
   RedControl · Mapa V16
   Workspace estable, gestión visible y modo inmersivo real.
   ========================================================= */

.map-page-heading-v16 { align-items: flex-end; }
.map-page-subtitle {
    margin: 4px 0 0;
    color: var(--rc-muted);
    font-size: 11px;
    line-height: 1.45;
}

.map-workspace.map-workspace-v16 {
    position: relative !important;
    display: block !important;
    height: clamp(560px, calc(100dvh - 216px), 860px) !important;
    min-height: 560px !important;
    overflow: hidden !important;
    isolation: isolate;
    background: #dfe6eb;
}

.map-workspace-v16 .map-canvas-wrap {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

.map-workspace-v16 .network-map,
.map-workspace-v16 .leaflet-container {
    width: 100% !important;
    height: 100% !important;
    min-width: 100% !important;
    min-height: 100% !important;
}

/* El panel es un drawer sobre el mapa. Ocultarlo ya no cambia el ancho
   del lienzo, eliminando el problema de mosaicos blancos/parciales. */
.map-workspace-v16 .map-drawer {
    position: absolute !important;
    z-index: 760 !important;
    top: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
    width: min(372px, calc(100% - 90px)) !important;
    height: auto !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: column;
    overflow: hidden !important;
    border: 1px solid var(--rc-border) !important;
    border-radius: 14px !important;
    background: color-mix(in srgb, var(--rc-surface) 97%, transparent) !important;
    box-shadow: 0 18px 42px rgba(15, 23, 42, .22) !important;
    backdrop-filter: blur(12px);
    transform: translateX(0);
    opacity: 1;
    transition: transform .18s ease, opacity .18s ease;
}

.map-workspace-v16.map-panel-collapsed .map-drawer {
    display: flex !important;
    transform: translateX(calc(-100% - 28px));
    opacity: 0;
    pointer-events: none;
}

.map-drawer-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px 11px;
    border-bottom: 1px solid var(--rc-border);
    background: var(--rc-surface);
}
.map-drawer-head > div { min-width: 0; display: grid; gap: 2px; }
.map-drawer-kicker {
    color: var(--rc-primary);
    font-size: 8.5px;
    font-weight: 800;
    letter-spacing: .09em;
}
.map-drawer-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 720;
}
.map-drawer-close {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    flex: 0 0 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--rc-muted);
    cursor: pointer;
}
.map-drawer-close:hover { background: var(--rc-surface-soft); color: var(--rc-text); }
.map-drawer-close .rz-icon { font-size: 17px; }

.map-drawer-tabs {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px;
    border-bottom: 1px solid var(--rc-border);
    background: var(--rc-surface-soft);
}
.map-drawer-tabs button {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--rc-muted);
    font-size: 10.5px;
    font-weight: 700;
    cursor: pointer;
}
.map-drawer-tabs button:hover { color: var(--rc-text); background: var(--rc-surface); }
.map-drawer-tabs button.active {
    color: var(--rc-primary);
    border-color: color-mix(in srgb, var(--rc-primary) 22%, var(--rc-border));
    background: var(--rc-surface);
    box-shadow: var(--rc-shadow-sm);
}
.map-drawer-tabs button b {
    min-width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 9px;
}
.map-drawer-tabs .rz-icon { font-size: 15px; }

.map-workspace-v16 .map-drawer > .tool-section,
.map-workspace-v16 .map-management-center {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.map-workspace-v16 .map-management-center { padding: 12px; }

.map-editor-section { padding: 13px 14px 76px !important; }
.map-editor-section .tool-section-title { align-items: flex-start; }
.map-editor-section .tool-section-title > div { display: grid; gap: 1px; }
.map-editor-section .tool-section-title small { color: var(--rc-muted); font-size: 9.5px; }
.map-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 9px;
    margin-top: 10px;
}
.map-form-grid .field { min-width: 0; margin: 0; }
.map-form-grid .field > .rz-textbox,
.map-form-grid .field > .rz-dropdown,
.map-form-grid .field > .rz-colorpicker,
.map-form-grid .field > textarea { width: 100% !important; }
.map-field-span-2 { grid-column: 1 / -1; }
.map-location-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 5px 10px;
    align-items: center;
    margin-top: 12px;
    padding: 10px 11px;
    border: 1px solid var(--rc-border);
    border-radius: 10px;
    background: var(--rc-surface-soft);
}
.map-location-card span { display: flex; align-items: center; gap: 6px; color: var(--rc-muted); font-size: 9.5px; font-weight: 700; text-transform: uppercase; }
.map-location-card strong { grid-column: 1 / -1; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10.5px; }
.map-location-card .rz-button { grid-column: 1 / -1; justify-self: start; }
.map-sticky-actions {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    padding: 10px 14px;
    border-top: 1px solid var(--rc-border);
    background: color-mix(in srgb, var(--rc-surface) 96%, transparent);
    backdrop-filter: blur(8px);
}
.route-editor-actions-v16 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.route-editor-actions-v16 .rz-button:last-child { grid-column: 1 / -1; }

/* Centro de gestión */
.map-management-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}
.map-management-summary > div {
    min-width: 0;
    display: grid;
    gap: 1px;
    padding: 9px 8px;
    border: 1px solid var(--rc-border);
    border-radius: 9px;
    background: var(--rc-surface-soft);
}
.map-management-summary b { font-size: 16px; line-height: 1; }
.map-management-summary span { color: var(--rc-muted); font-size: 8.5px; line-height: 1.25; }
.map-management-summary .has-hidden { border-color: color-mix(in srgb, #d97706 35%, var(--rc-border)); background: color-mix(in srgb, #f59e0b 8%, var(--rc-surface)); }
.map-management-summary .has-hidden b { color: #d97706; }

.map-management-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 7px;
}
.map-management-search > .rz-icon { position: absolute; left: 10px; z-index: 1; color: var(--rc-muted); font-size: 15px; pointer-events: none; }
.map-management-search .rz-textbox { width: 100% !important; padding-left: 32px !important; }
.map-management-filters { display: flex; gap: 5px; margin-bottom: 12px; }
.map-management-filters button {
    flex: 1;
    min-height: 29px;
    border: 1px solid var(--rc-border);
    border-radius: 7px;
    background: var(--rc-surface);
    color: var(--rc-muted);
    font-size: 9.5px;
    font-weight: 700;
    cursor: pointer;
}
.map-management-filters button.active { color: var(--rc-primary); border-color: color-mix(in srgb, var(--rc-primary) 30%, var(--rc-border)); background: color-mix(in srgb, var(--rc-primary) 7%, var(--rc-surface)); }

.map-management-group + .map-management-group { margin-top: 14px; }
.map-management-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: var(--rc-muted);
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.map-management-group-head span { display: flex; align-items: center; gap: 6px; }
.map-management-group-head .rz-icon { font-size: 14px; }
.map-management-group-head b { min-width: 22px; padding: 2px 6px; border-radius: 999px; background: var(--rc-surface-soft); color: var(--rc-text); text-align: center; }
.map-management-list-v16 { display: grid; gap: 4px; }
.map-management-list-v16.compact { max-height: 210px; overflow-y: auto; padding-right: 2px; }
.map-management-row-v16 {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    min-height: 42px;
    padding: 5px 6px;
    border: 1px solid var(--rc-border);
    border-radius: 9px;
    background: var(--rc-surface);
}
.map-management-row-v16:hover { background: var(--rc-surface-soft); }
.map-management-row-v16.is-hidden { border-style: dashed; opacity: .78; }
.map-management-main {
    min-width: 0;
    display: grid;
    gap: 1px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--rc-text);
    text-align: left;
    cursor: pointer;
}
.map-management-main:disabled { cursor: default; }
.map-management-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.map-management-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--rc-muted); font-size: 8.8px; }
.map-management-row-actions { display: flex; gap: 2px; }
.map-management-row-actions button {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--rc-muted);
    cursor: pointer;
}
.map-management-row-actions button:hover { color: var(--rc-primary); background: color-mix(in srgb, var(--rc-primary) 9%, transparent); }
.map-management-row-actions button.restore { color: #15803d; background: color-mix(in srgb, #16a34a 8%, transparent); }
.map-management-row-actions .rz-icon { font-size: 14px; }
.map-management-empty { padding: 10px; border: 1px dashed var(--rc-border); border-radius: 8px; color: var(--rc-muted); font-size: 10px; text-align: center; }

.map-empty-selection { display: grid; justify-items: start; gap: 8px; }
.map-empty-selection h3, .map-empty-selection p { margin: 0; }
.map-empty-selection p { color: var(--rc-muted); font-size: 10.5px; line-height: 1.5; }
.map-layer-summary-v16 { border-top: 1px solid var(--rc-border); }
.map-overlap-note {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 10px;
    padding: 8px 9px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--rc-primary) 6%, var(--rc-surface));
    color: var(--rc-muted);
    font-size: 9.5px;
    line-height: 1.4;
}
.map-overlap-note .rz-icon { flex: 0 0 auto; color: var(--rc-primary); font-size: 14px; }

/* Leaflet permanece correctamente dimensionado al abrir/cerrar el drawer. */
.map-workspace-v16:not(.map-panel-collapsed) .leaflet-left { left: 380px !important; }
.map-workspace-v16 .leaflet-left,
.map-workspace-v16 .leaflet-right { transition: left .18s ease, right .18s ease; }

/* La barra flotante no duplica conceptos confusos. Agrupación de proximidad
   queda automática; las coincidencias exactas se resuelven por separación/spiderfy. */
.map-workspace-v16 .map-floating-tools { z-index: 790 !important; }

/* Modo inmersivo CSS: evita el fallo de Fullscreen API con Radzen. */
body.map-immersive-open { overflow: hidden !important; }
body.map-immersive-open .sidebar,
body.map-immersive-open .topbar { visibility: hidden !important; pointer-events: none !important; }

.map-workspace.map-workspace-v16.map-immersive {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2500 !important;
    width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: #dfe6eb !important;
}
.map-workspace-v16.map-immersive .map-canvas-wrap,
.map-workspace-v16.map-immersive .network-map,
.map-workspace-v16.map-immersive .leaflet-container {
    width: 100vw !important;
    height: 100dvh !important;
    min-width: 100vw !important;
    min-height: 100dvh !important;
}
.map-workspace-v16.map-immersive .map-drawer {
    top: 14px !important;
    bottom: 14px !important;
    left: 14px !important;
    width: min(390px, calc(100vw - 92px)) !important;
}
.map-workspace-v16.map-immersive:not(.map-panel-collapsed) .leaflet-left { left: 400px !important; }

/* Dialogs/popup por encima del workspace inmersivo. */
.rz-dialog-mask,
.rz-dialog-wrapper { z-index: 7000 !important; }
.rz-popup,
.rz-dropdown-panel,
.rz-autocomplete-panel,
.rz-context-menu,
.rz-datepicker-popup { z-index: 7200 !important; }
.rz-notification { z-index: 7400 !important; }

@media (max-width: 900px) {
    .map-page-heading-v16 { align-items: stretch; }
    .map-page-heading-v16 .map-actions { width: 100%; }
    .map-commandbar-v16 { grid-template-columns: 1fr 1fr; }
    .map-commandbar-v16 .map-search-wrap { grid-column: 1 / -1; }
    .map-workspace.map-workspace-v16 { min-height: 520px !important; }
    .map-workspace-v16 .map-drawer { width: min(340px, calc(100% - 68px)) !important; }
    .map-workspace-v16:not(.map-panel-collapsed) .leaflet-left { left: 0 !important; }
}

@media (max-width: 600px) {
    .map-commandbar-v16 { grid-template-columns: 1fr; }
    .map-commandbar-v16 .map-search-wrap { grid-column: auto; }
    .map-workspace-v16 .map-drawer,
    .map-workspace-v16.map-immersive .map-drawer {
        top: 8px !important;
        bottom: 8px !important;
        left: 8px !important;
        width: calc(100% - 64px) !important;
    }
    .map-form-grid { grid-template-columns: 1fr; }
    .map-field-span-2 { grid-column: auto; }
    .map-management-summary { grid-template-columns: 1fr 1fr 1fr; }
}

/* =========================================================
   V17 · Mapa primero: menos controles, más lienzo
   ========================================================= */
.map-page-heading-v17 {
    margin-bottom: 7px !important;
}
.map-page-heading-v17 h1 { margin-bottom: 0 !important; }

.map-commandbar-v17 {
    grid-template-columns: minmax(300px, 1fr) 150px 140px auto auto !important;
    align-items: end !important;
    gap: 7px !important;
    margin-bottom: 8px !important;
    padding: 7px 8px !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 2px rgba(15,23,42,.035) !important;
    background: var(--rc-surface) !important;
}
.map-commandbar-v17 .map-search-v17 {
    min-width: 0;
    align-self: end;
}
.map-commandbar-v17 .map-search-v17 .rz-textbox {
    min-height: 36px !important;
}
.map-commandbar-v17 .map-command-compact > span {
    display: block;
    margin: 0 0 3px;
    font-size: 8.5px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.map-commandbar-v17 .map-command-compact .rz-dropdown {
    min-height: 36px !important;
}
.map-switch-v17 {
    min-height: 36px !important;
    align-self: end;
    padding: 0 10px !important;
    border-radius: 8px !important;
}
.map-command-actions-v17 {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    align-self: end;
    white-space: nowrap;
}
.map-command-actions-v17 .rz-button {
    min-height: 36px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
}

.map-workspace.map-workspace-v17 {
    height: clamp(600px, calc(100dvh - 184px), 920px) !important;
    min-height: 600px !important;
    border-radius: 11px !important;
    box-shadow: 0 8px 26px rgba(15,23,42,.10) !important;
}

/* El panel ya no forma parte permanente de la pantalla. Se abre únicamente
   al gestionar, crear o seleccionar un elemento. */
.map-workspace-v17 .map-drawer {
    width: min(340px, calc(100% - 82px)) !important;
    top: 10px !important;
    bottom: 10px !important;
    left: 10px !important;
    border-radius: 12px !important;
    background: var(--rc-surface) !important;
    backdrop-filter: none !important;
    box-shadow: 0 16px 38px rgba(15,23,42,.18) !important;
}
.map-workspace-v17:not(.map-panel-collapsed) .leaflet-left {
    left: 350px !important;
}
.map-workspace-v17 .map-drawer-head {
    padding: 11px 12px 9px !important;
}
.map-workspace-v17 .map-drawer-kicker {
    font-size: 8px !important;
}
.map-workspace-v17 .map-drawer-tabs {
    padding: 6px !important;
    gap: 4px !important;
}
.map-workspace-v17 .map-management-center {
    padding: 10px !important;
}
.map-workspace-v17 .map-management-summary {
    margin-bottom: 8px !important;
}
.map-workspace-v17 .map-management-group + .map-management-group {
    margin-top: 10px !important;
}

/* En modo normal los comandos de creación están en la barra superior.
   En modo inmersivo vuelven a aparecer dentro del mapa para conservar toda
   la capacidad operativa sin salir de la vista. */
.map-workspace-v17:not(.map-immersive) .map-floating-tools .immersive-action {
    display: none !important;
}
.map-workspace-v17 .map-floating-tools {
    top: 10px !important;
    right: 10px !important;
    gap: 3px !important;
    padding: 4px !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 22px rgba(15,23,42,.14) !important;
}
.map-workspace-v17 .map-floating-tools button {
    width: 32px !important;
    height: 32px !important;
    border-radius: 7px !important;
}
.map-workspace-v17 .map-floating-tools button .rzi {
    font-size: 18px !important;
}
.map-workspace-v17 .map-floating-tools .tool-divider {
    margin: 1px 4px !important;
}
.map-workspace-v17.map-immersive .map-floating-tools {
    top: 12px !important;
    right: 12px !important;
}
.map-workspace-v17.map-immersive .map-drawer {
    width: min(350px, calc(100vw - 82px)) !important;
    top: 12px !important;
    bottom: 12px !important;
    left: 12px !important;
}
.map-workspace-v17.map-immersive:not(.map-panel-collapsed) .leaflet-left {
    left: 362px !important;
}

/* Z-index correcto: la máscara queda por debajo y el formulario por encima. */
.rz-dialog-wrapper { z-index: 7000 !important; }
.rz-dialog-wrapper .rz-dialog { position: relative !important; z-index: 2 !important; opacity: 1 !important; filter: none !important; }
.rz-dialog-mask { z-index: 0 !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
.rz-popup,
.rz-dropdown-panel,
.rz-autocomplete-panel,
.rz-context-menu,
.rz-datepicker-popup { z-index: 7200 !important; }

@media (max-width: 1120px) {
    .map-commandbar-v17 {
        grid-template-columns: minmax(260px, 1fr) 145px 135px auto !important;
    }
    .map-command-actions-v17 {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 760px) {
    .map-commandbar-v17 {
        grid-template-columns: 1fr 1fr !important;
    }
    .map-commandbar-v17 .map-search-v17,
    .map-command-actions-v17 {
        grid-column: 1 / -1;
    }
    .map-switch-v17 { justify-self: stretch; }
    .map-workspace.map-workspace-v17 {
        min-height: 540px !important;
        height: calc(100dvh - 220px) !important;
    }
    .map-workspace-v17 .map-drawer,
    .map-workspace-v17.map-immersive .map-drawer {
        width: calc(100% - 58px) !important;
        left: 8px !important;
        top: 8px !important;
        bottom: 8px !important;
    }
}
