Nucleon-pair approximation to the nuclear shell model