// v-atoms.jsx — Lasso vendor dashboard icons + dense SaaS primitives

// ─── Icon set (lucide-style, 2 stroke) ───────────────────────────────
const I = {
  grid:    (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>,
  map:     (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M9 4 3 6v14l6-2 6 2 6-2V4l-6 2-6-2z"/><path d="M9 4v14M15 6v14"/></svg>,
  utensils:(p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M5 3v7a2 2 0 0 0 4 0V3M7 10v11M16 3c-1.5 0-3 1.5-3 5 0 2 1 3 2 3v10"/></svg>,
  receipt: (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M5 3h14v18l-3-2-2 2-2-2-2 2-2-2-3 2z"/><path d="M8 8h8M8 12h8M8 16h5"/></svg>,
  users:   (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><circle cx="9" cy="8" r="3.4"/><path d="M3 20c0-3.3 2.7-5.5 6-5.5s6 2.2 6 5.5"/><path d="M16 5a3.2 3.2 0 0 1 0 6.2M18 20c0-2.6-1-4.4-2.6-5.3"/></svg>,
  megaphone:(p={})=> <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 11v2a1 1 0 0 0 1 1h2l5 4V6L6 10H4a1 1 0 0 0-1 1z"/><path d="M16 8a5 5 0 0 1 0 8"/><path d="M7 14v4a1.5 1.5 0 0 0 3 0v-2"/></svg>,
  trophy:  (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M8 21h8M12 17v4M6 4h12v4a6 6 0 0 1-12 0z"/><path d="M18 5h3v2a3 3 0 0 1-3 3M6 5H3v2a3 3 0 0 0 3 3"/></svg>,
  settings:(p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="3"/><path d="M12 2v3M12 19v3M22 12h-3M5 12H2M19 5l-2 2M7 17l-2 2M19 19l-2-2M7 7 5 5"/></svg>,
  target:  (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2}><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.4" fill={p.c||'currentColor'}/></svg>,
  trendUp: (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 17 10 10l4 4 7-7"/><path d="M15 7h6v6"/></svg>,
  trendDown:(p={})=> <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 7 10 14l4-4 7 7"/><path d="M15 17h6v-6"/></svg>,
  flat:    (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round"><path d="M4 12h16"/></svg>,
  pound:   (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M7 21h11M7 21c2-1 2.5-3 2.5-5V9.5a3.5 3.5 0 0 1 7 0M6 13h8"/></svg>,
  tag:     (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 12V4a1 1 0 0 1 1-1h8l8 8-9 9-8-8z"/><circle cx="7.5" cy="7.5" r="1.4" fill={p.c||'currentColor'} stroke="none"/></svg>,
  refresh: (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 12a9 9 0 0 1 15-6.7L21 8"/><path d="M21 4v4h-4"/><path d="M21 12a9 9 0 0 1-15 6.7L3 16"/><path d="M3 20v-4h4"/></svg>,
  bell:    (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10 21a2 2 0 0 0 4 0"/></svg>,
  search:  (p={}) => <svg width={p.s||20} height={p.s||20} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>,
  x:       (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.4} strokeLinecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>,
  check:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.8} strokeLinecap="round" strokeLinejoin="round"><path d="M5 12.5 10 17 19 7.5"/></svg>,
  plus:    (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.6} strokeLinecap="round"><path d="M12 5v14M5 12h14"/></svg>,
  chevR:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.4} strokeLinecap="round" strokeLinejoin="round"><path d="m9 6 6 6-6 6"/></svg>,
  chevD:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.4} strokeLinecap="round" strokeLinejoin="round"><path d="m6 9 6 6 6-6"/></svg>,
  arrow:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14m-6-6 6 6-6 6"/></svg>,
  clock:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="9"/><path d="M12 7.5v5l3.5 2"/></svg>,
  pin:     (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M12 22s-7-7.3-7-13a7 7 0 1 1 14 0c0 5.7-7 13-7 13z"/><circle cx="12" cy="9" r="2.5"/></svg>,
  flame:   (p={}) => <svg width={p.s||16} height={p.s||16} viewBox="0 0 24 24" fill={p.f?(p.c||'currentColor'):'none'} stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M12 2c1 5-3 5-3 9a3 3 0 0 0 6 0c0-1-1-2-1-3 2 1 4 3 4 6a6 6 0 1 1-12 0c0-4 4-6 6-12z"/></svg>,
  shield:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M12 3 5 6v5c0 4.5 3 8 7 10 4-2 7-5.5 7-10V6z"/><path d="m9 12 2 2 4-4" strokeLinecap="round"/></svg>,
  eyeOff:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M10.6 6.2A9.9 9.9 0 0 1 12 6c6 0 10 6 10 6a16 16 0 0 1-2.6 3M6.6 6.6A16 16 0 0 0 2 12s4 6 10 6a9.5 9.5 0 0 0 3.4-.6"/><path d="m2 2 20 20M9.9 9.9a3 3 0 0 0 4.2 4.2"/></svg>,
  lock:    (p={}) => <svg width={p.s||16} height={p.s||16} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2}><rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></svg>,
  sparkle: (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.f?(p.c||'currentColor'):'none'} stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M12 3l1.8 4.9L19 9.7l-5.2 1.8L12 16l-1.8-4.5L5 9.7l5.2-1.8z"/><path d="M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"/></svg>,
  gift:    (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><rect x="3" y="9" width="18" height="5" rx="1"/><path d="M5 14v7h14v-7M12 9v12"/><path d="M12 9C12 6 10.5 4 8.5 4S6 5.5 7 7s5 2 5 2zM12 9c0-3 1.5-5 3.5-5S18 5.5 17 7s-5 2-5 2z"/></svg>,
  truck:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 6h11v9H3zM14 9h4l3 3v3h-7z"/><circle cx="7" cy="18" r="2"/><circle cx="17" cy="18" r="2"/></svg>,
  sun:     (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4 12H2M22 12h-2M5 5l1.5 1.5M17.5 17.5 19 19M19 5l-1.5 1.5M6.5 17.5 5 19"/></svg>,
  crown:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M3 8l4 4 5-7 5 7 4-4-2 11H5z"/><path d="M5 21h14" strokeLinecap="round"/></svg>,
  rocket:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M5 15c-1 1-1.5 4-1.5 4s3-.5 4-1.5M9 11a8 8 0 0 1 9-7 8 8 0 0 1-7 9l-3 3-2-2z"/><circle cx="14.5" cy="9.5" r="1.4"/></svg>,
  layers:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="m12 3 9 5-9 5-9-5z"/><path d="m3 13 9 5 9-5M3 17l9 5 9-5" opacity="0.6"/></svg>,
  image:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="8.5" cy="9.5" r="1.6"/><path d="m4 17 5-5 4 4 3-3 4 4"/></svg>,
  alert:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M12 3 2 20h20z"/><path d="M12 9v5M12 17.5v.5"/></svg>,
  zap:     (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.f?(p.c||'currentColor'):'none'} stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M13 2 4 14h7l-1 8 9-12h-7z"/></svg>,
  filter:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M3 5h18l-7 9v6l-4-2v-4z"/></svg>,
  swords:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M14.5 14.5 21 21l-1 1-3 .5-.5-3-6.5-6.5M3 3l5 .5L8.5 8 14 13.5M3 3l.5 5L8 8.5"/><path d="m17.5 5.5 3-.5 1 1-6.5 6.5"/></svg>,
  droplet: (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.f?(p.c||'currentColor'):'none'} stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M12 3c4 5 7 8 7 11a7 7 0 0 1-14 0c0-3 3-6 7-11z"/></svg>,
  density: (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.c||'currentColor'} stroke="none"><circle cx="6" cy="6" r="1.5"/><circle cx="12" cy="5" r="1.5"/><circle cx="18" cy="7" r="1.5"/><circle cx="5" cy="12" r="1.5"/><circle cx="11" cy="12" r="1.8"/><circle cx="18" cy="13" r="1.5"/><circle cx="7" cy="18" r="1.5"/><circle cx="13" cy="18" r="1.5"/><circle cx="19" cy="19" r="1.5"/></svg>,
  pizza:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M12 3 3 8c2 7 6 12 9 13s7-6 9-13z"/><circle cx="10" cy="9" r="1" fill={p.c||'currentColor'}/><circle cx="14" cy="11" r="1" fill={p.c||'currentColor'}/><circle cx="11" cy="14" r="1" fill={p.c||'currentColor'}/></svg>,
  info:    (p={}) => <svg width={p.s||16} height={p.s||16} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 7.5v.5"/></svg>,
  star:    (p={}) => <svg width={p.s||14} height={p.s||14} viewBox="0 0 24 24" fill={p.c||'#E0992A'}><path d="M12 2 14.9 8.6 22 9.3l-5.4 4.7L18.2 21 12 17.3 5.8 21l1.6-7L2 9.3l7.1-.7z"/></svg>,
  calendar:(p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 9h18M8 3v4M16 3v4" strokeLinecap="round"/></svg>,
  play:    (p={}) => <svg width={p.s||16} height={p.s||16} viewBox="0 0 24 24" fill={p.c||'currentColor'} stroke="none"><path d="M7 4v16l13-8z"/></svg>,
  logout:  (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><path d="M14 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-4M10 8l-4 4 4 4M6 12h11"/></svg>,
  pause:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.c||'currentColor'} stroke="none"><rect x="6" y="5" width="4" height="14" rx="1"/><rect x="14" y="5" width="4" height="14" rx="1"/></svg>,
  stop:    (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.c||'currentColor'} stroke="none"><rect x="6" y="6" width="12" height="12" rx="2"/></svg>,
  bookmark:(p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill={p.f?(p.c||'currentColor'):'none'} stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinejoin="round"><path d="M6 4h12a1 1 0 0 1 1 1v16l-7-4-7 4V5a1 1 0 0 1 1-1z"/></svg>,
  compass: (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2} strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z" fill={p.c||'currentColor'}/></svg>,
  chevL:   (p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.4} strokeLinecap="round" strokeLinejoin="round"><path d="m15 6-6 6 6 6"/></svg>,
  maximize:(p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round" strokeLinejoin="round"><path d="M8 3H5a2 2 0 0 0-2 2v3M16 3h3a2 2 0 0 1 2 2v3M21 16v3a2 2 0 0 1-2 2h-3M3 16v3a2 2 0 0 0 2 2h3"/></svg>,
  minimize:(p={}) => <svg width={p.s||18} height={p.s||18} viewBox="0 0 24 24" fill="none" stroke={p.c||'currentColor'} strokeWidth={p.w||2.2} strokeLinecap="round" strokeLinejoin="round"><path d="M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3"/></svg>,
};

// ─── Wordmark ────────────────────────────────────────────────────────
function Wordmark({ color='var(--brand-orange)', size=20 }) {
  return <div style={{ fontFamily:'"Alfa Slab One", Georgia, serif', fontWeight:400, fontSize:size*1.4, lineHeight:1, letterSpacing:'0.02em', color, textTransform:'uppercase', userSelect:'none' }}>LASSO</div>;
}
function Bull({ size=34 }) {
  return <img src="bull-twotone.png" alt="" style={{ width:size, height:'auto', display:'block' }} draggable={false}/>;
}

// ─── Eyebrow ─────────────────────────────────────────────────────────
function Eyebrow({ children, color='var(--warm-stone)', style={} }) {
  return <div style={{ fontFamily:'var(--font-display)', fontWeight:700, fontSize:10.5, letterSpacing:'0.16em', textTransform:'uppercase', color, ...style }}>{children}</div>;
}

// ─── Card ────────────────────────────────────────────────────────────
function Card({ children, pad=20, style={}, hover=false, onClick, ...rest }) {
  const [h, setH] = React.useState(false);
  return (
    <div onClick={onClick} {...rest}
      onMouseEnter={hover?()=>setH(true):undefined} onMouseLeave={hover?()=>setH(false):undefined}
      style={{
        background:'rgba(255,251,245,0.68)', backdropFilter:'blur(14px) saturate(150%)', WebkitBackdropFilter:'blur(14px) saturate(150%)',
        border:'1px solid rgba(255,255,255,0.55)', borderRadius:18,
        padding:pad,
        boxShadow: h
          ? '0 22px 44px -20px rgba(27,18,13,0.45), inset 0 1px 0 rgba(255,255,255,0.65)'
          : '0 12px 32px -20px rgba(27,18,13,0.35), inset 0 1px 0 rgba(255,255,255,0.6)',
        transition:'box-shadow 200ms, transform 200ms, border-color 200ms',
        transform: h ? 'translateY(-2px)' : 'none', cursor: onClick?'pointer':'default',
        borderColor: h ? 'rgba(255,255,255,0.85)' : 'rgba(255,255,255,0.55)', ...style,
      }}>{children}</div>
  );
}

// ─── Status pill ─────────────────────────────────────────────────────
const PILL_TONE = {
  green:{ bg:'rgba(46,139,78,0.10)',  fg:'#247a41', bd:'rgba(46,139,78,0.28)' },
  blue: { bg:'rgba(62,124,176,0.11)', fg:'#2f6694', bd:'rgba(62,124,176,0.28)' },
  amber:{ bg:'rgba(224,153,42,0.13)', fg:'#a86d12', bd:'rgba(224,153,42,0.32)' },
  red:  { bg:'rgba(193,59,31,0.10)',  fg:'#b0341a', bd:'rgba(193,59,31,0.26)' },
  purple:{bg:'rgba(122,87,201,0.11)', fg:'#6243ad', bd:'rgba(122,87,201,0.28)' },
  grey: { bg:'rgba(124,103,91,0.10)', fg:'#7C675B', bd:'rgba(124,103,91,0.26)' },
  orange:{bg:'rgba(216,90,20,0.10)',  fg:'#c0500f', bd:'rgba(216,90,20,0.30)' },
  dark: { bg:'var(--dark-chocolate)', fg:'var(--dust-cream)', bd:'rgba(255,255,255,0.14)' },
};
function Pill({ tone='grey', children, dot=false, icon, solid=false, style={} }) {
  const t = PILL_TONE[tone] || PILL_TONE.grey;
  return (
    <span style={{
      display:'inline-flex', alignItems:'center', gap:5, padding:'2.5px 9px', borderRadius:999,
      background: solid ? t.fg : t.bg, color: solid ? '#fff' : t.fg,
      border:'1px solid', borderColor: solid ? 'transparent' : (t.bd||'transparent'),
      fontFamily:'var(--font-display)', fontWeight:700, fontSize:11, letterSpacing:'0.01em',
      whiteSpace:'nowrap', ...style,
    }}>
      {dot && <span style={{ width:6, height:6, borderRadius:'50%', background:'currentColor' }}/>}
      {icon}{children}
    </span>
  );
}

// ─── Trend chip ──────────────────────────────────────────────────────
function Trend({ dir, pct, size=13 }) {
  const map = { up:{c:'#247a41',Ic:I.trendUp,s:'+'}, down:{c:'#b0341a',Ic:I.trendDown,s:'−'}, flat:{c:'#7C675B',Ic:I.flat,s:''} };
  const m = map[dir] || map.flat;
  return (
    <span style={{ display:'inline-flex', alignItems:'center', gap:3, color:m.c, fontFamily:'var(--font-display)', fontWeight:800, fontSize:size }}>
      <m.Ic c={m.c} s={size+2}/>{dir!=='flat' && `${m.s}${pct}%`}{dir==='flat' && 'Flat'}
    </span>
  );
}

// ─── Progress bar ────────────────────────────────────────────────────
function Bar({ pct, color='var(--brand-orange)', h=8, track='rgba(27,18,13,0.07)', radius=999 }) {
  return (
    <div style={{ width:'100%', height:h, background:track, borderRadius:radius, overflow:'hidden' }}>
      <div style={{ width:`${Math.max(0,Math.min(100,pct))}%`, height:'100%', background:color, borderRadius:radius, transition:'width 420ms var(--ease-out)' }}/>
    </div>
  );
}

// ─── Sparkline (mini bar chart) ──────────────────────────────────────
function Spark({ data, color='var(--brand-orange)', h=34, w=84, bars=true }) {
  const max = Math.max(...data, 1);
  if (bars) {
    return (
      <div style={{ display:'flex', alignItems:'flex-end', gap:3, height:h, width:w }}>
        {data.map((d,i)=>(
          <div key={i} style={{ flex:1, height:`${Math.max(8, d/max*100)}%`, background:color, opacity: 0.4 + (i/data.length)*0.6, borderRadius:2 }}/>
        ))}
      </div>
    );
  }
  const pts = data.map((d,i)=>`${(i/(data.length-1))*w},${h-(d/max)*(h-3)-2}`).join(' ');
  return <svg width={w} height={h} style={{ display:'block' }}><polyline points={pts} fill="none" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/></svg>;
}

// ─── Toggle switch ───────────────────────────────────────────────────
function Toggle({ on, onChange, color='var(--brand-orange)' }) {
  return (
    <button onClick={()=>onChange(!on)} style={{
      width:38, height:22, borderRadius:999, border:'none', cursor:'pointer', padding:2, flexShrink:0,
      background: on ? color : 'rgba(27,18,13,0.14)', transition:'background 200ms', position:'relative',
    }}>
      <span style={{ display:'block', width:18, height:18, borderRadius:'50%', background:'#fff',
        boxShadow:'0 1px 3px rgba(0,0,0,0.25)', transform: on ? 'translateX(16px)' : 'translateX(0)', transition:'transform 200ms var(--ease-out)' }}/>
    </button>
  );
}

// ─── Range slider (branded) ──────────────────────────────────────────
function Slider({ value, min, max, step=1, onChange, color='var(--brand-orange)' }) {
  const pct = ((value-min)/(max-min))*100;
  return (
    <div style={{ position:'relative', height:24, display:'flex', alignItems:'center' }}>
      <div style={{ position:'absolute', left:0, right:0, height:6, borderRadius:999, background:'rgba(27,18,13,0.09)' }}/>
      <div style={{ position:'absolute', left:0, width:`${pct}%`, height:6, borderRadius:999, background:color }}/>
      <input type="range" min={min} max={max} step={step} value={value}
        onChange={(e)=>onChange(+e.target.value)}
        style={{ position:'absolute', left:0, right:0, width:'100%', margin:0, appearance:'none', WebkitAppearance:'none', background:'transparent', height:24, cursor:'pointer' }}/>
      <span style={{ position:'absolute', left:`calc(${pct}% - 9px)`, width:18, height:18, borderRadius:'50%', background:'#fff', border:`4px solid ${color}`, boxShadow:'0 1px 4px rgba(0,0,0,0.25)', pointerEvents:'none' }}/>
    </div>
  );
}

// ─── Segmented control ───────────────────────────────────────────────
function Segmented({ options, value, onChange, size='md' }) {
  const pad = size==='sm' ? '6px 11px' : '8px 14px';
  const fs = size==='sm' ? 12 : 13;
  return (
    <div style={{ display:'inline-flex', background:'rgba(27,18,13,0.05)', borderRadius:12, padding:3, gap:2 }}>
      {options.map(o=>{
        const v = typeof o==='string'?o:o.value, l = typeof o==='string'?o:o.label;
        const on = v===value;
        return (
          <button key={v} onClick={()=>onChange(v)} style={{
            padding:pad, borderRadius:9, border:'none', cursor:'pointer',
            background: on ? 'var(--bg-surface)' : 'transparent',
            color: on ? 'var(--fg-primary)' : 'var(--warm-stone)',
            fontFamily:'var(--font-display)', fontWeight:700, fontSize:fs,
            boxShadow: on ? 'var(--shadow-sm)' : 'none', transition:'all 160ms', whiteSpace:'nowrap',
          }}>{l}</button>
        );
      })}
    </div>
  );
}

// ─── Icon button ─────────────────────────────────────────────────────
function IconBtn({ icon, onClick, badge, active=false }) {
  return (
    <button onClick={onClick} style={{
      width:40, height:40, borderRadius:12, border:'1px solid rgba(255,255,255,0.55)',
      background: active ? 'var(--bg-warm)' : 'rgba(255,251,245,0.62)', backdropFilter:'blur(10px) saturate(140%)', WebkitBackdropFilter:'blur(10px) saturate(140%)',
      cursor:'pointer', position:'relative',
      display:'flex', alignItems:'center', justifyContent:'center', boxShadow:'0 6px 18px -10px rgba(27,18,13,0.35), inset 0 1px 0 rgba(255,255,255,0.6)',
    }}>
      {icon}
      {badge && <span style={{ position:'absolute', top:8, right:9, width:8, height:8, borderRadius:'50%', background:'var(--brand-orange)', border:'2px solid var(--bg-surface)' }}/>}
    </button>
  );
}

// ─── Button ──────────────────────────────────────────────────────────
function Btn({ kind='primary', children, onClick, full=false, size='md', icon, disabled=false, style={} }) {
  const bg = { primary:'var(--dark-chocolate)', accent:'var(--brand-orange)', ghost:'transparent', soft:'var(--bg-warm)', white:'var(--bg-surface)' }[kind];
  const fg = { primary:'var(--dust-cream)', accent:'#fff', ghost:'var(--fg-primary)', soft:'var(--horse-brown)', white:'var(--fg-primary)' }[kind];
  const pad = { sm:'8px 13px', md:'11px 17px', lg:'14px 22px' }[size];
  const fs = { sm:12.5, md:13.5, lg:15 }[size];
  return (
    <button onClick={disabled?undefined:onClick} disabled={disabled} style={{
      background:bg, color:fg, border: kind==='ghost'||kind==='white' ? '1px solid var(--soft-line)' : 'none',
      padding:pad, borderRadius:12, fontFamily:'var(--font-display)', fontWeight:800, fontSize:fs, letterSpacing:'0.01em',
      cursor:disabled?'not-allowed':'pointer', width: full?'100%':undefined, opacity:disabled?0.45:1,
      display:'inline-flex', alignItems:'center', justifyContent:'center', gap:7, whiteSpace:'nowrap',
      boxShadow: kind==='accent'&&!disabled ? 'var(--shadow-orange)' : (kind==='primary'?'var(--shadow-sm)':'none'),
      transition:'transform 130ms, opacity 130ms', WebkitTapHighlightColor:'transparent', ...style,
    }}
    onMouseDown={(e)=>!disabled&&(e.currentTarget.style.transform='scale(0.97)')}
    onMouseUp={(e)=>e.currentTarget.style.transform=''} onMouseLeave={(e)=>e.currentTarget.style.transform=''}>
      {icon}{children}
    </button>
  );
}

// ─── Donut / ring gauge ──────────────────────────────────────────────
function Ring({ pct, size=60, stroke=7, color='var(--brand-orange)', track='rgba(27,18,13,0.08)', children }) {
  const r = (size-stroke)/2, c = 2*Math.PI*r, off = c*(1-pct/100);
  return (
    <div style={{ position:'relative', width:size, height:size }}>
      <svg width={size} height={size} style={{ transform:'rotate(-90deg)' }}>
        <circle cx={size/2} cy={size/2} r={r} fill="none" stroke={track} strokeWidth={stroke}/>
        <circle cx={size/2} cy={size/2} r={r} fill="none" stroke={color} strokeWidth={stroke} strokeLinecap="round"
          strokeDasharray={c} strokeDashoffset={off} style={{ transition:'stroke-dashoffset 600ms var(--ease-out)' }}/>
      </svg>
      {children && <div style={{ position:'absolute', inset:0, display:'flex', alignItems:'center', justifyContent:'center' }}>{children}</div>}
    </div>
  );
}

// ─── Page header ─────────────────────────────────────────────────────
function PageHead({ eyebrow, title, sub, right }) {
  return (
    <div style={{ display:'flex', alignItems:'flex-end', justifyContent:'space-between', gap:20, marginBottom:22 }}>
      <div>
        {eyebrow && <Eyebrow style={{ marginBottom:7 }}>{eyebrow}</Eyebrow>}
        <h1 style={{ margin:0, fontFamily:'var(--font-display)', fontWeight:900, fontSize:28, letterSpacing:'-0.02em', color:'var(--fg-primary)', lineHeight:1 }}>{title}</h1>
        {sub && <div style={{ marginTop:8, fontFamily:'var(--font-body)', fontSize:14, color:'var(--warm-stone)' }}>{sub}</div>}
      </div>
      {right}
    </div>
  );
}

Object.assign(window, {
  I, Wordmark, Bull, Eyebrow, Card, Pill, PILL_TONE, Trend, Bar, Spark,
  Toggle, Slider, Segmented, IconBtn, Btn, Ring, PageHead,
});
