<div class="wrap">
  <h3>Variation Cleanup</h3>
  <p>This tool finds and permanently deletes orphaned Kickflip product variations left over from legacy add-to-cart behavior. Variations younger than 7 days, still referenced by an order, or belonging to a genuine variable product are never touched.</p>

  <table class="form-table">
    <tbody>
      <tr>
        <th><label>Progress</label></th>
        <td>
          <p>Scanned so far: {{ progress.totalScanned }}</p>
          <p>Orphans found so far: {{ progress.totalOrphansFound }}</p>
          <p>Deleted so far: {{ progress.totalDeleted }}</p>
          <p>Skipped so far: {{ progress.totalSkipped }}</p>
          <p>Status: {{ progress.done ? 'Scan complete — no more candidates remain' : 'In progress' }}</p>
          {% if progress.lastRunAt %}
            <p>Last confirmed run: {{ progress.lastRunAt }}</p>
          {% endif %}
          {% if progress.exportFile %}
            <p>Last export file: <small>{{ progress.exportFile }}</small></p>
          {% endif %}
        </td>
      </tr>
    </tbody>
  </table>

  <form name="form" method="post">
    <input type="hidden" name="section" readonly="readonly" value="cleanup">
    <fieldset>
      {{ form.token | raw }}
    </fieldset>
    <button class="button button-primary">Scan next batch (dry-run)</button>
  </form>
</div>
