Quantum-critical theory of the spin-fermion model and its application to cuprates: Normal state analysis