General theory of kinetic ballooning modes