cols.reduce((a,b)=>a+b,0));
          if (score > best.score) best = { score, delim: d };
        } catch (e) {}
      }
      return best.delim;
    }

    function isNumeric(v) {
      if (v == null) return false;
      const n = Number(String(v).trim().replace(/,/g, ''));
      return !isNaN(n) && isFinite(n);
    }

    function toNumber(v) {
      const n = Number(String(v).trim().replace(/,/g, ''));
      return isNaN(n) ? NaN : n;
    }

    function clamp(n, a, b) { return Math.min(Math.max(n, a), b