Stability, energetics, and magnetic states of cobalt