US inflation hit a nearly two-year high in March, fueled by the Middle East war and rising energy prices, impacting consumer confidence despite a resilient job market.