// For Care Workers, For Facilities, For Agencies — one variation each,
// plus lightweight tweak to show interaction (accordion/tabs).

// SF Symbol-style stroke icons (1.6px, rounded caps, current color)
function WalletIcon({ size = 22 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M3 8.5C3 7.12 4.12 6 5.5 6h13A2.5 2.5 0 0 1 21 8.5v9A2.5 2.5 0 0 1 18.5 20h-13A2.5 2.5 0 0 1 3 17.5v-9Z" />
      <path d="M3 9h18" />
      <circle cx="16.5" cy="14" r="1.1" fill="currentColor" stroke="none" />
    </svg>);

}
function BadgeCheckIcon({ size = 22 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M12 2.5 14.2 4.4l2.9-.4.4 2.9 2.5 1.6-1.2 2.7 1.2 2.7-2.5 1.6-.4 2.9-2.9-.4L12 21.5l-2.2-1.9-2.9.4-.4-2.9-2.5-1.6 1.2-2.7L4 10.1l2.5-1.6.4-2.9 2.9.4L12 2.5Z" />
      <path d="m9 12 2.2 2.2L15.4 10" />
    </svg>);

}
function QrShareIcon({ size = 22 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <rect x="3.5" y="3.5" width="6" height="6" rx="1.4" />
      <rect x="14.5" y="3.5" width="6" height="6" rx="1.4" />
      <rect x="3.5" y="14.5" width="6" height="6" rx="1.4" />
      <path d="M14.5 14.5h2v2" />
      <path d="M20.5 14.5v6h-6" />
      <path d="M18.5 18.5h2" />
      <circle cx="6.5" cy="6.5" r="1" fill="currentColor" stroke="none" />
      <circle cx="17.5" cy="6.5" r="1" fill="currentColor" stroke="none" />
      <circle cx="6.5" cy="17.5" r="1" fill="currentColor" stroke="none" />
    </svg>);

}

// Small uniform headshot avatars — seeded deterministic variations.
function MiniAvatar({ seed = 0, size = 28 }) {
  const skins = ['#f5d6b3', '#e8c19a', '#d4a574', '#b78660', '#8b5e3c'];
  const hairs = ['#2c1810', '#4a3020', '#8b5a2b', '#c4a484', '#6b4423', '#1a1a1a', '#d4a574'];
  const uniforms = ['#2a6cb7', '#1f7a6a', '#5a4a8f', '#8b3a5f', '#2c5f8d', '#3d7a5a'];
  const skin = skins[seed % skins.length];
  const hair = hairs[seed * 3 % hairs.length];
  const uni = uniforms[seed * 5 % uniforms.length];
  const hairStyle = seed % 4; // 0 short, 1 long/tied, 2 bun, 3 buzz
  const id = `av-${seed}`;
  return (
    <div style={{ width: size, height: size, borderRadius: size / 2, overflow: 'hidden', flexShrink: 0, boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.06)' }}>
      <svg viewBox="0 0 60 60" width={size} height={size}>
        <defs>
          <linearGradient id={id} x1="0" x2="0" y1="0" y2="1">
            <stop offset="0%" stopColor="#eee4d4" />
            <stop offset="100%" stopColor="#d4c4a8" />
          </linearGradient>
        </defs>
        <rect width="60" height="60" fill={`url(#${id})`} />
        {/* uniform/shoulders */}
        <path d="M0,60 Q30,36 60,60 Z" fill={uni} />
        {/* neck */}
        <rect x="25" y="34" width="10" height="10" fill={skin} />
        {/* head */}
        <circle cx="30" cy="26" r="12" fill={skin} />
        {/* hair */}
        {hairStyle === 0 && <path d="M18,20 Q30,8 42,20 L42,24 Q30,17 18,24 Z" fill={hair} />}
        {hairStyle === 1 && <>
          <path d="M18,22 Q30,8 42,22 L42,26 Q30,19 18,26 Z" fill={hair} />
          <ellipse cx="30" cy="40" rx="7" ry="4" fill={hair} />
        </>}
        {hairStyle === 2 && <>
          <circle cx="30" cy="14" r="6" fill={hair} />
          <path d="M20,22 Q30,16 40,22 L40,24 Q30,20 20,24 Z" fill={hair} />
        </>}
        {hairStyle === 3 && <path d="M19,22 Q30,12 41,22 L41,23 Q30,19 19,23 Z" fill={hair} opacity="0.8" />}
        {/* eyes + smile */}
        <circle cx="26" cy="26" r="1.2" fill="#1d1d1f" />
        <circle cx="34" cy="26" r="1.2" fill="#1d1d1f" />
        <path d="M26,31 Q30,33 34,31" stroke="#1d1d1f" strokeWidth="1" fill="none" strokeLinecap="round" />
      </svg>
    </div>);

}

function PortabilityIllustration() {
  const [phase, setPhase] = React.useState(0); // 0: at Home A, 1: transit, 2: at Home B
  React.useEffect(() => {
    const id = setInterval(() => setPhase((p) => (p + 1) % 3), 2200);
    return () => clearInterval(id);
  }, []);

  const House = ({ name, sub, active, dimmed, color }) =>
  <div style={{
    display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10,
    opacity: dimmed ? 0.45 : 1, transition: 'opacity .6s ease'
  }}>
      <div style={{ position: 'relative' }}>
        <svg viewBox="0 0 100 90" width="110" height="99">
          <path d="M50 8 L92 42 L92 82 L8 82 L8 42 Z" fill={color} stroke={WF.ink} strokeWidth="1.5" strokeLinejoin="round" />
          <path d="M50 8 L92 42 L8 42 Z" fill={WF.ink} opacity="0.08" />
          <rect x="40" y="54" width="20" height="28" fill={WF.paper} stroke={WF.ink} strokeWidth="1" />
          <circle cx="56" cy="68" r="1.3" fill={WF.ink} />
          <rect x="18" y="52" width="14" height="12" fill={WF.paper} stroke={WF.ink} strokeWidth="1" />
          <rect x="68" y="52" width="14" height="12" fill={WF.paper} stroke={WF.ink} strokeWidth="1" />
          <path d="M18 52 L32 52 M18 58 L32 58" stroke={WF.ink} strokeWidth="0.6" opacity="0.5" />
          <path d="M68 52 L82 52 M68 58 L82 58" stroke={WF.ink} strokeWidth="0.6" opacity="0.5" />
          <rect x="46" y="2" width="3" height="10" fill={WF.ink} />
          <path d="M49 3 L58 6 L49 9 Z" fill={WF.accent} />
        </svg>
        {active &&
      <div style={{
        position: 'absolute', top: -6, right: -6,
        width: 22, height: 22, borderRadius: 11, background: WF.ok, color: 'white',
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        fontSize: 13, fontWeight: 600, boxShadow: '0 2px 6px rgba(0,0,0,.15)',
        animation: 'pi-pulse 1.8s ease-out infinite'
      }}>✓</div>
      }
      </div>
      <div style={{ textAlign: 'center' }}>
        <div style={{ fontSize: 13, fontWeight: 600 }}>{name}</div>
        <div className="wf-small" style={{ fontSize: 11, marginTop: 2 }}>{sub}</div>
      </div>
    </div>;


  // Wallet position along arc: phase 0 → left of arc, phase 1 → middle, phase 2 → right
  const walletX = phase === 0 ? 18 : phase === 1 ? 50 : 82; // percent
  const walletY = phase === 1 ? 8 : 38; // percent from top of arc container

  return (
    <div style={{
      position: 'relative', height: 360, padding: 24,
      background: `linear-gradient(180deg, ${WF.fill2} 0%, ${WF.paper} 100%)`,
      border: `1px solid ${WF.line2}`, borderRadius: 16, overflow: 'hidden'
    }}>
      <style>{`
        @keyframes pi-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
        @keyframes pi-float { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-3px) rotate(-3deg); } }
        @keyframes pi-dash { to { stroke-dashoffset: -20; } }
      `}</style>

      {/* Eyebrow pill */}
      <div style={{
        position: 'absolute', top: 16, left: 16,
        fontSize: 10, letterSpacing: 1.4, textTransform: 'uppercase',
        color: WF.ink2, background: WF.paper, padding: '5px 10px',
        borderRadius: 999, border: `1px solid ${WF.line2}`, fontWeight: 600
      }}>Your wallet · always with you</div>

      {/* Arc path */}
      <svg viewBox="0 0 600 200" preserveAspectRatio="none" style={{
        position: 'absolute', left: 0, right: 0, top: 60, width: '100%', height: 140, pointerEvents: 'none'
      }}>
        <path d="M 110 150 Q 300 20 490 150" fill="none" stroke={WF.accent} strokeWidth="2"
        strokeDasharray="5 5" strokeLinecap="round"
        style={{ animation: 'pi-dash 1.2s linear infinite' }} />
      </svg>

      {/* Houses + wallet */}
      <div style={{
        position: 'absolute', left: 0, right: 0, top: 80, bottom: 80,
        display: 'flex', alignItems: 'center', justifyContent: 'space-around'
      }}>
        <House name="Maple Grove LTC" sub="Former home" color="#e8d4b8" active={phase === 0} dimmed={phase === 2} />
        <House name="Cedar Park Retirement" sub="New home" color="#c8dcc0" active={phase === 2} dimmed={phase === 0} />
      </div>

      {/* Traveling wallet */}
      <div style={{
        position: 'absolute', left: `${walletX}%`, top: `${walletY}%`,
        transform: 'translate(-50%, -50%)',
        transition: 'left 1.6s cubic-bezier(.6,.1,.4,.9), top 1.6s cubic-bezier(.6,.1,.4,.9)',
        animation: 'pi-float 2.4s ease-in-out infinite'
      }}>
        <div style={{
          width: 110, background: WF.paper, borderRadius: 12,
          boxShadow: '0 10px 24px rgba(0,0,0,.15), 0 2px 6px rgba(0,0,0,.08)',
          border: `1px solid ${WF.line2}`, padding: 10
        }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 8 }}>
            <div style={{ width: 20, height: 20, borderRadius: 4, background: WF.accent, color: 'white',
              display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 11, fontWeight: 700 }}>C</div>
            <div style={{ fontSize: 10, fontWeight: 600 }}>Julian's Credz</div>
          </div>
          {[1, 2, 3].map((i) =>
          <div key={i} style={{
            display: 'flex', alignItems: 'center', gap: 5,
            padding: '4px 6px', background: WF.fill, borderRadius: 4, marginBottom: 3
          }}>
              <div style={{ width: 5, height: 5, borderRadius: 3, background: WF.ok }} />
              <div style={{ flex: 1, height: 4, background: WF.line2, borderRadius: 2 }} />
              <div style={{ fontSize: 8, color: WF.ok }}>✓</div>
            </div>
          )}
          <div style={{ fontSize: 8, color: WF.ink2, marginTop: 4, textAlign: 'center' }}>18 verified docs</div>
        </div>
      </div>

      {/* Caption bottom */}
      <div style={{
        position: 'absolute', bottom: 16, left: 0, right: 0, textAlign: 'center'
      }}>
        <div className="wf-small" style={{ fontSize: 11 }}>
          <span style={{ color: WF.ok, fontWeight: 600 }}>No re-uploads.</span>{' '}
          <span style={{ color: WF.ok, fontWeight: 600 }}>No lost files.</span>{' '}
          <span style={{ color: WF.ok, fontWeight: 600 }}>One wallet, for life.</span>
        </div>
      </div>
    </div>);

}

function ForCareWorkers() {
  const [openFaq, setOpenFaq] = React.useState(0);
  const faqs = [
  ['Is Credz free for care workers?', 'Yes, 100%. You pay nothing to build and share your Credz wallet. '],
  ['How long does verification take?', 'Most issuing bodies verify in under 24 hours. Some take up to 3 business days.'],
  ['Can I use Credz across provinces?', 'We currently support Ontario only. We\'re actively working on adding the other provinces — stay tuned.'],
  ['How secure are my credentials?', 'Extremely. Credz is 100% Canadian — built in Canada, by Canadians, hosted in Canada. Your data lives in AWS Canada (Central) and never leaves Canadian soil, keeping us fully aligned with PHIPA (Ontario) and PIPEDA (federal). Every document is protected by AES-256 at-rest encryption and TLS 1.2+ in transit, so your files are unreadable to anyone — including us — without your authorization. We verify credentials directly with provincial registries (CNO, HSCPOA, and more) so what\u2019s in your wallet is always authentic and audit-ready. You own your wallet: homes and agencies can only see your documents after you grant them access through an explicit, time-stamped Digital Handshake, and you can revoke that access in one tap. Behind the scenes we run continuous SOC 2 and HIPAA-aligned monitoring with full audit logging on every interaction.'],
  ['What if I leave the profession?', 'Your wallet is yours. Download everything and revoke access at any time.']];

  return (
    <div className="wf-page wf">
      <Chrome url="credz.health/care-workers" />
      <Nav active="Care Workers" />

      <div className="wf-section hero" style={{ display: 'grid', gridTemplateColumns: '1.05fr 1fr', gap: 56, alignItems: 'center' }}>
        <div>
          <Chip tone="accent">For the people who care</Chip>
          <h1 className="wf-h1" style={{ marginTop: 18, marginBottom: 18, fontSize: 60 }}>
            Your digital<br />passport for care.
          </h1>
          <p className="wf-sub" style={{ maxWidth: 460, marginBottom: 28 }}>
            Stop emailing docs to every home and agency. One consolidated, secure wallet for every license, test and certificate — verified by Credz, shared with a single QR tap.
          </p>
          <div style={{ display: 'flex', gap: 12, marginBottom: 24 }}>
            <Btn variant="accent" size="lg">Create my free Credz wallet</Btn>
            <Btn size="lg" variant="ghost">Watch 60-sec demo →</Btn>
          </div>
          <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
            <Placeholder label="App Store" w={132} h={40} radius={8} />
            <Placeholder label="Google Play" w={132} h={40} radius={8} />
          </div>
        </div>
        <div style={{ display: 'flex', justifyContent: 'center', gap: 20, position: 'relative' }}>
          <div className="wf-phone" style={{ transform: 'translateY(20px) rotate(-3deg)' }}>
            <div className="screen">
              <div style={{ padding: 16 }}>
                <div style={{ width: 60, height: 60, borderRadius: 30, margin: '8px auto 10px', overflow: 'hidden', boxShadow: '0 2px 8px rgba(0,0,0,.15)' }}>
                  <svg viewBox="0 0 60 60" width="60" height="60">
                    <defs>
                      <linearGradient id="avJ" x1="0" x2="0" y1="0" y2="1">
                        <stop offset="0%" stopColor="#e3d5c8" />
                        <stop offset="100%" stopColor="#c7a98b" />
                      </linearGradient>
                    </defs>
                    <rect width="60" height="60" fill="url(#avJ)" />
                    {/* shoulders */}
                    <path d="M0,60 Q30,36 60,60 Z" fill="#2a6cb7" />
                    {/* neck */}
                    <rect x="25" y="34" width="10" height="10" fill="#c7a98b" />
                    {/* head */}
                    <circle cx="30" cy="26" r="12" fill="#d9bda0" />
                    {/* hair */}
                    <path d="M18,20 Q30,8 42,20 L42,24 Q30,17 18,24 Z" fill="#3a2a1e" />
                    {/* eyes */}
                    <circle cx="26" cy="26" r="1.2" fill="#1d1d1f" />
                    <circle cx="34" cy="26" r="1.2" fill="#1d1d1f" />
                    {/* smile */}
                    <path d="M26,31 Q30,33 34,31" stroke="#1d1d1f" strokeWidth="1" fill="none" strokeLinecap="round" />
                  </svg>
                </div>
                <div style={{ textAlign: 'center', fontWeight: 600, fontSize: 14 }}>Julian Thorne, RN</div>
                <div className="wf-small" style={{ textAlign: 'center', marginTop: 2, marginBottom: 16 }}>CREDZ ID · C0122-54276</div>
                <div style={{ width: 100, height: 100, margin: '0 auto', background: 'white', padding: 6, borderRadius: 8, boxShadow: '0 2px 6px rgba(0,0,0,.08)' }}>
                  <img src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https%3A%2F%2Fmycredz.ca&margin=0" alt="QR: mycredz.ca" style={{ width: '100%', height: '100%', display: 'block' }} />
                </div>
                <Btn variant="primary" size="sm" style={{ width: '100%', marginTop: 16 }}>Share Wallet</Btn>
              </div>
            </div>
          </div>
          <div className="wf-phone" style={{ transform: 'translateY(-20px) rotate(4deg)' }}>
            <div className="screen">
              <div style={{ padding: 14 }}>
                <div className="wf-display" style={{ fontSize: 14, marginBottom: 10 }}>Documents</div>
                <div style={{ height: 5, background: WF.line2, borderRadius: 3, marginBottom: 4 }}>
                  <div style={{ width: '83%', height: 5, background: WF.accent, borderRadius: 3 }} />
                </div>
                <div className="wf-small" style={{ marginBottom: 10 }}>83% · 15 of 18 verified</div>
                {['RN License', 'CPR Level C', 'TB Skin Test', 'WHMIS'].map((d, i) =>
                <div key={d} style={{ display: 'flex', justifyContent: 'space-between', padding: '6px 10px', borderRadius: 7, background: WF.fill, marginBottom: 4, fontSize: 11 }}>
                    <span>{d}</span>
                    <span style={{ color: i < 3 ? WF.ok : WF.warn }}>{i < 3 ? '✓' : '⚠'}</span>
                  </div>
                )}
                <Btn variant="primary" size="sm" style={{ width: '100%', marginTop: 10, padding: '8px 12px', fontSize: 12 }}>Link with Home</Btn>
              </div>
            </div>
          </div>
        </div>
      </div>

      {/* Features — 3 */}
      <div className="wf-section" style={{ background: WF.fill2 }}>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 20 }}>
          {[
          [<WalletIcon />, 'One wallet, not ten inboxes', 'Stop gathering and emailing docs for every new home. Everything lives in one secure Credz wallet.'],
          [<BadgeCheckIcon />, 'Verified by a human', 'Every document is manually reviewed and stamped with an integrity check. The home trusts what they see.'],
          [<QrShareIcon />, 'Share with a QR tap', 'Scan once at onboarding. The home links to your live wallet — no PDFs, no email chains.']].
          map(([icon, t, d]) =>
          <div key={t} className="wf-card" style={{ padding: 28 }}>
              <div style={{ width: 44, height: 44, borderRadius: 12, background: WF.accentSoft, color: WF.accent, display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: 16 }}>{icon}</div>
              <div className="wf-h4" style={{ marginBottom: 8 }}>{t}</div>
              <p className="wf-body" style={{ fontSize: 14 }}>{d}</p>
            </div>
          )}
        </div>
      </div>

      {/* Own your data */}
      <div className="wf-section">
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 56, alignItems: 'center' }}>
          <PortabilityIllustration />
          <div>
            <Eyebrow>True portability</Eyebrow>
            <h2 className="wf-h2" style={{ marginTop: 14, marginBottom: 16, maxWidth: 420 }}>
              You change homes. Your record doesn't.
            </h2>
            <p className="wf-sub" style={{ marginBottom: 24, maxWidth: 440 }}>
              Leave a home. Join an agency. Go freelance. Your Credz wallet comes with you — no re-uploads, no lost files.
            </p>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
              {['Your credentials are owned by you, not your employer', 'Revoke facility access at any time', 'Download a full PDF binder whenever you want'].map((b) =>
              <div key={b} style={{ display: 'flex', gap: 10, alignItems: 'flex-start' }}>
                  <div style={{ width: 20, height: 20, borderRadius: 10, background: WF.accentSoft, display: 'flex', alignItems: 'center', justifyContent: 'center', color: WF.accent, fontSize: 12, marginTop: 2 }}>✓</div>
                  <div style={{ fontSize: 15 }}>{b}</div>
                </div>
              )}
            </div>
          </div>
        </div>
      </div>

      {/* Share in one tap */}
      <div className="wf-section">
        <Eyebrow>Share in one tap</Eyebrow>
        <h2 className="wf-h2" style={{ marginTop: 12, marginBottom: 10, maxWidth: 720 }}>From your wallet to the home's system. In seconds.

        </h2>
        <p className="wf-sub" style={{ maxWidth: 560, marginBottom: 40 }}>
          Scan a QR. The home pulls your live, verified Credz wallet — every document, every expiry, every integrity stamp.
        </p>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 2fr 1fr', gap: 32, alignItems: 'center' }}>
          <div style={{ display: 'flex', justifyContent: 'center' }}>
            <div className="wf-phone">
              <div className="screen">
                <div style={{ padding: 16, textAlign: 'center' }}>
                  <div style={{ width: 60, height: 60, borderRadius: 30, margin: '8px auto 10px', overflow: 'hidden', boxShadow: '0 2px 8px rgba(0,0,0,.15)' }}>
                    <svg viewBox="0 0 60 60" width="60" height="60">
                      <defs>
                        <linearGradient id="avJ2" x1="0" x2="0" y1="0" y2="1">
                          <stop offset="0%" stopColor="#e3d5c8" />
                          <stop offset="100%" stopColor="#c7a98b" />
                        </linearGradient>
                      </defs>
                      <rect width="60" height="60" fill="url(#avJ2)" />
                      <path d="M0,60 Q30,36 60,60 Z" fill="#2a6cb7" />
                      <rect x="25" y="34" width="10" height="10" fill="#c7a98b" />
                      <circle cx="30" cy="26" r="12" fill="#d9bda0" />
                      <path d="M18,20 Q30,8 42,20 L42,24 Q30,17 18,24 Z" fill="#3a2a1e" />
                      <circle cx="26" cy="26" r="1.2" fill="#1d1d1f" />
                      <circle cx="34" cy="26" r="1.2" fill="#1d1d1f" />
                      <path d="M26,31 Q30,33 34,31" stroke="#1d1d1f" strokeWidth="1" fill="none" strokeLinecap="round" />
                    </svg>
                  </div>
                  <div style={{ fontWeight: 600, fontSize: 14 }}>Julian Thorne, RN</div>
                  <div className="wf-small" style={{ marginTop: 2, marginBottom: 14 }}>CREDZ ID · C0122-54276</div>
                  <div style={{ width: 120, height: 120, margin: '0 auto 14px', background: 'white', padding: 7, borderRadius: 8, boxShadow: '0 2px 6px rgba(0,0,0,.08)' }}>
                    <img src="https://api.qrserver.com/v1/create-qr-code/?size=240x240&data=https%3A%2F%2Fmycredz.ca&margin=0" alt="QR: mycredz.ca" style={{ width: '100%', height: '100%', display: 'block' }} />
                  </div>
                  <div className="wf-small">Maple Grove is scanning…</div>
                </div>
              </div>
            </div>
          </div>
          <div style={{ textAlign: 'center' }}>
            <div style={{ height: 2, background: `linear-gradient(to right, ${WF.line2}, ${WF.accent}, ${WF.line2})`, marginBottom: 12 }} />
            <div className="wf-hand" style={{ color: WF.accent, fontSize: 20 }}>live, verified, tamper-proof →</div>
            <div className="wf-small" style={{ marginTop: 8 }}>No emails. No PDFs. No re-uploads.</div>
          </div>
          <div className="wf-card" style={{ padding: 16 }}>
            <div className="wf-small" style={{ marginBottom: 8 }}>Maple Grove · Admin view</div>
            <div style={{ padding: 14, background: WF.okSoft, borderRadius: 10, marginBottom: 10, textAlign: 'center', border: `1px solid ${WF.ok}33` }}>
              <div style={{ width: 36, height: 36, borderRadius: 18, background: WF.ok, color: 'white', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontSize: 18, fontWeight: 600, marginBottom: 8 }}>✓</div>
              <div style={{ fontWeight: 600, fontSize: 13, color: WF.ok, marginBottom: 3 }}>Success.</div>
              <div style={{ fontSize: 11, color: WF.ink2, lineHeight: 1.4 }}>Julian Thorne, RN is now added to your home.</div>
            </div>
            <div style={{ display: 'flex', gap: 10, alignItems: 'center', padding: 10, background: WF.fill2, borderRadius: 8, marginBottom: 8, border: `1px solid ${WF.line2}` }}>
              <div style={{ width: 28, height: 28, borderRadius: 14, overflow: 'hidden' }}>
                <svg viewBox="0 0 60 60" width="28" height="28">
                  <defs><linearGradient id="avJ3" x1="0" x2="0" y1="0" y2="1"><stop offset="0%" stopColor="#e3d5c8" /><stop offset="100%" stopColor="#c7a98b" /></linearGradient></defs>
                  <rect width="60" height="60" fill="url(#avJ3)" />
                  <path d="M0,60 Q30,36 60,60 Z" fill="#2a6cb7" />
                  <rect x="25" y="34" width="10" height="10" fill="#c7a98b" />
                  <circle cx="30" cy="26" r="12" fill="#d9bda0" />
                  <path d="M18,20 Q30,8 42,20 L42,24 Q30,17 18,24 Z" fill="#3a2a1e" />
                  <circle cx="26" cy="26" r="1.2" fill="#1d1d1f" />
                  <circle cx="34" cy="26" r="1.2" fill="#1d1d1f" />
                  <path d="M26,31 Q30,33 34,31" stroke="#1d1d1f" strokeWidth="1" fill="none" strokeLinecap="round" />
                </svg>
              </div>
              <div style={{ fontSize: 12 }}>
                <div style={{ fontWeight: 600 }}>Julian Thorne</div>
                <div style={{ color: WF.ok }}>✓ 18/18 verified</div>
              </div>
            </div>
            {['RN License', 'CPR · TB · WHMIS'].map((d) =>
            <div key={d} style={{ padding: 8, background: WF.fill, borderRadius: 6, fontSize: 11, marginBottom: 4 }}>{d}</div>
            )}
          </div>
        </div>
      </div>

      {/* Unlink in one tap */}
      <div className="wf-section">
        <Eyebrow>Unlink in one tap</Eyebrow>
        <h2 className="wf-h2" style={{ marginTop: 12, marginBottom: 10, maxWidth: 720 }}>
          Leave a home? Take your wallet with you.
        </h2>
        <p className="wf-sub" style={{ maxWidth: 620, marginBottom: 40 }}>
          When you stop working for a home, open your Credz wallet, tap the <b>Links</b> tab, select the home, and tap <b>Unlink</b>. The home instantly loses access to your credentials — and your record leaves with you.
        </p>
        <UnlinkFlowDemo />
      </div>

      {/* FAQ */}
      <div className="wf-section" style={{ background: WF.fill }}>
        <h2 className="wf-h2" style={{ marginBottom: 32 }}>Common questions.</h2>
        <div style={{ maxWidth: 780 }}>
          {faqs.map(([q, a], i) =>
          <div key={i} onClick={() => setOpenFaq(openFaq === i ? -1 : i)} style={{ borderBottom: `1px solid ${WF.line2}`, padding: '20px 0', cursor: 'pointer' }}>
              <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
                <div className="wf-h4" style={{ fontSize: 18 }}>{q}</div>
                <div style={{ fontSize: 22, color: WF.ink3, transform: openFaq === i ? 'rotate(45deg)' : 'none', transition: 'transform .2s' }}>+</div>
              </div>
              {openFaq === i && <p className="wf-body" style={{ marginTop: 12, maxWidth: 600 }}>{a}</p>}
            </div>
          )}
        </div>
        <div className="wf-note" style={{ marginTop: 24 }}>click any question → accordion expands</div>
      </div>

      <Footer />
    </div>);

}

function ForFacilities() {
  return (
    <div className="wf-page wf">
      <Chrome url="credz.health/facilities" />
      <Nav active="Facilities" />

      <div className="wf-section hero" style={{ display: 'grid', gridTemplateColumns: '1fr 1.05fr', gap: 48, alignItems: 'center' }}>
        <div>
          <Chip tone="accent">For facilities</Chip>
          <h1 className="wf-h1" style={{ marginTop: 18, marginBottom: 18, fontSize: 60 }}>
            The binder is dead.<br /><span style={{ color: WF.accent }}>Long live Credz.</span>
          </h1>
          <p className="wf-sub" style={{ maxWidth: 480, marginBottom: 28 }}>
            A compliance control center for long-term care and retirement. See every worker, every document, every expiry — in one screen. Audit-ready, 24/7.
          </p>
          <div style={{ display: 'flex', gap: 12 }}>
            <Btn variant="accent" size="lg">Secure my facility</Btn>
            <Btn size="lg" variant="ghost">Watch demo →</Btn>
          </div>
          <div className="wf-small" style={{ marginTop: 18 }}>14-day free trial · No credit card</div>
        </div>
        <div className="wf-card" style={{ padding: 20, boxShadow: '0 24px 60px rgba(0,0,0,.08)' }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
            <div className="wf-h4">Credz Compliance Dashboard</div>
            <Chip tone="ok">✓ 94% ready</Chip>
          </div>
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 10, marginBottom: 16 }}>
            {[
            ['Compliant', '142', WF.ok, WF.okSoft],
            ['Expiring', '12', WF.warn, WF.warnSoft],
            ['Expired', '3', WF.bad, WF.badSoft]].
            map(([l, n, c, bg]) =>
            <div key={l} style={{ padding: 14, background: bg, borderRadius: 10, border: `1px solid ${c}33` }}>
                <div style={{ fontSize: 11, textTransform: 'uppercase', letterSpacing: '.04em', fontWeight: 600, color: c, marginBottom: 4 }}>{l}</div>
                <div className="wf-display" style={{ fontSize: 28, fontWeight: 600, color: c, lineHeight: 1 }}>{n}</div>
                <div style={{ marginTop: 8, height: 4, background: `${c}22`, borderRadius: 2 }}>
                  <div style={{ height: 4, background: c, borderRadius: 2, width: l === 'Compliant' ? '90%' : l === 'Expiring' ? '55%' : '20%' }} />
                </div>
              </div>
            )}
          </div>
          {['Sarah M — RN · Compliant', 'James W — PSW · Expiring 11 days', 'David C — PSW · Compliant', 'Elena R — RN · Expired WHMIS'].map((r, i) => {
            const bad = r.includes('Expired'),warn = r.includes('Expiring');
            return (
              <div key={i} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '10px 12px', background: WF.paper, borderRadius: 8, border: `1px solid ${WF.line2}`, marginBottom: 6 }}>
                <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
                  <MiniAvatar seed={i + 7} size={28} />
                  <div style={{ fontSize: 13 }}>{r.split(' · ')[0]}</div>
                </div>
                <Chip tone={bad ? 'bad' : warn ? 'warn' : 'ok'}>{r.split(' · ')[1]}</Chip>
              </div>);

          })}
        </div>
      </div>

      {/* Audit-proof peace of mind band */}
      <div className="wf-section">
        <Eyebrow>Compliance as a Service</Eyebrow>
        <h2 className="wf-h2" style={{ marginTop: 14, marginBottom: 16, maxWidth: 720 }}>
          Rest easy. We've audit-proofed you.
        </h2>
        <p className="wf-sub" style={{ maxWidth: 580, marginBottom: 48 }}>
          No more scrambling through physical binders when a regulator walks in. Credz runs compliance in the background, so your home is always audit-proof.
        </p>

        {/* Before / after graphic */}
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
          {/* BEFORE */}
          <div className="wf-card" style={{ padding: 32, background: WF.fill2, position: 'relative' }}>
            <Chip tone="bad">Before Credz</Chip>
            <div className="wf-h3" style={{ marginTop: 14, marginBottom: 20 }}>The scramble.</div>
            <div style={{ position: 'relative', height: 320 }}>
              {/* Fake documents — tilted paper stack */}
              {[
              { kind: 'doc', label: 'RN License — Avery M.', sub: 'fake doc??', x: 0, y: 0, rot: -5, bad: true },
              { kind: 'doc', label: 'CPR Certificate', sub: 'Police Check\n✓', x: 180, y: 10, rot: 4 },
              { kind: 'doc', label: 'Flu shot', sub: 'is this current?', x: 95, y: 40, rot: 8, bad: true },
              { kind: 'doc', label: 'TB Skin Test', sub: '1 or 2 step?', x: 30, y: 110, rot: -2, bad: true },
              { kind: 'doc', label: 'Police Check', sub: 'Is this fake??', x: 195, y: 120, rot: 6 },
              { kind: 'doc', label: 'Mask Fit Test', sub: 'wh.  who verified this??', x: 110, y: 165, rot: -7, bad: true },
              { kind: 'doc', label: 'WHMIS Training', sub: 'paper copy only', x: 0, y: 195, rot: 3 },
              { kind: 'tag', label: '📧 Re: Re: Re: chasing docs', x: 12, y: 270, rot: -3 },
              { kind: 'tag', label: '🗂 Binder shelf, 2nd floor', x: 195, y: 275, rot: 2 }].
              map((d) => d.kind === 'doc' ?
              <div key={d.label} style={{
                position: 'absolute', left: d.x, top: d.y, transform: `rotate(${d.rot}deg)`,
                width: 150, padding: 10, background: WF.paper,
                border: `1px solid ${d.bad ? WF.bad : WF.line}`, borderRadius: 4,
                boxShadow: '0 3px 10px rgba(0,0,0,.08)'
              }}>
                  <div style={{ height: 2, background: WF.ink3, width: '70%', marginBottom: 6 }} />
                  <div style={{ fontSize: 11, fontWeight: 600, marginBottom: 4 }}>{d.label}</div>
                  <div style={{ height: 1, background: WF.line2, marginBottom: 3 }} />
                  <div style={{ height: 1, background: WF.line2, marginBottom: 3, width: '85%' }} />
                  <div style={{ height: 1, background: WF.line2, marginBottom: 6, width: '60%' }} />
                  <div style={{ fontSize: 10, color: d.bad ? WF.bad : WF.ink3 }}>{d.sub}</div>
                </div> :

              <div key={d.label} style={{
                position: 'absolute', left: d.x, top: d.y, transform: `rotate(${d.rot}deg)`,
                padding: '6px 10px', background: WF.fill, border: `1px solid ${WF.line}`,
                borderRadius: 999, fontSize: 11
              }}>{d.label}</div>
              )}
            </div>
            <div style={{ marginTop: 20, display: 'flex', flexDirection: 'column', gap: 6 }}>
              {['Days lost to verification scrambles', 'No visibility until it\'s too late', 'One inspection away from a citation'].map((x) =>
              <div key={x} style={{ fontSize: 13, color: WF.ink2, display: 'flex', gap: 8 }}>
                  <span style={{ color: WF.bad }}>✗</span>{x}
                </div>
              )}
            </div>
          </div>
          {/* AFTER */}
          <div className="wf-card" style={{ padding: 32, background: WF.accentSoft, border: `1px solid ${WF.accent}22` }}>
            <Chip tone="accent">With Credz</Chip>
            <div className="wf-h3" style={{ marginTop: 14, marginBottom: 20 }}>The calm.</div>
            <div style={{ background: WF.paper, borderRadius: 12, padding: 18, boxShadow: '0 4px 18px rgba(0,113,227,.08)', height: 260, display: 'flex', flexDirection: 'column', gap: 10 }}>
              <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
                <div style={{ fontWeight: 600, fontSize: 14 }}>Compliance · Live</div>
                <Chip tone="ok">✓ 100% audit-ready</Chip>
              </div>
              <div style={{ display: 'flex', flexDirection: 'column', gap: 6, flex: 1 }}>
                {[
                ['Avery M.', 'RN', '18/18'],
                ['James W.', 'PSW', '14/14'],
                ['Elena R.', 'RN', '18/18'],
                ['David C.', 'PSW', '14/14']].
                map(([n, r, c]) =>
                <div key={n} style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '7px 10px', background: WF.fill2, borderRadius: 6, border: `1px solid ${WF.line2}` }}>
                    <div style={{ width: 6, height: 6, borderRadius: 3, background: WF.ok }} />
                    <div style={{ flex: 1, fontSize: 12, fontWeight: 500 }}>{n}</div>
                    <div className="wf-small" style={{ fontSize: 11 }}>{r}</div>
                    <div style={{ fontSize: 11, color: WF.ok, fontWeight: 500 }}>{c} ✓</div>
                  </div>
                )}
              </div>
              <div style={{ padding: 10, background: WF.ink, color: 'white', borderRadius: 8, fontSize: 11, display: 'flex', justifyContent: 'space-between' }}>
                <span>Export inspection report</span>
                <span style={{ color: '#64d08a' }}>1-click ↓</span>
              </div>
            </div>
            <div style={{ marginTop: 20, display: 'flex', flexDirection: 'column', gap: 6 }}>
              {['Every staff member, always current', 'Regulator-ready in one click', 'Audit-proof, 24/7'].map((x) =>
              <div key={x} style={{ fontSize: 13, color: WF.ink2, display: 'flex', gap: 8 }}>
                  <span style={{ color: WF.ok }}>✓</span>{x}
                </div>
              )}
            </div>
          </div>
        </div>
      </div>

      {/* Benefit grid */}
      <div className="wf-section" style={{ background: WF.ink, color: 'white' }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 64, alignItems: 'center' }}>
          <div>
            <Eyebrow color="#8ab4f8">The problem</Eyebrow>
            <h2 className="wf-h2" style={{ color: 'white', marginTop: 14, marginBottom: 20, maxWidth: 460 }}>
              Compliance shouldn't live in an Excel sheet.
            </h2>
            <p style={{ fontSize: 17, color: 'rgba(255,255,255,.72)', lineHeight: 1.55, marginBottom: 20, maxWidth: 460 }}>
              Today, admins scan, upload, store and manually track every document in spreadsheets. Credentials quietly expire. Fake docs slip through. Inspectors arrive, and days disappear verifying what should have been verified once.
            </p>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10, maxWidth: 420 }}>
              {[
              'Manual Excel tracking → credentials expire unnoticed',
              'Fake documents slip past overworked administrators',
              'Homes waste days re-verifying the same worker, again and again'].
              map((t) =>
              <div key={t} style={{ display: 'flex', gap: 12, alignItems: 'flex-start' }}>
                  <div style={{ width: 6, height: 6, borderRadius: 3, background: WF.accent, marginTop: 7, flexShrink: 0 }} />
                  <div style={{ fontSize: 15, color: 'rgba(255,255,255,.85)' }}>{t}</div>
                </div>
              )}
            </div>
          </div>
          <ExcelToCredzAnim />
        </div>
      </div>

      {/* The fix */}
      <div className="wf-section">
        <Eyebrow>The fix</Eyebrow>
        <h2 className="wf-h2" style={{ marginTop: 14, marginBottom: 48, maxWidth: 680 }}>
          A passport for the people who hold us together.
        </h2>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 48, alignItems: 'flex-start' }}>
          <div className="wf-card" style={{ padding: 20, boxShadow: '0 18px 48px rgba(0,0,0,.06)' }}>
            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 14 }}>
              <div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
                <Placeholder label="" w={48} h={48} radius={24} />
                <div>
                  <div style={{ fontWeight: 600, fontSize: 15 }}>Avery Mitchell, RN</div>
                  <div className="wf-small">CREDZ ID · C0122-64278</div>
                </div>
              </div>
              <Chip tone="accent">✓ Credz Verified</Chip>
            </div>
            <div style={{ background: WF.okSoft, borderRadius: 10, padding: 14, marginBottom: 12 }}>
              <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
                <div style={{ fontWeight: 600, color: WF.ok, fontSize: 14 }}>100% Compliant</div>
                <div className="wf-small" style={{ color: WF.ok }}>18 / 18 documents</div>
              </div>
              <div style={{ height: 6, background: 'rgba(26,135,84,.15)', borderRadius: 3 }}>
                <div style={{ width: '100%', height: 6, background: WF.ok, borderRadius: 3 }} />
              </div>
            </div>
            <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 6 }}>
              {[['RN License', '2027-03'], ['CPR Level C', '2026-09'], ['TB Skin Test', '2026-11'], ['WHMIS', '2027-01'], ['Police Check', '2026-12'], ['First Aid', '2026-10']].map(([d, exp]) =>
              <div key={d} style={{ padding: 8, background: WF.fill2, borderRadius: 6, border: `1px solid ${WF.line2}`, fontSize: 11 }}>
                  <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                    <span style={{ fontWeight: 500 }}>{d}</span>
                    <span style={{ color: WF.ok }}>✓</span>
                  </div>
                  <div className="wf-small" style={{ fontSize: 10 }}>Valid · {exp}</div>
                </div>
              )}
            </div>
            <div style={{ marginTop: 10, padding: '8px 10px', background: WF.ink, color: 'white', borderRadius: 6, fontSize: 11, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
              <span>Integrity hash · verified 4 min ago</span>
              <span style={{ fontFamily: WF.mono, color: '#64d08a' }}>0x4a…e2f1</span>
            </div>
          </div>
          <div style={{ display: 'flex', flexDirection: 'column', gap: 24 }}>
            {[
            ['01', 'Kill the Excel sheet', 'Replace manual scanning, uploading and spreadsheet tracking with one live vault — for every staff member, always current.'],
            ['02', 'Fraud-proof by design', 'Every document is human-verified and stamped with an integrity check. Metadata is tracked so tampering is detectable.'],
            ['03', 'One source of truth', 'One place to see compliance status for all staff, all the time. No more binders, no more guessing.'],
            ['04', 'Onboarding in minutes', 'New hire already has a Credz wallet? Link it and their full verified binder transfers in one click.']].
            map(([n, t, d]) =>
            <div key={n} style={{ display: 'grid', gridTemplateColumns: '56px 1fr', gap: 20, paddingBottom: 20, borderBottom: `1px solid ${WF.line2}` }}>
                <div className="wf-display" style={{ fontSize: 28, color: WF.accent, fontWeight: 500 }}>{n}</div>
                <div>
                  <div className="wf-h4">{t}</div>
                  <div className="wf-body" style={{ marginTop: 6, fontSize: 15 }}>{d}</div>
                </div>
              </div>
            )}
          </div>
        </div>
      </div>

      {/* Inter-facility sync */}
      <div className="wf-section" style={{ background: WF.accent, color: 'white' }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 56, alignItems: 'center', marginBottom: 40 }}>
          <div>
            <Eyebrow color="rgba(255,255,255,.7)">Network effect</Eyebrow>
            <h2 className="wf-h2" style={{ marginTop: 14, marginBottom: 18, color: 'white', maxWidth: 440 }}>Inter-Facility Sync.

            </h2>
            <p style={{ color: 'rgba(255,255,255,.85)', fontSize: 18, lineHeight: 1.55, marginBottom: 24, maxWidth: 540 }}>
              When a care worker goes from one home to another home, within the same brand, their entire verified binder transfers instantly. No re-uploads. No re-verifying.
            </p>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 14, maxWidth: 540 }}>
              {[
              ['Pre-populated profiles', 'For any past Credz worker, on day one.'],
              ['Verified by a human', 'Every document. Stamped, hashed, audit-ready.'],
              ['Shared audit-readiness', 'Sister homes inherit each other\'s verifications.'],
              ['Zero re-uploads', 'Worker keeps one wallet. Homes stay in sync.']].
              map(([t, d]) =>
              <div key={t} style={{ padding: 16, background: 'rgba(255,255,255,.08)', borderRadius: 12, border: '1px solid rgba(255,255,255,.14)' }}>
                  <div style={{ fontWeight: 600, fontSize: 14, marginBottom: 4 }}>{t}</div>
                  <div style={{ fontSize: 12.5, color: 'rgba(255,255,255,.72)', lineHeight: 1.45 }}>{d}</div>
                </div>
              )}
            </div>
          </div>
          <FacilitySyncDemo />
        </div>
      </div>

      {/* Final CTA */}
      <div className="wf-section" style={{ textAlign: 'center' }}>
        <h2 className="wf-h2" style={{ marginBottom: 14 }}>Ready to modernize?</h2>
        <p className="wf-sub" style={{ maxWidth: 480, margin: '0 auto 28px' }}>
          See a live demo of Credz running on your facility's data in under 20 minutes.
        </p>
        <Btn variant="accent" size="lg">Book a demo</Btn>
      </div>

      <Footer />
    </div>);

}

function RealtimeSyncDemo() {
  // 0: expiring state / before upload
  // 1: worker tapping upload on phone
  // 2: verification pulse
  // 3: synced — both dashboards green
  const [step, setStep] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setStep((s) => (s + 1) % 4), 2100);
    return () => clearInterval(id);
  }, []);

  const Dashboard = ({ org, subtitle, tone }) => {
    const expired = step < 2;
    const syncing = step === 2;
    const synced = step === 3;
    const toneColor = tone === 'agency' ? '#5a4a8f' : '#1f7a6a';
    return (
      <div style={{
        background: WF.paper, border: `1px solid ${WF.line2}`, borderRadius: 14, padding: 18,
        boxShadow: '0 4px 14px rgba(0,0,0,.05)', minHeight: 300, position: 'relative', overflow: 'hidden'
      }}>
        {/* Sync flash overlay */}
        {syncing &&
        <div style={{
          position: 'absolute', inset: 0, background: `${WF.accent}0f`,
          pointerEvents: 'none', animation: 'rtsd-flash .8s ease-out'
        }} />
        }

        <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 4 }}>
          <div style={{ width: 22, height: 22, borderRadius: 4, background: toneColor, color: 'white',
            display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 11, fontWeight: 700 }}>
            {tone === 'agency' ? 'A' : 'H'}
          </div>
          <div style={{ fontWeight: 600, fontSize: 14 }}>{org}</div>
        </div>
        <div className="wf-small" style={{ fontSize: 11, marginBottom: 14 }}>{subtitle}</div>

        {/* Worker row */}
        <div style={{
          padding: 12, background: WF.fill2, borderRadius: 8, marginBottom: 10,
          border: `1px solid ${WF.line2}`
        }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 10 }}>
            <MiniAvatar seed={3} size={32} />
            <div style={{ flex: 1 }}>
              <div style={{ fontWeight: 600, fontSize: 13 }}>Julian Thorne, RN</div>
              <div className="wf-small" style={{ fontSize: 11 }}>18 credentials</div>
            </div>
            <Chip tone={expired ? 'bad' : synced ? 'ok' : 'warn'}>
              {expired ? 'Action required' : synced ? 'All current' : 'Updating…'}
            </Chip>
          </div>

          {/* CPR row – the one that expires */}
          <div style={{
            display: 'flex', alignItems: 'center', gap: 10, padding: '8px 10px',
            background: WF.paper, borderRadius: 6,
            border: `1px solid ${expired ? `${WF.bad}66` : synced ? `${WF.ok}66` : WF.line2}`,
            transition: 'all .5s ease'
          }}>
            <div style={{
              width: 8, height: 8, borderRadius: 4,
              background: expired ? WF.bad : synced ? WF.ok : WF.warn,
              transition: 'background .5s ease'
            }} />
            <div style={{ flex: 1, fontSize: 12, fontWeight: 500 }}>CPR Level C</div>
            {expired &&
            <div style={{ fontSize: 10, color: WF.bad, fontWeight: 600 }}>
                Expired 2 days ago
              </div>
            }
            {syncing &&
            <div style={{ fontSize: 10, color: WF.accent, fontWeight: 600, display: 'flex', alignItems: 'center', gap: 4 }}>
                <span style={{ display: 'inline-block', width: 8, height: 8, borderRadius: 4, border: `1.5px solid ${WF.accent}`, borderTopColor: 'transparent', animation: 'rtsd-spin .7s linear infinite' }} />
                Syncing
              </div>
            }
            {synced &&
            <div style={{ fontSize: 10, color: WF.ok, fontWeight: 600 }}>
                ✓ Valid · Jun 2027
              </div>
            }
          </div>

          {/* Other credential rows (always green) */}
          {['RN License', 'TB Skin Test', 'WHMIS'].map((c) =>
          <div key={c} style={{
            display: 'flex', alignItems: 'center', gap: 10, padding: '8px 10px',
            background: WF.paper, borderRadius: 6, marginTop: 4,
            border: `1px solid ${WF.line2}`
          }}>
              <div style={{ width: 8, height: 8, borderRadius: 4, background: WF.ok }} />
              <div style={{ flex: 1, fontSize: 12 }}>{c}</div>
              <div style={{ fontSize: 10, color: WF.ok, fontWeight: 600 }}>✓</div>
            </div>
          )}
        </div>

        {/* Footer — last update */}
        <div style={{
          display: 'flex', alignItems: 'center', gap: 6, fontSize: 10, color: WF.ink2
        }}>
          <span style={{
            width: 6, height: 6, borderRadius: 3, background: synced ? WF.ok : WF.ink3,
            animation: synced ? 'rtsd-pulse 1.4s ease-out infinite' : 'none'
          }} />
          {expired ? 'Last synced 14 days ago' : syncing ? 'Syncing now…' : 'Just updated · live'}
        </div>
      </div>);

  };

  return (
    <div>
      <style>{`
        @keyframes rtsd-spin { to { transform: rotate(360deg); } }
        @keyframes rtsd-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
        @keyframes rtsd-flash { 0% { opacity: 1; } 100% { opacity: 0; } }
        @keyframes rtsd-packet { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateX(150%) scale(1); opacity: 0; } }
        @keyframes rtsd-packet-left { 0% { transform: translateX(50%) scale(.6); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateX(-150%) scale(1); opacity: 0; } }
        @keyframes rtsd-lift { 0% { transform: translateY(0); } 50% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
      `}</style>

      {/* Step tracker pills */}
      <div style={{ display: 'flex', justifyContent: 'center', gap: 8, marginBottom: 24, flexWrap: 'wrap' }}>
        {['CPR expires', 'Worker uploads new doc', 'Verified', 'Agency + Home updated'].map((t, i) => {
          const active = step === i;
          const done = step > i;
          return (
            <div key={i} style={{
              padding: '6px 12px', borderRadius: 999, fontSize: 11, fontWeight: 500,
              background: active ? WF.ink : done ? WF.okSoft : WF.fill,
              color: active ? 'white' : done ? WF.ok : WF.ink2,
              border: `1px solid ${active ? WF.ink : done ? `${WF.ok}55` : WF.line2}`,
              transition: 'all .3s ease'
            }}>
              {done && '✓ '}{t}
            </div>);

        })}
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 0.9fr 1fr', gap: 20, alignItems: 'center' }}>
        {/* Agency dashboard */}
        <Dashboard org="Northern Care Staffing" subtitle="Agency · bench of 142" tone="agency" />

        {/* Center: worker phone */}
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 12 }}>
          {/* Left arrow */}
          <div style={{ width: '100%', height: 20, position: 'relative' }}>
            {step === 3 &&
            <>
                <div style={{
                position: 'absolute', left: '50%', top: 8, width: 10, height: 4, borderRadius: 2, background: WF.accent,
                animation: 'rtsd-packet-left 1.2s ease-out'
              }} />
                <div style={{
                position: 'absolute', left: '50%', top: 8, width: 10, height: 4, borderRadius: 2, background: WF.accent,
                animation: 'rtsd-packet 1.2s ease-out'
              }} />
              </>
            }
            <div style={{
              position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'space-between',
              fontSize: 10, color: WF.ink3, fontWeight: 600, textTransform: 'uppercase', letterSpacing: '.08em'
            }}>
              <span>←</span><span>→</span>
            </div>
          </div>

          <div className="wf-phone" style={{ animation: step === 1 ? 'rtsd-lift .8s ease-out' : 'none' }}>
            <div className="screen">
              <div style={{ padding: 14 }}>
                <div className="wf-display" style={{ fontSize: 13, marginBottom: 10 }}>Credz Wallet</div>

                {/* CPR card — the focus */}
                <div style={{
                  padding: 12, borderRadius: 10, marginBottom: 10,
                  background: step < 2 ? `${WF.bad}0f` : step === 2 ? `${WF.accent}0f` : `${WF.ok}0f`,
                  border: `1.5px solid ${step < 2 ? WF.bad : step === 2 ? WF.accent : WF.ok}`,
                  transition: 'all .4s ease'
                }}>
                  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 6 }}>
                    <div style={{ fontSize: 11, fontWeight: 600 }}>CPR Level C</div>
                    {step < 2 && <span style={{ fontSize: 9, color: WF.bad, fontWeight: 600 }}>EXPIRED</span>}
                    {step === 2 && <span style={{ fontSize: 9, color: WF.accent, fontWeight: 600 }}>VERIFYING…</span>}
                    {step === 3 && <span style={{ fontSize: 9, color: WF.ok, fontWeight: 600 }}>✓ VERIFIED</span>}
                  </div>
                  <div className="wf-small" style={{ fontSize: 9, marginBottom: 8 }}>
                    {step < 2 ? 'Expired 2 days ago' : step === 2 ? 'Checking with HSFC…' : 'Valid until Jun 15, 2027'}
                  </div>

                  {step === 0 &&
                  <div style={{
                    padding: '8px 10px', background: WF.bad, color: 'white', borderRadius: 6,
                    fontSize: 11, fontWeight: 600, textAlign: 'center'
                  }}>
                      Upload new certificate
                    </div>
                  }
                  {step === 1 &&
                  <div style={{
                    padding: '8px 10px', background: WF.ink, color: 'white', borderRadius: 6,
                    fontSize: 11, fontWeight: 600, textAlign: 'center',
                    display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 6
                  }}>
                      <span>📎</span> CPR-Jun2027.pdf
                    </div>
                  }
                  {step === 2 &&
                  <div style={{
                    padding: '8px 10px', background: WF.paper, borderRadius: 6,
                    fontSize: 11, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8,
                    border: `1px solid ${WF.accent}55`
                  }}>
                      <span style={{ display: 'inline-block', width: 10, height: 10, borderRadius: 5, border: `1.5px solid ${WF.accent}`, borderTopColor: 'transparent', animation: 'rtsd-spin .7s linear infinite' }} />
                      <span style={{ color: WF.accent, fontWeight: 600 }}>Verifying with registry</span>
                    </div>
                  }
                  {step === 3 &&
                  <div style={{
                    padding: '8px 10px', background: WF.ok, color: 'white', borderRadius: 6,
                    fontSize: 11, fontWeight: 600, textAlign: 'center'
                  }}>
                      ✓ Pushed to 2 linked orgs
                    </div>
                  }
                </div>

                <div className="wf-small" style={{ fontSize: 9, textAlign: 'center' }}>
                  {step === 0 && '1 item needs attention'}
                  {step === 1 && 'Uploading…'}
                  {step === 2 && 'Primary-source verification'}
                  {step === 3 && 'All 18 credentials current'}
                </div>
              </div>
            </div>
          </div>

          <div className="wf-small" style={{ fontSize: 11 }}>Julian's phone</div>
        </div>

        {/* Home dashboard */}
        <Dashboard org="Maple Grove LTC" subtitle="Home · 68 residents" tone="home" />
      </div>

      {/* Bottom caption */}
      <div style={{
        marginTop: 28, padding: 16, background: WF.paper, border: `1px solid ${WF.line2}`,
        borderRadius: 10, display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 24, flexWrap: 'wrap'
      }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13 }}>
          <span style={{ color: WF.bad, fontWeight: 600 }}>✗</span>
          <span style={{ color: WF.ink2, textDecoration: 'line-through' }}>Chasing docs via email</span>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13 }}>
          <span style={{ color: WF.bad, fontWeight: 600 }}>✗</span>
          <span style={{ color: WF.ink2, textDecoration: 'line-through' }}>Manual updates in two systems</span>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 13 }}>
          <span style={{ color: WF.ok, fontWeight: 600 }}>✓</span>
          <span style={{ fontWeight: 500 }}>One upload. Every record, in sync.</span>
        </div>
      </div>
    </div>);

}

function ForAgencies() {
  return (
    <div className="wf-page wf">
      <Chrome url="credz.health/agencies" />
      <Nav active="Agencies" />

      <div className="wf-section hero" style={{ display: 'grid', gridTemplateColumns: '1.1fr 1fr', gap: 48, alignItems: 'center' }}>
        <div>
          <Chip tone="accent">For staffing agencies</Chip>
          <h1 className="wf-h1" style={{ marginTop: 18, marginBottom: 18, fontSize: 60 }}>
            Place staff anywhere.<br />Instantly.
          </h1>
          <p className="wf-sub" style={{ maxWidth: 480, marginBottom: 28 }}>
            Verify once. Deploy everywhere. Your bench becomes a portable, audit-proof network — ready for the next shift, anywhere in Canada.
          </p>
          <div style={{ display: 'flex', gap: 12 }}>
            <Btn variant="accent" size="lg">Get started</Btn>
            <Btn size="lg" variant="ghost">Talk to sales →</Btn>
          </div>
        </div>
        <div className="wf-card" style={{ padding: 24, background: WF.ink, color: 'white', border: 'none' }}>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
            <div className="wf-h4" style={{ color: 'white' }}>Active Pipeline</div>
            <div style={{ fontSize: 11, color: 'rgba(255,255,255,.55)', textTransform: 'uppercase', letterSpacing: '.08em' }}>5 staff</div>
          </div>
          {/* Compliance summary bar */}
          <div style={{ display: 'flex', gap: 8, marginBottom: 16 }}>
            {[
            { v: 3, l: 'Compliant', bg: 'rgba(80,200,120,.18)', fg: '#7be39a' },
            { v: 2, l: 'Action needed', bg: 'rgba(255,176,46,.18)', fg: '#ffc66e' },
            { v: 0, l: 'Blocked', bg: 'rgba(255,99,99,.16)', fg: '#ff8e8e' }].
            map((t) =>
            <div key={t.l} style={{ flex: 1, padding: '10px 12px', background: t.bg, borderRadius: 8 }}>
                <div style={{ fontSize: 22, fontWeight: 600, color: t.fg, lineHeight: 1 }}>{t.v}</div>
                <div style={{ fontSize: 10, color: 'rgba(255,255,255,.65)', marginTop: 4, fontWeight: 600, textTransform: 'uppercase', letterSpacing: '.04em' }}>{t.l}</div>
              </div>
            )}
          </div>
          {[
          ['Sarah M', 'RN', 'Deployed · Maple Ridge', 100, 'ok'],
          ['James W', 'PSW', 'Missing CPR cert', 78, 'warn'],
          ['David C', 'PSW', 'Pre-verified · Any facility', 100, 'ok'],
          ['Elena R', 'RN', 'At Pine Grove until Apr 30', 100, 'ok'],
          ['Marcus T', 'PSW', 'Police check expired', 67, 'warn']].
          map(([n, r, s, pct, t], i) => {
            const tone = t === 'ok' ? { bar: '#50c878', chip: 'rgba(80,200,120,.22)', chipFg: '#7be39a', label: '✓ ' + pct + '%' } :
            { bar: '#ffb02e', chip: 'rgba(255,176,46,.22)', chipFg: '#ffc66e', label: '⚠ ' + pct + '%' };
            return (
              <div key={i} style={{ padding: '12px 0', borderBottom: i < 4 ? `1px solid rgba(255,255,255,.08)` : 'none' }}>
                <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
                  <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
                    <div style={{ width: 26, height: 26, borderRadius: 13, background: 'rgba(255,255,255,.15)' }} />
                    <div>
                      <div style={{ fontWeight: 500, fontSize: 13 }}>{n} · {r}</div>
                      <div style={{ color: 'rgba(255,255,255,.55)', fontSize: 12 }}>{s}</div>
                    </div>
                  </div>
                  <div style={{ padding: '3px 8px', background: tone.chip, color: tone.chipFg, borderRadius: 6, fontSize: 11, fontWeight: 600 }}>{tone.label}</div>
                </div>
                <div style={{ height: 4, background: 'rgba(255,255,255,.08)', borderRadius: 2, overflow: 'hidden' }}>
                  <div style={{ width: pct + '%', height: '100%', background: tone.bar, borderRadius: 2 }} />
                </div>
              </div>);

          })}
          {/* Send files button */}
          <div style={{ marginTop: 18, padding: '12px 16px', background: WF.accent, color: 'white', borderRadius: 10, display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12, cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,102,204,.4)' }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
              <span style={{ fontSize: 16 }}>⇪</span>
              <div style={{ fontSize: 13, fontWeight: 600 }}>Send employee files for home approval in 1 click</div>
            </div>
            <span style={{ fontSize: 16 }}>→</span>
          </div>
        </div>
      </div>

      {/* Agency pain vs one-click approval */}
      <div className="wf-section">
        <Eyebrow>The agency bottleneck</Eyebrow>
        <h2 className="wf-h2" style={{ marginTop: 14, marginBottom: 18, maxWidth: 720 }}>
          Stop building employee files by hand.
        </h2>
        <p className="wf-sub" style={{ maxWidth: 620, marginBottom: 40 }}>
          Today, you manually prep every profile, self-verify the docs, zip them into an email, and pray the home downloads before the shift starts. With Credz, you send a live wallet in one click — the home approves and gets access to the files in their system and onboarding dates write themselves back.
        </p>

        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 20, marginBottom: 48 }}>
          {/* BEFORE */}
          <div className="wf-card" style={{ padding: 28, background: WF.fill2, position: 'relative' }}>
            <Chip tone="bad">Before Credz</Chip>
            <div className="wf-h3" style={{ marginTop: 14, marginBottom: 20 }}>The manual pipeline.</div>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
              {[
              ['Prep the binder', 'Pull docs from 4 folders. Check every expiry by hand.'],
              ['Self-verify', 'Re-check every license online. Hope nothing is fake.'],
              ['Email the home', 'Attach 18 PDFs. Hit send. Wait.'],
              ['Home re-downloads', 'They save locally. Track expiries in their own sheet.'],
              ['Chase approval', 'Email thread grows. Onboarding slips by days.']].
              map(([t, d], i) =>
              <div key={t} style={{ display: 'flex', gap: 14, padding: 10, background: WF.paper, borderRadius: 8, border: `1px solid ${WF.line2}` }}>
                  <div style={{ width: 26, height: 26, borderRadius: 13, background: WF.badSoft, color: WF.bad, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 12, fontWeight: 600, flexShrink: 0 }}>{i + 1}</div>
                  <div>
                    <div style={{ fontWeight: 600, fontSize: 13 }}>{t}</div>
                    <div className="wf-small" style={{ fontSize: 11 }}>{d}</div>
                  </div>
                </div>
              )}
            </div>
            <div style={{ marginTop: 18, padding: '10px 14px', background: WF.badSoft, color: WF.bad, borderRadius: 8, fontSize: 13, fontWeight: 500, textAlign: 'center' }}>
              ⏱ 3–5 days, two separate copies, zero audit trail
            </div>
          </div>

          {/* AFTER */}
          <div className="wf-card" style={{ padding: 28, background: WF.accentSoft, border: `1px solid ${WF.accent}22` }}>
            <Chip tone="accent">With Credz</Chip>
            <div className="wf-h3" style={{ marginTop: 14, marginBottom: 20 }}>One-click sending file to home.</div>
            <AgencyReviewFlow />
          </div>
        </div>
      </div>
      <div className="wf-section" style={{ background: WF.fill2 }}>
        <h2 className="wf-h2" style={{ marginBottom: 40, maxWidth: 600 }}>
          Built for the speed of staffing.
        </h2>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16 }}>
          {[
          ['One-click approvals', 'Send a worker\'s Credz wallet to a home and get sign-off in one click. No email threads, no PDF chasing.'],
          ['Tandem with every home', 'Agency and home see the exact same verified record — always aligned, always up-to-date.'],
          ['Shared verified pool', 'Move any verified worker between any partnered home in minutes, not weeks.'],
          ['Bulk onboarding', 'Onboard 50+ candidates in a batch. Chase only what\'s missing.'],
          ['Real-time documentation', 'No stale PDFs. A renewal updates the home\'s view the same moment it\'s filed.'],
          ['Audit-ready placements', 'Every placement has a date-stamped, tamper-proof credential record attached.']].
          map(([t, d], i) =>
          <div key={t} className="wf-card" style={{ padding: 24 }}>
              <div style={{ width: 36, height: 36, borderRadius: 8, background: WF.accentSoft, display: 'flex', alignItems: 'center', justifyContent: 'center', marginBottom: 14 }}>
                <div style={{ color: WF.accent, fontWeight: 600, fontSize: 14 }}>0{i + 1}</div>
              </div>
              <div className="wf-h4" style={{ marginBottom: 6 }}>{t}</div>
              <p className="wf-body" style={{ fontSize: 14 }}>{d}</p>
            </div>
          )}
        </div>
      </div>

      {/* Real-time cross-org sync */}
      <div className="wf-section" style={{ background: WF.fill2 }}>
        <Eyebrow>Real-time sync</Eyebrow>
        <h2 className="wf-h2" style={{ marginTop: 14, marginBottom: 16, maxWidth: 760 }}>
          Worker updates once. <span style={{ color: WF.accent }}>Everyone sees it instantly.</span>
        </h2>
        <p className="wf-sub" style={{ maxWidth: 620, marginBottom: 40 }}>
          When a credential expires and the worker uploads the new one in the app, Credz pushes the update to every linked agency and home in real time. No more chasing docs. No more sifting through email threads. No more shifts lost to stale paperwork.
        </p>
        <RealtimeSyncDemo />
      </div>

      {/* Quote */}
      <div className="wf-section" style={{ textAlign: 'center' }}>
        <div style={{ fontSize: 48, color: WF.line, lineHeight: 1 }}>“</div>
        <p className="wf-display" style={{ fontSize: 30, fontWeight: 500, letterSpacing: '-0.014em', maxWidth: 820, margin: '4px auto 20px', lineHeight: 1.3 }}>Credz saves us 2-6 hours per employee onboarding. We gather docs and send to home for approval in seconds! Our clients love the peace of mind that our staff are always compliant at all times!

        </p>
        <div className="wf-small">Daniel Beard · Lion Healthcar</div>
      </div>

      <Footer />
    </div>);

}

// ──── ExcelToCredzAnim — chaotic spreadsheet flips into clean Credz dashboard ────
function ExcelToCredzAnim() {
  // 0..2: Excel state (chaos building); 3: flip; 4..5: Credz dashboard
  const [step, setStep] = React.useState(0);
  React.useEffect(() => {
    const id = setInterval(() => setStep((s) => (s + 1) % 6), 1500);
    return () => clearInterval(id);
  }, []);
  const showCredz = step >= 3;

  // Excel data — fake messy spreadsheet
  const rows = [
  { name: 'Avery M.', rn: 'EXPIRED', cpr: '2025-08', tb: '?', pc: 'missing' },
  { name: 'Julian T.', rn: '2027-03', cpr: '2024-11', tb: '2026-11', pc: '2026-12' },
  { name: 'Priya S.', rn: '2026-04', cpr: '?', tb: 'expired', pc: '2025-09' },
  { name: 'Marcus L.', rn: '#REF!', cpr: '2026-02', tb: '2026-08', pc: 'missing' },
  { name: 'Sara O.', rn: '2027-01', cpr: '2026-12', tb: '2026-10', pc: '2027-04' },
  { name: 'Devon R.', rn: 'expired', cpr: '2025-11', tb: '?', pc: '?' }];

  const cellTone = (v) => {
    const s = String(v).toLowerCase();
    if (s.includes('expir') || s === 'missing' || s === '#ref!') return { bg: '#fde7e7', fg: '#b4232c' };
    if (s === '?') return { bg: '#fff4d6', fg: '#8a6300' };
    return { bg: 'transparent', fg: '#1a1a1a' };
  };

  return (
    <div style={{ position: 'relative', height: 420, perspective: 1400 }}>
      <div style={{
        width: '100%', height: '100%', position: 'relative',
        transformStyle: 'preserve-3d',
        transition: 'transform .9s cubic-bezier(.7,0,.3,1)',
        transform: showCredz ? 'rotateY(180deg)' : 'rotateY(0deg)'
      }}>
        {/* Front: Excel */}
        <div style={{
          position: 'absolute', inset: 0,
          backfaceVisibility: 'hidden',
          background: '#fafaf7', borderRadius: 10, overflow: 'hidden',
          border: '1px solid rgba(255,255,255,.12)',
          boxShadow: '0 24px 60px rgba(0,0,0,.35)'
        }}>
          {/* Title bar */}
          <div style={{ height: 22, background: '#1a7a3e', display: 'flex', alignItems: 'center', padding: '0 10px', color: 'white', fontSize: 11, fontWeight: 600, letterSpacing: '.02em' }}>
            <span style={{ width: 10, height: 10, background: '#43a55c', borderRadius: 2, marginRight: 8, display: 'inline-block' }} />
            staff_compliance_FINAL_v7_FINAL.xlsx
          </div>
          {/* Toolbar */}
          <div style={{ height: 18, background: '#e9e6dc', display: 'flex', alignItems: 'center', padding: '0 10px', gap: 12, fontSize: 10, color: '#4a4a40', borderBottom: '1px solid #d5d2c5' }}>
            <span>File</span><span>Edit</span><span>View</span><span>Insert</span><span>Format</span><span>Data</span>
          </div>
          {/* Cell ref + formula bar */}
          <div style={{ height: 22, background: 'white', display: 'flex', alignItems: 'center', padding: '0 8px', borderBottom: '1px solid #d5d2c5', gap: 8, fontSize: 10, fontFamily: 'ui-monospace, Menlo, monospace', color: '#1a1a1a' }}>
            <span style={{ width: 38, padding: '2px 4px', background: '#f5f5f0', border: '1px solid #d5d2c5', borderRadius: 2 }}>B4</span>
            <span style={{ color: '#999' }}>fx</span>
            <span style={{ color: '#b4232c' }}>=VLOOKUP(#REF!,licenses!A:D,2,FALSE)</span>
          </div>
          {/* Column headers */}
          <div style={{ display: 'grid', gridTemplateColumns: '24px 1.4fr 1fr 1fr 1fr 1fr', background: '#f0eee6', borderBottom: '1px solid #c9c5b6', fontSize: 10, color: '#4a4a40' }}>
            {['', 'A', 'B', 'C', 'D', 'E'].map((c, i) =>
            <div key={i} style={{ padding: '3px 6px', textAlign: i === 0 ? 'center' : 'left', borderRight: '1px solid #c9c5b6', fontWeight: 600 }}>{c}</div>
            )}
          </div>
          {/* Header row */}
          <div style={{ display: 'grid', gridTemplateColumns: '24px 1.4fr 1fr 1fr 1fr 1fr', background: '#f5f3eb', borderBottom: '1px solid #c9c5b6', fontSize: 10 }}>
            {[' 1', 'Staff', 'RN', 'CPR', 'TB', 'Police'].map((c, i) =>
            <div key={i} style={{ padding: '4px 6px', borderRight: '1px solid #d9d5c6', fontWeight: 600, color: i === 0 ? '#999' : '#1a1a1a', textAlign: i === 0 ? 'center' : 'left' }}>{c}</div>
            )}
          </div>
          {/* Data rows */}
          {rows.map((r, i) =>
          <div key={r.name} style={{ display: 'grid', gridTemplateColumns: '24px 1.4fr 1fr 1fr 1fr 1fr', background: i % 2 === 0 ? 'white' : '#fafaf5', borderBottom: '1px solid #e3dfd0', fontSize: 11 }}>
              <div style={{ padding: '6px 4px', textAlign: 'center', color: '#999', borderRight: '1px solid #d9d5c6', fontSize: 10 }}>{i + 2}</div>
              {[r.name, r.rn, r.cpr, r.tb, r.pc].map((v, j) => {
              const tone = j === 0 ? { bg: 'transparent', fg: '#1a1a1a' } : cellTone(v);
              const isEditing = step === 1 && i === 1 && j === 2;
              return (
                <div key={j} style={{
                  padding: '6px 6px', borderRight: '1px solid #e3dfd0',
                  background: tone.bg, color: tone.fg, fontWeight: tone.fg !== '#1a1a1a' ? 600 : 400,
                  fontFamily: j === 0 ? 'inherit' : 'ui-monospace, Menlo, monospace',
                  position: 'relative'
                }}>
                    {v}
                    {isEditing && <span style={{ position: 'absolute', right: 4, top: 4, bottom: 4, width: 1, background: '#1a1a1a', animation: 'blink 1s steps(2) infinite' }} />}
                  </div>);

            })}
            </div>
          )}
          {/* Sticky note */}
          <div style={{
            position: 'absolute', right: 16, top: 96, width: 120, padding: '10px 12px',
            background: '#fff7a8', boxShadow: '0 6px 14px rgba(0,0,0,.18)',
            transform: step === 2 ? 'rotate(-4deg) scale(1.04)' : 'rotate(-7deg)',
            transition: 'transform .4s', fontFamily: 'Caveat, Marker Felt, cursive', fontSize: 14, color: '#5a4a00', lineHeight: 1.2
          }}>
            ask Sandra for<br />Avery's CPR and<br />First Aid!! 😩
          </div>
          {/* Sheet tabs */}
          <div style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: 18, background: '#e9e6dc', borderTop: '1px solid #c9c5b6', display: 'flex', alignItems: 'center', padding: '0 8px', gap: 4, fontSize: 10, color: '#4a4a40' }}>
            <span style={{ padding: '2px 8px', background: 'white', border: '1px solid #c9c5b6', borderBottom: 0, borderRadius: '3px 3px 0 0' }}>Staff</span>
            <span style={{ padding: '2px 8px' }}>Licenses</span>
            <span style={{ padding: '2px 8px' }}>Renewals</span>
            <span style={{ padding: '2px 8px' }}>Sheet4</span>
          </div>
        </div>

        {/* Back: Credz dashboard */}
        <div style={{
          position: 'absolute', inset: 0,
          backfaceVisibility: 'hidden',
          transform: 'rotateY(180deg)',
          background: 'white', borderRadius: 10, overflow: 'hidden',
          boxShadow: '0 24px 60px rgba(0,0,0,.35)'
        }}>
          {/* Header */}
          <div style={{ padding: '14px 18px', borderBottom: `1px solid ${WF.line2}`, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
            <div>
              <div style={{ fontSize: 11, color: WF.ink3, textTransform: 'uppercase', letterSpacing: '.08em', marginBottom: 2 }}>Credz Compliance Dashboard</div>
              <div style={{ fontWeight: 600, fontSize: 15, color: WF.ink }}>Maple Grove · 24 staff</div>
            </div>
            <div style={{ padding: '4px 10px', background: WF.okSoft, color: WF.ok, borderRadius: 999, fontSize: 11, fontWeight: 600 }}>● Live</div>
          </div>
          {/* Stat tiles */}
          <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 10, padding: 16 }}>
            {[
            { v: '22', l: 'Compliant', bg: WF.okSoft, fg: WF.ok },
            { v: '2', l: 'Expiring', bg: WF.warnSoft, fg: WF.warn },
            { v: '0', l: 'Expired', bg: WF.badSoft || '#fbe7e7', fg: WF.bad }].
            map((t) =>
            <div key={t.l} style={{ background: t.bg, color: t.fg, borderRadius: 10, padding: 14 }}>
                <div style={{ fontSize: 28, fontWeight: 600, lineHeight: 1 }}>{t.v}</div>
                <div style={{ fontSize: 11, fontWeight: 600, marginTop: 4, textTransform: 'uppercase', letterSpacing: '.05em' }}>{t.l}</div>
              </div>
            )}
          </div>
          {/* Compliance bar */}
          <div style={{ padding: '0 16px 12px' }}>
            <div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 11, color: WF.ink2, marginBottom: 6 }}>
              <span style={{ fontWeight: 600 }}>Overall compliance</span>
              <span style={{ color: WF.ok, fontWeight: 600 }}>92%</span>
            </div>
            <div style={{ height: 6, background: WF.fill2, borderRadius: 3, overflow: 'hidden' }}>
              <div style={{
                width: showCredz ? '92%' : '0%', height: '100%', background: WF.ok, borderRadius: 3,
                transition: 'width 1.2s cubic-bezier(.2,.7,.2,1) .3s'
              }} />
            </div>
          </div>
          {/* Staff list */}
          <div style={{ padding: '0 16px 16px' }}>
            <div style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: '.08em', color: WF.ink3, marginBottom: 8, fontWeight: 600 }}>Staff</div>
            {[
            ['Avery Mitchell', 'RN', '✓ 100%', WF.ok],
            ['Julian Thorne', 'RN', '✓ 100%', WF.ok],
            ['Priya Shah', 'PSW', '⚠ Renew CPR', WF.warn],
            ['Marcus Levesque', 'RPN', '✓ 100%', WF.ok],
            ['Sara Okafor', 'PSW', '✓ 100%', WF.ok]].
            map(([n, role, status, color], i) =>
            <div key={n} style={{
              display: 'flex', justifyContent: 'space-between', alignItems: 'center',
              padding: '8px 0', borderBottom: i < 4 ? `1px solid ${WF.line2}` : 'none',
              opacity: showCredz ? 1 : 0,
              transform: showCredz ? 'translateY(0)' : 'translateY(8px)',
              transition: `opacity .4s ${.4 + i * 0.08}s, transform .4s ${.4 + i * 0.08}s`
            }}>
                <div style={{ display: 'flex', gap: 10, alignItems: 'center' }}>
                  <div style={{ width: 22, height: 22, borderRadius: 11, background: WF.fill2 }} />
                  <div>
                    <div style={{ fontSize: 12, fontWeight: 600, color: WF.ink }}>{n}</div>
                    <div style={{ fontSize: 10, color: WF.ink3 }}>{role}</div>
                  </div>
                </div>
                <div style={{ fontSize: 11, color, fontWeight: 600 }}>{status}</div>
              </div>
            )}
          </div>
        </div>
      </div>
    </div>);

}

Object.assign(window, { ForCareWorkers, ForFacilities, ForAgencies, FacilitySyncDemo, AgencyReviewFlow, UnlinkFlowDemo, ExcelToCredzAnim });

// ──── UnlinkFlowDemo: revoke home access from your wallet in one tap ────
function UnlinkFlowDemo() {
  const [step, setStep] = React.useState(0);
  const maxStep = 4;
  React.useEffect(() => {
    const id = setInterval(() => setStep((s) => (s + 1) % (maxStep + 1)), 1900);
    return () => clearInterval(id);
  }, []);

  const steps = [
  { label: 'Open Credz wallet', tab: 'Documents' },
  { label: 'Tap the Links tab', tab: 'Links' },
  { label: 'Select Maple Grove', tab: 'Links' },
  { label: 'Tap Unlink', tab: 'Links' },
  { label: 'Access revoked', tab: 'Links' }];

  const cur = steps[step];

  return (
    <div>
      {/* Step tracker */}
      <div style={{ display: 'flex', justifyContent: 'center', gap: 8, marginBottom: 32, flexWrap: 'wrap' }}>
        {steps.map((s, i) =>
        <div key={i} style={{
          display: 'flex', alignItems: 'center', gap: 6,
          padding: '6px 12px', borderRadius: 999,
          background: i === step ? WF.ink : i < step ? WF.okSoft : WF.fill,
          color: i === step ? 'white' : i < step ? WF.ok : WF.ink2,
          border: `1px solid ${i === step ? WF.ink : i < step ? `${WF.ok}33` : WF.line2}`,
          fontSize: 12, fontWeight: 500, transition: 'all .3s'
        }}>
            <div style={{ width: 16, height: 16, borderRadius: 8, background: i === step ? 'white' : i < step ? WF.ok : WF.line2, color: i === step ? WF.ink : 'white', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 9, fontWeight: 700 }}>
              {i < step ? '✓' : i + 1}
            </div>
            {s.label}
          </div>
        )}
      </div>

      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.4fr 1fr', gap: 32, alignItems: 'center' }}>
        {/* Worker label */}
        <div style={{ textAlign: 'right' }}>
          <div className="wf-small" style={{ marginBottom: 4 }}>Worker</div>
          <div className="wf-h4" style={{ fontSize: 18 }}>Julian Thorne, RN</div>
          <div className="wf-small" style={{ marginTop: 4 }}>C0122-54276</div>
        </div>

        {/* Phone */}
        <div style={{ display: 'flex', justifyContent: 'center' }}>
          <div className="wf-phone">
            <div className="screen">
              <div style={{ padding: 14 }}>
                <div className="wf-display" style={{ fontSize: 14, marginBottom: 10 }}>My Wallet</div>
                {/* Tab bar */}
                <div style={{ display: 'flex', gap: 4, padding: 3, background: WF.fill, borderRadius: 999, marginBottom: 12 }}>
                  {['Documents', 'Links'].map((t) =>
                  <div key={t} style={{
                    flex: 1, padding: '5px 8px', borderRadius: 999, textAlign: 'center',
                    background: cur.tab === t ? WF.paper : 'transparent',
                    boxShadow: cur.tab === t ? '0 1px 3px rgba(0,0,0,.06)' : 'none',
                    fontSize: 11, fontWeight: 500, color: cur.tab === t ? WF.ink : WF.ink2,
                    transition: 'all .3s'
                  }}>{t}</div>
                  )}
                </div>

                {step === 0 &&
                <div style={{ animation: 'fadeIn .4s ease-out' }}>
                    {['RN License', 'CPR Level C', 'TB Skin Test', 'WHMIS'].map((d) =>
                  <div key={d} style={{ display: 'flex', justifyContent: 'space-between', padding: '6px 10px', background: WF.fill, borderRadius: 7, fontSize: 11, marginBottom: 4 }}>
                        <span>{d}</span><span style={{ color: WF.ok }}>✓</span>
                      </div>
                  )}
                  </div>
                }

                {step >= 1 &&
                <div style={{ animation: 'fadeIn .4s ease-out' }}>
                    <div className="wf-small" style={{ marginBottom: 6, fontSize: 10 }}>LINKED HOMES · 2</div>
                    {[
                  { name: 'Maple Grove Retirement', sub: 'Linked Jan 2024', selected: step >= 2 && step < 4, removed: step >= 4 },
                  { name: 'Cedar Park LTC', sub: 'Linked Aug 2025', selected: false, removed: false }].
                  map((h) =>
                  <div key={h.name} style={{
                    padding: 8,
                    background: h.selected ? WF.accentSoft : h.removed ? 'transparent' : WF.fill,
                    border: h.selected ? `1px solid ${WF.accent}` : h.removed ? `1px dashed ${WF.line2}` : `1px solid transparent`,
                    borderRadius: 7, marginBottom: 4,
                    opacity: h.removed ? 0.4 : 1,
                    transition: 'all .3s'
                  }}>
                        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
                          <div>
                            <div style={{ fontSize: 11, fontWeight: 600, textDecoration: h.removed ? 'line-through' : 'none' }}>{h.name}</div>
                            <div style={{ fontSize: 9, color: WF.ink2 }}>{h.removed ? '✗ Unlinked' : h.sub}</div>
                          </div>
                          {h.selected && !h.removed &&
                      <div style={{ color: WF.accent, fontSize: 12 }}>●</div>
                      }
                        </div>
                        {h.selected && step === 3 &&
                    <button style={{
                      marginTop: 8, width: '100%', padding: '7px', borderRadius: 6,
                      border: 'none', background: '#ff3b30', color: 'white',
                      fontSize: 11, fontWeight: 600, cursor: 'pointer',
                      animation: 'wfCheckPop .5s ease-out'
                    }}>
                            Unlink Home
                          </button>
                    }
                      </div>
                  )}

                    {step === 4 &&
                  <div style={{
                    marginTop: 8, padding: 10, background: WF.okSoft, borderRadius: 7,
                    border: `1px solid ${WF.ok}33`, textAlign: 'center',
                    animation: 'wfToastIn .4s ease-out'
                  }}>
                        <div style={{ fontSize: 10, color: WF.ok, fontWeight: 700 }}>✓ Access revoked</div>
                        <div style={{ fontSize: 9, color: WF.ink2, marginTop: 2 }}>Maple Grove no longer has access to your wallet.</div>
                      </div>
                  }
                  </div>
                }
              </div>
            </div>
          </div>
        </div>

        {/* Home admin view */}
        <div>
          <div className="wf-small" style={{ marginBottom: 4 }}>Maple Grove · Admin view</div>
          <div className="wf-card" style={{ padding: 14, opacity: step >= 4 ? 0.5 : 1, transition: 'opacity .5s' }}>
            <div style={{ display: 'flex', gap: 8, alignItems: 'center', marginBottom: 10 }}>
              <div style={{ width: 26, height: 26, borderRadius: 13, overflow: 'hidden' }}>
                <svg viewBox="0 0 60 60" width="26" height="26">
                  <defs><linearGradient id="avU" x1="0" x2="0" y1="0" y2="1"><stop offset="0%" stopColor="#e3d5c8" /><stop offset="100%" stopColor="#c7a98b" /></linearGradient></defs>
                  <rect width="60" height="60" fill="url(#avU)" />
                  <path d="M0,60 Q30,36 60,60 Z" fill="#2a6cb7" />
                  <rect x="25" y="34" width="10" height="10" fill="#c7a98b" />
                  <circle cx="30" cy="26" r="12" fill="#d9bda0" />
                  <path d="M18,20 Q30,8 42,20 L42,24 Q30,17 18,24 Z" fill="#3a2a1e" />
                  <circle cx="26" cy="26" r="1.2" fill="#1d1d1f" />
                  <circle cx="34" cy="26" r="1.2" fill="#1d1d1f" />
                  <path d="M26,31 Q30,33 34,31" stroke="#1d1d1f" strokeWidth="1" fill="none" strokeLinecap="round" />
                </svg>
              </div>
              <div style={{ fontSize: 12 }}>
                <div style={{ fontWeight: 600, textDecoration: step >= 4 ? 'line-through' : 'none' }}>Julian Thorne</div>
                <div style={{ color: step >= 4 ? '#ff3b30' : WF.ok, fontSize: 10 }}>
                  {step >= 4 ? '✗ Access revoked' : '✓ 18/18 verified · linked'}
                </div>
              </div>
            </div>
            {step >= 4 ?
            <div style={{
              padding: 10, background: 'rgba(255,59,48,.08)', border: '1px solid rgba(255,59,48,.25)',
              borderRadius: 6, fontSize: 10, color: '#b4232c', textAlign: 'center', animation: 'wfToastIn .4s ease-out'
            }}>
                Worker has unlinked. Their credentials are no longer visible.
              </div> :

            ['RN License · CNO', 'CPR Level C', 'TB Skin Test', 'WHMIS'].map((d) =>
            <div key={d} style={{ padding: '5px 8px', background: WF.fill, borderRadius: 5, fontSize: 10, marginBottom: 3, display: 'flex', justifyContent: 'space-between' }}>
                  <span>{d}</span><span style={{ color: WF.ok }}>✓</span>
                </div>
            )
            }
          </div>
          <div className="wf-small" style={{ marginTop: 8, textAlign: 'center', fontSize: 11 }}>
            {step >= 4 ? 'No access. No copies. Nothing left behind.' : 'Live link to worker\'s wallet'}
          </div>
        </div>
      </div>
    </div>);

}

// ──── AgencyReviewFlow: one-click send → home approves → onboarding date ────
function AgencyReviewFlow() {
  const [step, setStep] = React.useState(0);
  const maxStep = 3;
  React.useEffect(() => {
    const id = setInterval(() => setStep((s) => (s + 1) % (maxStep + 1)), 1900);
    return () => clearInterval(id);
  }, []);

  const rowBase = { display: 'flex', alignItems: 'center', gap: 10, padding: '8px 10px', background: WF.paper, borderRadius: 6, border: `1px solid ${WF.line2}`, fontSize: 11 };

  return (
    <div style={{ background: WF.paper, borderRadius: 12, padding: 16, boxShadow: '0 4px 16px rgba(0,113,227,.08)' }}>
      {/* Top bar */}
      <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12, paddingBottom: 10, borderBottom: `1px solid ${WF.line2}` }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
          <div style={{ width: 20, height: 20, borderRadius: 4, background: WF.accent, color: 'white', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 10, fontWeight: 600 }}>A</div>
          <div style={{ fontSize: 12, fontWeight: 600 }}>Northern Care Staffing</div>
          <span className="wf-small" style={{ fontSize: 10, color: WF.ink3 }}>→ Maple Grove LTC</span>
        </div>
        <div style={{ fontSize: 10, color: WF.ink3 }}>
          {['Staged', 'Sending', 'Under review', 'Approved'][step]}
        </div>
      </div>

      {/* Step 0–1: candidate ready to send */}
      {step < 2 &&
      <div>
          <div style={rowBase}>
            <Placeholder label="" w={28} h={28} radius={14} />
            <div style={{ flex: 1 }}>
              <div style={{ fontWeight: 600 }}>Sarah M · RN</div>
              <div className="wf-small" style={{ fontSize: 10 }}>18 / 18 verified · integrity ✓</div>
            </div>
            <Chip tone="ok">Credz</Chip>
          </div>
          <div style={{ marginTop: 10, padding: 10, background: WF.fill2, borderRadius: 6, display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 6, fontSize: 10 }}>
            {['RN License', 'CPR', 'TB', 'WHMIS', 'Police', 'First Aid'].map((d) =>
          <div key={d} style={{ padding: '4px 6px', background: WF.paper, borderRadius: 4, border: `1px solid ${WF.line2}`, display: 'flex', justifyContent: 'space-between' }}>
                <span>{d}</span><span style={{ color: WF.ok }}>✓</span>
              </div>
          )}
          </div>
          <div style={{ marginTop: 12, padding: '10px 14px', background: step === 0 ? WF.accent : WF.ink, color: 'white', borderRadius: 999, fontSize: 12, fontWeight: 500, textAlign: 'center', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
            {step === 0 ?
          <>↗ Send to Maple Grove for review</> :

          <><div style={{ width: 11, height: 11, borderRadius: 6, border: '2px solid white', borderTopColor: 'transparent', animation: 'spin 1s linear infinite' }} /> Sending live wallet…</>
          }
          </div>
        </div>
      }

      {/* Step 2: home reviewing */}
      {step === 2 &&
      <div>
          <div style={{ padding: 12, background: WF.warnSoft, border: `1px solid ${WF.warn}33`, borderRadius: 8, marginBottom: 10, fontSize: 11 }}>
            <div style={{ fontWeight: 600, color: WF.warn, marginBottom: 4, display: 'flex', alignItems: 'center', gap: 6 }}>
              <span>●</span> Maple Grove is reviewing
            </div>
            <div className="wf-small" style={{ fontSize: 10 }}>Director viewing Sarah's live wallet — no downloads, no copies.</div>
          </div>
          <div style={rowBase}>
            <Placeholder label="" w={24} h={24} radius={12} />
            <div style={{ flex: 1 }}>
              <div style={{ fontWeight: 600, fontSize: 11 }}>Sarah M · RN</div>
              <div className="wf-small" style={{ fontSize: 9 }}>Live view · no attachments</div>
            </div>
            <span style={{ fontSize: 10, color: WF.ink3 }}>Opened 3 min ago</span>
          </div>
          <div style={{ marginTop: 8, padding: 8, background: WF.fill, borderRadius: 6, fontSize: 10, color: WF.ink2, textAlign: 'center', fontStyle: 'italic' }}>
            "Looks great. Approving now."
          </div>
        </div>
      }

      {/* Step 3: approved with onboarding date */}
      {step === 3 &&
      <div>
          <div style={{ padding: 14, background: WF.okSoft, border: `1px solid ${WF.ok}33`, borderRadius: 8, marginBottom: 10, textAlign: 'center' }}>
            <div style={{ width: 32, height: 32, borderRadius: 16, background: WF.ok, color: 'white', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontSize: 16, fontWeight: 600, marginBottom: 6 }}>✓</div>
            <div style={{ fontWeight: 600, fontSize: 13, color: WF.ok, marginBottom: 2 }}>Approved by Maple Grove LTC</div>
            <div className="wf-small" style={{ fontSize: 10 }}>Sarah has been placed. Details written back to your pipeline.</div>
          </div>
          <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 6, marginBottom: 8 }}>
            {[
          ['Start date', 'Mon, Apr 28'],
          ['Orientation', 'Apr 26 · 9:00 AM'],
          ['Unit', 'Floor 3 — Memory Care'],
          ['Reports to', 'D. Chen, Nurse Mgr']].
          map(([k, v]) =>
          <div key={k} style={{ padding: 8, background: WF.fill2, borderRadius: 6, border: `1px solid ${WF.line2}`, fontSize: 10 }}>
                <div className="wf-small" style={{ fontSize: 9, textTransform: 'uppercase', letterSpacing: '.06em', marginBottom: 2 }}>{k}</div>
                <div style={{ fontWeight: 600, fontSize: 11 }}>{v}</div>
              </div>
          )}
          </div>
          <div style={{ padding: '8px 10px', background: WF.ink, color: 'white', borderRadius: 6, fontSize: 10, display: 'flex', justifyContent: 'space-between' }}>
            <span>Audit trail · date-stamped</span>
            <span style={{ color: '#64d08a', fontFamily: WF.mono }}>0x7f…3ab2</span>
          </div>
        </div>
      }

      {/* Step pips */}
      <div style={{ display: 'flex', justifyContent: 'center', gap: 6, marginTop: 14 }}>
        {Array.from({ length: maxStep + 1 }).map((_, i) =>
        <div key={i} style={{
          height: 3, width: i === step ? 24 : 12, borderRadius: 2,
          background: i === step ? WF.accent : WF.line,
          transition: 'all .3s'
        }} />
        )}
      </div>
    </div>);

}

// ──── FacilitySyncDemo: inter-facility sync auto-animation ────
function FacilitySyncDemo() {
  const [step, setStep] = React.useState(0);
  const maxStep = 4;
  React.useEffect(() => {
    const id = setInterval(() => setStep((s) => (s + 1) % (maxStep + 1)), 2000);
    return () => clearInterval(id);
  }, []);

  const typed = step === 0 ? '' : step === 1 ? 'Julian' : step === 2 ? 'Julian Thorne' : 'Julian Thorne';
  const cardBg = 'rgba(255,255,255,.08)';
  const cardBorder = 'rgba(255,255,255,.18)';
  const panel = { background: 'white', borderRadius: 14, color: WF.ink, padding: 18, boxShadow: '0 16px 40px rgba(0,0,0,.18)' };
  const miniLbl = { fontSize: 11, textTransform: 'uppercase', letterSpacing: '.08em', fontWeight: 600, color: 'rgba(255,255,255,.7)', marginBottom: 10, display: 'flex', alignItems: 'center', gap: 8 };

  return (
    <div>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 20, alignItems: 'stretch' }}>
        {/* MAPLE GROVE (inbound / searching) */}
        <div style={{ background: cardBg, border: `1px solid ${cardBorder}`, borderRadius: 14, padding: 20, minHeight: 420, display: 'flex', flexDirection: 'column' }}>
          <div style={miniLbl}>
            <span style={{ display: 'inline-block', width: 8, height: 8, borderRadius: 4, background: step >= 1 ? '#ffe89a' : 'rgba(255,255,255,.35)' }} />
            Maple Grove · Inbound home
          </div>
          <div style={panel}>
            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
              <div style={{ fontWeight: 600, fontSize: 13 }}>Credz Admin</div>
              <div className="wf-small" style={{ fontSize: 11 }}>Bench · 142 staff</div>
            </div>
            {/* search */}
            <div style={{ border: `1px solid ${step >= 1 && step < 3 ? WF.accent : WF.line}`, borderRadius: 10, padding: '9px 12px', display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12, background: WF.paper }}>
              <span style={{ fontSize: 13, color: WF.ink3 }}>🔍</span>
              <span style={{ fontFamily: WF.mono, fontSize: 12, color: WF.ink }}>{typed || 'Search network for a worker…'}</span>
              {step === 1 && <span style={{ display: 'inline-block', width: 1.5, height: 12, background: WF.accent, animation: 'blink 1s step-end infinite' }} />}
            </div>
            {/* result */}
            {step >= 1 && step < 3 &&
            <div style={{ padding: 10, background: WF.fill2, border: `1px solid ${WF.line2}`, borderRadius: 8, display: 'flex', gap: 10, alignItems: 'center' }}>
                <Placeholder label="" w={32} h={32} radius={16} />
                <div style={{ flex: 1, fontSize: 12 }}>
                  <div style={{ fontWeight: 600 }}>Julian Thorne, RN</div>
                  <div className="wf-small" style={{ fontSize: 10 }}>Linked at Pine Grove · 18/18 ✓</div>
                </div>
                <Chip tone="ok">Credz</Chip>
              </div>
            }
            {step === 1 &&
            <div style={{ marginTop: 10, padding: '9px 12px', background: WF.accent, color: 'white', borderRadius: 999, fontSize: 12, fontWeight: 500, textAlign: 'center' }}>
                Request sync from Pine Grove →
              </div>
            }
            {step === 2 &&
            <div style={{ marginTop: 10, padding: '9px 12px', background: WF.warnSoft, color: WF.warn, borderRadius: 8, fontSize: 11, fontWeight: 500, textAlign: 'center', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
                <div style={{ width: 12, height: 12, borderRadius: 6, border: `2px solid ${WF.warn}`, borderTopColor: 'transparent', animation: 'spin 1s linear infinite' }} />
                Awaiting Julian's approval
              </div>
            }
            {step >= 3 &&
            <div style={{ padding: 12, background: WF.okSoft, borderRadius: 10, textAlign: 'center', border: `1px solid ${WF.ok}33` }}>
                <div style={{ width: 30, height: 30, borderRadius: 15, background: WF.ok, color: 'white', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontSize: 15, fontWeight: 600, marginBottom: 6 }}>✓</div>
                <div style={{ fontWeight: 600, fontSize: 12, color: WF.ok, marginBottom: 2 }}>Success.</div>
                <div style={{ fontSize: 11, color: WF.ink2, lineHeight: 1.4 }}>Julian Thorne, RN is now synced to Maple Grove. 18/18 docs transferred.</div>
              </div>
            }
          </div>
        </div>

        {/* WORKER phone (center) */}
        <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 14 }}>
          {/* arrows */}
          <div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 11, color: 'rgba(255,255,255,.7)', fontWeight: 500, textTransform: 'uppercase', letterSpacing: '.08em' }}>
            <span style={{ opacity: step >= 1 ? 1 : 0.3 }}>← request</span>
            <span style={{ color: 'rgba(255,255,255,.4)' }}>·</span>
            <span style={{ opacity: step >= 3 ? 1 : 0.3 }}>approve →</span>
          </div>
          <div className="wf-phone" style={{ boxShadow: '0 24px 60px rgba(0,0,0,.25)' }}>
            <div className="screen">
              {step < 2 &&
              <div style={{ padding: 16, textAlign: 'center' }}>
                  <Placeholder label="" w={52} h={52} radius={26} style={{ margin: '8px auto 8px' }} />
                  <div style={{ fontWeight: 600, fontSize: 13 }}>Julian Thorne, RN</div>
                  <div className="wf-small" style={{ marginTop: 2, fontSize: 11 }}>CREDZ ID · C0122-54276</div>
                  <div style={{ marginTop: 14, padding: 10, background: WF.fill, borderRadius: 8, fontSize: 11, textAlign: 'left' }}>
                    <div style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: '.06em', color: WF.ink3, marginBottom: 6 }}>Connections</div>
                    <div style={{ display: 'flex', justifyContent: 'space-between', padding: '6px 0', borderBottom: `1px solid ${WF.line2}` }}>
                      <span>Pine Grove LTC</span><span style={{ color: WF.ok }}>✓ Linked</span>
                    </div>
                    <div style={{ padding: '8px 0 2px', color: WF.ink3, fontSize: 10 }}>No other homes yet</div>
                  </div>
                </div>
              }
              {step === 2 &&
              <div style={{ padding: 16 }}>
                  <Chip tone="accent">Sync request</Chip>
                  <div style={{ fontWeight: 600, fontSize: 13, marginTop: 10, marginBottom: 4 }}>Pine Grove LTC</div>
                  <div className="wf-small" style={{ fontSize: 11, lineHeight: 1.45, marginBottom: 10 }}>
                    is requesting to share your wallet with <strong style={{ color: WF.ink }}>Maple Grove LTC</strong>. Do you approve?
                  </div>
                  <div style={{ padding: 8, background: WF.fill, borderRadius: 8, fontSize: 10, marginBottom: 12 }}>
                    <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 3 }}>
                      <span style={{ color: WF.ink3 }}>From</span><span style={{ fontWeight: 600 }}>Pine Grove LTC</span>
                    </div>
                    <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 3 }}>
                      <span style={{ color: WF.ink3 }}>To</span><span style={{ fontWeight: 600 }}>Maple Grove LTC</span>
                    </div>
                    <div style={{ display: 'flex', justifyContent: 'space-between' }}>
                      <span style={{ color: WF.ink3 }}>Will share</span><span style={{ fontWeight: 600 }}>18 / 18 docs</span>
                    </div>
                  </div>
                  <div style={{ padding: '9px 12px', background: WF.accent, color: 'white', borderRadius: 999, fontSize: 11, fontWeight: 500, textAlign: 'center', marginBottom: 6 }}>
                    Yes, share my wallet
                  </div>
                  <div style={{ padding: '9px 12px', background: WF.fill, color: WF.ink2, borderRadius: 999, fontSize: 11, textAlign: 'center' }}>
                    Decline
                  </div>
                </div>
              }
              {step >= 3 &&
              <div style={{ padding: 16 }}>
                  <div style={{ textAlign: 'center', paddingBottom: 10, borderBottom: `1px solid ${WF.line2}`, marginBottom: 10 }}>
                    {step === 3 ?
                  <>
                        <div style={{ width: 40, height: 40, borderRadius: 20, background: WF.okSoft, display: 'inline-flex', alignItems: 'center', justifyContent: 'center', marginBottom: 8, color: WF.ok, fontSize: 18, fontWeight: 600 }}>✓</div>
                        <div style={{ fontWeight: 600, fontSize: 12 }}>Wallet shared</div>
                      </> :

                  <>
                        <div style={{ fontWeight: 600, fontSize: 13 }}>Julian Thorne, RN</div>
                        <div className="wf-small" style={{ fontSize: 10, marginTop: 2 }}>CREDZ ID · C0122-54276</div>
                      </>
                  }
                  </div>
                  <div style={{ fontSize: 10, textTransform: 'uppercase', letterSpacing: '.06em', color: WF.ink3, marginBottom: 8, fontWeight: 600 }}>Connections</div>
                  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '8px 10px', background: WF.fill2, borderRadius: 6, border: `1px solid ${WF.line2}`, marginBottom: 4, fontSize: 11 }}>
                    <div>
                      <div style={{ fontWeight: 600 }}>Pine Grove LTC</div>
                      <div style={{ fontSize: 9, color: WF.ink3 }}>Linked · 4 months</div>
                    </div>
                    <span style={{ color: WF.ok, fontWeight: 500 }}>✓ Linked</span>
                  </div>
                  <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '8px 10px', background: WF.okSoft, borderRadius: 6, border: `1px solid ${WF.ok}33`, fontSize: 11, animation: step === 4 ? 'fadeIn .4s' : 'none' }}>
                    <div>
                      <div style={{ fontWeight: 600 }}>Maple Grove LTC</div>
                      <div style={{ fontSize: 9, color: WF.ok }}>New · Just now</div>
                    </div>
                    <span style={{ color: WF.ok, fontWeight: 500 }}>✓ Linked</span>
                  </div>
                </div>
              }
            </div>
          </div>
          <div style={{ fontSize: 11, color: 'rgba(255,255,255,.7)', fontWeight: 500 }}>Julian · Credz app</div>
        </div>

        {/* PINE GROVE (outbound / originator) */}
        <div style={{ background: cardBg, border: `1px solid ${cardBorder}`, borderRadius: 14, padding: 20, minHeight: 420, display: 'flex', flexDirection: 'column' }}>
          <div style={miniLbl}>
            <span style={{ display: 'inline-block', width: 8, height: 8, borderRadius: 4, background: step >= 1 ? '#ffe89a' : 'rgba(255,255,255,.35)' }} />
            Pine Grove · Outbound home
          </div>
          <div style={panel}>
            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
              <div style={{ fontWeight: 600, fontSize: 13 }}>Julian Thorne · Profile</div>
              <Chip tone="ok">✓ 18/18</Chip>
            </div>
            <div style={{ padding: 10, background: WF.fill2, borderRadius: 8, marginBottom: 10, fontSize: 11, display: 'flex', alignItems: 'center', gap: 8, border: `1px solid ${WF.line2}` }}>
              <Placeholder label="" w={28} h={28} radius={14} />
              <div style={{ flex: 1 }}>
                <div style={{ fontWeight: 600, fontSize: 12 }}>Julian Thorne</div>
                <div className="wf-small" style={{ fontSize: 10 }}>RN · Linked since Dec '24</div>
              </div>
            </div>
            {step === 1 &&
            <div style={{ padding: 10, background: WF.warnSoft, border: `1px solid ${WF.warn}33`, borderRadius: 8, fontSize: 11 }}>
                <div style={{ fontWeight: 600, color: WF.warn, marginBottom: 2 }}>↗ Incoming sync request</div>
                <div style={{ fontSize: 10, color: WF.ink2 }}>Maple Grove LTC wants to sync Julian's wallet.</div>
              </div>
            }
            {step === 2 &&
            <div style={{ padding: 10, background: WF.accentSoft, border: `1px solid ${WF.accent}33`, borderRadius: 8, fontSize: 11, textAlign: 'center', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 8 }}>
                <div style={{ width: 12, height: 12, borderRadius: 6, border: `2px solid ${WF.accent}`, borderTopColor: 'transparent', animation: 'spin 1s linear infinite' }} />
                Forwarded · awaiting Julian
              </div>
            }
            {step >= 3 &&
            <div style={{ padding: 12, background: WF.okSoft, borderRadius: 10, textAlign: 'center', border: `1px solid ${WF.ok}33` }}>
                <div style={{ width: 30, height: 30, borderRadius: 15, background: WF.ok, color: 'white', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontSize: 15, fontWeight: 600, marginBottom: 6 }}>✓</div>
                <div style={{ fontWeight: 600, fontSize: 12, color: WF.ok, marginBottom: 2 }}>Shared with Maple Grove.</div>
                <div style={{ fontSize: 11, color: WF.ink2, lineHeight: 1.4 }}>Julian is now dual-linked. You keep full access at Pine Grove.</div>
              </div>
            }
          </div>
        </div>
      </div>

      {/* step pips */}
      <div style={{ display: 'flex', justifyContent: 'center', gap: 8, marginTop: 24 }}>
        {Array.from({ length: maxStep + 1 }).map((_, i) =>
        <div key={i} style={{
          height: 4, width: i === step ? 32 : 16, borderRadius: 2,
          background: i === step ? 'white' : 'rgba(255,255,255,.3)',
          transition: 'all .3s'
        }} />
        )}
      </div>
      <div style={{ textAlign: 'center', fontSize: 11, color: 'rgba(255,255,255,.6)', marginTop: 10 }}>
        {['Pine Grove already linked', 'Maple Grove finds Julian in the network', 'Julian gets a consent prompt', 'Approved — both homes sync', 'Worker\'s wallet shows both homes linked'][step]}
      </div>
    </div>);

}