{
        "dataSource": {
            "summaries": "/api/credit/utilization-summary/:orgId",
            "alerts": "/api/credit/alerts/:orgId"
        },
        "autoRefresh": 30000,
        "layout": {
            "type": "grid",
            "columns": 12
        },
        "widgets": [
            {
                "id": "healthy_count",
                "type": "stat",
                "title": "Healthy",
                "icon": "fa-check-circle",
                "color": "success",
                "position": { "row": 1, "col": 1, "width": 2 },
                "dataSource": "summaries",
                "value": "{{data.filter(c => c.health_status === 'healthy').length}}",
                "description": "Customers with good credit standing"
            },
            {
                "id": "caution_count",
                "type": "stat",
                "title": "Caution",
                "icon": "fa-exclamation-triangle",
                "color": "info",
                "position": { "row": 1, "col": 3, "width": 2 },
                "dataSource": "summaries",
                "value": "{{data.filter(c => c.health_status === 'caution').length}}",
                "description": "60-79% credit utilization"
            },
            {
                "id": "warning_count",
                "type": "stat",
                "title": "Warning",
                "icon": "fa-exclamation",
                "color": "warning",
                "position": { "row": 1, "col": 5, "width": 2 },
                "dataSource": "summaries",
                "value": "{{data.filter(c => c.health_status === 'warning').length}}",
                "description": "80-99% credit utilization"
            },
            {
                "id": "critical_count",
                "type": "stat",
                "title": "Critical",
                "icon": "fa-ban",
                "color": "error",
                "position": { "row": 1, "col": 7, "width": 2 },
                "dataSource": "summaries",
                "value": "{{data.filter(c => c.health_status === 'critical').length}}",
                "description": "100%+ credit utilization"
            },
            {
                "id": "on_hold_count",
                "type": "stat",
                "title": "On Hold",
                "icon": "fa-pause-circle",
                "color": "error",
                "position": { "row": 1, "col": 9, "width": 2 },
                "dataSource": "summaries",
                "value": "{{data.filter(c => c.on_hold).length}}",
                "description": "Accounts with credit hold"
            },
            {
                "id": "total_exposure",
                "type": "currency",
                "title": "Total Credit Exposure",
                "icon": "fa-dollar-sign",
                "color": "primary",
                "position": { "row": 1, "col": 11, "width": 2 },
                "dataSource": "summaries",
                "value": "{{data.reduce((sum, c) => sum + parseFloat(c.total_utilized || 0), 0)}}",
                "description": "Total outstanding across all customers",
                "format": "currency"
            },
            {
                "id": "utilization_chart",
                "type": "chart",
                "title": "Credit Utilization Distribution",
                "chartType": "doughnut",
                "position": { "row": 2, "col": 1, "width": 6 },
                "dataSource": "summaries",
                "config": {
                    "labels": ["Healthy (0-59%)", "Caution (60-79%)", "Warning (80-99%)", "Critical (100%+)", "On Hold"],
                    "datasets": [{
                        "label": "Customer Count",
                        "data": [
                            "{{data.filter(c => c.health_status === 'healthy').length}}",
                            "{{data.filter(c => c.health_status === 'caution').length}}",
                            "{{data.filter(c => c.health_status === 'warning').length}}",
                            "{{data.filter(c => c.health_status === 'critical').length}}",
                            "{{data.filter(c => c.on_hold).length}}"
                        ],
                        "backgroundColor": [
                            "#10b981",
                            "#3b82f6",
                            "#f59e0b",
                            "#ef4444",
                            "#6b7280"
                        ]
                    }]
                }
            },
            {
                "id": "top_at_risk",
                "type": "chart",
                "title": "Top 10 At-Risk Customers",
                "chartType": "horizontalBar",
                "position": { "row": 2, "col": 7, "width": 6 },
                "dataSource": "summaries",
                "config": {
                    "labels": "{{data.filter(c => c.utilization_percentage >= 80).sort((a,b) => b.utilization_percentage - a.utilization_percentage).slice(0,10).map(c => c.customer_name)}}",
                    "datasets": [{
                        "label": "Utilization %",
                        "data": "{{data.filter(c => c.utilization_percentage >= 80).sort((a,b) => b.utilization_percentage - a.utilization_percentage).slice(0,10).map(c => c.utilization_percentage)}}",
                        "backgroundColor": "#ef4444"
                    }]
                }
            },
            {
                "id": "alerts_panel",
                "type": "list",
                "title": "Unacknowledged Alerts",
                "icon": "fa-bell",
                "position": { "row": 3, "col": 1, "width": 12 },
                "dataSource": "alerts",
                "emptyMessage": "No unacknowledged alerts",
                "itemTemplate": "<div class=\"alert alert-{{item.severity}} mb-2\"><div class=\"flex items-center justify-between\"><div><strong>{{item.customer_name}}</strong> - {{item.alert_type}}</div><div><span class=\"badge badge-{{item.severity}}\">{{item.severity}}</span><button class=\"btn btn-sm btn-ghost ml-2\" data-action=\"credit:acknowledge-alert\" data-alert-id=\"{{item.alert_id}}\">Acknowledge</button></div></div><div class=\"text-sm mt-1\">{{item.message}}</div><div class=\"text-xs text-gray-500 mt-1\">{{item.created_at | formatDateTime}}</div></div>",
                "maxItems": 10
            },
            {
                "id": "recent_holds",
                "type": "table",
                "title": "Recent Credit Holds",
                "icon": "fa-pause-circle",
                "position": { "row": 4, "col": 1, "width": 12 },
                "dataSource": "summaries",
                "filter": "{{data.filter(c => c.on_hold)}}",
                "columns": [
                    {
                        "field": "customer_name",
                        "label": "Customer",
                        "sortable": true
                    },
                    {
                        "field": "credit_limit",
                        "label": "Credit Limit",
                        "type": "currency",
                        "sortable": true
                    },
                    {
                        "field": "total_utilized",
                        "label": "Utilized",
                        "type": "currency",
                        "sortable": true
                    },
                    {
                        "field": "utilization_percentage",
                        "label": "Utilization %",
                        "type": "percentage",
                        "sortable": true
                    },
                    {
                        "field": "hold_reason",
                        "label": "Hold Reason",
                        "sortable": false
                    },
                    {
                        "field": "hold_applied_at",
                        "label": "Hold Applied",
                        "type": "datetime",
                        "sortable": true
                    }
                ],
                "rowActions": [
                    {
                        "label": "Remove Hold",
                        "icon": "fa-play-circle",
                        "action": "credit:remove-hold",
                        "style": "success",
                        "confirm": "Remove credit hold for this customer?"
                    },
                    {
                        "label": "View History",
                        "icon": "fa-history",
                        "action": "credit:view-history",
                        "style": "ghost"
                    }
                ],
                "maxRows": 10
            }
        ]
    }