{% extends "ui/templates/base/layout.html" %}
{% import "ui/templates/components/macros.html" as ui %}
{% block content %}
<div class="space-y-6">
  {{ ui.page_shell('Audit Firms', 'Audit Firm master with search, paging, and quick actions for branch setup.', '<a href="/system-settings/tenants/new" class="rounded-xl bg-slate-900 text-white px-4 py-2 text-sm">Add Audit Firm</a>') }}
  <div class="overflow-hidden rounded-3xl bg-white shadow-soft">
    {{ ui.search_bar('/system-settings/tenants', filters.q, filters.per_page) }}
    {% if tenants %}
    <table class="w-full text-sm"><thead class="bg-slate-50 text-slate-600"><tr><th class="text-left p-3">ID</th><th class="text-left p-3">Code</th><th class="text-left p-3">Name</th><th class="text-left p-3">Firm Type</th><th class="text-left p-3">Status</th><th class="text-left p-3">Actions</th></tr></thead><tbody>{% for t in tenants %}<tr class="border-t"><td class="p-3">{{ t.id }}</td><td class="p-3">{{ t.code }}</td><td class="p-3">{{ t.name }}</td><td class="p-3">{{ (t.firm_type or 'proprietorship')|replace('_',' ')|title }}</td><td class="p-3">{{ ui.badge('Active','emerald') if t.is_active else ui.badge('Inactive','rose') }}</td><td class="p-3"><div class="flex gap-3"><a class="text-slate-900 underline" href="/system-settings/tenants/{{ t.id }}/edit">Edit</a><a class="text-slate-900 underline" href="/system-settings/branches/new?tenant_id={{ t.id }}">Add Branch</a></div></td></tr>{% endfor %}</tbody></table>
    {{ ui.pagination(tenants_page, '/system-settings/tenants', request.url.query) }}
    {% else %}<div class="p-6">{{ ui.empty_state('No audit firms found.') }}</div>{% endif %}
  </div>
</div>
{% endblock %}
