:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --bad: #cf222e;
  --todo: #9a6700;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 左侧竖向导航 ---------- */
.app { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  flex: 0 0 208px;
  width: 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}

.brand {
  display: flex; align-items: center; gap: 8px; font-weight: 600;
  padding: 16px 16px 14px; border-bottom: 1px solid var(--line);
}
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 12px; letter-spacing: .5px;
  flex: 0 0 auto;
}
.brand-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ver { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: auto; }

.nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 10px; overflow-y: auto; flex: 1 1 auto;
}
.nav a {
  display: block; padding: 10px 12px; border-radius: 6px; color: var(--text);
  text-decoration: none; font-size: 15.5px; line-height: 1.45;
  border-left: 3px solid transparent;
}
.nav a:hover { background: #eef2f7; }
.nav a.active {
  background: #e7f0ff; color: var(--accent); font-weight: 600;
  border-left-color: var(--accent);
}

.side-foot {
  border-top: 1px solid var(--line); padding: 10px 16px 14px;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11.5px; color: var(--muted);
}
.side-foot a { color: var(--muted); text-decoration: none; }
.side-foot a:hover { color: var(--accent); }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1680px; margin: 0 auto; padding: 20px 24px; flex: 1 1 auto; }
.page-title { font-size: 20px; margin: 4px 0 16px; }

/* 窄屏：侧栏收成顶部横条，避免挤占内容区 */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto; width: 100%; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 10px 14px; border-bottom: none; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 0 10px 10px; overflow: visible; }
  .nav a { border-left: none; padding: 6px 10px; }
  .nav a.active { border-left: none; }
  .side-foot { display: none; }
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }

table.kv { width: 100%; border-collapse: collapse; }
table.kv th {
  text-align: left; width: 132px; font-weight: 500;
  color: var(--muted); padding: 6px 8px 6px 0; vertical-align: top;
}
table.kv td { padding: 6px 0; word-break: break-all; }
table.kv tr + tr th, table.kv tr + tr td { border-top: 1px solid #f0f2f5; }

code {
  background: #f3f4f6; padding: 1px 6px; border-radius: 4px;
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px;
}

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 18px; margin-right: 8px;
}
.pill.ok { background: #e6f4ea; color: var(--ok); }
.pill.bad { background: #fde8e8; color: var(--bad); }
.pill.todo { background: #fff4d6; color: var(--todo); }

.err { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.muted { color: var(--muted); }

table.stages { width: 100%; border-collapse: collapse; }
table.stages th, table.stages td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #f0f2f5; }
table.stages th { color: var(--muted); font-weight: 500; font-size: 13px; }
table.stages .no { width: 60px; font-weight: 600; }

.placeholder .stage-badge {
  display: inline-block; padding: 2px 10px; border-radius: 6px;
  background: #fff4d6; color: var(--todo); font-size: 12px; margin-bottom: 10px;
}

.footer {
  padding: 16px 20px 28px; text-align: center;
  color: var(--muted); font-size: 12px;
}

/* ---------- 阶段二：采集 / 商品库 ---------- */
.btn {
  display: inline-block; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13px; text-decoration: none;
}
.btn:hover { background: #f3f6fa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1a5fd0; }
.btn.danger { color: var(--bad); border-color: #f3c0c4; }
.btn.sm { padding: 2px 8px; font-size: 12px; }

.bookmarklet-btn {
  display: inline-block; padding: 10px 22px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; text-decoration: none;
  box-shadow: 0 2px 6px rgba(31,111,235,.28); cursor: grab;
}
.bookmarklet-btn:hover { background: #1a5fd0; }

.steps { counter-reset: s; padding-left: 0; list-style: none; }
.steps li { counter-increment: s; margin-bottom: 8px; padding-left: 28px; position: relative; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 2px;
  width: 19px; height: 19px; border-radius: 50%; background: #e7f0ff; color: var(--accent);
  font-size: 12px; font-weight: 600; text-align: center; line-height: 19px;
}

textarea.js-src {
  width: 100%; font-family: Consolas, "Courier New", monospace; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: #fafbfc;
}

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="text"] {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; width: 260px; font-size: 13px;
}

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fafbfc;
  position: relative;
}
.thumb img, img.thumb { display: block; width: 100%; height: 150px; object-fit: contain; background: #fff; }
img.thumb { border: 1px solid var(--line); border-radius: 8px; }
.card img { max-width: 100%; }
.thumb .meta { padding: 5px 8px; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.thumb.bad { border-color: #f3c0c4; background: #fff6f6; }
.thumb.bad .ph { height: 150px; display: flex; align-items: center; justify-content: center; color: var(--bad); font-size: 12px; text-align: center; padding: 8px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 500; font-size: 13px; background: #fbfcfd; }
table.list tr.dup { background: #fffaf0; }
table.list tr.merged { opacity: .55; }
table.list img.mini { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert.warn { background: #fff8e6; border: 1px solid #f0dfa8; color: var(--todo); }
.alert.bad { background: #fdecec; border: 1px solid #f3c0c4; color: var(--bad); }
.alert.ok { background: #eaf6ee; border: 1px solid #bfe3c9; color: var(--ok); }

.pager { display: flex; gap: 6px; margin-top: 14px; align-items: center; }
.pager a, .pager span { padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--text); font-size: 13px; }
.pager .cur { background: var(--accent); color: #fff; border-color: var(--accent); }

.inline-form { display: inline; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field input[type="text"], .field select, .field input[type="file"] {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
}
.field input[type="text"] { width: 100%; max-width: 520px; }

/* ---------- 商品库宫格 ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.prod-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; transition: box-shadow .15s, border-color .15s;
}
.prod-card:hover { box-shadow: 0 4px 16px rgba(31, 35, 40, .10); border-color: #d3d8de; }
.prod-card.dup { border-color: #f0dfa8; background: #fffdf6; }
.prod-card.merged { opacity: .6; }
.prod-card .cover { display: block; background: #fff; cursor: zoom-in; border-bottom: 1px solid var(--line); }
.prod-card .cover img { display: block; width: 100%; height: 220px; object-fit: contain; background: #fff; }
.prod-card .cover .noimg {
  height: 220px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12.5px; background: #fafbfc;
}
.prod-card .cover.noimg-wrap { cursor: default; }
.prod-card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; }
.prod-card .name {
  font-size: 13.5px; font-weight: 600; line-height: 1.45; color: var(--text); text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.prod-card .name:hover { color: var(--accent); }
.prod-card .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.prod-card .row.price { color: var(--text); font-size: 13px; font-weight: 600; }
.prod-card .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.prod-card .dup-box { border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }

/* ---------- 图片大图弹层 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 1000; display: none;
  align-items: center; justify-content: center; padding: 28px;
  background: rgba(15, 18, 22, .74);
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 92vw; max-height: 86vh; object-fit: contain;
  background: #fff; border-radius: 8px; box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
  cursor: zoom-out;
}
.lightbox .lb-close {
  position: absolute; top: 14px; right: 18px; width: 36px; height: 36px; border: none;
  border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer;
}
.lightbox .lb-close:hover { background: rgba(255, 255, 255, .26); }
.lightbox .lb-caption {
  position: absolute; left: 0; right: 0; bottom: 16px; text-align: center;
  color: #dfe3e8; font-size: 12.5px; padding: 0 24px; word-break: break-all;
}
.thumb a img, table.list img.mini { cursor: zoom-in; }

/* ---------- 紧凑列表行（上架通道） ---------- */
.statline { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.statline strong { color: var(--text); font-size: 15px; }
.list-rows { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.list-row + .list-row { margin-top: 6px; }
.list-row.blocked { background: #fffdf6; border-color: #f0dfa8; }
.list-row .lr-main { flex: 1 1 auto; min-width: 0; }
.list-row .lr-title {
  display: block; font-size: 13.5px; font-weight: 600; color: var(--text); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-row .lr-title:hover { color: var(--accent); }
.list-row .lr-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .lr-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: 0 0 auto; }
.list-row .lr-acts { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.list-row .lr-detail { flex-basis: 100%; font-size: 12px; color: var(--muted); margin-top: 4px; }
.list-row .lr-detail div { margin: 2px 0; }
details.inline { display: inline-block; }
details.inline > summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details.card > summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
details.card > summary::-webkit-details-marker { color: var(--muted); }
@media (max-width: 820px) {
  .list-row { flex-wrap: wrap; }
  .list-row .lr-acts { flex-basis: 100%; }
}

/* ---------- 账号与权限 ---------- */
.side-user {
  border-top: 1px solid var(--line); padding: 10px 12px;
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
}
.side-user-name {
  flex: 1 1 auto; min-width: 0; color: var(--text); text-decoration: none;
  display: flex; align-items: center; gap: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-user-name:hover { color: var(--accent); }
.role-chip {
  font-size: 11px; padding: 1px 7px; border-radius: 10px; flex: 0 0 auto;
  background: #eef2f7; color: var(--muted); font-weight: 400;
}
.role-chip.role-admin { background: #fde8e8; color: var(--bad); }
.role-chip.role-supervisor { background: #e7f0ff; color: var(--accent); }
.btn-mini {
  padding: 3px 9px; font-size: 12px; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; cursor: pointer; color: var(--muted); font-family: inherit;
}
.btn-mini:hover { background: #f3f6fa; color: var(--text); }

.field input[type="password"], .field input[type="number"] {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px;
  width: 100%; max-width: 520px; font-family: inherit; background: #fff;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 登录页：独立居中布局，不套侧栏 */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  width: 348px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 26px 26px 20px;
  box-shadow: 0 8px 26px rgba(31, 35, 40, .07);
}
.auth-card .auth-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.auth-card .auth-title { font-size: 18px; font-weight: 600; margin: 14px 0 16px; }
.auth-card .field input[type="text"], .auth-card .field input[type="password"] { max-width: none; }
.auth-card .btn.primary { width: 100%; text-align: center; padding: 8px; margin-top: 6px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }

/* 采集令牌 / 代码块 */
.token-box {
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px;
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; word-break: break-all; margin-bottom: 10px;
}
.code-box {
  font-family: Consolas, "Courier New", monospace; font-size: 11.5px; line-height: 1.55;
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; max-height: 190px; overflow: auto; white-space: pre-wrap;
  word-break: break-all; color: #33415c;
}
.card h2 .pill { margin-left: 8px; font-weight: 400; }
