s.map((h, i) => `<option value="${i}">${escapeHtml(h)}</option>`).join('');
      valueSel.value = String(Math.min(state.valueColumn, headers.length - 1));

      const container = $('#datasets');
      container.innerHTML = '';
      const numericCandidates = guessNumericColumns();
      const defaults = numericCandidates.length ? numericCandidates : headers.map((_,i)=>i).slice(1);
      if (!state.datasets.length) state.datasets = defaults.slice(0, Math.min(3, defaults.length));
      const palette = nice