{#if statsError} {at("stats_error", { error: statsError }, "")} {:else if showSkeleton} {#each Array(3) as _, i (i)} {/each}
{#each Array(4) as _, m (m)}
{/each}
{:else if stats} {at("stats_label_users", {}, "")} {users.total_users ?? 0} +{users.active_today ?? 0} {at("stats_label_active_subs", {}, "")} {users.active_subscriptions ?? 0} {users.total_users ? Math.round(((users.active_subscriptions ?? 0) / (users.total_users || 1)) * 100) : 0}% {at("stats_label_inactive", {}, "")} {users.inactive_users ?? 0} {users.total_users ? Math.round(((users.inactive_users ?? 0) / (users.total_users || 1)) * 100) : 0}% {at("stats_label_today_rev", {}, "")} {fmtMoney(fin.today_revenue, currency)} {#if revenueKpis.growthPct != null} {#if revenueKpis.growthPct >= 0} {:else} {/if} {revenueKpis.growthPct >= 0 ? "+" : ""}{revenueKpis.growthPct.toFixed(1)}% {:else} {/if}
{at("stats_trend_payments", { count: fin.today_payments_count ?? 0 }, "")}
{fin.today_payments_count ?? 0}
{at("stats_revenue_avg_ticket_label", {}, "")}
{revenueKpis.avgToday != null ? fmtMoney(revenueKpis.avgToday, currency) : "—"}
{#if revenueKpis.avgToday == null}
{at("stats_revenue_avg_none", {}, "")}
{/if}
{at("stats_revenue_rolling_week", {}, "")}
{fmtMoney(fin.week_revenue, currency)}
{at("stats_revenue_rolling_month", {}, "")}
{fmtMoney(fin.month_revenue, currency)}
{at("stats_revenue_last_7_calendar", {}, "")}
{fmtMoney(revenueKpis.last7, currency)}
{at("stats_label_all_time", {}, "")}
{fmtMoney(fin.all_time_revenue, currency)}
{at("stats_revenue_total_14", {}, "")}
{fmtMoney(revenueKpis.total14, currency)}
{#if revenueKpis.growthPct != null} = 0} class:is-down={revenueKpis.growthPct < 0} > {at("stats_revenue_growth", { value: revenueKpis.growthPct.toFixed(1) }, "")} {:else} {at("stats_revenue_growth_na", {}, "")} {/if}
{at("stats_revenue_chart_title", {}, "")}
{#each REVENUE_PRESET_DAYS as d (d)} {/each}
{#each ["day", "week", "month"] as g (g)} {/each}

{at(revenueChartHintKey(), {}, "")}

{#if revenueChartSeries.length}
{at( "stats_revenue_chart_range_sum", { value: fmtMoney(chartRangeSum, currency) }, "" )} {#if revenueGranularity !== "day"} {at( "stats_revenue_chart_bucket_count", { count: revenueChartSeries.length }, "" )} {/if} {#if revenueChartShortfall} {at( "stats_revenue_chart_days_available", { count: dailySeries.length }, "" )} {:else if revenueRangeMode === "custom" && revenueCustomDaySpan > 0} {at("stats_revenue_chart_custom_span", { days: revenueCustomDaySpan }, "")} {/if}
{:else}

{at("stats_revenue_no_chart", {}, "")}

{/if}
{#if panelPayload?.error}

{at("stats_panel_unavailable_detail", {}, "")}

{:else if panelMetrics}
{at("stats_panel_online", {}, "")}
{panelMetrics.onlineNow}
{at("stats_panel_active", {}, "")}
{panelMetrics.active}
{at("stats_panel_total_users", {}, "")}
{panelMetrics.totalPanelUsers}
{at("stats_panel_expired", {}, "")}
{panelMetrics.expired}
{at("stats_panel_disabled", {}, "")}
{panelMetrics.disabled}
{at("stats_panel_limited", {}, "")}
{panelMetrics.limited}
{#if panelNodesListedCount > 0}
{at("stats_panel_nodes_online", {}, "")}
{panelNodesListedCount}
{/if} {#if panelMetrics.memPct != null}
{at("stats_panel_memory", {}, "")}
{panelMetrics.memPct.toFixed(1)}%
{/if} {#if panelMetrics.cpuPct != null}
{at("stats_panel_cpu", {}, "")}
{panelMetrics.cpuPct.toFixed(1)}%
{/if} {#if panelBw?.week != null}
{at("stats_panel_bw_week", {}, "")}
{panelBw.week}
{/if} {#if panelBw?.month != null}
{at("stats_panel_bw_month", {}, "")}
{panelBw.month}
{/if}
{#if panelNodeTraffic?.seven?.length}

{at("stats_panel_inner_nodes", {}, "")}

{at("stats_panel_inner_nodes_hint", {}, "")}

{#each panelNodeTraffic.seven.slice(0, PANEL_NODE_TILE_LIMIT) as node}
{node.label}
{node.value}
{#if node.online != null}
{at("stats_panel_node_users_online", { count: node.online }, "")}
{/if}
{/each}
{#if panelNodeTraffic.seven.length > PANEL_NODE_TILE_LIMIT}

{at( "stats_panel_nodes_overflow", { count: panelNodeTraffic.seven.length - PANEL_NODE_TILE_LIMIT }, "" )}

{/if}
{:else if panelPayload?.nodes && typeof panelPayload.nodes === "object" && Object.keys(panelPayload.nodes).length > 0}

{at("stats_panel_nodes_empty", {}, "")}

{/if}
{/if}
{at("stats_sync_label", {}, "")}: {stats.panel_sync?.status ?? "—"}{#if stats.panel_sync?.last_sync_time} · {at("stats_sync_last", {}, "")}: {fmtDateShort( stats.panel_sync.last_sync_time )}{/if} {#if stats.panel_sync && (stats.panel_sync.users_processed > 0 || stats.panel_sync.subscriptions_synced > 0)} {at( "stats_sync_processed", { users: stats.panel_sync.users_processed, subs: stats.panel_sync.subscriptions_synced, }, "" )} {/if} {#if stats.queue} {at("stats_label_queue", {}, "")}: {stats.queue.user_queue_size ?? 0}{at("stats_queue_users", {}, "")}, {stats.queue .group_queue_size ?? 0}{at("stats_queue_groups", {}, "")} {/if}
{at("stats_recent_payments", {}, "")} {at( "stats_records_count", { count: (stats.recent_payments || []).length }, "" )}
{#if statsLoading} {:else if (stats.recent_payments || []).length} {at("id", {}, "")} {at("user", {}, "")} {at("amount", {}, "")} {at("provider", {}, "")} {at("status", {}, "")} {at("date", {}, "")} {#each stats.recent_payments as p} #{p.payment_id} {p.user_label || p.user_id} {fmtMoney(p.amount, p.currency)} {p.provider} {p.status} {fmtDate(p.created_at)} {/each} {:else} {at("no_data", {}, "")} {/if}
{/if}