Electromagnetic Inversion with Local Power Conservation for Metasurface Design