I had a similar problem with my G1000 equiped aircraft 4 years ago. Funnily enough I only lost the heading/CDI at night (when I most needed it).
Turned out there was some kind of short between the NAV light wiring and the magnetometer/AHRS - hence it only happening at night.
The aircraft manufacturer produced an SB which rectified the problem.
Pain in the butt was I had to pay for the work! (parts were free)
This is the downside of buying an aircraft with what was (at that time) breakthrough technology - you become a test pilot and help them iron out the defects in the system.
SB