root = Card([headerRow, controls, kpiRow, visitorSection, lowerRow, emailSection, suggestions], "card", "column", "l")
headerRow = Card([header, statusTag], "clear", "row", "m", "center", "between")
header = CardHeader("Marketing Dashboard", "Weekly overview · Oct 2 – Oct 8, 2025")
statusTag = Tag("On track", null, null, "success")
controls = Card([dateForm, exportButtons], "clear", "row", "l", "center", "between")
dateForm = Form("date_range", applyButtons, [rangeField])
rangeField = FormControl("Date range", rangeSelect)
rangeSelect = Select("range", [range7, range14, range30, range90], "Choose a range", null, "30")
range7 = SelectItem("7", "Last 7 days")
range14 = SelectItem("14", "Last 14 days")
range30 = SelectItem("30", "Last 30 days")
range90 = SelectItem("90", "Last 90 days")
applyButtons = Buttons([applyBtn])
applyBtn = Button("Apply", null, "secondary")
exportButtons = Buttons([exportBtn, shareBtn])
exportBtn = Button("Export report", null, "primary")
shareBtn = Button("Share", null, "secondary")
kpiRow = Card([visitorKpi, conversionKpi], "sunk", "row", "l")
visitorKpi = Card([visitorLabel, visitorValue, visitorDelta], "clear")
visitorLabel = TextContent("Site visitors — last 30 days", "small")
visitorValue = TextContent("84,210", "large-heavy")
visitorDelta = TextContent("+12.4% vs previous period", "small")
conversionKpi = Card([conversionLabel, conversionValue, conversionDelta], "clear")
conversionLabel = TextContent("Conversion rate", "small")
conversionValue = TextContent("3.2%", "large-heavy")
conversionDelta = TextContent("+0.4 pts vs previous period", "small")
visitorSection = Card([visitorHeading, visitorsChart], "sunk")
visitorHeading = Heading("Site visitors — last 30 days", "h2")
visitorsChart = AreaChart(visitorLabels, [visitorSeries], "natural", "Date", "Visitors")
visitorLabels = ["Sep 9", "Sep 12", "Sep 15", "Sep 18", "Sep 21", "Sep 24", "Sep 27", "Sep 30", "Oct 3", "Oct 6"]
visitorSeries = Series("Visitors", [2100, 2400, 2650, 2900, 3100, 2850, 3220, 3480, 3420, 3710])
lowerRow = Card([sourcesCard, campaignsCard], "clear", "row", "l")
sourcesCard = Card([sourcesHeading, sourcesChart, sourcesTable], "sunk")
sourcesHeading = Heading("Top traffic sources", "h2")
sourcesChart = HorizontalBarChart(sourceLabels, [sourceSeries], "grouped", "Share", "% of sessions")
sourceLabels = ["Organic search", "Direct", "Paid social", "Email", "Referral"]
sourceSeries = Series("Share", [37, 25, 20, 11, 6])
sourcesTable = Table([sourceCol, sessionsCol, shareCol])
sourceCol = Col("Source", ["Organic search", "Direct", "Paid social", "Email", "Referral"])
sessionsCol = Col("Sessions", [31200, 21400, 16800, 9600, 5200])
shareCol = Col("Share", ["37%", "25%", "20%", "11%", "6%"])
campaignsCard = Card([campaignsHeading, bestCallout, campaignsTable], "sunk")
campaignsHeading = Heading("Running campaigns", "h2")
bestCallout = Callout("success", "Best performing campaign", "Summer Launch is leading with $18,400 spend and 4.8× ROAS — 2.3× higher return than the next best campaign.")
campaignsTable = Table([campaignCol, channelCol, spendCol, statusCol])
campaignCol = Col("Campaign", ["Summer Launch", "Spring Sale", "Retargeting", "Newsletter Boost", "Brand Awareness"])
channelCol = Col("Channel", ["Paid Social", "Search", "Display", "Email", "Video"])
spendCol = Col("Spend", ["$18,400", "$12,100", "$9,800", "$6,500", "$4,200"])
statusCol = Col("Status", ["Active", "Active", "Paused", "Active", "Active"])
emailSection = Card([emailHeading, emailStat, emailChart], "sunk")
emailHeading = Heading("Email subscriber growth — this month", "h2")
emailStat = TextContent("13,180 total · +780 new this month (+6.3%)", "small")
emailChart = AreaChart(emailLabels, [emailSeries], "natural", "Day", "Total subscribers")
emailLabels = ["Oct 1", "Oct 2", "Oct 3", "Oct 4", "Oct 5", "Oct 6", "Oct 7", "Oct 8"]
emailSeries = Series("Subscribers", [12400, 12510, 12630, 12705, 12820, 12910, 13045, 13180])
suggestions = FollowUpBlock([f1, f2, f3])
f1 = FollowUpItem("Compare conversion rate by traffic source")
f2 = FollowUpItem("Show campaign ROAS breakdown")
f3 = FollowUpItem("Export last quarter's report")