Mean-field theory of the spin-Peierls transition