#app_topbar {
    position: fixed;
    top: var(--altura_menu); left: var(--ancho_sidebar); right: 0; height: 44px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    display: flex; align-items: center;
    padding: 0 16px; z-index: 100;
    box-sizing: border-box; color: #2a2a2a;
}
/* Overlay de tinte por ventana (fondoCabezal) sobre la capa blanca base */
#app_topbar_tinte { position: absolute; inset: 0; background: transparent; pointer-events: none; z-index: 0; }
#app_topbar_icono { position: relative; z-index: 1; font-size: 18px; margin-right: 10px; color: inherit; }
#app_topbar_titulo {
    position: relative; z-index: 1; font-weight: 600; font-size: 15px; color: inherit;
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#app_topbar_cerrar {
    position: relative; z-index: 1; cursor: pointer; padding: 6px 10px;
    border-radius: 4px; color: inherit; font-size: 16px; transition: background 0.15s;
}
#app_topbar_cerrar:hover { background: rgba(220, 38, 38, 0.12); color: #dc2626; }
#app_topbar_cerrar.disabled { color: #656565; cursor: default; pointer-events: none; }

#app_topbar_candado {
    position: relative; z-index: 1; cursor: pointer; padding: 6px 8px; border-radius: 4px;
    color: inherit; font-size: 16px; transition: background 0.15s, color 0.15s;
    display: inline-flex; align-items: center; justify-content: center;
}
#app_topbar_candado > span { display: inline-block; width: 16px; text-align: center; line-height: 1; }
#app_topbar_candado:hover { background: rgba(0, 0, 0, 0.06); }
#app_topbar_candado.locked { color: #7f0a0a; }

#app_shell {
    position: fixed;
    top: calc(var(--altura_menu) + 44px); left: var(--ancho_sidebar); right: 0; bottom: 0;
    overflow: hidden; background: #f2f2f2;
    display: grid;
    /* CRÍTICO: sin estas pistas explícitas, la fila/columna implícita es `auto`
       (se ajusta al contenido) y el max-width/height:100% de .ventana se resuelve
       contra una pista indefinida → se ignora: la caja fija nunca se clampea al
       shell y el overflow:hidden la recorta SIN scroll. Con minmax(0,1fr) la pista
       es definida, .ventana se clampea y su overflow:auto scrollea. */
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr);
    place-items: center; /* centra la ventana caja fija */
}

#app_shell .ventana {
    position: relative; box-sizing: border-box;
    overflow: auto; background: #ffffff;
    max-width: 100%; max-height: 100%;
    /* isolation crea stacking context propio: ventanas viejas con elementos
       z-index negativo dejarían escapar ese z-index hasta el body y quedarían
       tapadas por el fondo del shell. */
    isolation: isolate;
    transition: opacity 100ms ease-in-out;
    z-index: 1;              /* tapa la marca de agua */
    animation: ventana_aparecer 150ms ease-out;
}
#app_shell .ventana_caja {
    box-shadow: 0 10px 40px -10px rgba(0,0,0,.15), 0 4px 12px -4px rgba(0,0,0,.08);
}
#app_shell .ventana_contenedor {
    position: relative; display: block;
    width: 100%; height: 100%; box-sizing: border-box;
}
@keyframes ventana_aparecer {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}
/* Marca de agua: visible solo con id_foco == null */
.logo_marca_de_agua {
    position: absolute; top: 50%; left: 50%; width: 24%;
    transform: translate(-50%, -50%); opacity: 0.30;
    pointer-events: none; user-select: none;
}

/* Chip de cuenta ML activa: solo visible cuando la ventana enfocada es de dominio ML */
#app_topbar_ml_cuenta {
    position: relative; z-index: 1;
    font-size: 11px; color: #555; background: #fff;
    padding: 2px 8px; border-radius: 8px; margin-right: 10px;
    white-space: nowrap; display: none;
    border: 1px solid #e0e0e0;
}
