It's been a while since I've done this kind of math, but I believe you have to use some linear algebra:
1. When the accelerometer is at rest, measure the acceleration in all three axes and convert it into a vector.
2. Create a rotation matrix
that rotates the vector into your desired vector (in this case, [0 0 1])
3. For all future data, convert into a vector and use the rotation matrix to determine the actual levelled acceleration.