Credit market imperfections, labor markets, and leverage dynamics in emerging economies