You accumulate 1 level that can be granted to your recruiter for every two levels that you gain up to level 85 per character. This means that once the recruited account gets to level 85:
- they stop accumulating more levels to grant
- they have 42 levels to grant
These levels must be granted within 90 days of the recruitment, after this time any levels that have not been granted at this time will expire, along with the other recruit a friend bonuses.
The recruited account cannot grant levels above their current level, so they wouldn't be able to get to level 40 and grant levels to the recruiter to a level that is above 40.
Levels can be granted by the recruited player to any character on the recruiter's account, however, there is no method of determining (other than manually keeping count) how many levels you have left to grant.