Power has been restored to more than 99% of mainland Spain, but a state of emergency remains in place.