Broad-based buying lifted indices, with midcaps and smallcaps outperforming amid improving risk appetite.