def evaluate_rules(data):

    rules = []

    ctr = data.get("ctr", 0)
    impressions = data.get("impressions", 0)
    spend = data.get("spend", 0)
    conversions = data.get("conversions", 0)
    health_score = data.get("health_score", 0)
    days_running = data.get("days_running", 0)

    # -----------------------------------
    # Low CTR Rule
    # -----------------------------------

    if ctr < 0.3:

        rules.append({
            "type": "CTR",
            "severity": "HIGH",
            "issue": "Low CTR detected",
            "recommendation": "Refresh creatives"
        })

    # -----------------------------------
    # High Spend Low Conversion
    # -----------------------------------

    if spend > 1000 and conversions < 5:

        rules.append({
            "type": "CONVERSION",
            "severity": "HIGH",
            "issue": "High spend with low conversions",
            "recommendation": "Optimize targeting"
        })

    # -----------------------------------
    # Creative Fatigue
    # -----------------------------------

    if days_running > 14:

        rules.append({
            "type": "CREATIVE",
            "severity": "MEDIUM",
            "issue": "Creative fatigue detected",
            "recommendation": "Rotate banners"
        })

    # -----------------------------------
    # Poor Health Score
    # -----------------------------------

    if health_score < 50:

        rules.append({
            "type": "HEALTH",
            "severity": "HIGH",
            "issue": "Campaign health critical",
            "recommendation": "Immediate optimization required"
        })

    # -----------------------------------
    # Low Delivery
    # -----------------------------------

    if impressions < 1000:

        rules.append({
            "type": "DELIVERY",
            "severity": "MEDIUM",
            "issue": "Low delivery volume",
            "recommendation": "Increase inventory targeting"
        })

    return rules