/* Sentosa Marketplace - Buyer Portal: MICE & Events
   S/No. 142  AI-assisted venue discovery and search (natural language, conversational filtering)
   S/No. 144a Native enquiry management (fallback where Salesforce CRM is not activated)
   Reply No. 4 Q27: Phase 1 purpose is enquiry generation, NOT real-time transactional booking.
                    No live availability calendar. Live confirmation handled by the SDC MICE team. */

const MICE_SUGGESTIONS = [
  "Beachfront gala dinner for 800 guests in December",
  "Conference for 500 delegates with 6 breakout rooms",
  "Outdoor product launch with staging for 1,200",
];

function MiceScreen({ onOpenVenue, onEnquiries }) {
  const [q, setQ] = React.useState("");
  const [submitted, setSubmitted] = React.useState("");
  const [thinking, setThinking] = React.useState(false);
  const [filters, setFilters] = React.useState([]);

  const run = (text) => {
    setQ(text); setThinking(true); setSubmitted("");
    setTimeout(() => { setThinking(false); setSubmitted(text); setFilters(deriveFilters(text)); }, 700);
  };

  function deriveFilters(text) {
    const t = text.toLowerCase();
    const out = [];
    const capMatch = t.match(/(\d{2,5})\s*(guests|delegates|pax|people)?/);
    if (capMatch) out.push({ k: "Capacity", v: `${capMatch[1]}+ pax` });
    if (/beach|waterfront|outdoor|lawn|open/.test(t)) out.push({ k: "Setting", v: "Outdoor / waterfront" });
    if (/indoor|conference|breakout|ballroom/.test(t)) out.push({ k: "Setting", v: "Indoor" });
    if (/gala|dinner|banquet/.test(t)) out.push({ k: "Format", v: "Gala dinner" });
    if (/conference|summit|breakout/.test(t)) out.push({ k: "Format", v: "Conference" });
    if (/launch|staging|stage/.test(t)) out.push({ k: "Format", v: "Product launch" });
    if (/dec|december/.test(t)) out.push({ k: "Period", v: "December 2026" });
    return out;
  }

  const cap = (() => { const m = submitted.match(/(\d{2,5})/); return m ? parseInt(m[1], 10) : 0; })();
  const list = submitted
    ? window.VENUES.filter(v => v.cap >= cap * 0.7).sort((a, b) => Math.abs(a.cap - cap) - Math.abs(b.cap - cap))
    : window.VENUES;

  return (
    <div>
      {/* Hero + AI search */}
      <div style={{ background: "var(--black)", color: "#fff" }}>
        <div style={{ maxWidth: "var(--maxw)", margin: "0 auto", padding: "40px 24px 44px" }}>
          <div className="overline" style={{ color: "var(--orange-300)" }}>MICE &amp; Events · Phase 1</div>
          <h1 style={{ color: "#fff", fontSize: "2.2rem", margin: "8px 0 10px", maxWidth: 660 }}>Find a Sentosa venue for your event</h1>
          <p style={{ fontSize: 16.5, color: "#C9C9C9", maxWidth: 620, lineHeight: 1.55, marginBottom: 22 }}>
            Describe the event in your own words. AI-assisted discovery interprets the brief, filters the island's venues,
            and captures your enquiry for the SDC MICE team.
          </p>

          <div style={{ maxWidth: 720 }}>
            <div style={{ display: "flex", gap: 10 }}>
              <div style={{ position: "relative", flex: 1 }}>
                <span style={{ position: "absolute", left: 14, top: "50%", transform: "translateY(-50%)", display: "flex" }}><Icon name="sparkles" size={18} color="var(--orange-300)" /></span>
                <input value={q} onChange={e => setQ(e.target.value)} onKeyDown={e => e.key === "Enter" && q.trim() && run(q)}
                  placeholder="e.g. beachfront gala dinner for 800 guests in December"
                  aria-label="Describe your event"
                  style={{ width: "100%", boxSizing: "border-box", height: 52, padding: "0 14px 0 44px", borderRadius: "var(--radius-md)",
                    border: "1.5px solid #3a3a3a", background: "#262626", color: "#fff", fontSize: 15, fontFamily: "var(--font-sans)", outline: "none" }} />
              </div>
              <Btn variant="primary" onClick={() => q.trim() && run(q)} icon="search">Search</Btn>
            </div>
            <div style={{ display: "flex", gap: 8, flexWrap: "wrap", marginTop: 14, alignItems: "center" }}>
              <span style={{ fontSize: 12.5, color: "#9A9A9A" }}>Try:</span>
              {MICE_SUGGESTIONS.map(s => (
                <button key={s} onClick={() => run(s)}
                  style={{ background: "#262626", border: "1px solid #3a3a3a", color: "#C9C9C9", borderRadius: "var(--radius-pill)",
                    padding: "6px 13px", fontSize: 12.5, cursor: "pointer", fontFamily: "var(--font-sans)" }}>{s}</button>
              ))}
            </div>
          </div>
        </div>
      </div>

      <div style={{ maxWidth: "var(--maxw)", margin: "0 auto", padding: "26px 24px" }}>
        {/* Conversational filter read-back */}
        {thinking && (
          <Card style={{ marginBottom: 20, display: "flex", alignItems: "center", gap: 12 }}>
            <Icon name="loader" size={18} color="var(--orange-900)" />
            <span style={{ color: "var(--fg2)" }}>Interpreting your brief…</span>
          </Card>
        )}
        {!thinking && submitted && (
          <Card style={{ marginBottom: 20 }}>
            <div style={{ display: "flex", alignItems: "flex-start", gap: 12 }}>
              <AiChip />
              <div style={{ flex: 1, minWidth: 0 }}>
                <div style={{ fontSize: 14.5, lineHeight: 1.55 }}>
                  Read as: <strong>{submitted}</strong>
                </div>
                <div style={{ display: "flex", gap: 8, flexWrap: "wrap", marginTop: 10 }}>
                  {filters.map((f, i) => (
                    <span key={i} style={{ fontSize: 12.5, padding: "5px 11px", borderRadius: "var(--radius-pill)", background: "var(--neutral-100)", color: "var(--fg1)", fontWeight: 500 }}>
                      <span style={{ color: "var(--fg2)" }}>{f.k}:</span> {f.v}
                    </span>
                  ))}
                  {filters.length === 0 && <span className="caption">No structured filters detected - showing all venues.</span>}
                </div>
                <div style={{ fontSize: 12.5, color: "var(--fg2)", marginTop: 10, display: "flex", alignItems: "center", gap: 6 }}>
                  <Icon name="info" size={14} color="var(--fg3)" />
                  Availability is confirmed by the SDC MICE team after enquiry - indicative pricing shown.
                </div>
              </div>
            </div>
          </Card>
        )}

        <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 16 }}>
          <div style={{ fontSize: 14, color: "var(--fg2)" }}><strong style={{ color: "var(--fg1)" }}>{list.length}</strong> venues</div>
          <Btn size="sm" variant="secondary" icon="inbox" onClick={onEnquiries}>My enquiries</Btn>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: "repeat(3,1fr)", gap: 18 }}>
          {list.map(v => (
            <Card key={v.id} pad={0} hover onClick={() => onOpenVenue(v)} style={{ overflow: "hidden", display: "flex", flexDirection: "column" }}>
              <Photo src={v.photo} tint={v.img} alt={v.name} zoom style={{ height: 220 }}>
                <span style={{ position: "absolute", top: 10, left: 10 }}><Badge tone="info" dot={false}>{v.cap.toLocaleString()} pax</Badge></span>
              </Photo>
              <div style={{ padding: 15, display: "flex", flexDirection: "column", flex: 1 }}>
                <div style={{ fontSize: 16, fontWeight: 600, lineHeight: 1.3 }}>{v.name}</div>
                <div style={{ fontSize: 12.5, color: "var(--fg2)", margin: "4px 0 10px" }}>{v.partner} · {v.layout}</div>
                <div style={{ display: "flex", gap: 6, flexWrap: "wrap", marginBottom: 12 }}>
                  {v.tags.map(t => <span key={t} style={{ fontSize: 11.5, padding: "3px 9px", borderRadius: "var(--radius-pill)", background: "var(--neutral-100)", color: "var(--fg2)" }}>{t}</span>)}
                </div>
                <div style={{ marginTop: "auto", display: "flex", alignItems: "flex-end", justifyContent: "space-between" }}>
                  <div>
                    <div style={{ fontSize: 17, fontWeight: 700 }}>S${v.rate.toLocaleString()}</div>
                    <div style={{ fontSize: 11.5, color: "var(--fg2)" }}>indicative / {v.unit}</div>
                  </div>
                  <Btn size="sm" variant="secondary" iconRight="arrow-right" onClick={() => onOpenVenue(v)}>Enquire</Btn>
                </div>
              </div>
            </Card>
          ))}
        </div>
      </div>
    </div>
  );
}

function VenueScreen({ v, onBack, onEnquire }) {
  const bars = [["Theatre", 100], ["Banquet", 68], ["Cocktail", 88], ["Classroom", 44], ["U-shape", 22]];
  return (
    <div style={{ maxWidth: "var(--maxw)", margin: "0 auto", padding: "24px 24px 8px" }}>
      <Breadcrumb items={[{ label: "MICE venues", onClick: onBack }, { label: v.name }]} />
      <div style={{ display: "grid", gridTemplateColumns: "1.3fr 1fr", gap: 32, alignItems: "start" }}>
        <div>
          <Photo src={v.photo} tint={v.img} alt={v.name} style={{ height: 440, borderRadius: "var(--radius-lg)" }} />
          <div style={{ display: "flex", gap: 10, marginTop: 12 }}>
            {[0, 1, 2, 3].map(i => (
              <Photo key={i} src={v.photo} tint={v.img}
                style={{ width: 110, height: 78, borderRadius: "var(--radius-md)", opacity: i === 0 ? 1 : 0.5,
                  border: i === 0 ? "2px solid var(--orange-700)" : "1px solid var(--border)", flex: "none" }} />
            ))}
          </div>

          {/* Floor plan */}
          <div style={{ marginTop: 28 }}>
            <h3 style={{ marginBottom: 10 }}>Floor plan</h3>
            <div style={{ border: "1px solid var(--border)", borderRadius: "var(--radius-lg)", padding: 20, background: "var(--neutral-50)" }}>
              <svg viewBox="0 0 420 190" style={{ width: "100%", height: "auto", display: "block" }} role="img" aria-label={`Indicative floor plan for ${v.name}`}>
                <rect x="8" y="8" width="404" height="174" fill="#fff" stroke="var(--border-strong)" strokeWidth="2" rx="4" />
                <rect x="28" y="28" width="150" height="90" fill="var(--orange-50)" stroke="var(--orange-700)" strokeWidth="1.5" rx="3" />
                <text x="103" y="78" textAnchor="middle" fontSize="12" fill="#9A4F0C" fontFamily="var(--font-sans)">Main floor</text>
                <rect x="196" y="28" width="90" height="44" fill="var(--neutral-100)" stroke="var(--border-strong)" strokeWidth="1.2" rx="3" />
                <text x="241" y="54" textAnchor="middle" fontSize="11" fill="var(--fg2)" fontFamily="var(--font-sans)">Breakout A</text>
                <rect x="196" y="80" width="90" height="38" fill="var(--neutral-100)" stroke="var(--border-strong)" strokeWidth="1.2" rx="3" />
                <text x="241" y="103" textAnchor="middle" fontSize="11" fill="var(--fg2)" fontFamily="var(--font-sans)">Breakout B</text>
                <rect x="300" y="28" width="86" height="90" fill="var(--neutral-100)" stroke="var(--border-strong)" strokeWidth="1.2" rx="3" />
                <text x="343" y="78" textAnchor="middle" fontSize="11" fill="var(--fg2)" fontFamily="var(--font-sans)">Foyer / F&amp;B</text>
                <rect x="28" y="132" width="358" height="30" fill="var(--neutral-50)" stroke="var(--border-strong)" strokeWidth="1.2" strokeDasharray="5 4" rx="3" />
                <text x="207" y="152" textAnchor="middle" fontSize="11" fill="var(--fg2)" fontFamily="var(--font-sans)">Load-in / staging access</text>
              </svg>
            </div>
          </div>

          {/* Capacity chart */}
          <div style={{ marginTop: 28 }}>
            <h3 style={{ marginBottom: 10 }}>Capacity by layout</h3>
            <Card pad={20}>
              <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
                {bars.map(([label, pct]) => (
                  <div key={label} style={{ display: "flex", alignItems: "center", gap: 14 }}>
                    <span style={{ width: 92, fontSize: 13.5, color: "var(--fg2)", flex: "none" }}>{label}</span>
                    <div style={{ flex: 1, height: 22, background: "var(--neutral-100)", borderRadius: "var(--radius-sm)", overflow: "hidden" }}>
                      <div style={{ width: `${pct}%`, height: "100%", background: pct === 100 ? "var(--action)" : "var(--orange-700)", borderRadius: "var(--radius-sm)" }}></div>
                    </div>
                    <span style={{ width: 64, textAlign: "right", fontSize: 13.5, fontWeight: 600 }}>{Math.round(v.cap * pct / 100).toLocaleString()}</span>
                  </div>
                ))}
              </div>
            </Card>
          </div>

          {/* Catering + AV */}
          <div style={{ marginTop: 28 }}>
            <h3 style={{ marginBottom: 10 }}>Catering &amp; technical</h3>
            <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 14 }}>
              {[["utensils-crossed", "Catering options", "In-house and approved external caterers. Halal-certified and vegetarian menus available."],
                ["speaker", "AV &amp; technical", v.av],
                ["clock", "Lead time", `${v.lead} minimum notice`],
                ["accessibility", "Accessibility", "Step-free access, accessible washrooms, reserved seating zones."]].map(([ic, h, b]) => (
                <div key={h} style={{ display: "flex", gap: 11, padding: 14, border: "1px solid var(--border)", borderRadius: "var(--radius-md)" }}>
                  <Icon name={ic} size={19} color="var(--orange-700)" style={{ marginTop: 1 }} />
                  <div><div style={{ fontSize: 14, fontWeight: 600 }} dangerouslySetInnerHTML={{ __html: h }}></div>
                    <div style={{ fontSize: 13, color: "var(--fg2)", lineHeight: 1.5, marginTop: 3 }}>{b}</div></div>
                </div>
              ))}
            </div>
          </div>
        </div>

        {/* Enquiry panel */}
        <Card style={{ position: "sticky", top: 96 }} pad={20}>
          <div className="overline" style={{ color: "var(--fg2)" }}>{v.partner}</div>
          <h2 style={{ margin: "4px 0 8px", fontSize: "1.4rem" }}>{v.name}</h2>
          <div style={{ display: "flex", gap: 8, flexWrap: "wrap", marginBottom: 16 }}>
            {v.tags.map(t => <Badge key={t} tone="neutral" dot={false}>{t}</Badge>)}
          </div>
          <div style={{ padding: "14px 0", borderTop: "1px solid var(--border)", borderBottom: "1px solid var(--border)" }}>
            <div style={{ fontSize: 26, fontWeight: 700 }}>S${v.rate.toLocaleString()}</div>
            <div style={{ fontSize: 13, color: "var(--fg2)" }}>indicative rate per {v.unit} · excludes GST</div>
          </div>
          <div style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: "9px 14px", fontSize: 13.5, padding: "16px 0" }}>
            <span style={{ color: "var(--fg2)" }}>Capacity</span><span style={{ fontWeight: 600 }}>Up to {v.cap.toLocaleString()} pax</span>
            <span style={{ color: "var(--fg2)" }}>Layout</span><span style={{ fontWeight: 600 }}>{v.layout}</span>
            <span style={{ color: "var(--fg2)" }}>Lead time</span><span style={{ fontWeight: 600 }}>{v.lead}</span>
          </div>
          <Btn variant="primary" full icon="send" onClick={() => onEnquire(v)}>Submit enquiry</Btn>
          <div style={{ fontSize: 12.5, color: "var(--fg2)", marginTop: 12, lineHeight: 1.5, textAlign: "center" }}>
            The SDC MICE team confirms availability and reverts with a formal offer.
          </div>
        </Card>
      </div>
    </div>
  );
}

function EnquiryFormScreen({ v, onBack, onSubmitted }) {
  const [f, setF] = React.useState({ event: "", pax: "", date: "", format: "Conference", budget: "", notes: "",
    name: "Priya Raman", role: "Head of Group Travel", email: "priya@wanderlust.com", phone: "+65 8123 4567", company: "Wanderlust Travel Pte Ltd" });
  const set = (k) => (e) => setF(p => ({ ...p, [k]: e.target.value }));
  const ok = f.event.trim() && f.pax.trim() && f.date.trim();
  return (
    <div style={{ maxWidth: 900, margin: "0 auto", padding: "24px 24px 8px" }}>
      <Breadcrumb items={[{ label: "MICE venues", onClick: onBack }, { label: v.name, onClick: onBack }, { label: "Enquiry" }]} />
      <h1 style={{ fontSize: "1.8rem", marginBottom: 6 }}>Submit an enquiry</h1>
      <p className="caption" style={{ marginBottom: 22 }}>
        For <strong style={{ color: "var(--fg1)" }}>{v.name}</strong>. Your contact details and event requirements are captured here and routed
        to the SDC MICE team - managed natively in the platform.
      </p>

      <div style={{ display: "grid", gridTemplateColumns: "1fr 320px", gap: 26, alignItems: "start" }}>
        <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
          <Card pad={20}>
            <div style={{ fontWeight: 600, fontSize: 16, marginBottom: 16 }}>Event requirements</div>
            <div style={{ display: "flex", flexDirection: "column", gap: 16 }}>
              <Field label="Event name" required value={f.event} onChange={set("event")} placeholder="e.g. APAC Partner Summit 2026" />
              <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 16 }}>
                <Field label="Expected attendance" required value={f.pax} onChange={set("pax")} placeholder="e.g. 480" help={`This venue holds up to ${v.cap.toLocaleString()}.`} />
                <Field label="Preferred date(s)" required value={f.date} onChange={set("date")} placeholder="e.g. 18-19 Nov 2026" />
              </div>
              <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 16 }}>
                <Field label="Event format" as="select" value={f.format} onChange={set("format")}>
                  <option>Conference</option><option>Gala dinner</option><option>Product launch</option>
                  <option>Incentive / team building</option><option>Cocktail reception</option><option>Exhibition</option>
                </Field>
                <Field label="Indicative budget (S$)" optional value={f.budget} onChange={set("budget")} prefix="S$" placeholder="e.g. 90,000" />
              </div>
              <Field label="Requirements and notes" as="textarea" optional value={f.notes} onChange={set("notes")}
                placeholder="Catering, AV, staging, accessibility, breakout needs, arrival logistics…" />
            </div>
          </Card>

          <Card pad={20}>
            <div style={{ fontWeight: 600, fontSize: 16, marginBottom: 16 }}>Your contact details</div>
            <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 16 }}>
              <Field label="Contact name" required value={f.name} onChange={set("name")} />
              <Field label="Role" value={f.role} onChange={set("role")} />
              <Field label="Email" required type="email" value={f.email} onChange={set("email")} />
              <Field label="Phone" required value={f.phone} onChange={set("phone")} />
              <div style={{ gridColumn: "1 / -1" }}><Field label="Organisation" required value={f.company} onChange={set("company")} /></div>
            </div>
          </Card>
        </div>

        <Card style={{ position: "sticky", top: 96 }} pad={20}>
          <Photo src={v.photo} tint={v.img} alt={v.name} style={{ height: 168, borderRadius: "var(--radius-md)", marginBottom: 14 }} />
          <div style={{ fontWeight: 600, fontSize: 15 }}>{v.name}</div>
          <div style={{ fontSize: 13, color: "var(--fg2)", marginBottom: 14 }}>{v.partner}</div>
          <div style={{ background: "var(--info-bg)", border: "1px solid #c4d4f7", borderRadius: "var(--radius-md)", padding: "11px 13px", fontSize: 12.5, color: "#1a44a8", lineHeight: 1.5, marginBottom: 16 }}>
            Submitting an enquiry does not reserve the venue. The SDC MICE team confirms availability and reverts with a formal offer.
          </div>
          <Btn variant="primary" full icon="send" disabled={!ok} onClick={() => ok && onSubmitted(f)}>Submit enquiry</Btn>
          <Btn variant="ghost" full onClick={onBack}>Cancel</Btn>
        </Card>
      </div>
    </div>
  );
}

function EnquirySubmittedScreen({ v, form, onEnquiries, onBack }) {
  return (
    <div style={{ maxWidth: 640, margin: "0 auto", padding: "56px 24px" }}>
      <div style={{ textAlign: "center", marginBottom: 26 }}>
        <div style={{ width: 68, height: 68, borderRadius: 999, background: "var(--success-bg)", display: "flex", alignItems: "center", justifyContent: "center", margin: "0 auto 18px" }}><Icon name="check" size={34} color="var(--success)" strokeWidth={2.5} /></div>
        <h1 style={{ fontSize: "1.8rem", marginBottom: 8 }}>Enquiry submitted</h1>
        <p style={{ color: "var(--fg2)", fontSize: 16 }}>Reference <strong style={{ color: "var(--fg1)", fontFamily: "var(--font-mono)" }}>ENQ-10462</strong> - routed to the SDC MICE team.</p>
      </div>
      <Card pad={0}>
        <div style={{ padding: "14px 18px", borderBottom: "1px solid var(--border)", display: "flex", justifyContent: "space-between", alignItems: "center" }}>
          <span style={{ fontWeight: 600 }}>Enquiry summary</span><Badge tone="info">New</Badge>
        </div>
        {[["Venue", v.name], ["Event", form.event], ["Attendance", `${form.pax} pax`], ["Preferred dates", form.date],
          ["Format", form.format], ["Contact", `${form.name} · ${form.email}`]].map(([k, val]) => (
          <div key={k} style={{ display: "flex", justifyContent: "space-between", gap: 20, padding: "11px 18px", borderBottom: "1px solid var(--border)", fontSize: 14 }}>
            <span style={{ color: "var(--fg2)" }}>{k}</span><span style={{ fontWeight: 600, textAlign: "right" }}>{val}</span>
          </div>
        ))}
      </Card>
      <div style={{ display: "flex", alignItems: "flex-start", gap: 10, marginTop: 18, padding: 14, background: "var(--neutral-50)", border: "1px solid var(--border)", borderRadius: "var(--radius-md)", fontSize: 13, color: "var(--fg2)", lineHeight: 1.55 }}>
        <Icon name="info" size={16} color="var(--fg3)" style={{ marginTop: 1 }} />
        Enquiry data is retained and managed within the B2B platform. Where SDC activates the optional Salesforce CRM integration, the same enquiry is pushed as a lead.
      </div>
      <div style={{ display: "flex", gap: 12, marginTop: 22, flexWrap: "wrap" }}>
        <Btn variant="primary" icon="inbox" onClick={onEnquiries}>Track my enquiries</Btn>
        <Btn variant="secondary" icon="arrow-left" onClick={onBack}>Back to venues</Btn>
      </div>
    </div>
  );
}

function EnquiriesScreen({ onBack, extra }) {
  const rows = (extra ? [extra] : []).concat(window.ENQUIRIES);
  const tone = { "Quote received": "success", "In discussion": "info", Confirmed: "success", New: "warning" };
  return (
    <div style={{ maxWidth: "var(--maxw)", margin: "0 auto", padding: "24px 24px 8px" }}>
      <Breadcrumb items={[{ label: "MICE venues", onClick: onBack }, { label: "My enquiries" }]} />
      <h1 style={{ fontSize: "1.8rem", marginBottom: 6 }}>My enquiries</h1>
      <p className="caption" style={{ marginBottom: 20 }}>Every enquiry raised by your organisation, with its current status from the SDC MICE team.</p>
      <Card pad={0}>
        <div style={{ overflowX: "auto" }}>
          <table style={{ width: "100%", borderCollapse: "collapse", minWidth: 820 }}>
            <thead>
              <tr>{["Reference", "Venue", "Event", "Pax", "Dates", "Status", "Updated"].map((h, i) => (
                <th key={h} style={{ textAlign: i === 3 ? "right" : "left", padding: "11px 18px", fontSize: 12, fontWeight: 600, letterSpacing: ".04em", textTransform: "uppercase", color: "var(--fg2)", borderBottom: "1px solid var(--border)" }}>{h}</th>
              ))}</tr>
            </thead>
            <tbody>
              {rows.map(e => (
                <tr key={e.ref}>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)", fontFamily: "var(--font-mono)", fontWeight: 600, fontSize: 13.5 }}>{e.ref}</td>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)", fontSize: 14.5 }}>{e.venue}</td>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)", fontSize: 14.5 }}>{e.event}</td>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)", fontSize: 14.5, textAlign: "right" }}>{e.pax}</td>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)", fontSize: 14.5, color: "var(--fg2)" }}>{e.date}</td>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)" }}><Badge tone={tone[e.status] || "neutral"}>{e.status}</Badge></td>
                  <td style={{ padding: "13px 18px", borderBottom: "1px solid var(--border)", fontSize: 13.5, color: "var(--fg2)" }}>{e.updated}</td>
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </Card>
    </div>
  );
}

Object.assign(window, { MiceScreen, VenueScreen, EnquiryFormScreen, EnquirySubmittedScreen, EnquiriesScreen });
