/* ============================================================
   共享文档系统 - 前端设计系统
   风格:简洁、留白充分、克制的强调色,不依赖任何图标字体/外部字体
   ============================================================ */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2430;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-soft-text: #4338ca;

  --success: #16a34a;
  --success-soft: #ecfdf3;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --muted-soft: #f3f4f6;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);

  --sidebar-w: 224px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #7c72f0);
  flex-shrink: 0;
}

.nav-group { margin-bottom: 18px; }

.nav-label {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--muted-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-soft-text); }
.nav-item svg { flex-shrink: 0; opacity: .85; }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.user-chip:hover { background: var(--muted-soft); }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 60px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.page-desc { color: var(--text-muted); font-size: 13px; margin: 0; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- 卡片 / 表面 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: box-shadow .15s ease, border-color .15s ease, transform .1s ease;
}
.doc-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }

.doc-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.doc-card-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-card-meta { color: var(--text-muted); font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
/* 别人正在编辑的格子:橙色虚线框 + 编辑人悬停提示,点了也进不去 */
.cell-locked { outline: 1.5px dashed #f59e0b; outline-offset: -1.5px; background: rgba(245, 158, 11, .08) !important; cursor: not-allowed !important; }
.cell-locked-input { outline: 1.5px dashed #f59e0b; background: rgba(245, 158, 11, .08); cursor: not-allowed; }
/* 直接显示在格子上的"谁在编辑",不用悬停才能看到 */
.cell-lock-tag { display: block; width: fit-content; max-width: 100%; margin-bottom: 3px; padding: 0 5px; border-radius: 3px; background: #f59e0b; color: #fff; font-size: 11px; font-weight: 600; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-box.cell-collapsed .cell-lock-tag { display: inline-block; margin: 0 4px 0 0; vertical-align: middle; }
.tracking-cell-box .cell-copy-btn, .tracking-line .cell-copy-btn { flex-shrink: 0; }
.doc-groups { display: flex; flex-direction: column; gap: 14px; }
.doc-card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); cursor: default; }
.doc-card-delete { color: #d92d20; }
.doc-card-rejected { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: rgba(217, 45, 32, .08); color: #b42318; font-size: 12px; cursor: default; }
.doc-transfer-note { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: rgba(245, 158, 11, .12); color: #92400e; font-size: 12.5px; }
.review-count { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: #d92d20; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.review-history-title { margin: 22px 0 10px; font-size: 14px; color: var(--text-muted); font-weight: 600; }
.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 18px; }
.review-item-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--muted-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease, opacity .12s ease;
  white-space: nowrap;
}
.btn:hover { background: #e9eaee; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--muted-soft); color: var(--text); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-icon { width: 30px; padding: 0; }

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.input, .select, textarea.textarea {
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea.textarea { height: auto; padding: 8px 12px; min-height: 70px; resize: vertical; }
.input:focus, .select:focus, textarea.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder { color: var(--text-faint); }

.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

.hint { font-size: 12px; color: var(--text-faint); margin-top: -8px; margin-bottom: 12px; }
.error-text { font-size: 12.5px; color: var(--danger); margin-top: -8px; margin-bottom: 12px; }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .01em;
}
.badge-indigo { background: var(--primary-soft); color: var(--primary-soft-text); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-gray { background: var(--muted-soft); color: var(--text-muted); }
/* "未选择"占位胶囊(是否印字/发货状态用):跟"单号"格子里空白胶囊同一个样子——
   灰色虚线、不加粗;平时不显示,只在这一行被悬停/编辑时才露出来(见下面的悬停规则)。 */
.badge-select-blank {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-faint);
  font-weight: 400;
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
/* 发货登记表容易又宽又长(多行内容+很多列)。限制这个容器自身的高度,
   让横向滚动条(以及纵向滚动条)始终出现在这个盒子的底部/右侧,
   而不是被推到页面最下面、要把整页拉到底才够得着。 */
.table-wrap-scroll {
  max-height: 56vh;
  min-height: 200px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
/* 拖拽手柄——按住它上下拖动调整选项顺序,不是拖整行,避免手一抖点到颜色/文字输入框
   上把正常编辑操作误触成拖拽。拖走的那一行半透明,拖到谁上面谁就露出一条高亮线。 */
.option-drag-handle {
  flex-shrink: 0;
  width: 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}
.option-drag-handle:hover { color: var(--text-muted); }
.option-drag-handle:active { cursor: grabbing; }
.option-row.dragging { opacity: .4; }
.option-row.drop-target { outline: 1.5px dashed var(--primary); outline-offset: -1.5px; }
.color-swatch {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  background: none;
}

/* 产品大类底下展开的"规格关联"面板——勾哪些产品规格属于这个大类 */
.spec-relation-panel {
  margin: -2px 0 4px 24px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--muted-soft);
}
.spec-relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  opacity: .5;
}
.spec-relation-chip input { cursor: pointer; }
.spec-relation-chip.checked { opacity: 1; }

/* "新增产品"弹窗大类字段的输入筛选+下拉选择组合框。下拉列表故意不用 position:absolute
   悬浮展示——弹窗内容区本身是 overflow-y:auto 的滚动容器,悬浮层会被它裁掉一截,
   干脆让下拉列表撑在正常文档流里,弹窗跟着一起滚动,不会有裁切问题。 */
.combobox-dropdown {
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.combobox-option {
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.combobox-option:hover, .combobox-option.highlighted { background: var(--muted-soft); }
.combobox-option.selected { font-weight: 700; color: var(--primary); }
.combobox-empty {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-faint);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

table.grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 100%;
  font-size: 13px;
}
/* 发货登记表用固定列宽布局:每一列宽度取自 th 上设置的宽度,
   内容超宽时只能在这一列内部换行/省略,不会把列越撑越宽。 */
table.grid.grid-fixed { table-layout: fixed; }

table.grid th {
  position: sticky;
  top: 0;
  background: #fafafb;
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  z-index: 1;
}
/* 每一列表头右边缘一条看不见的拖拽条,拖它左右移动可以调整这一列的宽度(table-layout:
   fixed 下改 th 的宽度,同一列所有格子都跟着变);平时透明,悬停/拖拽时才给一条高亮线提示。 */
.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
}
.col-resize-handle:hover,
.col-resize-handle:active {
  background: var(--primary);
  opacity: .35;
}
table.grid td {
  border-bottom: 1px solid var(--border);
  padding: 0;
  white-space: nowrap;
  vertical-align: top;
}
table.grid tbody tr:hover { background: var(--surface-hover); }
table.grid tbody tr:last-child td { border-bottom: none; }
/* 最左边"折叠按钮 + 序号"这一列悬浮固定,不管表格横向滚动到哪儿都贴在可视区域左边——
   不用先滚回最左边才能点到某一行的折叠按钮。td 自己需要一个不透明底色,不然横向滚动
   经过的其它格子内容会从底下透出来;表头那个角上的格子(同时悬浮在上边+左边)层级
   要比左边这一整列更高,不然横向滚动时会被普通表头盖住。 */
.col-sticky-left {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 2px 0 4px rgba(17, 24, 39, .06);
}
th.col-sticky-left { z-index: 3; background: #fafafb; }
table.grid tbody tr:hover .col-sticky-left { background: var(--surface-hover); }
.row-header-cell {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 8px;
}
/* 右边"修改历史/删除"这一列跟左边"折叠按钮"是同一个思路——悬浮固定在可视区域
   右边,横向滚动到哪儿都点得到,不用先滚到最右边。阴影方向相反(往左投),
   提示"这一列浮在别的格子上面"。 */
.col-sticky-right {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: -2px 0 4px rgba(17, 24, 39, .06);
}
th.col-sticky-right { z-index: 3; background: #fafafb; }
table.grid tbody tr:hover .col-sticky-right { background: var(--surface-hover); }

.field-picker { position: relative; }
.field-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  z-index: 50;
  min-width: 190px;
  max-height: 280px;
  overflow-y: auto;
}
.field-picker-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.field-picker-actions a { color: var(--primary); }
.field-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 2px;
  font-size: 13px;
  cursor: pointer;
}
.field-picker-item input { cursor: pointer; }

.filter-box { display: flex; flex-direction: column; gap: 4px; }
.filter-box label { font-size: 11px; color: var(--text-faint); font-weight: 600; }
.filter-box .input { width: 150px; height: 34px; }

.th-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.th-inner span:first-child { overflow: hidden; text-overflow: ellipsis; }
.tri-group { display: flex; flex-direction: column; gap: 3px; cursor: pointer; flex-shrink: 0; }
.tri-up, .tri-down {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: .9;
}
.tri-up { border-bottom: 5px solid var(--border-strong); }
.tri-down { border-top: 5px solid var(--border-strong); }
.tri-up:hover, .tri-down:hover { opacity: 1; }
.tri-up.active { border-bottom-color: var(--primary); }
.tri-down.active { border-top-color: var(--primary); }

.cell-box {
  position: relative;
  padding: 8px 12px;
  min-width: 90px;
  min-height: 100%;
  height: 100%;
  cursor: text;
  border: 1px solid transparent;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}
.cell-box:hover { background: #f8f9fb; }
/* 日期/店铺 格子右下角的灰色加号——像 Excel 的填充柄,按住往下拖可以把这一格
   内容拷贝到下面的空白格子;平时半透明,悬停这个格子才完全显示、方便抓取。 */
.fill-handle {
  position: absolute;
  right: 1px;
  bottom: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  cursor: crosshair;
  opacity: 0;
  transition: opacity .12s, color .12s;
}
.cell-box:hover .fill-handle { opacity: .8; }
.fill-handle:hover { opacity: 1; color: var(--primary); }
/* 拖拽经过、即将被填充的目标格子:虚线高亮,和 Excel 拖拽预览一个意思 */
.cell-box.fill-target {
  outline: 1.5px dashed var(--primary);
  outline-offset: -1.5px;
  background: var(--primary-soft);
}
.cell-box.cell-wrap {
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
}
.cell-box.cell-collapsed {
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cell-box.cell-readonly {
  cursor: default;
}
.cell-box.cell-readonly:hover {
  background: transparent;
}

/* 拷贝按钮。按钮定位在 td 上而不是 .cell-box 上:.cell-box 的高度只有内容那么高,
   同一行别的格子更高时,贴着它就到不了单元格真正的右下角。
   格子编辑时隐藏,不盖住输入框。 */
.cell-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.cell-copy-btn:hover { background: var(--primary-soft); color: var(--primary); }
/* 名称/成本计算公式的每一项:文字占满左边,拷贝按钮靠右对齐;文字折行时按钮对齐这一项的最后一行 */
.cell-item-line { display: flex; align-items: flex-end; gap: 4px; }
.cell-item-text { flex: 1; min-width: 0; }
.cell-item-line .cell-copy-btn { flex: none; }
.cell-copy-host { position: relative; }
.cell-copy-host .cell-box { padding-right: 28px; }
.cell-copy-corner { position: absolute; right: 3px; bottom: 3px; }
/* 不能用 :focus-within:按下鼠标时按钮自己拿到焦点就被隐藏了,点击会落空 */
.cell-copy-host:has(.cell-editing) .cell-copy-corner { display: none; }

/* 成本计算公式:SKU 和数量可以双击修改,"+"单独一行居中,还没填的"?"标红 */
.cost-formula { white-space: normal; word-break: break-word; }
.cost-formula-plus { text-align: center; font-weight: 600; }
.cost-formula-editable { cursor: pointer; border-radius: 3px; user-select: none; }
.cost-formula-editable:hover { background: var(--primary-soft); }
.cost-formula-missing { color: #d92d20; font-weight: 700; padding: 0 4px; background: rgba(217, 45, 32, .1); }
.cost-formula-select, .cost-formula-input { height: 24px; font-size: 12px; padding: 0 4px; }
.cost-formula-input { width: 64px; }

/* 备注格子:文字部分还是普通的 EditableCell(.cell-box),不额外改它的样式;
   这里只负责文字下面那一栏图片(一图一行,宽度自适应单元格)的外观。
   .remark-cell-wrapper 把"文字格子"和"图片栏"竖着摞在一起,所以要把
   .cell-box 原本"撑满整个格子高度"的规则去掉,改成按内容自然高度。 */
.remark-cell-wrapper { display: flex; flex-direction: column; }
.remark-cell-wrapper .cell-box { height: auto; min-height: 34px; }
.remark-images-wrap { display: flex; flex-direction: column; gap: 6px; padding: 6px 12px 10px; }
.remark-images { display: flex; flex-direction: column; gap: 6px; }
.remark-image-item { position: relative; }
.remark-image-item img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--muted-soft);
  cursor: zoom-in;
}
.remark-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(17, 24, 39, .6);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.remark-image-remove:hover { background: rgba(17, 24, 39, .85); }
/* 默认只显示一个小图标,不常驻占位置;点它才会弹出系统的选择文件对话框 */
.remark-upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  padding: 0;
  border-radius: 6px;
  color: var(--text-faint);
  background: var(--muted-soft);
  cursor: pointer;
  flex-shrink: 0;
  font: inherit;
}
.remark-upload-icon:hover { color: var(--primary); background: var(--primary-soft); }
.remark-upload-icon:disabled { cursor: default; opacity: .55; }
/* "选择图片"/"粘贴图片"两个按钮并排放,不能被 .remark-images-wrap 的纵向 flex 影响 */
.remark-upload-row { display: flex; flex-direction: row; gap: 6px; }
/* 只在这一行被鼠标悬停、或行内正在编辑(有控件拿到焦点)时才露出"添加图片"
   这一排按钮,平时收起来,减少表格里常驻的视觉干扰。 */
table.grid tbody tr:not(:hover):not(:focus-within) .remark-upload-row {
  display: none;
}

/* "单号"格子:只读态一行一条(类型胶囊 + 单号文字);可编辑态是常驻的结构化
   控件——每条一行"类型胶囊 + 单号输入框",结尾固定留一行"空白"占位方便新增。 */
.tracking-line {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  flex-wrap: wrap;
}
.tracking-value { word-break: break-all; white-space: pre-wrap; }
.tracking-cell-box {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100%;
  box-sizing: border-box;
  width: 100%;
}
.tracking-entry-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
/* 用 textarea 的那种(比如"印字内容")内容长了会自动长高,胶囊/打叉按钮要贴顶对齐,
   不然内容一多、中间垂直居中就会显得很奇怪;单行 input 的格子(比如"单号")不受影响。 */
.tracking-entry-row.tracking-entry-row-multiline {
  align-items: flex-start;
}
.tracking-entry-row.tracking-entry-row-multiline .tracking-type-select {
  margin-top: 1px;
}
/* 两条以上真实内容才出现的拖拽手柄——按住它上下拖动调整胶囊顺序,不是拖整行,
   避免手一抖点到里面的下拉框/输入框/按钮上,把正常点击操作误触成拖拽。 */
.tracking-entry-drag-handle {
  flex-shrink: 0;
  width: 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1;
  cursor: grab;
  user-select: none;
}
.tracking-entry-drag-handle:hover { color: var(--text-muted); }
.tracking-entry-drag-handle:active { cursor: grabbing; }
/* 正在被拖走的那一行半透明一下,拖到谁上面谁就露出一条高亮线提示"放这儿" */
.tracking-entry-row-dragging { opacity: .4; }
.tracking-entry-row-drop-target {
  outline: 1.5px dashed var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
/* 胶囊尺寸对齐"发货状态"用的 .badge(padding 2px 9px、11.5px/700):
   右边只多留够放下拉箭头的宽度,不再像原来 3px 20px 3px 10px 那样一大截空白。 */
.tracking-type-select {
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 999px;
  padding: 2px 16px 2px 9px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .01em;
  cursor: pointer;
  background-color: var(--muted-soft);
  color: var(--text-muted);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  background-size: 7px;
}
.tracking-type-select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
/* 未选择状态和"发货状态"一样不当成一个实心徽章显示——不填色、不加粗,
   只留一个很淡的下拉箭头,选中拱门/风机之后才变成实心胶囊(见上面的内联 style)。 */
.tracking-type-select.tracking-type-select-blank {
  background-color: transparent;
  color: var(--text-faint);
  font-weight: 400;
  letter-spacing: normal;
  border: 1px dashed var(--border);
}
/* "未选择"这一行是留给"新增下一条"用的占位行,平时不需要占视线——只在
   这一行所在的表格行被鼠标悬停、或行内有控件获得焦点(正在编辑)时才露出来。
   "是否印字"/"发货状态"的"未选择"占位胶囊也走同一条规则。 */
table.grid tbody tr:not(:hover):not(:focus-within) .tracking-entry-row-blank,
table.grid tbody tr:not(:hover):not(:focus-within) .badge-select-blank {
  display: none;
}
.tracking-entry-input {
  flex: 1;
  min-width: 0;
  width: 0; /* 强制按 flex 分配宽度,避免 input 默认尺寸把行撑宽 */
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: inherit;
  box-sizing: border-box;
}
.tracking-entry-input:focus { outline: none; border-color: var(--primary); }
/* multiline 模式(比如"印字内容"):文字到格子宽度就自动折行,高度跟着内容自动长高
   (JS 算好 scrollHeight 设过来),这里只需要关掉自带的拖拽把手和滚动条。 */
.tracking-entry-textarea {
  height: 26px; /* 初始高度跟单行 input 一致,JS 会在有内容后自动往高了调 */
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
  padding-top: 4px;
  padding-bottom: 4px;
}
/* 打叉删除按钮:不能用 position:absolute(没有专门的定位锚点,会飘到别处),
   就用普通的 flex 子项内联小圆按钮,和备注图片的删除按钮是同一个思路。 */
.tracking-entry-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  border: none;
  background: rgba(17, 24, 39, .12);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.tracking-entry-remove:hover { background: rgba(217, 45, 32, .18); color: #d92d20; }
/* optionalValue 格子(比如"印字内容")选完类型先只给这个"+"号,点了才出现输入框 */
.tracking-entry-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.tracking-entry-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
/* 点了"+"号出现输入框之后,前面胶囊文字后面补一个冒号,提示"这条带说明了" */
.tracking-entry-colon { flex-shrink: 0; color: var(--text-muted); font-size: 12.5px; }

.cell-editing {
  padding: 0;
}
.cell-editing input, .cell-editing textarea, .cell-editing select {
  width: 100%;
  height: 100%;
  min-height: 34px;
  border: none;
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  box-sizing: border-box;
}
.cell-editing select.cell-select {
  cursor: pointer;
}
/* "是否印字"/"发货状态"正在编辑、且当前还没选值时,下拉框本身也做成跟
   "单号"格子空白胶囊一样的灰色虚线小胶囊,不是不选中就摆一个大方框。 */
.cell-editing select.cell-select.cell-select-badge-blank {
  width: auto;
  height: auto;
  min-height: 0;
  display: inline-flex;
  padding: 2px 18px 2px 9px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  outline: none;
  background-color: transparent;
  color: var(--text-faint);
  font-weight: 400;
  font-size: 11.5px;
}
.cell-editing textarea { resize: vertical; display: block; }
.cell-empty { color: var(--text-faint); }
.cell-actions { padding: 6px 10px; display: flex; gap: 4px; }

/* ---------- 选项卡 ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- 弹层 ---------- */

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 18, 25, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal.modal-lg { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15.5px; font-weight: 700; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}

/* ---------- 提示 / 空状态 ---------- */

.toast-stack {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { opacity: .5; margin-bottom: 12px; }
.empty-state .empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }

.loading-block { padding: 40px; text-align: center; color: var(--text-muted); font-size: 13px; }

.center-screen {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f5f6fb 0%, #eef0f8 100%);
}

.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.login-brand h1 { font-size: 17px; margin: 0; }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 12.5px; }

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-danger { color: var(--danger); }
.mono { font-variant-numeric: tabular-nums; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { display: flex; gap: 8px; align-items: center; }
.mt-0 { margin-top: 0; }
.w-full { width: 100%; }

.history-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-row:last-child { border-bottom: none; }
.history-time { color: var(--text-faint); font-size: 11.5px; white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d7d9de; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #c2c5cc; }

/* ---------- 产品图库 ---------- */

/* 大类框双列排放,不然屏幕右边一大片空白;用多栏布局(不是 grid)是因为每个大类框
   高矮不一(卡片数量、每个卡片的图片数量都不一样),grid 两列会被最高的那个顶到一样高,
   矮的那栏底下照样空一截——多栏布局能让内容按实际高度顺流排布,不会留这种空档。
   屏幕窄的时候收成单列,不然一栏都塞不下还会挤变形。 */
/* 大类框分栏:哪个框放哪一栏由 ProductImages.js 按行数算好(宽屏两栏,窄于 900px 一栏),
   这里只负责把这几栏并排摆开 */
.product-category-grid {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}
.product-category-column { flex: 1; min-width: 0; }

/* 同一个大类下的所有分组卡片放在同一个框里,视觉上跟别的大类分开 */
.product-category-box {
  border: 1px solid #5fc4bb;
  border-radius: var(--radius);
  background: #81d8d0; /* 蒂芙尼蓝底色,里面白色的分组卡片跟它对比更清楚 */
  padding: 16px;
  margin-bottom: 20px;
  break-inside: avoid; /* 多栏布局下不让一个大类框被从中间断开分到两栏 */
}
/* 大类框之间拖动调顺序时的状态——跟分组卡片/选项设置页面是同一套视觉语言 */
.product-category-box.cat-dragging { opacity: .4; }
.product-category-box.cat-drop-target { outline: 1.5px dashed var(--primary); outline-offset: -1.5px; }
/* 拖大类框时浮在屏幕底部的拖放栏:页码(停一下翻页)+ 放到最前/最后 */
.category-drag-dock {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(17, 24, 39, .18);
}
.category-drag-dock-zone,
.category-drag-dock-page {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-muted);
  user-select: none;
}
.category-drag-dock-zone { padding: 8px 14px; }
.category-drag-dock-page { min-width: 34px; padding: 6px 8px; text-align: center; }
.category-drag-dock-page.current { border-style: solid; border-color: var(--primary); color: var(--primary); }
.category-drag-dock-zone.over,
.category-drag-dock-page.over { border-style: solid; border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-text); }
.product-category-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.product-category-box-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer; /* 双击可以给这个大类添加其它规格 */
}

.product-image-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.product-image-group:last-child { margin-bottom: 0; }
/* 分组卡片之间拖动调顺序时的状态——跟"选项设置"页面的 option-row 是同一套视觉语言 */
.product-image-group.card-dragging { opacity: .4; }
.product-image-group.card-drop-target { outline: 1.5px dashed var(--primary); outline-offset: -1.5px; }
.product-image-group-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.product-image-group-label { font-weight: 700; font-size: 14px; cursor: pointer; /* 双击可以修改印字/灯笼/夜光 */ }
/* 分组卡片里每个产品(SKU)一个可删除的胶囊,代替原来纯文字的规格列表 */
.product-image-group-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.product-item-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  font-size: 12px;
  font-weight: 600;
}
.product-item-chip-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  font-size: 13px;
  line-height: 1;
  padding: 2px;
}
.product-item-chip-remove:hover { opacity: 1; }
.product-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
/* 图片卡片本身就是拖拽手柄(整张卡片可拖),同一个产品的卡片之间互拖调顺序 */
/* 统一按 1:1 方框展示:图片长宽比各不一样,用 contain 整张缩进方框里(不裁切),空出来的地方留白 */
.product-image-card {
  position: relative;
  width: 96px;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: grab;
  flex-shrink: 0;
}
.product-image-card:active { cursor: grabbing; }
.product-image-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
}
.product-image-card.dragging { opacity: .4; }
.product-image-card.drop-target { outline: 2px dashed var(--primary); outline-offset: -2px; }
.product-image-card-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(17, 24, 39, .6);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-image-card-remove:hover { background: rgba(17, 24, 39, .85); }
.product-image-add {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  border: 1px dashed var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-faint);
  cursor: pointer;
  flex-shrink: 0;
}
.product-image-add:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
/* "粘贴截图"是最常用的加图方式,默认就用主色突出,排在"本地文件"前面 */
.product-image-paste {
  font: inherit;
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}
.product-image-paste:disabled { opacity: .6; cursor: progress; }
/* 当前 Ctrl+V 会贴到的分组卡片 */
.product-image-group.paste-target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.paste-target-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--primary-soft-text);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 2px 8px;
}
/* 分组卡片标题右侧的"删除子类"按钮;前面有粘贴提示时贴着提示放 */
.product-image-group-remove { margin-left: auto; align-self: center; height: 24px; padding: 0 8px; font-size: 12px; }
.paste-target-hint + .product-image-group-remove { margin-left: 0; }
/* "上传产品图"弹窗里的粘贴区 */
.paste-zone {
  min-height: 140px;
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-soft-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
}
.paste-zone.filled { background: var(--surface); border-style: solid; border-color: var(--border); }
.paste-zone img { max-width: 100%; max-height: 280px; display: block; border-radius: 4px; }

/* 库存台账里的产品缩略图,点击看大图 */
.inventory-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--muted-soft);
  cursor: zoom-in;
}
.inventory-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.inventory-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-faint);
  cursor: default;
}

/* 新建成本表格弹窗:可多选的发货登记文档列表 */
.cost-source-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.field label.cost-source-item {
  font-weight: 400;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.cost-source-item:last-child { border-bottom: none; }
.cost-source-item:hover { background: var(--surface-hover); }
.cost-source-item.disabled { opacity: .45; cursor: not-allowed; }
.cost-source-name { font-weight: 600; }

/* 成本表格:勾选用于多行粘贴的行 */
table.grid tbody tr.cost-row-selected,
table.grid tbody tr.cost-row-selected:hover { background: var(--primary-soft); }

/* 只读的人不能拷贝文档内容,见 ui.js 的 copyGuard */
.no-copy, .no-copy * { -webkit-user-select: none; user-select: none; }
.no-copy .cell-copy-btn { display: none !important; }
.no-copy input, .no-copy textarea { -webkit-user-select: text; user-select: text; }

/* 账号权限勾选 */
.perm-picker { display: flex; flex-direction: column; gap: 12px; }
.perm-group-name { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.perm-group-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; }
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.perm-item.disabled { opacity: .55; cursor: not-allowed; }
