:root {
  --bg: #efeae1;
  --ink: #1d1914;
  --muted: #6d655c;
  --line: #e2d9cc;
  --card: #fffdf9;
  --side: #1b2420;
  --side-text: #f6f1e8;
  --brand: #0e6b56;
  --brand-dark: #0a5343;
  --warn: #8a4b12;
  --warn-bg: #fff1df;
  --bad: #8d2e2e;
  --bad-bg: #fdecec;
  --ok-bg: #e7f5ef;
  --shadow: 0 1px 2px rgba(48, 36, 18, 0.05), 0 12px 32px rgba(48, 36, 18, 0.05);
  --radius: 16px;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.03em; }
h2 { font-size: 18px; }

body:has(.app) { height: 100vh; overflow: hidden; }
.app { display: flex; height: 100vh; min-height: 0; overflow: hidden; }
.side {
  width: 248px;
  flex: none;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  background: var(--side);
  color: var(--side-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #d9b36a;
  color: #1b2420;
  font-weight: 700;
}
.brand strong { display: block; font-size: 16px; }
.brand em { display: block; font-style: normal; color: #c9c1b4; font-size: 12px; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  color: inherit;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.side nav a.on, .side nav a:hover { background: rgba(255, 255, 255, 0.08); }
.side nav i {
  font-style: normal;
  background: #d9b36a;
  color: #1b2420;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
  font-size: 12px;
  padding: 1px 6px;
}
.side-foot { margin-top: auto; color: #c9c1b4; font-size: 12px; display: grid; gap: 10px; }
.side-foot p { margin: 0; }
.who { display: grid; gap: 2px; }
.who strong { color: var(--side-text); font-size: 14px; }
.who span { color: #d9b36a; font-size: 12px; }
.login-split { color: var(--muted); font-size: 13px; text-align: center; margin: 4px 0; }
.card form { display: grid; gap: 14px; }
.main { flex: 1; width: 100%; min-width: 0; min-height: 0; overflow-y: auto; padding: 28px 32px 64px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; }
.page-head p, .muted { color: var(--muted); }
.kicker { margin-bottom: 6px; font-size: 13px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; letter-spacing: -0.02em; }

.button, button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: white;
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}
.button:hover { background: var(--brand-dark); }
.button.secondary { background: #24312c; }
.button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: #d9b36a;
  cursor: pointer;
}
.linkish.danger { color: #e7b4b4; }

.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.banner.ok { background: var(--ok-bg); color: var(--brand-dark); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a {
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
}
.tabs a.on { background: white; color: var(--ink); box-shadow: var(--shadow); }
.search { display: flex; gap: 8px; margin-bottom: 10px; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters span { color: var(--muted); font-size: 13px; }
.filters form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: 8px; }
.filters form label { display: flex; gap: 6px; align-items: center; width: auto; }
.filters input[type="date"], .filters select { width: auto; padding: 6px 8px; }
.filters button {
  border: 0;
  background: white;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.filters a {
  text-decoration: none;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
}
.filters a.on { background: white; color: var(--ink); border-color: transparent; box-shadow: var(--shadow); }
.search input { flex: 1; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card h2 { margin-bottom: 12px; }
.empty { padding: 28px 8px; }
.empty h2 { margin-bottom: 6px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr[data-href] { cursor: pointer; }
tbody tr[data-href]:hover td { background: #f6f1e8; }
tr.stale td:first-child { box-shadow: inset 3px 0 0 #c47a2c; }
td span, td strong { display: block; }
.chip {
  display: inline-flex;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  background: #eee7dc;
}
.chip.pending, .chip.choosing, .chip.buyer { background: #fff1df; color: var(--warn); }
.chip.replied, .chip.online { background: var(--ok-bg); color: var(--brand-dark); }
.chip.wangwang { background: #fff4d6; color: #8a5a00; }
.chip.closed { background: #ece8e2; color: #5c564e; }
.chip.archived { background: #e5f2ea; color: #1d6b42; }

.form { display: grid; gap: 14px; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; }
.form legend { font-weight: 700; margin-bottom: 2px; }
label { display: grid; gap: 6px; font-size: 14px; }
label span, .file span { color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d9d0c3;
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { resize: vertical; }
input:disabled, select:disabled, textarea:disabled {
  background: #f4efe6;
  color: #3d3832;
  cursor: not-allowed;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .full { grid-column: 1 / -1; }
.sku-picture:not([hidden]) { display: inline-block; }
.sku-picture {
  width: 160px;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.sku-picture[hidden] { display: none; }
.sku-picture img { width: 100%; height: 100%; object-fit: contain; }
.actions { display: flex; gap: 10px; align-items: center; }
.choose { display: grid; gap: 10px; margin-top: 8px; }
.choose label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.choose input { width: auto; padding: 0; }
.choose .button { width: auto; justify-self: start; }
.assign { display: flex; gap: 10px; align-items: end; margin-top: 4px; }
.assign label { flex: 1; }
.assign .button { width: auto; white-space: nowrap; }
.detail-grid, .split { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 14px; }
dl { display: grid; gap: 10px; margin: 0 0 12px; }
dl div { display: grid; grid-template-columns: 88px 1fr; gap: 8px; }
dt { color: var(--muted); }
dd { margin: 0; }
.prose { white-space: pre-wrap; }
.gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.gallery img { width: 112px; height: 112px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: white; }
.chat { display: flex; flex-direction: column; gap: 14px; margin: 4px -4px 0; padding: 14px 8px; background: #ebe6de; border-radius: 12px; }
.chat-time { text-align: center; margin: 2px 0; }
.chat-time span { display: inline-block; padding: 2px 8px; border-radius: 4px; background: #d5cfc4; color: #fff; font-size: 12px; }
.chat-row { display: flex; align-items: flex-start; gap: 8px; }
.chat-row.mine { flex-direction: row-reverse; }
.chat-avatar { width: 38px; height: 38px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 700; flex: none; }
.chat-avatar.supplier { background: #5b7fbf; }
.chat-avatar.cs { background: #3d9a62; }
.chat-avatar.buyer { background: #c47a2c; }
.chat-main { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: min(72%, 460px); }
.chat-row.mine .chat-main { align-items: flex-end; }
.chat-name { margin: 0; color: #888; font-size: 12px; line-height: 1.2; }
.chat-bubble { background: #fff; border-radius: 4px 12px 12px 12px; padding: 8px 12px; }
.chat-row.mine .chat-bubble { background: #95ec69; border-radius: 12px 4px 12px 12px; }
.chat-bubble .gallery { margin-top: 8px; }
.chat-bubble .gallery img { width: 140px; height: 140px; }
.copy input { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }
.supplier header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.supplier header h2 { margin: 0; }
.supplier header p, .stack .muted { color: var(--muted); font-size: 13px; }
.stack { display: grid; gap: 12px; align-content: start; }
details summary { cursor: pointer; color: var(--brand-dark); margin: 8px 0; }
.tight { margin-top: 8px; }

.reply-wrap { width: min(720px, calc(100% - 32px)); margin: 28px auto 48px; }
.reply-wrap.narrow { width: min(420px, calc(100% - 32px)); margin-top: 12vh; }
.brand-line { color: var(--brand-dark); font-weight: 700; letter-spacing: 0.08em; margin-bottom: 12px; }
.reply-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.page-reply { background: #f7f3ec; }

@media (max-width: 860px) {
  body:has(.app) { height: auto; overflow: auto; }
  .app { display: block; height: auto; overflow: visible; }
  .side { width: auto; height: auto; overflow: visible; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 8px; }
  .main { height: auto; overflow: visible; padding: 18px 14px 40px; }
  .grid, .detail-grid, .split { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }
  dl div { grid-template-columns: 72px 1fr; }
}
