:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --text-sub: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
}

button, input, select { font-family: inherit; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--text-sub); margin-bottom: 20px; font-size: 13px; }

/* ---------- 通用 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-sub); font-size: 13px; }
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); }
.field input:disabled { background: #f3f4f6; color: var(--text-sub); }

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 4px; }

.hidden { display: none !important; }

/* ---------- 顶部栏 ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .user { color: var(--text-sub); font-size: 13px; }
.topbar .user b { color: var(--text); }

.container { padding: 20px 24px 40px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px;
  align-items: end;
}
.filters .field { margin-bottom: 0; }
.filter-actions { display: flex; gap: 8px; align-items: center; }

/* 商品多选 */
.multiselect { position: relative; }
.ms-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 34px;
  cursor: pointer;
  background: #fff;
}
.ms-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  min-width: 340px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 300px;
  overflow: auto;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  padding: 6px 0;
}
.ms-list .ms-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  cursor: pointer;
}
.ms-list .ms-item:hover { background: #f3f6fb; }
.ms-list .ms-item input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  border: none;
  accent-color: var(--primary);
}
.ms-list .ms-code {
  flex-shrink: 0;
  color: var(--text-sub);
  font-size: 12px;
}
.ms-list .ms-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.ms-list .ms-meta {
  flex-shrink: 0;
  color: var(--text-sub);
  font-size: 12px;
}
.ms-empty { padding: 8px 12px; color: var(--text-sub); }

/* ---------- 表格 ---------- */
.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.table-head .count { color: var(--text-sub); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
th { background: #f8fafc; color: var(--text-sub); font-weight: 600; font-size: 13px; }
tbody tr:hover { background: #f9fbff; }
td.addr, td.name { white-space: normal; min-width: 200px; }

/* 表头工具条分组 */
.table-head .th-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.table-head .th-right { margin-left: auto; }

/* 操作列：横向滚动时固定在最右侧 */
.table-wrap thead th.sticky-col,
.table-wrap tbody td.sticky-col {
  position: sticky;
  right: 0;
}
/* 操作列底色比行内容略深，横向滚动时与正文区域清晰分离 */
.table-wrap thead th.sticky-col {
  z-index: 3;
  background: #e2e8f0;
  box-shadow: -6px 0 8px -6px rgba(15, 23, 42, 0.25);
}
.table-wrap tbody td.sticky-col {
  z-index: 2;
  background: #eef2f7;
  box-shadow: -6px 0 8px -6px rgba(15, 23, 42, 0.2);
}
.table-wrap tbody tr:hover td.sticky-col { background: #e3e9f2; }

/* 操作列内按钮间距 */
.table-wrap td.op-cell { white-space: nowrap; }
.table-wrap td.op-cell .btn + .btn,
.table-wrap td.op-cell .tag + .btn { margin-left: 6px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.tag-shipped { background: #dcfce7; color: var(--success); }
.tag-unshipped { background: #fef3c7; color: var(--warn); }
.tag-noship { background: #e0f2fe; color: #0369a1; }
.btn-reship { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.btn-reship:hover { background: #ffedd5; }
.tag-off { background: #f3f4f6; color: var(--text-sub); }
.tag-type-book { background: #dcfce7; color: #15803d; }
.tag-type-course { background: #dbeafe; color: #1d4ed8; }
.tag-type-unit { background: #ede9fe; color: #6d28d9; }
.tag-super { background: #fef3c7; color: #b45309; margin-left: 8px; }
.tag-agency-system { background: #fef3c7; color: #b45309; }
.btn-danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.op-ghost { color: var(--text-sub); font-size: 12px; cursor: not-allowed; margin-left: 6px; }
input:disabled { background: #f3f4f6; color: #374151; cursor: not-allowed; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.pager .info { color: var(--text-sub); font-size: 13px; margin-right: auto; }

.empty { padding: 40px; text-align: center; color: var(--text-sub); }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  width: 520px;
  max-width: 92vw;
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  max-height: 90vh;
  overflow: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .order-info {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-sub);
}
.modal .order-info b { color: var(--text); }
.modal .order-info .info-label {
  display: inline-block;
  min-width: 56px;
  color: var(--text-sub);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.hint { color: var(--text-sub); font-size: 12px; margin-top: 4px; }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  z-index: 100;
  font-size: 13px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- 顶部标签页 ---------- */
.navtabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0;
}
.navtab {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #f1f5f9;
  color: var(--text-sub);
  padding: 8px 20px;
  font-size: 14px;
  cursor: pointer;
}
.navtab:hover { color: var(--text); }
.navtab-active { background: #fff; color: var(--primary); font-weight: 600; }

/* ---------- 账号管理 ---------- */
.users-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.users-toolbar input,
.users-toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.uform {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  max-height: 56vh;
  overflow: auto;
  padding: 2px;
}
.uform .field:nth-child(odd) { padding-right: 8px; }
@media (max-width: 720px) {
  .uform { grid-template-columns: 1fr; }
}
