What I mean is that your unhappiness sources are now, in fact, about inequalities.
And, while inequality is a source of unhappiness (especially after equality is a social value), the real source of unhappiness is the lack of yields.
Let's see food. I might be unhappy if, even when I'm not starving, I know that some people in my county have three meals a day, when I can only eat once a day. It's unfair, but at least I'm not hungry. But I could be hungry. If I'm not getting this one meal a day, even if all the people in my country are in my same situation, I won't feel pleased. Well, there's a specific unhappiness for a starving city, so let's see other yields.
Let's see gold. I can be unhappy knowing that 10% people in my country owns 90% of the GDP, that's especially true for I'm one of the other 90% that shares the rest. But I'd be much more unhappy if I could not pay for my roof, my clothes and a doctor when I need it.
Your current notation says that a citizen is 'suffering poverty' when he's comparing his wage against the median wage in the country. He might be angry about the inequality of wages, but this is not the same as 'suffering from poverty'. Not even close.
People can be unhappy about being objectively poor, and unhappy about being relativelly poor.
Knowing when a citizen is objectively poor is looking for a fixed minimum value for gold production per citizen that represents the basic needs, scaling with technology. You said this approach is too difficult, and I see why. But taking just inequalities in your country as the main source of unhappiness is misleading. I may have cities producing more gold than I'd ever need, crying about poverty, just because they happen to produce less than the median in the country. I may have perfectly content cities that are critically lacking gold, just because the values are well distributed among all my cities.
Another thing to consider is that adding unhappiness maluses to a disadvantageous situation, usually makes bad things worse. If my cities are objectively impoverished, without enough gold to make a steady development, and in top of that, I get a penalty to my economy, I'm being doubly punished for falling behind.
Maybe it's the concept of happiness what should change...
Happiness is a resource. Beyond a golden age or two, extra happiness does nothing, but unhappiness limits how much and how fast an empire can grow and expand. Growing and expanding makes victory more likely, so it makes a whole sense to limit those things. What feeling is this that makes people willing to grow and expand? It's not called happiness. Optimism? Willingness?
With such concept, we could say that people are willing to expand aggressively when there are little differences among the people in the country, and when there're not too many people already living in the country (which makes no sense in real life).
No, no. This ain't working.
What represents best what happiness is currently doing might be 'administrative capacity'. This is, what the empire is able to rule before everything crumbles down. This task is harder the more citizens, the more cities and the more complex the society. Yes.
Administrative capacity fully represents what we want happiness to do.
If
in the empire is the administrative capacity of the empire, what would 'distress', 'poverty', 'illiteracy' and 'boredom' represent? Those penalties appear when per citizen production of a yield does not meet the empire median, in other words, when some cities are too specialized or underdeveloped, depending on how tall the empire is. When we have lots of culture in one city and very little in another one, it becomes more difficult to make a single agenda, so a local administration is required for the 'boring' city.
So let's read 'distress', 'poverty', 'illiteracy' and 'boredom' as the local administrative effort required in the city due to the differences with the general (federal?) administration.
Fine. Now that I'm conceptually more relaxed, I'd like to suggest that, instead of targetting the raw empire median value, it'll be nicer if it targets from 80% to 120% of the median value. So, if the median value for science is 5.00 per citizen, no administrative effort is required for cities that have 4.00 to 6.00 science per citizen. Cities with bigger or lower values will require some
for their administration, increased by tech level. It may be a bit counter-intuitive that well developed cities gain 'unhappiness' for being over the average, but it is not unhappiness, it's administrative capacity, and big cities require more clerks.