here we are
And as for the general saying that one whose deeds and misdeeds are equally balanced is called Benoni, while he whose virtues outweigh his sins is called a Tzaddik, this is only the figurative use of the term in regard to reward and punishment, because he is judged according to the majority [of his acts] and he is deemed "righteous" in his verdict, since he is acquitted in law. But concerning the true definition and quality of the distinct levels and ranks, "Righteous" and "Intermediate" men, our Sages have remarked that the Righteous are motivated [solely] by their good nature, as it is written, "And my heart is a void within me," that is, void of an evil nature, because he [David] had slain it through fasting. But whoever has not attained this degree, even though his virtues exceed his sins, cannot at all be reckoned to have ascended to the rank of the Righteous (tzaddik). This is why our Sages have declared in the Midrash, "The Almighty saw that the righteous were few, so He planted them in every generation,..." [for,] as it is written, "The tzaddik is the foundation of the world."
The explanation [of the questions raised above] is to be found in the light of what Rabbi Chayim Vital wrote in Sha'ar ha-Kedushah (and in Etz Chayim, Portal 50, ch. 2) that in every Jew, whether righteous or wicked, are two souls, as it is written, "The neshamot (souls) which I have made," [alluding to] two souls. There is one soul which originates in the kelipah and sitra achra, and which is clothed in the blood of a human being, giving life to the body, as is written, "For the life of the flesh is in the blood." From it stem all the evil characteristics deriving from the four evil elements which are contained in it. These are: anger and pride, which emanate from the element of Fire, the nature of which is to rise upwards; the appetite for pleasures— from the element of Water, for water makes to grow all kinds of enjoyment; frivolity and scoffing, boasting and idle talk from the element of Air; and sloth and melancholy— from the element of Earth. From this soul stem also the good characteristics which are to be found in the innate nature of all Israel, such as mercy and benevolence. For in the case of Israel, this soul of the kelipah is derived from kelipat nogah, which also contains good, as it originates in the esoteric "Tree of Knowledge of Good and Evil." The souls of the nations of the world, however, emanate from the other, unclean kelipot which contain no good whatever, as is written in Etz Chayim, Portal 49, ch. 3, that all the good that the nations do, is done from selfish motives. So the Gemara comments on the verse, "The kindness of the nations is sin,"— that all the charity and kindness done by the nations of the world is only for their own self-glorification, and so on.
https://www.chabad.org/library/tanya/tanya_cdo/aid/1028872/jewish/Chapter-1.htm