// ===== m9-qualifications.jsx =====
// M9 · Qualifications — FR1 training & certification records, FR5 near-qualified

const {
  React,
  Card, Btn, IconBtn, StatusChip, Avatar, Kpi, Progress, Field, Input, Textarea, Select, Checkbox, Toggle, Tabs, Empty, SectionHead, TopBar,
  IconPlus, IconCheck, IconX, IconArrow, IconArrowL, IconDownload, IconUpload,
  IconBook, IconClock, IconUsers, IconAward, IconShield, IconSearch, IconFilter, IconBell,
  IconStar, IconEdit, IconExternal, IconMore, IconMail, IconFlag,
  VOLUNTEERS,
} = window;
const { useState: useQ9, useMemo: useQ9M } = React;

const q_over = { fontSize: 11, letterSpacing: "0.12em", textTransform: "uppercase", color: "var(--fg-3)", fontWeight: 500 };
const q_meta = { fontSize: 11, color: "var(--fg-3)" };

// Qualification TYPES — tenant-configurable
const QUAL_TYPES = [
  { id: "qt-firstaid",  category: "Certification", name: "CPR / First Aid (Red Cross)",  source: "External", validYears: 2, renewable: true,  evidence: "required", holders: 186, expiring30: 12, expired: 4 },
  { id: "qt-rmnaturalist", category: "Certification", name: "Rocky Mountain Naturalist", source: "External (CSU Extension)", validYears: 5, renewable: true, evidence: "required", holders: 24, expiring30: 0, expired: 1 },
  { id: "qt-wingshooter", category: "Certification", name: "Wingshooter Instructor",      source: "External (Kalkomey)", validYears: 3, renewable: true, evidence: "required", holders: 8,  expiring30: 1, expired: 0 },
  { id: "qt-camphost",     category: "Training",      name: "Camp host orientation",         source: "CPW LMS",  validYears: 1, renewable: true, evidence: "auto",      holders: 124, expiring30: 18, expired: 0 },
  { id: "qt-trail",        category: "Training",      name: "Trail crew safety",              source: "CPW LMS",  validYears: 1, renewable: true, evidence: "auto",      holders: 86,  expiring30: 8,  expired: 2 },
  { id: "qt-hunter-meth",  category: "Training",      name: "Hunter ed methodology",          source: "CPW LMS",  validYears: 3, renewable: true, evidence: "auto",      holders: 22,  expiring30: 0,  expired: 0 },
  { id: "qt-handbook",     category: "Onboarding",    name: "Volunteer handbook acknowledgment", source: "Acknowledgment", validYears: null, renewable: false, evidence: "auto", holders: 4127, expiring30: 0, expired: 0 },
  { id: "qt-sales",        category: "Training",      name: "CPW customer/sales platform",     source: "External (CPW IT)", validYears: 2, renewable: true, evidence: "required", holders: 38,  expiring30: 4, expired: 1 },
  { id: "qt-lang-spanish", category: "Language",      name: "Spanish (conversational)",         source: "Self-disclosed", validYears: null, renewable: false, evidence: "optional", holders: 142, expiring30: 0, expired: 0 },
  { id: "qt-lang-spanish-pro", category: "Language",  name: "Spanish (professional)",           source: "Self-disclosed", validYears: null, renewable: false, evidence: "review", holders: 28,  expiring30: 0, expired: 0 },
  { id: "qt-asl",          category: "Language",      name: "American Sign Language",           source: "Self-disclosed", validYears: null, renewable: false, evidence: "optional", holders: 6,   expiring30: 0, expired: 0 },
  { id: "qt-skill-photo",  category: "Skill",         source: "Self-disclosed", name: "Wildlife photography",  validYears: null, renewable: false, evidence: "optional", holders: 18, expiring30: 0, expired: 0 },
  { id: "qt-skill-bird",   category: "Skill",         source: "Self-disclosed", name: "Bird identification",   validYears: null, renewable: false, evidence: "optional", holders: 32, expiring30: 0, expired: 0 },
];

// Sample volunteer-held qualifications (for record view)
const QUAL_RECORDS = [
  { vol: "v-arenas",  type: "qt-firstaid",   completed: "Mar 8, 2024",  certDate: "Mar 8, 2024",  expires: "Mar 8, 2026",  status: "expired",   source: "Uploaded · red-cross-card.pdf", staffNote: "Following up on renewal." },
  { vol: "v-arenas",  type: "qt-camphost",   completed: "Apr 14, 2026", certDate: "Apr 14, 2026", expires: "Apr 14, 2027", status: "active",    source: "CPW LMS · auto-issued",          staffNote: "" },
  { vol: "v-arenas",  type: "qt-handbook",   completed: "Mar 14, 2018", certDate: "Mar 14, 2018", expires: null,            status: "active",    source: "Acknowledgment",                  staffNote: "" },
  { vol: "v-arenas",  type: "qt-lang-spanish-pro", completed: "Self · May 1, 2026", certDate: null, expires: null,         status: "pending",   source: "Self-disclosed",                  staffNote: "Awaiting review by Priya." },
  { vol: "v-okonkwo", type: "qt-firstaid",   completed: "May 12, 2024", certDate: "May 12, 2024", expires: "May 12, 2026",  status: "expiring",  source: "Uploaded · red-cross-card.pdf", staffNote: "Reminder sent May 1." },
  { vol: "v-okonkwo", type: "qt-hunter-meth",completed: "Jan 4, 2024",  certDate: "Jan 4, 2024",  expires: "Jan 4, 2027",   status: "active",    source: "CPW LMS · auto-issued",          staffNote: "" },
  { vol: "v-okonkwo", type: "qt-wingshooter",completed: "Sep 4, 2022",  certDate: "Sep 4, 2022",  expires: "Sep 4, 2025",   status: "expired",   source: "Kalkomey export",                staffNote: "Renewal class scheduled Jun 14." },
  { vol: "v-mendez",  type: "qt-firstaid",   completed: "Jun 14, 2025", certDate: "Jun 14, 2025", expires: "Jun 14, 2027",  status: "active",    source: "Uploaded · red-cross-card.pdf", staffNote: "" },
  { vol: "v-mendez",  type: "qt-trail",      completed: "Mar 30, 2025", certDate: "Mar 30, 2025", expires: "Mar 30, 2026",  status: "expired",   source: "CPW LMS",                         staffNote: "Auto-paused trail-crew signups." },
];

// Self-submitted qualifications awaiting staff review
const PENDING_SUBMISSIONS = [
  { id: "ps-1", vol: "v-arenas",  type: "qt-lang-spanish-pro", submitted: "Today, 8:14 am", evidence: "Resume + cert from Middlebury", note: "Worked 2 years at a bilingual school." },
  { id: "ps-2", vol: "v-kowalski", type: "qt-skill-photo",      submitted: "Yest, 4:42 pm", evidence: "Portfolio link",                  note: "Have published wildlife photos in CO Outdoors mag." },
  { id: "ps-3", vol: "v-tovar",    type: "qt-firstaid",          submitted: "Mon, 10:22 am",  evidence: "red-cross-renewed-may.pdf",        note: "Renewed last week, here's the new card." },
];

// Near-qualified records — vol is missing ONE thing to qualify for role
const NEAR_QUALIFIED = [
  { vol: "v-arenas",  role: "Trail crew", site: "Lory SP",      missing: ["Trail crew safety (overdue · renew)"],      ready: 5, total: 6 },
  { vol: "v-okonkwo", role: "Camp host",  site: "Boyd Lake SP", missing: ["First aid / CPR — expires May 12 (renew)"], ready: 4, total: 5 },
  { vol: "v-kowalski",role: "Naturalist", site: "Roxborough SP",missing: ["Naturalist program training (CSU Extension)"], ready: 3, total: 4 },
  { vol: "v-mendez",  role: "Trail crew", site: "Lake Pueblo SP", missing: ["Trail crew safety (renew)"],               ready: 5, total: 6 },
  { vol: "v-walsh",   role: "Hunter ed instructor", site: "Boulder field office", missing: ["Wingshooter Instructor cert", "First aid / CPR"], ready: 2, total: 4 },
  { vol: "v-park",    role: "Camp host", site: "Boyd Lake SP",  missing: ["Camp host orientation (overdue)"],             ready: 4, total: 5 },
];

// ============================================================
// ROOT
// ============================================================
const OrgQualifications = ({ go }) => {
  const [tab, setTab] = useQ9("types");
  return (
    <>
      <TopBar title="Qualifications" subtitle={`${QUAL_TYPES.length} qualification types · ${QUAL_RECORDS.length} sample records · ${PENDING_SUBMISSIONS.length} awaiting review · ${NEAR_QUALIFIED.length} near-qualified volunteers`}
        primary={<Btn icon={IconPlus}>New qualification type</Btn>}
        secondary={<Btn kind="secondary" icon={IconDownload}>Export</Btn>} />
      <div style={{ flex: 1, overflow: "auto", padding: "20px 32px 56px" }}>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(5, 1fr)", gap: 14, marginBottom: 22 }}>
          <Kpi label="Active holders" value="624" delta="across all types" tone="up" icon={IconUsers} />
          <Kpi label="Expiring 30 days" value="43" delta="prompt for renewal" tone="neutral" icon={IconClock} />
          <Kpi label="Expired" value="8" delta="signups auto-paused" tone="down" icon={IconShield} />
          <Kpi label="Pending review" value={PENDING_SUBMISSIONS.length.toString()} delta="self-submitted" tone="neutral" icon={IconClipboard} />
          <Kpi label="Near-qualified" value={NEAR_QUALIFIED.length.toString()} delta="1 cert away from a role" tone="up" icon={IconStar} />
        </div>

        <Tabs active={tab} onChange={setTab} tabs={[
          { id: "types",        label: "Types",                   count: QUAL_TYPES.length },
          { id: "records",      label: "Records",                 count: QUAL_RECORDS.length },
          { id: "review",       label: "Self-submissions",        count: PENDING_SUBMISSIONS.length },
          { id: "near",         label: "Near-qualified",          count: NEAR_QUALIFIED.length },
          { id: "expiring",     label: "Expiring soon",           count: 43 },
        ]} />

        {tab === "types"        && <TypesTab />}
        {tab === "records"      && <RecordsTab go={go} />}
        {tab === "review"       && <ReviewTab go={go} />}
        {tab === "near"         && <NearQualifiedTab go={go} />}
        {tab === "expiring"     && <ExpiringTab go={go} />}
      </div>
    </>
  );
};

const IconClipboard = window.IconClipboard;

// ---- TYPES ----
const TypesTab = () => {
  const [cat, setCat] = useQ9("all");
  const filtered = cat === "all" ? QUAL_TYPES : QUAL_TYPES.filter(q => q.category === cat);
  return (
    <>
      <div style={{ display: "flex", gap: 6, marginBottom: 14 }}>
        {["all", "Certification", "Training", "Language", "Skill", "Onboarding"].map(c => (
          <button key={c} onClick={() => setCat(c)} style={{
            padding: "7px 13px", borderRadius: 999, fontSize: 12, fontWeight: 500, cursor: "pointer", fontFamily: "inherit",
            background: cat === c ? "var(--coral-100)" : "transparent",
            color: cat === c ? "var(--coral-700)" : "var(--fg-1)",
            border: "1px solid " + (cat === c ? "var(--coral-200)" : "var(--border)"),
          }}>{c === "all" ? "All" : c}</button>
        ))}
      </div>
      <Card padded={false}>
        <div style={{ display: "grid", gridTemplateColumns: "minmax(220px, 1.6fr) 130px 160px 90px 100px 110px 110px 100px 36px", gap: 14, padding: "12px 18px", fontSize: 11, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--fg-3)", borderBottom: "1px solid var(--border)" }}>
          <span>Qualification</span><span>Category</span><span>Source</span><span>Validity</span><span>Evidence</span><span>Holders</span><span>Expiring 30d</span><span>Expired</span><span />
        </div>
        {filtered.map((q, i, arr) => (
          <div key={q.id} style={{ display: "grid", gridTemplateColumns: "minmax(220px, 1.6fr) 130px 160px 90px 100px 110px 110px 100px 36px", gap: 14, padding: "13px 18px", alignItems: "center", borderBottom: i === arr.length - 1 ? "none" : "1px solid var(--border-soft)", fontSize: 13 }}>
            <div>
              <div style={{ fontWeight: 500 }}>{q.name}</div>
              <div style={{ ...q_meta, marginTop: 2 }}>{q.renewable ? "Renewable" : "Lifetime"}</div>
            </div>
            <span style={{ fontSize: 11, padding: "2px 8px", borderRadius: 999, background: catBg(q.category), color: catFg(q.category), fontWeight: 500, justifySelf: "start" }}>{q.category}</span>
            <span style={{ ...q_meta }}>{q.source}</span>
            <span style={{ ...q_meta }}>{q.validYears ? `${q.validYears} yr` : "Lifetime"}</span>
            <span style={{ fontSize: 11, color: q.evidence === "required" ? "var(--crimson-600)" : q.evidence === "review" ? "var(--amber-600)" : q.evidence === "auto" ? "var(--sage-700)" : "var(--fg-3)", fontWeight: 500, textTransform: "capitalize" }}>{q.evidence}</span>
            <span style={{ fontSize: 13, fontVariantNumeric: "tabular-nums" }}>{q.holders.toLocaleString()}</span>
            <span style={{ fontSize: 12, color: q.expiring30 > 0 ? "var(--amber-600)" : "var(--fg-3)", fontWeight: q.expiring30 > 0 ? 500 : 400 }}>{q.expiring30}</span>
            <span style={{ fontSize: 12, color: q.expired > 0 ? "var(--crimson-600)" : "var(--fg-3)", fontWeight: q.expired > 0 ? 500 : 400 }}>{q.expired}</span>
            <IconBtn icon={IconMore} size={28} />
          </div>
        ))}
      </Card>
    </>
  );
};

function catBg(c) {
  if (c === "Certification") return "var(--amber-100)";
  if (c === "Training")      return "var(--iris-100)";
  if (c === "Language")      return "var(--sage-100)";
  if (c === "Skill")         return "var(--coral-100)";
  if (c === "Onboarding")    return "var(--paper-deep)";
  return "var(--paper-deep)";
}
function catFg(c) {
  if (c === "Certification") return "var(--amber-600)";
  if (c === "Training")      return "var(--iris-600)";
  if (c === "Language")      return "var(--sage-700)";
  if (c === "Skill")         return "var(--coral-700)";
  return "var(--fg-2)";
}

// ---- RECORDS ----
const RecordsTab = ({ go }) => (
  <Card padded={false}>
    <div style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.4fr) minmax(180px, 1.4fr) 120px 110px 100px 120px 36px", gap: 14, padding: "12px 18px", fontSize: 11, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--fg-3)", borderBottom: "1px solid var(--border)" }}>
      <span>Volunteer</span><span>Qualification</span><span>Completed</span><span>Expires</span><span>Status</span><span>Source</span><span />
    </div>
    {QUAL_RECORDS.map((r, i, arr) => {
      const v = VOLUNTEERS.find(x => x.id === r.vol);
      const t = QUAL_TYPES.find(x => x.id === r.type);
      if (!v || !t) return null;
      return (
        <div key={i} onClick={() => go("volunteer/" + v.id)} style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.4fr) minmax(180px, 1.4fr) 120px 110px 100px 120px 36px", gap: 14, padding: "13px 18px", alignItems: "center", borderBottom: i === arr.length - 1 ? "none" : "1px solid var(--border-soft)", cursor: "pointer", fontSize: 13 }}>
          <div style={{ display: "flex", gap: 10, alignItems: "center" }}>
            <Avatar {...v} />
            <span style={{ fontWeight: 500 }}>{v.name}</span>
          </div>
          <div>
            <div>{t.name}</div>
            <div style={{ ...q_meta, marginTop: 2 }}>{t.category}</div>
          </div>
          <span style={{ ...q_meta }}>{r.completed}</span>
          <span style={{ ...q_meta }}>{r.expires || "—"}</span>
          <StatusChip
            status={r.status === "active" ? "confirmed" : r.status === "expired" ? "expired" : r.status === "expiring" ? "info" : "pending"}
            size="sm"
            label={r.status === "active" ? "Active" : r.status === "expired" ? "Expired" : r.status === "expiring" ? "Expiring" : "Pending"} />
          <span style={{ ...q_meta }}>{r.source.split(" · ")[0]}</span>
          <IconBtn icon={IconExternal} size={28} />
        </div>
      );
    })}
  </Card>
);

// ---- REVIEW ----
const ReviewTab = ({ go }) => (
  <>
    <p style={{ fontSize: 13, color: "var(--fg-2)", marginBottom: 14, maxWidth: 620 }}>
      Volunteer-submitted qualifications awaiting staff review. Approve, reject, or request more evidence. Approved records become active and may unblock role eligibility.
    </p>
    <Card padded={false}>
      <div style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.2fr) minmax(180px, 1.4fr) minmax(180px, 1.4fr) 130px 220px", gap: 14, padding: "12px 18px", fontSize: 11, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--fg-3)", borderBottom: "1px solid var(--border)" }}>
        <span>Volunteer</span><span>Qualification</span><span>Evidence + note</span><span>Submitted</span><span>Action</span>
      </div>
      {PENDING_SUBMISSIONS.map((s, i, arr) => {
        const v = VOLUNTEERS.find(x => x.id === s.vol);
        const t = QUAL_TYPES.find(x => x.id === s.type);
        if (!v || !t) return null;
        return (
          <div key={s.id} style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.2fr) minmax(180px, 1.4fr) minmax(180px, 1.4fr) 130px 220px", gap: 14, padding: "13px 18px", alignItems: "start", borderBottom: i === arr.length - 1 ? "none" : "1px solid var(--border-soft)", fontSize: 13 }}>
            <div onClick={() => go("volunteer/" + v.id)} style={{ display: "flex", gap: 10, alignItems: "center", cursor: "pointer" }}>
              <Avatar {...v} />
              <span style={{ fontWeight: 500 }}>{v.name}</span>
            </div>
            <div>
              <div style={{ fontWeight: 500 }}>{t.name}</div>
              <div style={{ ...q_meta, marginTop: 2 }}>{t.category}</div>
            </div>
            <div>
              <div style={{ fontSize: 13, color: "var(--fg-1)", lineHeight: 1.5 }}>{s.note}</div>
              <div style={{ ...q_meta, marginTop: 4 }}>📎 {s.evidence}</div>
            </div>
            <span style={{ ...q_meta }}>{s.submitted}</span>
            <div style={{ display: "flex", gap: 6 }}>
              <Btn size="sm" kind="secondary" icon={IconX}>Reject</Btn>
              <Btn size="sm" kind="ghost">More info</Btn>
              <Btn size="sm" icon={IconCheck}>Approve</Btn>
            </div>
          </div>
        );
      })}
    </Card>
  </>
);

// ---- NEAR-QUALIFIED (FR5) ----
const NearQualifiedTab = ({ go }) => {
  const [role, setRole] = useQ9("all");
  const roles = Array.from(new Set(NEAR_QUALIFIED.map(n => n.role)));
  const filtered = role === "all" ? NEAR_QUALIFIED : NEAR_QUALIFIED.filter(n => n.role === role);
  return (
    <>
      <p style={{ fontSize: 13, color: "var(--fg-2)", marginBottom: 14, maxWidth: 660 }}>
        Volunteers who only need <strong>one or two more qualifications</strong> to qualify for a role. Use this to target Help Needed outreach and reduce time-to-active.
      </p>
      <div style={{ display: "flex", gap: 8, marginBottom: 14, alignItems: "center", flexWrap: "wrap" }}>
        <Select value={role} onChange={(e) => setRole(e.target.value)}
          options={[{ value: "all", label: "All roles" }, ...roles.map(r => ({ value: r, label: r }))]} />
        <Btn size="sm" kind="ghost">Within Northeast region</Btn>
        <div style={{ marginLeft: "auto", display: "flex", gap: 6 }}>
          <Btn size="sm" kind="secondary" icon={IconMail}>Help Needed outreach</Btn>
          <Btn size="sm" kind="secondary" icon={IconBell}>Send training nudge</Btn>
        </div>
      </div>
      <Card padded={false}>
        <div style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(180px, 1.2fr) minmax(220px, 1.6fr) 110px 130px 36px", gap: 14, padding: "12px 18px", fontSize: 11, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--fg-3)", borderBottom: "1px solid var(--border)" }}>
          <span>Volunteer</span><span>Role they want</span><span>Site</span><span>Missing</span><span>Progress</span><span>Action</span><span />
        </div>
        {filtered.map((n, i, arr) => {
          const v = VOLUNTEERS.find(x => x.id === n.vol);
          if (!v) return null;
          return (
            <div key={i} style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(180px, 1.2fr) minmax(220px, 1.6fr) 110px 130px 36px", gap: 14, padding: "13px 18px", alignItems: "center", borderBottom: i === arr.length - 1 ? "none" : "1px solid var(--border-soft)", fontSize: 13 }}>
              <div onClick={() => go("volunteer/" + v.id)} style={{ display: "flex", gap: 10, alignItems: "center", cursor: "pointer" }}>
                <Avatar {...v} />
                <div>
                  <div style={{ fontWeight: 500 }}>{v.name}</div>
                  <div style={{ ...q_meta, marginTop: 2 }}>{v.ytdHours} hr YTD</div>
                </div>
              </div>
              <span style={{ fontWeight: 500 }}>{n.role}</span>
              <span style={{ ...q_meta }}>{n.site}</span>
              <div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
                {n.missing.map(m => <span key={m} style={{ fontSize: 11, padding: "3px 8px", borderRadius: 6, background: "var(--amber-100)", color: "var(--amber-600)", fontWeight: 500, alignSelf: "flex-start" }}>{m}</span>)}
              </div>
              <div style={{ display: "flex", gap: 8, alignItems: "center" }}>
                <Progress value={n.ready} max={n.total} />
                <span style={{ ...q_meta, fontVariantNumeric: "tabular-nums" }}>{n.ready}/{n.total}</span>
              </div>
              <div style={{ display: "flex", gap: 4 }}>
                <Btn size="sm" kind="ghost" icon={IconMail}>Nudge</Btn>
                <Btn size="sm" kind="secondary" icon={IconBook}>Assign</Btn>
              </div>
              <IconBtn icon={IconMore} size={28} />
            </div>
          );
        })}
      </Card>
      <div style={{ marginTop: 14, padding: 14, background: "var(--paper-soft)", borderRadius: 12, fontSize: 12, color: "var(--fg-2)", lineHeight: 1.5, border: "1px solid var(--border-soft)" }}>
        <IconStar size={14} style={{ verticalAlign: "middle", marginRight: 6, color: "var(--coral-600)" }} />
        Sorted by impact — fewer-missing-qualifications first. Excludes volunteers with red/yellow flags from outreach. Recommendations are rule-based; no AI matching.
      </div>
    </>
  );
};

// ---- EXPIRING ----
const ExpiringTab = ({ go }) => (
  <>
    <p style={{ fontSize: 13, color: "var(--fg-2)", marginBottom: 14, maxWidth: 620 }}>
      Qualifications that have expired or are about to. Send renewal reminders, schedule renewal courses, or temporarily override with an audit trail.
    </p>
    <Card padded={false}>
      <div style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.2fr) minmax(180px, 1.4fr) 120px 110px 120px 200px", gap: 14, padding: "12px 18px", fontSize: 11, letterSpacing: "0.1em", textTransform: "uppercase", color: "var(--fg-3)", borderBottom: "1px solid var(--border)" }}>
        <span>Volunteer</span><span>Qualification</span><span>Expires</span><span>State</span><span>Impact</span><span>Action</span>
      </div>
      {QUAL_RECORDS.filter(r => r.status === "expired" || r.status === "expiring").map((r, i, arr) => {
        const v = VOLUNTEERS.find(x => x.id === r.vol);
        const t = QUAL_TYPES.find(x => x.id === r.type);
        if (!v || !t) return null;
        return (
          <div key={i} style={{ display: "grid", gridTemplateColumns: "minmax(180px, 1.2fr) minmax(180px, 1.4fr) 120px 110px 120px 200px", gap: 14, padding: "13px 18px", alignItems: "center", borderBottom: i === arr.length - 1 ? "none" : "1px solid var(--border-soft)", fontSize: 13 }}>
            <div onClick={() => go("volunteer/" + v.id)} style={{ display: "flex", gap: 10, alignItems: "center", cursor: "pointer" }}>
              <Avatar {...v} />
              <span style={{ fontWeight: 500 }}>{v.name}</span>
            </div>
            <div>{t.name}</div>
            <span style={{ ...q_meta }}>{r.expires}</span>
            <StatusChip status={r.status === "expired" ? "expired" : "info"} size="sm" label={r.status === "expired" ? "Expired" : "Expiring"} />
            <span style={{ fontSize: 11, color: r.status === "expired" ? "var(--crimson-600)" : "var(--amber-600)", fontWeight: 500 }}>{r.status === "expired" ? "Signups paused" : "Auto-pause in 14d"}</span>
            <div style={{ display: "flex", gap: 4 }}>
              <Btn size="sm" kind="ghost" icon={IconMail}>Remind</Btn>
              <Btn size="sm" kind="secondary">Override</Btn>
              <Btn size="sm" icon={IconBook}>Schedule</Btn>
            </div>
          </div>
        );
      })}
    </Card>
  </>
);

// ============================================================
Object.assign(window, { OrgQualifications });
