* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #f0f4f8;
  --bg-card: #ffffff;
  --bg-input: #e8edf2;
  --bg-hint: #f1f5f9;
  --color-main: #6366f1;
  --color-text: #333333;
  --color-text-dim: #888888;
  --color-border: #e2e8f0;
  --radius: 8px;
}

body { font-family: "Microsoft YaHei", sans-serif; background: var(--bg-primary); color: var(--color-text); min-height: 100vh; padding: 16px; }
.container { max-width: 810px; margin: 0 auto; }

/* 全局隐藏 placeholder */
::placeholder { color: transparent !important; opacity: 0 !important; }
input::placeholder, textarea::placeholder { color: transparent !important; opacity: 0 !important; }

h1 { text-align: center; color: var(--color-main); margin-bottom: 16px; font-size: 1.3rem; font-weight: bold; }

/* 头部 */
.header-bar { display: flex; justify-content: flex-end; align-items: center; margin-bottom: 12px; gap: 8px; }
.header-username { font-size: 12px; color: var(--color-text); }
.theme-toggle { background: var(--bg-hint); border: none; color: var(--color-text); padding: 6px 14px; cursor: pointer; font-size: 12px; border-radius: var(--radius); }
.theme-toggle:hover { opacity: 0.8; }

/* Tab */
.tabs { display: flex; margin-bottom: 0; gap: 4px; background: var(--bg-card); padding: 6px 6px 0; border-radius: var(--radius) var(--radius) 0 0; }
.tab { padding: 10px 24px; text-align: center; cursor: pointer; font-size: 14px; color: var(--color-text-dim); border-radius: var(--radius) var(--radius) 0 0; transition: all 0.2s; }
.tab:hover { background: var(--bg-hint); color: var(--color-text); }
.tab.active { color: var(--color-main); font-weight: bold; background: var(--bg-primary); }

.card { background: var(--bg-card); padding: 16px; display: none; border-radius: 0 0 var(--radius) var(--radius); }
.card.active { display: block; }
/* 商品列表底部留白，给管理弹窗腾空间 */
#cardList { margin-bottom: 50px; }

/* 工具栏 */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.toolbar-left, .toolbar-right { display: flex; gap: 8px; align-items: center; }
.category-select { background: var(--bg-input); border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 10px; font-size: 13px; border-radius: var(--radius); min-width: 100px; }
.count-badge { font-size: 13px; color: var(--color-text-dim); white-space: nowrap; }

.btn-tool { padding: 8px 14px; border: none; background: var(--bg-hint); color: var(--color-text); cursor: pointer; font-size: 13px; border-radius: var(--radius); }
.btn-tool:hover { opacity: 0.8; }
.btn-new { background: var(--color-main); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 12px; }

/* 排序输入框 */
.sort-input { background: var(--bg-card); border: 1px solid var(--color-border); color: var(--color-text); padding: 3px 6px; font-size: 13px; text-align: center; border-radius: 4px; width: 50px; }
.sort-input:focus { border-color: var(--color-main); outline: none; }
.sort-input::-webkit-inner-spin-button { opacity: 1; }
.btn-danger { color: #e74c3c; }
.btn-danger:hover { background: #fee2e2; }
.btn-back { background: var(--bg-hint); border: none; color: var(--color-main); padding: 6px 12px; cursor: pointer; font-size: 12px; border-radius: var(--radius); }

.edit-header-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }

/* 商品列表 */
.product-list { display: flex; flex-direction: column; gap: 8px; }
.product-item { background: var(--bg-hint); padding: 12px 14px; border-radius: var(--radius); cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: all 0.2s; }
.product-item:hover { background: #e0e7ff; }
.product-card { background: var(--bg-hint); padding: 12px 14px; border-radius: var(--radius); display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.product-card-info { flex: 1; }
.product-card-name { font-weight: 600; font-size: 14px; }
.product-card-meta { font-size: 12px; color: var(--color-text-dim); margin-top: 3px; }
.product-card-deleted-at { font-size: 11px; color: #e74c3c; margin-top: 2px; }
.product-card-actions { flex-shrink: 0; margin-left: 12px; }
.deleted-card { border-left: 3px solid #e74c3c; }
.product-main { display: flex; justify-content: space-between; align-items: center; flex: 1; min-width: 0; }
.product-left { min-width: 0; flex: 1; }
.product-code { font-size: 11px; color: var(--color-main); font-weight: 600; margin-bottom: 2px; }
.product-name { font-size: 15px; font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-meta { font-size: 12px; color: var(--color-text-dim); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }
.product-category { font-weight: 600; }
.product-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-left: 16px; flex-shrink: 0; }
.product-type-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.badge-single { background: #dbeafe; color: #1d4ed8; }
.badge-multi { background: #ede9fe; color: #6d28d9; }
.badge-frame { background: #fef3c7; color: #92400e; }
.product-stock { font-size: 13px; color: var(--color-text); }
.product-stock b { color: var(--color-main); }
.product-spec-summary { font-size: 11px; color: var(--color-text-dim); }
.product-actions { display: flex; gap: 6px; margin-left: 12px; flex-shrink: 0; }

.empty-tip { text-align: center; color: var(--color-text-dim); padding: 40px; font-size: 14px; }

/* 表单 */
.form-block { background: var(--bg-hint); padding: 14px; margin-bottom: 10px; border-radius: var(--radius); }
.form-block-title { font-size: 14px; color: var(--color-main); margin-bottom: 10px; font-weight: 600; }
.form-row { display: flex; align-items: center; margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.form-row:last-child { margin-bottom: 0; }
.form-label { width: 50px; font-size: 13px; color: var(--color-text-dim); flex-shrink: 0; }
.form-input { flex: 1; min-width: 0; background: var(--bg-card); border: 1px solid var(--color-border); color: var(--color-text); padding: 8px 10px; font-size: 13px; border-radius: var(--radius); box-sizing: border-box; }
.form-input-half { width: 130px; flex: none; }
.form-input-half2 { width: 160px; flex: none; }

/* 类型选择 */
.type-selector { display: flex; gap: 20px; flex-wrap: wrap; }
.type-option { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--color-text); cursor: pointer; }
.type-option input[type="radio"] { accent-color: var(--color-main); }

/* 规格配置 */
.spec-config { display: flex; flex-direction: column; gap: 12px; }
.spec-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spec-label { font-size: 13px; color: var(--color-text); font-weight: 600; width: 80px; flex-shrink: 0; }
.spec-tags { display: flex; gap: 6px; flex-wrap: wrap; min-width: 100px; }
.spec-tag { background: #e0e7ff; color: #3730a3; padding: 4px 10px; border-radius: 14px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.spec-tag-remove { cursor: pointer; font-size: 16px; color: #6366f1; margin-left: 2px; }
.spec-tag-remove:hover { color: #e74c3c; }
.spec-tag-empty { color: var(--color-text-dim); font-size: 13px; font-style: italic; }
.btn-add-spec { background: var(--color-main); color: #fff; border: none; padding: 5px 14px; border-radius: var(--radius); cursor: pointer; font-size: 12px; }
.btn-add-spec:hover { opacity: 0.8; }

/* SKU网格 */
/* 库存明细标题栏 */
.sku-title-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* 库存过滤开关 */
.stock-filter-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 12px; flex-shrink: 0; }
.toggle-switch { width: 36px; height: 20px; background: #ccc; border-radius: 20px; transition: background 0.25s; flex-shrink: 0; position: relative; pointer-events: none; }
.toggle-switch.active { background: var(--color-main); }
.toggle-slider-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle-switch.active .toggle-slider-knob { transform: translateX(16px); }
.toggle-label-text { color: var(--color-text-dim); white-space: nowrap; font-size: 12px; pointer-events: none; }

.sku-grid-wrap { overflow-x: auto; }
.sku-batch-row { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sku-grid { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.sku-header { display: flex; gap: 8px; font-weight: 600; color: var(--color-main); font-size: 12px; padding: 6px 8px; background: var(--bg-card); border-radius: var(--radius); }
.sku-header span { flex: 0.8; min-width: 0; text-align: center; }
.sku-header span:last-child { flex: 2; }
.sku-row { display: flex; gap: 8px; align-items: center; padding: 4px 8px; background: var(--bg-card); border-radius: 6px; }
.sku-row:hover { background: #fff3e0 !important; }
.sku-row span { flex: 0.8; min-width: 0; text-align: center; color: var(--color-text); font-weight: 500; }
.sku-row .sku-stepper { flex: 2; min-width: 0; }
.sku-input { width: 100%; flex: 1; min-width: 0; background: var(--bg-input); border: none; color: var(--color-text); padding: 5px 8px; font-size: 12px; text-align: center; border-radius: 4px; box-sizing: border-box; }
.sku-input:focus { border: 2px solid #ef4444; outline: none; box-shadow: none; }

/* 库存加减步进器 */
.sku-stepper { display: flex; align-items: center; gap: 0; flex: 1; min-width: 0; }
.sku-stock-input { border-radius: 0; -moz-appearance: textfield; }
.sku-stock-input::-webkit-inner-spin-button,
.sku-stock-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.sku-step-btn {
  width: 28px; height: 28px; border: none; background: var(--color-main);
  color: #fff; font-size: 16px; font-weight: bold; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; line-height: 1; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.sku-step-btn:first-child { border-radius: 4px 0 0 4px; }
.sku-step-btn:last-child { border-radius: 0 4px 4px 0; }
.sku-step-btn:hover { opacity: 0.85; }
.sku-step-btn:active { opacity: 0.7; transform: scale(0.95); }

/* 镜框规格表格 */
.frame-table { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.frame-row { display: flex; gap: 6px; align-items: center; padding: 4px 6px; background: var(--bg-card); border-radius: 6px; }
.frame-header { font-weight: 600; color: var(--color-main); font-size: 12px; padding: 6px 8px; }
.frame-header span { text-align: center; }
.frame-header span:nth-child(1) { width: 100px; }
.frame-header span:nth-child(2) { width: 80px; }
.frame-header span:nth-child(3) { width: 80px; }
.frame-header span:nth-child(4) { width: 70px; }
.frame-header span:nth-child(5) { width: 120px; }
.frame-header span:nth-child(6) { width: 40px; }
.frame-row .frame-input { width: 100px; background: var(--bg-input); border: none; color: var(--color-text); padding: 6px 8px; font-size: 12px; border-radius: 4px; text-align: center; flex-shrink: 0; }
.frame-row .frame-input:nth-child(2) { width: 80px; }
.frame-row .frame-input:nth-child(3) { width: 80px; }
.frame-row .frame-input:focus { outline: 2px solid var(--color-main); }
.frame-img-cell { width: 70px; display: flex; align-items: center; gap: 2px; flex-shrink: 0; justify-content: center; }
.frame-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; border: 1px solid var(--color-border); cursor: pointer; }
.frame-no-img { font-size: 10px; color: var(--color-text-dim); }
.btn-tiny { padding: 3px 6px; font-size: 12px; border: none; background: var(--bg-hint); color: var(--color-main); cursor: pointer; border-radius: 4px; }
.btn-tiny:hover { opacity: 0.8; }

/* 镜框卡片网格 */
.frame-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.frame-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}

.frame-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--color-main);
}

.frame-card-img-wrap {
  width: 100%;
  overflow: hidden;
  background: var(--bg-hint);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: zoom-in;
}

.frame-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame-card-no-img {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--color-text-dim);
  font-size: 13px;
}

/* 现代眼镜图标 - 极简线条风格 */
.icon-glasses {
  display: inline-block;
  width: 52px;
  height: 20px;
  position: relative;
  margin-bottom: 4px;
}

.icon-glasses::before,
.icon-glasses::after {
  content: '';
  position: absolute;
  top: 0;
  width: 20px;
  height: 18px;
  border: 2px solid var(--color-main);
  border-radius: 4px;
}

.icon-glasses::before {
  left: 0;
}

.icon-glasses::after {
  right: 0;
}

.icon-glasses {
  background: linear-gradient(to right, 
    transparent 0%, 
    transparent 38%, 
    var(--color-main) 38%, 
    var(--color-main) 62%, 
    transparent 62%, 
    transparent 100%);
  background-size: 100% 2px;
  background-position: center 9px;
  background-repeat: no-repeat;
}

/* 现代图标样式 */
.icon-album,
.icon-camera {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  vertical-align: middle;
  position: relative;
}

/* 相册图标 - 简洁图片样式 */
.icon-album::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 12px;
  border: 2px solid var(--color-main);
  border-radius: 3px;
}

.icon-album::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  width: 8px;
  height: 6px;
  border: 1.5px solid var(--color-main);
  border-radius: 2px;
  background: linear-gradient(135deg, transparent 45%, var(--color-main) 45%, var(--color-main) 55%, transparent 55%);
}

/* 相机图标 - 极简相机样式 */
.icon-camera::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 1px;
  width: 16px;
  height: 12px;
  border: 2px solid var(--color-main);
  border-radius: 3px;
}

.icon-camera::after {
  content: '';
  position: absolute;
  top: 0;
  left: 5px;
  width: 8px;
  height: 5px;
  border: 2px solid var(--color-main);
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}

.frame-card-stock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(99,102,241,0.9);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  z-index: 10;
  transition: background 0.2s;
}

.frame-card-stock-badge:hover {
  background: rgba(99,102,241,1);
}

.frame-card-stock-badge::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  bottom: -20px;
  left: -20px;
  cursor: pointer;
}

/* 卡片图片数量圆点 */
.card-img-dots {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 5;
  pointer-events: none;
}
.card-img-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}
.card-img-dot.active {
  background: #fff;
}

.frame-card-stock-badge span {
  pointer-events: none;
}

.frame-card-info {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-main);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 0 0 10px 10px;
}
.frame-card-info:hover {
  background: #e0e7ff;
}

/* 图片查看器 */
.image-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.image-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 28px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-viewer-close:hover {
  background: rgba(255,255,255,0.3);
}

.image-viewer-img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  cursor: default;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.image-viewer-info {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 14px;
  background: rgba(0,0,0,0.6);
  padding: 8px 16px;
  border-radius: 20px;
  white-space: nowrap;
}

/* 画廊导航 */
.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 22px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.gallery-arrow:hover { background: rgba(255,255,255,0.3); }
.gallery-arrow-left { left: 12px; }
.gallery-arrow-right { right: 12px; }

.gallery-dots {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10001;
}
.gallery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: background 0.2s;
  cursor: pointer;
}
.gallery-dot.active { background: #fff; }

/* 移动端适配 */
@media screen and (max-width: 768px) {
  .frame-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
  }
  .frame-card-stock-badge {
    font-size: 11px;
    padding: 2px 6px;
  }
  .frame-card-info {
    font-size: 11px;
  }
}

@media screen and (max-width: 360px) {
  .frame-card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
}

/* 镜框编辑弹窗 */
.frame-edit-field {
  margin-bottom: 12px;
}

.frame-edit-label {
  font-size: 13px;
  color: var(--color-text-dim);
  margin-bottom: 4px;
  display: block;
}

.frame-edit-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 8px 10px;
  font-size: 14px;
  border-radius: var(--radius);
}

.frame-edit-input:focus {
  outline: 2px solid var(--color-main);
}

.frame-edit-img-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.frame-edit-img-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-main);
  min-width: 52px;
  flex-shrink: 0;
}

.frame-edit-preview {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

/* 保存按钮 */
.btn-save { background: var(--color-main); color: #fff; border: none; width: 100%; padding: 12px; font-size: 15px; cursor: pointer; margin-top: 12px; border-radius: var(--radius); font-weight: 600; }
.btn-save:hover { opacity: 0.9; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 10px 24px; font-size: 14px; border-radius: 8px; color: #fff; opacity: 0; transition: opacity 0.3s; z-index: 1000; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 9999; }
.modal-content { background: #fff; border-radius: 12px; width: 340px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
.modal-header span { font-size: 14px !important; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--color-text-dim); padding: 0; width: 28px; height: 28px; line-height: 28px; text-align: center; flex-shrink: 0; }
.modal-close:hover { color: var(--color-text); }
.modal-body { padding: 12px 14px; overflow-y: auto; flex: 1; }
.modal-body input, .modal-body select, .modal-body textarea { box-sizing: border-box; max-width: 100%; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--color-border); flex-wrap: wrap; }
@media (max-width: 480px) {
  .modal-overlay { overflow-y: auto; }
  .modal-content { max-height: 96vh; border-radius: 10px; }
  .modal-body { padding: 8px 10px; }
  .modal-header { padding: 8px 10px; }
  .modal-footer { padding: 8px 10px; gap: 6px; }
  .modal-header span { font-size: 13px !important; }
}
.degree-presets { display: flex; gap: 8px; margin-bottom: 16px; }
.degree-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.degree-checkbox { display: flex; align-items: center; gap: 6px; padding: 8px; background: var(--bg-hint); border-radius: 6px; cursor: pointer; transition: all 0.2s; font-size: 13px; }
.degree-checkbox:hover { background: #e0e7ff; }
.degree-checkbox input[type="checkbox"] { accent-color: var(--color-main); width: 16px; height: 16px; cursor: pointer; }

/* 加载 */
.loading-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); display: flex; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.3s ease; }
.loading-overlay.fade-out { opacity: 0; pointer-events: none; }
.loading-text { background: #fff; padding: 20px 30px; border-radius: 10px; text-align: center; font-size: 14px; }
.loading-spinner { font-size: 28px; animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 登录 */
.login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); display: flex; justify-content: center; align-items: center; z-index: 99999; }
.login-overlay.hidden { display: none; }
.login-box { background: #fff; border-radius: 16px; padding: 36px 32px 28px; width: 320px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center; }
.login-title { font-size: 20px; font-weight: bold; color: #333; margin-bottom: 6px; }
.login-subtitle { font-size: 12px; color: #888; margin-bottom: 24px; }
.login-input { width: 100%; padding: 12px 14px; font-size: 15px; border: 2px solid #e2e8f0; border-radius: 10px; outline: none; margin-bottom: 14px; box-sizing: border-box; color: #333; }
.login-input:focus { border-color: #6366f1; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; font-weight: bold; color: #fff; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); border: none; border-radius: 10px; cursor: pointer; margin-top: 4px; }
.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-error { color: #e74c3c; font-size: 13px; min-height: 20px; margin-top: 8px; }
.login-footer { margin-top: 18px; font-size: 11px; color: #aaa; }

/* 响应式 - 仅尺寸调整，保持布局不变 */
@media screen and (max-width: 768px) {
  body { padding: 8px; font-size: 14px; }
  .container { max-width: 100%; }
  h1 { font-size: 1.1rem; margin-bottom: 10px; }
  
  /* Tab */
  .tab { padding: 8px 8px; font-size: 12px; }
  .tabs { gap: 2px; padding: 5px 4px 0; }
  .card { padding: 10px 8px; }
  
  /* 工具栏 - 保持横向 */
  .toolbar { gap: 5px; margin-bottom: 6px; }
  .toolbar-left { gap: 4px; }
  .toolbar-right { gap: 4px; }
  .date-label { padding: 4px 7px; font-size: 12px; min-width: 48px; }
  .date-sep { font-size: 12px; }
  .btn-tool { padding: 5px 8px; font-size: 12px; white-space: nowrap; }
  .category-select { font-size: 13px; padding: 8px 10px; min-width: 90px; }
  .count-badge { font-size: 12px; width: 100%; text-align: center; margin-top: 4px; }
  .btn-tool { padding: 8px 12px; font-size: 13px; }
  
  /* 商品列表 - 保持横向布局 */
  .product-item { padding: 10px; }
  .product-name { font-size: 14px; }
  .product-code { font-size: 11px; }
  .product-meta { font-size: 11px; gap: 8px; }
  .product-stock { font-size: 12px; }
  .product-spec-summary { font-size: 10px; }
  .btn-small { padding: 6px 10px; font-size: 12px; }
  
  /* 表单 - 保持行列结构，不换行 */
  .form-block { padding: 10px; }
  .form-block-title { font-size: 13px; }
  
  /* 弹窗内图片上传区 - 手机友好 */
  .frame-edit-img-row { flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
  .frame-edit-img-row .btn-small { padding: 4px 8px; font-size: 11px; }
  .frame-edit-preview { width: 40px; height: 40px; }
  .frame-edit-img-label { font-size: 12px; min-width: 42px; }
  .form-row { flex-wrap: nowrap !important; gap: 4px; margin-bottom: 8px; align-items: center; }
  .form-label { width: 45px; font-size: 12px; flex-shrink: 0; white-space: nowrap; overflow: hidden; }
  .form-input { padding: 8px; font-size: 14px; min-height: 36px; flex: 1; min-width: 0; }
  .form-input-half { width: auto !important; flex: 1 !important; min-width: 70px !important; }
  .form-input-half2 { width: 110px !important; flex: none !important; min-width: 110px !important; }
  select.form-input { padding-right: 20px; }
  #inputName { max-width: 100% !important; flex: 1 !important; }
  
  /* 规格配置 */
  .spec-row { flex-wrap: nowrap !important; gap: 4px; }
  .spec-label { width: 50px; font-size: 11px; flex-shrink: 0; }
  .spec-tags { display: flex; gap: 3px; flex-wrap: wrap; flex: 1; min-width: 0; }
  .spec-tag { font-size: 11px; padding: 3px 7px; border-radius: 10px; }
  .spec-tag-remove { font-size: 14px; }
  .btn-add-spec { padding: 5px 10px; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
  
  /* SKU 网格 - 支持横向滚动 */
  .sku-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sku-grid { min-width: 0; }
  .sku-header, .sku-row { font-size: 10px; gap: 3px; padding: 2px 4px; }
  .sku-header span { flex: 0.7 !important; min-width: 0; font-size: 10px; }
  .sku-header span:last-child { flex: 2.2 !important; }
  .sku-row span { flex: 0.7 !important; min-width: 0; font-size: 10px; }
  .sku-row .sku-stepper { flex: 2.2 !important; min-width: 0; }
  .sku-input { font-size: 12px; padding: 4px; }
  .sku-stepper { gap: 0; }
  .sku-step-btn { width: 32px; height: 32px; font-size: 20px; min-height: 32px; }
  .sku-stock-input { font-size: 14px; padding: 4px 2px; min-height: 32px; }
  
  
  /* 登录框 */
  .login-box { width: 90vw; max-width: 300px; padding: 12px 14px 10px; }
  .login-title { font-size: 15px; margin-bottom: 0; }
  .login-subtitle { font-size: 10px; margin-bottom: 8px; }
  .login-input { padding: 6px 8px; font-size: 13px; margin-bottom: 6px; }
  .login-btn { padding: 6px; font-size: 13px; margin-top: 0; }
  .login-footer { margin-top: 6px; font-size: 10px; }
  
  /* Toast */
  .toast { font-size: 14px; padding: 10px 20px; }
  
  /* 保存按钮 */
  @supports (padding: env(safe-area-inset-bottom)) {
    body {
      padding-left: calc(8px + env(safe-area-inset-left));
      padding-right: calc(8px + env(safe-area-inset-right));
      padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
  }
}

/* 单商品列表模式 */
.single-list { display: flex; flex-direction: column; gap: 4px; }
.single-list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.single-list-row:hover { background: #e0e7ff; }
.single-list-row > :nth-child(1) { flex: 1; display: flex; justify-content: center; align-items: center; }
.single-list-name { font-size: 14px; font-weight: 600; color: var(--color-text); flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.single-list-stock { font-size: 13px; font-weight: 600; color: var(--color-main); flex: 1; text-align: center; }
.single-list-remark { font-size: 12px; color: var(--color-text-dim); flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.single-list-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; border: 1px solid var(--color-border); display: block; }
.single-list-noimg { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; color: var(--color-text-dim); font-size: 11px; }
.single-list-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--color-main);
  font-weight: 600;
}
.single-list-head span:nth-child(1) { flex: 1; flex-shrink: 0; text-align: center; }
.single-list-head span:nth-child(2) { flex: 1; text-align: center; }
.single-list-head span:nth-child(3) { flex: 1; text-align: center; }
.single-list-head span:nth-child(4) { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* OCR 缩略图 */
.ocr-thumb {
  height: 32px;
  width: auto;
  max-width: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  flex-shrink: 0;
}
.ocr-thumb:hover { opacity: 0.8; }

/* OCR 识别按钮 */
.ocr-recognize-btn {
  background: linear-gradient(135deg, #f59e0b, #f97316) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 700;
}
.ocr-recognize-btn:hover {
  background: linear-gradient(135deg, #d97706, #ea580c) !important;
  opacity: 1;
}

/* 附件上传 */
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 40px;
}

.attachment-item {
  position: relative;
  width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.attachment-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  background: var(--bg-hint);
}

.attachment-icon {
  width: 72px;
  height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-hint);
  border-radius: 6px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  font-size: 10px;
  color: var(--color-text-dim);
  gap: 4px;
}

.attachment-icon.pdf-icon {
  color: #e74c3c;
}

.attachment-icon.excel-icon {
  color: #27ae60;
}

.attachment-icon .icon-file {
  font-size: 28px;
}

.attachment-name {
  font-size: 10px;
  color: var(--color-text-dim);
  text-align: center;
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.attachment-delete:hover {
  background: #c0392b;
}

.attachment-upload-btns {
  display: flex;
  gap: 8px;
}

.attachment-uploading {
  opacity: 0.6;
  pointer-events: none;
}

/* ═══════════ 出库记录 ═══════════ */
.ol-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ol-table thead th {
  background: var(--bg-hint); color: var(--color-main); font-size: 12px; font-weight: 600;
  padding: 8px 6px; text-align: center; white-space: nowrap;
}
.ol-table thead th:nth-child(2) { text-align: left; }
.ol-table tbody td {
  padding: 8px 6px; border-bottom: 1px solid var(--color-border); vertical-align: middle;
}
.ol-table tbody tr:nth-child(even) { background: var(--bg-hint); }
.ol-table tbody tr:hover { background: #e0e7ff; }

.ol-name { font-weight: 600; color: var(--color-text); font-size: 14px; }
.ol-ono { font-size: 11px; color: var(--color-text-dim); }
.ol-pname { font-weight: 500; color: var(--color-text); }
.ol-pmeta { font-size: 11px; color: var(--color-text-dim); }
.ol-td-customer { text-align: center; }
.ol-td-product { text-align: left; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-td-spec { text-align: center; font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-td-qty { text-align: center; font-weight: 600; }
.ol-td-price { text-align: center; white-space: nowrap; }
.ol-td-sales { text-align: center; }
.ol-td-time { text-align: center; font-size: 11px; color: var(--color-text-dim); white-space: nowrap; }

/* 手机端：表格→卡片 */
@media (max-width: 768px) {
  .ol-table thead { display: none; }
  .ol-table, .ol-table tbody, .ol-table tbody tr { display: block; }
  .ol-table tbody tr {
    background: var(--bg-hint);
    border-radius: var(--radius);
    margin-bottom: 8px;
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .ol-table tbody tr:nth-child(even) { background: var(--bg-hint); }
  .ol-table tbody tr:hover { background: #e0e7ff; }
  .ol-table tbody td {
    border: none;
    padding: 2px 4px;
  }

  .ol-td-customer { order: 1; flex: 1; text-align: left; }
  .ol-td-qty { order: 1; text-align: right; font-size: 14px; }
  .ol-td-product { order: 2; width: 100%; max-width: none; white-space: normal; margin-top: 2px; }
  .ol-td-spec { order: 3; width: 100%; max-width: none; white-space: normal; text-align: left; font-size: 12px; margin-top: 1px; }
  .ol-td-price { order: 4; text-align: center; }
  .ol-td-sales { order: 4; text-align: center; }
  .ol-td-time { order: 4; text-align: right; font-size: 11px; }

  .ol-name { font-size: 14px; color: var(--color-main); }
  .ol-ono { font-size: 11px; margin-left: 6px; }
  .ol-pname { font-size: 13px; }
  .ol-pmeta { font-size: 11px; margin-left: 4px; }

  /* 1. 订单号与客户名同行 */
  .ol-td-customer {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
  }

  /* 2. 商品品牌与名称同行 */
  .ol-td-product {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
  }

  /* 3. 交易时间与出库时间同行 */
  .ol-td-time br { display: none; }
  .ol-td-time span { margin-left: 4px; }
}

/* ═══════════ 日期文本选择器 ═══════════ */
.date-label {
  display:inline-block;
  background:var(--bg-input);
  border:1px solid var(--color-border);
  color:var(--color-text);
  padding:5px 10px;
  font-size:13px;
  border-radius:var(--radius);
  cursor:pointer;
  user-select:none;
  min-width:60px;
  text-align:center;
  white-space:nowrap;
}
.date-label:hover { border-color:var(--color-main); }
.date-sep {
  color:var(--color-text-dim);
  font-size:13px;
  margin:0 2px;
}
.search-toggle {
  display:inline-block;
  cursor:pointer;
  font-size:16px;
  line-height:1;
  padding:4px 6px;
  vertical-align:middle;
  user-select:none;
  border-radius:var(--radius);
  transition:background 0.15s;
}
.search-toggle:hover { background:var(--bg-hint); }
.search-bar { padding:6px 0 0; }
.search-bar input {
  width:100%;
  box-sizing:border-box;
  padding:7px 10px;
  font-size:13px;
  border:1px solid var(--color-border);
  border-radius:var(--radius);
  background:var(--bg-input);
  color:var(--color-text);
  outline:none;
}
.search-bar input:focus { border-color:var(--color-main); }

/* ═══════════ 订单详情弹窗 ═══════════ */
.ol-modal-overlay {
  position:fixed; top:0; left:0; width:100%; height:100%;
  background:rgba(0,0,0,0.5); z-index:1000;
  display:flex; align-items:center; justify-content:center;
  padding:20px; box-sizing:border-box;
}
.ol-modal-content {
  background:var(--bg-card); border-radius:var(--radius);
  max-width:700px; width:100%; max-height:80vh; overflow-y:auto;
  box-shadow:0 8px 32px rgba(0,0,0,0.2);
}
.ol-modal-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:16px 20px; border-bottom:1px solid var(--color-border);
  position:sticky; top:0; background:var(--bg-card); z-index:1;
}
.ol-modal-header h3 { margin:0; font-size:16px; color:var(--color-text); }
.ol-modal-close {
  cursor:pointer; font-size:18px; color:var(--color-text-dim); line-height:1;
  padding:4px 8px; border-radius:var(--radius);
}
.ol-modal-close:hover { background:var(--bg-hint); }
.ol-modal-body { padding:16px 20px 20px; }
.ol-detail-grid {
  display:grid; grid-template-columns:1fr 1fr; gap:8px 16px;
  margin-bottom:16px;
}
.ol-detail-group { display:flex; flex-direction:column; gap:2px; }
.ol-detail-group label { font-size:11px; color:var(--color-text-dim); }
.ol-detail-group span { font-size:13px; color:var(--color-text); }
.ol-detail-group .ol-status-badge {
  display:inline-block; padding:2px 8px; border-radius:4px; font-weight:600; font-size:12px;
}
.ol-detail-table { width:100%; border-collapse:collapse; font-size:13px; margin-top:8px; }
.ol-detail-table th {
  background:var(--bg-hint); color:var(--color-main); font-size:12px; font-weight:600;
  padding:7px 8px; text-align:center; border-bottom:1px solid var(--color-border);
}
.ol-detail-table th:first-child, .ol-detail-table th:nth-child(2) { text-align:left; }
.ol-detail-table td {
  padding:7px 8px; border-bottom:1px solid var(--color-border); text-align:center;
}
.ol-detail-table td:first-child { text-align:left; }
.ol-detail-table tbody tr:nth-child(even) { background:var(--bg-hint); }
.ol-detail-amount {
  display:flex; justify-content:flex-end; gap:16px; margin-top:12px;
  font-size:13px; color:var(--color-text);
}
.ol-detail-amount strong { color:var(--color-main); }
.ol-detail-rx {
  background:var(--bg-hint); border-radius:var(--radius); padding:10px 14px;
  margin-bottom:12px; font-size:12px; line-height:1.7;
}
.ol-detail-rx label { font-weight:600; color:var(--color-text-dim); margin-right:4px; }
.ol-detail-loading {
  text-align:center; padding:40px; color:var(--color-text-dim); font-size:14px;
}
.ol-detail-loading::after { content:'...'; animation:ol-dots 1.2s steps(3) infinite; }
@keyframes ol-dots { 0% { content:'.'; } 33% { content:'..'; } 66% { content:'...'; } }

/* 行可点击 */
.outlog-clickable { cursor:pointer; }
.outlog-clickable:hover { background:#e0e7ff !important; }
