:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e4e7ec; --text: #1d2433; --muted: #6b7385;
  --accent: #2f6fed; --accent-soft: #eaf1ff; --danger: #d9363e; --warn: #e8890c; --ok: #1f9d55;
  --presale: #2f6fed; --order: #8a4fff; --aftersale: #e8590c; --other: #8b93a3;
  --amazon: #ff9900; --shopify: #5e8e3e; --gmail: #d93025;
  --note: #fff8e1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1a1e26; --line: #2a303b; --text: #e6e9ef; --muted: #98a0b0;
    --accent: #5b8cff; --accent-soft: #1f2a44; --note: #2e2a1a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; }
a { color: var(--accent); cursor: pointer; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1em; }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; resize: vertical; }

.login { display: grid; place-items: center; height: 100%; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 32px; width: 340px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }

.app { display: grid; grid-template-columns: 210px 340px 1fr; height: 100vh; }
.nav { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 14px; }
.nav-title { color: var(--muted); font-size: 12px; padding: 14px 10px 4px; }
.nav-group a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text); }
.nav-group a:hover { background: var(--bg); }
.nav-group a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-group a span { margin-left: auto; color: var(--muted); font-size: 12px; }
.nav-foot { margin-top: auto; padding: 10px; display: grid; gap: 6px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.presale, .tag.presale { background: var(--presale); } .dot.order, .tag.order { background: var(--order); }
.dot.aftersale, .tag.aftersale { background: var(--aftersale); } .dot.other, .tag.other { background: var(--other); }
.ch { width: 18px; height: 18px; border-radius: 5px; color: #fff; font-style: normal; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.ch.amazon { background: var(--amazon); } .ch.shopify { background: var(--shopify); } .ch.gmail { background: var(--gmail); } .ch.chat { background: #0ea5a4; font-size: 10px; }

.list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.list-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.list-head input { flex: 1; min-width: 0; }
.banner { padding: 8px 12px; font-size: 13px; background: var(--accent-soft); color: var(--accent); border-bottom: 1px solid var(--line); }
.tickets { overflow-y: auto; flex: 1; }
.t-item { padding: 12px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 4px; }
.t-item:hover { background: var(--bg); }
.t-item.active { background: var(--accent-soft); }
.t-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.t-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-time { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }
.t-subj { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-prev { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; flex: none; }
.tag.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pri-urgent { background: var(--danger); } .pri-high { background: var(--warn); }
.waiting { font-size: 11px; color: var(--muted); }

.detail { display: grid; grid-template-columns: 1fr 290px; min-width: 0; overflow: hidden; }
.empty { grid-column: 1 / -1; display: grid; place-items: center; color: var(--muted); }
.conv { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.conv-head { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); display: grid; gap: 8px; }
.conv-head h2 { margin: 0; font-size: 16px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls select { padding: 4px 8px; font-size: 13px; }
.viewers { font-size: 12px; color: var(--warn); }
.summary { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.msgs { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 12px; align-content: start; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; max-width: 760px; }
.msg.out { margin-left: auto; border-color: var(--accent); }
.msg.note { background: var(--note); border-style: dashed; }
.msg-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.msg-body { white-space: pre-wrap; word-break: break-word; margin-top: 6px; }
.msg-zh { white-space: pre-wrap; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--muted); }
.msg-zh::before { content: "中文翻译："; font-weight: 600; }

.composer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px 14px; display: grid; gap: 8px; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: none; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font: inherit; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tools .grow { flex: 1; }
.hint { font-size: 12px; color: var(--muted); }
.checklist { background: var(--note); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.checklist ul { margin: 4px 0 0; padding-left: 18px; }
.zh-preview { font-size: 13px; color: var(--muted); white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 8px 10px; max-height: 140px; overflow: auto; }

.side { border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
.card h3 { font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 2px 8px; font-size: 13px; word-break: break-all; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.ord { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.ord b { font-size: 14px; }
.activity { font-size: 12px; color: var(--muted); display: grid; gap: 3px; }

dialog { border: none; border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(720px, 94vw); }
dialog::backdrop { background: rgba(0,0,0,.35); }
.dlg { padding: 18px 22px; max-height: 85vh; overflow-y: auto; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; }
.dlg-head h2 { margin: 0; }
.dlg section { margin-top: 18px; }
.dlg h3 { font-size: 15px; margin: 0 0 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.status-ok { color: var(--ok); } .status-no { color: var(--danger); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; vertical-align: top; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 180px 300px 1fr; }
  .detail { grid-template-columns: 1fr; }
  .side { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .nav { display: none; }
  .list { border-right: none; }
  .app.show-detail .list { display: none; }
  .app:not(.show-detail) .detail { display: none; }
  .detail { height: 100vh; }
}
.detail { height: 100vh; }
.conv { height: 100%; }
td a { white-space: nowrap; }

/* 附件 */
.atts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 10px; }
.att-img img { display: block; max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.att-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg, #f6f7f9); color: inherit; text-decoration: none; font-size: 13px; }
.att-file span { color: var(--muted); font-size: 12px; }
.att-file:hover, .att-img:hover img { border-color: #2f6fed; }

.msg-meta .by { background:var(--accent-soft); color:var(--accent); border-radius:10px; padding:1px 8px; font-size:12px; font-weight:600 }
.reply-warn { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; font-size: 13px; }
.reply-warn .cands { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
