/* =========================================================
   尚栈商品内容管理后台 · 样式
   ---------------------------------------------------------
   单页 + hash 路由，零构建。配色沿用尚栈品牌红 / 金。
   ========================================================= */

:root {
  --red: #c1272d;
  --red-deep: #8f1418;
  --red-soft: #fdecec;
  --gold: #c9a227;
  --bg: #f6f2f0;
  --panel: #ffffff;
  --line: #ece2df;
  --line-strong: #ddcec9;
  --text: #241f1e;
  --text-2: #5d514e;
  --muted: #948783;
  --ok: #1f7a4d;
  --ok-bg: #e8f5ee;
  --warn: #8a6208;
  --warn-bg: #fdf4e0;
  --danger: #b3261e;
  --danger-bg: #fdeceb;
  --info: #2f5d8a;
  --info-bg: #eaf1f8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 30, 25, .05), 0 6px 18px rgba(60, 30, 25, .04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- 骨架 ---------- */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.side {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--line);
}
.brand b {
  display: block;
  font-size: 19px;
  letter-spacing: 3px;
  color: var(--red);
}
.brand span {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  letter-spacing: 1.6px;
  color: var(--muted);
}
.side nav { padding: 12px 10px; flex: 1 1 auto; overflow: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 2px;
  cursor: pointer;
}
.nav-item:hover { background: #faf6f5; color: var(--text); }
.nav-item.on {
  background: var(--red-soft);
  color: var(--red-deep);
  font-weight: 600;
}
.nav-item .n {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  background: #f4eeec;
  border-radius: 20px;
  padding: 0 7px;
  min-width: 20px;
  text-align: center;
  font-weight: 500;
}
.nav-item.on .n { background: #fff; color: var(--red); }
.side-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: 0 0 auto; }
.dot.saved { background: var(--ok); }
.dot.dirty { background: var(--gold); }
.dot.danger { background: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar h1 { margin: 0; font-size: 17px; letter-spacing: .5px; }
.topbar p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 22px 26px 60px; max-width: 1320px; width: 100%; }

/* ---------- 通用块 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-hd {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-hd h2 { margin: 0; font-size: 14px; letter-spacing: .3px; }
.panel-hd .sub { font-size: 12px; color: var(--muted); }
.panel-hd .sp { margin-left: auto; }
.panel-bd { padding: 16px 18px; }
.stack > * + * { margin-top: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(186px, 1fr)); gap: 14px; }
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.stat:hover { border-color: var(--line-strong); }
.stat:active { transform: scale(.995); }
.stat .k { font-size: 12px; color: var(--muted); letter-spacing: .4px; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -.5px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 11.5px; color: var(--text-2); }
.stat .d em { font-style: normal; color: var(--red); font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text-2);
  padding: 7px 13px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #faf7f6; color: var(--text); }
.btn:active { transform: scale(.985); }
.btn.primary {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-deep) 100%);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(143,20,24,.22);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border-color: var(--line); background: transparent; }
.btn.danger { color: var(--danger); border-color: #f0d3d0; background: #fff; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.mini { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: #fff; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .6px;
  color: var(--muted);
  padding: 10px 12px;
  background: #fbf8f7;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid #f4eeec;
  vertical-align: middle;
}
table.tbl tbody tr:hover td { background: #fdfbfa; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .right { text-align: right; }
.cell-name { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cell-acts { display: flex; gap: 6px; justify-content: flex-end; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 状态标签 ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.6;
  font-weight: 500;
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.mute { color: var(--muted); background: #f3efee; }
.pill.danger { color: var(--danger); background: var(--danger-bg); }
.pill.info { color: var(--info); background: var(--info-bg); }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar .sp { margin-left: auto; }
.input, .select {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.input:focus, .select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(193,39,45,.09); }
.input.search { width: 230px; }
.select { padding-right: 26px; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23948783' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 9px center; }

/* ---------- 空态 ---------- */
.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty b { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 4px; }

.sub { font-size: 12px; color: var(--muted); }
ul.todo { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
ul.todo li { margin: 6px 0; }
ul.todo li b { color: var(--red); }
code {
  background: #f4eeec;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--red-deep);
}

/* ---------- 抽屉 ---------- */
.mask {
  position: fixed; inset: 0;
  background: rgba(40, 20, 18, .28);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 40;
}
.mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 92vw;
  background: #fff;
  box-shadow: -8px 0 32px rgba(60,30,25,.12);
  transform: translateX(102%);
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  z-index: 41;
  display: flex;
  flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-hd {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer-hd h3 { margin: 0; font-size: 15px; }
.drawer-hd .x {
  margin-left: auto;
  border: none; background: transparent;
  font-size: 20px; color: var(--muted); cursor: pointer;
  line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.drawer-hd .x:hover { background: #f6f0ee; color: var(--text); }
.drawer-bd { padding: 18px 20px; overflow: auto; flex: 1 1 auto; }
.drawer-ft {
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  display: flex; gap: 9px; align-items: center;
  background: #fdfbfa;
}
.drawer-ft .sp { margin-left: auto; }
.drawer-ft .hint { font-size: 11.5px; color: var(--muted); }

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
  letter-spacing: .3px;
}
.field .req { color: var(--red); }
.field input[type="text"], .field input[type="date"], .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 13.5px;
  outline: none;
  background: #fff;
}
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--red); box-shadow: 0 0 0 3px rgba(193,39,45,.09);
}
.field input[readonly] { background: #f8f4f3; color: var(--muted); }
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field .help.err { color: var(--danger); }
.field .help.warn { color: var(--warn); }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1 1 0; margin-bottom: 15px; }

.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}
.seg button {
  border: none;
  background: transparent;
  padding: 6px 13px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-2);
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button:hover { background: #faf6f5; }
.seg button.on { background: var(--red); color: #fff; font-weight: 600; }
.seg button.on.green { background: var(--ok); }
.seg button.on.gray { background: #8d817e; }
.seg button.on.gold { background: var(--gold); }

/* ---------- 上架矩阵 ---------- */
.matrix { overflow: auto; max-height: calc(100vh - 250px); }
table.mx { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.mx th, table.mx td { border-bottom: 1px solid #f4eeec; border-right: 1px solid #f4eeec; }
table.mx thead th {
  position: sticky; top: 0; z-index: 3;
  background: #fbf8f7;
  padding: 7px 4px;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  height: 56px;
  vertical-align: bottom;
}
table.mx thead th.corner {
  left: 0; z-index: 5;
  background: #fbf8f7;
  text-align: left; padding-left: 14px;
  min-width: 150px;
  vertical-align: bottom;
}
table.mx thead th .v { writing-mode: vertical-rl; text-orientation: mixed; max-height: 46px; overflow: hidden; margin: 0 auto; letter-spacing: .5px; }
table.mx tbody th {
  position: sticky; left: 0; z-index: 2;
  background: #fff;
  text-align: left;
  padding: 7px 12px 7px 14px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 150px;
  border-right: 1px solid var(--line-strong);
}
table.mx tbody th .c { font-size: 10.5px; color: var(--muted); margin-left: 6px; font-weight: 400; }
table.mx tbody tr:hover th { background: #fdfbfa; }
table.mx td { padding: 3px; text-align: center; }
.cell {
  width: 30px; height: 26px;
  border-radius: 6px;
  border: 1px dashed #e2d7d3;
  background: #fcfaf9;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  transition: all .1s;
  padding: 0;
}
.cell:hover { border-color: var(--red); color: var(--red); }
.cell.active { background: var(--red); border: 1px solid var(--red); color: #fff; }
.cell.active::after { content: "✓"; font-size: 12px; }
.cell.inactive { background: #f0ebe9; border: 1px solid #d9cecb; color: #9c8f8b; }
.cell.inactive::after { content: "×"; font-size: 13px; }
.cell.draft { background: #fff; border: 1.5px dashed var(--gold); color: var(--gold); }
.cell.draft::after { content: "·"; font-size: 16px; line-height: 1; }
.cell.blocked { position: relative; }
.cell.blocked::before {
  content: "";
  position: absolute; top: 2px; right: 2px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--warn);
}
.mx-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.mx-legend i { display: inline-block; width: 14px; height: 13px; border-radius: 4px; margin-right: 5px; vertical-align: -2px; }
.lg-none { border: 1px dashed #e2d7d3; background: #fcfaf9; }
.lg-active { background: var(--red); }
.lg-inactive { background: #f0ebe9; border: 1px solid #d9cecb; }
.lg-draft { background: #fff; border: 1.5px dashed var(--gold); }

/* ---------- 问题清单 ---------- */
.issue { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #f0e8e6; font-size: 13px; }
.issue:last-child { border-bottom: none; }
.issue .tag { flex: 0 0 auto; }
.issue .msg { flex: 1 1 auto; color: var(--text-2); }
.issue .code { flex: 0 0 auto; font-size: 10.5px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(36, 31, 30, .95);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 60;
  max-width: 80vw;
  display: flex;
  align-items: center;
  gap: 12px;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.err { background: rgba(179, 38, 30, .96); }
.toast .undo {
  border: 1px solid rgba(255,255,255,.45);
  background: transparent; color: #fff;
  border-radius: 6px; padding: 2px 9px; font-size: 12px; cursor: pointer;
}
.toast .undo:hover { background: rgba(255,255,255,.14); }

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #f0e0bd;
}
.notice.info { background: var(--info-bg); color: var(--info); border-color: #d5e2ef; }
.notice.danger { background: var(--danger-bg); color: var(--danger); border-color: #f2d3d0; }
.notice b { font-weight: 700; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; word-break: break-all; }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- 复选框清单（文案管理的场景 / 关联商品） ---------- */
.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 9px 11px;
  background: #fff;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbf8f7;
  user-select: none;
}
.check:hover { border-color: var(--red); color: var(--red-deep); }
.check input { accent-color: var(--red); margin: 0; }
.check:has(input:checked) { background: var(--red-soft); border-color: #f0c9c9; color: var(--red-deep); font-weight: 600; }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { border-bottom: none; border-right: 1px solid var(--line); padding: 12px 16px; white-space: nowrap; }
  .brand b { font-size: 15px; }
  .brand span { display: none; }
  .side nav { display: flex; gap: 4px; padding: 8px; flex: 1 1 auto; }
  .nav-item { white-space: nowrap; padding: 7px 11px; }
  .nav-item .n { display: none; }
  .side-foot { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
}
