<style>.dealflow-summary-widget{display:flex;flex-direction:column;overflow:hidden;min-width:0;flex:1 1 0;min-height:0;position:relative;}</style>
<div class="dealflow-summary-widget">
    <div style="display:flex;justify-content:space-between;align-items:baseline;flex-shrink:0;">
        <span style="font-size:20px;font-weight:700;">
            <a href="{{ path('mautic_dealflow_pipeline') }}" style="color:inherit;text-decoration:none;">${{ totalValue|number_format(0, '.', ',') }}</a>
        </span>
        <span style="font-size:12px;color:var(--text-secondary);">{{ dealCount }} open deal{{ dealCount == 1 ? '' : 's' }}</span>
    </div>
    {% if deals is not empty %}
        <div style="flex:1 1 0;overflow-y:auto;min-height:0;margin-top:8px;">
            <table style="width:100%;font-size:12px;table-layout:fixed;border-collapse:collapse;">
                <tbody>
                {% for deal in deals %}
                    <tr>
                        <td style="padding:4px 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:0;width:50%;"><a href="{{ path('mautic_dealflow_view', {'objectId': deal.getId()}) }}" style="color:inherit;text-decoration:none;font-weight:600;">{{ deal.getTitle() }}</a></td>
                        <td style="padding:4px 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:0;color:var(--text-secondary);width:30%;">{{ deal.getStage() ? deal.getStage().getName() : 'N/A' }}</td>
                        <td style="padding:4px 0;text-align:right;white-space:nowrap;width:20%;">${{ deal.getAmount()|number_format(0, '.', ',') }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
        <div style="flex-shrink:0;border-top:1px solid var(--border-subtle-01, #eee);margin-top:6px;padding-top:6px;text-align:right;">
            <a href="{{ path('mautic_dealflow_index') }}" style="font-size:12px;color:var(--brand-primary, #4e79a7);text-decoration:none;">View all &rarr;</a>
        </div>
    {% else %}
        <p style="color:var(--text-secondary);font-size:13px;">No open deals.</p>
    {% endif %}
    {% include '@DealFlow/Dashboard/_config_popover.html.twig' %}
</div>
