Quantum stochastic thermodynamics in the mesoscopic-leads formulation