Theory of ion and water transport in reverse osmosis membranes