:root {
  --brand: #1677ff;
  --brand-dark: #0b56c9;
  --text: #101828;
  --sub: #667085;
  --line: #eaecf0;
  --bg: #f5f7fa;
  --ok: #12b76a;
  --warn: #f79009;
  --danger: #f04438;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::placeholder {
  color: #98a2b3;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
}

/* ---------------------------- 登录 ---------------------------- */

.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 20% 10%, #e8f1ff 0%, #f7f9fc 45%, #eef2f8 100%);
  z-index: 50;
}

.login-card {
  width: 380px;
  padding: 40px 36px 32px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.12);
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3b8cff, #0b56c9);
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.login h1 {
  margin: 18px 0 6px;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.login p {
  margin: 0 0 24px;
  color: var(--sub);
  font-size: 13px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--sub);
}

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

textarea.input {
  height: auto;
  min-height: 96px;
  padding: 12px 14px;
  line-height: 1.6;
  resize: vertical;
}

.btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: #d0d5dd;
  background: #fafbfc;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-danger {
  color: var(--danger);
  border-color: #fecdca;
  background: #fffbfa;
}

.btn-danger:hover {
  background: #fef3f2;
}

.btn-block {
  width: 100%;
  height: 46px;
  font-size: 15px;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

.login-tip {
  margin-top: 18px;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.7;
}

.alert {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef3f2;
  color: #b42318;
  font-size: 13px;
}

/* ---------------------------- 布局 ---------------------------- */

.app {
  display: none;
  min-height: 100%;
}

.app.ready {
  display: flex;
}

.sidebar {
  width: 216px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b8cff, #0b56c9);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-name {
  font-weight: 600;
  letter-spacing: 0.4px;
}

.brand-sub {
  font-size: 11px;
  color: var(--sub);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  color: #475467;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
  border: none;
  background: none;
  text-align: left;
}

.nav-item:hover {
  background: #f2f4f7;
}

.nav-item.active {
  background: #eaf2ff;
  color: var(--brand);
  font-weight: 500;
}

.nav-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.sidebar-foot {
  position: absolute;
  bottom: 20px;
  left: 14px;
  right: 14px;
  font-size: 11px;
  color: #98a2b3;
  line-height: 1.6;
  padding: 0 8px;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 22px 28px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.page-desc {
  margin: 6px 0 0;
  color: var(--sub);
  font-size: 13px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eaf2ff;
  color: var(--brand);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------------------- 卡片 / 表格 ---------------------------- */

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-weight: 600;
  font-size: 15px;
}

.card-hint {
  color: var(--sub);
  font-size: 12px;
  margin-top: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--sub);
  font-size: 12px;
}

.stat-num {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  margin-top: 4px;
  font-size: 12px;
  color: #98a2b3;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search .input {
  padding-left: 36px;
  height: 40px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 11px;
  width: 16px;
  height: 16px;
  border: 2px solid #98a2b3;
  border-radius: 50%;
  opacity: 0.7;
}

.search-icon::after {
  content: '';
  position: absolute;
  right: -5px;
  bottom: -4px;
  width: 6px;
  height: 2px;
  background: #98a2b3;
  transform: rotate(45deg);
}

select.input {
  height: 40px;
  padding-right: 30px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #98a2b3 50%),
    linear-gradient(135deg, #98a2b3 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  font-weight: 500;
  color: var(--sub);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: #fcfcfd;
}

td {
  padding: 12px;
  border-bottom: 1px solid #f2f4f7;
  vertical-align: middle;
}

tbody tr:hover {
  background: #fafbff;
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  background: #f2f4f7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #98a2b3;
  font-size: 13px;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.name-cell {
  font-weight: 500;
  margin-bottom: 3px;
}

.meta {
  color: var(--sub);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  background: #f2f4f7;
  color: #475467;
}

.tag-blue {
  background: #eaf2ff;
  color: var(--brand);
}

.tag-green {
  background: #ecfdf3;
  color: #027a48;
}

.tag-amber {
  background: #fffaeb;
  color: #b54708;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.empty {
  padding: 48px 0;
  text-align: center;
  color: #98a2b3;
  font-size: 13px;
}

/* ---------------------------- 弹层 ---------------------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 40;
}

.modal-card {
  width: 100%;
  max-width: 860px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 32px 80px rgba(16, 24, 40, 0.24);
  animation: pop 0.16s ease-out;
}

.modal-card.narrow {
  max-width: 520px;
}

.modal-card.wide {
  max-width: 960px;
}

@keyframes pop {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  font-weight: 600;
  font-size: 16px;
}

.modal-body {
  padding: 20px 22px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
}

.close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #98a2b3;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.close:hover {
  background: #f2f4f7;
  color: #475467;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.form-grid .span-2 {
  grid-column: span 2;
}

.hint {
  font-size: 12px;
  color: var(--sub);
  margin-top: 6px;
  line-height: 1.6;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 10px;
  font-weight: 600;
  font-size: 14px;
}

.section-label:first-child {
  margin-top: 0;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
}

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}

.sku-table .input {
  height: 36px;
  padding: 0 5px;
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.sku-table th {
  font-size: 12px;
}

input[type='number']::-webkit-inner-spin-button,
input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sku-table td {
  padding: 8px 6px;
}

.sku-table th {
  padding: 8px 6px;
  background: #fafbfc;
}

.uploader {
  display: flex;
  align-items: center;
  gap: 14px;
}

.preview {
  width: 84px;
  height: 84px;
  border-radius: 12px;
  border: 1px dashed #d0d5dd;
  background: #f9fafb center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #98a2b3;
  font-size: 12px;
  overflow: hidden;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attrs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}

.chip:hover {
  border-color: #d0d5dd;
  background: #fff;
}

.field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.field-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcfd;
}

.field-item .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.field-item .ratio {
  width: 64px;
  height: 32px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 6px;
}

.badge-custom {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  background: #eaf2ff;
  color: var(--brand);
}

.toast {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: #101828;
  color: #fff;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}

.toast.err {
  background: #b42318;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.split {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.split > * {
  flex: 1;
  min-width: 220px;
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .main {
    padding: 16px;
  }
  .form-grid,
  .attrs-grid,
  .field-list {
    grid-template-columns: 1fr;
  }
  .form-grid .span-2 {
    grid-column: span 1;
  }
}

/* 商品列表筛选条 */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: -4px 0 14px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #eef1f5;
  border-radius: 10px;
}

.filter-select {
  width: 140px;
  height: 34px;
  font-size: 13px;
}

.range-box {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.range-label {
  font-size: 13px;
  color: #667085;
  white-space: nowrap;
}

.range-input {
  width: 76px;
  height: 34px;
  font-size: 13px;
  padding: 0 8px;
  text-align: center;
}

.range-dash {
  color: #b0b7c3;
  font-size: 12px;
}

.promo-text {
  color: #e5484d;
  margin-top: 2px;
}

@media (max-width: 900px) {
  .filter-select,
  .range-input {
    width: 84px;
  }
}

/* ==================== 标签打印中心 ==================== */
.print-layout {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr) 268px;
  gap: 14px;
  align-items: start;
}

.print-layout .panel {
  background: #fff;
  border: 1px solid #eef1f5;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: #344054;
  margin-bottom: 10px;
}

.pr-goods {
  margin: 8px 0;
  max-height: 300px;
  overflow: auto;
}

.pr-good-row {
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}

.pr-good-row:hover {
  background: #f4f8ff;
  border-color: #dbe8ff;
}

.pr-good-name {
  font-size: 13px;
  color: #101828;
  line-height: 1.35;
}

.pr-skus {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 8px 8px;
}

.pr-skus .btn {
  font-size: 12px;
  padding: 4px 8px;
  height: auto;
}

.pr-items {
  max-height: 260px;
  overflow: auto;
  margin-bottom: 8px;
}

.pr-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 0;
  border-bottom: 1px dashed #eef1f5;
}

.pr-item:last-child {
  border-bottom: 0;
}

.pr-item-main {
  flex: 1;
  min-width: 0;
}

.pr-item-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pr-item-ctrl {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pr-copies {
  min-width: 18px;
  text-align: center;
  font-size: 13px;
}

.print-main {
  background: #fff;
  border: 1px solid #eef1f5;
  border-radius: 12px;
  padding: 12px;
}

.print-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px dashed #eef1f5;
}

.print-bar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.print-tpl {
  width: 168px;
  height: 32px;
  font-size: 13px;
}

.pr-dpi {
  width: 92px;
  height: 32px;
  font-size: 13px;
}

.pr-num {
  width: 62px;
  height: 32px;
  font-size: 13px;
  text-align: center;
  padding: 0 6px;
}

.canvas-wrap {
  background: #f7f9fc;
  border: 1px solid #eef1f5;
  border-radius: 10px;
  padding: 18px;
  overflow: auto;
}

.canvas-stage {
  display: flex;
  justify-content: center;
  min-height: 240px;
}

#prCanvas {
  background: #fff;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.12);
  border-radius: 2px;
  cursor: move;
  touch-action: none;
}

.print-status {
  margin-top: 10px;
  font-size: 12px;
  color: #667085;
  line-height: 1.6;
  word-break: break-all;
}

.pr-el-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
}

.pr-el-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}

.pr-el-row:hover {
  background: #f7f9fc;
}

.pr-el-row.active {
  background: #eef4ff;
  border-color: #b7d2ff;
  color: #1254b8;
}

.pr-el-type {
  font-size: 11px;
  color: #667085;
  background: #f2f4f8;
  border-radius: 4px;
  padding: 1px 5px;
}

.pr-el-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pr-tpl-meta {
  font-size: 12px;
  color: #344054;
  line-height: 1.9;
}

.pr-tpl-meta .meta {
  display: inline-block;
  width: 42px;
  color: #98a2b3;
}

@media (max-width: 1280px) {
  .print-layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .print-inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

@media (max-width: 900px) {
  .print-layout {
    grid-template-columns: 1fr;
  }
  .print-inspector {
    grid-template-columns: 1fr;
  }
}

/* 待打印清单：改为上下结构，避免窄栏挤压 */
.pr-item {
  flex-direction: column;
  align-items: stretch;
}

.pr-item-ctrl {
  justify-content: flex-end;
  margin-top: 4px;
}


/* 打印页：选中商品即时预览条 */
.pr-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.pr-preview-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  min-width: 0;
}
.pr-preview-info b {
  font-weight: 600;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pr-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}

/* 门店可见范围与分店库存（v2.6） */
.shop-scope {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.check-pill input {
  margin: 0;
}
.shop-stock-th {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shop-stock-input {
  min-width: 72px;
}
.sku-total {
  display: inline-block;
  min-width: 52px;
  padding: 8px 6px;
  border-radius: 8px;
  background: #f2f4f7;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
