root = Card([header, overview, trends, trendsChart, programsSection, programsChart, waitlistSection, acceptance, revenue, capacity, teaching, risk, scholarship, housing, events, alumni, alumniChart, departmentFocus, semesterCompare, semesterChart, approve, message], "card", "column", "l")

header = CardHeader("University Overview", "Spring 2025 · Office of the Registrar")

overview = Card([overviewTitle, overviewKpis], "sunk")
overviewTitle = Heading("Key metrics", "h3")
overviewKpis = Table([metricName, metricValue])
metricName = Col("Metric", ["Total enrollment", "Applications", "Acceptance rate", "Tuition revenue", "Scholarship used", "Housing occupancy"])
metricValue = Col("Value", ["24,150", "18,420", "62%", "$412.6M", "$38.2M / $50M", "94%"])

trends = Card([trendsTitle, trendsChart], "sunk")
trendsTitle = Heading("Enrollment trend (5 years)", "h3")
trendsChart = LineChart(["2021", "2022", "2023", "2024", "2025"], [enrollSeries], "natural", "Year", "Students")
enrollSeries = Series("Enrollment", [21800, 22450, 23100, 23800, 24150])

programsSection = Card([programsTitle, programsChart], "sunk")
programsTitle = Heading("Applications by program", "h3")
programsChart = BarChart(["CS", "Business", "Biology", "Psychology", "Engineering"], [appSeries], "grouped", "Program", "Applications")
appSeries = Series("Applications", [4200, 3800, 3100, 2900, 2600])

waitlistSection = Card([waitlistTitle, waitlistTable], "sunk")
waitlistTitle = Heading("Waitlisted students per program", "h3")
waitlistTable = Table([waitProgram, waitCount])
waitProgram = Col("Program", ["CS", "Business", "Biology", "Psychology", "Engineering"])
waitCount = Col("Waitlisted", [340, 210, 180, 95, 150])

acceptance = Card([acceptanceTitle, acceptanceNote, acceptanceProgress], "sunk")
acceptanceTitle = Heading("Acceptance rate", "h3")
acceptanceNote = TextContent("Overall acceptance rate for Fall 2025 applicants.", "small")
acceptanceProgress = Progress(62, "62% accepted")

revenue = Card([revenueTitle, revenueChart], "sunk")
revenueTitle = Heading("Tuition revenue this year", "h3")
revenueChart = AreaChart(["Fall", "Winter", "Spring", "Summer"], [revSeries], "natural", "Term", "USD (M)")
revSeries = Series("Revenue", [118, 124, 131, 40])

capacity = Card([capacityTitle, capacityChart], "sunk")
capacityTitle = Heading("Course offering fill rate", "h3")
capacityChart = HorizontalBarChart(["Intro CS", "Calculus I", "Microeconomics", "Gen Psych", "Organic Chem"], [fillSeries], "grouped", "Fill %", "Course")
fillSeries = Series("Fill rate", [98, 92, 87, 95, 71])

teaching = Card([teachingTitle, teachingTable], "sunk")
teachingTitle = Heading("Teaching load by faculty", "h3")
teachingTable = Table([facName, facCourses, facStudents])
facName = Col("Faculty", ["Dr. Alvarez", "Dr. Chen", "Dr. Osei", "Dr. Patel", "Dr. Ruiz"])
facCourses = Col("Courses", [4, 3, 5, 3, 4])
facStudents = Col("Students", [420, 310, 510, 280, 390])

risk = Card([riskTitle, riskNote, riskList], "sunk")
riskTitle = Heading("Students at academic risk", "h3")
riskNote = TextContent("Students with GPA below 2.0 or on probation.", "small")
riskList = ListBlock([risk1, risk2, risk3, risk4], "number")
risk1 = ListItem("Emily Tran", "GPA 1.8 · Probation · CS")
risk2 = ListItem("Marcus Lee", "GPA 1.9 · Academic alert · Business")
risk3 = ListItem("Sofia Reyes", "GPA 1.7 · Probation · Biology")
risk4 = ListItem("James Wu", "GPA 2.0 · At risk · Engineering")

scholarship = Card([scholarshipTitle, scholarshipProgress], "sunk")
scholarshipTitle = Heading("Scholarship budget", "h3")
scholarshipProgress = Progress(76, "$38.2M used of $50M budget")

housing = Card([housingTitle, housingChart], "sunk")
housingTitle = Heading("Housing occupancy", "h3")
housingChart = SingleStackedBarChart(["Occupied", "Vacant"], [94, 6])

events = Card([eventsTitle, eventsList], "sunk")
eventsTitle = Heading("Campus events this month", "h3")
eventsList = ListBlock([event1, event2, event3, event4])
event1 = ListItem("Spring Career Fair", "May 12 · Student Union")
event2 = ListItem("Research Symposium", "May 18 · Science Hall")
event3 = ListItem("Alumni Networking Night", "May 22 · Alumni Center")
event4 = ListItem("Graduate Commencement", "May 30 · Main Quad")

alumni = Card([alumniTitle, alumniChart], "sunk")
alumniTitle = Heading("Alumni giving (4 years)", "h3")
alumniChart = BarChart(["2022", "2023", "2024", "2025"], [alumniSeries], "grouped", "Year", "Donors")
alumniSeries = Series("Donors", [8200, 9100, 9800, 10500])

departmentFocus = Card([deptTitle, deptSelect, deptNote], "sunk")
deptTitle = Heading("Focus on one department", "h3")
deptSelect = Form("dept-focus", deptButtons, [deptField])
deptField = FormControl("Department", deptDropdown)
deptDropdown = Select("department", [deptCS, deptBiz, deptBio, deptPsy, deptEng], "Choose a department")
deptCS = SelectItem("cs", "Computer Science")
deptBiz = SelectItem("biz", "Business")
deptBio = SelectItem("bio", "Biology")
deptPsy = SelectItem("psy", "Psychology")
deptEng = SelectItem("eng", "Engineering")
deptButtons = Buttons([deptGo])
deptGo = Button("Apply filter")
deptNote = TextContent("Selecting a department will filter the metrics above.", "small")

semesterCompare = Card([semesterTitle, semesterChart, semesterNote], "sunk")
semesterTitle = Heading("This semester vs last", "h3")
semesterChart = BarChart(["Enrollment", "Applications", "Retention", "Avg GPA"], [currentSem, lastSem], "grouped", "Metric", "Value")
currentSem = Series("Spring 2025", [24150, 18420, 88, 3.2])
lastSem = Series("Fall 2024", [23800, 17650, 86, 3.1])
semesterNote = TextContent("Retention and GPA shown as percentages and points respectively.", "small")

approve = Card([approveTitle, approveNote, approveButtons], "sunk")
approveTitle = Heading("Approve a new course", "h3")
approveNote = TextContent("Proposal: BIO 320 — Advanced Genomics · 3 credits · Instructor: Dr. Osei", "small")
approveButtons = Buttons([approveYes, approveNo])
approveYes = Button("Approve course", null, "primary")
approveNo = Button("Request changes", null, "secondary")

message = Card([messageTitle, messageForm], "sunk")
messageTitle = Heading("Message a student group", "h3")
messageForm = Form("student-message", messageButtons, [groupField, subjectField, bodyField])
groupField = FormControl("Recipient group", groupSelect)
groupSelect = Select("group", [groupCS, groupBiz, groupBio, groupPsy, groupEng], "Choose a group")
groupCS = SelectItem("cs", "CS Students")
groupBiz = SelectItem("biz", "Business Students")
groupBio = SelectItem("bio", "Biology Students")
groupPsy = SelectItem("psy", "Psychology Students")
groupEng = SelectItem("eng", "Engineering Students")
subjectField = FormControl("Subject", subjectInput)
subjectInput = Input("subject", "Event reminder")
bodyField = FormControl("Message", bodyArea)
bodyArea = TextArea("body", "Type your message here...", 4)
messageButtons = Buttons([sendBtn])
sendBtn = Button("Send message", null, "primary")