{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "admin-users",
  "type": "registry:block",
  "title": "Admin Users",
  "description": "A members admin with seat and 2FA stats, role and status filters, a sortable table you can bulk-edit, an invite dialog that checks emails as chips, and a drawer with each person's devices and activity.",
  "categories": [
    "screen",
    "Product"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/avatar.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/checkbox.json",
    "https://coss.com/ui/r/input-group.json",
    "https://coss.com/ui/r/menu.json",
    "https://coss.com/ui/r/table.json"
  ],
  "files": [
    {
      "path": "registry/devl/admin-users.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport {\n  ArrowDownIcon,\n  ArrowUpIcon,\n  BuildingIcon,\n  CheckIcon,\n  ChevronDownIcon,\n  CreditCardIcon,\n  EllipsisIcon,\n  FilterIcon,\n  KeyRoundIcon,\n  LaptopIcon,\n  LogInIcon,\n  MailIcon,\n  MenuIcon,\n  ScrollTextIcon,\n  SearchIcon,\n  SendIcon,\n  ShieldAlertIcon,\n  ShieldCheckIcon,\n  ShieldIcon,\n  SmartphoneIcon,\n  UserCogIcon,\n  UserMinusIcon,\n  UserPlusIcon,\n  UserRoundCheckIcon,\n  UserRoundXIcon,\n  UsersIcon,\n  XIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { type MouseEvent, type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Button } from \"@/components/ui/button\";\nimport { Checkbox } from \"@/components/ui/checkbox\";\nimport { InputGroup, InputGroupAddon, InputGroupInput } from \"@/components/ui/input-group\";\nimport {\n  Menu,\n  MenuCheckboxItem,\n  MenuGroup,\n  MenuGroupLabel,\n  MenuItem,\n  MenuPopup,\n  MenuRadioGroup,\n  MenuRadioItem,\n  MenuSeparator,\n  MenuTrigger,\n} from \"@/components/ui/menu\";\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from \"@/components/ui/table\";\n\nfunction useReducedMotionAfterMount() {\n  const prefers = useReducedMotion();\n  const [mounted, setMounted] = useState(false);\n  useEffect(() => setMounted(true), []);\n  return mounted && Boolean(prefers);\n}\n\nexport type AdminRole = \"owner\" | \"admin\" | \"member\" | \"viewer\" | \"billing\";\nexport type AdminStatus = \"active\" | \"invited\" | \"suspended\";\n\nexport interface AdminActivity {\n  kind: \"signin\" | \"role\" | \"key\" | \"join\" | \"invite\" | \"suspend\" | \"2fa\";\n  text: string;\n  when: string;\n}\n\nexport interface AdminUser {\n  id: string;\n  name: string;\n  email: string;\n  role: AdminRole;\n  status: AdminStatus;\n  twoFactor: boolean;\n  teams: string[];\n  minutesSinceActive: number | null;\n  joined: string;\n  location?: string;\n  activity?: AdminActivity[];\n}\n\nexport interface AdminUsersProps {\n  className?: string;\n  orgName?: string;\n  seats?: number;\n  users?: AdminUser[];\n  currentUserId?: string;\n}\n\nconst spring = { type: \"spring\", stiffness: 520, damping: 46, mass: 1 } as const;\nconst easeOut = [0.23, 1, 0.32, 1] as const;\nconst press = \"transition-[color,background-color,box-shadow,scale] duration-150 ease-out active:scale-[0.97]\";\nconst ring = \"outline-none focus-visible:ring-2 focus-visible:ring-ring\";\nconst hit = \"relative after:absolute after:-inset-3 after:content-['']\";\nconst menuPop =\n  \"transition-[opacity,scale] duration-150 ease-[cubic-bezier(0.23,1,0.32,1)] data-starting-style:scale-95 data-starting-style:opacity-0 data-ending-style:scale-95 data-ending-style:opacity-0 data-ending-style:duration-100\";\nconst barSurface =\n  \"rounded-full bg-primary text-primary-foreground shadow-lg/15 dark:border dark:bg-popover dark:text-popover-foreground dark:shadow-lg/40\";\nconst barButton = cn(\n  \"flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-full px-3 outline-none hover:bg-primary-foreground/12 focus-visible:ring-2 focus-visible:ring-primary-foreground/40 data-popup-open:bg-primary-foreground/12 dark:data-popup-open:bg-accent dark:focus-visible:ring-ring dark:hover:bg-accent\",\n  press,\n);\n\nexport const adminRoles: { value: AdminRole; label: string; description: string; pill: string }[] = [\n  { value: \"owner\", label: \"Owner\", description: \"Full control, including billing and deleting the org.\", pill: \"bg-violet-500/10 text-violet-700 dark:bg-violet-400/16 dark:text-violet-300\" },\n  { value: \"admin\", label: \"Admin\", description: \"Manage members, settings and integrations.\", pill: \"bg-sky-500/10 text-sky-700 dark:bg-sky-400/16 dark:text-sky-300\" },\n  { value: \"member\", label: \"Member\", description: \"Create and edit projects they're added to.\", pill: \"bg-muted text-foreground/80\" },\n  { value: \"viewer\", label: \"Viewer\", description: \"Read-only access. Free, doesn't use a seat.\", pill: \"bg-transparent text-muted-foreground ring-1 ring-border ring-inset\" },\n  { value: \"billing\", label: \"Billing\", description: \"Invoices and payment methods only.\", pill: \"bg-amber-500/12 text-amber-800 dark:bg-amber-400/16 dark:text-amber-300\" },\n];\n\nconst statusMeta: Record<AdminStatus, { label: string; dot: string; text: string }> = {\n  active: { label: \"Active\", dot: \"bg-success\", text: \"text-foreground\" },\n  invited: { label: \"Invited\", dot: \"bg-info\", text: \"text-info-foreground\" },\n  suspended: { label: \"Suspended\", dot: \"bg-destructive\", text: \"text-destructive-foreground\" },\n};\n\nconst avatarTones = [\n  \"bg-orange-500/16 text-orange-800 dark:bg-orange-400/18 dark:text-orange-200\",\n  \"bg-teal-500/16 text-teal-800 dark:bg-teal-400/18 dark:text-teal-200\",\n  \"bg-violet-500/16 text-violet-800 dark:bg-violet-400/18 dark:text-violet-200\",\n  \"bg-sky-500/16 text-sky-800 dark:bg-sky-400/18 dark:text-sky-200\",\n  \"bg-rose-500/16 text-rose-800 dark:bg-rose-400/18 dark:text-rose-200\",\n  \"bg-amber-500/20 text-amber-900 dark:bg-amber-400/18 dark:text-amber-200\",\n  \"bg-emerald-500/16 text-emerald-800 dark:bg-emerald-400/18 dark:text-emerald-200\",\n];\n\nconst defaultUsers: AdminUser[] = [\n  {\n    id: \"u1\",\n    name: \"Maya Lindgren\",\n    email: \"maya@larkfield.studio\",\n    role: \"owner\",\n    status: \"active\",\n    twoFactor: true,\n    teams: [\"Leadership\", \"Design\"],\n    minutesSinceActive: 3,\n    joined: \"Mar 2, 2024\",\n    location: \"Stockholm, SE\",\n  },\n  {\n    id: \"u2\",\n    name: \"Owen Adeyemi\",\n    email: \"owen@larkfield.studio\",\n    role: \"admin\",\n    status: \"active\",\n    twoFactor: true,\n    teams: [\"Engineering\", \"Platform\"],\n    minutesSinceActive: 42,\n    joined: \"Mar 9, 2024\",\n    location: \"Lagos, NG\",\n    activity: [\n      { kind: \"signin\", text: \"Signed in from Lagos, NG on Chrome\", when: \"42 min ago\" },\n      { kind: \"key\", text: \"Created API key “CI deploy”\", when: \"Oct 21\" },\n      { kind: \"role\", text: \"Role changed from Member to Admin by Maya Lindgren\", when: \"Oct 2\" },\n      { kind: \"2fa\", text: \"Turned on two-factor authentication\", when: \"Mar 10, 2024\" },\n      { kind: \"join\", text: \"Joined from an invite by Maya Lindgren\", when: \"Mar 9, 2024\" },\n    ],\n  },\n  { id: \"u3\", name: \"Priya Natarajan\", email: \"priya@larkfield.studio\", role: \"admin\", status: \"active\", twoFactor: true, teams: [\"Design\"], minutesSinceActive: 180, joined: \"Apr 14, 2024\", location: \"Bengaluru, IN\" },\n  { id: \"u4\", name: \"Jonas Weber\", email: \"jonas@larkfield.studio\", role: \"member\", status: \"active\", twoFactor: false, teams: [\"Engineering\"], minutesSinceActive: 1440, joined: \"May 3, 2024\", location: \"Berlin, DE\" },\n  { id: \"u5\", name: \"Camila Reyes\", email: \"camila@larkfield.studio\", role: \"member\", status: \"active\", twoFactor: true, teams: [\"Marketing\", \"Content\", \"Events\"], minutesSinceActive: 300, joined: \"Jun 20, 2024\", location: \"Mexico City, MX\" },\n  { id: \"u6\", name: \"Theo Laurent\", email: \"theo@larkfield.studio\", role: \"billing\", status: \"active\", twoFactor: true, teams: [\"Finance\"], minutesSinceActive: 4320, joined: \"Jul 1, 2024\", location: \"Lyon, FR\" },\n  { id: \"u7\", name: \"Hana Sato\", email: \"hana@larkfield.studio\", role: \"member\", status: \"active\", twoFactor: true, teams: [\"Engineering\", \"Platform\"], minutesSinceActive: 15, joined: \"Aug 12, 2024\", location: \"Osaka, JP\" },\n  { id: \"u8\", name: \"Dev Malhotra\", email: \"dev@larkfield.studio\", role: \"member\", status: \"suspended\", twoFactor: false, teams: [\"Engineering\"], minutesSinceActive: 64800, joined: \"Sep 5, 2024\", location: \"Toronto, CA\" },\n  { id: \"u9\", name: \"Rosa Ferreira\", email: \"rosa.ferreira@gmail.com\", role: \"viewer\", status: \"active\", twoFactor: false, teams: [\"Clients\"], minutesSinceActive: 10080, joined: \"Jan 18, 2025\", location: \"Porto, PT\" },\n  { id: \"u10\", name: \"Sam Okoro\", email: \"sam@larkfield.studio\", role: \"member\", status: \"invited\", twoFactor: false, teams: [\"Design\"], minutesSinceActive: null, joined: \"Invited Oct 22\" },\n  { id: \"u11\", name: \"\", email: \"lena@northpine.co\", role: \"viewer\", status: \"invited\", twoFactor: false, teams: [], minutesSinceActive: null, joined: \"Invited Oct 15\" },\n  { id: \"u12\", name: \"Felix Brandt\", email: \"felix@larkfield.studio\", role: \"member\", status: \"active\", twoFactor: true, teams: [\"Support\"], minutesSinceActive: 95, joined: \"Feb 7, 2025\", location: \"Hamburg, DE\" },\n  { id: \"u13\", name: \"Ama Mensah\", email: \"ama@larkfield.studio\", role: \"member\", status: \"active\", twoFactor: false, teams: [\"Content\"], minutesSinceActive: 2880, joined: \"Apr 30, 2025\", location: \"Accra, GH\" },\n];\n\nfunction initials(u: AdminUser) {\n  const src = u.name || u.email;\n  return src\n    .replace(/@.*/, \"\")\n    .split(/[\\s._-]+/)\n    .filter(Boolean)\n    .map((p) => p[0])\n    .join(\"\")\n    .slice(0, 2)\n    .toUpperCase();\n}\n\nfunction hashIndex(s: string, n: number) {\n  let h = 0;\n  for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) >>> 0;\n  return h % n;\n}\n\nfunction ago(m: number | null) {\n  if (m === null) return \"Never\";\n  if (m < 5) return \"Just now\";\n  if (m < 60) return `${m} min ago`;\n  if (m < 1440) return `${Math.floor(m / 60)}h ago`;\n  if (m < 2880) return \"Yesterday\";\n  return `${Math.floor(m / 1440)}d ago`;\n}\n\nconst roleMeta = (r: AdminRole) => adminRoles.find((x) => x.value === r) ?? adminRoles[2];\n\nfunction UserAvatar({ user, size = 8 }: { user: AdminUser; size?: 7 | 8 | 14 }) {\n  const sizes = { 7: \"[--avatar-size:--spacing(7)]\", 8: \"[--avatar-size:--spacing(8)]\", 14: \"[--avatar-size:--spacing(14)]\" };\n  return (\n    <Avatar className={cn(sizes[size], user.status === \"suspended\" && \"opacity-80 grayscale\")}>\n      <AvatarFallback className={cn(\"font-semibold\", avatarTones[hashIndex(user.email, avatarTones.length)])}>{initials(user)}</AvatarFallback>\n    </Avatar>\n  );\n}\n\nfunction RolePill({ role }: { role: AdminRole }) {\n  const m = roleMeta(role);\n  const reduce = useReducedMotionAfterMount();\n  return (\n    <motion.span\n      animate={{ opacity: 1, scale: 1 }}\n      className={cn(\"inline-flex h-6 items-center rounded-full px-2.5 font-medium text-xs\", m.pill)}\n      initial={reduce ? { opacity: 0.6 } : { opacity: 0.6, scale: 0.95 }}\n      key={role}\n      transition={{ duration: 0.18, ease: easeOut }}\n    >\n      {m.label}\n    </motion.span>\n  );\n}\n\nfunction StatusTag({ user }: { user: AdminUser }) {\n  const m = statusMeta[user.status];\n  return (\n    <span className={cn(\"inline-flex items-center gap-1.5 text-xs\", m.text)}>\n      <span className={cn(\"size-1.5 rounded-full\", m.dot)} />\n      {m.label}\n    </span>\n  );\n}\n\ntype Tab = \"all\" | AdminStatus;\ntype SortKey = \"name\" | \"minutesSinceActive\";\n\nconst activityIcon: Record<AdminActivity[\"kind\"], ReactNode> = {\n  signin: <LogInIcon />,\n  role: <UserCogIcon />,\n  key: <KeyRoundIcon />,\n  join: <UserRoundCheckIcon />,\n  invite: <MailIcon />,\n  suspend: <UserRoundXIcon />,\n  \"2fa\": <ShieldCheckIcon />,\n};\n\nfunction activityFor(u: AdminUser): AdminActivity[] {\n  if (u.activity) return u.activity;\n  if (u.status === \"invited\") return [{ kind: \"invite\", text: \"Invite sent by Maya Lindgren\", when: u.joined.replace(\"Invited \", \"\") }];\n  const list: AdminActivity[] = [];\n  if (u.minutesSinceActive !== null) list.push({ kind: \"signin\", text: `Signed in from ${u.location ?? \"an unknown location\"}`, when: ago(u.minutesSinceActive) });\n  if (u.status === \"suspended\") list.push({ kind: \"suspend\", text: \"Suspended by Owen Adeyemi\", when: \"Sep 30\" });\n  if (u.twoFactor) list.push({ kind: \"2fa\", text: \"Turned on two-factor authentication\", when: u.joined });\n  list.push({ kind: \"join\", text: \"Joined from an invite by Maya Lindgren\", when: u.joined });\n  return list;\n}\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\n\nexport function AdminUsers({\n  className,\n  orgName = \"Larkfield Studio\",\n  seats = 15,\n  users: initialUsers = defaultUsers,\n  currentUserId = \"u1\",\n}: AdminUsersProps) {\n  const reduce = useReducedMotionAfterMount();\n  const [users, setUsers] = useState(initialUsers);\n  const [tab, setTab] = useState<Tab>(\"all\");\n  const [query, setQuery] = useState(\"\");\n  const [roleFilter, setRoleFilter] = useState<AdminRole[]>([]);\n  const [no2fa, setNo2fa] = useState(false);\n  const [sort, setSort] = useState<{ key: SortKey; dir: 1 | -1 }>({ key: \"name\", dir: 1 });\n  const [selected, setSelected] = useState<string[]>([]);\n  const [detailId, setDetailId] = useState<string | null>(null);\n  const [invite, setInvite] = useState(false);\n  const [confirm, setConfirm] = useState<string[] | null>(null);\n  const [toast, setToast] = useState<{ id: number; text: string } | null>(null);\n  const [nav, setNav] = useState(false);\n  const [freshIds, setFreshIds] = useState<string[]>([]);\n  const counter = useRef(0);\n  const drawerRef = useRef<HTMLDivElement>(null);\n\n  const say = (text: string) => {\n    counter.current += 1;\n    setToast({ id: counter.current, text });\n  };\n\n  useEffect(() => {\n    if (!toast) return;\n    const t = setTimeout(() => setToast(null), 3200);\n    return () => clearTimeout(t);\n  }, [toast]);\n\n  useEffect(() => {\n    if (detailId) drawerRef.current?.focus();\n  }, [detailId]);\n\n  const counts: Record<Tab, number> = {\n    all: users.length,\n    active: users.filter((u) => u.status === \"active\").length,\n    invited: users.filter((u) => u.status === \"invited\").length,\n    suspended: users.filter((u) => u.status === \"suspended\").length,\n  };\n  const seatsUsed = users.filter((u) => u.status !== \"suspended\" && u.role !== \"viewer\").length;\n  const activeUsers = users.filter((u) => u.status === \"active\");\n  const twoFaPct = activeUsers.length ? Math.round((activeUsers.filter((u) => u.twoFactor).length / activeUsers.length) * 100) : 0;\n\n  const q = query.trim().toLowerCase();\n  const rows = users\n    .filter(\n      (u) =>\n        (tab === \"all\" || u.status === tab) &&\n        (roleFilter.length === 0 || roleFilter.includes(u.role)) &&\n        (!no2fa || !u.twoFactor) &&\n        (!q || u.name.toLowerCase().includes(q) || u.email.toLowerCase().includes(q) || u.teams.some((t) => t.toLowerCase().includes(q))),\n    )\n    .sort((a, b) => {\n      if (sort.key === \"name\") return (a.name || a.email).localeCompare(b.name || b.email) * sort.dir;\n      const av = a.minutesSinceActive ?? Number.POSITIVE_INFINITY;\n      const bv = b.minutesSinceActive ?? Number.POSITIVE_INFINITY;\n      return (av - bv) * sort.dir;\n    });\n\n  const visibleIds = rows.filter((r) => r.id !== currentUserId).map((r) => r.id);\n  const selectedVisible = selected.filter((id) => visibleIds.includes(id));\n  const allChecked = visibleIds.length > 0 && selectedVisible.length === visibleIds.length;\n  const someChecked = selectedVisible.length > 0 && !allChecked;\n  const selectedInvited = users.filter((u) => selectedVisible.includes(u.id) && u.status === \"invited\");\n  const filterCount = roleFilter.length + (no2fa ? 1 : 0);\n  const detail = users.find((u) => u.id === detailId) ?? null;\n  const me = users.find((u) => u.id === currentUserId);\n\n  const updateMany = (ids: string[], patch: Partial<AdminUser>) => setUsers((all) => all.map((u) => (ids.includes(u.id) ? { ...u, ...patch } : u)));\n  const label = (u: AdminUser) => u.name || u.email;\n\n  const remove = (ids: string[]) => {\n    const n = ids.length;\n    setUsers((all) => all.filter((u) => !ids.includes(u.id)));\n    setSelected((s) => s.filter((id) => !ids.includes(id)));\n    if (detailId && ids.includes(detailId)) setDetailId(null);\n    setConfirm(null);\n    say(n === 1 ? \"Member removed. Their work stays in the projects.\" : `${n} members removed`);\n  };\n\n  const toggleSort = (key: SortKey) => setSort((s) => (s.key === key ? { key, dir: s.dir === 1 ? -1 : 1 } : { key, dir: 1 }));\n\n  const sortHeader = (key: SortKey, text: string, className?: string) => (\n    <button\n      aria-label={`Sort by ${text}`}\n      className={cn(\"-mx-1 inline-flex cursor-pointer items-center gap-1 rounded px-1 hover:text-foreground\", ring, className)}\n      onClick={() => toggleSort(key)}\n      type=\"button\"\n    >\n      {text}\n      <span className={cn(\"flex size-3.5 items-center justify-center transition-opacity\", sort.key === key ? \"opacity-100\" : \"opacity-0\")}>\n        {sort.dir === 1 ? <ArrowUpIcon className=\"size-3\" /> : <ArrowDownIcon className=\"size-3\" />}\n      </span>\n    </button>\n  );\n\n  const roleMenu = (u: AdminUser, align: \"start\" | \"end\" = \"start\") =>\n    u.role === \"owner\" || u.id === currentUserId ? (\n      <RolePill role={u.role} />\n    ) : (\n      <Menu>\n        <MenuTrigger\n          aria-label={`Role for ${label(u)}: ${roleMeta(u.role).label}`}\n          className={cn(\"group/role relative inline-flex cursor-pointer items-center gap-1 rounded-full after:absolute after:-inset-x-1 after:-inset-y-2 after:content-['']\", ring)}\n          onClick={(e) => e.stopPropagation()}\n        >\n          <RolePill role={u.role} />\n          <ChevronDownIcon className=\"size-3.5 text-muted-foreground opacity-0 transition-opacity group-hover/role:opacity-100 group-data-popup-open/role:opacity-100 pointer-coarse:opacity-100\" />\n        </MenuTrigger>\n        <MenuPopup align={align} className={cn(\"w-64\", menuPop)}>\n          <MenuRadioGroup\n            onValueChange={(v) => {\n              updateMany([u.id], { role: v as AdminRole });\n              say(`${label(u)} is now ${roleMeta(v as AdminRole).label === \"Admin\" ? \"an\" : \"a\"} ${roleMeta(v as AdminRole).label.toLowerCase()}`);\n            }}\n            value={u.role}\n          >\n            {adminRoles\n              .filter((r) => r.value !== \"owner\")\n              .map((r) => (\n                <MenuRadioItem key={r.value} value={r.value}>\n                  <span className=\"flex flex-col py-0.5\">\n                    <span className=\"font-medium\">{r.label}</span>\n                    <span className=\"text-pretty text-muted-foreground text-xs\">{r.description}</span>\n                  </span>\n                </MenuRadioItem>\n              ))}\n          </MenuRadioGroup>\n        </MenuPopup>\n      </Menu>\n    );\n\n  const rowMenu = (u: AdminUser) =>\n    u.id === currentUserId ? (\n      <span className=\"block size-8\" />\n    ) : (\n      <Menu>\n        <MenuTrigger\n          aria-label={`Actions for ${label(u)}`}\n          onClick={(e) => e.stopPropagation()}\n          render={<Button className={press} size=\"icon-sm\" variant=\"ghost\" />}\n        >\n          <EllipsisIcon />\n        </MenuTrigger>\n        <MenuPopup align=\"end\" className={cn(\"w-48\", menuPop)}>\n          <MenuItem onClick={() => setDetailId(u.id)}>\n            <UserCogIcon /> View details\n          </MenuItem>\n          {u.status === \"invited\" && (\n            <MenuItem onClick={() => say(`Invite resent to ${u.email}`)}>\n              <SendIcon /> Resend invite\n            </MenuItem>\n          )}\n          {u.status === \"active\" && u.role !== \"owner\" && (\n            <MenuItem\n              onClick={() => {\n                updateMany([u.id], { status: \"suspended\" });\n                say(`${label(u)} suspended. Sessions signed out.`);\n              }}\n            >\n              <UserRoundXIcon /> Suspend\n            </MenuItem>\n          )}\n          {u.status === \"suspended\" && (\n            <MenuItem\n              onClick={() => {\n                updateMany([u.id], { status: \"active\" });\n                say(`${label(u)} reactivated`);\n              }}\n            >\n              <UserRoundCheckIcon /> Reactivate\n            </MenuItem>\n          )}\n          {u.role !== \"owner\" && (\n            <>\n              <MenuSeparator />\n              <MenuItem onClick={() => setConfirm([u.id])} variant=\"destructive\">\n                <UserMinusIcon /> {u.status === \"invited\" ? \"Revoke invite\" : \"Remove from org\"}\n              </MenuItem>\n            </>\n          )}\n        </MenuPopup>\n      </Menu>\n    );\n\n  const teamChips = (u: AdminUser, all = false) =>\n    u.teams.length === 0 ? (\n      <span className=\"text-muted-foreground text-xs\">No teams</span>\n    ) : (\n      <span className={cn(\"flex min-w-0 items-center gap-1\", all && \"flex-wrap\")}>\n        {(all ? u.teams : u.teams.slice(0, 2)).map((t) => (\n          <span className=\"truncate rounded-md border px-1.5 py-0.5 text-muted-foreground text-xs\" key={t}>\n            {t}\n          </span>\n        ))}\n        {!all && u.teams.length > 2 && <span className=\"text-muted-foreground text-xs tabular-nums\">+{u.teams.length - 2}</span>}\n      </span>\n    );\n\n  const twoFa = (u: AdminUser) =>\n    u.status === \"invited\" ? (\n      <span className=\"text-muted-foreground text-xs\">—</span>\n    ) : u.twoFactor ? (\n      <span className=\"inline-flex items-center gap-1.5 text-xs\">\n        <ShieldCheckIcon className=\"size-3.5 text-success-foreground\" /> On\n      </span>\n    ) : (\n      <span className=\"inline-flex items-center gap-1.5 text-warning-foreground text-xs\">\n        <ShieldAlertIcon className=\"size-3.5\" /> Off\n      </span>\n    );\n\n  const rowMotion = (u: AdminUser) => ({\n    animate: { opacity: 1, y: 0 },\n    exit: reduce ? { opacity: 0, transition: { duration: 0.12 } } : { opacity: 0, x: -16, transition: { duration: 0.16, ease: easeOut } },\n    initial: reduce ? false : freshIds.includes(u.id) ? { opacity: 0, y: -6 } : false,\n    layout: reduce ? false : (\"position\" as const),\n    transition: spring,\n  });\n\n  const listKey = [tab, roleFilter.join(\",\"), no2fa, q, sort.key, sort.dir].join(\"|\");\n  const MotionRow = MotionTableRow;\n\n  const navItems = [\n    { label: \"General\", icon: <BuildingIcon /> },\n    { label: \"Members\", icon: <UsersIcon />, active: true, badge: counts.invited },\n    { label: \"Teams\", icon: <UsersIcon /> },\n    { label: \"Roles\", icon: <UserCogIcon /> },\n    { label: \"Security & SSO\", icon: <ShieldIcon /> },\n    { label: \"Audit log\", icon: <ScrollTextIcon /> },\n    { label: \"Billing\", icon: <CreditCardIcon /> },\n  ];\n\n  const sidebar = (\n    <div className=\"flex h-full flex-col gap-5 p-3\">\n      <div className=\"flex items-center gap-2.5 px-1.5 pt-1\">\n        <span className=\"flex size-8 items-center justify-center rounded-lg bg-primary font-semibold text-primary-foreground text-xs\">\n          {orgName\n            .split(\" \")\n            .map((w) => w[0])\n            .join(\"\")\n            .slice(0, 2)}\n        </span>\n        <div className=\"flex min-w-0 flex-col\">\n          <span className=\"truncate font-heading font-semibold\">{orgName}</span>\n          <span className=\"text-muted-foreground text-xs\">Organization settings</span>\n        </div>\n      </div>\n      <nav aria-label=\"Settings\" className=\"flex flex-col gap-0.5\">\n        {navItems.map((n) => (\n          <button\n            aria-current={n.active ? \"page\" : undefined}\n            className={cn(\n              \"flex h-8 cursor-pointer items-center gap-2.5 rounded-lg px-2.5 text-left [&_svg]:size-4 [&_svg]:opacity-80\",\n              ring,\n              press,\n              n.active ? \"bg-accent font-medium text-foreground\" : \"text-muted-foreground hover:bg-accent hover:text-foreground\",\n            )}\n            key={n.label}\n            type=\"button\"\n          >\n            {n.icon}\n            <span className=\"flex-1\">{n.label}</span>\n            {n.badge ? <span className=\"rounded-full bg-info/12 px-1.5 font-medium text-info-foreground text-xs tabular-nums\">{n.badge}</span> : null}\n          </button>\n        ))}\n      </nav>\n      {me && (\n        <div className=\"mt-auto flex items-center gap-2.5 rounded-xl border bg-card p-2.5\">\n          <UserAvatar size={7} user={me} />\n          <div className=\"flex min-w-0 flex-col\">\n            <span className=\"truncate font-medium text-xs\">{me.name}</span>\n            <span className=\"text-muted-foreground text-xs\">{roleMeta(me.role).label}</span>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n\n  const tabs: { value: Tab; label: string }[] = [\n    { value: \"all\", label: \"All\" },\n    { value: \"active\", label: \"Active\" },\n    { value: \"invited\", label: \"Invited\" },\n    { value: \"suspended\", label: \"Suspended\" },\n  ];\n\n  const empty = (\n    <div className=\"flex flex-col items-center gap-4 px-6 py-14 text-center\">\n      <span className=\"flex size-10 items-center justify-center rounded-xl bg-muted text-muted-foreground\">\n        {q ? <SearchIcon className=\"size-4.5\" /> : <FilterIcon className=\"size-4.5\" />}\n      </span>\n      <div className=\"flex max-w-72 flex-col gap-1\">\n        <span className=\"text-balance font-medium\">{q ? `Nobody matches “${query.trim()}”` : tab === \"suspended\" ? \"No suspended members\" : \"No members match these filters\"}</span>\n        <span className=\"text-pretty text-muted-foreground text-xs\">{q ? \"Search works on names, emails and teams.\" : \"Try removing a filter.\"}</span>\n      </div>\n      <Button\n        className={press}\n        onClick={() => {\n          setQuery(\"\");\n          setRoleFilter([]);\n          setNo2fa(false);\n          setTab(\"all\");\n        }}\n        size=\"sm\"\n        variant=\"outline\"\n      >\n        Show everyone\n      </Button>\n    </div>\n  );\n\n  return (\n    <div\n      className={cn(\"@container relative isolate flex h-[760px] w-full overflow-hidden bg-background text-foreground text-sm\", className)}\n      onKeyDown={(e) => {\n        if (e.key !== \"Escape\") return;\n        if (confirm) setConfirm(null);\n        else if (invite) setInvite(false);\n        else if (detailId) setDetailId(null);\n        else if (nav) setNav(false);\n      }}\n    >\n      <aside className=\"hidden w-60 shrink-0 border-r bg-muted/40 @5xl:block\">{sidebar}</aside>\n\n      <AnimatePresence>\n        {nav && (\n          <>\n            <motion.div animate={{ opacity: 1 }} aria-hidden className=\"absolute inset-0 z-40 bg-black/32 @5xl:hidden\" exit={{ opacity: 0 }} initial={{ opacity: 0 }} onClick={() => setNav(false)} transition={{ duration: 0.2, ease: easeOut }} />\n            <motion.div\n              animate={{ x: 0 }}\n              aria-label=\"Settings navigation\"\n              aria-modal\n              className=\"absolute inset-y-0 left-0 z-50 w-72 max-w-[85%] border-r bg-background @5xl:hidden\"\n              exit={{ x: \"-100%\" }}\n              initial={{ x: \"-100%\" }}\n              role=\"dialog\"\n              transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 420, damping: 42 }}\n            >\n              <Button aria-label=\"Close navigation\" className=\"absolute top-3 right-3\" onClick={() => setNav(false)} size=\"icon-sm\" variant=\"ghost\">\n                <XIcon />\n              </Button>\n              {sidebar}\n            </motion.div>\n          </>\n        )}\n      </AnimatePresence>\n\n      <div className=\"relative flex min-w-0 flex-1 flex-col\">\n        <header className=\"flex h-12 shrink-0 items-center gap-2 border-b px-3 @5xl:hidden\">\n          <Button aria-label=\"Open navigation\" onClick={() => setNav(true)} size=\"icon-sm\" variant=\"ghost\">\n            <MenuIcon />\n          </Button>\n          <span className=\"truncate font-heading font-semibold\">{orgName}</span>\n          <span className=\"text-muted-foreground\">/ Members</span>\n          <Button aria-label=\"Invite members\" className={cn(\"ms-auto\", press)} onClick={() => setInvite(true)} size=\"icon-sm\">\n            <UserPlusIcon />\n          </Button>\n        </header>\n\n        <div className=\"min-h-0 flex-1 overflow-y-auto\">\n          <div className=\"flex flex-col gap-5 px-4 pt-5 pb-28 @3xl:px-6 @3xl:pt-6\">\n            <div className=\"flex flex-wrap items-center gap-3\">\n              <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n                <h2 className=\"text-balance font-heading font-semibold text-xl tracking-tight\">Members</h2>\n                <p className=\"text-pretty text-muted-foreground\">Manage who can access {orgName} and what they can do.</p>\n              </div>\n              <Button className={cn(\"hidden @5xl:inline-flex\", press)} onClick={() => setInvite(true)}>\n                <UserPlusIcon /> Invite members\n              </Button>\n            </div>\n\n            <section aria-label=\"Overview\" className=\"grid grid-cols-3 divide-x overflow-hidden rounded-xl border bg-card\">\n              <div className=\"flex min-w-0 flex-col gap-2 p-3 @xl:gap-2.5 @xl:px-4 @xl:py-3.5\">\n                <div className=\"flex items-baseline justify-between\">\n                  <span className=\"text-muted-foreground text-xs\">Seats</span>\n                  <span className=\"hidden text-muted-foreground text-xs tabular-nums @xl:inline\">{Math.max(0, seats - seatsUsed)} left</span>\n                </div>\n                <span className=\"font-heading font-semibold text-lg tabular-nums\">\n                  {seatsUsed} <span className=\"font-normal text-muted-foreground text-sm\">of {seats}</span>\n                </span>\n                <div aria-hidden className=\"flex h-1.5 gap-px overflow-hidden rounded-full @xl:gap-0.5\">\n                  {Array.from({ length: seats }, (_, i) => (\n                    <motion.span\n                      animate={{ opacity: 1 }}\n                      className={cn(\"h-full flex-1 rounded-full transition-colors duration-300\", i < seatsUsed ? (seatsUsed / seats > 0.9 ? \"bg-warning\" : \"bg-primary\") : \"bg-muted\")}\n                      initial={false}\n                      key={i}\n                    />\n                  ))}\n                </div>\n              </div>\n              <button\n                className={cn(\"flex min-w-0 cursor-pointer flex-col gap-2 p-3 text-left transition-colors duration-150 @xl:gap-2.5 @xl:px-4 @xl:py-3.5 [@media(hover:hover)]:hover:bg-accent/40\", ring, \"focus-visible:ring-inset\")}\n                onClick={() => setTab(\"invited\")}\n                type=\"button\"\n              >\n                <span className=\"truncate text-muted-foreground text-xs\">\n                  <span className=\"@xl:hidden\">Invites</span>\n                  <span className=\"hidden @xl:inline\">Pending invites</span>\n                </span>\n                <span className=\"font-heading font-semibold text-lg tabular-nums\">{counts.invited}</span>\n                <span className=\"hidden text-muted-foreground text-xs @xl:block\">Invites expire after 14 days</span>\n              </button>\n              <button\n                className={cn(\"flex min-w-0 cursor-pointer flex-col gap-2 p-3 text-left transition-colors duration-150 @xl:gap-2.5 @xl:px-4 @xl:py-3.5 [@media(hover:hover)]:hover:bg-accent/40\", ring, \"focus-visible:ring-inset\")}\n                onClick={() => {\n                  setNo2fa(true);\n                  setTab(\"active\");\n                }}\n                type=\"button\"\n              >\n                <span className=\"truncate text-muted-foreground text-xs\">\n                  <span className=\"@xl:hidden\">2FA</span>\n                  <span className=\"hidden @xl:inline\">Two-factor coverage</span>\n                </span>\n                <span className=\"flex items-center gap-2 font-heading font-semibold text-lg tabular-nums\">\n                  {twoFaPct}%\n                  {twoFaPct < 100 && <ShieldAlertIcon className=\"size-4 text-warning-foreground\" />}\n                </span>\n                <span className=\"hidden text-muted-foreground text-xs @xl:block\">\n                  <span className=\"tabular-nums\">{activeUsers.filter((u) => !u.twoFactor).length}</span> active{\" \"}\n                  {activeUsers.filter((u) => !u.twoFactor).length === 1 ? \"member\" : \"members\"} without 2FA\n                </span>\n              </button>\n            </section>\n\n            <div className=\"flex flex-col gap-3 @4xl:flex-row @4xl:items-center\">\n              <div className=\"-mx-4 overflow-x-auto px-4 [scrollbar-width:none] @3xl:-mx-6 @3xl:px-6 @4xl:mx-0 @4xl:px-0\">\n                <div aria-label=\"Status\" className=\"relative flex w-fit items-center gap-0.5 rounded-lg bg-muted p-0.5\" role=\"tablist\">\n                  {tabs.map((t) => (\n                    <button\n                      aria-selected={tab === t.value}\n                      className={cn(\"relative flex h-8 shrink-0 cursor-pointer items-center gap-1.5 rounded-md px-2.5 font-medium\", ring)}\n                      key={t.value}\n                      onClick={() => {\n                        setTab(t.value);\n                        setSelected([]);\n                      }}\n                      role=\"tab\"\n                      type=\"button\"\n                    >\n                      {tab === t.value && (\n                        <motion.span className=\"absolute inset-0 rounded-md bg-background shadow-xs/5 dark:bg-input\" layoutId={`${orgName}-tab`} transition={reduce ? { duration: 0 } : spring} />\n                      )}\n                      <span className={cn(\"relative transition-colors\", tab === t.value ? \"text-foreground\" : \"text-muted-foreground\")}>{t.label}</span>\n                      <span className={cn(\"relative text-xs tabular-nums\", tab === t.value ? \"text-foreground/70\" : \"text-muted-foreground\")}>{counts[t.value]}</span>\n                    </button>\n                  ))}\n                </div>\n              </div>\n              <div className=\"flex gap-2 @4xl:ms-auto\">\n                <InputGroup className=\"@4xl:w-60\">\n                  <InputGroupAddon>\n                    <SearchIcon />\n                  </InputGroupAddon>\n                  <InputGroupInput aria-label=\"Search members\" onChange={(e) => setQuery(e.target.value)} placeholder=\"Name, email or team\" type=\"search\" value={query} />\n                </InputGroup>\n                <Menu>\n                  <MenuTrigger aria-label={filterCount ? `Filter, ${filterCount} active` : \"Filter\"} render={<Button className={cn(\"relative\", press)} variant=\"outline\" />}>\n                    <FilterIcon />\n                    <span className=\"hidden @md:inline\">Filter</span>\n                    <AnimatePresence initial={false}>\n                      {filterCount > 0 && (\n                        <motion.span\n                          animate={{ opacity: 1, scale: 1 }}\n                          className=\"absolute -top-1.5 -right-1.5 flex h-4.5 min-w-4.5 items-center justify-center rounded-full bg-primary px-1 font-medium text-[10px] text-primary-foreground tabular-nums ring-2 ring-background\"\n                          exit={{ opacity: 0, scale: 0.95 }}\n                          initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.95 }}\n                          transition={{ duration: 0.15, ease: easeOut }}\n                        >\n                          {filterCount}\n                        </motion.span>\n                      )}\n                    </AnimatePresence>\n                  </MenuTrigger>\n                  <MenuPopup align=\"end\" className={cn(\"w-52\", menuPop)}>\n                    <MenuGroup>\n                      <MenuGroupLabel>Role</MenuGroupLabel>\n                      {adminRoles.map((r) => (\n                        <MenuCheckboxItem\n                          checked={roleFilter.includes(r.value)}\n                          key={r.value}\n                          onCheckedChange={(on) => setRoleFilter((f) => (on ? [...f, r.value] : f.filter((x) => x !== r.value)))}\n                        >\n                          {r.label}\n                        </MenuCheckboxItem>\n                      ))}\n                    </MenuGroup>\n                    <MenuSeparator />\n                    <MenuGroup>\n                      <MenuGroupLabel>Security</MenuGroupLabel>\n                      <MenuCheckboxItem checked={no2fa} onCheckedChange={(on) => setNo2fa(on)}>\n                        Two-factor off\n                      </MenuCheckboxItem>\n                    </MenuGroup>\n                  </MenuPopup>\n                </Menu>\n              </div>\n            </div>\n\n            <AnimatePresence initial={false}>\n              {filterCount > 0 && (\n                <motion.div\n                  animate={{ opacity: 1, height: \"auto\" }}\n                  className=\"-mt-2 overflow-hidden\"\n                  exit={{ opacity: 0, height: 0 }}\n                  initial={{ opacity: 0, height: 0 }}\n                  transition={{ duration: 0.2, ease: easeOut }}\n                >\n                  <div className=\"flex flex-wrap items-center gap-1.5 pt-0.5\">\n                    {roleFilter.map((r) => (\n                      <button\n                        aria-label={`Remove filter: ${roleMeta(r).label}`}\n                        className={cn(\"flex h-7 cursor-pointer items-center gap-1 rounded-full border bg-background ps-2.5 pe-1.5 text-xs hover:bg-accent dark:bg-input/32\", ring, press)}\n                        key={r}\n                        onClick={() => setRoleFilter((f) => f.filter((x) => x !== r))}\n                        type=\"button\"\n                      >\n                        <span className=\"text-muted-foreground\">Role:</span> {roleMeta(r).label}\n                        <XIcon className=\"size-3.5 text-muted-foreground\" />\n                      </button>\n                    ))}\n                    {no2fa && (\n                      <button\n                        aria-label=\"Remove filter: two-factor off\"\n                        className={cn(\"flex h-7 cursor-pointer items-center gap-1 rounded-full border bg-background ps-2.5 pe-1.5 text-xs hover:bg-accent dark:bg-input/32\", ring, press)}\n                        onClick={() => setNo2fa(false)}\n                        type=\"button\"\n                      >\n                        2FA off\n                        <XIcon className=\"size-3.5 text-muted-foreground\" />\n                      </button>\n                    )}\n                    <Button\n                      className={press}\n                      onClick={() => {\n                        setRoleFilter([]);\n                        setNo2fa(false);\n                      }}\n                      size=\"xs\"\n                      variant=\"ghost\"\n                    >\n                      Clear all\n                    </Button>\n                  </div>\n                </motion.div>\n              )}\n            </AnimatePresence>\n\n            <div className=\"overflow-hidden rounded-xl border bg-card\">\n              <div className=\"@3xl:hidden\">\n                <div className={cn(\"flex items-center gap-3 border-b px-4 py-2.5 text-muted-foreground text-xs\", rows.length === 0 && \"hidden\")}>\n                  <Checkbox aria-label=\"Select all visible members\" checked={allChecked} className={hit} indeterminate={someChecked} onCheckedChange={(on) => setSelected(on ? visibleIds : [])} />\n                  <span className=\"flex-1 font-medium tabular-nums\">{rows.length} members</span>\n                  {sortHeader(\"minutesSinceActive\", \"Last active\")}\n                </div>\n                <ul className=\"divide-y\">\n                  <AnimatePresence initial={false} key={listKey}>\n                    {rows.map((u) => {\n                      const isSel = selected.includes(u.id);\n                      return (\n                        <motion.li key={u.id} {...rowMotion(u)} className={cn(\"flex items-center gap-3 px-4 py-3 transition-colors\", isSel && \"bg-accent/60\")}>\n                          {u.id === currentUserId ? (\n                            <span className=\"size-4 shrink-0\" />\n                          ) : (\n                            <Checkbox aria-label={`Select ${label(u)}`} checked={isSel} className={hit} onCheckedChange={(on) => setSelected((s) => (on ? [...s, u.id] : s.filter((x) => x !== u.id)))} />\n                          )}\n                          <button className={cn(\"flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-lg text-left\", ring)} onClick={() => setDetailId(u.id)} type=\"button\">\n                            <UserAvatar user={u} />\n                            <span className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n                              <span className=\"flex items-center gap-1.5 truncate font-medium\">\n                                <span className=\"truncate\">{u.name || u.email}</span>\n                                {u.id === currentUserId && <span className=\"font-normal text-muted-foreground text-xs\">you</span>}\n                              </span>\n                              <span className=\"flex items-center gap-2 text-muted-foreground text-xs\">\n                                <StatusTag user={u} />\n                                <span aria-hidden>·</span>\n                                <span className=\"truncate tabular-nums\">{u.status === \"invited\" ? u.joined : ago(u.minutesSinceActive)}</span>\n                              </span>\n                            </span>\n                          </button>\n                          <RolePill role={u.role} />\n                        </motion.li>\n                      );\n                    })}\n                  </AnimatePresence>\n                </ul>\n              </div>\n\n              <Table className=\"min-w-[860px] table-fixed\" render={<div className=\"relative hidden w-full overflow-x-auto @3xl:block\" />}>\n                <TableHeader>\n                  <TableRow className=\"bg-muted/30 text-muted-foreground text-xs not-in-data-[variant=card]:hover:bg-muted/30 dark:not-in-data-[variant=card]:hover:bg-muted/30 [&_th]:h-9 [&_th]:font-medium [&_th]:text-muted-foreground [&_th]:text-xs\">\n                    <TableHead className=\"ps-4 has-[[role=checkbox]]:w-auto first:has-[[role=checkbox]]:pe-4\">\n                      <div className=\"flex items-center gap-3\">\n                        <Checkbox aria-label=\"Select all visible members\" checked={allChecked} className={hit} indeterminate={someChecked} onCheckedChange={(on) => setSelected(on ? visibleIds : [])} />\n                        {sortHeader(\"name\", \"Member\")}\n                      </div>\n                    </TableHead>\n                    <TableHead className=\"w-32\">Role</TableHead>\n                    <TableHead className=\"w-28\">Status</TableHead>\n                    <TableHead className=\"w-20\">2FA</TableHead>\n                    <TableHead className=\"w-44\">Teams</TableHead>\n                    <TableHead className=\"w-28\">{sortHeader(\"minutesSinceActive\", \"Last active\")}</TableHead>\n                    <TableHead className=\"w-14 pe-3\" />\n                  </TableRow>\n                </TableHeader>\n                <TableBody>\n                  <AnimatePresence initial={false} key={listKey}>\n                    {rows.map((u) => {\n                      const isSel = selected.includes(u.id);\n                      return (\n                        <MotionRow\n                          key={u.id}\n                          {...rowMotion(u)}\n                          className=\"group/row cursor-pointer\"\n                          data-state={isSel ? \"selected\" : undefined}\n                          onClick={(e: MouseEvent) => {\n                            if ((e.target as HTMLElement).closest(\"button, [role=checkbox], [role=menuitem]\")) return;\n                            setDetailId(u.id);\n                          }}\n                        >\n                          <TableCell className=\"py-2.5 ps-4 has-[[role=checkbox]]:w-auto first:has-[[role=checkbox]]:pe-4\">\n                            <div className=\"flex min-w-0 items-center gap-3\">\n                              {u.id === currentUserId ? (\n                                <span className=\"size-4 shrink-0\" />\n                              ) : (\n                                <Checkbox aria-label={`Select ${label(u)}`} checked={isSel} className={hit} onCheckedChange={(on) => setSelected((s) => (on ? [...s, u.id] : s.filter((x) => x !== u.id)))} />\n                              )}\n                              <UserAvatar user={u} />\n                              <div className=\"flex min-w-0 flex-1 flex-col\">\n                                <button className={cn(\"flex w-fit max-w-full cursor-pointer items-center gap-1.5 truncate rounded text-left font-medium hover:underline\", ring)} onClick={() => setDetailId(u.id)} type=\"button\">\n                                  <span className=\"truncate\">{u.name || u.email}</span>\n                                  {u.id === currentUserId && <span className=\"font-normal text-muted-foreground text-xs\">you</span>}\n                                </button>\n                                <span className=\"truncate text-muted-foreground text-xs\">{u.name ? u.email : \"Hasn't joined yet\"}</span>\n                              </div>\n                            </div>\n                          </TableCell>\n                          <TableCell>{roleMenu(u)}</TableCell>\n                          <TableCell>\n                            <div className=\"flex flex-col\">\n                              <StatusTag user={u} />\n                              {u.status === \"invited\" && <span className=\"text-muted-foreground text-xs\">{u.joined.replace(\"Invited \", \"Sent \")}</span>}\n                            </div>\n                          </TableCell>\n                          <TableCell>{twoFa(u)}</TableCell>\n                          <TableCell>{teamChips(u)}</TableCell>\n                          <TableCell className=\"text-muted-foreground text-xs tabular-nums\">{ago(u.minutesSinceActive)}</TableCell>\n                          <TableCell className=\"pe-3 text-right\">{rowMenu(u)}</TableCell>\n                        </MotionRow>\n                      );\n                    })}\n                  </AnimatePresence>\n                </TableBody>\n              </Table>\n              {rows.length === 0 && empty}\n            </div>\n          </div>\n        </div>\n\n        <div className=\"pointer-events-none absolute inset-x-0 bottom-4 z-30 flex justify-center px-3\">\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            {selectedVisible.length > 0 && !detail && !invite && !confirm ? (\n              <motion.div\n                animate={{ y: 0, opacity: 1, scale: 1 }}\n                aria-label=\"Bulk actions\"\n                className={cn(barSurface, \"pointer-events-auto flex max-w-full items-center gap-1 overflow-x-auto p-1 [scrollbar-width:none]\")}\n                exit={{ y: 8, opacity: 0, scale: 0.97, transition: { duration: 0.12, ease: easeOut } }}\n                initial={reduce ? { opacity: 0 } : { y: 16, opacity: 0, scale: 0.96 }}\n                key=\"bulk\"\n                role=\"toolbar\"\n                transition={reduce ? { duration: 0.15 } : spring}\n              >\n                <span className=\"flex h-8 shrink-0 items-center gap-2 ps-2.5 pe-1.5 font-medium\">\n                  <span className=\"flex h-5 min-w-5 items-center justify-center rounded-full bg-primary-foreground px-1.5 text-primary text-xs tabular-nums dark:bg-primary dark:text-primary-foreground\">\n                    {selectedVisible.length}\n                  </span>\n                  <span className=\"hidden @md:inline\">selected</span>\n                </span>\n                <span className=\"h-5 w-px shrink-0 bg-primary-foreground/20 dark:bg-border\" />\n                <Menu>\n                  <MenuTrigger className={barButton}>\n                    <UserCogIcon className=\"size-3.5 opacity-80\" /> Role\n                  </MenuTrigger>\n                  <MenuPopup align=\"center\" className={menuPop} side=\"top\" sideOffset={8}>\n                    <MenuGroup>\n                      <MenuGroupLabel>Change role to</MenuGroupLabel>\n                      {adminRoles\n                        .filter((r) => r.value !== \"owner\")\n                        .map((r) => (\n                          <MenuItem\n                            key={r.value}\n                            onClick={() => {\n                              const ids = users.filter((u) => selectedVisible.includes(u.id) && u.role !== \"owner\").map((u) => u.id);\n                              updateMany(ids, { role: r.value });\n                              say(`${ids.length} ${ids.length === 1 ? \"member is\" : \"members are\"} now ${r.label.toLowerCase()}${ids.length === 1 ? \"\" : \"s\"}`);\n                            }}\n                          >\n                            {r.label}\n                          </MenuItem>\n                        ))}\n                    </MenuGroup>\n                  </MenuPopup>\n                </Menu>\n                {selectedInvited.length > 0 && (\n                  <button className={barButton} onClick={() => say(`${selectedInvited.length} ${selectedInvited.length === 1 ? \"invite\" : \"invites\"} resent`)} type=\"button\">\n                    <SendIcon className=\"size-3.5 opacity-80\" /> Resend\n                  </button>\n                )}\n                <button\n                  className={barButton}\n                  onClick={() => {\n                    const ids = users.filter((u) => selectedVisible.includes(u.id) && u.status === \"active\" && u.role !== \"owner\").map((u) => u.id);\n                    updateMany(ids, { status: \"suspended\" });\n                    say(ids.length ? `${ids.length} suspended. Their sessions were signed out.` : \"Nobody to suspend in this selection\");\n                  }}\n                  type=\"button\"\n                >\n                  <UserRoundXIcon className=\"size-3.5 opacity-80\" /> Suspend\n                </button>\n                <button\n                  className={cn(barButton, \"hover:bg-destructive hover:text-white dark:hover:bg-destructive dark:hover:text-white\")}\n                  onClick={() => setConfirm(selectedVisible.filter((id) => users.find((u) => u.id === id)?.role !== \"owner\"))}\n                  type=\"button\"\n                >\n                  <UserMinusIcon className=\"size-3.5 opacity-80\" /> Remove\n                </button>\n                <button aria-label=\"Clear selection\" className={cn(barButton, \"w-8 justify-center px-0\")} onClick={() => setSelected([])} type=\"button\">\n                  <XIcon className=\"size-4\" />\n                </button>\n              </motion.div>\n            ) : toast ? (\n              <motion.div\n                animate={{ y: 0, opacity: 1, scale: 1 }}\n                className={cn(barSurface, \"pointer-events-auto flex max-w-full items-center gap-2 px-4 py-2\")}\n                exit={{ y: 8, opacity: 0, scale: 0.97, transition: { duration: 0.12, ease: easeOut } }}\n                initial={reduce ? { opacity: 0 } : { y: 16, opacity: 0, scale: 0.96 }}\n                key={toast.id}\n                role=\"status\"\n                transition={reduce ? { duration: 0.15 } : spring}\n              >\n                <CheckIcon className=\"size-4 shrink-0 opacity-80\" />\n                <span className=\"truncate\">{toast.text}</span>\n              </motion.div>\n            ) : null}\n          </AnimatePresence>\n        </div>\n\n      </div>\n\n      <AnimatePresence>\n        {detail && (\n          <>\n            <motion.div animate={{ opacity: 1 }} aria-hidden className=\"absolute inset-0 z-40 bg-black/24\" exit={{ opacity: 0 }} initial={{ opacity: 0 }} key=\"scrim\" onClick={() => setDetailId(null)} transition={{ duration: 0.2, ease: easeOut }} />\n            <motion.aside\n              animate={{ x: 0 }}\n              aria-label={`${label(detail)} details`}\n              aria-modal\n              className=\"absolute inset-y-0 right-0 z-50 flex w-full max-w-[420px] flex-col border-l bg-background shadow-lg/10 outline-none\"\n              exit={{ x: \"100%\", transition: { duration: 0.2, ease: easeOut } }}\n              initial={{ x: \"100%\" }}\n              key=\"drawer\"\n              ref={drawerRef}\n              role=\"dialog\"\n              tabIndex={-1}\n              transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 420, damping: 42 }}\n            >\n              <div className=\"flex h-12 shrink-0 items-center justify-between border-b px-4\">\n                <span className=\"font-medium text-muted-foreground text-xs\">Member details</span>\n                <Button aria-label=\"Close details\" className=\"-me-2\" onClick={() => setDetailId(null)} size=\"icon-sm\" variant=\"ghost\">\n                  <XIcon />\n                </Button>\n              </div>\n              <div className=\"min-h-0 flex-1 overflow-y-auto\">\n                <div className=\"flex flex-col gap-6 p-5\">\n                  <div className=\"flex items-center gap-4\">\n                    <UserAvatar size={14} user={detail} />\n                    <div className=\"flex min-w-0 flex-col gap-1\">\n                      <h3 className=\"truncate font-heading font-semibold text-lg\">{detail.name || detail.email}</h3>\n                      <span className=\"truncate text-muted-foreground\">{detail.name ? detail.email : \"Hasn't joined yet\"}</span>\n                      <span className=\"flex items-center gap-2\">\n                        {roleMenu(detail)}\n                        <StatusTag user={detail} />\n                      </span>\n                    </div>\n                  </div>\n\n                  <dl className=\"grid grid-cols-2 gap-x-4 gap-y-3 rounded-xl border bg-card p-4 text-xs\">\n                    <div className=\"flex flex-col gap-0.5\">\n                      <dt className=\"text-muted-foreground\">{detail.status === \"invited\" ? \"Invited\" : \"Joined\"}</dt>\n                      <dd className=\"font-medium\">{detail.joined.replace(\"Invited \", \"\")}</dd>\n                    </div>\n                    <div className=\"flex flex-col gap-0.5\">\n                      <dt className=\"text-muted-foreground\">Last active</dt>\n                      <dd className=\"font-medium tabular-nums\">{ago(detail.minutesSinceActive)}</dd>\n                    </div>\n                    <div className=\"flex flex-col gap-0.5\">\n                      <dt className=\"text-muted-foreground\">Two-factor</dt>\n                      <dd>{twoFa(detail)}</dd>\n                    </div>\n                    <div className=\"flex flex-col gap-0.5\">\n                      <dt className=\"text-muted-foreground\">Location</dt>\n                      <dd className=\"truncate font-medium\">{detail.location ?? \"—\"}</dd>\n                    </div>\n                    <div className=\"col-span-2 flex flex-col gap-1.5\">\n                      <dt className=\"text-muted-foreground\">Teams</dt>\n                      <dd>{teamChips(detail, true)}</dd>\n                    </div>\n                  </dl>\n\n                  {detail.status === \"active\" && (\n                    <section className=\"flex flex-col gap-2\">\n                      <h4 className=\"font-medium text-muted-foreground text-xs\">Signed-in devices</h4>\n                      <ul className=\"divide-y rounded-xl border\">\n                        {[\n                          { icon: <LaptopIcon />, name: \"MacBook Pro · Chrome\", meta: `${detail.location ?? \"Unknown\"} · ${ago(detail.minutesSinceActive)}`, current: true },\n                          { icon: <SmartphoneIcon />, name: \"iPhone · App\", meta: `${detail.location ?? \"Unknown\"} · 3d ago` },\n                        ].map((d) => (\n                          <li className=\"flex items-center gap-3 px-3 py-2.5\" key={d.name}>\n                            <span className=\"flex size-8 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-4\">{d.icon}</span>\n                            <span className=\"flex min-w-0 flex-1 flex-col\">\n                              <span className=\"truncate font-medium text-xs\">{d.name}</span>\n                              <span className=\"truncate text-muted-foreground text-xs tabular-nums\">{d.meta}</span>\n                            </span>\n                            {d.current && <span className=\"text-success-foreground text-xs\">Active now</span>}\n                          </li>\n                        ))}\n                      </ul>\n                    </section>\n                  )}\n\n                  <section className=\"flex flex-col gap-3\">\n                    <h4 className=\"font-medium text-muted-foreground text-xs\">Activity</h4>\n                    <ol className=\"relative flex flex-col gap-4\">\n                      <span aria-hidden className=\"absolute top-3 bottom-3 left-[13px] w-px bg-border\" />\n                      {activityFor(detail).map((a, i) => (\n                        <motion.li\n                          animate={{ opacity: 1, y: 0 }}\n                          className=\"relative flex gap-3\"\n                          initial={reduce ? false : { opacity: 0, y: 4 }}\n                          key={`${a.kind}-${i}`}\n                          transition={{ duration: 0.2, ease: easeOut, delay: 0.08 + Math.min(i, 5) * 0.03 }}\n                        >\n                          <span className=\"relative flex size-7 shrink-0 items-center justify-center rounded-full border bg-background text-muted-foreground [&_svg]:size-3.5\">\n                            {activityIcon[a.kind]}\n                          </span>\n                          <span className=\"flex min-w-0 flex-col gap-0.5 pt-1\">\n                            <span className=\"text-pretty text-xs leading-5\">{a.text}</span>\n                            <span className=\"text-muted-foreground text-xs tabular-nums\">{a.when}</span>\n                          </span>\n                        </motion.li>\n                      ))}\n                    </ol>\n                  </section>\n                </div>\n              </div>\n              {detail.role !== \"owner\" && detail.id !== currentUserId && (\n                <div className=\"flex shrink-0 gap-2 border-t p-4\">\n                  {detail.status === \"invited\" ? (\n                    <Button className={cn(\"flex-1\", press)} onClick={() => say(`Invite resent to ${detail.email}`)} variant=\"outline\">\n                      <SendIcon /> Resend invite\n                    </Button>\n                  ) : (\n                    <Button\n                      className={cn(\"flex-1\", press)}\n                      onClick={() => {\n                        const next = detail.status === \"suspended\" ? \"active\" : \"suspended\";\n                        updateMany([detail.id], { status: next });\n                        say(next === \"suspended\" ? `${label(detail)} suspended. Sessions signed out.` : `${label(detail)} reactivated`);\n                      }}\n                      variant=\"outline\"\n                    >\n                      {detail.status === \"suspended\" ? <UserRoundCheckIcon /> : <UserRoundXIcon />}\n                      {detail.status === \"suspended\" ? \"Reactivate\" : \"Suspend\"}\n                    </Button>\n                  )}\n                  <Button className={cn(\"flex-1\", press)} onClick={() => setConfirm([detail.id])} variant=\"destructive-outline\">\n                    <UserMinusIcon /> {detail.status === \"invited\" ? \"Revoke\" : \"Remove\"}\n                  </Button>\n                </div>\n              )}\n            </motion.aside>\n          </>\n        )}\n      </AnimatePresence>\n\n      <AnimatePresence>\n        {confirm && (\n          <ConfirmRemove\n            names={users.filter((u) => confirm.includes(u.id)).map(label)}\n            onCancel={() => setConfirm(null)}\n            onConfirm={() => remove(confirm)}\n          />\n        )}\n      </AnimatePresence>\n\n      <AnimatePresence>\n        {invite && (\n          <InviteDialog\n            onClose={() => setInvite(false)}\n            onSend={(emails, role) => {\n              const added: AdminUser[] = emails.map((email, i) => ({\n                id: `inv-${Date.now()}-${i}`,\n                name: \"\",\n                email,\n                role,\n                status: \"invited\",\n                twoFactor: false,\n                teams: [],\n                minutesSinceActive: null,\n                joined: \"Invited just now\",\n              }));\n              setUsers((all) => [...added, ...all]);\n              setFreshIds(added.map((a) => a.id));\n              setTab(\"all\");\n              setQuery(\"\");\n              setRoleFilter([]);\n              setNo2fa(false);\n              setSort({ key: \"minutesSinceActive\", dir: -1 });\n              setInvite(false);\n              say(`${emails.length} ${emails.length === 1 ? \"invite\" : \"invites\"} sent`);\n            }}\n            existing={users.map((u) => u.email.toLowerCase())}\n            seatsLeft={seats - seatsUsed}\n          />\n        )}\n      </AnimatePresence>\n    </div>\n  );\n}\n\nconst MotionTableRow = motion.create(TableRow);\n\nfunction ConfirmRemove({ names, onCancel, onConfirm }: { names: string[]; onCancel: () => void; onConfirm: () => void }) {\n  const reduce = useReducedMotionAfterMount();\n  const cancelRef = useRef<HTMLButtonElement>(null);\n  useEffect(() => cancelRef.current?.focus(), []);\n  const n = names.length;\n  return (\n    <>\n      <motion.div animate={{ opacity: 1 }} aria-hidden className=\"absolute inset-0 z-[60] bg-black/32\" exit={{ opacity: 0 }} initial={{ opacity: 0 }} onClick={onCancel} transition={{ duration: 0.18 }} />\n      <motion.div\n        animate={{ opacity: 1, scale: 1, y: 0 }}\n        aria-describedby=\"au-confirm-body\"\n        aria-labelledby=\"au-confirm-title\"\n        className=\"absolute inset-x-4 top-1/2 z-[70] mx-auto flex max-w-sm -translate-y-1/2 flex-col gap-4 rounded-2xl border bg-popover p-5 text-popover-foreground shadow-lg/10\"\n        exit={{ opacity: 0, scale: 0.97, transition: { duration: 0.12 } }}\n        initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.96 }}\n        role=\"alertdialog\"\n        transition={{ duration: 0.2, ease: easeOut }}\n      >\n        <div className=\"flex flex-col gap-1.5\">\n          <h3 className=\"text-balance font-heading font-semibold text-base\" id=\"au-confirm-title\">\n            Remove {n === 1 ? names[0] : `${n} members`}?\n          </h3>\n          <p className=\"text-pretty text-muted-foreground\" id=\"au-confirm-body\">\n            {n === 1 ? \"They\" : \"They all\"} lose access right away and {n === 1 ? \"their seat is\" : \"their seats are\"} freed. Projects and comments they made stay put.\n          </p>\n        </div>\n        <div className=\"flex justify-end gap-2\">\n          <Button className={press} onClick={onCancel} ref={cancelRef} variant=\"outline\">\n            Cancel\n          </Button>\n          <Button className={press} onClick={onConfirm} variant=\"destructive\">\n            Remove\n          </Button>\n        </div>\n      </motion.div>\n    </>\n  );\n}\n\nfunction InviteDialog({\n  onClose,\n  onSend,\n  seatsLeft,\n  existing,\n}: {\n  onClose: () => void;\n  onSend: (emails: string[], role: AdminRole) => void;\n  seatsLeft: number;\n  existing: string[];\n}) {\n  const reduce = useReducedMotionAfterMount();\n  const [emails, setEmails] = useState<string[]>([]);\n  const [draft, setDraft] = useState(\"\");\n  const [role, setRole] = useState<AdminRole>(\"member\");\n  const inputRef = useRef<HTMLInputElement>(null);\n  useEffect(() => inputRef.current?.focus(), []);\n\n  const commit = (raw: string) => {\n    const parts = raw.split(/[\\s,;]+/).map((p) => p.trim().toLowerCase()).filter(Boolean);\n    if (!parts.length) return;\n    setEmails((e) => [...e, ...parts.filter((p) => !e.includes(p))]);\n    setDraft(\"\");\n  };\n\n  const problem = (e: string) => (!EMAIL.test(e) ? \"format\" : existing.includes(e) ? \"taken\" : null);\n  const invalid = emails.filter((e) => problem(e) === \"format\");\n  const taken = emails.filter((e) => problem(e) === \"taken\");\n  const blocked = invalid.length + taken.length;\n  const validCount = emails.length - blocked;\n  const usesSeats = role !== \"viewer\";\n  const overSeats = usesSeats && validCount > seatsLeft;\n  const canSend = emails.length > 0 && blocked === 0 && !overSeats;\n\n  return (\n    <>\n      <motion.div animate={{ opacity: 1 }} aria-hidden className=\"absolute inset-0 z-[60] bg-black/32\" exit={{ opacity: 0 }} initial={{ opacity: 0 }} onClick={onClose} transition={{ duration: 0.18 }} />\n      <motion.div\n        animate={{ opacity: 1, scale: 1, y: 0 }}\n        aria-labelledby=\"au-invite-title\"\n        aria-modal\n        className=\"absolute inset-x-3 bottom-3 z-[70] mx-auto flex max-w-lg flex-col gap-5 rounded-2xl border bg-popover p-5 text-popover-foreground shadow-lg/10 @2xl:top-20 @2xl:bottom-auto\"\n        exit={{ opacity: 0, y: 8, scale: 0.98, transition: { duration: 0.14, ease: easeOut } }}\n        initial={reduce ? { opacity: 0 } : { opacity: 0, y: 12, scale: 0.98 }}\n        role=\"dialog\"\n        transition={{ duration: 0.22, ease: easeOut }}\n      >\n        <div className=\"flex items-start gap-3\">\n          <div className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n            <h3 className=\"font-heading font-semibold text-base\" id=\"au-invite-title\">\n              Invite members\n            </h3>\n            <p className=\"text-pretty text-muted-foreground text-xs\">They'll get an email with a link that works for 14 days.</p>\n          </div>\n          <Button aria-label=\"Close\" className=\"-me-2 -mt-1\" onClick={onClose} size=\"icon-sm\" variant=\"ghost\">\n            <XIcon />\n          </Button>\n        </div>\n\n        <div className=\"flex flex-col gap-2\">\n          <label className=\"font-medium text-xs\" htmlFor=\"au-invite-input\">\n            Email addresses\n          </label>\n          <div\n            className=\"flex min-h-10 cursor-text flex-wrap items-center gap-1.5 rounded-lg border border-input bg-background p-1.5 shadow-xs/5 transition-shadow has-focus-visible:border-ring has-focus-visible:ring-[3px] has-focus-visible:ring-ring/24 dark:bg-input/32\"\n            onClick={() => inputRef.current?.focus()}\n          >\n            <AnimatePresence initial={false}>\n              {emails.map((e) => {\n                const bad = problem(e) !== null;\n                return (\n                  <motion.span\n                    animate={{ opacity: 1, scale: 1 }}\n                    className={cn(\n                      \"flex h-7 items-center gap-1 rounded-md ps-2 pe-1 text-xs\",\n                      bad ? \"bg-destructive/10 text-destructive-foreground ring-1 ring-destructive/30 ring-inset\" : \"bg-muted text-foreground\",\n                    )}\n                    exit={{ opacity: 0, scale: 0.9, transition: { duration: 0.1 } }}\n                    initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.9 }}\n                    key={e}\n                    layout={reduce ? false : \"position\"}\n                    transition={{ duration: 0.15, ease: easeOut }}\n                  >\n                    {e}\n                    <button\n                      aria-label={`Remove ${e}`}\n                      className={cn(\"flex size-5 cursor-pointer items-center justify-center rounded hover:bg-foreground/10\", ring)}\n                      onClick={(ev) => {\n                        ev.stopPropagation();\n                        setEmails((all) => all.filter((x) => x !== e));\n                      }}\n                      type=\"button\"\n                    >\n                      <XIcon className=\"size-3\" />\n                    </button>\n                  </motion.span>\n                );\n              })}\n            </AnimatePresence>\n            <input\n              aria-describedby=\"au-invite-help\"\n              className=\"h-7 min-w-36 flex-1 bg-transparent px-1 text-sm outline-none placeholder:text-muted-foreground/72\"\n              id=\"au-invite-input\"\n              onBlur={() => {\n                commit(draft);\n              }}\n              onChange={(e) => {\n                const v = e.target.value;\n                if (/[,;\\s]$/.test(v)) commit(v);\n                else setDraft(v);\n              }}\n              onKeyDown={(e) => {\n                if (e.key === \"Enter\") {\n                  e.preventDefault();\n                  if (draft.trim()) commit(draft);\n                  else if (canSend) onSend(emails, role);\n                } else if (e.key === \"Backspace\" && !draft && emails.length) {\n                  setEmails((all) => all.slice(0, -1));\n                }\n              }}\n              onPaste={(e) => {\n                e.preventDefault();\n                commit(e.clipboardData.getData(\"text\"));\n              }}\n              placeholder={emails.length ? \"Add another\" : \"name@company.com\"}\n              ref={inputRef}\n              value={draft}\n            />\n          </div>\n          <span className={cn(\"text-xs\", blocked ? \"text-destructive-foreground\" : \"text-muted-foreground\")} id=\"au-invite-help\">\n            {invalid.length\n              ? `${invalid.length === 1 ? `“${invalid[0]}” doesn't look like an email` : `${invalid.length} addresses don't look right`}. Remove or fix ${invalid.length === 1 ? \"it\" : \"them\"}.`\n              : taken.length\n                ? `${taken.length === 1 ? `${taken[0]} is` : `${taken.length} addresses are`} already a member or invited.`\n                : \"Separate addresses with commas or paste a list.\"}\n          </span>\n        </div>\n\n        <fieldset className=\"flex flex-col gap-2\">\n          <legend className=\"mb-2 font-medium text-xs\">Role</legend>\n          <div className=\"grid grid-cols-1 gap-2 @lg:grid-cols-3\" role=\"radiogroup\">\n            {adminRoles\n              .filter((r) => r.value === \"admin\" || r.value === \"member\" || r.value === \"viewer\")\n              .map((r) => {\n                const on = role === r.value;\n                return (\n                  <button\n                    aria-checked={on}\n                    className={cn(\n                      \"relative flex cursor-pointer flex-col gap-1 rounded-xl border p-3 text-left\",\n                      ring,\n                      press,\n                      \"active:scale-[0.98]\",\n                      on ? \"border-foreground/40 bg-accent/60\" : \"hover:bg-accent/40\",\n                    )}\n                    key={r.value}\n                    onClick={() => setRole(r.value)}\n                    role=\"radio\"\n                    type=\"button\"\n                  >\n                    <span className=\"flex items-center justify-between font-medium\">\n                      {r.label}\n                      <span className={cn(\"flex size-4 items-center justify-center rounded-full border transition-colors\", on ? \"border-primary bg-primary text-primary-foreground\" : \"border-input\")}>\n                        {on && <CheckIcon className=\"size-2.5\" strokeWidth={3} />}\n                      </span>\n                    </span>\n                    <span className=\"text-pretty text-muted-foreground text-xs leading-4\">{r.description}</span>\n                  </button>\n                );\n              })}\n          </div>\n        </fieldset>\n\n        <div className=\"flex flex-wrap items-center justify-between gap-3\">\n          <span className={cn(\"text-xs tabular-nums\", overSeats ? \"text-destructive-foreground\" : \"text-muted-foreground\")}>\n            {usesSeats ? (overSeats ? `Only ${seatsLeft} seats left. Add seats or invite as viewers.` : validCount ? `Uses ${validCount} of ${seatsLeft} remaining ${seatsLeft === 1 ? \"seat\" : \"seats\"}` : `${seatsLeft} ${seatsLeft === 1 ? \"seat\" : \"seats\"} left`) : \"Viewers are free\"}\n          </span>\n          <div className=\"flex gap-2\">\n            <Button className={press} onClick={onClose} variant=\"ghost\">\n              Cancel\n            </Button>\n            <Button className={press} disabled={!canSend} onClick={() => onSend(emails, role)}>\n              <SendIcon /> Send {validCount > 1 ? `${validCount} invites` : \"invite\"}\n            </Button>\n          </div>\n        </div>\n      </motion.div>\n    </>\n  );\n}\n"
    }
  ]
}