Democrats captured majorities in both chambers of Congress and scored wins in several Republican strongholds, delivering a sweeping rebuke to President Donald Trump.