on_actions = {
	on_monthly = {
		effect = {

			set_temp_variable = { unemployment_value = modifier@monthly_unemployment_change }
			if = {
				limit = {
					NOT = { check_variable = { unemployment_value = 0 } }
					OR = {
						AND = {
							check_variable = { unemployment_value > 0 }
							check_variable = { current_unemployment < 1 }
						}
						AND = {
							check_variable = { unemployment_value < 0 }
							check_variable = { current_unemployment > 0 }
						}
					}
				}
				add_unemployment_effect = yes
			}
			eoanb_political_legitimacy_drift = yes

			if = {
				limit = { NOT = { has_country_flag = Country_Optimised } }
				
				set_temp_variable = { gained_money = 0 }
				if = {
					limit = {
						calculate_money_balance = yes
						OR = {
							check_variable = { money < 2000000 }
							NOT = { check_variable = { total_balance_temp > 0 } }
						}
						OR = {
							check_variable = { money > -2000000 }
							NOT = { check_variable = { total_balance_temp < 0 } }
						}
					}
					set_temp_variable = { gained_money = total_balance_temp }
					add_to_variable = { money = gained_money }
				}
				if = {
					limit = { check_variable = { money > 2000000 } }
					set_variable = { money = 2000000 }
				}
				else_if = {
					limit = { check_variable = { money < -2000000 } }
					set_variable = { money = -2000000 }
				}
				if = {
					limit = { calculate_inflation_change = yes }
					add_to_variable = { current_inflation = daily_inflation_change }
					set_variable = { inflation_effect_var = current_inflation }
					divide_variable = { inflation_effect_var = -10 }
				}
				if = {
					limit = { check_variable = { current_inflation < 0 } }
					set_variable = { current_inflation = 0 }
				}
				else_if = {
					limit = { check_variable = { current_inflation > 20000 } }
					set_variable = { current_inflation = 20000 }
				}
				

				if = {
					limit = {
						is_ai = no
						check_variable = { money < 0 }
					}
					set_temp_variable = { loans_amount = 0 }
					subtract_from_temp_variable = { loans_amount = money }
					divide_temp_variable = { loans_amount = 100 }
					add_to_temp_variable = { loans_amount = 0.5 }
					round_temp_variable = loans_amount
					take_loan_effect = yes
					if = {
						limit = {
							is_ai = no
							check_variable = { current_loans_sum > 0 }
						}
						set_variable = { show_automatic_loan_popup = 1 }
						set_variable = { automatic_loan_amount = loans_amount }
					}
					if = {
						limit = {
							tag = GRE
							has_idea = GRE_idea_national_debt
						}

						set_temp_variable = { inflation_to_gain = 0.1 }
						add_inflation_with_tooltip_effect = yes
						set_temp_variable = { money_to_gain = 10 }
						add_money_with_tooltip_effect = yes
					}
				}

				if = {
					limit = {
						is_ai = yes
						check_variable = { money < 0 }
					}
					add_to_variable = { money = 200 }
				}

				if = {
					limit = {
						is_ai = yes
						check_variable = { current_inflation > 0 }
					}
					set_variable = { current_inflation = 0 }
				}

				if = {
					limit = {
						has_taken_a_loan = yes
						has_dynamic_modifier = { modifier = bankrolling_giving_money }
					}
					remove_dynamic_modifier = { modifier = bankrolling_giving_money }
					var:bankrolled = {
						remove_dynamic_modifier = { modifier = bankrolling_recieving_money }
						clear_variable = bankrolled_recieving
					}
					clear_variable = bankrolled
					clr_country_flag = eoanb_is_bankrolling
					clear_variable = bankrolled_giving
				}
			}  # End Money System block

			if = {
				limit = { has_taken_a_loan = yes }
				add_ideas = debt_idea
			}
			else_if = {
				limit = { has_idea = bankruptcy }
				remove_ideas = debt_idea
			}
			else_if = {
				limit = {
					set_temp_variable = { loan_size_to_check = 0 }
					has_specific_loan_size = yes
				}
				remove_ideas = debt_idea
			}
		}
	}

	on_monthly_KOR = {
		effect = {
			add_to_variable = { andong_kim_power = modifier@KOR_Angdon_Kim_Modifier }
		}
	}

	on_monthly_NOR = {
		effect = {
			NOR = {
				if = {
					limit = { has_idea = NOR_idea_christiania_repairing }
					add_to_variable = { var = NOR_var_christiana_repairing value = 1.25 }
					NOR_scripted_effect_christiania_repairing = yes
				}
			}
		}
	}
	on_monthly_GRE = {
		effect = {
			GRE = {
				if = {
					limit = { 
						AND = {
							has_stability > 50
							has_stability < 60
						}
					 }
					add_to_variable = { var = GET_GRE_otto_support_var value = -0.25 }
				}
				else_if = {
					limit = { 
						AND = {
							has_stability > 30
							has_stability < 50
						}
					 }
					add_to_variable = { var = GET_GRE_otto_support_var value = -0.3 }
				}
				else_if = {
					limit = { 
						AND = {
							has_stability > 30
							has_stability < 50
						}
					 }
					add_to_variable = { var = GET_GRE_otto_support_var value = -0.5 }
				}
			}
		}
	}
	on_monthly_PRS = {
		effect = {
			PRS = {
				if = {
					limit = {
						has_country_flag = eoanb_flag_won_fra_prs_war
					}
					set_variable = { GER_elsass_german_pop = 28.state_population }
					multiply_variable = { GER_elsass_german_pop = 28.state_culture_array_num^0 }
					set_variable = { GER_elsass_french_pop = 28.state_population }
					multiply_variable = { GER_elsass_french_pop = 28.state_culture_array_num^1 }
					round_variable = GER_elsass_german_pop
					round_variable = GER_elsass_french_pop
				}
				add_to_variable = { GER_Elsass_Refresh_Variable = 1 }
			}
		}
	}
	# The AUS-specific block remains commented out (can be enabled if needed)
	# on_monthly_AUS = {
	# 	effect = {
	# 		if = {
	# 			limit = {
	# 				army_manpower_in_state = { amount > 20000 state = 159 }
	# 				army_manpower_in_state = { amount > 20000 state = 160 }
	# 			}
	# 			add_to_variable = { AUS_ITA_Unrest_risk_change = -0.01 }
	# 		}
	# 		if = {
	# 			limit = { has_variable = AUS_ITA_Unrest_risk_change }
	# 			add_to_variable = { ITA_UPROAR_RISK = modifier@AUS_Italian_Uproar_Risk_Modifier }
	# 		}
	# 	}
	# }
}
