You are a senior Python systems engineer.

Return ONLY executable Python code. Do not use Markdown fences.

Implement:

    atomic_write_json(path, data)

Requirements:

1. Use only the Python standard library.
2. Accept path as str or pathlib.Path.
3. Create missing parent directories.
4. Serialize JSON as UTF-8 with:
   - indent=2
   - sort_keys=True
   - ensure_ascii=False
   - trailing newline
5. Write to a temporary file in the SAME directory as the target.
6. Flush and fsync the temporary file before replacement.
7. Atomically replace the destination using os.replace().
8. On POSIX, fsync the parent directory after replacement.
9. If any error occurs before os.replace(), the existing destination
   must remain unchanged.
10. Clean up any leftover temporary file after failure.
11. Do not silently swallow exceptions.
12. The function should return the final pathlib.Path.

Include a short self-test under:

    if __name__ == "__main__":

The self-test must:
- write Unicode JSON,
- verify the file contents can be loaded back,
- verify keys are sorted in the serialized output,
- verify the file ends with a newline,
- print exactly:

PASS
