A new method is presented for accounting for microstructural features of flowing complex fluids at the level of mesoscopic, or coarse-grained, models by ensuring compatibility with macroscopic and continuum thermodynamics and classical transport phenomena. In this method, the microscopic state of the liquid is described by variables that are local expectation values of microscopic features. The hypothesis of local thermodynamic equilibrium is extended to include information on the microscopic state, i.e., the energy of the liquid is assumed to depend on the entropy, specific volume, and microscopic variables. For compatibility with classical transport phenomena, the microscopic variables are taken to be extensive variables (per unit mass or volume), which obey convection-diffusion-generation equations. Restrictions on the constitutive laws of the diffusive fluxes and generation terms are derived by separating dissipation by transport (caused by gradients in the derivatives of the energy with respect to the state variables) and by relaxation (caused by non-equilibrated microscopic processes like polymer chain stretching and orientation), and by applying isotropy. When applied to unentangled, isothermal, non-diffusing polymer solutions, the equations developed according to the new method recover those developed by the Generalized Bracket [J. Non-Newtonian Fluid Mech. 23 (1987) Rheol. 38 (1994) 769]. Minor differences with published results obtained by the Generalized Bracket are found in the equations describing flow coupled to heat and mass transfer in polymer solutions. The new method is applied to entangled polymer solutions and melts in the general case where the rate of generation of entanglements depends nonlinearly on the rate of strain. A link is drawn between the mesoscopic transport equations of entanglements and conformation and the microscopic equation describing the configurational distribution of polymer segment stretch and orientation. Constraints are derived on the generation terms in the transport equations of entanglements and conformation, and the formula for the elastic stress is generalized to account for reversible formation and destruction of entanglements. A simplified version of the transport equation of conformation is presented which includes many previously published constitutive models, separates flow-induced polymer stretching and orientation, yet is simple enough to be useful for developing large-scale computer codes for modeling coupled fluid flow and transport phenomena in two-and three-dimensional domains with complex shapes and free surfaces.