Generalized Grad–Shafranov equation for non-axisymmetric MHD equilibria