In addition to the useful link in post #4, please see the CA Department of Consumer Affairs CA Tenants Guide. There is a section on pages 59-61 on pro-rating the costs of carpet and paint. As noted at the end of the section:
Remember: These suggestions are not hard and fast rules. Rather, they are offered to help
tenants and landlords avoid, understand, and resolve security deposit disputes.