A stochastic theory of non-ideal behaviour: I. Microenvironment, chemical potential and transport