Atomic and electronic structure of the CoFeB∕MgO interface from first principles