A rigorous theory of finite-size scaling at first-order phase transitions