/* Canton Fair Team Guide — same design family as the Vanuatu guide (sage chrome, Barlow),
   with a vermilion accent. Mobile-first: phone = bottom nav, laptop = sidebar. No external requests
   (fonts, maps and charts are self-hosted so it still loads behind China's firewall). */

:root {
  --chrome: #C8E4CA;
  --chrome-ink: #12352b;
  --chrome-line: #a9cdb0;
  --page: #f4efe4;
  --panel: #fffdf8;
  --card: #ffffff;
  --ink: #1f2a33;
  --muted: #5b6670;
  --line: #ddd7c8;
  --line-soft: #efe9dc;
  --accent: #b4372b;
  --accent-ink: #ffffff;
  --accent-soft: #f9e6e2;
  --blue: #496275;
  --blue-soft: #e6edf2;
  --good: #2f7d4f;
  --good-soft: #e3f2e8;
  --warn: #a86a12;
  --warn-soft: #fbf0d9;
  --bad: #a33a3a;
  --radius: 12px;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.55 "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--page);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  -webkit-text-size-adjust: 100%;
}
button, select, input, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3, h4 { font-family: var(--cond); font-weight: 700; letter-spacing: .01em; margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 30px; } h2 { font-size: 24px; } h3 { font-size: 19px; } h4 { font-size: 16px; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.stack > * + * { margin-top: 10px; }
.mt { margin-top: 14px; } .mt0 { margin-top: 0 !important; }

/* ---------- top bar ---------- */
.top {
  background: var(--chrome); color: var(--chrome-ink); display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-bottom: 1px solid var(--chrome-line); position: relative; z-index: 30;
}
.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; min-width: 0; }
.brand b { font: 700 24px/1 var(--cond); text-transform: uppercase; letter-spacing: .03em; color: var(--accent); }
.brand span { font-size: 12.5px; opacity: .8; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.burger { display: none; border: 1px solid var(--chrome-line); background: #f4faf4; border-radius: 8px; padding: 4px 10px; font-size: 18px; cursor: pointer; }
.pill { border: 1px solid var(--chrome-line); background: #f4faf4; border-radius: 999px; padding: 4px 11px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.pill.ok { color: var(--good); } .pill.wait { color: var(--warn); } .pill.off { color: var(--bad); }
.me { display: flex; align-items: center; gap: 6px; border: 1px solid var(--chrome-line); background: #f4faf4; border-radius: 999px; padding: 3px 12px 3px 4px; cursor: pointer; font-weight: 600; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 0; }
.side { background: var(--chrome); border-right: 1px solid var(--chrome-line); overflow-y: auto; padding: 10px 8px 24px; }
.side h5 { font: 700 12px/1 var(--cond); letter-spacing: .12em; text-transform: uppercase; color: #3e6a55; margin: 16px 10px 6px; }
.side a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; color: var(--chrome-ink); text-decoration: none; font-weight: 500; }
.side a:hover { background: #b6d9b9; }
.side a.on { background: var(--chrome-ink); color: #fff; }
.side a .n { margin-left: auto; font-size: 11.5px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 7px; min-width: 20px; text-align: center; }
.side a .ic { width: 22px; text-align: center; }
.main { overflow-y: auto; padding: 18px 20px 60px; min-width: 0; scroll-behavior: smooth; }
.main > .view { max-width: 1180px; margin: 0 auto; }

.bottom { display: none; }

/* ---------- cards / layout ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card.flat { background: var(--panel); }
.card h3 { margin-bottom: 6px; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gauto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi b { display: block; font: 700 30px/1.05 var(--cond); color: var(--accent); }
.kpi span { font-size: 12.5px; color: var(--muted); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.head h1, .head h2 { margin: 0; }
.head p { margin: 2px 0 0; color: var(--muted); }
.callout { border-left: 4px solid var(--blue); background: var(--blue-soft); border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.bad { border-color: var(--bad); background: #f8e6e6; }
.callout.good { border-color: var(--good); background: var(--good-soft); }

/* ---------- controls ---------- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--line-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #e2b8b8; }
.btn.sm { padding: 4px 10px; font-size: 13px; font-weight: 500; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: block; margin: 0 0 10px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=url], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; min-height: 40px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #e8b3ab; border-color: var(--accent); }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; background: var(--blue-soft); color: var(--blue); margin: 1px 3px 1px 0; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: #f8e6e6; color: var(--bad); }
.tag.red { background: var(--accent-soft); color: var(--accent); }
.badge-v { font-size: 11px; font-weight: 700; border-radius: 4px; padding: 0 5px; margin-right: 5px; }
.badge-v.ok { background: var(--good-soft); color: var(--good); }
.badge-v.un { background: var(--warn-soft); color: var(--warn); }

.av { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font: 700 12px var(--cond); color: #fff; flex: none; }
.av.lg { width: 38px; height: 38px; font-size: 16px; }

/* ---------- tables / lists ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font: 700 12.5px var(--cond); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--line); padding: 6px 8px; }
table.tbl td { border-bottom: 1px solid var(--line-soft); padding: 7px 8px; vertical-align: top; }
.tblwrap { overflow-x: auto; }
.list > .item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line-soft); }
.item.click { cursor: pointer; }
.item.click:hover { background: #fbf7ee; }
.sup { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer; }
.sup:hover { border-color: var(--accent); }
.sup .logo { width: 46px; height: 46px; border-radius: 8px; background: var(--line-soft); object-fit: contain; flex: none; display: flex; align-items: center; justify-content: center; font: 700 18px var(--cond); color: var(--muted); }
.sup h4 { margin: 0; }
.stars { color: #e0a01a; letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: #ddd; }
.status { border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }

/* ---------- photos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; background: var(--line-soft); display: block; }
.photos figcaption { font-size: 11.5px; color: var(--muted); }
.photos .wait { position: absolute; top: 4px; left: 4px; background: var(--warn); color: #fff; border-radius: 4px; font-size: 10px; padding: 0 5px; }

/* ---------- timeline / chat ---------- */
.tl > div { border-left: 3px solid var(--line); padding: 2px 0 12px 12px; margin-left: 6px; position: relative; }
.tl > div::before { content: ""; position: absolute; left: -7px; top: 6px; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; max-width: 760px; }
.msg .bub { background: #fff; border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 7px 12px; min-width: 0; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .bub { background: var(--accent-soft); border-color: #eec9c3; border-radius: 14px 4px 14px 14px; }
.msg.pinned .bub { border-color: var(--warn); background: var(--warn-soft); }
.msg .who { font-size: 12px; color: var(--muted); }
.msg img { max-width: 240px; border-radius: 8px; display: block; margin-top: 4px; }
.mention { background: #ffe9a8; border-radius: 4px; padding: 0 3px; font-weight: 600; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 30, 36, .55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 620px; padding: 18px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal.wide { max-width: 900px; }
.modal h3 { font-size: 22px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%) translateY(20px); background: #1f2a33; color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.fab { position: fixed; right: 18px; bottom: 22px; z-index: 40; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(180, 55, 43, .45); cursor: pointer; }

/* ---------- accordion (guide sections) ---------- */
details.acc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; }
details.acc > summary { cursor: pointer; padding: 10px 14px; font: 700 18px var(--cond); list-style: none; display: flex; align-items: center; gap: 8px; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::before { content: "▸"; color: var(--accent); transition: .15s; }
details.acc[open] > summary::before { transform: rotate(90deg); }
details.acc > .body { padding: 2px 16px 12px; }
.facts { list-style: none; padding: 0; margin: 0; }
.facts li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.facts li:last-child { border: 0; }
.facts a.src { font-size: 12px; margin-left: 4px; }

/* ---------- maps ---------- */
.mapbox { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #dfe9ee; }
svg.plan { width: 100%; height: auto; background: #fbf8f0; border: 1px solid var(--line); border-radius: var(--radius); }
svg.plan text { font-family: "Barlow", sans-serif; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  body { grid-template-rows: auto minmax(0, 1fr) auto; }
  .top { gap: 6px; padding: 6px 10px; min-width: 0; }
  .brand b { font-size: 20px; }
  .me span.small { display: none; }
  .me { padding: 3px; }
  .pill { padding: 3px 8px; font-size: 12px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .burger { display: block; }
  .brand span { display: none; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: fixed; z-index: 60; inset: 48px 0 0 0; padding-bottom: 90px; }
  .side.open { display: block; }
  .main { padding: 14px 14px 90px; }
  .bottom { display: flex; background: var(--chrome); border-top: 1px solid var(--chrome-line); padding-bottom: var(--safe-b); z-index: 50; }
  .bottom a { flex: 1; text-align: center; padding: 6px 2px 5px; color: var(--chrome-ink); text-decoration: none; font-size: 11.5px; position: relative; }
  .bottom a .ic { display: block; font-size: 20px; line-height: 1.1; }
  .bottom a.on { color: var(--accent); font-weight: 700; }
  .bottom a .n { position: absolute; top: 2px; left: 55%; background: var(--accent); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 0 5px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fgrid { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 26px; }
  .fab { bottom: calc(74px + var(--safe-b)); }
  .toast { bottom: calc(86px + var(--safe-b)); }
  .mapbox { height: 420px; }
}
@media (max-width: 520px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .kpis.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media print {
  .top, .side, .bottom, .fab, .btn, .toast { display: none !important; }
  body { display: block; background: #fff; }
  .main { overflow: visible; padding: 0; }
}

.stickybar { position: sticky; bottom: 0; z-index: 20; display: flex; gap: 12px; align-items: center; background: #fffdf8; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-top: 14px; box-shadow: 0 -4px 18px rgba(0,0,0,.10); }
@media (max-width: 860px) { .stickybar { bottom: 8px; flex-wrap: wrap; } .stickybar .btn { width: 100%; justify-content: center; } }

/* ---------- calendar ---------- */
.cal-grid { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-hr { border-top: 1px solid var(--line-soft); position: relative; cursor: pointer; }
.cal-hr:first-child { border-top: 0; }
.cal-hr:hover { background: #fbf7ee; }
.cal-hr span { position: absolute; left: 8px; top: 2px; font-size: 11.5px; color: var(--muted); }
.cal-blk { position: absolute; border-radius: 8px; padding: 3px 7px; font-size: 12.5px; line-height: 1.25; overflow: hidden; cursor: pointer; z-index: 2; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.cal-blk .av { width: 18px; height: 18px; font-size: 10px; }
.cal-task { position: absolute; left: 58px; right: 8px; background: #fff6d6; border: 1px dashed #d9b84a; border-radius: 6px; padding: 1px 8px; font-size: 12px; z-index: 3; cursor: pointer; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: #d21f2b; z-index: 4; }
.cal-ev { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; margin: 3px 0; cursor: pointer; font-size: 13px; }
.cal-ev .av { width: 18px; height: 18px; font-size: 10px; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-day { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-height: 150px; cursor: pointer; }
.cal-day.today, .cal-mc.today { outline: 2px solid var(--accent); }
.cal-dh { margin-bottom: 4px; }
.cal-month .cal-mh { display: grid; grid-template-columns: repeat(7, 1fr); font: 700 12px var(--cond); text-transform: uppercase; color: var(--muted); text-align: center; margin-bottom: 4px; }
.cal-mg { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-mc { background: #fff; border: 1px solid var(--line-soft); border-radius: 8px; min-height: 84px; padding: 4px; cursor: pointer; overflow: hidden; }
.cal-mc.empty { background: transparent; border: 0; cursor: default; }
.cal-dot { color: #fff; border-radius: 4px; font-size: 11px; padding: 0 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) {
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .cal-day { min-height: 0; }
  .cal-mc { min-height: 58px; }
  .cal-dot { font-size: 10px; }
}

/* ---------- pipeline board ---------- */
.pl-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }
.pl-col { background: #f1ede2; border-radius: 12px; padding: 8px; min-height: 240px; scroll-snap-align: start; }
.pl-head { background: #fff; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.pl-head .btn { margin-left: auto; }
.pl-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; cursor: grab; }
.pl-card:hover { border-color: var(--accent); }
.pl-card .av { width: 22px; height: 22px; font-size: 11px; }
