:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #ef4444;
  --success: #16a34a;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --sidebar-bg: #f1f5f9;
  --sidebar-text: #475569;
  --sidebar-active: #2563eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

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

.sidebar {
  width: 210px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar .logo {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.2;
  font-size: 22px;
  font-weight: 700;
  color: #1e293b;
  background: transparent;
  letter-spacing: 1px;
}
.sidebar .logo .logo-sub {
  font-size: 12px;
  font-weight: 400;
  color: rgba(15, 23, 42, 0.55);
  letter-spacing: 3px;
}
.sidebar .logo .logo-img {
  height: 72px;
  max-width: 190px;
  object-fit: contain;
  display: block;
}
.sidebar .logo .logo-text {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  letter-spacing: 5px;
  margin-top: 4px;
}
.sidebar .logo .logo-sub2 {
  font-size: 11px;
  font-weight: 400;
  color: #64748b;
  text-align: center;
  letter-spacing: 2px;
  margin-top: 2px;
}

.sidebar nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.28); border-radius: 4px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav { scrollbar-width: thin; scrollbar-color: rgba(15,23,42,.28) transparent; }

.sidebar nav a {
  display: block;
  margin: 3px 0;
  color: var(--sidebar-text);
  border-radius: 6px;
}

.sidebar nav a:hover { background: rgba(15, 23, 42, 0.06); text-decoration: none; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }

.sidebar .nav-main {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.sidebar .nav-main svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 8px;
  opacity: 0.85;
}
.sidebar .nav-main.active svg { opacity: 1; }

.sidebar .nav-head {
  cursor: default;
}

.sidebar nav a.nav-sub {
  padding: 6px 14px 6px 32px;
  font-size: 12.5px;
  font-weight: 400;
  position: relative;
  transition: background 0.15s ease;
}
/* 只有带步骤数字的菜单（选品计划那五个步骤）才右移留白 + 做让位动画 */
.sidebar nav a.nav-sub.has-step {
  padding-left: 54px;
  overflow: visible;
  transition: transform 0.32s cubic-bezier(.22,1,.36,1), background 0.15s ease;
  will-change: transform;
}
/* 仅「选品计划」这类带步骤数字的菜单做让位动画（.has-step），其它二级菜单不受影响 */
.sidebar nav a.nav-sub.has-step.active { z-index: 3; transform: translateY(30px); }
.sidebar nav a.nav-sub.has-step.active ~ a.nav-sub.has-step { transform: translateY(30px); }
.sidebar nav a.nav-sub .nav-step {
  position: absolute;
  left: 10px;
  bottom: 0;
  font-size: 54px;
  font-weight: 800;
  font-style: italic;
  line-height: 1;
  color: #fff;
  opacity: 0;
  text-shadow: 0 2px 5px rgba(15,23,42,.22);
  transform: translateY(14px) scale(.92);
  transform-origin: left bottom;
  pointer-events: none;
  user-select: none;
  letter-spacing: -2px;
  z-index: 0;
}
.sidebar nav a.nav-sub.active .nav-step { animation: navStepIn .42s cubic-bezier(.22,1,.36,1) .07s both; }
@keyframes navStepIn {
  0% { opacity: 0; transform: translateY(16px) scale(.9); }
  55% { opacity: .95; }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.sidebar nav a.nav-sub svg {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  margin-right: 6px;
  opacity: 0.75;
}
.sidebar nav a.nav-sub.active {
  background: var(--sidebar-active);
  color: #fff;
}

/* ===== 一级/二级菜单折叠（点击一级菜单展开/收起二级） ===== */
.sidebar .nav-group { margin: 2px 0; }
.sidebar .nav-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background .2s ease;
}
.sidebar .nav-toggle:hover { background: rgba(15, 23, 42, 0.06); }
.sidebar .nav-group .nav-arrow {
  width: 14px;
  height: 14px;
  margin-left: auto;
  margin-right: 0;
  opacity: 0.55;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}
.sidebar .nav-group.collapsed .nav-arrow { transform: rotate(-90deg); }
.sidebar .nav-sub-wrap {
  max-height: 180px;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}
.sidebar .nav-group.collapsed .nav-sub-wrap {
  max-height: 0;
  opacity: 0;
}
/* 只有「选品计划」这个分组需要更大的高度（让位动画用）。
   底部预留只在「有步骤被选中」时才生效，否则默认展开时下方会空出一块。 */
.sidebar .nav-group.nav-steps .nav-sub-wrap {
  max-height: 400px;
  padding-bottom: 0;
  transition: max-height 0.3s ease, padding-bottom 0.3s ease, opacity 0.25s ease;
}
.sidebar .nav-group.nav-steps:not(.collapsed).has-active-step .nav-sub-wrap,
.sidebar .nav-group.nav-steps:not(.collapsed):has(a.nav-sub.has-step.active) .nav-sub-wrap {
  max-height: 400px;
  padding-bottom: 34px;
}
.sidebar .nav-group.nav-steps.collapsed .nav-sub-wrap { max-height: 0; padding-bottom: 0; opacity: 0; }
.sidebar .nav-group + .nav-main,
.sidebar .nav-group + .nav-group { margin-top: 4px; }

.sidebar .foot { display: none; }
.sidebar .foot .sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 0 10px;
  min-width: 0;
}
.sidebar .foot .sidebar-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.sidebar .foot .sidebar-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.sidebar .foot .sidebar-user-name {
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .foot .sidebar-user-role {
  color: #64748b;
  font-size: 11px;
}
.sidebar .foot .logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar .foot .logout-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.sidebar .foot .logout-btn:hover {
  background: rgba(248, 113, 113, 0.08);
  color: #dc2626;
  border-color: rgba(248, 113, 113, 0.3);
}

.main {
  flex: 1;
  margin-left: 210px;
  padding: 20px 24px 40px;
  min-width: 0;
}

/* 标签页外壳内嵌模式：隐藏页面自带侧边栏，内容区占满 */
.embed .sidebar { display: none; }
.embed .main { margin-left: 0; width: 100%; }

/* 移动端：隐藏侧边栏，内容区全宽 */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; width: 100%; }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.topbar h1 { font-size: 20px; font-weight: 600; }
.topbar .sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.topbar-user {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -20px -24px 14px;
  padding: 8px 24px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}
.topbar-user .tb-left { display: flex; align-items: center; gap: 18px; color: #64748b; font-size: 13px; }
.topbar-user .tb-right { display: flex; align-items: center; gap: 8px; }
.tb-user-wrap { display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 6px; border-radius: 8px; transition: background 0.12s; }
.tb-user-wrap:hover { background: #f1f5f9; }
.tb-user-drop { position: relative; }
.tb-caret { color: #94a3b8; font-size: 11px; }
.tb-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 200;
  min-width: 170px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 6px;
}
.tb-drop-user { padding: 8px 10px; font-weight: 600; color: #1e293b; font-size: 13px; border-bottom: 1px solid #f1f5f9; margin-bottom: 4px; }
.tb-drop-logout {
  width: 100%;
  border: none;
  background: #fff;
  color: #dc2626;
  padding: 8px 10px;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.tb-drop-logout:hover { background: #fef2f2; }
.tb-weather { white-space: nowrap; }
.tb-ai-balance { margin-left: 10px; font-size: 12px; color: #4d6bfe; background: #eef2ff; border: 1px solid #c7d7fe; padding: 3px 10px 3px 7px; border-radius: 999px; white-space: nowrap; cursor: help; display: inline-flex; align-items: center; gap: 5px; }
.tb-ai-balance svg { width: 14px; height: 14px; fill: currentColor; display: block; }
.tb-ai-balance.tb-ai-dim { color: #94a3b8; background: #f1f5f9; border-color: #e2e8f0; }
.tb-ustime { white-space: nowrap; font-variant-numeric: tabular-nums; }
.tb-avatar { width: 30px; height: 30px; border-radius: 50%; background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.tb-name { font-size: 13px; font-weight: 600; color: #334155; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-logout { border: 1px solid var(--border); background: #fff; color: #64748b; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; transition: all 0.12s; }
.tb-logout:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }

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

.card .card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card .card-body { padding: 14px 16px; }

/* 容器型卡片：直接包裹子卡片/面板（打印设置、授权管理、同步设置、广告统计等）时补内边距，避免子卡片贴边 */
.card:has(> .ps-card, > .auth-grid, > .auth-tabs, > .sync-grid, > .ad-stats, > .pf-stats) {
  padding: 24px;
}

/* ===== 工具栏 / 表单 ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
}

.toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[type="date"] { padding: 6px 8px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.form-grid .full { grid-column: 1 / -1; }

.form-item label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; }

.checks { display: flex; gap: 14px; flex-wrap: wrap; padding-top: 4px; }
.checks label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.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-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-link { border: none; background: none; color: var(--primary); padding: 2px 5px; font-size: 12px; cursor: pointer; }
.btn-link.danger { color: var(--danger); }

.op-cell { white-space: nowrap; }
.op-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  color: #64748b;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  vertical-align: middle;
  margin: 0 1px;
}
.op-icon:hover { background: #eff6ff; color: var(--primary); }
.op-icon.op-del:hover { background: #fef2f2; color: var(--danger); }
.op-icon svg { width: 15px; height: 15px; }

.op-btn2 {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  margin: 1px 2px;
  white-space: nowrap;
}
.as-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  width: fit-content;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.as-card:hover { border-color: var(--primary, #2563eb); background: #eff6ff; }
.as-card input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary, #2563eb);
  cursor: pointer;
  flex-shrink: 0;
}
.as-card .as-title { font-weight: 600; color: #1e293b; font-size: 13px; }
.as-card .as-hint { color: #94a3b8; font-size: 12px; }
.op-btn2:hover { border-color: var(--primary); background: #eff6ff; }
.op-btn2.op-ok { color: var(--success); }
.op-btn2.op-ok:hover { border-color: var(--success); background: #f0fdf4; }

.wb-cell { display: flex; align-items: flex-start; gap: 4px; }
.wb-cell .wb-nums { flex: 1; text-align: left; line-height: 1.8; }
.wb-cell .wb-nums a {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.wb-cell .op-icon { margin-top: 1px; flex-shrink: 0; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }

tr.store-group-row td {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-bottom: 1px solid #e2e8f0;
}

/* ===== 商品管理：左右分栏（左父体 / 右变体） ===== */
.products-split {
  display: flex;
  gap: 14px;
  min-height: 480px;
}
.product-parents {
  width: 270px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  padding: 4px 10px 4px 0;
}
.parent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s;
}
.parent-item:hover { background: #f1f5f9; }
.parent-item.active { background: var(--primary, #2563eb); color: #fff; }
.parent-key { font-weight: 700; font-size: 13px; }
.parent-cnt {
  font-size: 11px;
  color: #475569;
  background: #e2e8f0;
  border-radius: 10px;
  padding: 1px 7px;
}
.parent-item.active .parent-cnt { background: rgba(255, 255, 255, 0.25); color: #fff; }
.parent-stores {
  grid-column: 1 / -1;
  display: flex;
  gap: 4px;
  margin-top: 1px;
}
.parent-stores .store-block {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.4;
}
.parent-item.active .parent-stores .store-block {
  background: #fff !important;
  color: #1e293b;
}
.parent-name {
  grid-column: 1 / -1;
  font-size: 11px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.parent-item.active .parent-name { color: rgba(255, 255, 255, 0.85); }
.product-children { flex: 1; min-width: 0; }
.product-children .table-wrap { max-height: calc(100vh - 300px); overflow-y: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.grid th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 10px 10px;
  text-align: center;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.grid td {
  border-bottom: 1px solid #f1f5f9;
  padding: 8px 10px;
  text-align: center;
  vertical-align: middle;
  word-break: break-all;
}

/* 悬停行高亮：半透明蓝色，让 tr 上的店铺水印仍可透过显示 */
table.grid tr:hover td { background: rgba(59, 130, 246, 0.09); }

/* 店铺水印（老系统同款：悬停行显示店铺名，旋转半透明） */
table.grid tr.wm-active { background-repeat: repeat; }
table.grid tr.wm-active td { background-color: rgba(59, 130, 246, 0.09); }

.thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  display: inline-block;
  vertical-align: middle;
}

.thumbs img + img { margin-left: 5px; }

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

/* ===== 状态标签 ===== */
.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
}

.tag-unshipped { background: #ff4d4f; }
.tag-shipped { background: #52c41a; }
.tag-returned { background: #faad14; }
.tag-brush { background: #f5222d; }
.tag-fake { background: #722ed1; }
.tag-transport { background: #1890ff; }
.tag-signed { background: #009e5f; }
.tag-purchase-need { background: #ff4d4f; }
.tag-purchase-transport { background: #1890ff; }
.tag-purchase-arrived { background: #52c41a; }
.tag-purchase-ordered { background: #1890ff; }  
.tag-purchase-factory { background: #787878; }  
.tag-purchase-canceled { background: #94a3b8; }
.tag-purchase-skip { background: #64748b; }
.tag-gray { background: #9ca3af; }
.tag-blue { background: #1890ff; }
.tag-green { background: #52c41a; }
.tag-red { background: #ff4d4f; }
.tag-warning { background: #fa8c16; }

/* ===== 站点色块（订单属性标签，FBM 区分站点来源） ===== */
.site-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  vertical-align: middle;
  cursor: default;
}
.site-us { background: #1d4ed8; }
.site-ca { background: #dc2626; }
.site-mx { background: #059669; }
.site-br { background: #d97706; }
.site-uk { background: #7c3aed; }
.site-de { background: #b45309; }
.site-fr { background: #2563eb; }
.site-it { background: #16a34a; }
.site-es { background: #db2777; }
.site-jp { background: #be123c; }
.site-au { background: #0e7490; }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  position: sticky;
  bottom: 0;
  background: #fff;
  z-index: 20;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.05);
}

.pagination button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
}

.pagination button:disabled { opacity: 0.45; cursor: not-allowed; }
.pagination button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination select { padding: 4px 6px; }
.pagination .pg-jump { display: inline-flex; align-items: center; gap: 4px; }
.pagination .pg-jump input { width: 56px; padding: 4px 6px; }
.pagination .pg-jump .pg-go {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 5px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay.show { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 720px;
  max-width: 100%;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
  animation: modalIn 0.22s ease;
  overflow: hidden;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal.wide { width: 960px; }
.modal.small { width: 440px; }
.modal.ultra { width: 1380px; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc, #fff);
}

.modal-head::before {
  content: '';
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--primary);
  flex-shrink: 0;
}

.modal-head .close {
  margin-left: auto;
  border: none;
  background: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: all 0.15s;
}
.modal-head .close:hover { background: #f1f5f9; color: var(--text); }

.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }

.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafbfc;
}

.modal .form-item { margin-bottom: 4px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.info-grid .item { background: #f8fafc; border-radius: 6px; padding: 8px 10px; }
.info-grid .item .k { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.info-grid .item .v { font-size: 13px; font-weight: 500; word-break: break-all; }

/* ===== 预报/面单弹窗 ===== */
.fc-batch {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.fc-table-wrap {
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.fc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.fc-table th {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 7px 8px;
  text-align: center;
  position: sticky;
  top: 0;
  white-space: nowrap;
}
.fc-table td {
  border-bottom: 1px solid #f1f5f9;
  padding: 6px 8px;
  text-align: center;
  vertical-align: middle;
}
.fc-table input[type="number"], .fc-table input[type="text"], .fc-table select {
  width: 100%;
  padding: 4px 6px;
  font-size: 12px;
}
.fc-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
}
.fc-no-recipient { color: var(--danger); font-size: 12px; }
.fc-hint { color: var(--text-muted); font-size: 12px; margin-top: 8px; }

/* ===== Toast ===== */
#toastBox {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: fadeIn 0.2s;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 统计卡片 ===== */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-card .label { color: var(--text-muted); font-size: 13px; }
.stats-table { max-width: 520px; }
.stats-table th, .stats-table td { padding: 9px 16px; }
.stats-table .amt { font-weight: 600; }

.time-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.time-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.time-card .time-head {
  background: var(--tc);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 14px;
  letter-spacing: 1px;
}
.time-card .time-body { padding: 14px 16px; }
.time-card .time-orders {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.time-card .time-orders span { font-size: 13px; color: var(--text-muted); }
.time-card .time-orders b { font-size: 28px; color: var(--tc); }
.time-card .time-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 7px 0 2px;
  border-top: 1px dashed #f1f5f9;
}
.time-card .time-row span { color: var(--text-muted); }
.time-card .time-row b { font-weight: 600; white-space: nowrap; }
.time-card .amt { color: var(--tc); }
.cmp-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
  padding: 0 6px;
  border-radius: 8px;
  margin-left: 6px;
  white-space: nowrap;
  vertical-align: 1px;
}
span.cmp-badge.cmp-up { color: #15803d; background: #dcfce7; }
span.cmp-badge.cmp-down { color: #b91c1c; background: #fee2e2; }
span.cmp-badge.cmp-flat { color: #64748b; background: #f1f5f9; }

/* ===== 看板站点小卡（紧凑） ===== */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.site-mini {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.site-head { display: flex; justify-content: space-between; align-items: center; }
.site-head > span:first-child { font-weight: 700; font-size: 14px; color: #1e293b; }
.site-meta { font-size: 12px; color: #94a3b8; }
.site-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 10px; }
.site-stat { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: #64748b; }
.site-stat b { font-size: 18px; color: var(--primary, #2563eb); }
.site-foot {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed #f1f5f9;
  font-size: 12px;
  color: #64748b;
}
.site-stores { margin-top: 6px; font-size: 12px; color: #94a3b8; }
.site-stores div { padding: 2px 0; }

/* ===== 看板图表 ===== */
.chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 200px;
  padding: 8px 4px 0;
  overflow-x: auto;
}
.trend-col { flex: 1; min-width: 60px; text-align: center; }
.trend-bar-row { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 132px; }
.trend-bar { width: 16px; border-radius: 3px 3px 0 0; }
.bar-orders { background: #2563eb; }
.bar-shipped { background: #16a34a; }
.trend-num { font-size: 13px; font-weight: 600; margin-top: 4px; }
.trend-amount { font-size: 11px; color: var(--text-muted); }
.trend-date { font-size: 11px; color: var(--text-muted); }
.channel-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.channel-label { width: 42px; font-size: 13px; color: var(--text-muted); }
.channel-bar { flex: 1; height: 18px; background: #f1f5f9; border-radius: 9px; overflow: hidden; }
.channel-fill { height: 100%; }
.fill-fba { background: #2563eb; }
.fill-fbm { background: #16a34a; }
.channel-num { width: 120px; font-size: 13px; }

/* ===== 打印 ===== */
@media print {
  body.printing * { visibility: hidden; }
  #waybillPrint, #waybillPrint * { visibility: visible; }
#waybillPrint {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    padding: 20px;
    font-size: 13px;
  }
}

/* ===== 数据看板：店铺订单汇总卡片（一级店铺聚合 + 站点明细） ===== */
.store-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
  align-items: stretch;
}
.store-groups .card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}
.store-groups .card .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.store-sum-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}
.store-agg-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.store-agg-cell {
  min-width: 0;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  padding: 8px 10px;
}
.store-agg-cell span {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
}
.store-agg-cell b {
  font-size: 18px;
  color: #0f172a;
}
.store-agg-cell em {
  font-style: normal;
  display: block;
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
  white-space: nowrap;
}
.store-agg-cell span.cmp-badge {
  display: inline-block;
  margin: 0 0 0 6px;
  font-size: 11px;
  line-height: 1.6;
  padding: 0 6px;
  border-radius: 8px;
  vertical-align: 1px;
}
.store-sites {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  border-top: 1px solid #f1f5f9;
  padding-top: 10px;
}
.store-sites-title {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 4px;
}
.store-site-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.store-site-card {
  min-width: 0;
  border: 1px solid #eef2f7;
  border-radius: 8px;
  background: #fafbfc;
  padding: 10px 12px;
}
.store-site-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.store-site-head > span:first-child {
  font-weight: 600;
  color: #1e293b;
  font-size: 13px;
  white-space: nowrap;
}
.store-site-cells {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.store-site-cell {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
}
.store-site-cell span {
  color: #94a3b8;
}
.store-site-cell b {
  color: #0f172a;
  font-size: 13px;
  white-space: nowrap;
}
.store-site-cell em {
  font-style: normal;
  color: #64748b;
  white-space: nowrap;
  text-align: right;
}
.store-site-channel {
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
}

/* ===== 看板订单地区分布（美国地图） ===== */
.geo-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.geo-toggle button {
  border: 0;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.geo-toggle button.active {
  background: var(--primary, #2563eb);
  color: #fff;
}
.geo-fly-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: #64748b;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.geo-fly-btn.active {
  background: var(--primary, #2563eb);
  color: #fff;
}
.geo-wrap {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}
.geo-map {
  flex: 0 1 920px;
  min-width: 0;
  position: relative;
}
.us-map-svg {
  width: 100%;
  height: auto;
  display: block;
}
.geo-fly {
  pointer-events: none;
}
.geo-pop {
  position: absolute;
  z-index: 5;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
  padding: 8px 14px;
  pointer-events: none;
  white-space: nowrap;
  text-align: center;
}
.geo-pop-name {
  font-size: 12px;
  color: #64748b;
}
.geo-pop-num {
  font-size: 20px;
  font-weight: 700;
  color: #1e40af;
  line-height: 1.3;
}
.geo-pop-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}
.geo-state {
  stroke: #fff;
  stroke-width: 0.6;
  transition: opacity 0.15s;
  cursor: default;
}
.geo-state:hover {
  opacity: 0.82;
  stroke-width: 1.1;
}
.geo-state.geo-picked {
  stroke: #0f172a;
  stroke-width: 1.6;
  opacity: 1;
}
.geo-side {
  width: 360px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.geo-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}
.geo-legend .grad {
  flex: 1;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(to right, #eef2f7, #dbeafe, #1e40af);
}
.geo-block-title {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
}
.geo-top-item {
  display: grid;
  grid-template-columns: 1fr 90px 48px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  padding: 5px 0;
}
.gt-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.gt-code {
  font-weight: 600;
  color: #334155;
  flex: none;
}
.gt-zh {
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gt-bar {
  height: 10px;
  background: #f1f5f9;
  border-radius: 5px;
  overflow: hidden;
}
.gt-bar i {
  display: block;
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
}
.gt-num {
  text-align: right;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.geo-country {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #64748b;
  padding: 6px 0;
  border-bottom: 1px dashed #f1f5f9;
}
.geo-country b {
  color: #334155;
  font-variant-numeric: tabular-nums;
}
