:root {
  color-scheme: light;
  --panel: #ffffff;
  --ink: #20263a;
  --muted: #75809a;
  --line: #e2e8f2;
  --soft: #f7f9fc;
  --group: #f2f5fb;
  --group-mint: #e8f8f6;
  --brand: #2d63ff;
  --brand-deep: #1f46bd;
  --good: #17a05d;
  --warn: #d97706;
  --shadow: 0 14px 40px rgba(24, 38, 78, 0.08);
  --mobile-shadow: 0 10px 28px rgba(24, 38, 78, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(45, 99, 255, 0.08), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #f2f5fb 100%);
}

.page-shell {
  width: min(1480px, calc(100% - 20px));
  margin: 14px auto 24px;
}

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

.hero {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  margin-bottom: 12px;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-deep);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.08;
}

.hero-text,
.panel-head p,
.hint,
.modal-text {
  margin-top: 6px;
  color: var(--muted);
}

.status-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.status-content {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 12px;
}

.status-text {
  min-width: 0;
}

.status-text p {
  margin-top: 4px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

.status-actions .secondary-button {
  min-width: 96px;
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warn);
  box-shadow: 0 0 0 5px rgba(217, 119, 6, 0.12);
  flex: 0 0 auto;
  margin-top: 5px;
}

.status-dot.ok {
  background: var(--good);
  box-shadow: 0 0 0 5px rgba(23, 160, 93, 0.12);
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

.panel-head {
  margin-bottom: 10px;
}

.query-head,
.result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.query-toolbar,
.actions,
.toolbar-actions,
.pager,
.order-toolbar,
.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.query-toolbar,
.actions,
.toolbar-actions,
.order-toolbar {
  align-items: flex-end;
}

.pager {
  align-items: center;
}

.stack {
  display: grid;
  gap: 10px;
}

textarea,
input,
button {
  font: inherit;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--ink);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.compact-textarea {
  min-height: 88px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  cursor: pointer;
  font-weight: 700;
  position: relative;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.is-loading {
  padding-right: 34px;
}

button.is-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 999px;
  animation: button-spin 0.8s linear infinite;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.secondary-button {
  background: #fff;
  color: var(--brand-deep);
  border: 1px solid var(--line);
}

.icon-button {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.toolbar-field {
  min-width: 120px;
}

.toolbar-field-wide {
  width: 360px;
}

.toolbar-field-xxwide {
  width: 420px;
}

.page-indicator {
  min-width: 72px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.pager-input {
  width: 88px;
  height: 36px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.loading,
.error,
.empty {
  border-radius: 12px;
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.error {
  color: #b42318;
}

.hidden {
  display: none !important;
}

.mobile-sort-bar {
  display: none;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.goods-table-wrap {
  max-height: 58vh;
  overflow: auto;
}

.order-table-wrap {
  max-height: 52vh;
  overflow: auto;
}

.goods-table,
.order-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.col-check {
  width: 38px;
}

.col-index,
.order-col-index {
  width: 56px;
}

.col-goods {
  width: 430px;
}

.col-attr {
  width: 140px;
}

.col-num,
.order-col-num {
  width: 88px;
}

.col-usable {
  width: 110px;
}

.order-col-order-no {
  width: 150px;
}

.order-col-skc {
  width: 180px;
}

.order-col-status {
  width: 110px;
}

.order-col-time {
  width: 140px;
}

.order-col-meta {
  width: 220px;
}

.goods-table th,
.goods-table td,
.order-table th,
.order-table td {
  padding: 5px 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  background: #fff;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.goods-table th:nth-child(n + 5),
.goods-table td:nth-child(n + 5),
.order-table th:nth-child(n + 7),
.order-table td:nth-child(n + 7) {
  white-space: nowrap;
}

.goods-table th:last-child,
.goods-table td:last-child,
.order-table th:last-child,
.order-table td:last-child {
  border-right: 0;
}

.goods-table thead th,
.order-table thead th {
  font-weight: 600;
  color: #334155;
}

.group-row th {
  font-size: 12px;
  text-align: center;
  padding: 7px 6px;
  background: var(--group);
}

.group-row th:nth-child(2) {
  background: var(--group-mint);
}

.column-row th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  text-align: left;
  background: #f9fbff;
}

.sortable {
  cursor: pointer;
  user-select: none;
}

.sortable::after {
  content: " ↕";
  color: #9aa4b2;
  font-size: 10px;
}

.sortable[data-active="true"][data-direction="asc"]::after,
.sort-chip[data-active="true"][data-direction="asc"]::after {
  content: " ↑";
  color: var(--brand-deep);
}

.sortable[data-active="true"][data-direction="desc"]::after,
.sort-chip[data-active="true"][data-direction="desc"]::after {
  content: " ↓";
  color: var(--brand-deep);
}

.check-cell,
.index-cell {
  text-align: center;
  vertical-align: middle;
}

.section-cell {
  background: #fcfdff;
}

.goods-block,
.status-stack {
  display: grid;
  gap: 3px;
}

.goods-block {
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.thumb {
  width: 58px;
  height: 78px;
  object-fit: cover;
  border-radius: 8px;
  background: #edf2f8;
  border: 1px solid var(--line);
}

.goods-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.goods-line {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px;
  align-items: start;
  font-size: 11px;
}

.goods-line span {
  color: var(--muted);
}

.goods-line strong {
  font-size: 12px;
  color: var(--ink);
  min-width: 0;
  line-height: 1.2;
}

.goods-line-status .status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.goods-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.mini-tag {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--brand-deep);
  font-size: 10px;
  white-space: nowrap;
}

.mini-tag.accent {
  background: #ecfdf3;
  color: #067647;
}

.mini-tag.muted {
  background: #f2f4f7;
  color: var(--muted);
}

.status-stack {
  align-items: flex-start;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3b4db5;
  font-size: 10px;
}

.status-pill.ok {
  background: #e8fff1;
  color: #067647;
}

.summary-row td {
  background: #f8fafc;
  font-weight: 700;
}

.sticky-summary-row td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 -6px 12px rgba(24, 38, 78, 0.06);
}

.mobile-goods-list,
.mobile-order-list {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  position: relative;
  width: min(680px, calc(100% - 24px));
  margin: 8vh auto 0;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
}

.modal-card-wide {
  width: min(1460px, calc(100% - 24px));
  max-height: 88vh;
  overflow-y: auto;
}

.modal-head,
.order-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.order-pager-wrap {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0 12px;
}

.order-type-tabs {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.order-type-tab {
  background: #fff;
  color: var(--brand-deep);
  border: 1px solid var(--line);
}

.order-type-tab.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  border-color: transparent;
}

.order-spu-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.order-spu-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 12px;
}

.order-spu-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
  color: var(--ink);
}

.order-spu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.order-spu-grid div {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 10px;
  background: var(--soft);
}

.order-spu-grid span {
  font-size: 11px;
  color: var(--muted);
}

.order-spu-grid strong {
  font-size: 14px;
  color: var(--ink);
}

.order-strong {
  font-weight: 700;
}

.order-sub {
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

.order-meta {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .query-head,
  .result-head,
  .query-toolbar,
  .order-toolbar,
  .order-result-head {
    align-items: stretch;
  }

  .toolbar-field,
  .toolbar-field-wide,
  .toolbar-field-xxwide {
    width: 100%;
    flex: 1 1 100%;
  }

  .page-shell {
    width: calc(100% - 12px);
    margin: 8px auto 16px;
  }

  .panel,
  .hero {
    padding: 12px;
    border-radius: 16px;
  }

  .modal-card,
  .modal-card-wide {
    width: calc(100% - 12px);
    margin-top: 10px;
    border-radius: 16px;
  }

  .modal-card-wide {
    max-height: 92vh;
  }

  .order-pager-wrap {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  body {
    background:
      radial-gradient(circle at top, rgba(45, 99, 255, 0.1), transparent 26%),
      linear-gradient(180deg, #f8fbff 0%, #eef3fb 100%);
  }

  h1 {
    font-size: 24px;
    line-height: 1.1;
  }

  h2 {
    font-size: 18px;
  }

  .hero-text,
  .panel-head p,
  .hint,
  .modal-text {
    font-size: 13px;
    line-height: 1.45;
  }

  .status-card {
    padding: 12px;
  }

  .status-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .status-actions .secondary-button {
    width: 100%;
    min-width: 0;
  }

  .query-toolbar,
  .pager,
  .order-toolbar {
    width: 100%;
  }

  .pager {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
  }

  .pager .page-indicator {
    order: -1;
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    height: 34px;
    justify-content: flex-start;
    padding: 0 10px;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .pager .pager-input {
    width: 100%;
    height: 40px;
  }

  .pager button {
    width: 100%;
    min-height: 40px;
  }

  .result-head {
    gap: 10px;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions .secondary-button {
    width: 100%;
  }

  .goods-table-wrap,
  .order-table-wrap {
    display: none;
  }

  .mobile-sort-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mobile-sort-bar::-webkit-scrollbar {
    display: none;
  }

  .sort-chip {
    flex: 0 0 auto;
    padding: 9px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--brand-deep);
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
  }

  .sort-chip[data-active="true"] {
    background: linear-gradient(135deg, var(--brand), var(--brand-deep));
    color: #fff;
    border-color: transparent;
  }

  .mobile-goods-list,
  .mobile-order-list {
    display: grid;
    gap: 10px;
  }

  .mobile-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--mobile-shadow);
    overflow: hidden;
  }

  .mobile-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px 0;
  }

  .mobile-card-body {
    display: grid;
    gap: 12px;
    padding: 10px 12px 12px;
  }

  .mobile-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--ink);
  }

  .mobile-index {
    color: var(--brand-deep);
    font-weight: 700;
    font-size: 13px;
  }

  .goods-block {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
  }

  .thumb {
    width: 72px;
    height: 96px;
    border-radius: 10px;
  }

  .goods-info {
    gap: 5px;
  }

  .goods-line {
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 6px;
    font-size: 12px;
  }

  .goods-line strong {
    font-size: 13px;
    line-height: 1.35;
  }

  .goods-tags {
    gap: 6px;
    margin-top: 4px;
  }

  .mini-tag,
  .status-pill {
    min-height: 22px;
    padding: 0 8px;
    font-size: 11px;
  }

  .mobile-section {
    display: grid;
    gap: 8px;
  }

  .mobile-section-title,
  .mobile-summary-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.02em;
  }

  .mobile-attr-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .mobile-attr-chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f2f6ff;
    color: var(--brand-deep);
    font-size: 12px;
  }

  .mobile-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-metric {
    display: grid;
    gap: 4px;
    padding: 10px;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfcff, #f3f7ff);
    border: 1px solid #e8eefc;
  }

  .mobile-metric span {
    color: var(--muted);
    font-size: 11px;
  }

  .mobile-metric strong {
    color: var(--ink);
    font-size: 16px;
    line-height: 1.1;
  }

  .mobile-summary-card {
    padding: 12px;
  }

  .mobile-summary-card .mobile-summary-title {
    margin-bottom: 8px;
  }

  .mobile-order-title {
    padding: 0 12px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
  }

  .mobile-order-sub {
    padding: 2px 12px 0;
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-info-grid div {
    display: grid;
    gap: 3px;
    padding: 10px;
    border-radius: 12px;
    background: var(--soft);
  }

  .mobile-info-grid span {
    color: var(--muted);
    font-size: 11px;
  }

  .mobile-info-grid strong {
    font-size: 13px;
    line-height: 1.3;
  }

  .mobile-metrics-grid-order {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-meta {
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 12px;
    padding: 0;
  }

  .order-spu-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: calc(100% - 8px);
    margin: 4px auto 12px;
  }

  .hero,
  .panel,
  .modal-card {
    border-radius: 14px;
  }

  .hero,
  .panel {
    padding: 10px;
  }

  .status-card {
    gap: 10px;
    padding: 10px;
  }

  .status-actions {
    grid-template-columns: 1fr;
  }

  .goods-block {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .thumb {
    width: 64px;
    height: 86px;
  }

  .mobile-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-info-grid {
    grid-template-columns: 1fr;
  }

  .pager {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pager .page-indicator {
    grid-column: 1 / -1;
  }

  .modal-card,
  .modal-card-wide {
    width: calc(100% - 8px);
    margin-top: 4px;
    padding: 12px;
  }

  .modal-card-wide {
    max-height: 94vh;
  }
}
