Theory of diffraction efficiency and anomalies of shallow metal gratings of finite conductivity