export async function apiFetch(url, options = {}) { const response = await fetch(url, options); const result = await response.json().catch(() => ({})); if (!response.ok) { throw new Error(result.detail || `API ${response.status}`); } return result; }