The Shockley-Queisser (SQ) limit provides a convenient metric for predicting light-to-electricity conversion efficiency of a solar cell based on the band gap of the light-absorbing layer. In reality, few materials approach this radiative limit. We develop a formalism and a computational method to predict the maximum photovoltaic efficiency of imperfect crystals from first principles. Our scheme includes equilibrium populations of native defects, their carrier-capture coefficients, and the associated recombination rates. When applied to kesterite solar cells, we reveal an intrinsic limit of 20% for $mathrm{Cu_2ZnSnSe_4}$, which falls far below the SQ limit of 32%. The effects of atomic substitution and extrinsic doping are studied, leading to pathways for enhanced efficiency of 31%. This approach can be applied to support targeted-materials selection for future solar-energy technologies.