Three-loop static QCD potential in heavy quarkonia