:root {
  --primary: #2f6bff;
  --primary-light: #5b8bff;
  --primary-bg: #eaf0ff;
  --danger: #e5484d;
  --danger-bg: #fdecec;
  --warn: #f5a623;
  --warn-bg: #fef4e5;
  --success: #30a46c;
  --success-bg: #e8f7f0;
  --purple: #8e4ec6;
  --purple-bg: #f4ebfb;
  --teal: #0e9a8f;
  --teal-bg: #e6f7f6;
  --text-1: #1c2333;
  --text-2: #5b6472;
  --text-3: #9aa3b2;
  --line: #e8ecf3;
  --bg: #f4f6fa;
  --card: #ffffff;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(28, 35, 51, .05), 0 4px 14px rgba(28, 35, 51, .06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px; color: var(--text-1); background: var(--bg);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}
input, select, textarea, button { font-family: inherit; font-size: 13px; color: var(--text-1); }
button { cursor: pointer; border: none; background: none; }
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d3d9e4; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bcc5d4; }

/* ===== 统一图标 ===== */
svg.i { width: 14px; height: 14px; display: block; flex-shrink: 0; }
.nav-ico svg.i { width: 18px; height: 18px; }
.search-ico svg.i { width: 14px; height: 14px; }
.modal-close svg.i { width: 15px; height: 15px; }
.rt-dot svg.i { width: 12px; height: 12px; }
.btn svg.i { width: 14px; height: 14px; }
.btn-primary svg.i, .btn-success svg.i { color: #fff; }

/* ===== 登录 ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef3ff 0%, #f3eeff 50%, #ecf7f4 100%);
  padding: 20px;
}
.login-card {
  width: 400px; background: #fff; border-radius: var(--r-lg); padding: 40px 34px 30px;
  box-shadow: 0 24px 64px rgba(47, 107, 255, .14); border: 1px solid rgba(47, 107, 255, .08);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; box-shadow: 0 6px 16px rgba(47, 107, 255, .28);
}
.logo-name { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.logo-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.input {
  height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px;
  width: 100%; background: #fafbfd; transition: border-color .15s, box-shadow .15s, background .15s;
  color: var(--text-1);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); background: #fff; }
.input::placeholder { color: var(--text-3); }
textarea.input { padding: 10px 12px; line-height: 1.6; }
.login-err { color: var(--danger); font-size: 12px; min-height: 18px; }
.login-hint { font-size: 12px; color: var(--text-3); text-align: center; }

/* ===== 自定义原生控件 ===== */
/* select 去掉原生箭头，用统一 SVG 箭头 */
select.input {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px;
}
select.input:focus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232f6bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
/* checkbox 自定义 */
input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 16px; height: 16px;
  border: 1.5px solid #c8cfdc; border-radius: 5px; background: #fff; cursor: pointer;
  position: relative; transition: border-color .15s, background .15s; vertical-align: middle; flex-shrink: 0;
}
input[type="checkbox"]:hover { border-color: var(--primary); }
input[type="checkbox"]:checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 4.5px; top: 1px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
/* date 输入 */
input[type="date"].input { padding-right: 8px; cursor: pointer; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap; user-select: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: #eef1f6; color: var(--text-1); }
.btn-secondary:hover { background: #e2e7f0; }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success-bg); color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: #eef1f6; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; height: 42px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 布局 ===== */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 212px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; border-bottom: 1px solid #f1f3f8; margin-bottom: 14px; }
.sidebar-logo .logo-mark { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }
.sidebar-logo .logo-name { font-size: 15px; }
.sidebar-logo .logo-sub { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2); transition: all .15s; text-align: left; width: 100%; position: relative;
}
.nav-item:hover { background: #f4f6fa; color: var(--text-1); }
.nav-item.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -12px; top: 20%; bottom: 20%; width: 3px; border-radius: 2px; background: var(--primary); }
.nav-ico { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-footer { border-top: 1px solid var(--line); padding-top: 12px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ===== 卡片 / 表格 ===== */
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px 20px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; width: 240px; }
.search-box .input { padding-left: 32px; }
.search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); display: flex; align-items: center; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; color: var(--text-3); font-weight: 500;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f8f9fc;
}
.table th:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.table th:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.table td { padding: 12px; border-bottom: 1px solid #f1f3f8; font-size: 13px; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: #fafbfd; }
.table tbody tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); font-size: 13px; }

/* 徽标 */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 6px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-blue { background: var(--primary-bg); color: var(--primary); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warn-bg); color: var(--warn); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: #eef1f6; color: var(--text-2); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(28, 35, 51, .42); display: flex; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal {
  background: #fff; border-radius: var(--r-lg); box-shadow: 0 24px 70px rgba(28, 35, 51, .25);
  width: 640px; max-width: calc(100vw - 40px); max-height: calc(100vh - 60px);
  display: flex; flex-direction: column; animation: popIn .18s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-header { padding: 18px 22px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.modal-close { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.modal-close:hover { background: #f0f2f7; color: var(--text-1); }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-footer { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #f4f6fa; }

/* 表单 */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; margin-bottom: 12px; }
.form-row .full { grid-column: 1 / -1; }
.form-label { font-size: 12px; color: var(--text-2); font-weight: 500; margin-bottom: 6px; display: block; }
.form-label .req { color: var(--danger); }

/* Toast */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1c2333; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: popIn .2s ease; display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* 商品卡片（销售下单） */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.prod-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px;
  cursor: pointer; transition: all .15s; position: relative;
}
.prod-card:hover { border-color: var(--primary); box-shadow: 0 6px 18px rgba(47, 107, 255, .12); transform: translateY(-1px); }
.prod-card .pc-name { font-weight: 600; font-size: 13px; line-height: 1.4; }
.prod-card .pc-spec { font-size: 11px; color: var(--text-3); margin: 4px 0 8px; }
.prod-card .pc-price { font-size: 16px; font-weight: 700; color: var(--primary); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.prod-card .pc-stock { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.prod-card .pc-qty { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.prod-card .pc-qty input { width: 100%; height: 30px; border: 1px solid var(--line); border-radius: 7px; text-align: center; font-size: 13px; }
.prod-card.out { opacity: .45; }
.qty-btn { width: 26px; height: 26px; border-radius: 7px; background: #eef1f6; font-size: 15px; flex-shrink: 0; color: var(--text-1); }
.qty-btn:hover { background: #e2e7f0; }

/* 订单明细 */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { text-align: left; font-size: 12px; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #f8f9fc; white-space: nowrap; }
.items-table td { padding: 9px 10px; border-bottom: 1px solid #f1f3f8; font-size: 13px; }
.items-table tr:last-child td { border-bottom: none; }
.items-table input { height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; width: 90px; text-align: center; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-box { flex: 1; min-width: 160px; background: #fff; border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-box .sb-label { font-size: 12px; color: var(--text-2); }
.stat-box .sb-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.8; }

/* 勾选标签 */
.chk { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; font-size: 13px; color: var(--text-2); cursor: pointer; }

/* 品牌分组折叠（销售下单） */
.brand-group { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: #fff; }
.brand-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; background: #f6f8fc; user-select: none; }
.brand-head:hover { background: #eef2fa; }
.brand-arrow { font-size: 11px; color: var(--primary); width: 14px; font-family: var(--mono); }
.brand-name { font-weight: 700; font-size: 14px; }
.brand-count { font-size: 12px; color: var(--text-3); }
.brand-sum { font-size: 12px; color: var(--text-3); margin-left: auto; }
.brand-group .prod-grid { padding: 10px; }

/* ===== 退货进度 ===== */
/* 列表迷你进度 */
.rt-mini { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; margin-top: 6px; }
.rt-mini b { font-size: 10px; font-weight: 400; color: var(--text-3); padding: 1px 5px; border-radius: 5px; background: #eef1f6; }
.rt-mini b.on { background: var(--primary); color: #fff; font-weight: 600; }
.rt-mini b.cur { background: var(--primary-bg); color: var(--primary); font-weight: 700; }
.rt-mini i { width: 8px; height: 2px; background: #dfe3ec; border-radius: 1px; }
.rt-mini i.on { background: var(--primary); }
/* 详情完整进度条 */
.rt-steps { display: flex; align-items: flex-start; margin: 4px 0 18px; background: #f8f9fc; border-radius: var(--r-md); padding: 16px 10px 14px; }
.rt-step { flex: 1; text-align: center; position: relative; }
.rt-step::before { content: ''; position: absolute; top: 12px; left: calc(-50% + 14px); width: calc(100% - 28px); height: 2px; background: #dfe3ec; }
.rt-step:first-child::before { display: none; }
.rt-step.done::before, .rt-step.cur::before { background: var(--primary); }
.rt-dot {
  width: 24px; height: 24px; border-radius: 50%; margin: 0 auto; background: #eef1f6; color: var(--text-3);
  font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; border: 2px solid transparent;
}
.rt-step.done .rt-dot { background: var(--primary); color: #fff; }
.rt-step.done .rt-dot svg.i { color: #fff; }
.rt-step.cur .rt-dot { border-color: var(--primary); color: var(--primary); }
.rt-label { font-size: 11px; color: var(--text-3); margin-top: 6px; }
.rt-step.done .rt-label, .rt-step.cur .rt-label { color: var(--primary); font-weight: 600; }
.rt-step.fail .rt-dot { border-color: var(--danger); color: var(--danger); }
.rt-step.fail .rt-label { color: var(--danger); font-weight: 600; }
.rt-step.fail::before { background: var(--danger); }
