:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --sidebar: #101828;
  --sidebar-hover: #1d2939;
  --green: #079455;
  --green-bg: #ecfdf3;
  --amber: #b54708;
  --amber-bg: #fffaeb;
  --red: #b42318;
  --red-bg: #fef3f2;
  --blue-bg: #eff8ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 18px 18px 14px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
  border-bottom: 1px solid #1f2937;
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: #98a2b3; letter-spacing: 0; margin-top: 2px; }

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: #cbd5e1;
  font-size: 13.5px;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav .ico { width: 16px; text-align: center; opacity: .9; }
.nav .group { padding: 14px 10px 6px; font-size: 11px; color: #667085; letter-spacing: .5px; }

.sidebar-foot { padding: 12px 16px; border-top: 1px solid #1f2937; font-size: 12px; color: #98a2b3; }

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

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }

.content { padding: 20px 24px 48px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-head h2 { font-size: 14.5px; margin: 0; font-weight: 650; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat .hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat.accent .value { color: var(--accent); }
.stat.green .value { color: var(--green); }
.stat.amber .value { color: var(--amber); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th {
  text-align: left;
  padding: 10px 14px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}
table.table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f2f4f7;
  vertical-align: middle;
}
table.table tbody tr:hover { background: #fafbfc; }
table.table tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.empty { padding: 44px 18px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: #f2f4f7;
  color: #475467;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--accent-dark); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: .12s;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--red); border-color: #fecdca; }
.btn.danger:hover { background: var(--red-bg); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { filter: brightness(.94); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 表单 ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: #344054; font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; min-height: 76px; }
.form-actions {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { min-width: 140px; }

/* ---------- 提示 ---------- */
.flash {
  padding: 11px 15px;
  border-radius: 9px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.flash.ok { background: var(--green-bg); border-color: #abefc6; color: #067647; }
.flash.err { background: var(--red-bg); border-color: #fecdca; color: #b42318; }

/* ---------- 滤镜条 ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=text] { width: 220px; }
.filters select { width: auto; min-width: 130px; }

/* ---------- 时间线 ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 0 4px 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 26px;
  border-left: 2px solid #e4e7ec;
  margin-left: 7px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}
.timeline .t { font-weight: 600; font-size: 13.5px; }
.timeline .m { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- 详情键值 ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 24px;
}
.kv .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv .v { font-size: 13.5px; font-weight: 550; }

/* ---------- 商品缩略 ---------- */
.sku { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: #475467; }
.prod-name { font-weight: 600; }
.prod-sub { font-size: 12px; color: var(--muted); }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1e3a8a22, transparent 45%),
    radial-gradient(circle at 80% 80%, #2563eb22, transparent 45%), #0f172a;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px 26px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .45);
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; margin-top: 6px; }
.login-hint {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 行编辑表 ---------- */
.item-table { width: 100%; border-collapse: collapse; }
.item-table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 8px;
  font-weight: 600;
}
.item-table td { padding: 5px 8px; vertical-align: middle; }
.item-table select, .item-table input { font-size: 13px; padding: 7px 9px; }
.item-row-remove {
  border: none;
  background: none;
  color: var(--red);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
}

.serial-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.serial-list { display: flex; flex-wrap: wrap; gap: 6px; }
.serial-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: #f2f4f7;
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 6px;
}

.section-title { font-size: 13px; font-weight: 650; margin: 0 0 10px; color: #344054; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

@media (max-width: 860px) {
  .sidebar { width: 62px; flex-basis: 62px; }
  .sidebar .brand { font-size: 0; padding: 16px 0; text-align: center; }
  .sidebar .brand small { display: none; }
  .nav .group { display: none; }
  .nav a { justify-content: center; padding: 9px 6px; }
  .nav a .txt { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
}

/* ---------- 代理商后台（独立门户，无侧边栏） ---------- */
.portal-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 6;
}
.portal-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.portal-brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.portal-brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.portal-nav { display: flex; gap: 20px; flex: 1; }
.portal-nav a {
  color: #475467;
  font-size: 14px;
  padding: 18px 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.portal-nav a:hover { color: var(--accent); text-decoration: none; }
.portal-nav a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.portal-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.portal-main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.portal-hero {
  background: linear-gradient(120deg, #1e3a8a, #2563eb);
  color: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  margin-bottom: 20px;
}
.portal-hero h2 { margin: 0 0 4px; font-size: 18px; }
.portal-hero p { margin: 0; font-size: 13px; opacity: .85; }
.portal-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 25% 20%, #1e3a8a33, transparent 45%),
    radial-gradient(circle at 75% 80%, #2563eb33, transparent 45%), #0b1220;
  padding: 20px;
}
.price-strong { font-weight: 700; color: #b42318; font-variant-numeric: tabular-nums; }
.price-old { font-size: 12px; color: var(--muted); text-decoration: line-through; }
.qty-input { width: 88px !important; }
@media (max-width: 760px) {
  .portal-inner { gap: 14px; }
  .portal-nav { gap: 12px; overflow-x: auto; }
  .portal-nav a { white-space: nowrap; font-size: 13px; }
  .portal-user span { display: none; }
}

/* ---------- 表格转卡片（窄屏，用于代理商后台） ---------- */
@media (max-width: 720px) {
  .table.responsive thead { display: none; }
  .table.responsive,
  .table.responsive tbody,
  .table.responsive tr,
  .table.responsive td { display: block; width: 100%; }
  .table.responsive tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    margin-bottom: 10px;
    padding: 6px 14px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
  }
  .table.responsive td {
    border: none;
    padding: 7px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    text-align: right;
    font-size: 14px;
  }
  .table.responsive td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12.5px;
    text-align: left;
    flex: 0 0 auto;
    font-weight: 500;
  }
  .table.responsive td:empty { display: none; }
  .table.responsive tfoot { display: block; }
  .table.responsive tfoot tr { border: none; box-shadow: none; }
  .table.responsive .num { text-align: right; }
}

/* ---------- 统计条与趋势图 ---------- */
.bar-row { margin-bottom: 16px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.bar-head .name { font-size: 13.5px; font-weight: 600; }
.bar-head .name small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.bar-head .val { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track {
  height: 8px;
  background: #f2f4f7;
  border-radius: 6px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #5b4ae8, #8e7cf7);
}
.bar-fill.warn { background: linear-gradient(90deg, #f04438, #f79009); }

.trend {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 150px;
  padding-top: 8px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.trend-val { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.trend-bar {
  width: 100%;
  max-width: 46px;
  min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #7b6bf2, #5b4ae8);
  transition: height .3s;
}
.trend-label { font-size: 11.5px; color: var(--muted); }

.stats-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .stats-cols { grid-template-columns: 1fr; }
}

/* ---------- 复制提示 ---------- */
.wms-toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 12px);
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(16, 24, 40, .92);
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 9999;
  pointer-events: none;
  word-break: break-all;
}
.wms-toast.show { opacity: 1; transform: translate(-50%, 0); }


/* ---------- 日期范围下拉筛选 ---------- */
.df { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.df-preset { width: auto; min-width: 112px; }
.df-custom { display: flex; align-items: center; gap: 6px; }
/* 类上的 display 会盖掉浏览器默认的 [hidden]，这里显式兜一下 */
.df-custom[hidden] { display: none; }
.df-custom i { font-style: normal; color: var(--muted); font-size: 12.5px; }
.df-custom input[type="date"] { width: auto; }

/* ---------- 复制失败的手动兜底弹窗 ---------- */
.wms-copy-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9998;
}
.wms-copy-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .3);
}
.wms-copy-title { font-size: 13.5px; font-weight: 600; margin-bottom: 10px; }
.wms-copy-box textarea {
  width: 100%;
  min-height: 88px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  resize: none;
  margin-bottom: 12px;
}
.wms-copy-box .btn { width: 100%; justify-content: center; }
