* { box-sizing: border-box; }
:root {
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --line: #E8E8E8;
  --text: #111111;
  --muted: #8A8A8A;
  --soft: #F4F4F2;
  --danger: #B3261E;
  --ok: #1F7A45;
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 32px 28px;
}
.login-brand { font-size: 24px; font-weight: 700; letter-spacing: 4px; }
.login-sub { margin-top: 6px; color: var(--muted); letter-spacing: 2px; font-size: 13px; }
.login-field { display: block; margin-top: 20px; }
.login-field input {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.login-field input:focus { border-color: #111; }
.login-error { margin-top: 14px; color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid #111;
  background: #111;
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 1px;
  white-space: nowrap;
}
.btn.ghost { background: #fff; color: #111; border-color: var(--line); }
.btn.ghost:hover { border-color: #111; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 22px; padding: 11px 16px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 主结构 ---------- */
.topbar {
  height: 60px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-size: 17px; font-weight: 600; letter-spacing: 2px; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 8px; letter-spacing: 1px; }
.top-actions { display: flex; gap: 10px; }
.page { max-width: 1280px; margin: 0 auto; padding: 22px 28px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }

/* ---------- 统计卡 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.stat-label { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.stat-value { margin-top: 8px; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat-card.warn .stat-value { color: var(--danger); }

/* ---------- 筛选 ---------- */
.filters { padding: 18px 20px; margin-bottom: 18px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label { color: var(--muted); font-size: 12px; }
.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus { border-color: #111; }
.span-2 { grid-column: span 2; }
.filter-actions { display: flex; gap: 10px; justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
}
.chip.active { background: #111; color: #fff; border-color: #111; }

/* ---------- 表格 ---------- */
.table-card { overflow: hidden; }
.table-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.list-summary { color: var(--muted); font-size: 13px; }
.table-scroll { overflow-x: auto; }
table.orders { width: 100%; border-collapse: collapse; min-width: 980px; }
table.orders th, table.orders td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid #F1F1F1;
  white-space: nowrap;
  vertical-align: top;
}
table.orders th { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .5px; background: #FCFCFC; }
table.orders tbody tr:hover { background: #FAFAFA; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.order-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 18px;
}
.pill.dark { background: #111; color: #fff; border-color: #111; }
.pill.ok { color: var(--ok); border-color: #B9DCC6; background: #F1FAF4; }
.pill.warn { color: var(--danger); border-color: #EDC4C0; background: #FDF3F2; }
.pill.muted { color: var(--muted); }
.empty-row td { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-info { color: var(--muted); font-size: 13px; }
.pager-actions { display: flex; align-items: center; gap: 10px; }
.page-size { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------- 抽屉 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, .42);
  z-index: 40;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(720px, 94vw);
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 32px rgba(0, 0, 0, .12);
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}
.drawer-title { font-size: 18px; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.drawer-sub { margin-top: 6px; color: var(--muted); font-size: 13px; }
.icon-btn {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.drawer-actions {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.section { margin-bottom: 24px; }
.section-title { font-size: 13px; color: var(--muted); letter-spacing: 2px; margin-bottom: 10px; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
.kv { display: flex; gap: 10px; font-size: 13.5px; }
.kv .k { color: var(--muted); min-width: 72px; }
.kv .v { word-break: break-all; }
.copy-line { display: flex; align-items: center; gap: 8px; }
.copy-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
  cursor: pointer;
}
.photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.photo-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #FCFCFC; }
.photo-item img { width: 100%; height: 110px; object-fit: cover; display: block; background: #F2F2F2; }
.photo-missing { height: 110px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 6px; }
.photo-cap { padding: 6px 8px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.pay-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pay-table th, .pay-table td { padding: 8px 10px; border-bottom: 1px solid #F1F1F1; text-align: left; }
.pay-table th { color: var(--muted); font-weight: 500; }

/* ---------- 发货弹窗 ---------- */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(400px, 92vw);
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  z-index: 60;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal-field { display: block; margin-bottom: 14px; color: var(--muted); font-size: 12px; }
.modal-field input {
  width: 100%;
  margin-top: 7px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.modal-field input:focus { border-color: #111; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(17, 17, 17, .92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 80;
  max-width: 80vw;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .page { padding: 16px 14px 40px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-actions { grid-column: span 2; justify-content: flex-start; }
  .kv-grid { grid-template-columns: 1fr; }
  .photos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
