{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "payroll-run-summary",
  "title": "Payroll Run Summary",
  "description": "A payroll run review screen: status steps from draft to scheduled, counting totals for gross, net, taxes and deductions with a split bar and change vs last month, departments that expand to employees with prorations and commissions flagged, pre-run checks you resolve in place, and an approve → confirm → processing → scheduled flow.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/payroll-run-summary/payroll-run-summary.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\ninterface Employee {\n  name: string;\n  role: string;\n  gross: number;\n  note?: string;\n}\ninterface Department {\n  id: string;\n  name: string;\n  employees: Employee[];\n}\ninterface Issue {\n  id: string;\n  level: \"warn\" | \"error\";\n  title: string;\n  detail: string;\n  action: string;\n}\n\nexport interface PayrollRunSummaryProps {\n  period?: string;\n  payDate?: string;\n  daysUntilPay?: number;\n  departments?: Department[];\n  lastRunGross?: number;\n  taxRate?: number;\n  deductionRate?: number;\n  issues?: Issue[];\n  currency?: string;\n  /** Return a Promise; the run shows Processing until it resolves. */\n  onApprove?: () => void | Promise<void>;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.62)\", faint: \"rgba(245,244,241,0.36)\", card: \"#121212\", well: \"rgba(255,255,255,0.035)\", hover: \"rgba(255,255,255,0.03)\", border: \"rgba(255,255,255,0.08)\", track: \"rgba(255,255,255,0.08)\", on: \"#F5F4F1\", onText: \"#0A0A0A\", green: \"#4ADE80\", amber: \"#FBBF24\", red: \"#F87171\", net: \"#4ADE80\", tax: \"#60A5FA\", ded: \"#A78BFA\", ring: \"rgba(245,244,241,0.6)\" },\n  light: { bg: \"#FAFAF8\", text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.62)\", faint: \"rgba(10,10,10,0.4)\", card: \"#FFFFFF\", well: \"rgba(10,10,10,0.03)\", hover: \"rgba(10,10,10,0.025)\", border: \"rgba(10,10,10,0.09)\", track: \"rgba(10,10,10,0.08)\", on: \"#0A0A0A\", onText: \"#FAFAF8\", green: \"#15803D\", amber: \"#B45309\", red: \"#DC2626\", net: \"#16A34A\", tax: \"#2563EB\", ded: \"#7C3AED\", ring: \"rgba(10,10,10,0.5)\" },\n};\nconst E = (name: string, role: string, gross: number, note?: string): Employee => ({ name, role, gross, note });\nconst DEPARTMENTS: Department[] = [\n  { id: \"eng\", name: \"Engineering\", employees: [E(\"Jonas Berg\", \"VP Engineering\", 14200), E(\"Daniel Sato\", \"Engineering Lead\", 11800), E(\"Priya Nair\", \"Solutions Architect\", 10400), E(\"Sven Lund\", \"Backend Engineer\", 8600), E(\"Vera Novak\", \"Frontend Engineer\", 4100, \"On leave · 50%\"), E(\"Grace Liu\", \"Data Scientist\", 9200)] },\n  { id: \"design\", name: \"Design\", employees: [E(\"Amara Okafor\", \"Head of Design\", 10900), E(\"Keiko Tanaka\", \"Brand Designer\", 7300), E(\"Elif Demir\", \"Product Designer\", 2400, \"New hire · prorated 4 days\")] },\n  { id: \"sales\", name: \"Sales\", employees: [E(\"Hugo Bernard\", \"Sales Director\", 11200, \"Incl. Q3 commission €2,400\"), E(\"Ben Castillo\", \"Account Executive\", 6800), E(\"Umar Haddad\", \"Account Executive\", 6500)] },\n  { id: \"ops\", name: \"Operations\", employees: [E(\"Felix Wagner\", \"Finance Manager\", 9100), E(\"Lucas Rossi\", \"Ops Manager\", 7600), E(\"Olivia Brooks\", \"Legal Counsel\", 9800), E(\"Yara Costa\", \"Office Manager\", 4900)] },\n  { id: \"people\", name: \"People & Support\", employees: [E(\"Ruth Adeyemi\", \"Head of People\", 9600), E(\"Isla Murphy\", \"CS Lead\", 7400), E(\"Noah Fischer\", \"Recruiter\", 5900), E(\"Quentin Dubois\", \"Support Engineer\", 1600, \"New hire · prorated 3 days\")] },\n];\nconst ISSUES: Issue[] = [\n  { id: \"bank\", level: \"error\", title: \"Missing bank details\", detail: \"Quentin Dubois has no IBAN on file\", action: \"Request details\" },\n  { id: \"tax\", level: \"warn\", title: \"Tax class not confirmed\", detail: \"Elif Demir started Oct 28\", action: \"Mark as confirmed\" },\n];\nconst STEPS = [\"Draft\", \"Review\", \"Approved\", \"Scheduled\"];\n\nfunction Money({ value, currency, reduce }: { value: number; currency: string; reduce: boolean }) {\n  const mv = useMotionValue(reduce ? value : 0);\n  const text = useTransform(mv, (v) => `${currency}${Math.round(v).toLocaleString(\"en-US\")}`);\n  React.useEffect(() => {\n    if (reduce) {\n      mv.set(value);\n      return;\n    }\n    const c = animate(mv, value, { duration: 0.9, ease: [0.22, 1, 0.36, 1] });\n    return () => c.stop();\n  }, [value, reduce, mv]);\n  return <motion.span>{text}</motion.span>;\n}\n\nexport function PayrollRunSummary({ period = \"November 2026\", payDate = \"Nov 27\", daysUntilPay = 4, departments = DEPARTMENTS, lastRunGross = 153000, taxRate = 0.24, deductionRate = 0.09, issues: initialIssues = ISSUES, currency = \"€\", onApprove, theme = \"dark\", className }: PayrollRunSummaryProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const [open, setOpen] = React.useState<string | null>(\"design\");\n  const [issues, setIssues] = React.useState(initialIssues);\n  const [fixing, setFixing] = React.useState<string | null>(null);\n  const [step, setStep] = React.useState(1);\n  const [confirm, setConfirm] = React.useState(false);\n  const [progress, setProgress] = React.useState<number | null>(null);\n  const timers = React.useRef<ReturnType<typeof setTimeout>[]>([]);\n  const focusOnce = React.useCallback((el: HTMLButtonElement | null) => el?.focus({ preventScroll: true }), []);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach(clearTimeout);\n  }, []);\n\n  const fmt = (n: number) => `${currency}${Math.round(n).toLocaleString(\"en-US\")}`;\n  const headcount = departments.reduce((a, d) => a + d.employees.length, 0);\n  const gross = departments.reduce((a, d) => a + d.employees.reduce((b, e) => b + e.gross, 0), 0);\n  const tax = gross * taxRate;\n  const ded = gross * deductionRate;\n  const net = gross - tax - ded;\n  const delta = (gross - lastRunGross) / lastRunGross;\n  const maxDept = Math.max(...departments.map((d) => d.employees.reduce((b, e) => b + e.gross, 0)));\n  const blocking = issues.some((i) => i.level === \"error\");\n\n  const fix = (id: string) => {\n    setFixing(id);\n    timers.current.push(\n      setTimeout(\n        () => {\n          setIssues((l) => l.filter((i) => i.id !== id));\n          setFixing(null);\n        },\n        reduce ? 0 : 700,\n      ),\n    );\n  };\n  const approve = async () => {\n    setConfirm(false);\n    setStep(2);\n    setProgress(0);\n    const n = reduce ? 1 : 12;\n    const run = onApprove ? Promise.resolve(onApprove()) : Promise.resolve();\n    for (let i = 1; i <= n; i++) timers.current.push(setTimeout(() => setProgress(i / n), i * 110));\n    await Promise.all([run, new Promise((r) => timers.current.push(setTimeout(r, n * 110 + 150)))]);\n    setProgress(null);\n    setStep(3);\n  };\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const split = [\n    { k: \"Net pay\", v: net, c: p.net },\n    { k: \"Taxes\", v: tax, c: p.tax },\n    { k: \"Deductions\", v: ded, c: p.ded },\n  ];\n\n  return (\n    <section className={cn(\"@container w-full\", className)} style={{ background: p.bg, color: p.text }}>\n      <div className=\"mx-auto max-w-5xl px-4 py-10 @[640px]:px-6\">\n        {/* Header */}\n        <div className=\"flex flex-wrap items-start justify-between gap-4\">\n          <div>\n            <p className=\"m-0 text-[12px] font-medium tracking-[0.06em] uppercase\" style={{ color: p.faint }}>\n              Payroll run\n            </p>\n            <h2 className=\"m-0 mt-1 text-[22px] font-semibold tracking-[-0.01em]\">{period}</h2>\n            <p className=\"m-0 mt-1 text-[13px]\" style={{ color: p.muted }}>\n              {headcount} employees · pays {payDate}\n              {step < 3 && <span style={{ color: daysUntilPay <= 3 ? p.amber : p.muted }}> · approve within {daysUntilPay} days</span>}\n            </p>\n          </div>\n          <ol className=\"m-0 flex list-none items-center gap-1 p-0\" aria-label=\"Run status\">\n            {STEPS.map((s, i) => (\n              <li key={s} className=\"flex items-center gap-1\" aria-current={i === step ? \"step\" : undefined}>\n                <span className=\"flex items-center gap-1.5 rounded-full px-2.5 py-1 text-[11.5px] font-medium transition-colors\" style={{ background: i < step ? `${p.green}1A` : i === step ? p.on : p.well, color: i < step ? p.green : i === step ? p.onText : p.faint }}>\n                  {i < step ? \"✓\" : null}\n                  {s}\n                </span>\n                {i < STEPS.length - 1 && <span className=\"h-px w-3\" style={{ background: i < step ? p.green : p.border }} />}\n              </li>\n            ))}\n          </ol>\n        </div>\n\n        {/* Totals */}\n        <div className=\"mt-5 rounded-2xl border p-5\" style={{ background: p.card, borderColor: p.border }}>\n          <div className=\"grid grid-cols-2 gap-4 @[640px]:grid-cols-4\">\n            <div>\n              <p className=\"m-0 text-[12px]\" style={{ color: p.muted }}>\n                Gross pay\n              </p>\n              <p className=\"m-0 mt-1 text-[24px] font-semibold tracking-[-0.02em] tabular-nums\">\n                <Money value={gross} currency={currency} reduce={reduce} />\n              </p>\n              <p className=\"m-0 mt-0.5 text-[12px] tabular-nums\" style={{ color: delta >= 0 ? p.amber : p.green }}>\n                {delta >= 0 ? \"▲\" : \"▼\"} {(Math.abs(delta) * 100).toFixed(1)}% vs October\n              </p>\n            </div>\n            {split.map((s) => (\n              <div key={s.k}>\n                <p className=\"m-0 flex items-center gap-1.5 text-[12px]\" style={{ color: p.muted }}>\n                  <span className=\"h-2 w-2 rounded-sm\" style={{ background: s.c }} />\n                  {s.k}\n                </p>\n                <p className=\"m-0 mt-1 text-[20px] font-semibold tracking-[-0.02em] tabular-nums\">\n                  <Money value={s.v} currency={currency} reduce={reduce} />\n                </p>\n                <p className=\"m-0 mt-0.5 text-[12px] tabular-nums\" style={{ color: p.faint }}>\n                  {Math.round((s.v / gross) * 100)}% of gross\n                </p>\n              </div>\n            ))}\n          </div>\n          <div className=\"mt-4 flex h-2.5 gap-0.5 overflow-hidden rounded-full\" role=\"img\" aria-label={`Net ${fmt(net)}, taxes ${fmt(tax)}, deductions ${fmt(ded)}`}>\n            {split.map((s, i) => (\n              <motion.span key={s.k} className=\"h-full first:rounded-l-full last:rounded-r-full\" style={{ background: s.c }} initial={reduce ? false : { width: 0 }} animate={{ width: `${(s.v / gross) * 100}%` }} transition={{ duration: 0.8, delay: reduce ? 0 : 0.2 + i * 0.1, ease: [0.22, 1, 0.36, 1] }} />\n            ))}\n          </div>\n        </div>\n\n        <div className=\"mt-4 grid grid-cols-1 gap-4 @[800px]:grid-cols-[minmax(0,1fr)_320px]\">\n          {/* Departments */}\n          <div className=\"rounded-2xl border\" style={{ background: p.card, borderColor: p.border }}>\n            <div className=\"flex items-baseline justify-between px-5 pt-4 pb-2\">\n              <h3 className=\"m-0 text-[14px] font-semibold\">By department</h3>\n              <span className=\"text-[12px]\" style={{ color: p.faint }}>\n                Gross\n              </span>\n            </div>\n            <ul className=\"m-0 list-none p-0 pb-2\">\n              {departments.map((d) => {\n                const total = d.employees.reduce((b, e) => b + e.gross, 0);\n                const isOpen = open === d.id;\n                return (\n                  <li key={d.id} className=\"border-t first:border-t-0\" style={{ borderColor: p.border }}>\n                    <button type=\"button\" onClick={() => setOpen(isOpen ? null : d.id)} aria-expanded={isOpen} className={cn(\"grid w-full cursor-pointer grid-cols-[16px_minmax(0,1fr)_auto] items-center gap-3 border-0 bg-transparent px-5 py-3 text-left\", focus)} style={{ color: p.text, ...ring }}>\n                      <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" className=\"transition-transform\" style={{ color: p.faint, transform: isOpen ? \"rotate(90deg)\" : undefined }} aria-hidden=\"true\">\n                        <path d=\"m9 6 6 6-6 6\" />\n                      </svg>\n                      <span className=\"min-w-0\">\n                        <span className=\"flex items-baseline gap-2 text-[13.5px] font-medium\">\n                          {d.name}\n                          <span className=\"text-[12px] font-normal\" style={{ color: p.faint }}>\n                            {d.employees.length}\n                          </span>\n                        </span>\n                        <span className=\"mt-1.5 block h-1 overflow-hidden rounded-full\" style={{ background: p.track }}>\n                          <motion.span className=\"block h-full rounded-full\" style={{ background: p.muted }} initial={reduce ? false : { width: 0 }} animate={{ width: `${(total / maxDept) * 100}%` }} transition={{ duration: 0.7, delay: reduce ? 0 : 0.3 }} />\n                        </span>\n                      </span>\n                      <span className=\"text-[13px] font-medium tabular-nums\">{fmt(total)}</span>\n                    </button>\n                    <AnimatePresence initial={false}>\n                      {isOpen && (\n                        <motion.ul key=\"emps\" initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.25 }} className=\"m-0 list-none overflow-hidden p-0\">\n                          {d.employees.map((e) => (\n                            <li key={e.name} className=\"flex items-center gap-3 py-2 pr-5 pl-12 text-[12.5px]\">\n                              <span className=\"min-w-0 flex-1\">\n                                <span className=\"block truncate\">{e.name}</span>\n                                <span className=\"block truncate text-[11.5px]\" style={{ color: e.note ? p.amber : p.faint }}>\n                                  {e.note ?? e.role}\n                                </span>\n                              </span>\n                              <span className=\"tabular-nums\" style={{ color: p.muted }}>\n                                {fmt(e.gross)}\n                              </span>\n                            </li>\n                          ))}\n                        </motion.ul>\n                      )}\n                    </AnimatePresence>\n                  </li>\n                );\n              })}\n            </ul>\n          </div>\n\n          {/* Checks + approve */}\n          <div className=\"flex flex-col gap-4\">\n            <div className=\"rounded-2xl border p-4\" style={{ background: p.card, borderColor: p.border }}>\n              <div className=\"flex items-center justify-between\">\n                <h3 className=\"m-0 text-[14px] font-semibold\">Pre-run checks</h3>\n                <span className=\"text-[12px] tabular-nums\" style={{ color: issues.length ? p.amber : p.green }} aria-live=\"polite\">\n                  {issues.length ? `${issues.length} to review` : \"✓ All clear\"}\n                </span>\n              </div>\n              <ul className=\"m-0 mt-3 flex list-none flex-col gap-2 p-0\">\n                <AnimatePresence initial={false}>\n                  {issues.map((i) => (\n                    <motion.li key={i.id} layout={!reduce} exit={reduce ? undefined : { opacity: 0, x: 24, height: 0, marginTop: 0 }} transition={{ duration: 0.25 }} className=\"overflow-hidden rounded-xl border p-3\" style={{ borderColor: `${i.level === \"error\" ? p.red : p.amber}44`, background: `${i.level === \"error\" ? p.red : p.amber}0D` }}>\n                      <p className=\"m-0 flex items-center gap-1.5 text-[13px] font-medium\" style={{ color: i.level === \"error\" ? p.red : p.amber }}>\n                        {i.level === \"error\" ? \"●\" : \"▲\"} {i.title}\n                      </p>\n                      <p className=\"m-0 mt-0.5 text-[12px]\" style={{ color: p.muted }}>\n                        {i.detail}\n                      </p>\n                      <button type=\"button\" onClick={() => fix(i.id)} disabled={fixing === i.id} className={cn(\"mt-2 flex h-7 cursor-pointer items-center gap-1.5 rounded-md border bg-transparent px-2.5 text-[12px] font-medium disabled:opacity-60\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                        {fixing === i.id && <motion.span className=\"h-3 w-3 rounded-full border-2 border-current border-t-transparent\" animate={reduce ? undefined : { rotate: 360 }} transition={{ repeat: Infinity, duration: 0.7, ease: \"linear\" }} aria-hidden=\"true\" />}\n                        {i.action}\n                      </button>\n                    </motion.li>\n                  ))}\n                </AnimatePresence>\n                {issues.length === 0 && (\n                  <motion.li initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} className=\"rounded-xl p-3 text-[12.5px]\" style={{ background: `${p.green}0F`, color: p.green }}>\n                    Bank details, tax classes and new hires are all set.\n                  </motion.li>\n                )}\n              </ul>\n            </div>\n\n            <div className=\"rounded-2xl border p-4\" style={{ background: p.card, borderColor: p.border }}>\n              <AnimatePresence mode=\"popLayout\" initial={false}>\n                {step === 3 ? (\n                  <motion.div key=\"paid\" role=\"status\" initial={reduce ? false : { opacity: 0, scale: 0.96 }} animate={{ opacity: 1, scale: 1 }} className=\"text-center\">\n                    <motion.span initial={reduce ? false : { scale: 0 }} animate={{ scale: 1 }} transition={{ type: \"spring\", stiffness: 400, damping: 16 }} className=\"mx-auto grid h-11 w-11 place-items-center rounded-full text-[18px]\" style={{ background: p.green, color: \"#0A0A0A\" }} aria-hidden=\"true\">\n                      ✓\n                    </motion.span>\n                    <p className=\"m-0 mt-3 text-[15px] font-semibold\">Payroll scheduled</p>\n                    <p className=\"m-0 mt-1 text-[12.5px]\" style={{ color: p.muted }}>\n                      {fmt(net)} goes out to {headcount} people on {payDate}. Payslips are emailed the same morning.\n                    </p>\n                  </motion.div>\n                ) : progress !== null ? (\n                  <motion.div key=\"prog\" initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }} aria-live=\"polite\">\n                    <p className=\"m-0 flex justify-between text-[13px] font-medium\">\n                      Processing payments\n                      <span className=\"tabular-nums\" style={{ color: p.muted }}>\n                        {Math.round(progress * headcount)} / {headcount}\n                      </span>\n                    </p>\n                    <div className=\"mt-3 h-2 overflow-hidden rounded-full\" style={{ background: p.track }}>\n                      <motion.div className=\"h-full rounded-full\" style={{ background: p.green }} animate={{ width: `${progress * 100}%` }} transition={{ duration: 0.12 }} />\n                    </div>\n                  </motion.div>\n                ) : (\n                  <motion.div key=\"approve\" initial={reduce ? false : { opacity: 0 }} animate={{ opacity: 1 }}>\n                    <div className=\"flex items-baseline justify-between text-[13px]\">\n                      <span style={{ color: p.muted }}>Total to fund</span>\n                      <span className=\"text-[16px] font-semibold tabular-nums\">{fmt(gross + gross * 0.21)}</span>\n                    </div>\n                    <p className=\"m-0 mt-0.5 text-[11.5px]\" style={{ color: p.faint }}>\n                      Gross pay plus {fmt(gross * 0.21)} employer contributions\n                    </p>\n                    {confirm ? (\n                      <div className=\"mt-3 flex gap-2\" role=\"alertdialog\" aria-label=\"Approve payroll?\">\n                        <button type=\"button\" onClick={() => setConfirm(false)} className={cn(\"h-9 flex-1 cursor-pointer rounded-lg border bg-transparent text-[13px] font-medium\", focus)} style={{ borderColor: p.border, color: p.text, ...ring }}>\n                          Cancel\n                        </button>\n                        <button type=\"button\" ref={focusOnce} onClick={approve} className={cn(\"h-9 flex-[2] cursor-pointer rounded-lg border-0 text-[13px] font-semibold\", focus)} style={{ background: p.green, color: \"#0A0A0A\", ...ring }}>\n                          Confirm & pay {payDate}\n                        </button>\n                      </div>\n                    ) : (\n                      <button type=\"button\" onClick={() => setConfirm(true)} disabled={blocking} className={cn(\"mt-3 h-9 w-full cursor-pointer rounded-lg border-0 text-[13px] font-semibold disabled:cursor-not-allowed disabled:opacity-40\", focus)} style={{ background: p.on, color: p.onText, ...ring }}>\n                        Approve payroll\n                      </button>\n                    )}\n                    {blocking && (\n                      <p className=\"m-0 mt-2 text-center text-[11.5px]\" style={{ color: p.red }}>\n                        Fix the missing bank details first\n                      </p>\n                    )}\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default PayrollRunSummary;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}