/* ============ PDD 上货后台 主题 ============ */
:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e6e8f0;
  --text: #1e2430;
  --muted: #8a92a6;
  --accent: #e11d48;
  --accent-2: #fb7185;
  --accent-grad: linear-gradient(135deg, #e11d48, #f43f5e);
  --green: #16a34a;
  --green-grad: linear-gradient(135deg, #16a34a, #22c55e);
  --blue: #2563eb;
  --amber: #d97706;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --sidebar-w: 232px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--blue); text-decoration: none; }

/* ---------- 布局: 侧边栏 + 内容 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; position: fixed; top: 0; left: 0; bottom: 0;
  background: linear-gradient(180deg, #101624 0%, #0b101d 100%);
  color: #cbd5e1; display: flex; flex-direction: column; padding: 20px 14px;
  z-index: 100; overflow-y: auto;
}
.sidebar .logo {
  display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800;
  color: #fff; padding: 6px 10px 22px; letter-spacing: .5px;
}
.sidebar .logo .logo-badge {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--accent-grad); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(225, 29, 72, .45);
}
.sidebar .logo span small { display: block; font-size: 10px; font-weight: 400; color: #64748b; letter-spacing: 2px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar .nav-sep { padding: 12px 12px 4px; font-size: 11px; letter-spacing: 1px; color: #475569; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 10px; color: #94a3b8; font-size: 14px; transition: all .18s;
}
.sidebar .nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.sidebar .nav-item:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.sidebar .nav-item.active {
  background: var(--accent-grad); color: #fff; font-weight: 600;
  box-shadow: 0 6px 18px rgba(225, 29, 72, .35);
}
.sidebar .nav-item.active svg { opacity: 1; }
.sidebar .side-foot {
  margin-top: auto; padding: 12px 10px 4px; font-size: 11px; color: #475569;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.main { flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: .3px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  margin-bottom: 18px; transition: box-shadow .2s;
}
.card-title {
  display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px dashed var(--border);
}
.card-title::before {
  content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent-grad); flex: none;
}

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card .stat-ico {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.stat-card .stat-ico svg { width: 19px; height: 19px; }
.stat-card .stat-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.stat-card::after {
  content: ""; position: absolute; right: -24px; top: -24px; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(225, 29, 72, .07), transparent 70%);
}

/* ---------- 按钮 ---------- */
button, .btn {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text);
  transition: all .15s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .btn:hover { border-color: #cdd3e0; background: #f8f9fc; transform: translateY(-1px); }
button:active { transform: none; }
button.primary { background: var(--accent-grad); border: none; color: #fff; box-shadow: 0 4px 14px rgba(225, 29, 72, .3); }
button.primary:hover { box-shadow: 0 6px 18px rgba(225, 29, 72, .4); filter: brightness(1.05); }
button.green { background: var(--green-grad); border: none; color: #fff; box-shadow: 0 4px 14px rgba(22, 163, 74, .28); }
button.green:hover { filter: brightness(1.05); }
button.danger { background: #fff; border-color: #fecaca; color: #dc2626; }
button.danger:hover { background: #fef2f2; border-color: #f87171; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { background: #f1f2f7; color: var(--text); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn-icon { padding: 7px 10px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #4b5563; margin-bottom: 6px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=url], input[type=email],
input:not([type]), select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:not([type]), input[type=text], input[type=number], input[type=password], input[type=url], input[type=email], select {
  height: 38px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(225, 29, 72, .12);
}
textarea { resize: vertical; line-height: 1.55; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- 表格 ---------- */
.tbl-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #fafbfd; font-weight: 700; color: #5b6478; font-size: 12px; letter-spacing: .4px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid #f0f2f7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #fafbff; }
.tbl-title { font-weight: 600; }
.tbl-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-draft, .st-pending { background: #f1f2f6; color: #6b7280; }
.st-generating { background: #fef3c7; color: var(--amber); }
.st-ready { background: #dcfce7; color: var(--green); }
.st-selected, .st-doing { background: #dbeafe; color: var(--blue); }
.st-published, .st-done { background: var(--green-grad); color: #fff; }
.st-failed { background: #fee2e2; color: #dc2626; }
.st-reuse { background: #ede9fe; color: #7c3aed; }

/* ---------- 参考图 ---------- */
.ref-block { margin-top: 4px; }
.ref-block-title {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 10px; font-size: 13px;
}
.ref-list { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.ref-item {
  position: relative; width: 64px; flex: none; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; background: #fafbfd;
}
.ref-item img { width: 64px; height: 64px; object-fit: cover; display: block; }
.ref-item .ref-idx {
  position: absolute; top: 3px; left: 3px; background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 999px;
}
.ref-item .ref-del {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border: none; cursor: pointer;
  background: rgba(220, 38, 38, .9); color: #fff; border-radius: 999px; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.ref-item .ref-del:hover { background: #dc2626; }
.ref-row { display: flex; gap: 10px; align-items: stretch; width: 100%; }
.ref-row .style-desc-ta {
  flex: 1; min-width: 200px; min-height: 58px; height: auto;
  font-size: 11.5px; border-radius: 8px; align-self: center;
}
.size-sel {
  width: auto; min-width: 148px; font-size: 12.5px; height: 34px; padding: 0 8px;
}

/* ---------- 图片网格 ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.img-cell {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s;
}
.img-cell:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.img-cell .ph {
  width: 100%; aspect-ratio: 1; background: linear-gradient(135deg, #eef1f6, #e4e8f0);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: #9aa3b5; font-size: 12px; font-weight: 600; letter-spacing: 1px;
}
.img-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.img-wrap { position: relative; }
.img-wrap img { opacity: .45; filter: grayscale(.3); }
.img-wrap .gen-mask {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .55); color: #475569; font-size: 13px; font-weight: 700;
  border-radius: 8px; letter-spacing: 1px; animation: pulse 1.2s infinite;
}
.img-cell .ph.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.img-cell .cell-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0 6px; }
.img-cell .cell-name { font-weight: 700; font-size: 12.5px; }
.img-cell textarea { font-size: 12px; height: 84px; margin-bottom: 8px; border-radius: 8px; }
.img-cell .err { color: #dc2626; font-size: 12px; margin-bottom: 6px; word-break: break-all; background: #fef2f2; padding: 5px 8px; border-radius: 6px; }
.img-cell .err-msg {
  color: #dc2626; font-size: 12px; margin-bottom: 6px; background: #fef2f2; padding: 5px 8px;
  border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.img-cell .err-msg.open { white-space: normal; word-break: break-all; }

/* ---------- Tab ---------- */
.tabs {
  display: flex; gap: 6px; background: #eef0f5; padding: 4px; border-radius: 12px;
  width: fit-content; margin-bottom: 18px; flex-wrap: wrap;
}
.tabs button {
  border: none; background: transparent; padding: 8px 18px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: #64748b;
}
.tabs button.active { background: #fff; color: var(--accent); box-shadow: 0 2px 8px rgba(16, 24, 40, .1); }

/* ---------- 提示 ---------- */
#toast-box { position: fixed; top: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 18px; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: slideIn .25s ease; min-width: 200px; max-width: 380px;
}
.toast.ok { background: var(--green-grad); }
.toast.err { background: linear-gradient(135deg, #dc2626, #ef4444); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 进度 ---------- */
.progress { height: 8px; background: #eef0f5; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--green-grad); border-radius: 999px; transition: width .4s; }

/* ---------- 槽位/规格编辑器 ---------- */
.slot-head {
  display: flex; gap: 10px; align-items: center; padding: 0 10px 8px;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .3px;
  border-bottom: 1px dashed var(--border); margin-bottom: 10px;
}
.slot-row {
  display: flex; gap: 10px; margin-bottom: 10px; align-items: center;
  background: #fafbfd; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
}
.slot-row:hover { border-color: #d6dae6; background: #fff; }
.slot-row .slot-name { width: 150px; flex: none; font-weight: 600; }
.slot-row .slot-tag { color: var(--accent); font-weight: 700; font-size: 12px; }
.slot-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.slot-bar select { width: auto; min-width: 160px; }

/* ---------- 流程指引 ---------- */
.step-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.step-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fafbfd;
  position: relative; padding-left: 52px;
}
.step-item .step-no {
  position: absolute; left: 14px; top: 16px; width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent-grad); color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.step-item b { display: block; margin-bottom: 2px; }
.step-item p { color: var(--muted); font-size: 12px; }

/* ---------- 商品卡/抽卡结果 ---------- */
.gacha-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.gacha-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); transition: all .18s; position: relative; overflow: hidden;
}
.gacha-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #fda4af; }
.gacha-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent-grad); opacity: 0; transition: opacity .2s;
}
.gacha-card:hover::before { opacity: 1; }
.gacha-card .gc-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; line-height: 1.5; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: #f1f2f7; color: #4b5563;
  border-radius: 8px; padding: 3px 9px; font-size: 12px; margin: 2px 4px 2px 0;
}
.chip.red { background: #ffe4e6; color: var(--accent); }

/* ---------- 通用 ---------- */
.muted { color: var(--muted); }
.grow { flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.hr { border: none; border-top: 1px dashed var(--border); margin: 16px 0; }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 10px; }
.empty b { display: block; color: #6b7280; font-size: 14px; margin-bottom: 4px; }

@media (max-width: 960px) {
  .sidebar { position: static; width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; overflow: visible; }
  .sidebar .logo { padding: 0 14px 0 0; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar .side-foot { display: none; }
  .main { margin-left: 0; padding: 18px; }
}
