* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fa;
  color: #1f2329;
}
.hidden { display: none !important; }

/* login */
.login-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef3ff, #f5f7fa);
}
.login-card {
  width: 320px; background: #fff; padding: 32px 28px; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08); text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: #2f6fed; }
.login-card .sub { margin: 0 0 22px; color: #8a9099; font-size: 13px; }
.login-card input {
  display: block; width: 100%; margin: 10px 0; padding: 11px 12px;
  border: 1px solid #dfe3e8; border-radius: 8px; font-size: 14px;
}
.login-card button {
  width: 100%; padding: 11px; margin-top: 6px; border: 0; border-radius: 8px;
  background: #2f6fed; color: #fff; font-size: 15px; cursor: pointer;
}
.login-card button:hover { background: #2659c4; }
.login-card .hint { color: #aab0b8; font-size: 12px; margin: 14px 0 0; }

/* app */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: #fff; border-bottom: 1px solid #eaecef;
}
.brand { font-weight: 600; font-size: 17px; }
.brand .domain { color: #2f6fed; font-weight: 400; font-size: 13px; margin-left: 6px; }
.ghost {
  border: 1px solid #dfe3e8; background: #fff; color: #5a6168;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
}
.ghost:hover { border-color: #2f6fed; color: #2f6fed; }

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 16px 22px; background: #fff; border-bottom: 1px solid #eaecef;
}
.toolbar input, .toolbar select {
  padding: 9px 11px; border: 1px solid #dfe3e8; border-radius: 8px; font-size: 14px;
}
.toolbar #search { width: 240px; }
/* 排序方式下拉：显示「产品编码 ↑ 正序」等较长文案，单独给宽度；
   非默认排序时高亮，一眼能看出当前列表是按什么排的 */
.toolbar #sortSel { width: 172px; }
.toolbar #sortSel.active-sort { color: #2f6fed; font-weight: 600; background: #eef2fb; border-color: #bcd0f7; }
.toolbar button {
  padding: 9px 16px; border: 0; border-radius: 8px; background: #eef2fb; color: #2f6fed; cursor: pointer; font-size: 14px;
}
.toolbar button:hover { background: #e2e9f9; }
.import-btn {
  display: inline-flex; align-items: center; padding: 9px 16px; border-radius: 8px;
  background: #2f6fed; color: #fff; font-size: 14px; cursor: pointer;
}
.import-btn:hover { background: #2659c4; }
.stat { color: #8a9099; font-size: 13px; }

/* 保存按钮 + 未保存提示 */
.primary {
  padding: 9px 18px; border: 0; border-radius: 8px;
  background: #1f9d55; color: #fff; font-size: 14px; cursor: pointer; font-weight: 600;
}
.primary:hover { background: #178a49; }
.primary:disabled { background: #9fd3b3; cursor: default; }
.primary.pulse { box-shadow: 0 0 0 3px rgba(31,157,85,.18); }
.dirty { color: #e08a00; font-size: 13px; font-weight: 500; }

/* 列显示选择器 */
.col-wrap { position: relative; margin-left: auto; }
.col-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: #fff; border: 1px solid #eaecef; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10); padding: 6px; width: 180px;
  max-height: 320px; overflow: auto;
}
.col-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px;
  border-radius: 6px; font-size: 13px; cursor: pointer; color: #1f2329;
}
.col-item:hover { background: #f5f7fa; }
.col-item input { cursor: pointer; }
/* 长文本列：最多 15 汉字宽、3 行，超出省略号；点击弹窗看全文 */
.clamped { cursor: pointer; width: 15em; max-width: 15em; }
.clamped .clamp3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 15em;
  color: #41464c;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: break-word;
}
.clamped:hover { background: #f0f5ff !important; box-shadow: inset 0 0 0 1px #d6e2ff; }
.clamped .muted { color: #c4c9d0; }

/* 长文本查看 / 编辑弹窗 */
.view-modal .modal-card { width: 540px; }
#viewText {
  width: 100%; min-height: 220px; box-sizing: border-box;
  padding: 11px 12px; border: 1px solid #dfe3e8; border-radius: 8px;
  font-size: 14px; line-height: 1.6; resize: vertical; font-family: inherit; color: #1f2329;
}
#viewText:focus { outline: none; border-color: #2f6fed; box-shadow: 0 0 0 2px rgba(47,111,237,.12); }
.modal-hint { margin: 8px 0 18px; font-size: 12px; color: #aab0b8; }

main { padding: 18px 22px; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
th, td { padding: 11px 12px; border-bottom: 1px solid #f0f2f5; font-size: 13px; text-align: left; vertical-align: top; }
th { background: #fafbfc; color: #6b7280; font-weight: 600; }
tr:hover td { background: #fafcff; }
.thumb { width: 64px; }
.thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid #eee; }
.noimg { color: #c4c9d0; }
.pi { max-width: 220px; color: #5a6168; word-break: break-all; }

/* 可编辑单元格（缩略图除外） */
.ed { cursor: text; outline: none; }
.ed:hover { background: #f0f5ff !important; box-shadow: inset 0 0 0 1px #d6e2ff; }
.ed:focus { background: #fffbe6 !important; box-shadow: inset 0 0 0 2px #2f6fed; }
.del { border: 1px solid #f0c2c2; background: #fff; color: #d9534f; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.del:hover { background: #fdecec; }
.empty { text-align: center; color: #aab0b8; padding: 50px; background: #fff; border-radius: 10px; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 16px; color: #6b7280; font-size: 13px; }
.pager button { padding: 7px 16px; border: 1px solid #dfe3e8; background: #fff; border-radius: 8px; cursor: pointer; }
.pager button:hover { border-color: #2f6fed; color: #2f6fed; }
/* 首页/末页时置灰，避免点到空页（分组模式每页 20 款，页数比表格模式少） */
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:disabled:hover { border-color: #dfe3e8; color: inherit; }

/* 可排序表头（产品编码 / 库存位置） */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: #2f6fed; }
th.sortable.active { color: #2f6fed; }
th.sortable .arrow { font-size: 11px; opacity: .7; margin-left: 2px; }

/* 数量范围双框筛选 */
.qty-box { display: inline-flex; align-items: center; gap: 4px; }
.qty-box > label { font-size: 13px; color: #6b7280; }
.qty-box .qty-num { width: 64px; }
.qty-box .qty-num:focus { border-color: #2f6fed; outline: none; }
.qty-box .tilda { color: #b5bac1; }

/* 数量预警三档：=0 灰色(未盘点/无库存记录)；1~2 红色(快断货)；>30 荧光绿(库存充足)；3~30 不高亮 */
tr.qty-zero > td { background: #fafafa; }
tr.qty-zero > td.quantity {
  background: #ececec; color: #8a8f98; font-weight: 600;
  box-shadow: inset 0 0 0 1px #d6d8dc;
}
tr.qty-low > td { background: #fff5f5; }
tr.qty-low > td.quantity {
  background: #ffd7d3; color: #c02626; font-weight: 700;
  box-shadow: inset 0 0 0 1px #f5a9a2;
}
tr.qty-high > td { background: #f8fff1; }
tr.qty-high > td.quantity {
  background: #b4ff72; color: #1a6b23; font-weight: 700;
  box-shadow: inset 0 0 0 1px #7fd12e;
}
td.quantity { text-align: center; width: 72px; border-radius: 4px; }

/* 导入：清空后导入复选框 */
.clear-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #6b7280; cursor: pointer; user-select: none; }
.clear-chk input { cursor: pointer; }
.clear-chk:hover { color: #374151; }

/* 删除二次确认弹窗 */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); z-index: 100; }
.modal-card { background: #fff; border-radius: 12px; padding: 24px 26px; width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
.modal-title { margin: 0 0 10px; font-size: 16px; font-weight: 600; color: #1f2329; }
.modal-text { margin: 0 0 20px; font-size: 14px; color: #5a6168; line-height: 1.6; }
.modal-text b { color: #d9534f; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions .danger { border: 0; border-radius: 8px; background: #d9534f; color: #fff; padding: 8px 16px; cursor: pointer; font-size: 14px; }
.modal-actions .danger:hover { background: #c9302c; }

/* ===== 多尺码：按款式分组视图 ===== */
.group-view { display: flex; flex-direction: column; gap: 10px; }
.style-card { background: #fff; border: 1px solid #eaecef; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.04); overflow: hidden; }
.style-head { display: flex; align-items: flex-start; gap: 14px; padding: 12px 14px; cursor: pointer; }
.style-head:hover { background: #fafcff; }
.style-head .thumb { width: auto; }
.style-head .thumb img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; border: 1px #eee; }
.style-meta { flex: 0 0 20em; width: 20em; min-width: 0; }
.style-name { font-weight: 600; font-size: 14px; color: #1f2329; }
.style-name .code { color: #2f6fed; font-weight: 500; font-size: 13px; margin-left: 4px; }
.style-sub { color: #8a9099; font-size: 12px; margin-top: 2px; }
.size-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.size-chip { background: #eef2fb; border-radius: 99px; padding: 2px 10px; font-size: 12px; color: #374151; }
.size-chip b { margin-left: 4px; color: #1f2329; }
.size-chip.zero { background: #ececec; color: #8a8f98; }
.size-chip.low { background: #ffd7d3; color: #c02626; }
.size-chip.high { background: #b4ff72; color: #1a6b23; }
.style-total { flex: 0 0 auto; font-size: 13px; color: #1f9d55; font-weight: 600; white-space: nowrap; }
.style-arrow { color: #b5bac1; font-size: 12px; transition: transform .18s; }
.style-card.open .style-arrow { transform: rotate(90deg); }
.style-summary { padding: 0 14px 12px; border-top: 1px solid #f0f2f5; }
.style-detail { padding: 0 14px 14px; border-top: 1px solid #f0f2f5; }
.matrix { width: 100%; border-collapse: collapse; margin-top: 10px; background: #fff; box-shadow: none; }
.matrix th, .matrix td { border-bottom: 1px solid #f0f2f5; padding: 8px 10px; font-size: 13px; text-align: center; }
.matrix th { background: #fafbfc; color: #6b7280; font-weight: 600; }
.matrix td.sku { color: #5a6168; font-size: 12px; }
.matrix .qty-in { width: 68px; padding: 5px; text-align: center; border: 1px solid #dfe3e8; border-radius: 6px; font-size: 13px; }
.matrix .qty-in:focus { outline: none; border-color: #2f6fed; box-shadow: 0 0 0 2px rgba(47,111,237,.12); }
/* 头部中间空白区：字段横向铺开、固定列宽，填充「商品编码」与「总库存」之间的空隙 */
.style-info { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 14px 18px; flex: 1 1 auto; min-width: 0; }
.si-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.si-cell.si-w { flex: 0 0 5ch; width: 5ch; }              /* 重量(g)：5 个数字宽度 */
.si-cell.si-d { flex: 0 0 10em; width: 10em; }            /* 基础中文/英文描述：各 10 汉字宽 */
.si-cell.si-p { flex: 0 0 10em; width: 10em; }            /* 进货信息：10 汉字宽 */
.si-cell.si-l { flex: 0 0 5em; width: 5em; }             /* 库存位置：5 汉字宽 */
.si-k { font-size: 11px; color: #8a9099; white-space: nowrap; }
.si-v { font-size: 13px; color: #2b2f36; word-break: break-word; line-height: 1.45; }
.si-v.si-loc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-v.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.si-v.si-click { cursor: pointer; }
.si-v.si-click:hover { color: #2f6fed; text-decoration: underline dotted; }
/* 分组视图：点击截断描述弹出的完整文字（只读） */
.full-text-body { margin: 0 0 18px; padding: 11px 12px; background: #fafbfc; border: 1px solid #dfe3e8; border-radius: 8px; font-size: 14px; line-height: 1.7; color: #1f2329; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; }
/* 工具条：按款式分组 复选框 */
.group-chk { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #6b7280; cursor: pointer; user-select: none; }
.group-chk input { cursor: pointer; }
.group-chk:hover { color: #374151; }

/* ===== 多尺码：批量建款弹窗 ===== */
.bulk-modal .modal-card { width: 560px; }
.bulk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.bulk-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #6b7280; }
.bulk-grid .span2 { grid-column: 1 / -1; }
.bulk-grid input, .bulk-grid select { padding: 8px 10px; border: 1px solid #dfe3e8; border-radius: 8px; font-size: 14px; color: #1f2329; }
.bulk-grid input:focus, .bulk-grid select:focus { outline: none; border-color: #2f6fed; box-shadow: 0 0 0 2px rgba(47,111,237,.12); }
.bulk-preview { margin: 12px 0 4px; max-height: 190px; overflow: auto; border: 1px dashed #dfe3e8; border-radius: 8px; padding: 8px; background: #fbfcfe; }
.bulk-preview table { box-shadow: none; border-radius: 6px; }
.bulk-preview th, .bulk-preview td { padding: 6px 8px; font-size: 12px; }
.bulk-hint { color: #aab0b8; font-size: 12px; margin: 6px 0 0; line-height: 1.6; }

/* ===== 缩略图：多图角标 + 可点击 ===== */
.thumb-wrap { position: relative; display: inline-block; line-height: 0; }
.thumb-wrap .g-open { cursor: zoom-in; }
.style-head .thumb-wrap .g-open { cursor: zoom-in; }
.img-badge {
  position: absolute; right: -3px; bottom: -3px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: 8px; background: #2f6fed; color: #fff;
  font-size: 11px; font-weight: 600; line-height: 16px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); pointer-events: none;
}

/* ===== 多图查看器 ===== */
.gallery-modal { z-index: 140; }
.gal-card {
  background: #fff; border-radius: 12px; width: min(880px, 94vw); max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 60px rgba(0,0,0,.28);
}
.gal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #eef0f3; }
.gal-title-wrap { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.gal-title { font-size: 16px; font-weight: 600; color: #1f2329; font-family: ui-monospace, Menlo, Consolas, monospace; }
.gal-sub { font-size: 12px; color: #aab0b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-close { border: 0; background: transparent; font-size: 16px; color: #8a929b; cursor: pointer; padding: 4px 8px; }
.gal-close:hover { color: #1f2329; }
.gal-body { position: relative; display: flex; align-items: center; justify-content: center; background: #f7f8fa; min-height: 300px; flex: 1; overflow: hidden; }
.gal-body img { max-width: 100%; max-height: 60vh; object-fit: contain; display: block; cursor: zoom-in; background: #fff; }
.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.9); color: #1f2329; font-size: 24px; line-height: 1;
  box-shadow: 0 2px 10px rgba(0,0,0,.15); z-index: 2;
}
.gal-nav:hover:not(:disabled) { background: #fff; color: #2f6fed; }
.gal-nav:disabled { opacity: .35; cursor: default; }
#galPrev { left: 14px; }
#galNext { right: 14px; }
.gal-foot { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid #eef0f3; }
.gal-count { font-size: 12px; color: #6b7280; white-space: nowrap; }
.gal-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; flex: 1; }
.gitem { position: relative; flex: 0 0 auto; cursor: pointer; border: 2px solid transparent; border-radius: 8px; overflow: hidden; line-height: 0; }
.gitem img { width: 52px; height: 52px; object-fit: cover; display: block; }
.gitem.on { border-color: #2f6fed; }
.gitem .gn {
  position: absolute; left: 2px; bottom: 2px; background: rgba(0,0,0,.55); color: #fff;
  font-size: 10px; line-height: 1; padding: 2px 4px; border-radius: 4px;
}
.gal-urls { display: flex; align-items: center; gap: 10px; padding: 10px 18px 14px; border-top: 1px solid #eef0f3; flex-wrap: wrap; }
.gal-urls > div { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 320px; }
.gal-urls .u-k { flex: 0 0 auto; font-size: 11px; color: #aab0b8; }
.gal-urls code {
  font-size: 11px; color: #5a6168; background: #f6f7f9; border-radius: 6px;
  padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}

/* ===== 轻提示 ===== */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 12px);
  background: rgba(31,35,41,.94); color: #fff; font-size: 13px; line-height: 1.5;
  padding: 10px 18px; border-radius: 8px; max-width: 70vw;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
