Equilibrium and electrostatic stability theory of tokamaks from the drift-kinetic equation