// Autentiche digitali — dashboard, emissione in 3 passaggi, proprietario, email, accettazione, verifica, diritto di segreteria, diritto di seguito.
const { useState: aS, useEffect: aE } = React;
const T2 = (s, it, en) => (s.lang === "en" ? en : it);
const OWN = { none: ["lt", "Non assegnata", "Unassigned"], invited: ["warn", "In attesa di accettazione", "Awaiting acceptance"], claimed: ["ok", "Assegnata", "Assigned"], declined: ["bad", "Rifiutata", "Declined"], expired: ["lt", "Invito scaduto", "Invitation expired"] };
const ownKey = (c) => (!c.ownerId ? "none" : c.claim || "invited");
const CST = { draft: ["lt", "Bozza", "Draft"], issued: ["ok", "Emessa", "Issued"], revoked: ["bad", "Revocata", "Revoked"], superseded: ["lt", "Sostituita", "Replaced"] };
const PAY = { none: "Non richiesto", due: "Da pagare", processing: "Pagamento in corso", paid: "Pagato", refunded: "Rimborsato" };
const feeCfg = (s) => s.adminFee || { on: false, amount: 40, cur: "EUR" };
const money = (n, cur) => (cur === "USD" ? "$ " : cur === "GBP" ? "£ " : cur === "CHF" ? "CHF " : "€ ") + Number(n).toLocaleString("it-IT");
const OwnPill = ({ c }) => { const { s } = useC(); const k = OWN[ownKey(c)]; return <Pill k={k[0]}>{T2(s, k[1], k[2])}</Pill>; };
const CstPill = ({ c }) => { const { s } = useC(); const k = CST[c.status] || CST.issued; return <Pill k={k[0]}>{T2(s, k[1], k[2])}</Pill>; };
const txHash = (c) => (c && c.hash ? "0x" + c.hash.slice(32) + c.hash.slice(0, 32) : null);
const shortTx = (x) => (x ? x.slice(0, 12) + "…" + x.slice(-8) : "");
function ArchStamp({ size = 74 }) { const { s } = useC(); if (s.archive.stamp) return <img className="au-stamp" src={s.archive.stamp} alt="Timbro dell'archivio" style={{ width: size, height: size }} />;
  const n = (s.archive.name || "").toUpperCase(); return <svg className="au-stamp" viewBox="0 0 100 100" width={size} height={size} aria-label="Timbro dell'archivio"><defs><path id="stp" d="M50 50 m-36 0 a36 36 0 1 1 72 0 a36 36 0 1 1 -72 0" /></defs><circle cx="50" cy="50" r="46" fill="none" stroke="currentColor" strokeWidth="1.6" /><circle cx="50" cy="50" r="27" fill="none" stroke="currentColor" strokeWidth="1" /><text fontSize="8.6" letterSpacing="1.4" fill="currentColor"><textPath href="#stp">{n} · {n}</textPath></text><text x="50" y="54" textAnchor="middle" fontSize="11" fontWeight="600" fill="currentColor">{s.archive.mark || "AR"}</text></svg>; }
function TxExplain({ c, who = "archive", compact }) { const { s } = useC(); const t = (x, y) => T2(s, x, y); const tx = txHash(c); const on = c && c.anchored !== false;
  return <div className={"au-tx" + (compact ? " sm" : "")}><div className="au-tx-h"><svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" strokeWidth="1.7"><rect x="4" y="10" width="16" height="10" rx="2" /><path d="M8 10V7a4 4 0 0 1 8 0v3" /></svg><b>{t("Registrata con un codice univoco", "Registered with a unique code")}</b>{on ? <Pill k="ok">{t("Confermata", "Confirmed")}</Pill> : <Pill k="warn">{t("In conferma", "Confirming")}</Pill>}</div>
    <div className="au-tx-c"><span>{t("Codice transazione", "Transaction code")}</span><b className="mono">{on ? shortTx(tx) : t("in attesa…", "pending…")}</b></div>
    {!compact && <ul><li>{t("Il codice è unico: identifica solo questa autentica e solo quest'opera.", "The code is unique: it identifies only this certificate and this artwork.")}</li><li>{t("Non è falsificabile: chiunque può verificarlo con il QR code o l'ID.", "It can't be forged: anyone can check it with the QR code or ID.")}</li><li>{t("Non è modificabile né trasferibile ad altre opere: ogni cambiamento dei dati produrrebbe un codice diverso.", "It can't be edited or moved to another artwork: any data change would produce a different code.")}</li><li>{who === "archive" ? t("Per correggere, l'archivio emette una nuova autentica che sostituisce la precedente; lo storico resta visibile.", "To correct it, the archive issues a replacement; history stays visible.") : t("Solo l'archivio può sostituirla o revocarla, e ogni passaggio resta registrato.", "Only the archive can replace or revoke it, and every step stays on record.")}</li></ul>}
  </div>; }
const LangSw = () => { const { s, mut } = useC(); return <div className="seg au-lang">{[["it", "IT"], ["en", "EN"]].map(([k, l]) => <button key={k} className={(s.lang || "it") === k ? "on" : ""} onClick={() => mut((n) => { n.lang = k; })}>{l}</button>)}</div>; };

function sendInvite(n, certId, owner) {
  const c = byId(n.certs, certId); let cid = owner.id;
  if (!cid) { cid = "c" + Date.now(); n.collectors.push({ id: cid, name: owner.name.trim(), email: owner.email.trim(), city: "", kind: owner.kind || "Privato", notes: owner.notes || "" }); }
  const o = byId(n.collectors, cid); c.ownerId = cid; c.claim = "invited"; c.invite = { sentAt: today(), to: o.email, token: Math.random().toString(36).slice(2, 10), expires: "30 giorni", delivery: "In consegna" };
  n.mails = n.mails || []; n.mails.push({ id: "m" + Date.now(), certId, to: o.email, toName: o.name, kind: "invite", at: today(), status: "In consegna" });
  log(n, { type: "proprieta", artworkId: c.artworkId, text: `Invito inviato a ${o.name} · ${certId}` });
}

// ---------------- Dashboard ----------------
function AuthDash() {
  const { s, go, mut } = useC(); const [f, setF] = aS(""); const [as, setAs] = aS(null); const [mail, setMail] = aS(null); const t = (a, b) => T2(s, a, b);
  const F = { "": () => true, issued: (c) => c.status === "issued", none: (c) => c.status === "issued" && !c.ownerId, invited: (c) => c.status === "issued" && c.ownerId && c.claim === "invited", claimed: (c) => c.claim === "claimed", declined: (c) => ["declined", "expired"].includes(c.claim), revoked: (c) => c.status === "revoked", paid: (c) => c.payment === "paid", due: (c) => c.payment === "due" };
  const L = s.certs.filter(F[f] || F[""]).slice().reverse();
  const cnt = (k) => s.certs.filter(F[k]).length;
  return <div className="page au">
    <div className="ph"><div><h1>{t("Autentiche digitali", "Digital certificates")}</h1><p className="au-in">{t("Gestisci le autentiche delle opere del tuo archivio in un unico spazio. Emetti certificati digitali, verifica le informazioni delle opere e, quando lo desideri, associa ogni certificato al suo proprietario.", "Manage your archive's certificates in one place. Issue digital certificates, verify artwork information and, when you wish, link each certificate to its owner.")}</p>
      </div>
      <div className="row"><LangSw /><Btn onClick={() => go({ v: "archive", p: "settings", sec: "fee" })}>{t("Diritto di segreteria", "Administrative fee")}</Btn><Btn k="dark" onClick={() => go({ v: "archive", p: "newauth" })}><Ic.plus /> {t("Nuova autentica", "New certificate")}</Btn></div></div>
    {(() => { const iss = s.certs.filter((c) => c.status === "issued"); const acc = iss.filter((c) => c.claim === "claimed").length; const pend = iss.filter((c) => c.ownerId && c.claim === "invited").length; const un = iss.filter((c) => !c.ownerId).length; const rej = iss.filter((c) => ["declined", "expired"].includes(c.claim)).length;
      const paid = s.certs.filter((c) => c.payment === "paid").reduce((x, c) => x + (c.fee ? c.fee.amount : 0), 0); const due = s.certs.filter((c) => c.payment === "due").reduce((x, c) => x + (c.fee ? c.fee.amount : 0), 0); const cur = (feeCfg(s).cur);
      const K = [[t("Emesse", "Issued"), iss.length, "issued"], [t("Accettate", "Accepted"), acc, "claimed"], [t("In attesa", "Pending"), pend, "invited"], [t("Non assegnate", "Unassigned"), un, "none"], [t("Rifiutate o scadute", "Declined / expired"), rej, "declined"], [t("Segreteria riscossa", "Fees collected"), money(paid, cur), "paid"], [t("Da riscuotere", "To collect"), money(due, cur), "due"]];
      return <div className="au-k">{K.map(([l, v, k]) => <button key={k} className={f === k ? "on" : ""} onClick={() => setF(f === k ? "" : k)}><b>{v}</b><span>{l}</span></button>)}</div>; })()}
    <details className="au-how"><summary>{t("Come funzionano le autentiche digitali?", "How do digital certificates work?")}</summary><h2 style={{ display: "none" }}>{t("Come funzionano le autentiche digitali?", "How do digital certificates work?")}</h2>
      
      <ol>{[[t("Emetti il certificato", "Issue the certificate"), t("Seleziona un'opera, verifica le informazioni e genera la sua autentica digitale.", "Select an artwork, verify its information and generate its digital certificate.")],
        [t("Associa un proprietario", "Link an owner"), t("Se conosci il proprietario, puoi invitarlo a ricevere il certificato. Puoi anche farlo successivamente.", "If you know the owner, invite them to receive the certificate. You can also do it later.")],
        [t("Conserva e verifica", "Keep and verify"), t("Ogni certificato viene registrato su Certify ed è verificabile tramite un codice identificativo e un QR code.", "Each certificate is registered on Certify and can be verified with its identifier and QR code.")]].map(([a, b], i) => <li key={i}><span>{i + 1}</span><div><b>{a}</b><p>{b}</p></div></li>)}</ol><TxExplain c={{ hash: "0".repeat(64), anchored: true }} compact={false} /></details>
    <div className="tools"><div className="seg">{[["", t("Tutte", "All")], ["issued", t("Emesse", "Issued")], ["none", t("Non assegnate", "Unassigned")], ["invited", t("In attesa di accettazione", "Awaiting acceptance")], ["claimed", t("Accettate", "Accepted")], ["revoked", t("Revocate", "Revoked")]].map(([k, l]) => <button key={k} className={f === k ? "on" : ""} onClick={() => setF(k)}>{l} <em>{cnt(k)}</em></button>)}</div></div>
    {L.length ? <div className="tbl"><table><thead><tr><th></th><th>{t("Artista e titolo", "Artist and title")}</th><th>{t("ID autentica", "Certificate ID")}</th><th>{t("Emessa il", "Issued")}</th><th>{t("Proprietario", "Owner")}</th><th>{t("Segreteria", "Fee")}</th><th>{t("Stato", "Status")}</th><th></th></tr></thead><tbody>
      {L.map((c) => { const a = byId(s.works, c.artworkId); const o = c.ownerId && byId(s.collectors, c.ownerId); return <tr key={c.id} onClick={() => go({ v: "archive", p: "cert", id: c.id })}>
        <td style={{ width: 52 }}><div className="th"><Art a={a} label={false} r={6} /></div></td>
        <td><span className="mut sm">{c.snapshot.artist}</span><div><b>{c.snapshot.title}</b></div></td>
        <td className="mono">{c.id}</td><td>{c.issuedAt}</td>
        <td>{o ? <><div>{o.name}</div><OwnPill c={c} /></> : <OwnPill c={c} />}{c.fee && <div className="au-fee-m">{c.payment === "paid" ? t("Segreteria riscossa", "Fee collected") : t("Segreteria: ", "Fee: ") + PAY[c.payment]}</div>}</td><td onClick={(e) => e.stopPropagation()}>{!c.fee ? <span className="mut sm">{t("Non richiesto", "Not required")}</span> : c.payment === "paid" ? <Pill k="ok">{money(c.fee.amount, c.fee.cur)} · {t("Riscosso", "Collected")}</Pill> : <span className="au-pay"><Pill k="warn">{money(c.fee.amount, c.fee.cur)} · {PAY[c.payment]}</Pill><button className="lnk" onClick={() => mut((n) => { const x = byId(n.certs, c.id); x.payment = "paid"; log(n, { type: "autentica", artworkId: c.artworkId, text: "Diritto di segreteria riscosso · " + c.id }); })}>{t("Segna come pagato", "Mark paid")}</button></span>}</td><td><CstPill c={c} /></td>
        <td className="au-act" onClick={(e) => e.stopPropagation()}>{c.status === "issued" && (!c.ownerId || ["declined", "expired"].includes(c.claim)) ? <Btn k="sm" onClick={() => setAs(c.id)}>{t("Associa proprietario", "Link owner")}</Btn> : c.claim === "invited" ? <Btn k="sm" onClick={() => setMail(c.id)}>{t("Vedi invito", "View invite")}</Btn> : <Btn k="sm" onClick={() => go({ v: "verify", id: c.id })}><Ic.qr /></Btn>}</td></tr>; })}
    </tbody></table></div>
      : <div className="card empty-c"><Ic.seal /><h3>{t("Nessuna autentica in questa vista", "No certificates in this view")}</h3><p className="mut">{t("Emetti la prima autentica da un'opera del catalogo.", "Issue your first certificate from a catalogued artwork.")}</p><Btn k="dark" onClick={() => go({ v: "archive", p: "newauth" })}><Ic.plus /> {t("Nuova autentica", "New certificate")}</Btn></div>}
    {as && <AssignOwner certId={as} onClose={() => setAs(null)} onSent={() => { setMail(as); setAs(null); }} />}
    {mail && <Modal title={t("Email al proprietario", "Owner email")} onClose={() => setMail(null)}><OwnerEmail certId={mail} /><InviteStatus certId={mail} /></Modal>}
  </div>;
}

// ---------------- Owner assignment ----------------
function OwnerFields({ v, set }) {
  const { s } = useC(); const t = (a, b) => T2(s, a, b);
  return <div className="au-of">
    <label className="fld"><span>{t("Seleziona un proprietario esistente", "Pick an existing owner")}</span><select value={v.id || ""} onChange={(e) => { const o = byId(s.collectors, e.target.value); set(o ? { ...v, id: o.id, name: o.name, email: o.email } : { ...v, id: "", name: "", email: "" }); }}><option value="">{t("— Nuovo proprietario —", "— New owner —")}</option>{s.collectors.map((o) => <option key={o.id} value={o.id}>{o.name} · {o.email}</option>)}</select></label>
    {!v.id && <><div className="au-g2"><label className="fld"><span>{t("Nome e cognome / Ragione sociale", "Full name / Company")} *</span><input value={v.name} onChange={(e) => set({ ...v, name: e.target.value })} /></label>
      <label className="fld"><span>Email *</span><input type="email" value={v.email} onChange={(e) => set({ ...v, email: e.target.value })} placeholder="nome@esempio.it" /></label></div>
      <div className="fld"><span>{t("Tipologia", "Type")}</span><div className="seg">{["Privato", "Azienda"].map((k) => <button key={k} className={v.kind === k ? "on" : ""} onClick={() => set({ ...v, kind: k })}>{k === "Privato" ? t("Privato", "Private") : t("Azienda", "Company")}</button>)}</div></div></>}
    <label className="fld"><span>{t("Note interne (facoltative)", "Internal notes (optional)")}</span><textarea rows={2} value={v.notes} onChange={(e) => set({ ...v, notes: e.target.value })} /></label>
    <p className="mut sm au-priv"><Ic.lock /> {t("I dati del proprietario restano riservati all'archivio e non compaiono nella verifica pubblica.", "Owner details stay private to the archive and never appear in the public verification.")}</p>
  </div>;
}
const ownerOk = (v) => v.id || (v.name.trim() && /\S+@\S+\.\S+/.test(v.email));
function AssignOwner({ certId, onClose, onSent }) {
  const { s, mut, say } = useC(); const [v, setV] = aS({ id: "", name: "", email: "", kind: "Privato", notes: "" }); const t = (a, b) => T2(s, a, b);
  return <Modal title={t("Associa proprietario", "Link owner")} onClose={onClose}>
    <p className="mut" style={{ marginTop: 0 }}>{t("Invita il proprietario dell'opera a ricevere il certificato digitale. Una volta accettato, il certificato sarà disponibile nel suo account Certify.", "Invite the artwork's owner to receive the digital certificate. Once accepted, it will be available in their Certify account.")}</p>
    <OwnerFields v={v} set={setV} />
    <div className="row" style={{ justifyContent: "flex-end", marginTop: 14 }}><Btn onClick={onClose}>{t("Annulla", "Cancel")}</Btn><Btn k="dark" disabled={!ownerOk(v)} onClick={() => { mut((n) => sendInvite(n, certId, v)); say(t("Invito inviato (simulato)", "Invitation sent (simulated)")); onSent && onSent(); }}>{t("Invia invito", "Send invitation")}</Btn></div>
  </Modal>;
}
function InviteStatus({ certId }) {
  const { s, mut, say, go } = useC(); const c = byId(s.certs, certId); const o = c && c.ownerId && byId(s.collectors, c.ownerId); const t = (a, b) => T2(s, a, b);
  if (!c || !o || !c.invite) return null; const inv = c.invite;
  return <div className="au-inv">
    <div className="au-inv-h"><b>{t("Invito inviato", "Invitation sent")}</b><OwnPill c={c} /></div>
    <p className="mut sm">{t(`Abbiamo inviato un'email a ${o.email}. Il certificato rimarrà in attesa di accettazione fino alla conferma del proprietario.`, `We emailed ${o.email}. The certificate will await acceptance until the owner confirms.`)}</p>
    <dl className="pdl"><dt>{t("Destinatario", "Recipient")}</dt><dd>{o.name} · {o.email}</dd><dt>{t("Data invito", "Sent on")}</dt><dd>{inv.sentAt}</dd><dt>{t("Consegna", "Delivery")}</dt><dd>{inv.delivery} <span className="mut sm">· simulata</span></dd><dt>{t("Link", "Link")}</dt><dd>{t("Monouso, scade tra", "Single-use, expires in")} {inv.expires}</dd></dl>
    {c.claim === "invited" && <div className="row" style={{ flexWrap: "wrap" }}>
      <Btn k="sm" onClick={() => { mut((n) => { const x = byId(n.certs, c.id); x.invite = { ...x.invite, sentAt: today(), token: Math.random().toString(36).slice(2, 10) }; n.mails.push({ id: "m" + Date.now(), certId: c.id, to: o.email, toName: o.name, kind: "reminder", at: today(), status: "In consegna" }); log(n, { type: "proprieta", artworkId: c.artworkId, text: `Invito reinviato a ${o.name} · ${c.id}` }); }); say(t("Invito reinviato", "Invitation resent")); }}>{t("Reinvia invito", "Resend")}</Btn>
      <Btn k="sm" onClick={() => { mut((n) => { const x = byId(n.certs, c.id); x.ownerId = null; x.claim = null; x.invite = null; log(n, { type: "proprieta", artworkId: c.artworkId, text: `Invito annullato · ${c.id}` }); }); say(t("Invito annullato · l'autentica resta valida", "Invitation cancelled · certificate stays valid")); }}>{t("Annulla invito", "Cancel invitation")}</Btn>
      <Btn k="sm dark" onClick={() => go({ v: "collector", p: "claim", id: c.id })}>{t("Apri come proprietario", "Open as owner")} →</Btn></div>}
    <p className="mut sm">{t("L'autentica resta valida anche se l'invito scade o viene rifiutato.", "The certificate stays valid even if the invitation expires or is declined.")}</p>
  </div>;
}

// ---------------- Owner email ----------------
function OwnerEmail({ certId }) {
  const { s, go } = useC(); const c = byId(s.certs, certId); const a = c && byId(s.works, c.artworkId); const o = c && c.ownerId && byId(s.collectors, c.ownerId);
  if (!c || !o) return null; const first = o.name.split(" ")[0];
  return <div className="em"><div className="em-m"><div><span>Da</span>Certify per conto di {s.archive.name}</div><div><span>A</span>{o.email}</div><div><span>Oggetto</span><b>Un'opera a te associata è stata certificata digitalmente</b></div></div>
    <div className="em-b"><p>Buongiorno {first},</p>
      <p>{s.archive.name} ti ha indicato come proprietario dell'opera <i>{c.snapshot.title}</i> di {c.snapshot.artist}.</p>
      <div className="em-w"><div style={{ width: 70, height: 84 }}><Art a={a} label={false} r={4} /></div><div><b>{c.snapshot.artist}</b><i>{c.snapshot.title}</i><span>{c.snapshot.year} · {c.id}</span></div></div>
      <p>L'archivio utilizza Certify per emettere e gestire le autentiche digitali delle proprie opere. È stato emesso un certificato digitale relativo a quest'opera, che potrai consultare e conservare nel tuo account personale.</p>
      <p>Per ricevere il certificato, ti chiediamo di verificare il tuo indirizzo email e confermare l'assegnazione.</p>
      <button className="btn dark" style={{ width: "100%", justifyContent: "center" }} onClick={() => go({ v: "collector", p: "claim", id: c.id })}>Visualizza e accetta il certificato</button>
      <p>Il certificato è registrato con un codice univoco: non può essere falsificato, modificato o trasferito ad altre opere, e puoi verificarlo in qualsiasi momento.</p><p>Una volta completata la procedura, potrai accedere al certificato in qualsiasi momento attraverso Certify.</p>
      <p className="mut sm">Se ritieni che questa assegnazione non sia corretta, potrai segnalarlo prima di accettarla.</p>
      <p>Certify</p><p className="mut sm">Link sicuro, monouso, con scadenza · Email simulata</p></div></div>;
}

// ---------------- Issue: 3 steps ----------------
function NewAuth3() {
  const { s, mut, go, say } = useC(); const t = (a, b) => T2(s, a, b); const fee = feeCfg(s);
  const [step, setStep] = aS(0); const [q, setQ] = aS(""); const [pick, setPick] = aS(s.route.id || null); const [cs, setCs] = aS(null);
  const [tpl, setTpl] = aS(s.archive.template || "standard"); const [sig, setSig] = aS(`${s.archive.signatory} · ${s.archive.role}`);
  const [want, setWant] = aS(null); const [own, setOwn] = aS({ id: "", name: "", email: "", kind: "Privato", notes: "" }); const [ok, setOk] = aS(false); const [busy, setBusy] = aS(false); const [res, setRes] = aS(null); const [mail, setMail] = aS(false);
  const free = s.works.filter((a) => !certOf(s, a.id));
  const L = free.filter((a) => (a.title + a.year + (a.catNo || "") + (a.medium || "")).toLowerCase().includes(q.toLowerCase())).slice(0, 60);
  const a = pick && byId(s.works, pick);
  const pre = (s.certs[0] && s.certs[0].id.split("-").slice(0, 2).join("-")) || "CERT-" + (s.archive.mark || "AR"); const nextId = `${pre}-${String(s.certs.length + 124).padStart(6, "0")}`;
  aE(() => { if (a) setCs(snapOf(s, a)); }, [pick]);
  const dup = a && certOf(s, a.id);
  const edited = a && cs && JSON.stringify(cs) !== JSON.stringify(snapOf(s, a));
  const emit = async () => {
    if (busy || dup) return; setBusy(true); const id = nextId; const h = await sha({ ...cs, id, note: "" });
    mut((n) => { if (certOf(n, a.id)) return; const x = byId(n.works, a.id); x.authState = { status: "approved" };
      n.certs.push({ id, artworkId: a.id, snapshot: cs, hash: h, issuedAt: today(), status: "issued", ownerId: null, claim: null, invite: null, public: true, note: "", replaces: null, anchored: false, template: tpl, signatory: sig, fee: fee.on ? { amount: fee.amount, cur: fee.cur } : null, payment: fee.on ? "due" : "none", history: [{ at: today(), text: "Autentica emessa · firmata da " + sig }] });
      log(n, { type: "autentica", artworkId: a.id, text: `${cs.title}: autentica ${id} emessa`, hash: h.slice(0, 10) });
      if (want && ownerOk(own)) sendInvite(n, id, own); });
    setTimeout(() => mut((n) => { const c = byId(n.certs, id); if (c) c.anchored = true; }), 3000);
    setRes(id); setBusy(false); setStep(3);
  };
  const S = [t("Verifica opera", "Verify artwork"), t("Certificato e proprietario", "Certificate and owner"), t("Conferma", "Confirm")];
  const F = (k, l) => <label className="fld"><span>{l}</span><input value={cs[k] || ""} onChange={(e) => setCs({ ...cs, [k]: e.target.value })} /></label>;
  const cert = res && byId(s.certs, res);
  return <div className="page wide au">
    <button className="lnk back" onClick={() => go({ v: "archive", p: "certs" })}><Ic.back /> {t("Autentiche", "Certificates")}</button>
    {step < 3 && <div className="au-steps">{S.map((l, i) => <div key={i} className={i === step ? "on" : i < step ? "done" : ""}><span>{i < step ? "✓" : i + 1}</span>{l}</div>)}<LangSw /></div>}

    {step === 0 && <div className="au-two">
      <div><h1 className="au-t">{t("Seleziona e verifica l'opera", "Select and verify the artwork")}</h1><p className="mut">{t("Seleziona l'opera per la quale desideri emettere un'autentica. Le informazioni già presenti nel catalogo verranno inserite automaticamente nel certificato.", "Select the artwork to certify. Information already in the catalogue is filled in automatically.")}</p>
        <div className="row" style={{ margin: "14px 0" }}><input className="au-q" value={q} onChange={(e) => setQ(e.target.value)} placeholder={t("Cerca per titolo, anno o n. archivio", "Search title, year or archive no.")} /><Btn onClick={() => go({ v: "archive", p: "newauthx", mode: "new" })}><Ic.plus /> {t("Crea nuova scheda", "New record")}</Btn></div>
        <div className="au-pick">{L.map((w) => <button key={w.id} className={pick === w.id ? "on" : ""} onClick={() => setPick(w.id)}><div><Art a={w} label={false} r={4} /></div><span><b>{w.title}</b><em>{w.yearLabel || w.year} · {w.catNo || t("senza n.", "no no.")}</em></span></button>)}{!L.length && <div className="empty">{t("Nessuna opera senza autentica corrisponde alla ricerca.", "No uncertified artwork matches.")}</div>}</div>
        <p className="mut sm">{t("Sono elencate solo le opere senza un'autentica valida, per evitare emissioni doppie.", "Only artworks without a valid certificate are listed, to prevent duplicates.")}</p></div>
      <div className="au-side">{a && cs ? <><div className="au-prev-i"><Art a={a} label={false} r={8} /></div><h3>{t("Dati del certificato", "Certificate data")}</h3>
        <div className="au-g2">{F("artist", t("Artista", "Artist"))}{F("title", t("Titolo", "Title"))}{F("year", t("Anno", "Year"))}{F("catNo", t("N. catalogo ragionato", "Catalogue no."))}</div>{F("medium", t("Tecnica", "Medium"))}{F("dims", t("Dimensioni", "Dimensions"))}
        {(a.docs || []).length > 0 && <p className="mut sm">{(a.docs || []).length} {t("documenti collegati alla scheda", "documents on the record")}</p>}
        {edited && <p className="au-note">{t("Le correzioni valgono solo per il certificato. La scheda scientifica dell'opera non viene modificata.", "Corrections apply to the certificate only. The artwork's record is not changed.")}</p>}
        <Btn k="dark" style={{ width: "100%", justifyContent: "center", marginTop: 12 }} onClick={() => setStep(1)}>{t("Continua", "Continue")}</Btn></>
        : <div className="empty">{t("Seleziona un'opera dall'elenco.", "Select an artwork from the list.")}</div>}</div>
    </div>}

    {step === 1 && <div className="au-two">
      <div><h1 className="au-t">{t("Prepara l'autentica", "Prepare the certificate")}</h1><p className="mut">{t("Il certificato digitale riporterà le informazioni dell'opera e i dati dell'archivio che ne autorizza l'emissione.", "The certificate shows the artwork information and the details of the archive authorising it.")}</p>
        <div className="au-g2" style={{ marginTop: 14 }}><label className="fld"><span>{t("Modello", "Template")}</span><select value={tpl} onChange={(e) => setTpl(e.target.value)}><option value="standard">{t("Standard dell'archivio", "Archive standard")}</option><option value="minimal">{t("Essenziale", "Minimal")}</option></select></label>
          <label className="fld"><span>{t("Firmatario autorizzato", "Authorised signatory")}</span><select value={sig} onChange={(e) => setSig(e.target.value)}><option>{`${s.archive.signatory} · ${s.archive.role}`}</option></select></label></div>
        <div className="au-id"><span>{t("ID autentica", "Certificate ID")}</span><b className="mono">{nextId}</b><span>QR</span><b className="mono">certifyarchive.com/verify/{nextId}</b></div>
        <h2 className="au-h2">{t("Vuoi associare un proprietario?", "Link an owner?")}</h2>
        <p className="mut">{t("Puoi associare il certificato al proprietario attuale dell'opera. Il proprietario riceverà un'email per accedere a Certify e accettare l'assegnazione. Se non conosci il proprietario, puoi completare l'emissione e associarlo successivamente.", "You can link the certificate to the current owner, who will receive an email to accept it. If you don't know the owner, issue now and link later.")}</p>
        <div className="au-yn"><button className={want === true ? "on" : ""} onClick={() => setWant(true)}><b>{t("Sì, associa un proprietario", "Yes, link an owner")}</b></button><button className={want === false ? "on" : ""} onClick={() => setWant(false)}><b>{t("No, lo farò in seguito", "No, I'll do it later")}</b></button></div>
        {want && <OwnerFields v={own} set={setOwn} />}
        <div className="row" style={{ marginTop: 16 }}><Btn onClick={() => setStep(0)}>{t("Indietro", "Back")}</Btn><Btn k="dark" disabled={want === null || (want && !ownerOk(own))} onClick={() => setStep(2)}>{t("Continua", "Continue")}</Btn></div></div>
      <div className="au-side au-cert"><CertDoc snap={cs} id={nextId} issuedAt={today()} a={a} small /><div className="au-wm">{t("Anteprima", "Preview")}</div></div>
    </div>}

    {step === 2 && <div className="au-two">
      <div><h1 className="au-t">{t("Conferma l'emissione", "Confirm issuance")}</h1><p className="mut">{t("Controlla le informazioni prima di emettere l'autentica. Una volta confermata, il certificato verrà registrato e sarà immediatamente valido, indipendentemente dall'eventuale assegnazione a un proprietario.", "Check before issuing. Once confirmed, the certificate is registered and valid immediately, whether or not an owner is linked.")}</p>
        <dl className="pdl au-sum"><dt>{t("Opera", "Artwork")}</dt><dd><b>{cs.title}</b>, {cs.year} · {cs.medium} · {cs.dims}</dd><dt>{t("Archivio emittente", "Issuing archive")}</dt><dd>{s.archive.name}</dd><dt>{t("Firmatario", "Signatory")}</dt><dd>{sig}</dd><dt>{t("ID autentica", "Certificate ID")}</dt><dd className="mono">{nextId}</dd>
          <dt>{t("Proprietario", "Owner")}</dt><dd>{want ? `${own.name} · ${own.email} — ${t("riceverà un invito", "will receive an invitation")}` : t("Nessuno · potrai associarlo in seguito", "None · link later")}</dd>
          <dt>{t("Diritto di segreteria", "Administrative fee")}</dt><dd>{fee.on ? `${money(fee.amount, fee.cur)} · ${t("da pagare", "due")}` : t("Non applicato", "Not applied")}</dd>
          <dt>{t("Pubblico", "Public")}</dt><dd>{t("ID, opera, archivio, data e stato sono verificabili tramite QR. I dati del proprietario restano riservati.", "ID, artwork, archive, date and status are verifiable via QR. Owner details stay private.")}</dd></dl>
        <label className="au-ck"><input type="checkbox" checked={ok} onChange={(e) => setOk(e.target.checked)} /><span>{t("Confermo che le informazioni riportate nel certificato sono state verificate e approvate dall'archivio e autorizzo l'emissione dell'autentica.", "I confirm the information on the certificate has been verified and approved by the archive, and I authorise its issuance.")}</span></label>
        {dup && <p className="au-note bad">{t("Esiste già un'autentica valida per quest'opera.", "A valid certificate already exists for this artwork.")}</p>}
        <div className="row" style={{ marginTop: 16 }}><Btn onClick={() => setStep(1)}>{t("Indietro", "Back")}</Btn><Btn k="dark" disabled={!ok || busy || dup} onClick={emit}>{busy ? t("Registrazione…", "Registering…") : t("Emetti autentica", "Issue certificate")}</Btn></div></div>
      <div className="au-side au-cert"><CertDoc snap={cs} id={nextId} issuedAt={today()} a={a} small /></div>
    </div>}

    {step === 3 && cert && <div className="au-done">
      <div className="au-ok">✓</div><h1 className="au-t">{t("Autentica emessa correttamente", "Certificate issued")}</h1>
      <p className="mut">{t("Il certificato è stato registrato ed è ora disponibile su Certify.", "The certificate is registered and now available on Certify.")}</p>
      <dl className="pdl au-sum"><dt>ID</dt><dd className="mono">{cert.id}</dd><dt>{t("Stato", "Status")}</dt><dd><CstPill c={cert} /> <span className="mut sm">{cert.anchored ? t("· registrazione confermata", "· registration confirmed") : t("· registrazione in conferma", "· registration confirming")}</span></dd>
        <dt>{t("Proprietario", "Owner")}</dt><dd><OwnPill c={cert} /></dd>{cert.fee && <><dt>{t("Diritto di segreteria", "Fee")}</dt><dd>{money(cert.fee.amount, cert.fee.cur)} · {PAY[cert.payment]}</dd></>}</dl>
      <div className="row au-da"><Btn k="dark" onClick={() => go({ v: "archive", p: "cert", id: cert.id })}>{t("Visualizza certificato", "View certificate")}</Btn><Btn onClick={() => say(t("PDF scaricato (simulato)", "PDF downloaded (simulated)"))}>{t("Scarica PDF", "Download PDF")}</Btn>{!cert.ownerId && <Btn onClick={() => setMail("assign")}>{t("Associa proprietario", "Link owner")}</Btn>}<Btn onClick={() => go({ v: "archive", p: "certs" })}>{t("Torna alle autentiche", "Back to certificates")}</Btn></div>
      <TxExplain c={cert} />
      {cert.ownerId && <div className="au-mailbox"><InviteStatus certId={cert.id} /><OwnerEmail certId={cert.id} /></div>}
      {mail === "assign" && <AssignOwner certId={cert.id} onClose={() => setMail(false)} onSent={() => setMail(false)} />}
    </div>}
  </div>;
}

// ---------------- Owner claim (5 screens) ----------------
function ClaimFlow() {
  const { s, mut, go, say } = useC(); const c = byId(s.certs, s.route.id); const [st, setSt] = aS(0); const [code, setCode] = aS(""); const [tries, setTries] = aS(0); const [wait, setWait] = aS(60); const [pw, setPw] = aS(""); const [err, setErr] = aS(""); const t = (a, b) => T2(s, a, b);
  aE(() => { if (st !== 2) return; setWait(60); const i = setInterval(() => setWait((w) => (w > 0 ? w - 1 : 0)), 1000); return () => clearInterval(i); }, [st]);
  if (!c || !c.ownerId) return <div className="cp"><div className="vf"><div className="empty">{t("Invito non valido o scaduto.", "Invalid or expired invitation.")}</div></div></div>;
  const a = byId(s.works, c.artworkId); const o = byId(s.collectors, c.ownerId); const ARC = s.archive.name;
  const Art2 = () => <div className="cl-w"><div><Art a={a} label={false} r={6} /></div><span><em>{c.snapshot.artist}</em><b>{c.snapshot.title}</b><em>{t("Emessa da", "Issued by")} {ARC}</em></span></div>;
  if (c.claim === "claimed" && st < 4) return <div className="cp"><div className="cp-top"><Mark s={20} /><b>CERTIFY</b></div><div className="vf cl"><h1>{t("Certificato già accettato", "Certificate already accepted")}</h1><Art2 /><Btn k="dark" onClick={() => go({ v: "collector", p: "home", cid: o.id })}>{t("Vai alla mia collezione", "Go to my collection")}</Btn></div></div>;
  const check = () => { if (tries >= 4) { setErr(t("Troppi tentativi. Richiedi un nuovo codice.", "Too many attempts. Request a new code.")); return; } if (/^\d{6}$/.test(code)) { setErr(""); setSt(3); } else { setTries(tries + 1); setErr(t(`Codice non valido · ${4 - tries} tentativi rimasti`, `Invalid code · ${4 - tries} attempts left`)); } };
  const accept = () => { mut((n) => { const x = byId(n.certs, c.id); x.claim = "claimed"; x.invite = { ...(x.invite || {}), acceptedAt: today(), delivery: "Consegnata" }; (x.history = x.history || []).push({ at: today(), text: `Email verificata · accettata da ${o.name}` }); log(n, { type: "proprieta", artworkId: c.artworkId, text: `${o.name} ha accettato l'autentica ${c.id}` }); }); setSt(4); };
  const decline = () => { mut((n) => { const x = byId(n.certs, c.id); x.claim = "declined"; (x.history = x.history || []).push({ at: today(), text: `Assegnazione rifiutata da ${o.name}` }); log(n, { type: "proprieta", artworkId: c.artworkId, text: `${o.name} non riconosce l'opera · ${c.id} · archivio notificato` }); }); say(t("Segnalazione inviata all'archivio", "Report sent to the archive")); go({ v: "verify", id: c.id }); };
  const steps = [t("Benvenuto", "Welcome"), "Account", "Email", t("Conferma", "Confirm"), t("Fatto", "Done")];
  return <div className="cp"><div className="cp-top"><Mark s={20} /><b>CERTIFY</b><span className="mut">{t("per conto di", "on behalf of")} {ARC}</span><span style={{ marginLeft: "auto" }}><LangSw /></span></div>
    <div className="vf cl"><div className="cl-st">{steps.map((l, i) => <i key={i} className={i <= st ? "on" : ""} title={l}></i>)}</div>
      {st === 0 && <><h1>{t("Un certificato ti aspetta", "A certificate is waiting for you")}</h1><p className="mut">{t(`${ARC} ti ha indicato come proprietario di un'opera e ti invita a ricevere il relativo certificato digitale.`, `${ARC} has named you as the owner of an artwork and invites you to receive its digital certificate.`)}</p><Art2 /><Btn k="dark" onClick={() => setSt(1)}>{t("Continua", "Continue")}</Btn></>}
      {st === 1 && <><h1>{t("Crea il tuo account", "Create your account")}</h1><p className="mut">{t("Un account Certify ti permette di conservare e consultare i certificati delle opere a te associate, in un unico spazio.", "A Certify account keeps the certificates of your artworks in one place.")}</p>
        <label className="fld"><span>{t("Nome e cognome", "Full name")}</span><input defaultValue={o.name} /></label><label className="fld"><span>Email</span><input value={o.email} readOnly /></label><label className="fld"><span>Password</span><input type="password" value={pw} onChange={(e) => setPw(e.target.value)} /></label>
        <Btn k="dark" disabled={pw.length < 8} onClick={() => { setCode(""); setTries(0); setErr(""); setSt(2); }}>{t("Crea account", "Create account")}</Btn><button className="lnk" onClick={() => setSt(2)}>{t("Ho già un account · Accedi", "I already have an account · Sign in")}</button><p className="mut sm">{t("Minimo 8 caratteri.", "At least 8 characters.")}</p></>}
      {st === 2 && <><h1>{t("Verifica la tua email", "Verify your email")}</h1><p className="mut">{t(`Ti abbiamo inviato un codice di verifica all'indirizzo ${o.email}. Inseriscilo qui per confermare che l'indirizzo ti appartiene.`, `We sent a code to ${o.email}. Enter it to confirm the address is yours.`)}</p>
        <input className="cl-code mono" inputMode="numeric" maxLength={6} value={code} onChange={(e) => setCode(e.target.value.replace(/\D/g, ""))} placeholder="000000" onKeyDown={(e) => e.key === "Enter" && check()} />
        {err && <p className="au-note bad">{err}</p>}<Btn k="dark" disabled={code.length !== 6} onClick={check}>{t("Verifica", "Verify")}</Btn>
        <p className="mut sm">{t("Il codice è valido 10 minuti · massimo 5 tentativi.", "Code valid for 10 minutes · max 5 attempts.")} {wait > 0 ? t(`Nuovo codice tra ${wait}s`, `New code in ${wait}s`) : <button className="lnk" onClick={() => { setWait(60); setTries(0); setErr(""); say(t("Nuovo codice inviato (simulato)", "New code sent (simulated)")); }}>{t("Invia un nuovo codice", "Send a new code")}</button>}</p>
        <p className="mut sm">{t("Demo: qualsiasi codice di 6 cifre. La verifica conferma che l'email è tua, non la proprietà legale dell'opera.", "Demo: any 6-digit code. Verification confirms the email is yours, not legal ownership.")}</p></>}
      {st === 3 && <><h1>{t("Conferma l'assegnazione", "Confirm the assignment")}</h1><p className="mut">{t(`${ARC} ti ha indicato come proprietario dell'opera riportata qui sotto. Confermando, accetti di ricevere il certificato digitale nel tuo account Certify.`, `${ARC} has named you as the owner of the artwork below. By confirming, you accept the certificate into your Certify account.`)}</p>
        <div className="cl-cert"><CertDoc snap={c.snapshot} id={c.id} issuedAt={c.issuedAt} a={a} small /></div><TxExplain c={c} who="owner" compact />
        <div className="row"><Btn k="dark" onClick={accept}>{t("Confermo e accetto", "Confirm and accept")}</Btn><Btn onClick={decline}>{t("Non riconosco questa opera", "I don't recognise this artwork")}</Btn></div></>}
      {st === 4 && <><div className="au-ok">✓</div><h1>{t("Il tuo certificato è disponibile", "Your certificate is available")}</h1><p className="mut">{t("Hai completato la procedura. Il certificato è ora disponibile nel tuo account Certify.", "All done. The certificate is now in your Certify account.")}</p><Art2 />
        <div className="row" style={{ flexWrap: "wrap" }}><Btn onClick={() => go({ v: "verify", id: c.id })}>{t("Visualizza certificato", "View certificate")}</Btn><Btn onClick={() => say(t("PDF scaricato (simulato)", "PDF downloaded (simulated)"))}>{t("Scarica PDF", "Download PDF")}</Btn><Btn k="dark" onClick={() => go({ v: "collector", p: "home", cid: o.id })}>{t("Vai alla mia collezione", "Go to my collection")}</Btn></div>
        <TxExplain c={c} who="owner" /><p className="mut sm">{t("L'archivio è stato avvisato dell'accettazione.", "The archive has been notified.")}</p></>}
    </div></div>;
}

// ---------------- Public verification ----------------
function VerifyAuth() {
  const { s, go } = useC(); const [id, setId] = aS(s.route.id || ""); const [r, setR] = aS(null); const t = (a, b) => T2(s, a, b);
  const check = async (v) => { const c = s.certs.find((x) => x.id.toLowerCase() === (v || id).trim().toLowerCase()); if (!c) return setR({ none: true }); const h = await sha({ ...c.snapshot, id: c.id, note: c.note }); setR({ c, ok: h === c.hash }); };
  aE(() => { if (s.route.id) check(s.route.id); }, []);
  const c = r && r.c; const a = c && byId(s.works, c.artworkId);
  return <div className="cp"><div className="cp-top"><Mark s={20} /><b>CERTIFY</b><span className="mut">{t("Verifica pubblica", "Public verification")}</span><span style={{ marginLeft: "auto" }}><LangSw /></span></div>
    <div className="vf"><h1>{t("Verifica dell'autentica", "Certificate verification")}</h1>
      {!c && <><p className="mut">{t("Inserisci l'ID stampato sul certificato o inquadra il QR code.", "Enter the ID printed on the certificate or scan the QR code.")}</p>
        <div className="row"><input className="mono" value={id} onChange={(e) => setId(e.target.value)} placeholder="CERT-FA-000124" onKeyDown={(e) => e.key === "Enter" && check()} /><Btn k="dark" onClick={() => check()}>{t("Verifica", "Verify")}</Btn></div>
        {s.certs.length > 0 && <div className="mut sm" style={{ marginTop: 10 }}>{t("Prova", "Try")}: {s.certs.slice(-3).map((x) => <button key={x.id} className="lnk" style={{ marginRight: 8 }} onClick={() => { setId(x.id); check(x.id); }}>{x.id}</button>)}</div>}
        {r && r.none && <div className="vr bad">{t("Autentica non trovata.", "Certificate not found.")}</div>}</>}
      {c && <><p className="mut">{t(`Questo certificato è stato emesso da ${s.archive.name} e registrato su Certify.`, `This certificate was issued by ${s.archive.name} and registered on Certify.`)}</p>
        <div className={"vr " + (c.status === "issued" && r.ok ? "good" : "bad")}><b>{c.status === "issued" ? (r.ok ? t("Autentica valida", "Valid certificate") : t("Dati non integri", "Data integrity failed")) : c.status === "revoked" ? t("Autentica revocata", "Certificate revoked") : t(`Sostituita da ${c.replacedBy}`, `Replaced by ${c.replacedBy}`)}</b>
          <div className="vf-w"><div><Art a={a} label={false} r={6} /></div><dl className="pdl"><dt>{t("Artista", "Artist")}</dt><dd>{c.snapshot.artist}</dd><dt>{t("Opera", "Artwork")}</dt><dd>{c.snapshot.title}, {c.snapshot.year}</dd><dt>{t("Tecnica", "Medium")}</dt><dd>{c.snapshot.medium}</dd><dt>{t("Dimensioni", "Dimensions")}</dt><dd>{c.snapshot.dims}</dd><dt>{t("Emessa da", "Issued by")}</dt><dd>{s.archive.name}</dd><dt>{t("Firmatario", "Signatory")}</dt><dd>{c.signatory || `${s.archive.signatory} · ${s.archive.role}`}</dd><dt>{t("Data", "Date")}</dt><dd>{c.issuedAt}</dd><dt>ID</dt><dd className="mono">{c.id}</dd><dt>{t("Proprietario", "Owner")}</dt><dd>{c.claim === "claimed" ? t("Registrato presso l'archivio (riservato)", "Registered with the archive (private)") : t("Non registrato", "Not registered")}</dd></dl></div></div>
        <TxExplain c={c} who="owner" />
        <p className="mut sm">{t("L'archivio emittente è responsabile dell'autenticazione scientifica dell'opera. Certify fornisce registrazione, conservazione e verifica del certificato.", "The issuing archive is responsible for the scholarly authentication. Certify provides registration, storage and verification.")}</p>
        <button className="lnk" onClick={() => { setR(null); setId(""); }}>{t("Verifica un altro certificato", "Verify another")}</button></>}
    </div></div>;
}

// ---------------- Diritto di segreteria (settings) ----------------
function FeeSettings({ bare }) {
  const { s, mut, go, say } = useC(); const f = feeCfg(s); const [amt, setAmt] = aS(String(f.amount)); const t = (a, b) => T2(s, a, b);
  const save = (patch) => { mut((n) => { n.adminFee = { ...feeCfg(n), ...patch }; log(n, { type: "struttura", text: "Diritto di segreteria aggiornato · vale per le autentiche future" }); }); say(t("Salvato · si applica alle prossime autentiche", "Saved · applies to future certificates")); };
  const v = parseFloat(amt.replace(",", ".")); const bad = !(v > 0);
  return <div className={bare ? "au au-fee bare" : "page au au-fee"}>
    {bare ? <h2>{t("Diritto di segreteria", "Administrative fee")}</h2> : <h1 className="au-t">{t("Diritto di segreteria", "Administrative fee")}</h1>}
    <p className="mut">{t("Puoi scegliere se applicare un diritto di segreteria per l'emissione delle autentiche digitali. L'importo è completamente personalizzabile e può essere modificato o disattivato in qualsiasi momento.", "Choose whether to apply an administrative fee to digital certificates. The amount is fully customisable and can be changed or disabled at any time.")}</p>
    <div className="card au-fc">
      <div className="dr"><span><b>{t("Applica diritto di segreteria", "Apply administrative fee")}</b></span><Tg on={f.on} onClick={() => save({ on: !f.on })} label={f.on ? t("Attivo", "On") : t("Disattivato", "Off")} /></div>
      {f.on && <div className="au-g2" style={{ marginTop: 12 }}><label className="fld"><span>{t("Importo per certificato", "Amount per certificate")}</span><input value={amt} onChange={(e) => setAmt(e.target.value)} onBlur={() => !bad && save({ amount: v })} /><em className="mut sm">{t("Suggerito: 40", "Suggested: 40")}</em></label>
        <label className="fld"><span>{t("Valuta", "Currency")}</span><select value={f.cur} onChange={(e) => save({ cur: e.target.value })}>{["EUR", "USD", "GBP", "CHF"].map((k) => <option key={k}>{k}</option>)}</select></label></div>}
      {f.on && bad && <p className="au-note bad">{t("Inserisci un importo maggiore di zero.", "Enter an amount above zero.")}</p>}
      <p className="mut sm">{t("Le modifiche valgono solo per le autentiche e le richieste di pagamento future, mai per quelle già emesse. Se disattivato, non compare alcun passaggio di pagamento.", "Changes apply to future certificates and payment requests only. When disabled, no payment step appears.")}</p>
    </div>
    <section className="au-how"><h2>{t("Cosa comprende il diritto di segreteria?", "What does the fee cover?")}</h2>
      <p className="mut">{t("Il diritto di segreteria copre la gestione amministrativa e digitale del certificato, la sua registrazione su Certify e la disponibilità di un sistema di verifica online.", "The fee covers the administrative and digital handling of the certificate, its registration on Certify and online verification.")}</p>
      <p className="mut">{t("L'autenticità dell'opera è attestata dall'archivio che emette il certificato, sulla base delle proprie verifiche e competenze scientifiche.", "Authenticity is attested by the issuing archive, based on its own scholarly assessment.")}</p>
      <p className="mut sm">{t("È separato dall'eventuale contributo per la valutazione scientifica, che si gestisce nelle richieste di autentica. Non viene addebitato al proprietario per accettare un'autentica già emessa.", "It is separate from any scholarly evaluation fee handled in authentication requests, and is never charged to owners for accepting an issued certificate.")}</p>
      <p className="mut sm">{t("Stati di pagamento", "Payment states")}: {Object.values(PAY).join(" · ")}. {t("Un pagamento risulta «Pagato» solo dopo la conferma del fornitore.", "A payment shows as Paid only after provider confirmation.")}</p></section>
  </div>;
}

// ---------------- Diritto di seguito (in sviluppo) ----------------
function Seguito() {
  const { s } = useC(); const t = (a, b) => T2(s, a, b);
  return <div className="page au au-seg"><div className="row" style={{ alignItems: "center" }}><h1 className="au-t" style={{ margin: 0 }}>{t("Diritto di seguito", "Resale right")}</h1><Pill k="warn">{t("In sviluppo", "In development")}</Pill></div>
    <p className="mut" style={{ maxWidth: 680 }}>{t("Stiamo sviluppando nuovi strumenti per aiutare gli archivi a monitorare e gestire il diritto di seguito sulle rivendite delle opere. L'obiettivo è semplificare la raccolta delle informazioni, il monitoraggio delle transazioni e la gestione amministrativa dei compensi spettanti agli aventi diritto.", "We're building tools to help archives monitor and manage resale rights on artwork resales: simpler data collection, transaction monitoring and administration of the sums due to rights holders.")}</p>
    <div className="au-soon">{[t("Monitoraggio delle rivendite", "Resale monitoring"), t("Registrazione dei trasferimenti di proprietà", "Ownership transfer records"), t("Calcolo dei compensi secondo le regole applicabili", "Royalty calculation under applicable rules"), t("Storico delle transazioni", "Transaction history"), t("Strumenti di rendicontazione", "Reporting tools")].map((x) => <div key={x}><span>{x}</span><em>{t("Funzionalità in sviluppo", "In development")}</em></div>)}</div>
    <p className="mut sm">{t("Certify non riscuote oggi il diritto di seguito e non sostituisce gli enti autorizzati alla riscossione. È una funzione separata dal diritto di segreteria delle autentiche.", "Certify does not currently collect resale royalties nor replace authorised collecting bodies. This is separate from the certificate administrative fee.")}</p>
  </div>;
}

Object.assign(window, { TxExplain, ArchStamp, AuthDash, NewAuth3, AssignOwner, InviteStatus, OwnerEmail, ClaimFlow, VerifyAuth, FeeSettings, Seguito, OwnPill, CstPill });
