root = Card([header, liveViewers, topTitles, watchTimeTrend, subChurn, genrePerformance, bufferingRate, deliveryHealth, upcomingReleases, expiringLicenses, recCTR, searchNoPlay, revenueByPlan, deviceSplit, regionFocus, featureFlags, promoteTitle], "clear", "column", "l")
header = CardHeader("Streaming Operations Dashboard", "Real-time platform health & content intelligence")
liveViewers = Card([viewersHeading, viewersMetric], "card", "row", "l", "center", "between")
viewersHeading = Heading("Live Viewers", "h3")
viewersMetric = TextContent("2.4M", "large-heavy")
topTitles = Card([topTitlesHeading, topTitlesTable], "card", "column", "m")
topTitlesHeading = Heading("Most-Watched Titles (Last 24h)", "h3")
topTitlesTable = Table([titleCol, hoursCol, viewersCol, completionCol])
titleCol = Col("Title", ["The Crown S6", "Stranger Things S4", "Wednesday S1", "Squid Game S1", "Bridgerton S2", "The Witcher S3"])
hoursCol = Col("Hours Watched", [1245000, 987000, 876000, 754000, 632000, 598000], "number")
viewersCol = Col("Unique Viewers", [892000, 712000, 645000, 589000, 512000, 478000], "number")
completionCol = Col("Completion %", [68, 72, 79, 85, 64, 58], "number")
watchTimeTrend = Card([watchTimeHeading, watchTimeChart], "card", "column", "m")
watchTimeHeading = Heading("Watch Time — Past 30 Days", "h3")
watchTimeChart = AreaChart(watchTimeLabels, [watchTimeSeries], "natural", "Date", "Hours (M)")
watchTimeLabels = ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7", "Day 8", "Day 9", "Day 10", "Day 11", "Day 12", "Day 13", "Day 14", "Day 15", "Day 16", "Day 17", "Day 18", "Day 19", "Day 20", "Day 21", "Day 22", "Day 23", "Day 24", "Day 25", "Day 26", "Day 27", "Day 28", "Day 29", "Day 30"]
watchTimeSeries = Series("Total Hours", [4.2, 4.5, 4.1, 4.8, 5.2, 5.8, 6.1, 4.3, 4.6, 4.4, 4.9, 5.3, 5.7, 6.2, 6.5, 4.7, 4.8, 4.5, 5.0, 5.4, 5.9, 6.3, 6.6, 4.9, 5.1, 4.8, 5.2, 5.6, 6.0, 6.4, 6.7])
subChurn = Card([subChurnHeading, subChurnChart], "card", "column", "m")
subChurnHeading = Heading("New Subscribers vs Cancellations", "h3")
subChurnChart = BarChart(subChurnLabels, [newSubSeries, churnSeries], "grouped", "Week", "Count")
subChurnLabels = ["W1", "W2", "W3", "W4"]
newSubSeries = Series("New Subscribers", [12400, 13200, 11800, 14100])
churnSeries = Series("Cancellations", [3200, 2900, 3500, 2800])
genrePerformance = Card([genreHeading, genreChart], "card", "column", "m")
genreHeading = Heading("Performance by Genre", "h3")
genreChart = HorizontalBarChart(genreLabels, [genreHoursSeries, genreCompletionSeries], "grouped", "Hours (M)", "Genre")
genreLabels = ["Drama", "Comedy", "Action", "Sci-Fi", "Documentary", "Horror", "Animation", "Thriller"]
genreHoursSeries = Series("Hours Watched (M)", [12.4, 8.7, 15.2, 9.3, 4.1, 3.8, 6.5, 7.2])
genreCompletionSeries = Series("Completion Rate %", [72, 68, 78, 75, 82, 65, 85, 70])
bufferingRate = Card([bufferHeading, bufferMetric, bufferTrend], "card", "column", "m")
bufferHeading = Heading("Buffering Rate", "h3")
bufferMetric = TextContent("0.87%", "large-heavy")
bufferTrend = TextContent("Down 0.12pp vs last week • Target: <1%", "small")
deliveryHealth = Card([deliveryHeading, deliveryTable], "card", "column", "m")
deliveryHeading = Heading("Delivery Health by Region", "h3")
deliveryTable = Table([regionCol, latencyCol, errorCol, cdnCol, statusCol])
regionCol = Col("Region", ["North America", "Europe", "APAC", "LATAM", "MEA"])
latencyCol = Col("Avg Latency (ms)", [42, 58, 89, 112, 145], "number")
errorCol = Col("Error Rate %", [0.12, 0.18, 0.31, 0.42, 0.58], "number")
cdnCol = Col("CDN Utilization %", [68, 72, 79, 85, 71], "number")
statusCol = Col("Status", ["Healthy", "Healthy", "Degraded", "Degraded", "Warning"])
upcomingReleases = Card([releasesHeading, releasesList], "card", "column", "m")
releasesHeading = Heading("Releases Coming This Month", "h3")
releasesList = ListBlock([release1, release2, release3, release4, release5], "number")
release1 = ListItem("The Crown — Season 6, Part 2", "Dec 14 • Drama • 6 episodes", null, "View details")
release2 = ListItem("Rebel Moon — Director's Cut", "Dec 19 • Sci-Fi • Film", null, "View details")
release3 = ListItem("Squid Game: The Challenge", "Dec 22 • Reality • 10 episodes", null, "View details")
release4 = ListItem("Maestro", "Dec 25 • Biopic • Film", null, "View details")
release5 = ListItem("Berlin — Money Heist Spinoff", "Dec 29 • Thriller • 8 episodes", null, "View details")
expiringLicenses = Card([expiringHeading, expiringTable], "card", "column", "m")
expiringHeading = Heading("Licenses Expiring Soon (Next 30 Days)", "h3")
expiringTable = Table([expTitleCol, expDateCol, expRegionCol, expActionCol])
expTitleCol = Col("Title", ["Friends", "The Office US", "Parks & Rec", "Harry Potter Films", "Marvel Phase 1-3"])
expDateCol = Col("Expiry Date", ["Dec 31", "Jan 15", "Jan 22", "Jan 28", "Feb 5"])
expRegionCol = Col("Region", ["Global", "US/CA", "Global", "EMEA", "Global"])
expActionCol = Col("Action", ["Renewing", "In negotiation", "Renewing", "Evaluating", "In negotiation"])
recCTR = Card([recHeading, recMetric, recDetail], "card", "row", "l", "center", "between")
recHeading = Heading("Recommendation Click-Through Rate", "h3")
recMetric = TextContent("4.2%", "large-heavy")
recDetail = TextContent("Up 0.3pp WoW • 1.8M clicks / 42.8M impressions", "small")
searchNoPlay = Card([searchHeading, searchMetric, searchDetail], "card", "row", "l", "center", "between")
searchHeading = Heading("Searches Without Playback", "h3")
searchMetric = TextContent("18.7%", "large-heavy")
searchDetail = TextContent("12.4M searches • Top gaps: 'Oppenheimer', 'Dune 2', 'Avatar 3'", "small")
revenueByPlan = Card([revHeading, revChart], "card", "column", "m")
revHeading = Heading("Revenue Split by Plan", "h3")
revChart = PieChart(revLabels, revValues, "donut")
revLabels = ["Premium 4K", "Standard HD", "Basic SD", "Mobile Only", "Annual"]
revValues = [42.3, 28.7, 15.2, 8.4, 5.4]
deviceSplit = Card([deviceHeading, deviceChart], "card", "column", "m")
deviceHeading = Heading("Viewing Split by Device", "h3")
deviceChart = PieChart(deviceLabels, deviceValues, "donut")
deviceLabels = ["Smart TV", "Mobile", "Desktop", "Tablet", "Game Console", "Streaming Stick"]
deviceValues = [38.5, 24.2, 18.7, 9.8, 5.4, 3.4]
regionFocus = Card([regionFocusHeading, regionSelect], "card", "column", "m")
regionFocusHeading = Heading("Focus Region", "h3")
regionSelect = Select("focus_region", [regionNA, regionEU, regionAPAC, regionLATAM, regionMEA], "Select a region to filter views")
regionNA = SelectItem("na", "North America")
regionEU = SelectItem("eu", "Europe")
regionAPAC = SelectItem("apac", "APAC")
regionLATAM = SelectItem("latam", "LATAM")
regionMEA = SelectItem("mea", "MEA")
featureFlags = Card([flagsHeading, flagsTable], "card", "column", "m")
flagsHeading = Heading("Feature Flags", "h3")
flagsTable = Table([flagNameCol, flagDescCol, flagEnvCol, flagStateCol])
flagNameCol = Col("Flag", ["new_home_ranking", "shuffle_play", "download_quality_auto", "live_chat", "ai_recs_v2", "kids_profile_pin"])
flagDescCol = Col("Description", ["ML-based home ranking", "Shuffle episodes in series", "Auto-adjust download quality", "Live chat during premieres", "Next-gen recommendation model", "PIN protection for kids profiles"])
flagEnvCol = Col("Environment", ["Production", "Staging", "Production", "Canary", "Staging", "Production"])
flagStateCol = Col("State", ["ON", "ON", "OFF", "OFF", "ON", "ON"])
promoteTitle = Card([promoteHeading, promoteForm], "card", "column", "m")
promoteHeading = Heading("Promote Title on Home Screen", "h3")
promoteForm = Form("promote-title", promoteButtons, [promoteTitleField, promotePositionField, promoteDurationField, promoteRegionField])
promoteTitleField = FormControl("Title", promoteTitleSelect, "Search and select a title to promote")
promoteTitleSelect = Select("promote_title", [promoteOpt1, promoteOpt2, promoteOpt3, promoteOpt4, promoteOpt5], "Choose a title")
promoteOpt1 = SelectItem("crown-s6", "The Crown — Season 6")
promoteOpt2 = SelectItem("stranger-s4", "Stranger Things — Season 4")
promoteOpt3 = SelectItem("wednesday-s1", "Wednesday — Season 1")
promoteOpt4 = SelectItem("squid-s1", "Squid Game — Season 1")
promoteOpt5 = SelectItem("bridgerton-s2", "Bridgerton — Season 2")
promotePositionField = FormControl("Position", promotePositionSelect, "Where on the home screen")
promotePositionSelect = Select("promote_position", [posHero, posRow1, posRow2, posContinue, posTrending], "Select position")
posHero = SelectItem("hero", "Hero Banner (Top)")
posRow1 = SelectItem("row1", "Row 1 — Continue Watching")
posRow2 = SelectItem("row2", "Row 2 — Trending Now")
posContinue = SelectItem("continue", "Continue Watching Rail")
posTrending = SelectItem("trending", "Trending Now Rail")
promoteDurationField = FormControl("Duration (days)", promoteDurationInput, "How long to keep the promotion active")
promoteDurationInput = Input("promote_duration", "7", "number", null, "7")
promoteRegionField = FormControl("Region", promoteRegionSelect, "Limit promotion to specific region (optional)")
promoteRegionSelect = Select("promote_region", [promoteRegionAll, promoteRegionNA, promoteRegionEU, promoteRegionAPAC, promoteRegionLATAM, promoteRegionMEA], "All regions")
promoteRegionAll = SelectItem("all", "All Regions")
promoteRegionNA = SelectItem("na", "North America")
promoteRegionEU = SelectItem("eu", "Europe")
promoteRegionAPAC = SelectItem("apac", "APAC")
promoteRegionLATAM = SelectItem("latam", "LATAM")
promoteRegionMEA = SelectItem("mea", "MEA")
promoteButtons = Buttons([promoteSubmitBtn, promoteCancelBtn])
promoteSubmitBtn = Button("Promote Title", null, "primary")
promoteCancelBtn = Button("Cancel", null, "tertiary")