:root {
  --bg: #f2f3f5;
  --panel: #ffffff;
  --line: #dee0e3;
  --line-soft: #eff0f1;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --brand: #3370ff;
  --brand-soft: #e8f3ff;
  --ok: #2ea121;
  --ok-soft: #e4f7e3;
  --warn: #d97706;
  --warn-soft: #fff7e8;
  --danger: #f54a45;
  --danger-soft: #feecec;
  --radius: 6px;
  --sidebar-w: 220px;
  --font: "PingFang SC", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
aside {
  width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 10px 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.brand { padding: 8px 12px 16px; font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.brand span { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--text-3); }
.nav-group { margin: 14px 12px 4px; font-size: 12px; color: var(--text-3); }
nav { display: flex; flex-direction: column; gap: 1px; }
nav a, nav button {
  all: unset; cursor: pointer; padding: 8px 12px; border-radius: var(--radius);
  font-size: 13px; color: var(--text-2); position: relative; display: block;
  text-decoration: none;
}
nav a:hover, nav button:hover { background: var(--line-soft); color: var(--text); }
nav a.active, nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
nav a.active::before, nav button.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--brand);
}
.aside-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--text-3); line-height: 1.5; }
.aside-foot a { color: var(--brand); text-decoration: none; }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-head {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 16px 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.page-head h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.page-head .desc { margin: 4px 0 0; font-size: 13px; color: var(--text-2); line-height: 1.5; max-width: 640px; }
.head-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.content { padding: 16px 24px 80px; flex: 1; overflow: auto; }
.screen { display: none; }
.screen.active { display: block; }
.btn {
  height: 32px; padding: 0 14px; border-radius: var(--radius); font-size: 13px;
  font-family: inherit; cursor: pointer; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.img-run-progress { display: none; }
.img-run-progress.show { display: block; }
.img-ver button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--text); }
.btn-xs { padding: 2px 8px; font-size: 12px; line-height: 1.3; width: auto; }
.stats {
  display: flex; flex-wrap: wrap; gap: 0; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px;
}
.stat {
  padding: 10px 16px; border-right: 1px solid var(--line-soft); font-variant-numeric: tabular-nums;
}
.stat:last-child { border-right: none; }
.stat .k { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.panel + .panel { margin-top: 12px; }
.panel h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.field { margin-bottom: 10px; }
input, select, textarea {
  width: 100%; height: 32px; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0 10px; font: inherit; color: var(--text); background: #fff;
}
textarea { height: 72px; padding: 8px 10px; resize: vertical; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
th { color: var(--text-3); font-weight: 500; background: #f8f9fa; }
tr:hover td { background: #f8f9fa; }
tr.row-on td { background: var(--brand-soft); }
.tag {
  display: inline-block; padding: 2px 6px; font-size: 12px; border-radius: 2px;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-neutral { background: var(--line-soft); color: var(--text-2); }
.muted { color: var(--text-3); font-size: 13px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--text-3); }
.kv .v { font-variant-numeric: tabular-nums; }
.kv .emph { font-weight: 600; color: var(--text); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }
.toast {
  position: fixed; right: 20px; bottom: 20px; background: var(--text); color: #fff;
  padding: 10px 14px; border-radius: var(--radius); font-size: 13px; display: none; z-index: 200;
}
.toast.show { display: block; }
.placeholder {
  padding: 32px; text-align: center; color: var(--text-2); border: 1px dashed var(--line);
  border-radius: var(--radius); background: var(--panel);
}
.api-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--text-3); }
.api-dot.up { background: var(--ok); }
.api-dot.down { background: var(--danger); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fad2d0; }
.btn-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde2b3; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 120px; }
table.data { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.tag-n { background: var(--line-soft); color: var(--text-2); }
.tag-w { background: var(--warn-soft); color: var(--warn); }
.tag-d { background: var(--danger-soft); color: var(--danger); }
.tag-g { background: #dcfce7; color: #166534; }
.tag-r { background: #fee2e2; color: #991b1b; }
.tag-b { background: var(--brand-soft); color: var(--brand); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.split > * { min-width: 0; overflow: auto; }
.split > table.data { align-self: start; height: max-content; }
.list-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  max-height: 2.8em;
}
#listDraftBox { overflow: auto; }
#listDraftBox table.data { min-width: 1080px; }
#listDraftBox table.data td, #listDraftBox table.data th { vertical-align: top; }
.sku-spec {
  min-width: 180px;
  max-width: 280px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.split3 { display: grid; grid-template-columns: 1fr 1.1fr 0.95fr; gap: 12px; }
@media (max-width: 1100px) {
  .split3, .split { grid-template-columns: 1fr; }
}
.thumb {
  width: 36px; height: 36px; border-radius: 4px; object-fit: cover;
  background: var(--line-soft); border: 1px solid var(--line); vertical-align: middle; margin-right: 8px;
}
.prep-hero { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.prep-hero-thumbs { display: flex; gap: 4px; flex-shrink: 0; }
.prep-hero-thumbs img {
  width: 40px !important;
  height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--line-soft);
  cursor: zoom-in;
}
.prep-cell { display: flex; gap: 8px; align-items: flex-start; max-width: 280px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-2); }
.panel { padding: 0; }
.panel-hd {
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; font-weight: 500;
}
.panel-bd { padding: 14px; }
.supplier {
  display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 8px; cursor: pointer;
}
.supplier.on { border-color: var(--brand); background: var(--brand-soft); }
.kv-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-2); }
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.step {
  font-size: 12px; color: var(--text-3); padding: 4px 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
}
.step.on { color: var(--brand); border-color: #b6ceff; background: var(--brand-soft); }
.bi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bi textarea { width: 100%; min-height: 130px; height: 130px; }
.note { padding: 8px 10px; border-radius: var(--radius); font-size: 12px; line-height: 1.5; margin: 10px 0; }
.note-ok { background: var(--ok-soft); color: var(--ok); }
.note-d { background: var(--danger-soft); color: var(--danger); }
.note-b { background: var(--brand-soft); color: var(--brand); }
.sticky {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.sticky .right { display: flex; gap: 8px; flex-wrap: wrap; }
.page-head .head-actions .btn { width: auto; }
input.tiny { width: 80px; }
.pack-fields { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.pack-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.pack-lab { font-size: 12px; color: var(--text-2); font-weight: 500; }
.pack-in { display: flex; align-items: center; gap: 4px; }
.pack-unit { font-size: 12px; color: var(--text-3); min-width: 1.6em; }

#prodDetailPanel {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, 0.45);
  display: none !important; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow: auto;
  pointer-events: none;
}
#prodDetailPanel.open {
  display: flex !important;
  pointer-events: auto;
}
#prodDetailPanel .detail-modal {
  width: min(920px, 100%);
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  margin-bottom: 40px;
}

.prod-gallery { min-width: 0; }
.gallery-main {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  cursor: zoom-in;
}
.gallery-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.gallery-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid var(--line);
  cursor: pointer;
  opacity: 0.85;
}
.gallery-thumb:hover { opacity: 1; }
.gallery-thumb.on {
  border-color: #0f766e;
  opacity: 1;
  box-shadow: 0 0 0 1px #0f766e;
}
.sku-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.zoomable { cursor: zoom-in; }

.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.82);
  padding: 24px;
}
.img-lightbox.open { display: flex; }
.img-lightbox img {
  max-width: min(96vw, 1100px);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  background: #fff;
}
.img-cmp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 12px;
}
.img-cmp .side {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 6px;
}
.img-cmp .side label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.img-cmp img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  background: #f7f7f8;
  cursor: zoom-in;
  border-radius: 4px;
}
.img-ver { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.img-ver button {
  height: 28px; font-size: 12px; padding: 0 10px;
  border: 1px solid var(--line); background: #fff; border-radius: var(--radius); cursor: pointer;
}
.img-ver button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.img-workbench {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  flex-direction: column;
  background: #0b1220;
  color: #e2e8f0;
}
.img-workbench.open { display: flex; }
.img-workbench-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #111827;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.img-workbench-hd .muted { color: #94a3b8; font-size: 12px; }
.img-workbench-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  background: #0f172a;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.img-workbench-tabs button {
  height: 40px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.img-workbench-tabs button.on {
  color: #f8fafc;
  border-bottom-color: var(--brand, #2563eb);
}
.img-workbench-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.img-workbench-side {
  padding: 12px;
  border-right: 1px solid rgba(255,255,255,.06);
  background: #0f172a;
}
.img-workbench-side img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #111;
  border-radius: 6px;
}
.img-workbench-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px;
}
.img-wb-pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.img-wb-pane.on { display: flex; }
.img-wb-schemes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.img-wb-scheme {
  text-align: left;
  border: 1px solid rgba(255,255,255,.12);
  background: #111827;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
}
.img-wb-scheme.on {
  border-color: var(--brand, #2563eb);
  background: rgba(37, 99, 235, 0.18);
}
.img-wb-scheme b { display: block; font-size: 13px; margin-bottom: 4px; }
.img-wb-scheme span { font-size: 12px; color: #94a3b8; }
.fabric-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.fabric-toolbar .btn.on {
  border-color: var(--brand, #2563eb);
  background: rgba(37, 99, 235, 0.16);
}
.fabric-tool-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
}
.fabric-tool-label input[type="range"] { width: 90px; }
.fabric-tool-label input[type="color"] {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
}
.fabric-stage {
  flex: 1;
  min-height: calc(100vh - 220px);
  background:
    linear-gradient(45deg, #1e293b 25%, transparent 25%),
    linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%),
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #0f172a;
  border-radius: 8px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
}
.fabric-stage .canvas-container {
  margin: 0 auto;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
@media (max-width: 900px) {
  .img-workbench-body { grid-template-columns: 1fr; }
  .img-workbench-side { display: none; }
}

.img-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #0f172a;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.cat-pick {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbfc;
  padding: 10px;
  max-height: 360px;
  overflow: auto;
}
.cat-pick-status { margin-bottom: 8px; line-height: 1.45; }
.cat-pick-status.ok { color: var(--ok); }
.cat-pick-status.wait { color: var(--text-2); }
.cat-pick-levels { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pick-levels label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.cat-pick-levels select { min-width: 140px; height: 32px; }
.cat-leaf-list { max-height: 240px; overflow: auto; margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.cat-leaf {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
}
.cat-leaf .name { display: block; font-weight: 500; }
.cat-leaf .path { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; }
.cat-leaf.on { border-color: var(--brand); background: var(--brand-soft); }
.attr-board {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfbfc;
}
.attr-spu-title { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.attr-spu td { vertical-align: top; }
.attr-head { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; flex-wrap: wrap; }
.attr-head .btn { width: auto; padding: 4px 10px; font-size: 12px; }
.attr-catalog td { vertical-align: top; }

.hist-list { list-style: none; margin: 0; padding: 0; }
.hist-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.hist-list li.bad { border-color: #fecaca; background: #fff7f7; }
.hist-list li.ok { background: #f8fafc; }
.hist-hd { display: flex; justify-content: space-between; gap: 8px; font-weight: 500; margin-bottom: 2px; }

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 28px 24px;
  box-shadow: 0 8px 28px rgba(31, 35, 41, 0.06);
}
.login-card .brand { padding: 0 0 18px; }
.login-card .field { display: block; margin-bottom: 12px; }
.login-card .field span { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.login-card .field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  font-family: inherit;
  font-size: 14px;
}
.login-err { color: var(--danger); font-size: 13px; margin: 0 0 12px; }


