:root {
  --bg: #fbf9f5;
  --card: #fff;
  --brand: #7e9c82;
  --brand-dark: #5e7a62;
  --accent: #ce8e73;
  --ink: #2b2722;
  --text: #4a453e;
  --muted: #9a948a;
  --line: #ece7df;
  --side-w: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

body {
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(43,39,34,.06);
}
.login-card h1 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.35;
}
.login-card .btn {
  width: 100%;
  margin-top: 16px;
}

label {
  display: block;
  font-size: 13px;
  margin: 10px 0 6px;
  color: var(--ink);
  line-height: 1.4;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  line-height: 1.4;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
}
textarea {
  resize: vertical;
  min-height: 72px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.hot-add { background: #e7eee6; color: #3d5c42; border: 1px solid #7e9c82; }
.btn.hot-add:not(:disabled):hover { background: #7e9c82; color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: #f7e2db; color: #d9735a; }
.btn:disabled { opacity: 0.55; cursor: default; }
.msg {
  min-height: 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--accent);
  margin-top: 10px;
}

/* ---------- 主框架：侧栏 + 内容 ---------- */
.app {
  display: flex;
  min-height: 100vh;
  height: 100%;
  width: 100%;
  max-width: 100%;
  align-items: stretch;
  overflow: hidden;
}

.side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.side-top {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  padding: 8px 12px 8px;
  line-height: 1.35;
  letter-spacing: 0.02em;
}

.side nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.logout {
  margin-top: 4px;
  margin-bottom: 8px;
  width: calc(100% - 8px);
  align-self: stretch;
  margin-left: 4px;
}

.nav {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  line-height: 1.4;
  white-space: nowrap;
}
.nav.on,
.nav:hover {
  background: #e7eee6;
  color: var(--brand-dark);
}
.nav.hidden,
.admin-only.hidden,
.scope-leader-wrap.hidden {
  display: none !important;
}
.side-identity {
  font-size: 12px;
  color: #7a8578;
  margin: 4px 0 8px;
  padding: 0 4px;
}
.leader-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #e7eee6;
  vertical-align: middle;
}
.leader-avatar.empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9a948a;
}
.leader-avatar.preview {
  width: 64px;
  height: 64px;
}
.leader-avatar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 20px clamp(16px, 2vw, 40px) 48px;
  width: 100%;
  box-sizing: border-box;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.main > .tab {
  width: 100%;
  max-width: none;
}

.tab h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.4;
  font-weight: 700;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 18px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}
.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.form.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px 16px;
  margin-bottom: 16px;
}
.form.grid .full { grid-column: 1 / -1; }

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  padding: 12px 0 10px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 16px -12px rgba(43, 39, 34, 0.28);
}

.row-head .row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  width: 100%;
  position: sticky;
  top: var(--sticky-head-h, 56px);
  z-index: 39;
  background: var(--bg);
  padding: 8px 0 10px;
  box-shadow: 0 8px 16px -12px rgba(43, 39, 34, 0.2);
}

.row-head .toolbar {
  position: static;
  top: auto;
  padding: 0;
  margin-bottom: 0;
  background: transparent;
  box-shadow: none;
  z-index: auto;
}

.tab > h2:first-child {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  margin-top: 0;
  padding: 12px 0 10px;
  box-shadow: 0 8px 16px -12px rgba(43, 39, 34, 0.28);
}

.modal .toolbar {
  top: 52px;
}
.toolbar input,
.toolbar select {
  flex: 1 1 180px;
  max-width: none;
  min-width: 0;
}

.order-toolbar {
  align-items: center;
}
.order-toolbar .date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
  padding: 0 4px;
  color: #6b655c;
  font-size: 13px;
  white-space: nowrap;
}
.order-toolbar .date-field input[type='date'] {
  flex: 0 0 auto;
  min-width: 140px;
  width: 150px;
  max-width: 160px;
}
.order-toolbar .date-quick {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.order-toolbar .date-quick .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.order-filter-meta {
  color: #6b655c;
  font-size: 13px;
  white-space: nowrap;
}
.cell-nowrap {
  white-space: nowrap;
}
.cell-sub {
  color: #9a948a;
  font-size: 12px;
  margin-top: 2px;
}
.cell-badge {
  display: inline-block;
  margin-top: 4px;
}
button.linkish {
  border: 0;
  background: transparent;
  color: #5e7a62;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.linkish:hover {
  color: #3f5643;
}
#sideIdentity.hidden {
  display: none;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.45;
  table-layout: auto;
}

/* 全局：列头与数据居中；自适应列宽；过长换行 */
th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
  max-width: 280px;
}

th {
  background: #f4f0e9;
  color: var(--ink);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: normal;
  max-width: none;
}

td.actions {
  white-space: normal;
  max-width: 380px;
  vertical-align: middle;
}
td.actions .actions-wrap,
td .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

/* 备注 / 地址 / 商品名略宽，仍可换行 */
td[data-label='备注'],
td[data-label='地址'],
td[data-label='商品'],
td[data-label='名称'],
td[data-label='群名'],
td[data-label='归属群主'] {
  max-width: 340px;
}

th.col-check,
td.col-check {
  width: 40px;
  min-width: 40px;
  max-width: 44px;
  padding-left: 8px;
  padding-right: 6px;
  white-space: nowrap;
}

th.col-check input,
td.col-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  vertical-align: middle;
  appearance: auto;
  -webkit-appearance: checkbox;
}

/* 缩略图列保持紧凑 */
td .table-thumb,
td .leader-avatar {
  display: inline-block;
  vertical-align: middle;
}

/* 选中行高亮（各页通用） */
tr.is-selected td {
  background: #f3f8ef;
}

/* 订单表：整行上下居中；商品最多 3 种，超出提示查看详情 */
#tab-orders table th,
#tab-orders table td {
  vertical-align: middle;
}
#tab-orders .order-goods-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 280px;
  margin: 0 auto;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}
#tab-orders .order-goods-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  width: 100%;
}
#tab-orders .order-goods-text {
  text-align: left;
  min-width: 0;
  word-break: break-word;
}
#tab-orders .order-goods-more {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 4px 0;
  border: none;
  background: transparent;
  color: #5e7a62;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  line-height: 1.4;
}
#tab-orders .order-goods-more:hover {
  color: #3f5643;
  text-decoration: underline;
}
#tab-orders .cell-sub,
#tab-orders .cell-badge {
  display: block;
  text-align: center;
}
#tab-orders .cell-nowrap {
  text-align: center;
}
#tab-orders td[data-label='时间'],
#tab-orders td[data-label='客户'],
#tab-orders td[data-label='群主'],
#tab-orders td[data-label='商品'] {
  text-align: center;
}

/* 操作列：随行高上下居中，按钮自动换行 */
#tab-orders td.actions {
  vertical-align: middle;
  max-width: 380px;
  min-width: 240px;
  white-space: normal;
  padding-top: 12px;
  padding-bottom: 12px;
}
#tab-orders td.actions .actions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-content: center;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
}

#tab-customers .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
#tab-customers td.actions .btn,
#tab-products td.actions .btn,
#tab-leaders td.actions .btn,
#tab-applications td.actions .btn {
  margin: 0;
}
#batchDeleteCustomerBtn:disabled,
#batchDeleteProductBtn:disabled,
#batchDeleteLeaderBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#tab-products .selected-hint,
#tab-applications .selected-hint,
#tab-leaders .selected-hint,
#tab-customers .selected-hint {
  align-self: center;
  color: #5e7a62;
  font-size: 13px;
  white-space: nowrap;
}

.dc-rank-wrap table th,
.dc-rank-wrap table td {
  text-align: center;
  vertical-align: middle;
}
.dc-rank-row {
  cursor: pointer;
}
.dc-rank-row:hover td {
  background: #f3f8ef;
}

.rc-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
.rc-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.rc-card.warn {
  border-color: #e4c2a8;
  background: #fff8f2;
}
.rc-card.ok {
  border-color: #c5d6c7;
  background: #f4f8f4;
}
.rc-card-lab {
  color: #6b655c;
  font-size: 13px;
}
.rc-card-num {
  font-size: 24px;
  font-weight: 700;
  color: #2b2722;
  margin: 6px 0 4px;
  white-space: nowrap;
}
.rc-card-sub {
  color: #9a948a;
  font-size: 12px;
  line-height: 1.4;
}
.rc-owe {
  color: #a45c32;
}
.cell-muted {
  color: #b0aaa0;
}
.rc-detail {
  margin-top: 22px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
#tab-reconcile .date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b655c;
  font-size: 13px;
  white-space: nowrap;
}
#tab-reconcile .date-field input[type='date'] {
  min-width: 140px;
}
#tab-reconcile th.col-check,
#tab-reconcile td.col-check {
  width: 36px;
  text-align: center;
}

#rcBatchTransferBtn:disabled,
#rcRequestProofBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.rc-proof-alert {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff4e8;
  border: 1px solid #e8c9a8;
  color: #7a4a28;
  font-size: 14px;
}
.rc-need-proof {
  color: #b45309;
  font-weight: 600;
  font-size: 12px;
}
tr.is-need-proof td {
  background: #fff8f1;
}
.pp-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  vertical-align: middle;
}
.pp-thumb-link {
  display: inline-block;
}
.pp-preview {
  display: block;
  margin-top: 10px;
  max-width: 100%;
  max-height: 240px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.pp-upload-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.dc-periods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
.dc-period-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.dc-period-btn.on {
  background: #e54d42;
  border-color: #e54d42;
  color: #fff;
}
.dc-net {
  text-align: center;
  padding: 18px 12px 8px;
}
.dc-net-num {
  font-size: 40px;
  font-weight: 700;
  color: #e54d42;
  line-height: 1.1;
}
.dc-net-lab {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.dc-sections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 12px 0 8px;
}
.dc-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.dc-card h3 {
  margin: 0 0 12px;
  font-size: 15px;
}
.dc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 10px;
}
.dc-grid div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dc-grid b {
  font-size: 16px;
  color: var(--ink);
}
.dc-grid span {
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 900px) {
  .dc-sections {
    grid-template-columns: 1fr;
  }
}

.dc-detail-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dc-compare-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 8px 0 16px;
}
.dc-sum-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dc-sum-card b {
  font-size: 22px;
  color: var(--ink);
}
.dc-sum-card span {
  font-size: 12px;
  color: var(--muted);
}
.dc-compare-chart {
  margin-bottom: 18px;
}
.chart-box-tall {
  height: 360px;
}
.dc-rank-wrap {
  margin-top: 8px;
}
@media (max-width: 900px) {
  .dc-compare-summary {
    grid-template-columns: 1fr 1fr;
  }
}

.cate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(43,39,34,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-card {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  position: relative;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  padding-bottom: 8px;
}
.modal-head h3 {
  margin: 0;
  color: var(--ink);
  line-height: 1.4;
}
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #f4f0e9;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-close:hover { background: #e7eee6; color: var(--brand-dark); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: #fff;
  z-index: 2;
  padding: 12px 0 4px;
}

.upload-block {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fcfbf8;
}

.spec-editor .upload-title {
  margin-bottom: 6px;
}
.spec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 10px;
}
.spec-row {
  display: grid;
  grid-template-columns: 140px minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.spec-row select,
.spec-row input {
  width: 100%;
}
.spec-row .btn {
  padding: 6px 10px;
}
@media (max-width: 720px) {
  .spec-row {
    grid-template-columns: 1fr auto;
  }
  .spec-row select {
    grid-column: 1 / -1;
  }
}

.sku-block .sku-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sku-label-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: var(--ink);
}
.sku-label-field select {
  min-width: 120px;
}
.sku-label-custom {
  width: 160px;
  max-width: 40vw;
}
.sku-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
  max-height: 360px;
  overflow: auto;
}
.sku-row {
  display: grid;
  grid-template-columns: 56px minmax(120px, 1.6fr) 100px 90px auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.sku-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f4f0e9;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}
.sku-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sku-thumb .sku-thumb-empty {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px;
  line-height: 1.2;
}
.sku-row input[type="text"],
.sku-row input[type="number"] {
  width: 100%;
  min-width: 0;
}
.sku-row-ops {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.sku-row-ops .btn {
  padding: 4px 10px;
  font-size: 12px;
}
@media (max-width: 720px) {
  .sku-row {
    grid-template-columns: 56px 1fr;
  }
  .sku-row-ops {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}
.upload-title {
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 10px;
  font-weight: 600;
  line-height: 1.4;
}
.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.upload-tip { font-size: 12px; color: var(--muted); line-height: 1.4; }
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.img-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 20px;
}
.video-preview {
  min-height: 20px;
}
.video-preview-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 420px;
}
.video-preview-inner video {
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  background: #111;
}
.video-preview-path {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.4;
}
.img-preview.single { min-height: 72px; }
.thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-img-preview .detail-thumb {
  width: 96px;
  height: 120px;
}
.detail-img-preview .thumb-idx {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
}
.thumb .rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(43,39,34,.7);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.thumb-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0;
  line-height: 1.4;
}
.table-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  display: block;
}
.cate-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cate-card-top { display: flex; gap: 12px; align-items: center; }
.cate-card-top img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  flex-shrink: 0;
  padding: 4px;
  box-sizing: border-box;
}
.cate-card h4 { margin: 0 0 4px; color: var(--ink); line-height: 1.35; }
.cate-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.cate-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

.quick-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 6px 20px rgba(43,39,34,.04);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}
.stat-card.accent { background: #e7eee6; border-color: #cfe0cd; }
.stat-card.warn { background: #f4e7df; border-color: #e8d2c4; }
.stat-card.clickable {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.stat-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(43, 39, 34, 0.08);
}
.stat-jump {
  margin-top: 10px;
  font-size: 12px;
  color: var(--brand-dark, #5e7a62);
  opacity: 0.85;
}
.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}
.stat-num {
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  word-break: break-all;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}
.badge.paid { background: #f4e7df; color: #ce8e73; }
.badge.transferred { background: #e2eff3; color: #6e9fb0; }
.badge.shipped { background: #e7eee6; color: #5e7a62; }
.badge.requested { background: #f8ecd8; color: #b07a3a; }

.modal-card-wide {
  width: min(860px, 100%);
}

.order-goods-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}
.order-goods-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.order-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: #f4f0e9;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.order-thumb-empty {
  background: #f4f0e9
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 24 24' fill='none' stroke='%23c4beb4' stroke-width='1.5'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'/%3E%3Cpath d='M21 15l-5-5L5 21'/%3E%3C/svg%3E")
    center/40% no-repeat;
  border: 1px solid var(--line);
}
.order-goods-name {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.35;
}
.order-goods-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.order-detail-body {
  padding: 4px 0 8px;
}
.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 16px;
  margin-bottom: 18px;
}
.order-detail-grid .full {
  grid-column: 1 / -1;
}
.od-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.od-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f4f0e9;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}
.order-detail-sub {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--ink);
}
.order-detail-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.order-detail-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  background: #fbf9f5;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.order-detail-cover {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #f4f0e9;
  flex-shrink: 0;
  border: 1px solid var(--line);
}
.order-detail-item-name {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.4;
}
.order-detail-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.order-items-preview {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.draft-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #f4f0e9;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  flex-wrap: wrap;
}

.customer-detail {
  margin-top: 24px;
  padding: 18px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.customer-detail h3 {
  margin: 0 0 8px;
  line-height: 1.4;
  color: var(--ink);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
  margin-top: 22px;
}
.chart-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 6px 20px rgba(43,39,34,.04);
  min-width: 0;
}
.chart-card.chart-wide {
  grid-column: 1 / -1;
}
.chart-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.4;
}
.chart-sub {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.chart-box {
  position: relative;
  height: 280px;
  width: 100%;
}
.chart-box-pie {
  height: 300px;
  max-width: 360px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card.chart-wide { grid-column: auto; }
  :root { --side-w: 180px; }
  .main { padding: 22px 18px 40px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ---------- 手机 / 窄屏 ---------- */
@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  .login-wrap {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .login-card {
    padding: 22px 18px;
    border-radius: 16px;
  }

  .app {
    flex-direction: column;
    min-height: 100dvh;
  }

  .side {
    width: 100%;
    flex: none;
    height: auto;
    position: sticky;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px));
    gap: 10px;
    box-shadow: 0 4px 16px rgba(43, 39, 34, 0.06);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
  }

  .side-top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .brand {
    padding: 0;
    font-size: 17px;
  }

  .logout {
    margin: 0;
    width: auto;
    min-height: 36px;
    padding: 6px 14px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .side nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    margin: 0 -4px;
    padding-left: 4px;
    padding-right: 4px;
  }
  .side nav::-webkit-scrollbar { display: none; }

  .nav {
    width: auto;
    flex: 0 0 auto;
    padding: 9px 14px;
    font-size: 13px;
    background: #f4f0e9;
    border-radius: 999px;
    min-height: 36px;
  }
  .nav.on {
    background: #e7eee6;
    color: var(--brand-dark);
    font-weight: 600;
  }

  .main {
    padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
  }

  .tab h2 { font-size: 19px; margin-bottom: 6px; }
  .hint { font-size: 12px; margin-bottom: 14px; }

  .row-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .row-head .btn { width: 100%; }

  .toolbar {
    width: 100%;
    flex-direction: column;
  }
  .toolbar input,
  .toolbar select {
    max-width: none;
    flex: 1 1 auto;
    width: 100%;
  }

  .quick-card {
    padding: 14px;
    border-radius: 14px;
  }

  .form.grid {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .stat-card { padding: 14px; }
  .stat-num { font-size: 20px; }

  .chart-box { height: 220px; }
  .chart-box-pie { height: 240px; max-width: none; }
  .chart-card { padding: 14px; }

  .cate-list {
    grid-template-columns: 1fr;
  }

  /* 表格 → 卡片列表 */
  .table-wrap {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  .table-wrap table {
    min-width: 0 !important;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: block;
  }

  .table-wrap tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 4px 14px rgba(43, 39, 34, 0.04);
  }

  .table-wrap td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border: none;
    padding: 8px 0;
    text-align: right;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .table-wrap td.col-check {
    display: none;
  }

  .table-wrap td:not(:last-child) {
    border-bottom: 1px dashed #f0ebe3;
  }

  .table-wrap td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 36%;
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    padding-top: 2px;
  }

  .table-wrap td.actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 12px;
    border-bottom: none !important;
  }
  .table-wrap td.actions .actions-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    justify-content: flex-start;
  }
  .table-wrap td.actions::before {
    width: 100%;
    max-width: none;
    margin-bottom: 2px;
  }
  .table-wrap td.actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
    font-size: 13px;
    padding: 9px 10px;
  }

  .order-goods-cell {
    align-items: flex-end;
    width: 100%;
  }
  .order-goods-line {
    justify-content: flex-end;
    text-align: left;
  }

  .img-preview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* 弹窗全屏更友好 */
  .modal {
    padding: 0;
    align-items: flex-end;
  }
  .modal-card,
  .modal-card-wide {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: 18px 18px 0 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  }
  .modal-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-actions .btn {
    flex: 1 1 calc(50% - 8px);
  }

  .order-detail-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .order-detail-item {
    padding: 10px;
  }
  .order-detail-cover {
    width: 56px;
    height: 56px;
  }
  .order-detail-item-meta {
    gap: 6px 10px;
    font-size: 12px;
  }

  .customer-detail {
    padding: 14px;
  }

  .btn {
    min-height: 42px;
  }

  input, textarea, select {
    min-height: 44px;
    font-size: 16px; /* 避免 iOS 聚焦放大 */
  }
}

@media (max-width: 420px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .table-wrap td.actions .btn {
    flex: 1 1 100%;
  }
}


.modal-card-share { max-width: 440px; width: calc(100% - 24px); }
.share-card {
  background: #fff; border: 1px solid #ece7df; border-radius: 16px;
  padding: 22px 20px 18px; color: #2b2722;
}
.share-card-brand { font-size: 13px; letter-spacing: 0.08em; color: #7e9c82; font-weight: 700; }
.share-card-title { margin-top: 6px; font-size: 22px; font-weight: 700; }
.share-card-meta { margin-top: 16px; display: grid; gap: 8px; font-size: 13px; line-height: 1.45; }
.share-card-meta span { display: inline-block; min-width: 42px; color: #9a948a; margin-right: 8px; }
.share-card-items { margin-top: 16px; border-top: 1px dashed #ece7df; padding-top: 12px; display: grid; gap: 10px; }
.share-card-item { display: flex; gap: 10px; align-items: center; }
.share-card-cover { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: #f5f5f5; flex-shrink: 0; }
.share-card-item-name { font-size: 13px; font-weight: 600; line-height: 1.35; }
.share-card-item-meta { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: #6f6960; }
.share-card-total { margin-top: 16px; padding-top: 12px; border-top: 1px solid #ece7df; text-align: right; font-size: 14px; }
.share-card-total b { font-size: 22px; color: #ce8e73; margin-left: 6px; }
.share-card-note { margin-top: 10px; font-size: 12px; color: #6f6960; line-height: 1.45; }
.hot-pick-wrap {
  max-height: 48vh;
  overflow: auto;
}
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e7eee6;
  color: #5e7a62;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}
.share-card-foot {
  margin-top: 14px; text-align: center; font-size: 12px; color: #7e9c82;
  background: #e7eee6; border-radius: 999px; padding: 8px 12px;
}
