// data.jsx — realistic fake operational data for TRAPO OpsPilot
// TRAPO: car floor mats & automotive accessories e-commerce (SEA market, RM currency)

const STAFF = {
  aisyah:  { name: "Aisyah Rahman",   initials: "AR", color: "#0d9488", role: "Ops Lead" },
  marcus:  { name: "Marcus Tan",      initials: "MT", color: "#2563eb", role: "Fulfillment" },
  priya:   { name: "Priya Nair",      initials: "PN", color: "#7c3aed", role: "Warranty" },
  daniel:  { name: "Daniel Wong",     initials: "DW", color: "#d97706", role: "Logistics" },
  siti:    { name: "Siti Kamarudin",  initials: "SK", color: "#db2777", role: "CX Agent" },
  jason:   { name: "Jason Lim",       initials: "JL", color: "#16a34a", role: "Installations" },
  faridah: { name: "Faridah Yusof",   initials: "FY", color: "#ea580c", role: "CX Agent" },
};

const CURRENT_USER = { name: "Nadia Hassan", initials: "NH", color: "#0d9488", role: "Operations Manager", email: "nadia.h@trapo.co" };

// helper for customers
function cust(name, email, color) {
  const initials = name.split(" ").map(w => w[0]).join("").slice(0, 2).toUpperCase();
  return { name, email, initials, color };
}

const PRIORITY = {
  high:   { label: "High",   dot: "#dc2626", bg: "#fef2f2", text: "#b91c1c", border: "#fecaca" },
  medium: { label: "Medium", dot: "#ea580c", bg: "#fff7ed", text: "#c2410c", border: "#fed7aa" },
  low:    { label: "Low",    dot: "#71717a", bg: "#f4f4f5", text: "#52525b", border: "#e4e4e7" },
};

const STATUS = {
  open:        { label: "Open",         bg: "#eff6ff", text: "#1d4ed8", dot: "#3b82f6" },
  in_progress: { label: "In Progress",  bg: "#f0fdfa", text: "#0f766e", dot: "#14b8a6" },
  escalated:   { label: "Escalated",    bg: "#fef2f2", text: "#b91c1c", dot: "#ef4444" },
  waiting:     { label: "Awaiting Cust.",bg: "#fefce8", text: "#a16207", dot: "#eab308" },
  resolved:    { label: "Resolved",     bg: "#f0fdf4", text: "#15803d", dot: "#22c55e" },
};

// Each exception. waitH = hours waiting (drives sort + "waiting time" display)
const EXCEPTIONS = [
  {
    id: "TRP-48201", customer: cust("Wei Jie Lim", "weijie.lim@gmail.com", "#2563eb"),
    car: "Honda City 2022", product: "HEX II Floor Mat — Black/Red",
    issue: "Unfulfilled Paid Order", priority: "high", waitH: 48, value: 289,
    suggested: "Check warehouse stock & contact customer", staff: "marcus", status: "open",
    channel: "Web", created: "2 days ago", rule: "Paid orders not fulfilled after 24h",
    summary: "Customer ordered a HEX II mat for Honda City. Payment of RM289 completed 48 hours ago but no fulfillment record detected in WMS. Stock shows 3 units available at Shah Alam DC. Likely a sync failure between payment gateway and fulfillment queue.",
    action: "Verify SKU HEX2-HC22-BR availability at Shah Alam, push order to pick list, and send the customer a proactive delay apology with a revised dispatch ETA.",
    reply: "Hi Wei Jie, thanks for your patience! We've confirmed your HEX II mat for your Honda City is in stock and we're prioritising dispatch today. You'll receive tracking within 24 hours. Apologies for the delay — here's RM20 off your next order: TRAPO20.",
    timeline: [
      { t: "48h ago", e: "Payment captured — RM289 via FPX", icon: "card" },
      { t: "47h ago", e: "Order confirmation email sent", icon: "mail" },
      { t: "24h ago", e: "Rule triggered: unfulfilled after 24h", icon: "flag" },
      { t: "2h ago", e: "Auto-assigned to Marcus Tan", icon: "user" },
    ],
  },
  {
    id: "TRP-48197", customer: cust("Nurul Izzah", "nurul.izzah@outlook.com", "#db2777"),
    car: "Perodua Myvi 2023", product: "HEX Anti-Fatigue Mat",
    issue: "Missing Tracking", priority: "high", waitH: 36, value: 349,
    suggested: "Request tracking from courier API", staff: "daniel", status: "escalated",
    channel: "App", created: "1 day ago", rule: "Missing tracking numbers",
    summary: "Order dispatched 36 hours ago but no tracking number was written back from the courier (J&T) API. Customer has messaged twice asking for an update. Parcel scan shows it left the DC, so this is a data write-back failure, not a lost parcel.",
    action: "Pull the AWB from the J&T manifest export, attach to the order, and send tracking to the customer. Flag the J&T webhook integration to Logistics for a fix.",
    reply: "Hi Nurul, your order is on its way! Here is your tracking number: JT-MY-8841290372. You can follow it at jtexpress.my. Sorry for the wait in getting this to you — it's out for delivery and should arrive within 1–2 business days.",
    timeline: [
      { t: "36h ago", e: "Parcel scanned out of Shah Alam DC", icon: "truck" },
      { t: "30h ago", e: "Courier webhook failed (no AWB written)", icon: "alert" },
      { t: "12h ago", e: "Customer message: 'where is my order?'", icon: "chat" },
      { t: "4h ago", e: "Escalated to Logistics", icon: "flag" },
    ],
  },
  {
    id: "TRP-48188", customer: cust("Arjun Patel", "arjun.p@gmail.com", "#7c3aed"),
    car: "Honda Civic 2021", product: "3D Trunk Liner",
    issue: "Warranty Claim", priority: "medium", waitH: 52, value: 199,
    suggested: "Review photos & approve replacement", staff: "priya", status: "in_progress",
    channel: "Web", created: "2 days ago", rule: "Unresolved warranty claims older than 48h",
    summary: "Customer submitted a warranty claim for a 3D trunk liner with a reported seam defect, 52 hours ago. Three photos attached clearly show stitching separation within the 12-month warranty window. Replacement stock is available.",
    action: "Approve the warranty replacement, generate a return label for the defective unit, and dispatch a new trunk liner. Log the defect against batch B-2024-11 for QA tracking.",
    reply: "Hi Arjun, thanks for sending those photos — we can see the stitching defect and your claim is approved under our 12-month warranty. A replacement 3D trunk liner is being dispatched today, and we've included a prepaid return label for the faulty one. No charge to you.",
    timeline: [
      { t: "52h ago", e: "Warranty claim submitted with 3 photos", icon: "shield" },
      { t: "50h ago", e: "Auto-classified: defect — stitching", icon: "ai" },
      { t: "48h ago", e: "Rule triggered: claim aging > 48h", icon: "flag" },
      { t: "6h ago", e: "Priya Nair reviewing photos", icon: "user" },
    ],
  },
  {
    id: "TRP-48176", customer: cust("Chong Mei Ling", "meiling.chong@gmail.com", "#0891b2"),
    car: "Toyota Vios 2023", product: "Installation — HEX II + Trunk",
    issue: "Installation Booking", priority: "medium", waitH: 20, value: 538,
    suggested: "Reassign to available installer slot", staff: "jason", status: "waiting",
    channel: "App", created: "20 hours ago", rule: "Installation slot unconfirmed after 12h",
    summary: "Customer booked an in-store installation for a HEX II set + trunk liner, but the assigned installer at the Penang branch called in sick. No replacement slot has been confirmed and the appointment is tomorrow at 2pm.",
    action: "Reassign to the next available installer at Penang or offer the customer a slot at the nearby branch. Confirm the new time by SMS and update the booking calendar.",
    reply: "Hi Mei Ling, regarding your installation tomorrow — we've had a scheduling change at our Penang branch. We can confirm your 2pm slot with a different installer, or move you to 11am if that's easier. Just reply with your preference and we'll lock it in!",
    timeline: [
      { t: "20h ago", e: "Installation booked — Penang, 2pm", icon: "calendar" },
      { t: "5h ago", e: "Installer marked unavailable", icon: "alert" },
      { t: "2h ago", e: "Slot conflict flagged", icon: "flag" },
    ],
  },
  {
    id: "TRP-48170", customer: cust("Rajesh Kumar", "rajesh.k@yahoo.com", "#ca8a04"),
    car: "Proton X50 2022", product: "HEX II Floor Mat — Full Set",
    issue: "Delayed Shipment", priority: "high", waitH: 72, value: 459,
    suggested: "Expedite & offer goodwill credit", staff: null, status: "open",
    channel: "Web", created: "3 days ago", rule: "Shipment delayed beyond SLA (48h)",
    summary: "A full HEX II set has been sitting in 'packed' status for 72 hours, well beyond the 48h dispatch SLA. The parcel appears stuck at the DC with no courier pickup scan. Customer is a repeat buyer (4 prior orders).",
    action: "Escalate to the DC supervisor for immediate courier pickup, and proactively offer the customer a goodwill credit given their repeat-buyer status and the SLA breach.",
    reply: "Hi Rajesh, we noticed your HEX II set has taken longer than our usual standard to ship — that's on us. We've expedited it for pickup today and added RM30 store credit to your account as an apology. Thank you for being a loyal TRAPO customer!",
    timeline: [
      { t: "72h ago", e: "Order packed at Shah Alam DC", icon: "box" },
      { t: "48h ago", e: "SLA breach — no courier pickup", icon: "alert" },
      { t: "3h ago", e: "Surfaced to Exception Queue", icon: "flag" },
    ],
  },
  {
    id: "TRP-48155", customer: cust("Tan Hui Ying", "huiying.tan@gmail.com", "#0d9488"),
    car: "Mazda CX-5 2023", product: "Tailored Dashboard Cover",
    issue: "Payment Mismatch", priority: "medium", waitH: 28, value: 159,
    suggested: "Reconcile gateway vs. order total", staff: "marcus", status: "in_progress",
    channel: "Web", created: "1 day ago", rule: "Payment amount mismatch detected",
    summary: "The captured payment (RM159) is RM20 less than the order total (RM179) after a discount code was applied twice. The order is on hold pending reconciliation. Risk of under-charging if released as-is.",
    action: "Confirm whether the second discount application was valid. If not, request the RM20 balance via a payment link; if it was a legitimate promo stack, release the order and note the exception.",
    reply: "Hi Hui Ying, quick note on your dashboard cover order — there was a small discrepancy with a discount code. Good news: we've honoured the price you paid. Your order is now released and will ship shortly. Thanks for shopping with TRAPO!",
    timeline: [
      { t: "28h ago", e: "Order placed — RM179 total", icon: "card" },
      { t: "28h ago", e: "Captured RM159 (RM20 short)", icon: "alert" },
      { t: "27h ago", e: "Rule triggered: payment mismatch", icon: "flag" },
    ],
  },
  {
    id: "TRP-48142", customer: cust("Lim Boon Keng", "bk.lim@hotmail.com", "#4f46e5"),
    car: "Nissan Almera 2022", product: "Door Sill Protector Set",
    issue: "Stock Shortage", priority: "low", waitH: 30, value: 89,
    suggested: "Offer backorder or alternative finish", staff: "siti", status: "waiting",
    channel: "App", created: "1 day ago", rule: "Paid order with zero available stock",
    summary: "Customer paid for a door sill protector set in the carbon finish, but inventory dropped to zero after an unsynced bulk order. The silver finish is in stock. Restock ETA for carbon is 9 days.",
    action: "Offer the customer the silver finish for immediate dispatch, or a backorder with a small discount. Hold the order until the customer responds.",
    reply: "Hi Boon Keng, the carbon finish you ordered just sold out and won't restock for ~9 days. We can ship the silver finish today instead, or hold your carbon set with RM15 off for the wait. Which would you prefer?",
    timeline: [
      { t: "30h ago", e: "Order placed — carbon finish", icon: "card" },
      { t: "26h ago", e: "Stock dropped to 0 (bulk order)", icon: "alert" },
      { t: "10h ago", e: "Awaiting customer choice", icon: "chat" },
    ],
  },
  {
    id: "TRP-48131", customer: cust("Siti Aminah", "siti.aminah@gmail.com", "#be123c"),
    car: "Toyota Corolla Cross 2023", product: "HEX Anti-Fatigue Mat",
    issue: "Return/Refund", priority: "low", waitH: 40, value: 349,
    suggested: "Approve return, issue refund on receipt", staff: "faridah", status: "in_progress",
    channel: "Web", created: "2 days ago", rule: "Return request unactioned > 36h",
    summary: "Customer requested a return citing wrong fitment — ordered for Corolla Cross but received Corolla Altis cut. This is a picking error on our side. Return is clearly warranted.",
    action: "Approve the return at no cost to the customer, dispatch the correct Corolla Cross cut immediately, and issue a refund only if they prefer that over a replacement.",
    reply: "Hi Siti, apologies — it looks like we sent the wrong cut for your Corolla Cross. We're dispatching the correct mat today at no charge, with a prepaid return label for the incorrect one. Would you prefer a replacement (already on the way) or a full refund?",
    timeline: [
      { t: "40h ago", e: "Return requested — wrong fitment", icon: "return" },
      { t: "38h ago", e: "Picking error confirmed", icon: "alert" },
      { t: "5h ago", e: "Faridah processing", icon: "user" },
    ],
  },
  {
    id: "TRP-48120", customer: cust("Ganesh Subra", "ganesh.s@gmail.com", "#0369a1"),
    car: "Honda HR-V 2023", product: "3D Trunk Liner + Sunshade",
    issue: "Unfulfilled Paid Order", priority: "medium", waitH: 26, value: 268,
    suggested: "Push stuck order to fulfillment", staff: null, status: "open",
    channel: "App", created: "1 day ago", rule: "Paid orders not fulfilled after 24h",
    summary: "Bundle order paid 26 hours ago, stuck in 'pending review' due to an address validation flag (unit number missing). Both items are in stock. Customer's phone number is on file.",
    action: "Call or SMS the customer to confirm the unit number, correct the shipping address, and release the order to fulfillment.",
    reply: "Hi Ganesh, we're ready to ship your trunk liner and sunshade but need to confirm your delivery address — could you reply with your unit/house number? As soon as we have it, your order goes out the same day. Thanks!",
    timeline: [
      { t: "26h ago", e: "Payment captured — RM268", icon: "card" },
      { t: "26h ago", e: "Address validation flag raised", icon: "alert" },
      { t: "2h ago", e: "Rule triggered: unfulfilled 24h", icon: "flag" },
    ],
  },
  {
    id: "TRP-48098", customer: cust("Yusof Idris", "yusof.idris@outlook.com", "#9333ea"),
    car: "Proton Saga 2021", product: "HEX II Floor Mat — Black/Grey",
    issue: "Missing Tracking", priority: "low", waitH: 18, value: 259,
    suggested: "Resend tracking link via SMS", staff: "siti", status: "waiting",
    channel: "Web", created: "18 hours ago", rule: "Missing tracking numbers",
    summary: "Tracking number exists in the system but the customer reports the SMS link never arrived. Likely an SMS gateway delivery failure to their carrier. Parcel is in transit normally.",
    action: "Resend the tracking link via SMS and email, and confirm the parcel's current status so the customer is reassured it's on the way.",
    reply: "Hi Yusof, sorry the tracking link didn't reach you! Here it is again: trapo.co/t/8841290 — your HEX II mat is currently in transit and estimated for delivery within 2 days. We've also emailed you a copy just in case.",
    timeline: [
      { t: "18h ago", e: "Tracking generated — SMS sent", icon: "truck" },
      { t: "14h ago", e: "SMS delivery failed (gateway)", icon: "alert" },
      { t: "3h ago", e: "Customer reports no link", icon: "chat" },
    ],
  },
  {
    id: "TRP-48077", customer: cust("Kavitha Raman", "kavitha.r@gmail.com", "#0d9488"),
    car: "Perodua Ativa 2023", product: "Warranty — HEX II discolouration",
    issue: "Warranty Claim", priority: "high", waitH: 76, value: 0,
    suggested: "Escalate — aging claim past SLA", staff: "priya", status: "escalated",
    channel: "App", created: "2 days ago", rule: "Unresolved warranty claims older than 48h",
    summary: "Warranty claim for premature discolouration on a HEX II mat, now 60 hours old and past the 48h resolution SLA. Customer has escalated via social media. Photos suggest a genuine material issue, not user damage.",
    action: "Prioritise this claim immediately given the SLA breach and public escalation. Approve replacement, respond on the social channel, and route the photos to QA for the affected production batch.",
    reply: "Hi Kavitha, thank you for flagging this and apologies it's taken longer than it should. We've reviewed your photos — this is covered under warranty and a replacement HEX II mat is being dispatched today. We've also passed this to our quality team. You'll hear from us shortly.",
    timeline: [
      { t: "60h ago", e: "Warranty claim — discolouration", icon: "shield" },
      { t: "48h ago", e: "SLA breach on claim resolution", icon: "alert" },
      { t: "8h ago", e: "Customer escalated on social", icon: "chat" },
      { t: "1h ago", e: "Escalated to Warranty Lead", icon: "flag" },
    ],
  },
  {
    id: "TRP-48054", customer: cust("Brandon Goh", "brandon.goh@gmail.com", "#2563eb"),
    car: "Tesla Model 3 2023", product: "HEX II Floor Mat — Tesla Fit",
    issue: "Delayed Shipment", priority: "medium", waitH: 50, value: 399,
    suggested: "Confirm courier pickup window", staff: "daniel", status: "in_progress",
    channel: "Web", created: "2 days ago", rule: "Shipment delayed beyond SLA (48h)",
    summary: "Order packed and labelled but missed two consecutive courier pickup windows due to a public holiday backlog. Now 50 hours old. Parcel is intact and ready at the DC.",
    action: "Confirm the next guaranteed pickup slot with the courier, update the customer with a firm ETA, and monitor until the first transit scan appears.",
    reply: "Hi Brandon, your Tesla-fit HEX II set is packed and ready — a public holiday caused a short courier backlog on our end. It's confirmed for pickup tomorrow morning and you'll get tracking the moment it scans. Appreciate your patience!",
    timeline: [
      { t: "50h ago", e: "Order packed & labelled", icon: "box" },
      { t: "30h ago", e: "Missed pickup — holiday backlog", icon: "alert" },
      { t: "5h ago", e: "Daniel coordinating pickup", icon: "user" },
    ],
  },
  {
    id: "TRP-48039", customer: cust("Faiz Abdullah", "faiz.a@hotmail.com", "#ea580c"),
    car: "Toyota Hilux 2022", product: "Heavy-Duty Cargo Mat",
    issue: "Installation Booking", priority: "low", waitH: 14, value: 229,
    suggested: "Send booking confirmation reminder", staff: "jason", status: "waiting",
    channel: "App", created: "14 hours ago", rule: "Installation slot unconfirmed after 12h",
    summary: "Customer selected an installation add-on but never completed the booking calendar step, so no slot is reserved. Order is otherwise paid and ready.",
    action: "Send a friendly reminder with a one-tap booking link so the customer can pick an installation slot, then confirm.",
    reply: "Hi Faiz, your Hilux cargo mat is ready and your free installation is included — you just need to pick a time! Tap here to choose a slot at your nearest branch: trapo.co/book/48039. Takes 30 seconds.",
    timeline: [
      { t: "14h ago", e: "Installation add-on selected", icon: "calendar" },
      { t: "13h ago", e: "Booking step abandoned", icon: "alert" },
      { t: "2h ago", e: "Reminder queued", icon: "flag" },
    ],
  },
  {
    id: "TRP-48012", customer: cust("Michelle Teo", "michelle.teo@gmail.com", "#db2777"),
    car: "BMW 320i 2023", product: "Premium HEX II + Boot Liner",
    issue: "Unfulfilled Paid Order", priority: "high", waitH: 30, value: 689,
    suggested: "Resolve SKU mapping error, fulfill", staff: null, status: "open",
    channel: "Web", created: "1 day ago", rule: "Paid orders not fulfilled after 24h",
    summary: "High-value premium bundle (RM689) unfulfilled for 30 hours due to a SKU mapping error — the BMW-specific cut is mapped to a discontinued internal code, so it won't appear on pick lists.",
    action: "Correct the SKU mapping to the active BMW 320i code, manually push the order to fulfillment, and verify the bundle picks correctly to avoid a repeat.",
    reply: "Hi Michelle, thanks for your patience with your premium HEX II and boot liner set. We hit a small catalogue hiccup on our side which is now fixed — your order is being prepared for dispatch today and tracking will follow within 24 hours.",
    timeline: [
      { t: "30h ago", e: "Payment captured — RM689", icon: "card" },
      { t: "29h ago", e: "SKU not found on pick list", icon: "alert" },
      { t: "6h ago", e: "Rule triggered: unfulfilled 24h", icon: "flag" },
    ],
  },
  {
    id: "TRP-47998", customer: cust("Hafiz Razak", "hafiz.razak@gmail.com", "#16a34a"),
    car: "Mercedes C200 2022", product: "Warranty — clip breakage",
    issue: "Warranty Claim", priority: "medium", waitH: 44, value: 0,
    suggested: "Approve clip replacement kit", staff: "priya", status: "open",
    channel: "App", created: "2 days ago", rule: "Unresolved warranty claims older than 48h",
    summary: "Customer reports a fixing clip snapped on a HEX II mat after 3 months. Claim is 44 hours old — approaching the 48h SLA. A clip replacement kit resolves this without a full mat swap.",
    action: "Approve and ship a clip replacement kit free of charge, with a short fitting guide. Pre-empt the SLA breach by actioning before the 48h mark.",
    reply: "Hi Hafiz, sorry to hear a clip snapped! That's covered under warranty — we're sending you a free replacement clip kit today along with a quick fitting guide. If you'd prefer a full mat replacement instead, just let us know.",
    timeline: [
      { t: "44h ago", e: "Warranty claim — clip breakage", icon: "shield" },
      { t: "42h ago", e: "Auto-classified: hardware defect", icon: "ai" },
      { t: "3h ago", e: "Approaching 48h SLA", icon: "flag" },
    ],
  },
  {
    id: "TRP-47981", customer: cust("Adeline Chua", "adeline.chua@gmail.com", "#7c3aed"),
    car: "Honda City 2023", product: "Sunshade — Custom Fit",
    issue: "Stock Shortage", priority: "low", waitH: 22, value: 79,
    suggested: "Backorder with ETA notification", staff: "siti", status: "waiting",
    channel: "Web", created: "22 hours ago", rule: "Paid order with zero available stock",
    summary: "Custom-fit sunshade for Honda City is out of stock with a 5-day restock ETA. Low-value, low-urgency item. Customer hasn't chased yet.",
    action: "Notify the customer of the short backorder with a clear ETA and the option to cancel for a full refund. No action needed beyond the proactive heads-up.",
    reply: "Hi Adeline, your custom-fit sunshade is briefly out of stock — restock is expected within 5 days and we'll ship it the moment it lands. If you'd rather not wait, just reply and we'll refund you in full, no problem.",
    timeline: [
      { t: "22h ago", e: "Order placed — custom sunshade", icon: "card" },
      { t: "20h ago", e: "Stock at 0 — restock in 5d", icon: "alert" },
      { t: "4h ago", e: "ETA notice queued", icon: "flag" },
    ],
  },
];

// KPI definitions for the dashboard
const KPIS = [
  { key: "open",     label: "Open Exceptions",        value: "47", delta: "+8", trend: "up",   bad: true,  sub: "vs. yesterday", spark: [28,31,30,35,33,39,42,47] },
  { key: "delayed",  label: "Delayed Orders",         value: "23", delta: "+3", trend: "up",   bad: true,  sub: "beyond 48h SLA", spark: [12,15,14,18,17,20,21,23] },
  { key: "warranty", label: "Pending Warranty Claims",value: "12", delta: "−2", trend: "down", bad: false, sub: "awaiting review", spark: [18,17,16,15,14,14,13,12] },
  { key: "install",  label: "Installation Issues",    value: "6",  delta: "+1", trend: "up",   bad: true,  sub: "slot conflicts", spark: [3,4,3,5,4,5,5,6] },
  { key: "restime",  label: "Avg Resolution Time",    value: "4.2h",delta: "−0.6h", trend: "down", bad: false, sub: "last 24h", spark: [6.1,5.8,5.5,5.2,4.9,4.6,4.4,4.2] },
];

// Admin rules
const RULES_INIT = [
  { id: "r1", name: "Unfulfilled paid orders", desc: "Flag paid orders not fulfilled after a set time.", enabled: true,  threshold: 24, unit: "hours", priority: "high",   triggered: 14, icon: "box" },
  { id: "r2", name: "Aging warranty claims", desc: "Flag unresolved warranty claims older than threshold.", enabled: true,  threshold: 48, unit: "hours", priority: "high",   triggered: 4,  icon: "shield" },
  { id: "r3", name: "Missing tracking numbers", desc: "Flag dispatched orders with no tracking written back.", enabled: true,  threshold: 6,  unit: "hours", priority: "medium", triggered: 3,  icon: "truck" },
  { id: "r4", name: "Shipment SLA breach", desc: "Flag packed orders not picked up within SLA window.", enabled: true,  threshold: 48, unit: "hours", priority: "high",   triggered: 5,  icon: "clock" },
  { id: "r5", name: "Payment amount mismatch", desc: "Flag orders where captured amount ≠ order total.", enabled: true,  threshold: 0,  unit: "RM tolerance", priority: "medium", triggered: 2, icon: "card" },
  { id: "r6", name: "Installation slot unconfirmed", desc: "Flag bookings without a confirmed installer slot.", enabled: false, threshold: 12, unit: "hours", priority: "low",    triggered: 0,  icon: "calendar" },
  { id: "r7", name: "Zero-stock paid order", desc: "Flag paid orders for SKUs with no available stock.", enabled: true,  threshold: 0,  unit: "units", priority: "medium", triggered: 2, icon: "alert" },
  { id: "r8", name: "Return request unactioned", desc: "Flag return/refund requests left unactioned.", enabled: false, threshold: 36, unit: "hours", priority: "low",    triggered: 0,  icon: "return" },
];

const NAV = [
  { key: "dashboard", label: "Dashboard", icon: "grid" },
  { key: "queue",     label: "Exception Queue", icon: "alert", badge: 47 },
  { key: "orders",    label: "Orders", icon: "box" },
  { key: "warranty",  label: "Warranty Claims", icon: "shield", badge: 12 },
  { key: "install",   label: "Installations", icon: "wrench" },
  { key: "insights",  label: "AI Insights", icon: "sparkles" },
  { key: "rules",     label: "Admin Rules", icon: "sliders" },
  { key: "audit",     label: "Audit Logs", icon: "list" },
];

Object.assign(window, { STAFF, CURRENT_USER, PRIORITY, STATUS, EXCEPTIONS, KPIS, RULES_INIT, NAV });
