KiDS-Legacy: cosmological constraints from cosmic shear with the complete Kilo-Degree Survey