The conditional colour–magnitude distribution – I. A comprehensive model of the colour–magnitude–halo mass distribution of present-day galaxies