def add_image_version_to_plan(spec: dict, plan_id: str, image_version: str, image_url: str):
    """Add a new image version to a given plan and return a modified offer spec."""

    plan_spec = {}
    for plan in spec["definition"]["plans"]:
        if plan["planId"] == plan_id:
            plan_spec = plan

    if not plan_spec:
        raise RuntimeError(f"Plan {plan_id} not found in offer {spec['id']}.")

    plan_spec["microsoft-azure-virtualmachines.vmImages"][image_version] = {
        "osVhdUrl": image_url,
        "lunVhdDetails": []
    }
    return spec