This has happened to me twice now, each time when researching level upgrades (Politics Lvl 2, Economy lvl 2). And it hasn’t refunded any of the gems… I submitted a bug report about it but hopefully I am at least refunded the gems it took to pay for these upgrades.