/* ============================================================
   CH Service Hub — TikTok Shop customer service workspace demo
   Design tokens + layout + components
   ============================================================ */

:root {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f4f6fa;
  --border: #e4e8f0;
  --border-2: #edf0f6;
  --text: #101828;
  --text-2: #475467;
  --text-3: #8a94a6;
  --text-4: #aab2c0;
  --brand: #335cff;
  --brand-2: #2748d8;
  --brand-soft: #eef2ff;
  --brand-border: #dbe3ff;
  --tiktok: #fe2c55;
  --cyan: #00c2b8;
  --green: #0e9f6e;
  --green-soft: #e7f7f0;
  --amber: #d97706;
  --amber-soft: #fef4e6;
  --red: #e02424;
  --red-soft: #feecec;
  --purple: #7c3aed;
  --purple-soft: #f3eeff;
  --rail: #0d1322;
  --rail-2: #161d30;
  --rail-text: #93a0b8;
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 16px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI",
    "PingFang SC", "Hiragino Sans", "Microsoft YaHei", "Noto Sans", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d3dae6; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9c3d3; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; vertical-align: -3px; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-rows: 58px 1fr 26px;
  height: 100vh;
  width: 100vw;
  background: var(--surface);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 4px 10px rgba(51, 92, 255, 0.3); }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.brand-sub { font-size: 10.5px; color: var(--text-3); letter-spacing: 0.01em; }
.tiktok-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 20px; font-size: 10.5px; font-weight: 600;
  color: #111; background: #f1f3f8; border: 1px solid var(--border);
}
.tiktok-pill .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--tiktok); box-shadow: 0 0 0 2px rgba(254, 44, 85, 0.16); }

.topsearch {
  flex: 1; max-width: 560px; position: relative;
}
.topsearch .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.topsearch input {
  width: 100%; height: 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-3); padding: 0 12px 0 36px; outline: none; color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.topsearch input::placeholder { color: var(--text-4); }
.topsearch input:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(51, 92, 255, .12); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.webhook-pill {
  display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px;
  border-radius: 20px; background: var(--green-soft); color: #0a7c56;
  font-size: 11.5px; font-weight: 600; border: 1px solid #c9ecdd;
}
.webhook-pill .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(14, 159, 110, .5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(14,159,110,.45);} 70% { box-shadow: 0 0 0 6px rgba(14,159,110,0);} 100% { box-shadow: 0 0 0 0 rgba(14,159,110,0);} }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-border); }
.icon-btn .ico { width: 19px; height: 19px; }

.lang-toggle { display: flex; align-items: center; background: var(--surface-3); border-radius: 9px; padding: 2px; border: 1px solid var(--border); }
.lang-toggle button {
  border: 0; background: transparent; padding: 5px 9px; border-radius: 7px; cursor: pointer;
  font-size: 11.5px; font-weight: 600; color: var(--text-3); transition: all .12s;
}
.lang-toggle button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

.agent-chip { display: flex; align-items: center; gap: 8px; padding: 3px 9px 3px 3px; border-radius: 20px; border: 1px solid var(--border); cursor: pointer; background: #fff; }
.agent-chip:hover { background: var(--surface-2); }
.agent-meta { line-height: 1.2; }
.agent-meta .name { font-size: 12px; font-weight: 600; }
.agent-meta .status { font-size: 10.5px; color: var(--green); display: flex; align-items: center; gap: 4px; }
.agent-meta .status .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }

/* ---------- Workspace grid ---------- */
.workspace {
  display: grid;
  grid-template-columns: 68px 344px minmax(0, 1fr) 388px;
  min-height: 0;
  overflow: hidden;
}
.workspace.full { grid-template-columns: 68px minmax(0, 1fr); }

/* ---------- Left rail ---------- */
.rail {
  background: var(--rail);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0 10px; gap: 6px; position: relative; z-index: 20;
}
.rail-logo { width: 34px; height: 34px; margin-bottom: 8px; border-radius: 10px; cursor: pointer; }
.rail-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent;
  color: var(--rail-text); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; position: relative; transition: background .12s, color .12s;
}
.rail-btn .ico { width: 20px; height: 20px; }
.rail-btn .lbl { font-size: 8.5px; letter-spacing: .01em; opacity: .85; }
.rail-btn:hover { background: rgba(255,255,255,.07); color: #e7ecf7; }
.rail-btn.active { background: rgba(255,255,255,.11); color: #fff; }
.rail-btn.active::before {
  content: ""; position: absolute; left: -12px; top: 12px; bottom: 12px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.rail-badge {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 8px; background: var(--tiktok); color: #fff; font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--rail);
}
.rail-spacer { flex: 1; }
.rail-avatar { margin-top: 6px; }

/* ---------- Conversation list ---------- */
.convlist {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.convlist-head { padding: 14px 14px 10px; }
.convlist-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.convlist-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.convlist-title .count { font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--surface-3); border: 1px solid var(--border); padding: 1px 7px; border-radius: 10px; }
.btn-new { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text-2); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-new:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.listsearch { position: relative; margin-bottom: 10px; }
.listsearch .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-3); }
.listsearch input {
  width: 100%; height: 32px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; padding: 0 10px 0 32px; outline: none;
}
.listsearch input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(51,92,255,.1); }

.tabs { display: flex; gap: 2px; background: var(--surface-3); border-radius: 9px; padding: 2px; border: 1px solid var(--border); }
.tabs button {
  flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 5px 4px;
  font-size: 11.5px; font-weight: 600; color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px; transition: all .12s;
}
.tabs button .n { font-size: 10px; background: #e7ebf4; color: var(--text-2); border-radius: 8px; padding: 0 5px; min-width: 16px; }
.tabs button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }
.tabs button.active .n { background: var(--brand-soft); color: var(--brand); }

.list-filter-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.chip-select {
  display: inline-flex; align-items: center; gap: 6px; height: 27px; padding: 0 9px;
  border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 11.5px;
  font-weight: 500; color: var(--text-2); cursor: pointer;
}
.chip-select .ico { width: 14px; height: 14px; color: var(--text-3); }
.chip-select:hover { border-color: #cfd7e6; }

.conv-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.conv-item {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px;
  padding: 11px 10px; border-radius: 11px; cursor: pointer; position: relative;
  border: 1px solid transparent; margin-bottom: 2px; transition: background .12s, border-color .12s;
}
.conv-item:hover { background: #fff; border-color: var(--border); }
.conv-item.active { background: #fff; border-color: var(--brand-border); box-shadow: 0 2px 8px rgba(51,92,255,.07); }
.conv-item.active::before {
  content: ""; position: absolute; left: -8px; top: 14px; bottom: 14px; width: 3px;
  background: var(--brand); border-radius: 3px;
}
.conv-item.unread .conv-name { font-weight: 700; }
.conv-item.unread .conv-snippet { color: var(--text-2); font-weight: 500; }
.conv-avatar { position: relative; }
.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; letter-spacing: .02em; flex: 0 0 auto;
  width: 38px; height: 38px; font-size: 13px; position: relative;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.xs { width: 24px; height: 24px; font-size: 9.5px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar .flag-badge {
  position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 1px solid var(--border); font-size: 9px; display: flex;
  align-items: center; justify-content: center;
}
.conv-main { min-width: 0; }
.conv-row1 { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.conv-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.conv-flag { font-size: 11px; }
.conv-shop { font-size: 10px; color: var(--text-3); background: var(--surface-3); border-radius: 4px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 84px; }
.conv-snippet { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-snippet .preview-type { color: var(--text-2); font-weight: 500; }
.conv-row2 { display: flex; align-items: center; gap: 5px; margin-top: 4px; }
.conv-tag { font-size: 10px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border-2); }
.conv-tag.high { background: var(--red-soft); color: #b42318; border-color: #fbd5d5; }
.conv-tag.resolved { background: var(--green-soft); color: #087443; border-color: #cdeee0; }
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.conv-time { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.unread-badge { min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.conv-item.unread .unread-badge { background: var(--tiktok); }

/* ---------- Thread ---------- */
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f7f8fb; }
.thread-head {
  height: 72px; flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 0 18px;
  background: #fff; border-bottom: 1px solid var(--border); position: relative; z-index: 10;
}
.thread-head-main { min-width: 0; flex: 1; }
.thread-name-row { display: flex; align-items: center; gap: 8px; }
.thread-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.thread-sub { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: 11px; color: var(--text-3); }
.thread-sub .sep { width: 1px; height: 10px; background: var(--border); }
.thread-sub .mono { font-family: var(--mono); font-size: 10.5px; color: var(--text-2); }
.thread-actions { display: flex; align-items: center; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border);
  background: #fff; color: var(--text-2); font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: all .12s;
}
.btn:hover { border-color: #cfd7e6; background: var(--surface-2); color: var(--text); }
.btn .ico { width: 15px; height: 15px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 2px 6px rgba(51,92,255,.25); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 11.5px; border-radius: 8px; }
.btn.danger { color: var(--red); border-color: #f6d0d0; background: #fff; }
.btn.danger:hover { background: var(--red-soft); border-color: #f0bbbb; }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { background: #0b8a5f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }

.thread-scroll { flex: 1; overflow-y: auto; padding: 18px 26px 26px; min-height: 0; scroll-behavior: smooth; }
.thread-intro {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 22px;
  color: var(--text-3); font-size: 11.5px; text-align: center;
}
.thread-intro .pill { background: #fff; border: 1px solid var(--border); border-radius: 20px; padding: 5px 12px; display: flex; align-items: center; gap: 6px; }
.thread-intro .pill .ico { width: 14px; height: 14px; }

.date-sep { display: flex; align-items: center; gap: 12px; margin: 16px 0 18px; color: var(--text-3); font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.date-sep::before, .date-sep::after { content: ""; flex: 1; height: 1px; background: #e7eaf1; }

.msg-row { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-end; max-width: 640px; }
.msg-row.buyer { flex-direction: row; }
.msg-row.agent { flex-direction: row-reverse; margin-left: auto; }
.msg-row .avatar { align-self: flex-end; }
.msg-body { min-width: 0; display: flex; flex-direction: column; }
.msg-row.agent .msg-body { align-items: flex-end; }
.msg-sender { font-size: 10.5px; color: var(--text-3); margin: 0 4px 4px; display: flex; align-items: center; gap: 6px; }
.msg-sender .role-chip { font-size: 9.5px; padding: 0 5px; border-radius: 4px; background: #eef1f6; color: var(--text-2); font-weight: 600; letter-spacing: .01em; }
.msg-sender .role-chip.agent { background: var(--brand-soft); color: var(--brand); }
.bubble {
  border-radius: 14px; padding: 9px 13px; background: #fff; border: 1px solid var(--border);
  box-shadow: var(--shadow-xs); color: var(--text); font-size: 13px; line-height: 1.5;
  max-width: 520px; overflow-wrap: anywhere; white-space: normal;
}
.msg-row.agent .bubble { background: var(--brand-soft); border-color: var(--brand-border); border-bottom-right-radius: 5px; }
.msg-row.buyer .bubble { border-bottom-left-radius: 5px; }
.bubble.card-bubble { padding: 0; background: transparent; border: 0; box-shadow: none; max-width: 348px; }
.msg-meta { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--text-3); margin: 4px 4px 0; }
.msg-meta .ico { width: 13px; height: 13px; }
.msg-meta .read { color: var(--brand); display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.msg-meta .read .ico { width: 13px; height: 13px; }

.translation {
  margin-top: 6px; padding-top: 6px; border-top: 1px dashed #d8ddea;
  font-size: 11.5px; color: var(--text-2); display: flex; gap: 6px; align-items: flex-start;
}
.translation .ico { width: 13px; height: 13px; margin-top: 2px; color: var(--text-3); }
.translation .label { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; white-space: nowrap; padding-top: 1px; }

.system-row { display: flex; justify-content: center; margin: 12px 0; }
.system-pill {
  display: inline-flex; align-items: center; gap: 7px; background: #eef1f6; color: var(--text-2);
  border-radius: 20px; padding: 5px 12px; font-size: 11px; border: 1px solid #e4e8f0; max-width: 560px;
}
.system-pill .ico { width: 13px; height: 13px; color: var(--text-3); }
.system-pill.robot { background: var(--purple-soft); border-color: #e3d8ff; color: #5b21b6; }
.system-pill.robot .ico { color: #7c3aed; }

/* ---------- Message cards ---------- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-sm); width: 340px; max-width: 100%;
}
.card-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px 8px; }
.card-top .card-title { font-size: 11.5px; font-weight: 700; letter-spacing: .01em; display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.card-top .card-title .ico { width: 14px; height: 14px; color: var(--text-3); }
.card-top .card-link { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--brand); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.card-body { padding: 0 12px 12px; }
.card-product { display: flex; gap: 10px; align-items: center; }
.card-product img, .card-product .ph { width: 52px; height: 52px; border-radius: 9px; background: var(--surface-3); object-fit: cover; border: 1px solid var(--border-2); }
.card-product .p-title { font-size: 12px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-product .p-meta { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.card-price-row { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; }
.card-price { font-size: 14px; font-weight: 700; color: var(--text); }
.card-price-old { font-size: 11px; color: var(--text-4); text-decoration: line-through; }
.card-divider { height: 1px; background: var(--border-2); margin: 10px 0; }
.card-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; margin-top: 5px; }
.card-kv .k { color: var(--text-3); }
.card-kv .v { color: var(--text-2); font-weight: 600; text-align: right; }
.card-kv .v.mono { font-family: var(--mono); font-size: 10.5px; }
.card-items { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.card-item { display: flex; gap: 8px; align-items: center; }
.card-item img { width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--border-2); object-fit: cover; }
.card-item .i-name { font-size: 11.5px; font-weight: 600; line-height: 1.3; }
.card-item .i-meta { font-size: 10.5px; color: var(--text-3); }
.card-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--surface-2); border-top: 1px solid var(--border-2); font-size: 10.5px; color: var(--text-3); }
.status-chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 6px; letter-spacing: .01em;
}
.status-chip .dot { width: 5px; height: 5px; border-radius: 50%; }
.status-chip.green { background: var(--green-soft); color: #087443; }
.status-chip.green .dot { background: var(--green); }
.status-chip.blue { background: var(--brand-soft); color: var(--brand-2); }
.status-chip.blue .dot { background: var(--brand); }
.status-chip.amber { background: var(--amber-soft); color: #b45309; }
.status-chip.amber .dot { background: var(--amber); }
.status-chip.red { background: var(--red-soft); color: #b42318; }
.status-chip.red .dot { background: var(--red); }
.status-chip.gray { background: #eef1f6; color: var(--text-2); }
.status-chip.gray .dot { background: var(--text-3); }

.card-image img { width: 100%; display: block; border-radius: 10px; }
.card-image { overflow: hidden; border-radius: 12px; border: 1px solid var(--border); background: #fff; cursor: zoom-in; width: 260px; box-shadow: var(--shadow-sm); }
.card-image .img-meta { padding: 6px 10px; font-size: 10px; color: var(--text-3); border-top: 1px solid var(--border-2); display: flex; justify-content: space-between; }
.video-card { position: relative; width: 270px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); cursor: pointer; box-shadow: var(--shadow-sm); background: #111; }
.video-card img { width: 100%; display: block; opacity: .92; }
.video-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.video-play .circle {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.92);
  display: flex; align-items: center; justify-content: center; color: #111;
  box-shadow: 0 6px 18px rgba(0,0,0,.3);
}
.video-play .circle .ico { width: 18px; height: 18px; margin-left: 2px; }
.video-duration { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.72); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 5px; font-weight: 600; }
.video-card .v-label { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 9.5px; padding: 1px 6px; border-radius: 5px; }

.coupon-card { width: 320px; border-radius: 12px; border: 1px solid #f3d6a8; background: linear-gradient(135deg, #fffaf1, #fff3df); overflow: hidden; box-shadow: var(--shadow-sm); }
.coupon-main { display: flex; align-items: stretch; }
.coupon-amount { padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; min-width: 96px; border-right: 1px dashed #edcf9f; }
.coupon-amount .big { font-size: 20px; font-weight: 800; color: #b45309; letter-spacing: -.02em; }
.coupon-amount .small { font-size: 9.5px; color: #b07a3e; font-weight: 600; }
.coupon-info { padding: 10px 12px; flex: 1; }
.coupon-info .c-title { font-size: 12px; font-weight: 700; color: #7c3f00; }
.coupon-info .c-sub { font-size: 10.5px; color: #a9762f; margin-top: 2px; }
.coupon-info .c-scope { font-size: 9.5px; color: #b5894f; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.coupon-foot { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; border-top: 1px dashed #edcf9f; font-size: 9.5px; color: #a9762f; }
.ticket-dash { position: relative; }
.ticket-dash::before, .ticket-dash::after {
  content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #f7f8fb; border: 1px solid #f3d6a8;
}
.ticket-dash::before { left: -6px; top: -7px; }
.ticket-dash::after { right: -6px; top: -7px; }

.return-card { width: 340px; border-radius: 12px; border: 1px solid var(--border); background: #fff; overflow: hidden; box-shadow: var(--shadow-sm); }
.return-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--red-soft); border-bottom: 1px solid #fbdada; }
.return-head .ico { width: 15px; height: 15px; color: var(--red); }
.return-head .t { font-size: 11.5px; font-weight: 700; color: #b42318; }
.return-head .status-chip { margin-left: auto; }
.return-body { padding: 10px 12px 12px; }
.return-evidence { display: flex; gap: 8px; margin-top: 8px; }
.return-evidence img { width: 56px; height: 44px; border-radius: 7px; object-fit: cover; border: 1px solid var(--border-2); }

/* ---------- Composer ---------- */
.composer-wrap { flex: 0 0 auto; background: #fff; border-top: 1px solid var(--border); padding: 10px 16px 12px; }
.quick-replies { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.quick-replies::-webkit-scrollbar { display: none; }
.qr-chip {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  border-radius: 20px; padding: 4px 10px; font-size: 11px; cursor: pointer; display: flex; align-items: center; gap: 5px;
}
.qr-chip:hover { border-color: var(--brand-border); background: var(--brand-soft); color: var(--brand-2); }
.qr-chip .ico { width: 12px; height: 12px; }
.composer {
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s; overflow: hidden;
}
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(51,92,255,.1); background: #fff; }
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none; outline: none;
  padding: 11px 13px 4px; min-height: 42px; max-height: 120px; line-height: 1.5; font-size: 13px;
}
.composer textarea::placeholder { color: var(--text-4); }
.composer-bar { display: flex; align-items: center; gap: 2px; padding: 4px 8px 7px; }
.tool-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent;
  color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-btn .ico { width: 17px; height: 17px; }
.composer-spacer { flex: 1; }
.char-count { font-size: 10.5px; color: var(--text-4); font-variant-numeric: tabular-nums; margin-right: 8px; }
.char-count.warn { color: var(--amber); }
.send-btn { height: 32px; padding: 0 14px; border-radius: 9px; border: 0; background: var(--brand); color: #fff; font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; box-shadow: 0 2px 8px rgba(51,92,255,.3); }
.send-btn:hover { background: var(--brand-2); }
.send-btn:disabled { opacity: .4; box-shadow: none; cursor: not-allowed; }
.composer-hint { font-size: 10.5px; color: var(--text-4); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.composer-hint .ico { width: 12px; height: 12px; }

/* ---------- Context panel ---------- */
.context { background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.context-tabs { display: flex; gap: 0; padding: 0 10px; border-bottom: 1px solid var(--border); background: #fff; flex: 0 0 auto; }
.context-tab {
  flex: 1; border: 0; background: transparent; padding: 12px 2px 10px; font-size: 11.5px;
  font-weight: 600; color: var(--text-3); cursor: pointer; position: relative; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.context-tab .badge { font-size: 9px; background: var(--red-soft); color: var(--red); border-radius: 7px; padding: 0 5px; font-weight: 700; }
.context-tab:hover { color: var(--text); }
.context-tab.active { color: var(--brand); }
.context-tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px 2px 0 0; }
.context-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 20px; min-height: 0; }
.context-section { margin-bottom: 16px; }
.context-title { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.context-title .ico { width: 13px; height: 13px; }
.panel { border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: var(--shadow-xs); overflow: hidden; }
.panel-pad { padding: 12px; }
.kv-list { display: flex; flex-direction: column; gap: 7px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; align-items: flex-start; }
.kv-row .k { color: var(--text-3); white-space: nowrap; }
.kv-row .v { color: var(--text); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.kv-row .v.mono { font-family: var(--mono); font-size: 10.5px; font-weight: 500; color: var(--text-2); }
.kv-row .v .copy-btn { border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 0 0 0 4px; }
.kv-row .v .copy-btn:hover { color: var(--brand); }
.order-panel-head { padding: 12px; border-bottom: 1px solid var(--border-2); background: var(--surface-2); display: flex; align-items: center; gap: 10px; }
.order-panel-head .t { font-size: 12px; font-weight: 700; }
.order-panel-head .sub { font-size: 10.5px; color: var(--text-3); margin-top: 1px; font-family: var(--mono); }
.order-panel-head .status-chip { margin-left: auto; }
.c-item-row { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border-2); align-items: center; }
.c-item-row:last-child { border-bottom: 0; }
.c-item-row img { width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--border-2); object-fit: cover; }
.c-item-row .ci-main { flex: 1; min-width: 0; }
.c-item-row .ci-name { font-size: 11.5px; font-weight: 600; line-height: 1.3; }
.c-item-row .ci-meta { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.c-item-row .ci-price { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.panel-actions { display: flex; gap: 7px; padding: 10px 12px; border-top: 1px solid var(--border-2); background: var(--surface-2); flex-wrap: wrap; }
.panel-actions .btn { flex: 1; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 8px; width: 2px; background: #e7eaf1; }
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -16px; top: 4px; width: 8px; height: 8px; border-radius: 50%;
  background: #cfd7e6; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #cfd7e6;
}
.tl-item.current::before { background: var(--brand); box-shadow: 0 0 0 1.5px var(--brand); }
.tl-desc { font-size: 11.5px; font-weight: 600; line-height: 1.35; }
.tl-item.current .tl-desc { color: var(--brand-2); }
.tl-time { font-size: 10px; color: var(--text-3); margin-top: 2px; }

.after-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 10px; box-shadow: var(--shadow-xs); }
.after-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border-2); }
.after-head .title { font-size: 11.5px; font-weight: 700; }
.after-head .status-chip { margin-left: auto; }
.after-body { padding: 10px 12px; }
.eligibility {
  display: flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 9px;
  background: var(--green-soft); color: #087443; font-size: 11px; font-weight: 600; border: 1px solid #cdeee0;
}
.eligibility.warn { background: var(--amber-soft); color: #b45309; border-color: #f5deb6; }
.eligibility .ico { width: 14px; height: 14px; }
.evidence-strip { display: flex; gap: 6px; margin-top: 8px; }
.evidence-strip img { width: 62px; height: 48px; border-radius: 8px; border: 1px solid var(--border-2); object-fit: cover; cursor: zoom-in; }
.muted-note { font-size: 10.5px; color: var(--text-3); line-height: 1.45; }

.coupon-panel-item { border: 1px solid #f3d6a8; background: linear-gradient(135deg, #fffaf1, #fff3df); border-radius: 11px; padding: 10px 12px; margin-bottom: 9px; }
.coupon-panel-item .row { display: flex; align-items: center; gap: 10px; }
.coupon-panel-item .amount { font-size: 18px; font-weight: 800; color: #b45309; letter-spacing: -.02em; min-width: 66px; }
.coupon-panel-item .info { flex: 1; min-width: 0; }
.coupon-panel-item .title { font-size: 11.5px; font-weight: 700; color: #7c3f00; }
.coupon-panel-item .sub { font-size: 10px; color: #a9762f; margin-top: 1px; }
.coupon-panel-item .valid { font-size: 9.5px; color: #b5894f; margin-top: 3px; }
.coupon-panel-item .btn { margin-top: 8px; width: 100%; }

.buyer-hero { display: flex; align-items: center; gap: 12px; padding: 14px; }
.buyer-hero .name { font-size: 15px; font-weight: 700; }
.buyer-hero .sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.buyer-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 12px 12px; }
.buyer-stat { background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 9px; padding: 8px 9px; }
.buyer-stat .v { font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.buyer-stat .k { font-size: 9.5px; color: var(--text-3); margin-top: 1px; }
.history-row { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-top: 1px solid var(--border-2); cursor: pointer; }
.history-row:hover { background: var(--surface-2); }
.history-row img { width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--border-2); object-fit: cover; }
.history-row .h-main { flex: 1; min-width: 0; }
.history-row .h-id { font-size: 11px; font-weight: 600; font-family: var(--mono); }
.history-row .h-meta { font-size: 10px; color: var(--text-3); }
.history-row .h-amount { font-size: 11px; font-weight: 700; }

/* ---------- Empty states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 42px 20px; text-align: center; color: var(--text-3); }
.empty-state .circle { width: 52px; height: 52px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-4); }
.empty-state .circle .ico { width: 24px; height: 24px; }
.empty-state .title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.empty-state .sub { font-size: 11.5px; max-width: 260px; line-height: 1.5; }

/* ---------- Full pages (performance / coverage) ---------- */
.page { overflow-y: auto; background: var(--bg); padding: 24px 30px 40px; min-height: 0; }
.page-inner { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 15px; box-shadow: var(--shadow-xs); }
.kpi-card .k { font-size: 10.5px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; text-transform: uppercase; }
.kpi-card .v { font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; display: flex; align-items: baseline; gap: 6px; }
.kpi-card .v .unit { font-size: 13px; font-weight: 600; color: var(--text-3); }
.kpi-card .foot { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-3); }
.kpi-card .delta { color: var(--green); font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.kpi-card .delta .ico { width: 12px; height: 12px; }
.kpi-bar { height: 5px; border-radius: 4px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.kpi-bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #5b7bff, #335cff); }
.kpi-target { font-size: 9.5px; color: var(--text-4); }

.panel-lg { background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-xs); overflow: hidden; margin-bottom: 16px; }
.panel-lg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border-2); }
.panel-lg-head .t { font-size: 13px; font-weight: 700; }
.panel-lg-head .sub { font-size: 11px; color: var(--text-3); }
.chart-wrap { padding: 16px 16px 8px; }
.chart-legend { display: flex; gap: 16px; padding: 0 16px 12px; font-size: 11px; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.data-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--border-2); background: var(--surface-2); white-space: nowrap; }
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-2); }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { font-variant-numeric: tabular-nums; }
.data-table .mono { font-family: var(--mono); font-size: 10.5px; }
.data-table .ok { color: var(--green); font-weight: 700; }

/* Coverage */
.coverage-rules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.rule-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-xs); display: flex; gap: 12px; }
.rule-card .rule-id { font-size: 10px; font-weight: 800; color: var(--brand); background: var(--brand-soft); border: 1px solid var(--brand-border); padding: 3px 7px; border-radius: 6px; height: fit-content; font-family: var(--mono); white-space: nowrap; }
.rule-card .r-title { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.rule-card .r-desc { font-size: 11px; color: var(--text-2); line-height: 1.5; }
.rule-card .r-status { margin-top: 8px; display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; color: var(--green); }
.rule-card .r-status .ico { width: 13px; height: 13px; }
.uc-group-title { display: flex; align-items: center; gap: 8px; padding: 10px 16px 8px; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.uc-group-title .n { background: var(--surface-3); border-radius: 8px; padding: 1px 7px; font-size: 9.5px; color: var(--text-2); }
.uc-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.uc-table th { text-align: left; font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: 7px 16px; border-bottom: 1px solid var(--border-2); background: var(--surface-2); font-weight: 700; }
.uc-table td { padding: 8px 16px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
.uc-table tr:last-child td { border-bottom: 0; }
.uc-table .uc-id { font-family: var(--mono); font-size: 10.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.uc-table .where { color: var(--text-2); }
.uc-table .req { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; }
.uc-table .req.yes { background: var(--red-soft); color: #b42318; }
.uc-table .req.no { background: var(--surface-3); color: var(--text-3); }
.uc-table .covered { color: var(--green); font-weight: 700; display: inline-flex; gap: 4px; align-items: center; }
.uc-table .covered .ico { width: 13px; height: 13px; }
.uc-table .show-btn { border: 1px solid var(--border); background: #fff; border-radius: 7px; padding: 3px 8px; font-size: 10.5px; font-weight: 600; color: var(--brand); cursor: pointer; }
.uc-table .show-btn:hover { background: var(--brand-soft); border-color: var(--brand-border); }

.arch { display: flex; align-items: stretch; gap: 14px; padding: 22px; flex-wrap: wrap; }
.arch-node { flex: 1; min-width: 190px; border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: linear-gradient(180deg, #fff, var(--surface-2)); box-shadow: var(--shadow-xs); }
.arch-node .an-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.arch-node .an-title { font-size: 13px; font-weight: 700; }
.arch-node .an-sub { font-size: 10.5px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.arch-node.highlight { border-color: var(--brand-border); background: linear-gradient(180deg, #fff, var(--brand-soft)); }
.arch-arrow { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-3); font-size: 9.5px; text-align: center; min-width: 74px; }
.arch-arrow .ico { width: 20px; height: 20px; color: var(--brand); }
.arch-arrow .ico.back { color: var(--green); }

.shop-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-2); font-size: 11.5px; }
.shop-row:last-child { border-bottom: 0; }
.shop-row .flag { font-size: 18px; }
.shop-row .sname { font-weight: 600; width: 190px; }
.shop-row .chip { background: var(--green-soft); color: #087443; border-radius: 6px; padding: 1px 7px; font-size: 9.5px; font-weight: 700; }
.shop-row .mono { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.webhook-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; }
.webhook-item { display: flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; font-size: 10.5px; font-family: var(--mono); color: var(--text-2); background: var(--surface-2); }
.webhook-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.coverage-note { margin-top: 8px; font-size: 11px; color: var(--text-3); line-height: 1.5; }

/* ---------- Trace drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 16, 30, .28); z-index: 70; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 470px; max-width: 92vw; background: #fff;
  z-index: 71; box-shadow: var(--shadow-lg); transform: translateX(102%); transition: transform .24s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 15px 16px; border-bottom: 1px solid var(--border); }
.drawer-head .t { font-size: 14px; font-weight: 700; }
.drawer-head .sub { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 12px 14px 24px; background: var(--surface-2); }
.trace-count { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; color: var(--text-3); margin-bottom: 10px; }
.trace-item { background: #fff; border: 1px solid var(--border); border-radius: 11px; margin-bottom: 9px; overflow: hidden; box-shadow: var(--shadow-xs); }
.trace-item.new { animation: traceIn .35s ease; }
@keyframes traceIn { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; transform: none; } }
.trace-line { display: flex; align-items: center; gap: 8px; padding: 9px 11px; }
.method { font-size: 9.5px; font-weight: 800; padding: 2px 6px; border-radius: 5px; font-family: var(--mono); letter-spacing: .02em; }
.method.GET { background: #e7f0ff; color: #1d4ed8; }
.method.POST { background: #e7f7ef; color: #0a7c56; }
.method.PUT { background: #fff3e0; color: #b45309; }
.method.WEBHOOK { background: #f3eeff; color: #6d28d9; }
.trace-path { font-family: var(--mono); font-size: 10px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.trace-code { font-size: 9.5px; font-weight: 700; color: var(--green); white-space: nowrap; }
.trace-ts { font-size: 9px; color: var(--text-4); white-space: nowrap; }
.trace-detail { border-top: 1px solid var(--border-2); padding: 8px 11px 10px; background: #fcfdff; }
.trace-detail pre { margin: 4px 0 0; font-family: var(--mono); font-size: 9.5px; line-height: 1.5; color: #334155; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 168px; overflow-y: auto; background: #f6f8fc; border: 1px solid var(--border-2); border-radius: 7px; padding: 7px 8px; }
.trace-detail .lbl { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.trace-meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; }

/* ---------- Modal / popover ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,16,30,.45); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadeIn .16s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 520px; max-width: 94vw; max-height: 88vh; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
  animation: modalIn .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal.wide { width: 720px; }
.modal.xwide { width: 880px; }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border-2); }
.modal-head .mt { font-size: 15px; font-weight: 700; }
.modal-head .ms { font-size: 11px; color: var(--text-3); margin-top: 3px; line-height: 1.45; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 14px 18px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border-2); background: var(--surface-2); }
.picker-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.picker-item { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 11px; padding: 10px; cursor: pointer; background: #fff; transition: border-color .12s, background .12s; }
.picker-item:hover { border-color: var(--brand-border); background: var(--brand-soft); }
.picker-item img { width: 46px; height: 46px; border-radius: 9px; border: 1px solid var(--border-2); object-fit: cover; }
.picker-item .pi-title { font-size: 11.5px; font-weight: 600; line-height: 1.3; }
.picker-item .pi-meta { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.picker-item .pi-price { font-size: 11.5px; font-weight: 700; margin-top: 3px; }
.picker-empty { padding: 26px; text-align: center; color: var(--text-3); font-size: 12px; }

.lightbox { position: fixed; inset: 0; background: rgba(8,12,20,.82); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 40px; cursor: zoom-out; animation: fadeIn .16s; }
.lightbox img { max-width: 90vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.video-modal { width: 720px; max-width: 92vw; background: #0b0f18; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-lg); }
.video-modal img { width: 100%; display: block; }
.video-modal .vm-bar { padding: 12px 16px; display: flex; align-items: center; gap: 12px; color: #cfd6e3; font-size: 11px; }
.video-modal .vm-bar .play { color: #fff; }
.progress { flex: 1; height: 4px; border-radius: 3px; background: rgba(255,255,255,.18); overflow: hidden; }
.progress i { display: block; height: 100%; width: 18%; background: var(--brand); border-radius: 3px; animation: progressRun 12s linear forwards; }
@keyframes progressRun { from { width: 4%; } to { width: 100%; } }

/* ---------- Buyer simulator ---------- */
.sim-panel { width: 460px; }
.sim-section { border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; margin-bottom: 10px; }
.sim-section .st { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.sim-section .ss { font-size: 10.5px; color: var(--text-3); margin: 3px 0 10px; line-height: 1.4; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 9px; }
.field label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.field select, .field input { height: 32px; border-radius: 8px; border: 1px solid var(--border); background: #fff; padding: 0 9px; outline: none; font-size: 12px; }
.field select:focus, .field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(51,92,255,.1); }
.sim-row { display: flex; gap: 8px; }
.sim-row .field { flex: 1; }
.seg { display: flex; background: var(--surface-3); border-radius: 9px; padding: 2px; border: 1px solid var(--border); }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 5px 3px; font-size: 10.5px; font-weight: 600; color: var(--text-3); cursor: pointer; }
.seg button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Toast + caption ---------- */
.toast-root { position: fixed; bottom: 44px; right: 18px; z-index: 95; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 260px; max-width: 380px; background: #fff; border: 1px solid var(--border);
  border-left: 3px solid var(--brand); border-radius: 11px; box-shadow: var(--shadow-md);
  padding: 10px 13px; display: flex; gap: 10px; align-items: flex-start;
  animation: toastIn .24s cubic-bezier(.2,.8,.3,1);
}
.toast.out { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
.toast .t-icon { width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.toast .t-icon.green { background: var(--green-soft); color: var(--green); }
.toast .t-icon.amber { background: var(--amber-soft); color: var(--amber); }
.toast .t-icon .ico { width: 15px; height: 15px; }
.toast .t-title { font-size: 12px; font-weight: 700; line-height: 1.35; }
.toast .t-sub { font-size: 10.5px; color: var(--text-3); margin-top: 2px; line-height: 1.4; }

.caption-root { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 96; pointer-events: none; width: max-content; max-width: 1120px; }
.caption {
  background: rgba(9, 14, 28, .9); color: #fff; border-radius: 14px; padding: 11px 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; gap: 14px; backdrop-filter: blur(8px);
  animation: captionIn .3s cubic-bezier(.2,.8,.3,1);
}
@keyframes captionIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.caption .c-badge { font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; background: var(--tiktok); color: #fff; padding: 4px 8px; border-radius: 7px; white-space: nowrap; }
.caption .c-text { font-size: 15px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; }
.caption .c-sub { font-size: 11.5px; color: #aeb9cc; margin-top: 3px; line-height: 1.4; }
.caption .c-step { font-size: 10px; color: #8f9bb3; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.16); }

/* ---------- Footer ---------- */
.statusbar {
  display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--surface);
  border-top: 1px solid var(--border); font-size: 10.5px; color: var(--text-3); z-index: 25;
}
.statusbar .item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.statusbar .item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.statusbar .spacer { flex: 1; }
.statusbar .mono { font-family: var(--mono); font-size: 9.5px; }
.statusbar .demo-tag { background: var(--amber-soft); color: #b45309; border: 1px solid #f5deb6; border-radius: 5px; padding: 0 6px; font-weight: 700; font-size: 9.5px; }

/* ---------- Truncation / utility ---------- */
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* language-specific tweaks */
html[data-lang="zh"] .conv-name, html[data-lang="zh"] .thread-name { letter-spacing: 0; }
html[data-lang="zh"] .bubble { line-height: 1.6; }

/* responsive */
@media (max-width: 1500px) {
  .workspace { grid-template-columns: 64px 312px minmax(0, 1fr) 352px; }
  .card { width: 316px; }
  .card-image, .video-card { width: 240px; }
  .thread-scroll { padding: 16px 20px 22px; }
  .kpi-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1280px) {
  .workspace { grid-template-columns: 60px 288px minmax(0, 1fr) 320px; }
  .brand { min-width: 190px; }
  .topsearch { max-width: 360px; }
  .thread-sub .hide-sm { display: none; }
}

/* ---------- final additions ---------- */
.hide-sm { display: inline-flex; align-items: center; }
.trace-more { border-top: 1px solid var(--border-2); padding: 6px 11px 8px; }
.trace-more summary {
  cursor: pointer; font-size: 9px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-3); list-style: none; display: flex;
  align-items: center; gap: 4px;
}
.trace-more summary::-webkit-details-marker { display: none; }
.trace-more summary::before { content: "▸"; font-size: 8px; color: var(--text-4); }
.trace-more[open] summary::before { content: "▾"; }
.trace-more[open] summary { margin-bottom: 5px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-grid button {
  height: 44px; border: 0; background: transparent; border-radius: 9px; cursor: pointer;
  font-size: 22px; line-height: 1; transition: background .12s, transform .12s;
}
.emoji-grid button:hover { background: var(--surface-3); transform: scale(1.08); }
.arch-arrow .ico.back { transform: rotate(180deg); color: var(--green); }
.conv-shop { max-width: 96px; }
.rail-btn .lbl { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox img { max-width: 92vw; max-height: 90vh; }
.video-modal .icon-btn:hover { background: rgba(255,255,255,.12); }
.sim-panel .sim-section:last-child { margin-bottom: 0; }

body.caption-on .statusbar { visibility: hidden; }
body.caption-on .caption-root { bottom: 8px; }

/* ---------- hosted reviewer mode ---------- */
.modal.review-modal { width: 660px; }
.review-hero { padding: 36px 40px 28px; text-align: center; }
.review-logo { width: 54px; height: 54px; border-radius: 15px; box-shadow: 0 10px 24px rgba(51,92,255,.28); margin-bottom: 14px; }
.review-badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.review-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.review-badge.green { background: var(--green-soft); color: #087443; border-color: #cdeee0; }
.review-title { font-size: 25px; font-weight: 800; letter-spacing: -.02em; }
.review-sub { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
.review-body { font-size: 13px; line-height: 1.65; color: var(--text-2); margin: 18px auto 0; max-width: 520px; text-align: left; }
.review-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }
.review-btn { height: 40px; padding: 0 18px; font-size: 13px; border-radius: 10px; }
.review-foot { margin-top: 18px; font-size: 11px; color: var(--text-3); }
.review-foot a { color: var(--brand); font-weight: 600; }
#narrow-hint {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 34px; z-index: 60;
  display: flex; align-items: center; gap: 12px; max-width: 92vw;
  background: #111827; color: #fff; font-size: 11.5px; line-height: 1.4;
  padding: 8px 10px 8px 14px; border-radius: 10px; box-shadow: var(--shadow-lg);
}
#narrow-hint .icon-btn { color: #fff; width: 24px; height: 24px; flex: 0 0 auto; }
#narrow-hint .icon-btn .ico { width: 14px; height: 14px; }
