<div class="space-y-6">
  <div class="flex justify-end"><a href="/partner/dashboard?tab=escalations" class="af-btn af-btn-secondary">Escalations & Review Ageing</a></div>
  <div class="rounded-3xl border border-slate-200 bg-white p-5 shadow-soft">
    <div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
      <div>
        <h2 class="text-lg font-semibold text-slate-900">Partner Engagement Review Queue</h2>
        <p class="text-sm text-slate-500">Engagement-level Partner and Review Partner review, significant exceptions and final-release blockers.</p>
      </div>
      <a href="/partner/reviews" class="rounded-2xl border border-slate-300 px-4 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Open Existing Review Board</a>
    </div>

    <div class="mt-5 space-y-4">
      {% for item in partner_engagement_review_queue %}
      <article class="rounded-3xl border border-slate-200 p-5">
        <div class="flex flex-col gap-4 xl:flex-row xl:items-center xl:justify-between">
          <div class="min-w-0">
            <div class="flex flex-wrap items-center gap-2">
              <h3 class="font-semibold text-slate-900">{{ item.client_name }}</h3>
              <span class="rounded-full bg-slate-100 px-2.5 py-1 text-xs font-semibold text-slate-700">{{ item.financial_year }}</span>
              {% if item.release_blockers %}<span class="rounded-full bg-rose-100 px-2.5 py-1 text-xs font-semibold text-rose-700">{{ item.release_blockers }} release blocker{{ '' if item.release_blockers == 1 else 's' }}</span>{% endif %}
              {% if item.exception_count %}<span class="rounded-full bg-amber-100 px-2.5 py-1 text-xs font-semibold text-amber-700">{{ item.exception_count }} exception{{ '' if item.exception_count == 1 else 's' }}</span>{% endif %}
            </div>
            <p class="mt-1 text-sm text-slate-500">{{ item.service_name }}</p>
            <div class="mt-3 flex flex-wrap gap-2 text-xs">
              <span class="rounded-full bg-indigo-50 px-2.5 py-1 font-semibold text-indigo-700">Partner pending: {{ item.pending_partner }}</span>
              <span class="rounded-full bg-purple-50 px-2.5 py-1 font-semibold text-purple-700">Review Partner pending: {{ item.pending_review_partner }}</span>
              <span class="rounded-full bg-rose-50 px-2.5 py-1 font-semibold text-rose-700">Rework: {{ item.rework_count }}</span>
              <span class="rounded-full bg-slate-100 px-2.5 py-1 font-semibold text-slate-700">{{ item.sla.label }}</span>
            </div>
          </div>
          <div class="w-full xl:w-72">
            <div class="flex items-center justify-between text-xs text-slate-500"><span>Weighted progress</span><span>{{ item.weighted_progress.progress_percent }}%</span></div>
            <div class="mt-2 h-2 rounded-full bg-slate-100"><div class="h-2 rounded-full bg-brand-600" style="width: {{ item.weighted_progress.progress_percent }}%"></div></div>
            <a href="{{ item.href }}" class="mt-4 inline-flex w-full justify-center rounded-2xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white">Start / Continue Partner Review</a>
          </div>
        </div>
      </article>
      {% else %}
      <div class="rounded-3xl border border-dashed border-slate-300 p-8 text-center text-sm text-slate-500">No engagements are awaiting Partner or Review Partner action.</div>
      {% endfor %}
    </div>
  </div>

  <div class="rounded-3xl border border-slate-200 bg-white p-5 shadow-soft">
    <h2 class="text-lg font-semibold text-slate-900">Existing Task-Level Review Queue</h2>
    <p class="text-sm text-slate-500">Retained for compatibility with the existing Partner workflow.</p>
    <div class="mt-5 grid gap-4 lg:grid-cols-2">
      {% for item in review_queue %}<a href="{{ item.href }}" class="rounded-3xl border border-slate-200 p-5 hover:bg-slate-50"><div class="flex items-start justify-between gap-3"><div><h3 class="font-semibold text-slate-900">{{ item.task_name }}</h3><p class="mt-1 text-xs text-slate-500">{{ item.client_name }} · {{ item.service_name }}</p></div><span class="rounded-full bg-brand-100 px-2.5 py-1 text-xs font-semibold text-brand-700">Review</span></div><div class="mt-3 text-xs text-slate-500">Prepared by: {{ item.assigned_to }} · Due: {{ item.due_date or '-' }}</div></a>{% else %}<div class="rounded-3xl border border-dashed border-slate-300 p-8 text-center text-sm text-slate-500 lg:col-span-2">No completed tasks waiting in the legacy task queue.</div>{% endfor %}
    </div>
  </div>
</div>
