root = Card([overview, metricsRow, chartsRow, tablesRow, operationsRow, actionsRow], "card", "column", "l")
overview = CardHeader("Live Operations Dashboard", "Nebula Rift • Global • Updated 14:32 UTC")
metricsRow = Card([ccuCard, dauCard, mauCard, revTodayCard, arpuCard], "clear", "row", "m", "stretch", "between", true)
ccuCard = Card([ccuLabel, ccuValue], "sunk", "column", "s", "center")
ccuLabel = TextContent("Players Online", "small")
ccuValue = TextContent("247,891", "large-heavy")
dauCard = Card([dauLabel, dauValue], "sunk", "column", "s", "center")
dauLabel = TextContent("Daily Active", "small")
dauValue = TextContent("1.2M", "large-heavy")
mauCard = Card([mauLabel, mauValue], "sunk", "column", "s", "center")
mauLabel = TextContent("Monthly Active", "small")
mauValue = TextContent("8.7M", "large-heavy")
revTodayCard = Card([revTodayLabel, revTodayValue], "sunk", "column", "s", "center")
revTodayLabel = TextContent("Revenue Today", "small")
revTodayValue = TextContent("$487,320", "large-heavy")
arpuCard = Card([arpuLabel, arpuValue], "sunk", "column", "s", "center")
arpuLabel = TextContent("Revenue / User (30d)", "small")
arpuValue = TextContent("$4.12", "large-heavy")
chartsRow = Card([sessionChartCard, inflationChartCard], "clear", "row", "l", "stretch", "between")
sessionChartCard = Card([sessionChartHeader, sessionChart], "card", "column", "m")
sessionChartHeader = CardHeader("Session Length (14d)", "Average minutes per session")
sessionChart = LineChart(sessionLabels, [sessionSeries], "natural", "Day", "Minutes")
sessionLabels = ["Mar 1", "Mar 2", "Mar 3", "Mar 4", "Mar 5", "Mar 6", "Mar 7", "Mar 8", "Mar 9", "Mar 10", "Mar 11", "Mar 12", "Mar 13", "Mar 14"]
sessionSeries = Series("Avg Session", [22, 24, 23, 25, 26, 28, 30, 29, 27, 26, 25, 24, 23, 22])
inflationChartCard = Card([inflationChartHeader, inflationChart], "card", "column", "m")
inflationChartHeader = CardHeader("Currency Inflation Index", "Gold value relative to launch baseline (1.0)")
inflationChart = LineChart(inflationLabels, [inflationSeries], "natural", "Week", "Index")
inflationLabels = ["W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8"]
inflationSeries = Series("Inflation", [1.0, 1.03, 1.07, 1.12, 1.18, 1.25, 1.31, 1.38])
tablesRow = Card([topItemsCard, regionsCard, crashCard], "clear", "row", "l", "stretch", "between")
topItemsCard = Card([topItemsHeader, topItemsTable], "card", "column", "m")
topItemsHeader = CardHeader("Best-Selling Items (7d)", "Units sold and revenue")
topItemsTable = Table([itemNameCol, itemUnitsCol, itemRevenueCol])
itemNameCol = Col("Item", ["Cosmic Wings", "Void Armor Set", "Starter Bundle", "Nebula Mount", "Battle Pass S3", "Emote Pack"])
itemUnitsCol = Col("Units", [12450, 8920, 15600, 3210, 28400, 5670])
itemRevenueCol = Col("Revenue", ["$186,750", "$267,600", "$156,000", "$160,500", "$284,000", "$56,700"])
regionsCard = Card([regionsHeader, regionsTable], "card", "column", "m")
regionsHeader = CardHeader("Server Regions & Health", "Capacity and latency")
regionsTable = Table([regionNameCol, regionStatusCol, regionCapacityCol, regionLatencyCol, regionPlayersCol])
regionNameCol = Col("Region", ["US-East", "US-West", "EU-Central", "EU-West", "AP-Singapore", "AP-Tokyo", "SA-São Paulo", "ME-Dubai"])
regionStatusCol = Col("Status", ["Healthy", "Healthy", "Degraded", "Healthy", "Healthy", "Healthy", "Warning", "Healthy"])
regionCapacityCol = Col("Capacity %", [67, 54, 89, 61, 72, 68, 93, 45])
regionLatencyCol = Col("Avg Latency (ms)", [42, 38, 55, 48, 62, 58, 71, 89])
regionPlayersCol = Col("Players", [52100, 38400, 45200, 29800, 31600, 27900, 14200, 8700])
crashCard = Card([crashHeader, crashChart], "card", "column", "m")
crashHeader = CardHeader("Crash Rate by App Version", "Crashes per 1k sessions (7d)")
crashChart = HorizontalBarChart(crashLabels, [crashSeries], "grouped", "Crashes / 1k", "Version")
crashLabels = ["v3.2.1", "v3.2.0", "v3.1.5", "v3.1.4", "v3.1.3"]
crashSeries = Series("Crash Rate", [0.8, 2.3, 4.1, 5.7, 6.2])
operationsRow = Card([eventsCard, reportsCard, appealsCard, experimentsCard], "clear", "row", "l", "stretch", "between")
eventsCard = Card([eventsHeader, eventsList], "card", "column", "m")
eventsHeader = CardHeader("Live Events", "Running and upcoming")
eventsList = ListBlock(eventItems, "number")
eventItems = [event1, event2, event3, event4, event5]
event1 = ListItem("Double XP Weekend", "Running • Ends Mar 16 23:59 UTC", null, "Manage")
event2 = ListItem("Cosmic Conquest Season 3", "Running • Ends Apr 20", null, "Manage")
event3 = ListItem("Void Invasion", "Starts Mar 18 14:00 UTC", null, "Preview")
event4 = ListItem("Community Tournament Qualifiers", "Starts Mar 22 18:00 UTC", null, "Preview")
event5 = ListItem("Anniversary Celebration", "Starts Apr 1 00:00 UTC", null, "Preview")
reportsCard = Card([reportsHeader, reportsContent], "card", "column", "m")
reportsHeader = CardHeader("Player Reports", "Awaiting moderation review")
reportsContent = Card([reportsCount, reportsBreakdown, reportsAction], "clear", "column", "s")
reportsCount = TextContent("1,247 reports pending", "large-heavy")
reportsBreakdown = TextContent("Cheating: 523 • Toxicity: 389 • Exploits: 187 • Spam: 148", "small")
reportsAction = Buttons([reviewReportsBtn])
reviewReportsBtn = Button("Open Review Queue", null, "primary")
appealsCard = Card([appealsHeader, appealsContent], "card", "column", "m")
appealsHeader = CardHeader("Ban Appeals", "Awaiting moderation review")
appealsContent = Card([appealsCount, appealsBreakdown, appealsAction], "clear", "column", "s")
appealsCount = TextContent("312 appeals pending", "large-heavy")
appealsBreakdown = TextContent("Permanent: 187 • Temporary: 94 • Chat: 31", "small")
appealsAction = Buttons([reviewAppealsBtn])
reviewAppealsBtn = Button("Open Appeal Queue", null, "primary")
experimentsCard = Card([experimentsHeader, exp1Card, exp2Card], "card", "column", "m")
experimentsHeader = CardHeader("Running Experiments", "A/B test results (95% confidence)")
exp1Card = Card([exp1Header, exp1Metrics, exp1Action], "sunk", "column", "s")
exp1Header = TextContent("Exp #1: Daily Login Reward Revamp", "small-heavy")
exp1Metrics = TextContent("Control: 34.2% retention • Variant: 37.8% retention • +3.6pp (p<0.01)", "small")
exp1Action = Buttons([exp1ShipBtn, exp1ExtendBtn])
exp1ShipBtn = Button("Ship to 100%", null, "primary", "normal", "small")
exp1ExtendBtn = Button("Extend", null, "secondary", "normal", "small")
exp2Card = Card([exp2Header, exp2Metrics, exp2Action], "sunk", "column", "s")
exp2Header = TextContent("Exp #2: Battle Pass Price Elasticity", "small-heavy")
exp2Metrics = TextContent("Control: $9.99 • Variant: $7.99 • ARPU: -2.1% • Conversion: +18.4%", "small")
exp2Action = Buttons([exp2ShipBtn, exp2ExtendBtn])
exp2ShipBtn = Button("Ship to 100%", null, "primary", "normal", "small")
exp2ExtendBtn = Button("Extend", null, "secondary", "normal", "small")
actionsRow = Card([patchNotesForm, regionFocusCard, hotfixCard], "clear", "row", "l", "stretch", "between")
patchNotesForm = Card([patchHeader, patchForm], "card", "column", "m")
patchHeader = CardHeader("Draft Patch Notes", "For v3.2.2 — save as draft or publish")
patchForm = Form("patch-notes", patchButtons, [patchTitleField, patchVersionField, patchBodyField])
patchTitleField = FormControl("Title", patchTitleInput, "e.g., \"v3.2.2 — Void Invasion Hotfix\"")
patchTitleInput = Input("patch_title", "v3.2.2 — ", "text", null, "")
patchVersionField = FormControl("Version", patchVersionInput, "Auto-filled from build pipeline")
patchVersionInput = Input("patch_version", "3.2.2", "text", null, "3.2.2")
patchBodyField = FormControl("Notes (Markdown)", patchBodyInput, "Use ## for categories, - for bullets")
patchBodyInput = TextArea("patch_body", "## Bug Fixes\n- Fixed Void Portal visual desync\n- Resolved crash on AP-Singapore login\n\n## Balance\n- Adjusted Cosmic Wings drop rate\n\n## Known Issues", 8, null, "")
patchButtons = Buttons([patchSaveBtn, patchPublishBtn], "row")
patchSaveBtn = Button("Save Draft", null, "secondary")
patchPublishBtn = Button("Publish", null, "primary")
regionFocusCard = Card([regionFocusHeader, regionFocusForm], "card", "column", "m")
regionFocusHeader = CardHeader("Focus Region", "Filter all metrics to a single region")
regionFocusForm = Form("region-focus", regionFocusButtons, [regionSelectField])
regionSelectField = FormControl("Select Region", regionSelect, "All metrics will re-filter to this region")
regionSelect = Select("region_focus", regionOptions, "All Regions (Global)", null, "All Regions (Global)", "medium")
regionOptions = [optGlobal, optUSEast, optUSWest, optEUCentral, optEUWest, optAPSingapore, optAPTokyo, optSASaoPaulo, optMEDubai]
optGlobal = SelectItem("global", "All Regions (Global)")
optUSEast = SelectItem("us-east", "US-East")
optUSWest = SelectItem("us-west", "US-West")
optEUCentral = SelectItem("eu-central", "EU-Central")
optEUWest = SelectItem("eu-west", "EU-West")
optAPSingapore = SelectItem("ap-singapore", "AP-Singapore")
optAPTokyo = SelectItem("ap-tokyo", "AP-Tokyo")
optSASaoPaulo = SelectItem("sa-saopaulo", "SA-São Paulo")
optMEDubai = SelectItem("me-dubai", "ME-Dubai")
regionFocusButtons = Buttons([regionApplyBtn], "row")
regionApplyBtn = Button("Apply Filter", null, "primary")
hotfixCard = Card([hotfixHeader, hotfixForm], "card", "column", "m")
hotfixHeader = CardHeader("Ship Hotfix", "Emergency build deployment")
hotfixForm = Form("hotfix-deploy", hotfixButtons, [hotfixVersionField, hotfixDescField, hotfixRegionsField, hotfixConfirmField])
hotfixVersionField = FormControl("Hotfix Version", hotfixVersionInput, "e.g., 3.2.1-hotfix.1")
hotfixVersionInput = Input("hotfix_version", "3.2.1-hotfix.1", "text", null, "")
hotfixDescField = FormControl("Description", hotfixDescInput, "What does this fix?")
hotfixDescInput = TextArea("hotfix_desc", "Fixes Void Portal desync causing disconnects on AP-Singapore", 3, null, "")
hotfixRegionsField = FormControl("Target Regions", hotfixRegionsSelect, "Select one or more regions")
hotfixRegionsSelect = Select("hotfix_regions", hotfixRegionOptions, "All Regions", null, "All Regions", "medium")
hotfixRegionOptions = [hfOptAll, hfOptUSEast, hfOptUSWest, hfOptEUCentral, hfOptEUWest, hfOptAPSingapore, hfOptAPTokyo, hfOptSASaoPaulo, hfOptMEDubai]
hfOptAll = SelectItem("all", "All Regions")
hfOptUSEast = SelectItem("us-east", "US-East")
hfOptUSWest = SelectItem("us-west", "US-West")
hfOptEUCentral = SelectItem("eu-central", "EU-Central")
hfOptEUWest = SelectItem("eu-west", "EU-West")
hfOptAPSingapore = SelectItem("ap-singapore", "AP-Singapore")
hfOptAPTokyo = SelectItem("ap-tokyo", "AP-Tokyo")
hfOptSASaoPaulo = SelectItem("sa-saopaulo", "SA-São Paulo")
hfOptMEDubai = SelectItem("me-dubai", "ME-Dubai")
hotfixConfirmField = FormControl("Confirmation", hotfixConfirmCheck, "Type 'DEPLOY' to confirm")
hotfixConfirmCheck = Input("hotfix_confirm", "DEPLOY", "text", null, "")
hotfixButtons = Buttons([hotfixCancelBtn, hotfixDeployBtn], "row")
hotfixCancelBtn = Button("Cancel", null, "tertiary")
hotfixDeployBtn = Button("Deploy Hotfix", null, "primary", "destructive")