async function laddaSovlage() { const res = await apiFetch('/api/sleep'); if (!res) return; const d = await res.json(); document.getElementById('sleep-enabled').checked = !!d.enabled; document.getElementById('sleep-start').value = d.start || '22:00'; document.getElementById('sleep-end').value = d.end || '07:00'; } async function sparaSovlage() { const status = document.getElementById('sleep-status'); status.textContent = 'Sparar...'; const res = await apiFetch('/api/sleep', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ enabled: document.getElementById('sleep-enabled').checked, start: document.getElementById('sleep-start').value, end: document.getElementById('sleep-end').value, }), }); if (!res) return; status.textContent = '✓ Sparat'; setTimeout(() => { status.textContent = ''; }, 3000); }