While a trial court has broad discretion to allow an amendment to conform to proof after commencement of trial (CCP 576), the trial court lacks authority to make a sua sponte post-trial amendment of the complaint to allege a claim based on facts and theories not alleged in the complaint. Doing so denies the defendant due process.