/* ==========================================================================
   多肽进销存系统 · 样式（Element Plus 风格复刻）
   ========================================================================== */

:root {
  --primary: #409eff;
  --primary-light: #66b1ff;
  --primary-dark: #337ecc;
  --success: #67c23a;
  --warning: #e6a23c;
  --danger: #f56c6c;
  --info: #909399;

  --text-primary: #303133;
  --text-regular: #606266;
  --text-secondary: #909399;
  --text-placeholder: #a8abb2;

  --border: #dcdfe6;
  --border-light: #e4e7ed;
  --border-lighter: #ebeef5;

  --bg-page: #f5f7fa;
  --bg-card: #ffffff;
  --bg-fill: #f0f2f5;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --shadow-card: 0 2px 12px 0 rgba(0, 0, 0, .08);
  --shadow-dialog: 0 12px 32px 4px rgba(0, 0, 0, .12);

  --aside-bg: #1d2b3a;
  --aside-text: #cfd8e3;
  --aside-hover: #17232f;

  --radius: 4px;
  --radius-lg: 10px;
}

[data-theme="dark"] {
  --text-primary: #e5eaf3;
  --text-regular: #cfd3dc;
  --text-secondary: #a3a6ad;
  --text-placeholder: #8d9095;
  --border: #4c4d4f;
  --border-light: #414243;
  --border-lighter: #363637;
  --bg-page: #141414;
  --bg-card: #1d1e1f;
  --bg-fill: #262727;
  --bg-header: #1d1e1f;
  --bg-input: #1d1e1f;
  --shadow-card: 0 2px 12px 0 rgba(0, 0, 0, .45);
  --aside-bg: #141414;
  --aside-hover: #1d1e1f;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text-regular);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text-primary); }

.ico { vertical-align: -3px; }

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

.layout { display: flex; height: 100vh; overflow: hidden; }

.aside {
  width: 220px;
  flex: 0 0 220px;
  background: var(--aside-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logo {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 15px;
  white-space: nowrap;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu { flex: 1; overflow-y: auto; padding: 4px 0; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 20px;
  color: var(--aside-text);
  font-size: 14px;
  transition: background .2s, color .2s;
}
.menu-item:hover { background: var(--aside-hover); color: #fff; }
.menu-item.active { color: #fff; background: #2a3b4d; }
.menu-item .ico { opacity: .85; }

.body { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.header {
  height: 56px;
  flex: 0 0 56px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-lighter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.header-left, .header-right { display: flex; align-items: center; gap: 10px; }
.page-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.user-name { color: var(--text-primary); }
.logout { color: var(--danger); font-size: 14px; }
.logout:hover { color: #f89898; }

.theme-toggle {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-regular);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle .ico-moon { display: none; }
[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
[data-theme="dark"] .theme-toggle .ico-moon { display: inline-flex; }

.main { flex: 1; overflow-y: auto; padding: 16px; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-lighter);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-lighter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.card-head .card-extra { font-weight: 400; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }

/* ---------------- 统计卡 ---------------- */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-lighter);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  transition: transform .2s, box-shadow .2s;
}
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { transform: translateY(-4px); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.stat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-label { color: var(--text-secondary); font-size: 14px; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
}
.stat-icon .ico { width: 19px; height: 19px; vertical-align: 0; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-value.small { font-size: 18px; margin-top: 8px; }
.stat-sub { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.text-danger { color: var(--danger); }

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 15px;
  font-size: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-regular);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  line-height: 1;
}
.btn:hover { color: var(--primary); border-color: #c6e2ff; background: #ecf5ff; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #85ce61; border-color: #85ce61; color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover { background: #ebb563; border-color: #ebb563; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #f78989; border-color: #f78989; color: #fff; }
.btn-small { height: 26px; padding: 0 10px; font-size: 12px; }
.btn-large { height: 40px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn-link { border: 0; background: transparent; padding: 0 4px; height: auto; color: var(--primary); }
.btn-link:hover { background: transparent; color: var(--primary-light); }
.btn-link.danger { color: var(--danger); }
.btn-link.danger:hover { color: #f89898; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 表单 ---------------- */

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-regular); }
.field .req::before { content: "*"; color: var(--danger); margin-right: 3px; }
.field-hint { font-size: 12px; color: var(--text-secondary); }

.input, .select, textarea.input {
  height: 32px;
  padding: 0 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
textarea.input { height: auto; padding: 8px 11px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); }
.input::placeholder, textarea.input::placeholder { color: var(--text-placeholder); }
.input[readonly] { background: var(--bg-fill); }
.input-lg { height: 40px; font-size: 15px; }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23a8abb2' stroke-width='1.4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.input-wrap { position: relative; }
.input-tip { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.full { grid-column: 1 / -1; }

.checkbox { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0 14px 8px 0; font-size: 13px; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }

.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 20px; cursor: pointer; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------------- 表格 ---------------- */

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  background: #fafafa;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-lighter);
  white-space: nowrap;
}
[data-theme="dark"] .table th { background: #262727; }
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-lighter);
  color: var(--text-regular);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--bg-fill); }
.table .center { text-align: center; }
.table .right { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table .muted { color: var(--text-secondary); }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.table-empty { padding: 40px 0; text-align: center; color: var(--text-secondary); font-size: 13px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }

/* ---------------- 标签 ---------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--radius);
  line-height: 1;
  white-space: nowrap;
}
.tag-primary { background: #ecf5ff; color: var(--primary); border: 1px solid #d9ecff; }
.tag-success { background: #f0f9eb; color: var(--success); border: 1px solid #e1f3d8; }
.tag-warning { background: #fdf6ec; color: var(--warning); border: 1px solid #faecd8; }
.tag-danger  { background: #fef0f0; color: var(--danger);  border: 1px solid #fde2e2; }
.tag-info    { background: #f4f4f5; color: var(--info);    border: 1px solid #e9e9eb; }
.expire-tag { height: 24px; }

/* ---------------- 工具栏 / 分页 ---------------- */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }

.pager { display: flex; align-items: center; gap: 6px; padding: 12px 0 2px; flex-wrap: wrap; }
.pager-btn {
  min-width: 30px; height: 28px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-regular); font-size: 13px; background: var(--bg-card);
}
.pager-btn:hover { color: var(--primary); border-color: var(--primary); }
.pager-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager-info { color: var(--text-secondary); font-size: 12px; margin-left: 6px; }

/* ---------------- 弹窗 ---------------- */

.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .5);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 2000; overflow-y: auto; padding: 60px 16px 40px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: 6px;
  box-shadow: var(--shadow-dialog);
  width: 560px; max-width: 100%;
  animation: modalIn .18s ease-out;
}
.modal.wide { width: 900px; }
.modal.narrow { width: 420px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.modal-head {
  padding: 16px 20px 10px;
  font-size: 16px; font-weight: 600; color: var(--text-primary);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-close { border: 0; background: transparent; font-size: 20px; color: var(--text-secondary); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--primary); }
.modal-body { padding: 6px 20px 10px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------- 提示 / 消息 ---------------- */

.toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 5000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  min-width: 240px; max-width: 70vw;
  padding: 10px 16px; border-radius: 6px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .16);
  background: #fff; border: 1px solid var(--border-lighter);
  color: var(--text-regular);
  animation: toastIn .18s ease-out;
  display: flex; gap: 8px; align-items: center;
}
.toast.success { background: #f0f9eb; border-color: #e1f3d8; color: var(--success); }
.toast.error   { background: #fef0f0; border-color: #fde2e2; color: var(--danger); }
.toast.warning { background: #fdf6ec; border-color: #faecd8; color: var(--warning); }
.toast.info    { background: #f4f4f5; border-color: #e9e9eb; color: var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.alert { padding: 9px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; line-height: 1.6; }
.alert-info { background: #f4f4f5; color: var(--info); border: 1px solid #e9e9eb; }
.alert-warning { background: #fdf6ec; color: #b88230; border: 1px solid #faecd8; }
.alert-danger { background: #fef0f0; color: var(--danger); border: 1px solid #fde2e2; }
.alert-success { background: #f0f9eb; color: var(--success); border: 1px solid #e1f3d8; }

.desc-list { display: grid; grid-template-columns: 110px 1fr; gap: 0; border: 1px solid var(--border-lighter); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.desc-list dt { background: #fafafa; padding: 9px 12px; border-bottom: 1px solid var(--border-lighter); border-right: 1px solid var(--border-lighter); color: var(--text-secondary); }
.desc-list dd { margin: 0; padding: 9px 12px; border-bottom: 1px solid var(--border-lighter); color: var(--text-regular); word-break: break-all; }
[data-theme="dark"] .desc-list dt { background: #262727; }

/* ---------------- 业务专用 ---------------- */

.paste-box { margin-bottom: 10px; }
.paste-tip { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }
.paste-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.items-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; flex-wrap: wrap; gap: 10px; }
.qty-total { color: var(--primary); font-weight: 600; }
.manual-total { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 14px; font-size: 15px; color: var(--text-regular); }
.manual-total .dollar { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 16px 0 8px; }
.section-title-row { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px; }
.copy-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pre-line { white-space: pre-line; }

.qty-input { width: 110px !important; }
.item-table select { min-width: 240px; }
.unmatched { color: var(--danger); }
.item-hint { font-size: 12px; color: var(--text-secondary); }

.batch-row-new { animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-lighter); margin-bottom: 16px; }
.tab {
  padding: 8px 14px; font-size: 14px; color: var(--text-regular);
  border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.show { display: block; }

.empty { padding: 36px 0; text-align: center; color: var(--text-secondary); font-size: 13px; }

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1d2b3a, #3a6ea5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 420px; max-width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 28px 24px 22px;
}
.login-card h2 { font-size: 21px; text-align: center; margin: 0 0 4px; }
.login-card .sub { text-align: center; color: var(--text-secondary); margin: 0 0 20px; font-size: 13px; }
.captcha-row { display: flex; gap: 8px; width: 100%; }
.captcha-row .input { flex: 1; }
.captcha-img {
  width: 120px; height: 40px; flex: 0 0 120px;
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; object-fit: cover; background: #f6f8fb;
}
.login-card .hints { color: var(--text-secondary); font-size: 12px; line-height: 1.9; margin-top: 16px; border-top: 1px dashed var(--border-lighter); padding-top: 12px; }
.register-link { text-align: center; color: var(--text-regular); margin-top: 14px; font-size: 14px; }
.login-form .field { margin-bottom: 16px; }

.cs-bar { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 12px; z-index: 9999; }
.cs-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .22);
  cursor: pointer; position: relative; border: 0;
  transition: transform .2s, box-shadow .2s;
  color: var(--text-regular);
}
.cs-btn:hover { transform: scale(1.12); box-shadow: 0 4px 20px rgba(0, 0, 0, .28); }
.cs-btn .cs-qr-tip {
  display: none; position: absolute; right: 0; bottom: calc(100% + 10px);
  background: #fff; border-radius: 8px; box-shadow: 0 2px 16px rgba(0, 0, 0, .2);
  padding: 8px; text-align: center;
}
.cs-btn:hover .cs-qr-tip { display: block; }
.cs-qr-tip img { width: 180px; height: 180px; object-fit: contain; border-radius: 4px; display: block; }
.cs-qr-tip p { margin: 6px 0 0; font-size: 12px; color: #606266; }

.steps { display: flex; gap: 0; margin-bottom: 14px; }
.step { font-size: 12px; color: var(--text-secondary); padding-right: 18px; position: relative; }
.step.on { color: var(--primary); }

.upload-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.note { font-size: 12px; color: var(--text-secondary); line-height: 1.7; }

code { background: var(--bg-fill); padding: 1px 5px; border-radius: 3px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

@media (max-width: 900px) {
  .stat-grid, .stat-grid.cols-5 { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .aside { width: 64px; flex: 0 0 64px; }
  .logo { font-size: 12px; }
  .menu-item span { display: none; }
  .header-right .expire-tag { display: none; }
  .modal.wide { width: 100%; }
}
