The U.S. economy unexpectedly lost jobs in July, demonstrating a wobbly labor market as shoppers continued to withstand a surge of inflation set off by the Iran war.