root = Card([header, kpiRow, sessionCard, salesCard, regionCard, crashCard, eventsCard, moderationCard, economyCard, experimentsCard, patchCard, opsCard], "card", "column", "l")

header = CardHeader("Live-Ops Command Center", "Game Studio — Real-time monitoring & operations")

kpiRow = Card([onlineKpi, dauKpi, mauKpi, revenueTodayKpi, arpuKpi], "card", "row", "l")
onlineKpi = Card([onlineLabel, onlineValue], "sunk", "column", "none")
onlineLabel = TextContent("Players online", "small")
onlineValue = TextContent("128,432", "large-heavy")
dauKpi = Card([dauLabel, dauValue], "sunk", "column", "none")
dauLabel = TextContent("Daily active players", "small")
dauValue = TextContent("2,180,556", "large-heavy")
mauKpi = Card([mauLabel, mauValue], "sunk", "column", "none")
mauLabel = TextContent("Monthly active players", "small")
mauValue = TextContent("8,402,119", "large-heavy")
revenueTodayKpi = Card([revenueTodayLabel, revenueTodayValue], "sunk", "column", "none")
revenueTodayLabel = TextContent("Revenue today", "small")
revenueTodayValue = TextContent("$184,290", "large-heavy")
arpuKpi = Card([arpuLabel, arpuValue], "sunk", "column", "none")
arpuLabel = TextContent("Revenue per user", "small")
arpuValue = TextContent("$0.084", "large-heavy")

sessionCard = Card([sessionHeader, sessionLineChart], "sunk")
sessionHeader = Heading("Session length over the past two weeks", "h3")
sessionLineChart = LineChart(sessionLabels, [sessionSeries], "natural", "Date", "Avg minutes")
sessionLabels = ["May 1", "May 2", "May 3", "May 4", "May 5", "May 6", "May 7", "May 8", "May 9", "May 10", "May 11", "May 12", "May 13", "May 14"]
sessionSeries = Series("Avg session length", [18, 19, 17, 21, 20, 22, 23, 24, 22, 25, 26, 27, 28, 29])

salesCard = Card([salesHeader, salesTable], "sunk")
salesHeader = Heading("Best-selling items", "h3")
salesTable = Table([salesItemCol, salesUnitsCol])
salesItemCol = Col("Item", ["Dragon Crown", "Phoenix Wings", "Shadow Blade", "Mana Potion XL", "Mystery Chest"])
salesUnitsCol = Col("Units", [12430, 9800, 8450, 7210, 5120])

regionCard = Card([regionHeader, regionTable], "sunk")
regionHeader = Heading("Server region health", "h3")
regionTable = Table([regionNameCol, regionStatusCol, regionLoadCol])
regionNameCol = Col("Region", ["NA East", "NA West", "EU West", "EU Central", "APAC", "LATAM"])
regionStatusCol = Col("Status", ["Healthy", "Healthy", "Degraded", "Healthy", "Warning", "Healthy"])
regionLoadCol = Col("Load", ["42%", "38%", "71%", "55%", "63%", "58%"])

crashCard = Card([crashHeader, crashChart], "sunk")
crashHeader = Heading("Crash rate by app version", "h3")
crashChart = BarChart(["1.4.0", "1.4.1", "1.5.0-rc1", "1.5.0"], [crashSeries], "grouped", "Version", "Crash %")
crashSeries = Series("Crash rate", [0.8, 1.2, 0.5, 0.3])

eventsCard = Card([eventsHeader, runningEvents, upcomingEvents], "sunk")
eventsHeader = Heading("Live events", "h3")
runningEvents = Card([runningHeaderText, runningList], "clear", "column", "s")
runningHeaderText = TextContent("Running now", "small-heavy")
runningList = ListBlock([event1, event2])
event1 = ListItem("Summer Festival", "Ends in 2d 4h", null, "View")
event2 = ListItem("Double XP Weekend", "Ends in 11h 30m")
upcomingEvents = Card([upcomingHeaderText, upcomingList], "clear", "column", "s")
upcomingHeaderText = TextContent("Upcoming", "small-heavy")
upcomingList = ListBlock([event3, event4])
event3 = ListItem("Crown Raid", "Starts in 1d 12h")
event4 = ListItem("Mystery Chest Event", "Starts in 3d 0h")

moderationCard = Card([modHeader, modRow], "sunk")
modHeader = Heading("Player moderation", "h3")
modRow = Card([reportsCard, appealsCard], "clear", "row", "l")
reportsCard = Card([reportsHeader, reportsCount, reportsBtn], "card", "column", "s")
reportsHeader = Heading("Player reports awaiting review", "h4")
reportsCount = TextContent("12,431", "large-heavy")
reportsBtn = Button("Review reports")
appealsCard = Card([appealsHeader, appealsCount, appealsBtn], "card", "column", "s")
appealsHeader = Heading("Ban appeals awaiting review", "h4")
appealsCount = TextContent("847", "large-heavy")
appealsBtn = Button("Review appeals")

economyCard = Card([economyHeader, inflationChart], "sunk")
economyHeader = Heading("In-game currency inflation", "h3")
inflationChart = LineChart(["W1", "W2", "W3", "W4", "W5", "W6"], [inflationSeries], "linear", "Week", "Currency in circulation (M)")
inflationSeries = Series("Coins minted", [100, 115, 132, 148, 175, 196])

experimentsCard = Card([expHeader, expRow], "sunk")
expHeader = Heading("Running experiments", "h3")
expRow = Card([expOne, expTwo], "clear", "row", "l")
expOne = Card([expOneHeader, expOneTable], "card")
expOneHeader = Heading("XP Curve v2", "h4")
expOneTable = Table([expVariantCol, expRetentionCol])
expVariantCol = Col("Variant", ["Control", "Test"])
expRetentionCol = Col("D7 retention", ["34.2%", "36.8%"])
expTwo = Card([expTwoHeader, expTwoTable], "card")
expTwoHeader = Heading("Starter Bundle", "h4")
expTwoTable = Table([exp2VariantCol, exp2ConvCol])
exp2VariantCol = Col("Variant", ["Control", "Test"])
exp2ConvCol = Col("Purchase rate", ["2.1%", "2.7%"])

patchCard = Card([patchHeader, patchForm], "sunk")
patchHeader = Heading("Draft patch notes", "h3")
patchForm = Form("patch-notes", patchButtons, [patchField])
patchField = FormControl("Notes", patchTextarea, "Markdown supported")
patchTextarea = TextArea("notes", "## v1.5.1\n- Fixed crash on login\n- Balanced Dragon Crown", 6)
patchButtons = Buttons([savePatchBtn, publishBtn])
savePatchBtn = Button("Save draft")
publishBtn = Button("Publish", null, "secondary")

opsCard = Card([opsHeader, opsRow], "sunk")
opsHeader = Heading("Operations", "h3")
opsRow = Card([focusCard, hotfixCard], "clear", "row", "l")
focusCard = Card([focusHeader, focusForm], "card")
focusHeader = Heading("Focus on one region", "h4")
focusForm = Form("region-focus", focusButtons, [regionField])
regionField = FormControl("Region", regionSelect)
regionSelect = Select("region", [regionNa, regionEu, regionApac], "Choose a region")
regionNa = SelectItem("na", "North America")
regionEu = SelectItem("eu", "Europe")
regionApac = SelectItem("apac", "APAC")
focusButtons = Buttons([applyFocusBtn])
applyFocusBtn = Button("Apply focus", null, "primary")
hotfixCard = Card([hotfixHeader, hotfixDialog], "card")
hotfixHeader = Heading("Ship a hotfix", "h4")
hotfixDialog = AlertDialogBlock("Ship hotfix", "Confirm hotfix", "This will restart all game servers immediately. Continue?", "Ship now", "Cancel", "destructive")