{% if not employee %}
<div class="rounded-2xl border border-amber-200 bg-amber-50 p-6 text-sm text-amber-900 shadow-soft">Your login is not linked to an employee profile yet.</div>
{% else %}
<div class="flex flex-wrap items-center justify-between gap-3">
  <div><h3 class="text-lg font-semibold text-slate-900">Returned / Correction Work</h3><p class="mt-1 text-sm text-slate-600">Your current workflow uses blocked status for correction, clarification and returned work. Use this page to clear them.</p></div>
  <a href="/employee/work?status=blocked" class="af-btn af-btn-primary">Open Full Board</a>
</div>
<div class="rounded-2xl border border-slate-200 bg-white shadow-soft overflow-hidden">
  <table class="min-w-full divide-y divide-slate-200 text-sm">
    <thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500"><tr><th class="px-4 py-3">Client</th><th class="px-4 py-3">Service</th><th class="px-4 py-3">FY</th><th class="px-4 py-3">Blocked</th><th class="px-4 py-3">Overdue</th><th class="px-4 py-3">Action</th></tr></thead>
    <tbody class="divide-y divide-slate-100">
      {% set ns = namespace(count=0) %}
      {% if work_payload %}
        {% for column in work_payload.columns if column.code == 'blocked' %}
          {% for card in column.cards %}
          {% set ns.count = ns.count + 1 %}
          <tr class="hover:bg-slate-50"><td class="px-4 py-3 font-medium text-slate-900">{{ card.client_name }}</td><td class="px-4 py-3 text-slate-600">{{ card.service_name }}</td><td class="px-4 py-3 text-slate-600">{{ card.financial_year }}</td><td class="px-4 py-3 text-amber-700 font-semibold">{{ card.blocked_count }}</td><td class="px-4 py-3 text-red-700 font-semibold">{{ card.overdue_count }}</td><td class="px-4 py-3"><a href="/employee/work/engagements/{{ card.engagement_id }}" class="rounded-xl bg-brand-600 px-3 py-2 text-xs font-semibold text-white hover:bg-brand-700">Open</a></td></tr>
          {% endfor %}
        {% endfor %}
      {% endif %}
      {% if ns.count == 0 %}<tr><td colspan="6" class="px-4 py-8 text-center text-slate-500">No returned or blocked work is pending.</td></tr>{% endif %}
    </tbody>
  </table>
</div>
{% endif %}
