/* Claims Desk — the one fixture set. Every screen reads these arrays; a record
   that appears twice is this entry read twice, never a second literal written
   to match. Timestamps are offsets from load, so every time bar, countdown and
   date column is true whenever the kit is opened.

   Narrative check: the notifications, the file notes and the recovery
   correspondence below all name real records — CLM-26-0179, CLM-25-0977,
   CLM-25-0913, CLM-26-0207, CLM-25-0929, REC-26-0038, REC-26-0022 — and agree
   with their status, amounts and clocks at the timestamp they carry. */

const CLAIMS_NOW = Date.now();
const D = 864e5;
const dAgo = (days) => CLAIMS_NOW - days * D;
const dAhead = (days) => CLAIMS_NOW + days * D;

const CLAIMS_USER = { name: "Imogen Petrakis", role: "Cargo claims adjuster", email: "i.petrakis@corvenline.example", avatar: "../../assets/img/avatar-40-03.jpg", alerts: ["time_bar", "documents"] };
const CLAIMS_MANAGER = { name: "Roland Achebe", role: "Claims manager" };
const CLAIMS_CARRIER = { name: "Corven Line", desk: "Claims desk", region: "North Atlantic" };

const doc = (type, status, receivedAt, note) => ({ type: type, status: status, receivedAt: receivedAt || null, note: note || null });

/* Every claim carries its cargo facts, the customer's claimed figure, the
   adjuster's adjustments (null until the file has been assessed), its evidence,
   and — once decided — its settlement and the customer's response.
   deliveredAt is the only clock stored: the time bar is derived from it. */
const CLAIMS = [
  {
    id: "CLM-26-0188", customer: "Ravenna Machine Tools", claimedAt: dAgo(138), deliveredAt: dAgo(151),
    bl: "CRVN-2604-88192", container: "MSKU 4417820", vessel: "Tanager Bay", voyage: "214E",
    commodity: "CNC lathe assemblies", packages: 24, weightKg: 18400,
    pol: "Genoa", pod: "Charleston",
    incident: "Lashing failure in hold 3 — six pallets crushed against the bulkhead",
    status: "ready_for_decision", claimedCents: 12840000,
    assessment: { depreciationCents: 1284000, salvageCents: 3150000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(6) },
    documents: [
      doc("port_photos", "received", dAgo(112), "41 frames, Charleston terminal"),
      doc("surveyor_report", "received", dAgo(38), "Cawley Marine, survey held 12 days after discharge"),
      doc("packing_list", "received", dAgo(120)),
      doc("commercial_invoice", "received", dAgo(120)),
      doc("delivery_receipt", "received", dAgo(126), "Signed with exception: \"6 pallets visibly crushed, contents unchecked\""),
    ],
    notes: [
      { at: dAgo(6), who: "Imogen Petrakis", text: "Assessed on the surveyor's figures. Betterment applied at 10% — the units were two years into a seven-year life." },
      { at: dAgo(34), who: "Cawley Marine", text: "Survey report filed. Damage consistent with lashing failure, not pre-shipment handling." },
    ],
  },
  {
    id: "CLM-26-0201", customer: "Fen & Marrow Foods", claimedAt: dAgo(84), deliveredAt: dAgo(96),
    bl: "CRVN-2605-11740", container: "TCLU 9930411", vessel: "Ardent Fen", voyage: "118W",
    commodity: "Tinned preserves", packages: 480, weightKg: 9600,
    pol: "Valencia", pod: "Newark",
    incident: "Water ingress through a failed door gasket — 62 cartons pulped",
    status: "ready_for_decision", claimedCents: 1860000,
    assessment: { depreciationCents: 0, salvageCents: 240000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(3) },
    documents: [
      doc("port_photos", "received", dAgo(80)),
      doc("surveyor_report", "received", dAgo(21), "Vandermeer Adjusters"),
      doc("packing_list", "received", dAgo(82)),
      doc("commercial_invoice", "received", dAgo(82)),
      doc("delivery_receipt", "received", dAgo(88), "Signed with exception: \"one pallet wet, carton damage\""),
    ],
  },
  {
    id: "CLM-26-0195", customer: "Ravenna Machine Tools", claimedAt: dAgo(92), deliveredAt: dAgo(104),
    bl: "CRVN-2605-30447", container: "MSKU 6620713", vessel: "Kestrel Fen", voyage: "119W",
    commodity: "Tooling and collet sets", packages: 340, weightKg: 22400,
    pol: "Genoa", pod: "Charleston",
    incident: "Seawater ingress through a split roof panel — 96 boxes corroded",
    status: "awaiting_signoff", claimedCents: 9650000,
    assessment: { depreciationCents: 480000, salvageCents: 620000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(9) },
    decision: { outcome: "approve_full", decidedAt: dAgo(4), decidedBy: "Imogen Petrakis", signedOffBy: null, justification: null },
    documents: [
      doc("port_photos", "received", dAgo(100)),
      doc("surveyor_report", "received", dAgo(30), "Cawley Marine — chloride testing on 40 sampled boxes"),
      doc("packing_list", "received", dAgo(101)),
      doc("commercial_invoice", "received", dAgo(101)),
      doc("delivery_receipt", "received", dAgo(102), "Signed with exception: \"upper tier boxes wet and rust stained\""),
    ],
    notes: [
      { at: dAgo(4), who: "Imogen Petrakis", text: "Approved in full at $80,500.00 and sent to Roland Achebe for sign-off — above my $25,000.00 authority." },
    ],
  },
  {
    id: "CLM-26-0207", customer: "Ferrymead Automotive", claimedAt: dAgo(60), deliveredAt: dAgo(72),
    bl: "CRVN-2606-10884", container: "FCIU 8830220", vessel: "Tanager Bay", voyage: "217E",
    commodity: "Gearbox castings", packages: 120, weightKg: 19200,
    pol: "Bremerhaven", pod: "Jacksonville",
    incident: "Crates dropped from the second tier during restow — 29 castings cracked",
    status: "awaiting_signoff", claimedCents: 5480000,
    assessment: { depreciationCents: 274000, salvageCents: 0, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(16) },
    decision: { outcome: "approve_part", decidedAt: dAgo(11), decidedBy: "Imogen Petrakis", signedOffBy: null, justification: "Twenty-nine of the one hundred and twenty crates are cracked; the remainder were surveyed as sound. Betterment of 5% is applied because the castings had been held in inventory for a year before shipment." },
    documents: [
      doc("port_photos", "received", dAgo(68)),
      doc("surveyor_report", "received", dAgo(40), "Atlantic Marine Consultants — the same surveyor as CLM-25-0913"),
      doc("packing_list", "received", dAgo(69)),
      doc("commercial_invoice", "received", dAgo(69)),
      doc("delivery_receipt", "received", dAgo(70), "Signed with exception: \"crate banding broken, castings visible\""),
    ],
    notes: [
      { at: dAgo(11), who: "Imogen Petrakis", text: "Approved in part at $47,060.00 and sent to Roland Achebe for sign-off." },
      { at: dAgo(3), who: "Imogen Petrakis", text: "Chased the sign-off — the consignee is asking for a date and this is their second claim on the same lane." },
    ],
  },
  {
    id: "CLM-26-0179", customer: "Aurelian Tile Imports", claimedAt: dAgo(174), deliveredAt: dAgo(188),
    bl: "CRVN-2603-70055", container: "HLXU 2288104", vessel: "Tanager Bay", voyage: "209E",
    commodity: "Glazed floor tile", packages: 1240, weightKg: 24600,
    pol: "Castellón", pod: "Savannah",
    incident: "Stack collapse in transit — 310 boxes broken",
    status: "ready_for_decision", claimedCents: 4125000, assessment: null,
    documents: [
      doc("port_photos", "received", dAgo(150)),
      doc("surveyor_report", "illegible", dAgo(9), "Scan is a photograph of a screen — pages 3–7 unreadable, re-requested"),
      doc("packing_list", "received", dAgo(160)),
      doc("commercial_invoice", "received", dAgo(160)),
      doc("delivery_receipt", "received", dAgo(166), "Clean receipt — damage reported 2 days after delivery"),
    ],
    notes: [
      { at: dAgo(9), who: "Imogen Petrakis", text: "Surveyor's report rejected as illegible. Cannot assess breakage percentage without pages 3–7." },
    ],
  },
  {
    id: "CLM-26-0212", customer: "Kettleworth Brewing", claimedAt: dAgo(52), deliveredAt: dAgo(60),
    bl: "CRVN-2606-40318", container: "CMAU 5510992", vessel: "Kestrel Fen", voyage: "121W",
    commodity: "Cask ale in kegs", packages: 96, weightKg: 5760,
    pol: "Liverpool", pod: "Baltimore",
    incident: "Twelve kegs punctured by a shifted stillage",
    status: "awaiting_documents", claimedCents: 2278000, assessment: null,
    documents: [
      doc("port_photos", "received", dAgo(48)),
      doc("surveyor_report", "received", dAgo(30), "Northgate Marine"),
      doc("packing_list", "requested", null, "Requested twice — chased 6 days ago"),
      doc("commercial_invoice", "requested", null, "Requested 18 days ago"),
      doc("delivery_receipt", "received", dAgo(54)),
    ],
  },
  {
    id: "CLM-26-0166", customer: "Silbury Ceramics", claimedAt: dAgo(200), deliveredAt: dAgo(212),
    bl: "CRVN-2602-99120", container: "OOLU 7712035", vessel: "Ardent Fen", voyage: "112W",
    commodity: "Sanitaryware", packages: 310, weightKg: 16800,
    pol: "Leixões", pod: "Houston",
    incident: "Container dropped during discharge — full stack fractured",
    status: "awaiting_survey", claimedCents: 9650000, assessment: null,
    documents: [
      doc("port_photos", "received", dAgo(190)),
      doc("surveyor_report", "requested", null, "Joint survey booked with the terminal for next week"),
      doc("packing_list", "received", dAgo(195)),
      doc("commercial_invoice", "received", dAgo(195)),
      doc("delivery_receipt", "received", dAgo(198), "Signed with exception: \"container corner post deformed\""),
    ],
  },
  {
    id: "CLM-26-0154", customer: "Trelawney Paper", claimedAt: dAgo(228), deliveredAt: dAgo(240),
    bl: "CRVN-2601-33871", container: "MSCU 1180644", vessel: "Kestrel Fen", voyage: "108W",
    commodity: "Coated paper reels", packages: 44, weightKg: 21120,
    pol: "Gothenburg", pod: "Norfolk",
    incident: "Condensation damage to outer wraps of 11 reels",
    status: "awaiting_documents", claimedCents: 894000, assessment: null,
    documents: [
      doc("port_photos", "requested", null, "Customer's photographs never supplied"),
      doc("surveyor_report", "received", dAgo(180), "Bergen Cargo Survey"),
      doc("packing_list", "received", dAgo(210)),
      doc("commercial_invoice", "received", dAgo(210)),
      doc("delivery_receipt", "requested", null, "Consignee cannot locate the signed copy"),
    ],
  },
  {
    id: "CLM-25-0977", customer: "Vosges Cold Chain", claimedAt: dAgo(306), deliveredAt: dAgo(318),
    bl: "CRVN-2510-20447", container: "MWCU 6650180", vessel: "Tanager Bay", voyage: "198E",
    commodity: "Frozen confectionery", packages: 20, weightKg: 22000,
    pol: "Antwerp", pod: "Miami",
    incident: "Reefer compressor failure for 61 hours — full load condemned",
    status: "escalated_legal", claimedCents: 31000000,
    assessment: { depreciationCents: 0, salvageCents: 0, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(96) },
    documents: [
      doc("port_photos", "received", dAgo(300)),
      doc("surveyor_report", "received", dAgo(280), "Delacroix & Fils, with the reefer data logger download"),
      doc("packing_list", "received", dAgo(302)),
      doc("commercial_invoice", "received", dAgo(302)),
      doc("delivery_receipt", "received", dAgo(304), "Signed with exception: \"load temperature +8°C on discharge\""),
    ],
    notes: [
      { at: dAgo(74), who: "Imogen Petrakis", text: "Escalated. The claimant argues the limitation of liability is broken by unseaworthiness — a reefer pre-trip inspection was skipped. Legal holding the file." },
    ],
  },
  {
    id: "CLM-26-0143", customer: "Nordkapp Seafood", claimedAt: dAgo(245), deliveredAt: dAgo(257),
    bl: "CRVN-2512-88710", container: "MWCU 4410277", vessel: "Ardent Fen", voyage: "104W",
    commodity: "Frozen cod fillet", packages: 900, weightKg: 19800,
    pol: "Ålesund", pod: "Boston",
    incident: "Set-point drift — 140 cartons out of specification",
    status: "approved_awaiting_payment", claimedCents: 7430000,
    assessment: { depreciationCents: 371500, salvageCents: 890000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(20) },
    decision: { outcome: "approve_full", decidedAt: dAgo(14), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "unscheduled", amountCents: 5668500 },
    documents: [
      doc("port_photos", "received", dAgo(240)),
      doc("surveyor_report", "received", dAgo(200), "Nordic Marine Survey"),
      doc("packing_list", "received", dAgo(242)),
      doc("commercial_invoice", "received", dAgo(242)),
      doc("delivery_receipt", "received", dAgo(244), "Signed with exception: \"pulp temperatures above specification\""),
    ],
  },
  {
    id: "CLM-26-0131", customer: "Pallas Glassworks", claimedAt: dAgo(288), deliveredAt: dAgo(300),
    bl: "CRVN-2511-51204", container: "TGHU 3390118", vessel: "Kestrel Fen", voyage: "099W",
    commodity: "Laboratory glassware", packages: 210, weightKg: 4200,
    pol: "Piraeus", pod: "Philadelphia",
    incident: "Forklift strike at the terminal — 38 cases broken",
    status: "approved_awaiting_payment", claimedCents: 1680000,
    assessment: { depreciationCents: 0, salvageCents: 132000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(40) },
    decision: { outcome: "approve_full", decidedAt: dAgo(32), decidedBy: "Imogen Petrakis", signedOffBy: null, justification: null },
    settlement: { status: "scheduled", amountCents: 1048000, scheduledFor: dAhead(3), reference: "PAY-26-3402" },
    documents: [
      doc("port_photos", "received", dAgo(285)),
      doc("surveyor_report", "received", dAgo(270), "Keystone Marine"),
      doc("packing_list", "received", dAgo(286)),
      doc("commercial_invoice", "received", dAgo(286)),
      doc("delivery_receipt", "received", dAgo(288), "Signed with exception: \"38 cases crushed\""),
    ],
  },
  {
    id: "CLM-25-0929", customer: "Vollmer Interiors", claimedAt: dAgo(276), deliveredAt: dAgo(288),
    bl: "CRVN-2511-19983", container: "SEGU 8820156", vessel: "Tanager Bay", voyage: "201E",
    commodity: "Upholstered seating", packages: 130, weightKg: 7800,
    pol: "Naples", pod: "New York",
    incident: "Rainwater ingress through a damaged roof panel",
    status: "approved_awaiting_payment", claimedCents: 3400000,
    assessment: { depreciationCents: 340000, salvageCents: 0, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(60) },
    decision: { outcome: "approve_full", decidedAt: dAgo(52), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "returned", amountCents: 2560000, scheduledFor: dAgo(12), sentAt: dAgo(9), returnedAt: dAgo(4), returnReason: "IBAN rejected by the beneficiary bank", reference: "PAY-26-3286" },
    documents: [
      doc("port_photos", "received", dAgo(270)),
      doc("surveyor_report", "received", dAgo(250), "Hudson Marine"),
      doc("packing_list", "received", dAgo(272)),
      doc("commercial_invoice", "received", dAgo(272)),
      doc("delivery_receipt", "received", dAgo(274), "Signed with exception: \"cartons water stained\""),
    ],
  },
  {
    id: "CLM-25-0942", customer: "Dunmore Textiles", claimedAt: dAgo(198), deliveredAt: dAgo(210),
    bl: "CRVN-2601-70228", container: "APZU 6610338", vessel: "Ardent Fen", voyage: "110W",
    commodity: "Woven furnishing fabric", packages: 620, weightKg: 12400,
    pol: "İzmir", pod: "Charleston",
    incident: "Rolls chafed through by an unsecured stow",
    status: "paid", claimedCents: 8900000,
    assessment: { depreciationCents: 890000, salvageCents: 1750000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(40) },
    decision: { outcome: "approve_full", decidedAt: dAgo(30), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "sent", amountCents: 5760000, scheduledFor: dAgo(4), sentAt: dAgo(2), reference: "PAY-26-3318" },
    response: { status: "awaiting_response", offerSentAt: dAgo(2) },
    recoveryId: "REC-26-0044",
    documents: [
      doc("port_photos", "received", dAgo(195)),
      doc("surveyor_report", "received", dAgo(170), "Levant Cargo Control"),
      doc("packing_list", "received", dAgo(196)),
      doc("commercial_invoice", "received", dAgo(196)),
      doc("delivery_receipt", "received", dAgo(198), "Signed with exception: \"outer rolls chafed\""),
    ],
  },
  {
    id: "CLM-25-0913", customer: "Ferrymead Automotive", claimedAt: dAgo(240), deliveredAt: dAgo(252),
    bl: "CRVN-2512-30991", container: "FCIU 2201884", vessel: "Kestrel Fen", voyage: "101W",
    commodity: "Crated engine components", packages: 168, weightKg: 26400,
    pol: "Bremerhaven", pod: "Jacksonville",
    incident: "Dropped container at the terminal — 11 crates crushed",
    status: "paid", claimedCents: 21040000,
    assessment: { depreciationCents: 2104000, salvageCents: 4046000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(70) },
    decision: { outcome: "approve_part", decidedAt: dAgo(60), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: "Eleven of the one hundred and sixty-eight crates are crushed; the rest were surveyed as sound and returned to stock. Betterment of 10% is applied because the castings were held in inventory for two years before shipment, and the scrap value realised by your buyer is credited back." },
    settlement: { status: "cleared", amountCents: 14390000, scheduledFor: dAgo(40), sentAt: dAgo(32), clearedAt: dAgo(26), reference: "PAY-26-3140" },
    response: { status: "disputed", offerSentAt: dAgo(32), respondedAt: dAgo(12), demandCents: 21040000, note: "The consignee rejects the betterment deduction and the salvage credit, and holds the carrier to the full invoice value of all one hundred and sixty-eight crates." },
    recoveryId: "REC-26-0038",
    documents: [
      doc("port_photos", "received", dAgo(235)),
      doc("surveyor_report", "received", dAgo(210), "Atlantic Marine Consultants"),
      doc("packing_list", "received", dAgo(236)),
      doc("commercial_invoice", "received", dAgo(236)),
      doc("delivery_receipt", "received", dAgo(238), "Signed with exception: \"container dropped, contents unchecked\""),
    ],
  },
  {
    id: "CLM-25-0908", customer: "Larkspur Wine Imports", claimedAt: dAgo(268), deliveredAt: dAgo(280),
    bl: "CRVN-2511-88034", container: "TRLU 5580227", vessel: "Ardent Fen", voyage: "098W",
    commodity: "Bottled wine", packages: 1100, weightKg: 16500,
    pol: "Sète", pod: "Baltimore",
    incident: "Heat damage — container stowed above deck without protection",
    status: "paid", claimedCents: 7900000,
    assessment: { depreciationCents: 0, salvageCents: 1260000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(80) },
    decision: { outcome: "approve_full", decidedAt: dAgo(70), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "cleared", amountCents: 6140000, scheduledFor: dAgo(60), sentAt: dAgo(52), clearedAt: dAgo(40), reference: "PAY-26-3061" },
    response: { status: "accepted", offerSentAt: dAgo(52), respondedAt: dAgo(46) },
    recoveryId: "REC-26-0022",
    documents: [
      doc("port_photos", "received", dAgo(265)),
      doc("surveyor_report", "received", dAgo(240), "Midi Cargo Survey"),
      doc("packing_list", "received", dAgo(266)),
      doc("commercial_invoice", "received", dAgo(266)),
      doc("delivery_receipt", "received", dAgo(268), "Signed with exception: \"bottles cooked, labels lifted\""),
    ],
  },
  {
    id: "CLM-25-0889", customer: "Ostend Chemicals", claimedAt: dAgo(300), deliveredAt: dAgo(312),
    bl: "CRVN-2510-66218", container: "DFSU 9910556", vessel: "Kestrel Fen", voyage: "094W",
    commodity: "Drummed lubricant", packages: 80, weightKg: 16000,
    pol: "Zeebrugge", pod: "Savannah",
    incident: "Drums punctured by a road trailer's tie-down",
    status: "paid", claimedCents: 3450000,
    assessment: { depreciationCents: 0, salvageCents: 275000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(110) },
    decision: { outcome: "approve_full", decidedAt: dAgo(100), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "cleared", amountCents: 2675000, scheduledFor: dAgo(80), sentAt: dAgo(70), clearedAt: dAgo(54), reference: "PAY-26-2903" },
    response: { status: "accepted", offerSentAt: dAgo(70), respondedAt: dAgo(64) },
    recoveryId: "REC-26-0031",
    documents: [
      doc("port_photos", "received", dAgo(298)),
      doc("surveyor_report", "received", dAgo(280), "Palmetto Marine"),
      doc("packing_list", "received", dAgo(299)),
      doc("commercial_invoice", "received", dAgo(299)),
      doc("delivery_receipt", "received", dAgo(300), "Signed with exception: \"two drums leaking on arrival\""),
    ],
  },
  {
    id: "CLM-25-0851", customer: "Halvard Steel", claimedAt: dAgo(330), deliveredAt: dAgo(342),
    bl: "CRVN-2509-11209", container: "MSKU 7730448", vessel: "Tanager Bay", voyage: "189E",
    commodity: "Cold-rolled coil", packages: 16, weightKg: 25600,
    pol: "Rotterdam", pod: "Mobile",
    incident: "Coils shifted in transit — edge damage from inadequate cradling",
    status: "paid", claimedCents: 11200000,
    assessment: { depreciationCents: 0, salvageCents: 1900000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(140) },
    decision: { outcome: "approve_full", decidedAt: dAgo(130), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "cleared", amountCents: 6860800, scheduledFor: dAgo(110), sentAt: dAgo(100), clearedAt: dAgo(88), reference: "PAY-26-2744" },
    response: { status: "accepted", offerSentAt: dAgo(100), respondedAt: dAgo(94) },
    recoveryId: "REC-25-0996",
    documents: [
      doc("port_photos", "received", dAgo(328)),
      doc("surveyor_report", "received", dAgo(310), "Gulf Marine Survey"),
      doc("packing_list", "received", dAgo(329)),
      doc("commercial_invoice", "received", dAgo(329)),
      doc("delivery_receipt", "received", dAgo(330), "Signed with exception: \"coil edges deformed\""),
    ],
  },
  {
    id: "CLM-25-0961", customer: "Silbury Ceramics", claimedAt: dAgo(210), deliveredAt: dAgo(222),
    bl: "CRVN-2601-58003", container: "OOLU 4420917", vessel: "Tanager Bay", voyage: "205E",
    commodity: "Vitreous china basins", packages: 190, weightKg: 11400,
    pol: "Leixões", pod: "Houston",
    incident: "Reach-stacker strike on the container door — 47 units broken",
    status: "paid", claimedCents: 4180000,
    assessment: { depreciationCents: 0, salvageCents: 310000, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(130) },
    decision: { outcome: "approve_full", decidedAt: dAgo(120), decidedBy: "Imogen Petrakis", signedOffBy: "Roland Achebe", justification: null },
    settlement: { status: "cleared", amountCents: 3370000, scheduledFor: dAgo(100), sentAt: dAgo(92), clearedAt: dAgo(80), reference: "PAY-26-2988" },
    response: { status: "accepted", offerSentAt: dAgo(92), respondedAt: dAgo(86) },
    /* Deliberately no recoveryId: the terminal that struck the door has never
       been pursued, which is what makes this the file a new recovery opens
       against. */
    documents: [
      doc("port_photos", "received", dAgo(206)),
      doc("surveyor_report", "received", dAgo(190), "Bayou Marine Survey — terminal incident report attached"),
      doc("packing_list", "received", dAgo(207)),
      doc("commercial_invoice", "received", dAgo(207)),
      doc("delivery_receipt", "received", dAgo(208), "Signed with exception: \"door panel stove in, contents broken\""),
    ],
  },
  {
    id: "CLM-25-0864", customer: "Marlowe Furniture", claimedAt: dAgo(318), deliveredAt: dAgo(330),
    bl: "CRVN-2509-40772", container: "CAIU 3320991", vessel: "Ardent Fen", voyage: "091W",
    commodity: "Flat-pack cabinetry", packages: 260, weightKg: 10400,
    pol: "Gdańsk", pod: "Norfolk",
    incident: "Scuffing and corner damage reported on 44 cartons",
    status: "rejected", claimedCents: 3340000,
    assessment: { depreciationCents: 0, salvageCents: 0, deductibleCents: 500000, assessedBy: "Imogen Petrakis", assessedAt: dAgo(46) },
    decision: { outcome: "reject", decidedAt: dAgo(38), decidedBy: "Imogen Petrakis", signedOffBy: null, rejectReason: "pre_shipment_damage", justification: "The surveyor's report and the packing photographs taken at Gdańsk both show corner crushing before the container was sealed. The delivery receipt was signed clean, and the damage described matches the pre-shipment condition, so the loss did not occur in the carrier's custody." },
    documents: [
      doc("port_photos", "received", dAgo(316)),
      doc("surveyor_report", "received", dAgo(300), "Baltic Marine Survey"),
      doc("packing_list", "received", dAgo(317)),
      doc("commercial_invoice", "received", dAgo(317)),
      doc("delivery_receipt", "received", dAgo(318), "Clean receipt, no exception noted"),
    ],
  },
];

/* Recoveries — the mirror image, with their own counterparties, their own
   deadlines and their own money. soughtCents always reads the settlement the
   claim actually paid, so the two sides can never drift apart. */
const RECOVERIES = [
  {
    id: "REC-26-0044", claimId: "CLM-25-0942", counterparty: { name: "Quayside Lashing Services", kind: "lashing", contact: "claims@quaysidelashing.example" },
    basis: "Terminal lashing contract, clause 11 — notice within 40 days of payment",
    soughtCents: 5760000, recoveredCents: 0, offerCents: null,
    status: "to_file", openedAt: dAgo(2), fileByAt: dAhead(38),
    log: [{ at: dAgo(2), who: "Imogen Petrakis", text: "Recovery opened against the lashing contractor on payment of CLM-25-0942. Notice not yet served." }],
  },
  {
    id: "REC-26-0038", claimId: "CLM-25-0913", counterparty: { name: "Meridian Terminal Services", kind: "terminal", contact: "liability@meridianterminal.example" },
    basis: "Terminal handling agreement, clause 8 — 12 months from the incident",
    soughtCents: 14390000, recoveredCents: 0, offerCents: null,
    status: "filed", openedAt: dAgo(24), noticeServedAt: dAgo(18), fileByAt: dAhead(160),
    log: [
      { at: dAgo(24), who: "Imogen Petrakis", text: "Recovery opened on payment of CLM-25-0913. Terminal's own incident report names the reach-stacker operator." },
      { at: dAgo(18), who: "Imogen Petrakis", text: "Notice of claim served with the survey report and the settlement proof of $143,900.00." },
      { at: dAgo(5), who: "Meridian Terminal Services", text: "Acknowledged. Liability under review by their insurer; response promised within 30 days." },
    ],
  },
  {
    id: "REC-26-0022", claimId: "CLM-25-0908", counterparty: { name: "Meridian Terminal Services", kind: "terminal", contact: "liability@meridianterminal.example" },
    basis: "Terminal handling agreement, clause 8 — 12 months from the incident",
    soughtCents: 6140000, recoveredCents: 0, offerCents: 3400000,
    status: "negotiating", openedAt: dAgo(64), noticeServedAt: dAgo(58), fileByAt: dAhead(88),
    log: [
      { at: dAgo(58), who: "Imogen Petrakis", text: "Notice served. Above-deck stowage was booked by the terminal against our stowage plan." },
      { at: dAgo(20), who: "Meridian Terminal Services", text: "Liability admitted in part. Offer of $34,000.00 in full and final settlement." },
      { at: dAgo(9), who: "Imogen Petrakis", text: "Offer rejected as below the surveyed loss. Counter-proposal of $52,000.00 sent." },
    ],
  },
  {
    id: "REC-26-0031", claimId: "CLM-25-0889", counterparty: { name: "Brandt Haulage", kind: "haulier", contact: "ops@brandthaulage.example" },
    basis: "Haulage subcontract, CMR liability",
    soughtCents: 2675000, recoveredCents: 1920000, offerCents: 1920000,
    status: "recovered", openedAt: dAgo(50), noticeServedAt: dAgo(46), fileByAt: dAhead(20), closedAt: dAgo(12),
    log: [
      { at: dAgo(46), who: "Imogen Petrakis", text: "Notice served. Tie-down puncture is squarely the haulier's." },
      { at: dAgo(12), who: "Brandt Haulage", text: "Settled at $19,200.00 — CMR weight limitation applied to the drummed weight." },
    ],
  },
  {
    id: "REC-25-0996", claimId: "CLM-25-0851", counterparty: { name: "Halland Packing Co", kind: "packer", contact: "claims@hallandpacking.example" },
    basis: "Stuffing services agreement, clause 6",
    soughtCents: 6860800, recoveredCents: 0, offerCents: null,
    status: "denied", openedAt: dAgo(80), noticeServedAt: dAgo(74), fileByAt: dAgo(10), closedAt: dAgo(40),
    log: [
      { at: dAgo(74), who: "Imogen Petrakis", text: "Notice served — cradling was specified in the stuffing instructions." },
      { at: dAgo(40), who: "Halland Packing Co", text: "Liability denied. They rely on the carrier's stowage plan having been altered after stuffing." },
    ],
  },
];

/* Claimants — the counterparty on the customer's side. Holds only what a claim
   cannot: who to write to, when they first shipped with us, their main lane and
   the terms they book on. Everything else about a claimant — what they have
   claimed, what we have paid, what they have disputed — is derived from CLAIMS
   by name, which is the join key. */
const CLAIMANTS = [
  { id: "ravenna-machine-tools", name: "Ravenna Machine Tools", contact: "Lucia Ferretti", email: "l.ferretti@ravennatools.example", since: dAgo(1580), lane: "Genoa → Charleston", terms: "Named account · contract of affreightment" },
  { id: "fen-marrow-foods", name: "Fen & Marrow Foods", contact: "Owen Brackley", email: "o.brackley@fenmarrow.example", since: dAgo(720), lane: "Valencia → Newark", terms: "Spot booking · bill of lading terms" },
  { id: "aurelian-tile-imports", name: "Aurelian Tile Imports", contact: "Nuria Palau", email: "n.palau@aureliantile.example", since: dAgo(2100), lane: "Castellón → Savannah", terms: "Named account · contract of affreightment" },
  { id: "kettleworth-brewing", name: "Kettleworth Brewing", contact: "Sam Ackroyd", email: "s.ackroyd@kettleworth.example", since: dAgo(410), lane: "Liverpool → Baltimore", terms: "Spot booking · bill of lading terms" },
  { id: "silbury-ceramics", name: "Silbury Ceramics", contact: "Inês Cardoso", email: "i.cardoso@silburyceramics.example", since: dAgo(1240), lane: "Leixões → Houston", terms: "Named account · bill of lading terms" },
  { id: "trelawney-paper", name: "Trelawney Paper", contact: "Erik Sandell", email: "e.sandell@trelawneypaper.example", since: dAgo(2600), lane: "Gothenburg → Norfolk", terms: "Named account · contract of affreightment" },
  { id: "vosges-cold-chain", name: "Vosges Cold Chain", contact: "Camille Rouart", email: "c.rouart@vosgescold.example", since: dAgo(1890), lane: "Antwerp → Miami", terms: "Reefer contract · pre-trip inspection clause" },
  { id: "nordkapp-seafood", name: "Nordkapp Seafood", contact: "Håkon Vik", email: "h.vik@nordkappseafood.example", since: dAgo(980), lane: "Ålesund → Boston", terms: "Reefer contract · pre-trip inspection clause" },
  { id: "pallas-glassworks", name: "Pallas Glassworks", contact: "Dimitra Solaki", email: "d.solaki@pallasglass.example", since: dAgo(1450), lane: "Piraeus → Philadelphia", terms: "Spot booking · bill of lading terms" },
  { id: "vollmer-interiors", name: "Vollmer Interiors", contact: "Greta Vollmer", email: "g.vollmer@vollmerinteriors.example", since: dAgo(640), lane: "Naples → New York", terms: "Spot booking · bill of lading terms" },
  { id: "dunmore-textiles", name: "Dunmore Textiles", contact: "Ayla Demir", email: "a.demir@dunmoretextiles.example", since: dAgo(2240), lane: "İzmir → Charleston", terms: "Named account · contract of affreightment" },
  { id: "ferrymead-automotive", name: "Ferrymead Automotive", contact: "Dale Okonkwo", email: "d.okonkwo@ferrymeadauto.example", since: dAgo(3100), lane: "Bremerhaven → Jacksonville", terms: "Named account · contract of affreightment" },
  { id: "larkspur-wine-imports", name: "Larkspur Wine Imports", contact: "Margaux Pell", email: "m.pell@larkspurwine.example", since: dAgo(870), lane: "Sète → Baltimore", terms: "Spot booking · bill of lading terms" },
  { id: "ostend-chemicals", name: "Ostend Chemicals", contact: "Joris Vandael", email: "j.vandael@ostendchem.example", since: dAgo(1720), lane: "Zeebrugge → Savannah", terms: "Named account · dangerous goods addendum" },
  { id: "halvard-steel", name: "Halvard Steel", contact: "Nils Halvard", email: "n.halvard@halvardsteel.example", since: dAgo(3400), lane: "Rotterdam → Mobile", terms: "Named account · contract of affreightment" },
  { id: "marlowe-furniture", name: "Marlowe Furniture", contact: "Piotr Marlowe", email: "p.marlowe@marlowefurniture.example", since: dAgo(520), lane: "Gdańsk → Norfolk", terms: "Spot booking · bill of lading terms" },
];

/* Notifications. Every one names a record and agrees with it at the timestamp
   it carries; `kind` is a value of ALERT_KINDS, so the alerts a person chooses
   in settings and the things this desk actually raises are one vocabulary. */
const NOTIFICATIONS = [
  { id: "ntf_9", kind: "documents", title: "Surveyor's report rejected as illegible", body: "CLM-26-0179 · Aurelian Tile Imports — pages 3–7 unreadable", at: dAgo(0.25), route: "/claims/CLM-26-0179/evidence" },
  { id: "ntf_8", kind: "signoff", title: "Sign-off still outstanding after 11 days", body: "CLM-26-0207 · Ferrymead Automotive — with Roland Achebe", at: dAgo(0.5), route: "/signoff" },
  { id: "ntf_7", kind: "time_bar", title: "Time bar inside 60 days", body: "CLM-25-0977 · Vosges Cold Chain — with legal since 74 days ago", at: dAgo(0.85), route: "/claims/CLM-25-0977" },
  { id: "ntf_6", kind: "payment", title: "Payment returned by the beneficiary bank", body: "CLM-25-0929 · Vollmer Interiors — IBAN rejected, $25,600.00 to reschedule", at: dAgo(4), route: "/payments" },
  { id: "ntf_5", kind: "recovery", title: "Meridian Terminal Services acknowledged the notice", body: "REC-26-0038 · liability under review by their insurer", at: dAgo(5), route: "/recovery/REC-26-0038" },
  { id: "ntf_4", kind: "documents", title: "Packing list still outstanding after two requests", body: "CLM-26-0212 · Kettleworth Brewing — last chased 6 days ago", at: dAgo(6), route: "/claims/CLM-26-0212/evidence" },
  { id: "ntf_3", kind: "response", title: "Customer disputed our offer", body: "CLM-25-0913 · Ferrymead Automotive holds us to $210,400.00", at: dAgo(12), route: "/responses" },
  { id: "ntf_2", kind: "time_bar", title: "Inside 90 days of the bar with payment unsent", body: "CLM-26-0131 · Pallas Glassworks — scheduled, not yet released", at: dAgo(16), route: "/claims/CLM-26-0131" },
  { id: "ntf_1", kind: "recovery", title: "Counterparty offered below the surveyed loss", body: "REC-26-0022 · Meridian Terminal Services offered $34,000.00 of $61,400.00", at: dAgo(20), route: "/recovery/REC-26-0022" },
];
/* What has already been read when the desk is opened — anything older than the
   last working day. The unread count everywhere derives from this one list. */
const NOTIFICATIONS_READ = ["ntf_1", "ntf_2", "ntf_3", "ntf_4"];

Object.assign(window, { CLAIMS_NOW, CLAIMS_USER, CLAIMS_MANAGER, CLAIMS_CARRIER, CLAIMS, CLAIMANTS, RECOVERIES, NOTIFICATIONS, NOTIFICATIONS_READ });
