<div class="rounded-3xl border border-slate-200 bg-white shadow-soft">
  <div class="flex flex-col gap-3 border-b border-slate-100 p-5 md:flex-row md:items-center md:justify-between">
    <div><h2 class="text-lg font-bold text-slate-900">Branches</h2><p class="text-sm text-slate-500">Create branches and assign partner/users for each branch.</p></div>
    <a href="/system-settings/branches" class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-700">Manage Branches</a>
  </div>
  <div class="overflow-x-auto">
    <table class="min-w-full divide-y divide-slate-100 text-sm">
      <thead class="bg-slate-50 text-left text-xs font-semibold uppercase tracking-wide text-slate-500"><tr><th class="px-5 py-3">Branch</th><th class="px-5 py-3">Status</th><th class="px-5 py-3 text-right">Partners</th><th class="px-5 py-3 text-right">Users</th><th class="px-5 py-3 text-right">Clients</th><th class="px-5 py-3">Login / Assignment</th><th class="px-5 py-3">Storage / SMTP</th></tr></thead>
      <tbody class="divide-y divide-slate-100">
        {% for branch in branches %}
        <tr class="hover:bg-slate-50">
          <td class="px-5 py-3"><div class="font-semibold text-slate-900">{{ branch.name }}</div><div class="text-xs text-slate-500">{{ branch.code }}{% if branch.is_head_office %} &gt; Head Office{% endif %}</div></td>
          <td class="px-5 py-3"><span class="rounded-full px-2.5 py-1 text-xs font-semibold {% if branch.is_active %}bg-emerald-50 text-emerald-700{% else %}bg-slate-100 text-slate-600{% endif %}">{% if branch.is_active %}Active{% else %}Inactive{% endif %}</span></td>
          <td class="px-5 py-3 text-right font-semibold {% if branch.partner_count %}text-slate-900{% else %}text-amber-700{% endif %}">{{ branch.partner_count }}</td>
          <td class="px-5 py-3 text-right font-semibold">{{ branch.user_count }}</td>
          <td class="px-5 py-3 text-right font-semibold">{{ branch.client_count }}</td>
          <td class="px-5 py-3 text-xs text-slate-600">Login: {{ 'Allowed' if branch.allow_login else 'Blocked' }}<br>Assignments: {{ 'Allowed' if branch.allow_new_assignments else 'Blocked' }}</td>
          <td class="px-5 py-3 text-xs text-slate-600">Storage: {{ branch.local_storage_path or 'Not set' }}<br>SMTP: {{ 'Configured' if branch.smtp_configured else 'Pending' }}</td>
        </tr>
        {% else %}
        <tr><td colspan="7" class="px-5 py-8 text-center text-slate-500">No branches found. Create the first branch from System Settings.</td></tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</div>
