Theory of defect complexes in insulators