You rank up each time the blue gem fills all three of its sections up, and one section fills up each time you gain a level with one of the four classes or promoting a character. In one playthrough, the maximum level after unlocking all promotions for all characters is 599.