/* 变体图片分组 · 管理工具 — 简洁实用的本地界面 */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2328;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 15px; }
.shop-status { font-size: 12px; color: var(--muted); margin-left: auto; }
.shop-status.ok { color: var(--ok); }
.shop-status.err { color: var(--err); }

/* 按钮 */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #f0f2f5; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.danger { color: var(--err); border-color: #f0c4c4; }
.btn.danger:hover { background: #fdf2f2; }
.btn.ghost { background: transparent; }

/* 视图容器 */
.view { max-width: 1180px; margin: 0 auto; padding: 20px; }

/* 搜索 + 列表 */
.search-row { display: flex; gap: 8px; margin-bottom: 16px; }
#search {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
#search:focus { outline: none; border-color: var(--brand); }

.product-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.product-card {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.product-card:hover { box-shadow: var(--shadow); border-color: #cfd4da; }
.product-card .thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f0f2f5;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .noimg { color: var(--muted); font-size: 12px; }
.p-title {
  font-weight: 600;
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.list-footer { text-align: center; margin-top: 18px; }

/* 详情头部 */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-head h2 { font-size: 18px; margin: 0; }
.admin-link { text-decoration: none; }
.admin-link:hover { text-decoration: underline; }

/* 目标栏 */
.target-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.seg { display: flex; gap: 14px; }
.seg label { display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: 13px; }
.target-controls { display: flex; align-items: center; gap: 8px; }
.ctl-label { font-size: 12px; color: var(--muted); }
select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  max-width: 320px;
}
select:focus { outline: none; border-color: var(--brand); }

/* 工作区 */
.workspace { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } }
.col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.col-head { font-weight: 600; margin-bottom: 12px; }

/* 媒体网格 */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #f0f2f5;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile:hover { border-color: #cfd4da; }
.tile.sel { border-color: var(--brand); }
.tile .badge {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 已选条 */
.selected-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 96px;
  padding: 10px;
  background: #fafbfc;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.chip {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: grab;
  background: #fff;
}
.chip.dragging { opacity: 0.4; }
.chip img { width: 100%; height: 100%; object-fit: cover; }
.chip .order {
  position: absolute;
  top: 3px;
  left: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(37, 99, 235, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip .x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip .x:hover { background: var(--err); }

.empty { color: var(--muted); font-size: 13px; padding: 8px; }

.dirty-note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: var(--warn);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 10px;
}

.actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.save-status { font-size: 12px; color: var(--muted); }

.results { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.res { font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.res.ok { background: #f0fdf4; color: var(--ok); }
.res.err { background: #fef2f2; color: var(--err); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  z-index: 50;
}
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
.toast.err { background: var(--err); }
