This is a challenging fight but, just so you know, it is not the final battle and you still have more gems to collect.
When I first played this encounter I had my rogue zip around the room (with Spider Climb boots) and de-activate the "force field" protecting the "Master" (green dragon and guardian of the Gem of Abjuration) while CCing and focusing fire on the spectres that were not CCed so I took very little damage from the spectres or the lightning. Once the dragon emerged, it was a completely different fight but, fortunately, my team was all dwarves(!) so we took very little damage from his poison breath.
Anyway, some possible tips:
Do not bunch-up so the dragon will not use his breath weapon as much.
Cast Haste on your tank since he will need to chase the dragon around the room when he flies away.
Use a melee Rogue to take advantage of the opportunity attacks, when the dragon flies, so you get 2 Sneak Attacks / round.
"Burn" away the dragon's Legendary Saves by hitting him with mid-level spells that require saving throws before hitting him with your "big guns" or, preferably, Hold Monster. Ideally your early spells inflict half damage on a successful save so, at least, they are doing something.
Expect to be hurt by his poisonous attacks so, if you are not already resistant (like my team of dwarves), use Antidote before the fight since it lasts for 1 hour or a Protection from Poison spell.
Summon elementals, ideally flying ones like the Wind Snakes, since they are immune to poison plus they will chase the dragon around, getting opportunity attacks and soaking attacks otherwise meant for your party; do not expect them to inflict much damage though.
Use your consumables like Flaming Arrows or Giant Strength potions since this is the toughest fight near the end of the game. The actual final battle is a cakewalk and needs some serious buffing; though I thought I read earlier that a specific and very dangerous monster was missing from it?