{# Repository status grid — expects: repo_states (list[RepoState]) #}
{% if repo_states %}
    {% set live_count = repo_states|selectattr('status.value', 'equalto', 'live')|list|length %}
    {% set failed_count = repo_states|selectattr('status.value', 'equalto', 'failed')|list|length %}
    {% set pending_count = repo_states|selectattr('status.value', 'equalto', 'reload_pending')|list|length + repo_states|selectattr('status.value', 'equalto', 'reloading')|list|length %}
    {% set status_summary = live_count ~ ' live' ~ (', ' ~ pending_count ~ ' reloading' if pending_count > 0 else '') ~ (', ' ~ failed_count ~ ' failed' if failed_count > 0 else '') %}
<div id="repos-section" class="repos-section">
    <div class="section-title">Repositories ({{ status_summary }})</div>
    <div class="repos-grid">
        {% for repo in repo_states|sort(attribute='repo_id') %}
        <div class="repo-card">
            <a href="/repo/{{ repo.repo_id }}">
                <span class="repo-status-indicator {{ repo.status.value }}"></span>
                <span class="repo-name">{{ repo.repo_id }}</span>
            </a>
            {% if repo.status.value == 'failed' and repo.error_type %}
            <span class="repo-error-hint">{{ repo.error_type }}</span>
            {% endif %}
        </div>
        {% endfor %}
    </div>
</div>
{% endif %}
