:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1b2434;
  --ink-soft: #5b6779;
  --ink-mute: #8b95a7;
  --line: #e3e8f0;
  --brand: #2c62f0;
  --brand-soft: #eaf0ff;
  --ok: #12855a;
  --ok-soft: #e3f7ee;
  --warn: #b06a00;
  --warn-soft: #fff3dd;
  --danger: #c02b3a;
  --danger-soft: #fdeaec;
  --info: #1c6ea4;
  --info-soft: #e6f2fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 39, 75, .06), 0 6px 18px rgba(24, 39, 75, .05);
}

* { box-sizing: border-box; }

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

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

/* 销售端蓝色主题 */
body.role-sales {
  --bg: #f2f6ff;
  --brand: #3f74e0;
  --brand-soft: #e3ecff;
}
body.role-sales .sidebar {
  background: linear-gradient(180deg, #2f5fc4 0%, #1e438f 100%);
}
body.role-sales .nav a.on {
  background: #5990ff;
  color: #fff;
}
body.role-sales .btn-primary {
  background: #5990ff;
  border-color: #5990ff;
  color: #fff;
}
body.role-sales .btn-primary:hover {
  background: #4a83f0;
  border-color: #4a83f0;
}

/* 管理端橙色主题 */
body.role-admin {
  --bg: #fff8ec;
  --brand: #c46f00;
  --brand-soft: #ffedd0;
}
body.role-admin .sidebar {
  background: linear-gradient(180deg, #7a3c00 0%, #522800 100%);
}
body.role-admin .nav a.on {
  background: #ff9600;
  color: #3d2400;
}
body.role-admin .btn-primary {
  background: #ff9600;
  border-color: #ff9600;
  color: #3d2400;
}
body.role-admin .btn-primary:hover {
  background: #f18b00;
  border-color: #f18b00;
}

/* 仓库端绿色主题 */
body.role-warehouse {
  --bg: #f6fbdf;
  --brand: #5f8a00;
  --brand-soft: #eaf9c4;
}
body.role-warehouse .sidebar {
  background: linear-gradient(180deg, #4a7500 0%, #2f4d00 100%);
}
body.role-warehouse .nav a.on {
  background: #88d600;
  color: #1f3300;
}
body.role-warehouse .btn-primary {
  background: #88d600;
  border-color: #88d600;
  color: #1f3300;
}
body.role-warehouse .btn-primary:hover {
  background: #7cc300;
  border-color: #7cc300;
}

.layout { display: flex; min-height: 100vh; }

/* ---------------------------------------------------------------- 侧边栏 */
.sidebar {
  width: 200px;
  flex: 0 0 200px;
  background: #101828;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 18px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand small { display: block; font-weight: 400; font-size: 11px; color: #7c8ba1; letter-spacing: 0; margin-top: 2px; }

.nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: #64748b; padding: 12px 10px 6px; letter-spacing: 1px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px;
  color: #7c8ba1;
}

.sidebar-foot .who { color: #e2e8f0; font-weight: 600; font-size: 13px; }

/* ------------------------------------------------------------------ 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.topbar .sub { color: var(--ink-mute); font-size: 12.5px; margin-top: 1px; }

/* 内容区跟随窗口宽度自适应：窗口拉宽，表格列按内容自动分配多出来的宽度 */
.content { padding: 20px 24px 48px; width: 100%; min-width: 0; }

/* ------------------------------------------------------------------ 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

/* 需要表头吸顶的卡片不能裁剪溢出，否则 sticky 会失效 */
.card.no-clip { overflow: visible; }

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.card-head .hint { font-size: 12.5px; color: var(--ink-mute); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ------------------------------------------------------------------ 统计 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat .label { font-size: 12.5px; color: var(--ink-mute); }
.stat .value { font-size: 23px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.stat .value.sm { font-size: 19px; }
.stat .foot { font-size: 12px; color: var(--ink-mute); margin-top: 4px; }
.stat.accent { border-left: 3px solid var(--brand); }
.stat.good { border-left: 3px solid var(--ok); }
.stat.bad { border-left: 3px solid var(--danger); }

/* ------------------------------------------------------------------ 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #344054; }
.field .tip { font-size: 12px; color: var(--ink-mute); font-weight: 400; margin-left: 6px; }
.field-error { font-size: 12.5px; color: var(--danger); margin-top: 4px; }
.field-hint { font-size: 12.5px; color: var(--warn); margin-top: 4px; }
input.input-error, input.input-error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], input[type="email"], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #d3dae6;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea { min-height: 74px; resize: vertical; }
input[type="file"] { font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 16px; }

/* ------------------------------------------------------------------ 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid #d3dae6;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: #f7f9fc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #2453d1; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.btn-ok:hover { background: #0d6d49; }
.btn-danger { background: #fff; border-color: #f0c2c7; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

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

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  /* 中文默认可以逐字换行，窄列下会变成"一个字一行"；
     keep-all 让它只在标点/空格处断，实在放不下才硬断 */
  word-break: keep-all;
  overflow-wrap: break-word;
}
table.tbl th {
  text-align: left;
  padding: 9px 12px;
  background: #fafbfe;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  color: #475467;
  font-size: 12.5px;
  white-space: nowrap;
}

table.tbl td { padding: 9px 12px; border-bottom: 1px solid #eef2f8; vertical-align: middle; }

/* 列宽固定：展开行内面板时不会把各列挤变形 */
table.tbl-fixed { table-layout: fixed; }
table.tbl-fixed td { overflow-wrap: anywhere; }

/* 长表格：容器自己滚动，表头钉在容器顶部。
   横向和吸顶必须共存 —— 所以让这个容器成为滚动参照，而不是整个页面。 */
.table-wrap.tall {
  overflow: auto;
  max-height: max(420px, calc(100vh - 330px));
}
.table-wrap.tall thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #fff;
  box-shadow: inset 0 -1px 0 var(--line), 0 4px 8px -6px rgba(24, 39, 75, .25);
}

/* 表格跟着窗口一起收窄；只有窄到手机宽度才保留一个很低的下限，避免整页挤坏 */
table.tbl-wide { min-width: 720px; }     /* 订单列表 / 货物管理 */
table.tbl-mid { min-width: 560px; }      /* 仓库待发货 / 已发货 */
table.tbl-wide-sm { min-width: 520px; }  /* 回款记录等中等表格 */

/* 订单表 15 列比较多：窗口变窄时先压缩间距，再依次收起次要列 */
@media (max-width: 1500px) {
  table.tbl-wide th { padding: 8px 9px; }
  table.tbl-wide td { padding: 8px 9px; }
  .vch-thumb img { width: 28px; height: 28px; }
}
@media (max-width: 1320px) {
  table.tbl[data-col-table] .c-paid,
  table.tbl[data-col-table] .c-logi { display: none; }
  table.tbl[data-col-table] .c-no a { white-space: normal; word-break: break-all; }
  table.tbl[data-col-table] .c-time { white-space: normal; }
}

/* 中键拖动平移表格 */
.table-wrap.panning {
  cursor: grabbing;
  user-select: none;
}
.table-wrap.panning * { cursor: grabbing !important; }

/* 订单列表里的「售后确认」下拉：没设置是灰的，已确认是绿的 */
.confirm-select {
  width: 100%;
  max-width: 104px;
  padding: 3px 5px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid #d3dae6;
  background: #fff;
  color: #667085;
}

.voucher-btn {
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1.2;
}

/* 回款凭证列：缩略图 + 「查看 / ＋回款」竖排小按钮 */
.vch-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vch-thumb img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line);
  display: block;
}
.vch-acts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: stretch;
}
.vch-acts .btn {
  white-space: nowrap;
}

/* 订单表：显示列 / 按列收起 */
.table-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.col-picker { position: relative; }
.col-picker > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.col-picker > summary::-webkit-details-marker { display: none; }
.col-picker[open] > summary {
  background: var(--brand-soft);
  border-color: #b9c8f5;
  color: var(--brand);
}
.col-picker-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 210px;
  max-height: 340px;
  overflow: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, .14);
}
.col-picker-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
.col-picker-menu label:hover { background: #f5f7fb; }

.col-hide-btn {
  margin-left: 4px;
  padding: 1px 3px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #b6bfcc;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.col-hide-btn:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
.col-hidden { display: none !important; }
col.col-hidden { visibility: collapse; }
.confirm-select.state-confirmed {
  background: var(--ok-soft);
  border-color: #b9e6d2;
  color: #0b6b47;
}
.confirm-select.state-returned {
  background: var(--danger-soft);
  border-color: #f3c6cb;
  color: var(--danger);
}
.confirm-select.state-after_sale {
  background: var(--warn-soft);
  border-color: #f0dcb4;
  color: var(--warn);
}

.state-badge-none { background: #eef1f5; color: #667085; }
.state-badge-confirmed { background: var(--ok-soft); color: var(--ok); }
.state-badge-returned { background: var(--danger-soft); color: var(--danger); }
.state-badge-after_sale { background: var(--warn-soft); color: var(--warn); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafcff; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.nowrap { white-space: nowrap; }
table.tbl .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; }

/* ------------------------------------------------------------------ 标记 */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-shipped { background: var(--info-soft); color: var(--info); }
.badge-delivered { background: var(--ok-soft); color: var(--ok); }
.badge-received { background: #d8f2e6; color: #0b6b47; }
.badge-cancelled { background: #eef1f5; color: #667085; }
.badge-unpaid { background: var(--danger-soft); color: var(--danger); }
.badge-partial { background: var(--warn-soft); color: var(--warn); }
.badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-over { background: #efe6ff; color: #6b39c9; }
.badge-neutral { background: #eef1f5; color: #475467; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warning { background: var(--warn-soft); color: var(--warn); }

.muted { color: var(--ink-mute); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }

/* ------------------------------------------------------------------ 提示条 */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: #0b6b47; border-color: #b9e6d2; }
.flash-err { background: var(--danger-soft); color: var(--danger); border-color: #f3c6cb; }

/* ------------------------------------------------------------------ 筛选栏 */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fafbfe;
}

.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters .f span { font-size: 12px; color: var(--ink-mute); }
.filters input, .filters select { padding: 6px 10px; font-size: 13px; min-width: 130px; }

/* ------------------------------------------------------------------ 分页 */
.pager { display: flex; gap: 8px; align-items: center; padding: 14px 18px; justify-content: flex-end; font-size: 13px; }
.pager a, .pager span.cur {
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
}
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.pager .info { margin-right: auto; color: var(--ink-mute); }

/* ------------------------------------------------------------------ 详情 */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.detail-item .k { font-size: 12px; color: var(--ink-mute); }
.detail-item .v { font-size: 14px; margin-top: 2px; word-break: break-word; }

.timeline { list-style: none; margin: 0; padding: 4px 0 0 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid #e6ebf4; margin-left: 5px; }
.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 #c6d2e6;
}
.timeline li.first::before { border-color: var(--brand); background: var(--brand); }
.timeline li.first .ctx { font-weight: 600; color: var(--ink); }
.timeline .when { font-size: 12px; color: var(--ink-mute); }
.timeline .ctx { font-size: 13.5px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb {
  width: 108px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  text-align: center;
}
.thumb img { width: 100%; height: 108px; object-fit: cover; display: block; background: #f2f4f8; }
.thumb .cap { font-size: 11.5px; padding: 5px 6px; color: var(--ink-soft); }

/* ------------------------------------------------------------------ 空状态 */
.empty { padding: 44px 20px; text-align: center; color: var(--ink-mute); font-size: 13.5px; }
.empty .big { font-size: 30px; display: block; margin-bottom: 8px; opacity: .35; }

/* ------------------------------------------------------------------ 登录页 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #101828 0%, #1d3a8a 60%, #2c62f0 100%);
  padding: 24px;
}

.login-box { width: 100%; max-width: 390px; background: #fff; border-radius: 16px; padding: 32px 30px 26px; box-shadow: 0 24px 60px rgba(8, 20, 50, .35); }
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box .sub { color: var(--ink-mute); font-size: 13px; margin-bottom: 22px; }
.login-foot { text-align: center; color: rgba(255, 255, 255, .7); font-size: 12px; margin-top: 18px; }

/* ------------------------------------------------------------------ 条形图 */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding: 0 2px; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, #5b8bff, #2c62f0); border-radius: 5px 5px 0 0; min-height: 2px; }
.bar.paid { background: linear-gradient(180deg, #3fc48c, #12855a); }
.bar-lab { font-size: 11px; color: var(--ink-mute); white-space: nowrap; }
.bar-val { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }

/* ------------------------------------------------------------------ 自适应 */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 7px 11px; }
  .nav-group { display: none; }
  .sidebar-foot { display: flex; justify-content: space-between; align-items: center; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  /* 只对「自适应列宽」的表格隐藏次要列。
     固定列宽的表格里隐藏单元格会让后面的列错位，反而溢出。 */
  table.tbl:not(.tbl-fixed) .c-qty,
  table.tbl:not(.tbl-fixed) .c-paid,
  table.tbl:not(.tbl-fixed) .c-logi,
  table.tbl:not(.tbl-fixed) .c-time { display: none; }
  table.tbl th, table.tbl td { padding: 9px 10px; }
}

@media (max-width: 700px) {
  .c-sales, .c-paybadge { display: none; }
  .filters { gap: 8px; }
  .filters input, .filters select { min-width: 0; width: 100%; }
  .filters .f { flex: 1 1 44%; }
}

.ship-form { flex-wrap: nowrap; align-items: center; }

/* 订单列表里的展开面板 */
tr.panel-row > td { padding: 0 !important; }
.payment-block .card-body:first-child { padding: 0; }
.payment-block .table-wrap { background: #fff; }

/* ---------------------------------------------------------------- 图片查看器 */
body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(10, 15, 25, .92);
  display: flex;
  flex-direction: column;
}
.viewer[hidden] { display: none; }

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #e6ecf5;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  flex: 0 0 auto;
}
.viewer-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.viewer-hint { color: #93a4bd; margin-left: auto; }
.viewer-zoom { font-variant-numeric: tabular-nums; color: #b9c6da; min-width: 52px; text-align: right; }
.viewer-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08);
  color: #e6ecf5;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.viewer-btn:hover { background: rgba(255, 255, 255, .18); }
.viewer-close { background: rgba(220, 70, 80, .85); border-color: transparent; }
.viewer-close:hover { background: #d33b47; }

.viewer-stage {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.viewer-stage.grabbing { cursor: grabbing; }
.viewer-stage img {
  max-width: 92%;
  max-height: 92%;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

@media (max-width: 700px) {
  .viewer-hint { display: none; }
}

/* 规格参数输入行 */
.spec-grid { display: flex; flex-direction: column; gap: 8px; }
.spec-row { display: grid; grid-template-columns: 26px 1fr 1fr; gap: 8px; align-items: center; }
.spec-row .spec-idx { font-size: 12px; color: var(--ink-mute); text-align: center; }
.spec-row input { min-width: 0; }

.sub-label { font-size: 12px; color: var(--ink-mute); margin-bottom: 4px; }

.cascade { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 900px) { .cascade { grid-template-columns: repeat(2, 1fr); } }

/* 商品树编辑器 */
.tree { font-size: 14px; }
.tree > .tchildren > .tnode { margin-top: 10px; }
.tchildren { margin-left: 12px; padding-left: 14px; border-left: 1px dashed #dbe3ef; }
.tnode { margin: 4px 0; }
.trow { display: flex; align-items: center; gap: 6px; }
.tlabel {
  flex: 0 0 42px;
  font-size: 12px;
  color: var(--ink-mute);
  text-align: right;
  white-space: nowrap;
}
.t-input { flex: 1 1 auto; min-width: 0; }
.t-input.t-price { flex: 0 0 118px; }
.t-input.t-qty { flex: 0 0 92px; }

/* 批量上架卡片：默认折叠，点小三角展开 */
.bulk-card > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.bulk-card > summary::-webkit-details-marker { display: none; }
.bulk-card > summary .chev {
  display: inline-block;
  margin-right: 7px;
  color: #98a2b3;
  transition: transform .16s ease;
}
.bulk-card[open] > summary .chev { transform: rotate(90deg); }

/* 库存列：数量 + 加库存按钮 */
.stock-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.stock-add { padding: 2px 6px; font-size: 11.5px; }
.stock-in { color: var(--ok); }
.stock-out { color: var(--danger); font-weight: 600; }
.logi-empty {
  display: flex;
  align-items: center;
  gap: 6px;
}
.copy-address {
  margin-top: 6px;
  padding: 2px 7px;
  font-size: 11.5px;
}

/* 发货弹窗里的手机扫码 */
.scan-row {
  display: flex;
  gap: 8px;
}
.scan-row input {
  flex: 1 1 auto;
  min-width: 0;
}
.scan-box {
  margin-top: 10px;
  padding: 10px;
  border-radius: 10px;
  background: #0f172a;
}
.scan-box video {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}
.scan-status {
  margin: 8px 0;
  color: #cbd5e1;
  font-size: 12.5px;
}
.scan-box .btn {
  border-color: transparent;
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

/* 账号管理弹窗 */
.form-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, .45);
}
.form-modal[hidden] { display: none; }
.form-dialog {
  width: 100%;
  max-width: 660px;
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(8, 20, 50, .3);
}
.form-dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
}
.form-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.form-section .field {
  flex: 1 1 260px;
  margin-bottom: 0;
}
.category-form {
  border-top: 1px solid var(--line);
}
.category-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 6px;
}
.category-checks .check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}

/* 加库存弹窗 */
.stock-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, .45);
}
.stock-modal[hidden] { display: none; }
.stock-dialog {
  width: 100%;
  max-width: 420px;
  padding: 18px 20px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(8, 20, 50, .28);
}
.stock-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 15px;
}

/* 回款弹窗 */
.pay-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, .45);
}
.pay-modal[hidden] { display: none; }
.pay-dialog {
  width: 100%;
  max-width: 1060px;
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(8, 20, 50, .3);
}
.pay-dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.pay-dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pay-flash[hidden] { display: none; }
.pay-flash .flash {
  margin: 10px 18px 0;
}

/* 登记新订单弹窗 */
.order-modal {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, .45);
}
.order-modal[hidden] { display: none; }
.order-dialog {
  width: 100%;
  max-width: 1100px;
  height: 88vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(8, 20, 50, .3);
}
.order-dialog iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--bg);
}

/* 弹窗里的登记页只显示表单本身 */
body.embed .sidebar,
body.embed .topbar { display: none; }
body.embed .content { padding: 14px 16px 24px; }
body.modal-open { overflow: hidden; }

/* 回款金额旁边的成交价提示 */
.price-hint {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: #7a3a09;
  font-size: 12.5px;
}
body.role-sales .price-hint {
  background: #e3ecff;
  color: #1e3a8a;
}

/* 二次确认小弹窗（登记订单 / 登记回款共用） */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, .45);
}
.confirm-modal[hidden] { display: none; }
.confirm-dialog {
  width: 100%;
  max-width: 460px;
  padding: 18px 20px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(8, 20, 50, .3);
}
.confirm-head {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 700;
}
.pay-confirm-text {
  margin-bottom: 10px;
  color: #7a3a09;
  font-size: 13px;
  white-space: pre-line;
}
.tadd {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #c9d6ea;
  background: #eef4ff;
  color: var(--brand);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.tadd:hover { background: #dfeaff; border-color: var(--brand); }

.tremove {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #f0c9ce;
  background: #fdf0f1;
  color: var(--danger);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.tremove:hover { background: #fadfe2; border-color: var(--danger); }

@media (max-width: 760px) {
  .trow { flex-wrap: wrap; }
  .tlabel { flex: 0 0 36px; }
  .t-input.t-price { flex: 1 1 40%; }
  .t-input.t-qty { flex: 0 0 34%; }
}

@media (max-width: 700px) {
  .spec-row { grid-template-columns: 22px 1fr 1fr; }
}
