(defcomp (&key (name :as string) (path :as string) (needed :as number) (direct :as number) (total :as number) (pct :as number) (savings :as number)
                             (io-refs :as list) (pure-in-page :as number) (io-in-page :as number) (components :as list))
  (details (~tw :tokens "rounded border border-stone-200")
    (summary (~tw :tokens "p-4 cursor-pointer hover:bg-stone-50 transition-colors")
      (div (~tw :tokens "flex items-center justify-between mb-2")
        (div
          (span (~tw :tokens "font-mono font-semibold text-stone-800") name)
          (span (~tw :tokens "text-stone-400 text-sm ml-2") path))
        (div (~tw :tokens "flex items-center gap-2")
          (span (~tw :tokens "inline-block px-1.5 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800")
            (str pure-in-page " pure"))
          (span (~tw :tokens "inline-block px-1.5 py-0.5 rounded text-xs font-medium bg-amber-100 text-amber-800")
            (str io-in-page " IO"))
          (div (~tw :tokens "text-right")
            (span (~tw :tokens "font-mono text-sm")
              (span (~tw :tokens "text-violet-700 font-bold") (str needed))
              (span (~tw :tokens "text-stone-400") (str " / " total)))
            (span (~tw :tokens "ml-2 inline-block px-1.5 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800")
              (str savings "% saved")))))
      (div (~tw :tokens "w-full bg-stone-200 rounded-full h-2.5")
        (div (~tw :tokens "bg-violet-600 h-2.5 rounded-full transition-all")
             :style (str "width: " pct "%"))))

    ;; Component tree (shown when expanded)
    (div (~tw :tokens "border-t border-stone-200 p-4 bg-stone-50")
      (div (~tw :tokens "text-xs font-medium text-stone-500 uppercase tracking-wide mb-3")
        (str needed " components in bundle"))
      (div (~tw :tokens "space-y-1")
        (map (fn (comp)
          (~analyzer/component
            :comp-name (get comp "name")
            :is-pure (get comp "is-pure")
            :io-refs (get comp "io-refs")
            :deps (get comp "deps")
            :source (get comp "source")))
          components)))))
