html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f0f2f5;
  color: #333;
  overflow: hidden;
}

* { box-sizing: border-box; }

/* ===== Login ===== */
.login-wrapper {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-box {
  background: #fff; border-radius: 8px; padding: 40px;
  width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.login-box h1 { text-align: center; margin: 0 0 8px 0; font-size: 22px; }
.login-box .subtitle { text-align: center; color: #999; margin-bottom: 24px; font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; color: #666; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9;
  border-radius: 4px; font-size: 14px; outline: none; transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #667eea; }
.form-group textarea { resize: vertical; min-height: 60px; max-height: 200px; }

.btn {
  display: inline-block; padding: 8px 20px; border: none; border-radius: 4px;
  font-size: 14px; cursor: pointer; transition: all .2s;
}
.btn-primary { background: #667eea; color: #fff; padding: 6px 18px; }
.btn-primary:hover { background: #5a6fd6; }
.login-box .btn-primary { width: 100%; padding: 10px; }
.btn-danger { background: #ff4d4f; color: #fff; }
.btn-danger:hover { background: #e04345; }
.btn-default { background: #fff; color: #333; border: 1px solid #d9d9d9; }
.btn-default:hover { border-color: #667eea; color: #667eea; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-success { background: #52c41a; color: #fff; }
.btn-success:hover { background: #49b016; }
.btn-warning { background: #faad14; color: #fff; }
.btn-warning:hover { background: #e09d12; }

.error-msg { color: #ff4d4f; font-size: 13px; margin-top: 8px; text-align: center; }

/* ===== Layout ===== */
.layout { display: flex; height: 100vh; min-height: 0; overflow: hidden; }
.sidebar {
  width: 200px; background: #001529; color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  height: 100vh; overflow: hidden;
}
.sidebar .logo {
  padding: 20px 16px; font-size: 16px; font-weight: bold;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}
.sidebar .nav { flex: 1; padding: 8px 0; }
.sidebar .nav-item {
  display: block; padding: 12px 24px; color: rgba(255,255,255,0.7);
  text-decoration: none; font-size: 14px; cursor: pointer;
  transition: all .2s; border-left: 3px solid transparent;
}
.sidebar .nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar .nav-item.active { color: #fff; background: #1890ff; border-left-color: #1890ff; }
.sidebar .user-info {
  padding: 16px; border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px; color: rgba(255,255,255,0.5);
}
.sidebar .user-info .name { font-size: 14px; color: #fff; }
.sidebar .user-info .password-link { color: #69c0ff; cursor: pointer; margin-top: 4px; display: inline-block; }
.sidebar .user-info .logout { color: #ff4d4f; cursor: pointer; margin-top: 4px; display: inline-block; }

.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.main-header {
  padding: 12px 24px; background: #fff; border-bottom: 1px solid #e8e8e8;
  font-size: 16px; display: flex; align-items: center; justify-content: space-between;
}
.main-content { flex: 1; min-height: 0; padding: 20px 24px; overflow: auto; }

/* ===== Cards & Tables ===== */
.card {
  background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  padding: 20px; margin-bottom: 16px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #f0f0f0;
}
.card-header h3 { margin: 0; font-size: 15px; }

.stats-row { display: flex; gap: 16px; margin-bottom: 20px; }
.stat-card {
  flex: 1; background: #fff; border-radius: 4px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); text-align: center;
}
.stat-card .num { font-size: 32px; font-weight: bold; color: #1890ff; }
.stat-card .label { font-size: 13px; color: #999; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f0f0f0; }
table th { background: #fafafa; font-weight: 600; white-space: nowrap; }
table tr:hover td { background: #fafafa; }

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.audit-log-summary,
.pagination-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  color: #6b7280;
  font-size: 13px;
}

.pagination-bar {
  justify-content: flex-end;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.raw-payload {
  margin: 0;
  max-height: 56vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: 1px solid #e1e5ea;
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
}

.filter-bar {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar input, .filter-bar select { padding: 7px 10px; font-size: 13px; border: 1px solid #d9d9d9; border-radius: 4px; }
.filter-bar input:focus, .filter-bar select:focus { border-color: #667eea; outline: none; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.45); display: flex;
  justify-content: center; align-items: center; z-index: 1000;
}
.modal {
  background: #fff; border-radius: 6px; width: 600px; max-height: 80vh;
  overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid #f0f0f0;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { cursor: pointer; font-size: 18px; color: #999; border: none; background: none; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #f0f0f0; text-align: right; }

.system-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
}
.system-dialog {
  width: min(520px, calc(100vw - 40px));
  max-height: min(80vh, 640px);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.24);
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
}
.system-dialog-title {
  flex: 0 0 auto;
  font-size: 16px;
  font-weight: 600;
  color: #1f2d3d;
  margin-bottom: 12px;
}
.system-dialog-message {
  flex: 1 1 auto;
  min-height: 44px;
  font-size: 14px;
  line-height: 1.7;
  color: #1f2d3d;
  white-space: normal;
  overflow-y: auto;
  /* 给滚动区让点呼吸空间，避免长 SKU 列表贴边 */
  padding-right: 4px;
}
.system-dialog-actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ===== Status Tags ===== */
.tag { display: inline-block; padding: 2px 8px; border-radius: 2px; font-size: 12px; }
.tag-draft { background: #f0f0f0; color: #999; }
.tag-pending { background: #fff7e6; color: #fa8c16; }
.tag-approved { background: #e6f7ff; color: #1890ff; }
.tag-rejected { background: #fff1f0; color: #f5222d; }
.tag-shipped { background: #f6ffed; color: #52c41a; }
.tag-received { background: #f6ffed; color: #52c41a; }
.tag-completed { background: #f6ffed; color: #52c41a; }
.tag-resolved { background: #f6ffed; color: #52c41a; }

/* ===== Utilities ===== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-16 { margin-top: 16px; }
.mr-8 { margin-right: 8px; }
.gap-8 { display: flex; gap: 8px; }
.flex { display: flex; }
.hidden { display: none !important; }

/* ===== Items Table in Forms ===== */
.items-table { margin-bottom: 12px; }
.items-table td input { width: 100px; text-align: center; }
.items-table td select { min-width: 160px; }

/* ===== Inbound Item Row ===== */
.inbound-row td { vertical-align: middle; }
.inbound-row .diff-cell { font-weight: bold; }
.inbound-row .diff-cell.pos { color: #52c41a; }
.inbound-row .diff-cell.neg { color: #ff4d4f; }

/* ===== Permission Checkbox Grid ===== */
.check-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px 12px;
  padding: 8px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  background: #fafafa;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  user-select: none;
}
.check-item input[type="checkbox"] { margin: 0; }

/* ===== 详情页：顶部工具栏 + 信息网格 ===== */
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar .btn { flex: 0 0 auto; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  padding: 12px 0;
}
.detail-cell label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}
.detail-cell > div {
  font-size: 14px;
  color: #333;
}
.detail-cell select,
.detail-cell textarea,
.detail-cell input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 14px;
}
.detail-cell textarea { min-height: 50px; resize: vertical; }

/* ===== 单号可点击样式 ===== */
.order-link {
  color: #667eea;
  cursor: pointer;
  font-family: 'Consolas', 'Monaco', monospace;
  text-decoration: none;
}
.order-link:hover {
  text-decoration: underline;
  color: #5a6fd6;
}

/* ===== 草稿状态 tag ===== */
.tag-draft {
  background: #fff7e6;
  color: #d48806;
  border: 1px solid #ffd591;
}

/* ===== Comfort polish ===== */
:root {
  --page-bg: #eef2f5;
  --surface: #ffffff;
  --line: #e1e5ea;
  --muted: #6b7280;
  --text: #1f2d3d;
  --primary: #4f6fe5;
  --primary-hover: #3f5ed0;
  --sidebar: #1f2b2f;
  --sidebar-active: #4f6fe5;
  --success: #20c997;
  --warning: #8892a6;
  --danger: #ff5b4f;
}

body {
  background: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.login-wrapper {
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.16), transparent 28%),
    radial-gradient(circle at 85% 80%, rgba(31, 111, 104, 0.18), transparent 30%),
    #eef3f7;
}

.login-box {
  border: 1px solid rgba(15, 47, 46, 0.08);
  box-shadow: 0 18px 60px rgba(15, 47, 46, 0.14);
}

.form-group label {
  color: #4b5563;
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea,
.detail-cell select,
.detail-cell textarea,
.detail-cell input,
.filter-bar input,
.filter-bar select {
  border-color: #d6dce5;
  border-radius: 6px;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.detail-cell select:focus,
.detail-cell textarea:focus,
.detail-cell input:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.btn {
  border-radius: 3px;
  font-weight: 500;
  line-height: 1.4;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-default { border-color: #d6dce5; color: #374151; }
.btn-default:hover { border-color: var(--primary); color: var(--primary); background: #f8fbff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-warning:hover { background: #b45309; }
.btn-danger:hover { background: #b91c1c; }

.sidebar {
  width: 186px;
  background: var(--sidebar);
  color: #f8fafc;
  box-shadow: none;
}

.sidebar .logo {
  order: 0;
  height: 40px;
  padding: 10px 16px;
  letter-spacing: 0;
  color: #ffffff;
  font-size: 17px;
  line-height: 20px;
  border-bottom-color: rgba(255, 255, 255, 0.10);
}

.sidebar .nav {
  order: 3;
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar .nav-item {
  margin: 0;
  padding: 12px 22px;
  border-left: 0;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.sidebar .nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar .nav-item.active {
  color: #ffffff;
  background: var(--sidebar-active);
  border-left-color: transparent;
}

.sidebar .user-info {
  order: 1;
  flex: 0 0 auto;
  padding: 14px 14px 12px;
  border-top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.sidebar .user-info .user-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.6;
  min-width: 0;
}

.sidebar .user-info .user-meta-label {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.45);
}

.sidebar .user-info .user-meta-value {
  min-width: 0;
  color: rgba(255, 255, 255, 0.82);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar .user-info .user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 7px;
}

.sidebar .user-info .name {
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
}

.sidebar .user-info .role {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.52);
}

.sidebar .user-info .password-link {
  display: inline-flex;
  margin-top: 0;
  color: #69c0ff;
  cursor: pointer;
}

.sidebar .user-info .logout {
  display: inline-flex;
  margin-top: 0;
  color: #8dd8c9;
  cursor: pointer;
}

.side-search {
  order: 2;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.side-search input {
  width: 100%;
  height: 30px;
  padding: 6px 10px;
  border: 0;
  border-radius: 2px;
  outline: none;
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
  font-size: 12px;
}

.side-search input::placeholder {
  color: rgba(255, 255, 255, 0.46);
}

.main-header {
  min-height: 40px;
  padding: 0 16px;
  background: #ffffff;
  color: #1f2d3d;
  border-bottom: 1px solid #dfe4ea;
  box-shadow: 0 1px 4px rgba(31, 45, 61, 0.08);
  font-size: 13px;
  font-weight: 500;
}

.header-left,
.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-menu {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  font-size: 16px;
}

.header-actions {
  margin-left: auto;
  color: #6b7280;
  font-size: 12px;
}

.main-content {
  padding: 12px;
  overscroll-behavior: contain;
  transition: opacity .15s ease;
}

.main-content.is-loading {
  opacity: .62;
  pointer-events: none;
}

.card,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: none;
}

.card {
  overflow-x: auto;
  background: #ffffff;
  padding: 12px;
}

.main-content > .card:first-child {
  overflow: visible;
}

.stock-query-card {
  overflow: visible;
}

.stock-query-card #stocksResult {
  overflow-x: auto;
}

.stat-card .num {
  color: var(--primary);
}

.toolbar {
  padding: 6px 0 10px;
  border-bottom-color: var(--line);
  gap: 6px;
}

.main-content > .card:first-child > .toolbar:first-child {
  position: sticky;
  top: -12px;
  z-index: 20;
  margin: -12px -12px 12px;
  padding: 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

table {
  min-width: 760px;
}

table th {
  background: #ffffff;
  color: #1f2d3d;
  font-weight: 600;
}

table th,
table td {
  padding: 8px 10px;
  border: 1px solid #edf0f2;
}

table tr:hover td {
  background: #f9fafb;
}

.modal-overlay {
  background: rgba(15, 23, 42, 0.48);
}

.modal {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.modal-header,
.modal-footer {
  background: #f8fafc;
}

.tag {
  border-radius: 999px;
  padding: 2px 9px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 40px;
  margin: 0;
}

.toast {
  position: fixed;
  right: 24px;
  top: 22px;
  z-index: 2000;
  padding: 10px 14px;
  border-radius: 8px;
  background: #334155;
  color: #fff;
  box-shadow: 0 12px 30px rgba(16, 42, 67, 0.22);
  font-size: 13px;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Balanced action buttons */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border: 1px solid var(--success);
}

.btn-success:hover {
  background: #16b486;
  border-color: #16b486;
  color: #fff;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  border: 1px solid var(--warning);
}

.btn-warning:hover {
  background: #747e92;
  border-color: #747e92;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: #ee4f44;
  border-color: #ee4f44;
  color: #fff;
}

.btn-default {
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
}

.btn-default:hover {
  background: #f9fafb;
  border-color: var(--primary);
  color: var(--primary);
}

.filter-bar,
.detail-grid {
  background: #ffffff;
  border: 0;
  border-radius: 0;
  padding: 8px 0;
}

.stat-card {
  background: #ffffff;
}

/* Permission editor: compact matrix instead of wide generic table */
.modal {
  width: min(760px, calc(100vw - 32px));
}

.permission-matrix-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
}

.permission-table {
  width: auto;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 12px;
}

.permission-table th,
.permission-table td {
  padding: 7px 8px;
  border: 1px solid #edf0f2;
}

.permission-table .module-col {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  text-align: left;
  white-space: nowrap;
}

.permission-table .action-col,
.permission-table .action-cell {
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  text-align: center;
}

.permission-table input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  vertical-align: middle;
}

.permission-table input[type="checkbox"]:disabled {
  opacity: .28;
}

/* Detail pages: keep forms readable on wide monitors */
#mainContent .card > .detail-grid,
#mainContent .card > .form-group {
  max-width: 1120px;
}

#mainContent .card > .detail-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px 20px;
}

#mainContent .card > .form-group textarea {
  min-height: 86px;
}

#mainContent .card > h3 {
  max-width: 1120px;
  margin: 18px 0 12px !important;
  padding-top: 8px;
  border-top: 1px solid #edf0f2;
  font-size: 16px;
}

.items-table {
  margin-top: 10px;
  width: auto;
  min-width: 0;
  max-width: 100%;
  table-layout: auto;
}

.detail-items-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 1120px;
  padding: 8px 10px;
  border: 1px solid #e4e8ee;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #f8fafc;
  flex-wrap: wrap;
}

.detail-import-wrap {
  position: relative;
}

.detail-import-trigger {
  min-width: 74px;
}

.detail-import-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 120;
  min-width: 120px;
  padding: 4px;
  border: 1px solid #d6dce5;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.detail-import-wrap.is-open .detail-import-menu {
  display: block;
}

.detail-import-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #374151;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}

.detail-import-menu button:hover {
  background: #f3f6fb;
  color: var(--primary);
}

.location-editor {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 220px;
}

.location-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.location-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 180px;
  padding: 3px 6px;
  border-radius: 4px;
  background: #eef4ff;
  color: #1d4ed8;
  font-size: 12px;
}

.location-tag-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-tag button {
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  line-height: 16px;
}

.location-tag button:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

.location-add-input {
  width: 100%;
  min-width: 130px;
  max-width: 160px;
  padding: 6px 8px;
  border: 1px solid #d6dce5;
  border-radius: 4px;
  font-size: 13px;
}

.location-add-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.08);
}

/* ===== Multi-Select Dropdown ===== */
.msel-wrap {
  position: relative;
  width: 280px;
}

.msel-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border: 1px solid #d6dce5;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: border-color .2s;
  font-size: 14px;
}

.msel-trigger:hover {
  border-color: var(--primary);
}

.msel-trigger .msel-label {
  flex: 1;
  color: #1f2d3d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msel-trigger .msel-arrow {
  font-size: 10px;
  color: #999;
  margin-left: 8px;
  transition: transform .2s;
}

.msel-dropdown.is-open ~ .msel-trigger .msel-arrow,
.msel-trigger:has(+ .msel-dropdown.is-open) .msel-arrow {
  transform: rotate(180deg);
}

.msel-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #d6dce5;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.09);
  display: none;
  max-height: 260px;
  overflow-y: auto;
}

.msel-dropdown.is-open {
  display: block;
}

.stock-query-card .msel-dropdown {
  max-height: none;
  overflow-y: visible;
}

.msel-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  transition: background .12s;
  margin: 0;
}

.msel-opt:hover {
  background: #f5f7fa;
}

.batch-bar { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-height: 36px; }
.batch-bar.hidden { display: none; }
.batch-bar .count { color: #666; font-size: 13px; }
th.cb-cell, td.cb-cell { width: 36px; text-align: center; }
th.cb-cell input, td.cb-cell input { margin: 0; cursor: pointer; }
th.idx-cell, td.idx-cell { width: 40px; text-align: center; color: #999; font-size: 12px; }
.msel-opt input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.msel-opt:first-child {
  border-bottom: 1px solid #edf0f2;
  padding-bottom: 10px;
  margin-bottom: 2px;
  font-weight: 500;
}

.msel-opt span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-product-search {
  position: relative;
  max-width: 1120px;
  padding: 10px;
  border: 1px solid #e4e8ee;
  border-top-color: #eef1f5;
  background: #fff;
}

.detail-product-search label {
  display: block;
  margin-bottom: 6px;
  color: #5f6b7a;
  font-size: 12px;
  font-weight: 600;
}

.detail-product-search input {
  max-width: 520px;
  height: 30px;
  padding: 6px 10px;
  border: 1px solid #d7dde6;
  border-radius: 3px;
  font-size: 13px;
  outline: none;
}

.detail-product-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79, 111, 229, .12);
}

.detail-product-search > div {
  display: none;
  z-index: 120;
  max-width: 520px;
  width: calc(100% - 20px);
  margin-top: 0 !important;
  border: 1px solid #b8c4d6 !important;
  border-top: 0 !important;
  border-radius: 0 !important;
  background: #fff;
  box-shadow: none;
  max-height: 210px !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
}

.detail-product-search > div.search-dropdown {
  max-width: none;
  width: auto;
}

.detail-product-search > div.is-open:not(:empty) {
  display: block;
}

.detail-product-search > div > div {
  min-height: 28px;
  padding: 5px 10px !important;
  border-bottom: 0 !important;
  color: #111827;
  line-height: 18px;
}

.detail-product-search > div > div:hover {
  background: #e9eef7 !important;
}

.detail-stats {
  display: flex;
  gap: 18px;
  max-width: 1120px;
  padding: 8px 10px;
  border: 1px solid #e4e8ee;
  border-top: 0;
  background: #fbfcfe;
  color: #4b5563;
  font-size: 13px;
}

.detail-stats b {
  color: #1f2d3d;
  font-weight: 700;
}

.items-table input[type="checkbox"],
.items-table .detail-row-check {
  width: 14px;
  height: 14px;
  padding: 0;
  margin: 0;
}

.items-table th:first-child:has(input[type="checkbox"]),
.items-table td:first-child:has(.detail-row-check) {
  text-align: center;
}

.items-table .detail-sku-cell {
  color: #1f2d3d;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.items-table .detail-name-cell {
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.items-table td .detail-row-check + input[type="hidden"],
.items-table .detail-sku-cell input[type="hidden"] {
  display: none;
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { min-height: 100vh; height: auto; flex-direction: column; overflow: visible; }
  .sidebar {
    width: 100%;
    height: auto;
    min-height: auto;
    overflow: visible;
  }
  .sidebar .nav {
    display: flex;
    overflow-x: auto;
    padding: 8px;
  }
  .sidebar .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .sidebar .user-info {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
  }
  .main { min-height: 0; overflow: visible; }
  .main-content { padding: 16px; overflow: visible; }
  .main-content > .card:first-child > .toolbar:first-child {
    top: 0;
    margin: -16px -16px 12px;
    padding: 16px;
  }
  .stats-row { flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal {
    width: calc(100vw - 24px);
    max-height: 88vh;
  }
}

/* ===== 新手指南 ===== */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.guide-card {
  background: #fafbfc;
  border-radius: 10px;
  padding: 16px 18px;
  border: 1px solid #e8ecf1;
  transition: box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.guide-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-color: #d0d7de;
}
.guide-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.guide-card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 6px;
  background: #4a90d9;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.guide-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
}
.guide-card-text {
  margin: 0;
  font-size: 13px;
  color: #5a5f6e;
  line-height: 1.65;
  flex: 1;
}
@media (max-width: 768px) {
  .guide-grid { grid-template-columns: 1fr; }
}

/* ===== 主页流程卡片（可折叠） ===== */
.flow-section {
  margin-top: 20px;
}
.flow-section + .flow-section {
  margin-top: 24px;
}
.flow-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #8a8f99;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin: 0 0 10px;
  padding-left: 2px;
}
.flow-card {
  background: #fafbfc;
  border: 1px solid #e8ecf1;
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.flow-card:hover {
  border-color: #d0d7de;
}
.flow-card[open] {
  background: #ffffff;
  border-color: #c8d1dc;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.flow-card-summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}
.flow-card-summary::-webkit-details-marker { display: none; }
.flow-card-summary::marker { content: ''; }
.flow-card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 7px;
  background: #4a90d9;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.flow-card[data-group="basic"] .flow-card-num {
  background: #8a96a8;
}
.flow-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a2e;
  flex-shrink: 0;
}
.flow-card-hint {
  font-size: 12px;
  color: #9aa0a8;
  flex: 1;
  margin-left: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flow-card-arrow {
  color: #b0b6bf;
  font-size: 14px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.flow-card[open] .flow-card-arrow {
  transform: rotate(180deg);
  color: #4a90d9;
}
.flow-card-body {
  padding: 4px 18px 18px;
  border-top: 1px solid #eef0f3;
}
.flow-card-lead {
  font-size: 13px;
  color: #5a5f6e;
  line-height: 1.65;
  margin: 12px 0 14px;
}
.flow-card-tip {
  background: #fff8e6;
  border-left: 3px solid #f0b429;
  border-radius: 0 6px 6px 0;
  padding: 10px 12px;
  font-size: 12px;
  color: #5a5f6e;
  line-height: 1.6;
}
.flow-card-tip strong {
  color: #8a5a00;
  font-weight: 600;
}
@media (max-width: 768px) {
  .flow-card-hint { display: none; }
  .flow-card-summary { gap: 10px; padding: 12px 14px; }
  .flow-card-body { padding: 4px 14px 14px; }
}

/* ===== 业务全貌卡片 + 图例 ===== */
.flow-card-overview {
  background: linear-gradient(135deg, #fff8e6 0%, #ffffff 60%);
  border-color: #f0d99b;
}
.flow-card-overview:hover { border-color: #e0b95c; }
.flow-card-overview[open] {
  background: #ffffff;
  border-color: #e0b95c;
  box-shadow: 0 2px 12px rgba(240, 180, 41, 0.15);
}
.flow-card-num-star {
  background: linear-gradient(135deg, #f0b429 0%, #e0931c 100%) !important;
  font-size: 14px;
}
.flow-overview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 14px;
  padding: 10px 12px;
  background: #fafbfc;
  border-radius: 8px;
  border: 1px solid #eef0f3;
}
.legend-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid;
  line-height: 1.6;
}
.legend-req   { background: #e3f2fd; border-color: #4a90d9; color: #1857a3; }
.legend-trans { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.legend-ret   { background: #fff3e0; border-color: #fb8c00; color: #c25600; }
.legend-recv  { background: #fffbe6; border-color: #f0b429; color: #8a5a00; }
.legend-inv   { background: #f3e5f5; border-color: #9c27b0; color: #6a1b7a; }
.legend-fei   { background: #e0f7fa; border-color: #00acc1; color: #00626f; }
.legend-loss  { background: #ffebee; border-color: #e91e63; color: #a3104a; }
.flow-overview-img-wrap {
  margin: 0 0 14px;
  border: 1px solid #eef0f3;
  border-radius: 8px;
  overflow: auto;
  background: #ffffff;
  padding: 12px;
  text-align: center;
}
.flow-overview-img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.flow-overview-img-fallback {
  padding: 24px;
  background: #fff8e6;
  border-radius: 6px;
  color: #8a5a00;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}
.flow-overview-img-fallback code {
  background: #f5f5f7;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  color: #c25600;
}

/* ===== Column header funnel filter ===== */
.col-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 8px;
  padding: 0;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  color: #595959;
  cursor: pointer;
  vertical-align: middle;
  transition: all .15s;
}
.col-filter-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}
.col-filter-btn:hover {
  background: #eef0ff;
  color: #667eea;
  border-color: #667eea;
}
.col-filter-btn.active {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102,126,234,.15);
}
.col-filter-pop {
  position: absolute;
  z-index: 1000;
  width: 240px;
  background: #fff;
  border: 1px solid #d6dce5;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  font-size: 13px;
}
.cfp-search { padding: 8px; border-bottom: 1px solid #f0f0f0; }
.cfp-search input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}
.cfp-search input:focus { border-color: #667eea; outline: none; }
.cfp-list { max-height: 240px; overflow-y: auto; padding: 4px 0; }
.cfp-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  margin: 0;
}
.cfp-opt:hover { background: #f5f7fa; }
.cfp-opt.cfp-all {
  font-weight: 500;
  border-bottom: 1px solid #f0f0f0;
}
.cfp-opt input { margin: 0; flex-shrink: 0; accent-color: #667eea; }
.cfp-opt span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1f2d3d;
}
.cfp-opt span.cfp-empty { color: #999; font-style: italic; }
.cfp-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
  border-radius: 0 0 6px 6px;
}
.cfp-empty-result { padding: 16px; text-align: center; color: #999; font-size: 12px; }

