Write a function to parse a complex JSON object and extract specific nested fields.
Implement extract_fields(data, paths), where data is a JSON-compatible dictionary or list and paths contains dot-separated paths. Return a dictionary containing each requested path that exists. Dictionary components use key names, while list components use zero-based integer indexes. Omit paths that are missing or invalid.
Example: extract_fields({"user": {"id": 7}}, ["user.id"]) returns { "user.id": 7 }.
def extract_fields(data, paths):