:root {
  --ant-primary: #1677ff;
  --ant-success: #52c41a;
  --ant-warning: #faad14;
  --ant-error: #ff4d4f;
  --ant-text: #262626;
  --ant-text-secondary: #8c8c8c;
  --ant-border: #f0f0f0;
  --ant-bg-layout: #f5f5f5;
  --ant-bg-card: #ffffff;
  --ant-sider: #001529;
  --ant-sider-text: rgba(255, 255, 255, 0.65);
  --ant-sider-active: #1677ff;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ant-text);
  background: var(--ant-bg-layout);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
}

.sidebar {
  background: var(--ant-sider);
  color: var(--ant-sider-text);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 10px;
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  color: #fff;
  font-weight: 600;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-group {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.nav-group-toggle {
  width: 100%;
  height: 32px;
  border: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  text-align: left;
  font-size: 13px;
  line-height: 20px;
  padding: 6px 10px;
  cursor: pointer;
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.nav-sub {
  display: none;
  gap: 2px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.1);
}

.nav-group.open .nav-sub {
  display: grid;
}

.nav-sub a {
  text-decoration: none;
  color: var(--ant-sider-text);
  padding: 7px 10px 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 20px;
}

.nav-sub a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-sub a.active {
  color: #fff;
  background: var(--ant-sider-active);
  font-weight: 500;
}

.side-note {
  margin-top: 8px;
  padding: 8px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.56);
}

.main {
  padding: 10px;
  display: grid;
  gap: 8px;
  align-content: start;
}

.card {
  background: var(--ant-bg-card);
  border: 1px solid var(--ant-border);
  border-radius: var(--radius);
}

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

.title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 22px;
  font-weight: 600;
}

.title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  border: 1px solid var(--ant-border);
  background: #fafafa;
  color: var(--ant-text-secondary);
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  padding: 0 8px;
}

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

.stat {
  padding: 8px 10px;
}

.stat .k {
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.stat .v {
  margin-top: 2px;
  font-size: 20px;
  line-height: 24px;
  font-weight: 600;
}

.stat .s {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.s-up {
  color: var(--ant-success);
}

.s-down {
  color: var(--ant-error);
}

.section {
  padding: 10px 12px;
}

.section-head {
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.section-head h3 {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.section-head p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

button,
select,
input {
  height: 28px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--ant-text);
  background: #fff;
}

textarea {
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ant-text);
  background: #fff;
  resize: vertical;
  min-height: 68px;
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:hover {
  color: var(--ant-primary);
  border-color: #91caff;
}

button:disabled {
  cursor: not-allowed;
  color: #8c8c8c;
  background: #f5f5f5;
  border-color: #d9d9d9;
}

button.is-loading {
  position: relative;
  padding-left: 22px;
}

button.is-loading::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 50%;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid #91caff;
  border-top-color: #1677ff;
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
}

.btn-primary {
  color: #fff;
  background: var(--ant-primary);
  border-color: var(--ant-primary);
}

.btn-primary:hover {
  color: #fff;
  background: #4096ff;
  border-color: #4096ff;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.filters input {
  min-width: 220px;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.tab-btn {
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: var(--ant-text-secondary);
  padding: 0 10px;
  height: 28px;
  font-size: 12px;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--ant-primary);
  border-color: #91caff;
  background: #e6f4ff;
}

.table-wrap {
  border: 1px solid var(--ant-border);
  border-radius: 8px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--ant-border);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #fafafa;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.88);
}

tbody tr:hover td {
  background: #fafafa;
}

.table-action-btn {
  height: 22px;
  line-height: 20px;
  padding: 0 6px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  background: #fff;
  color: #0958d9;
  font-size: 12px;
  cursor: pointer;
}

.table-action-btn:hover {
  border-color: #91caff;
  background: #e6f4ff;
  color: #0958d9;
}

.cell-marketing {
  min-width: 180px;
  white-space: normal;
}

.cell-marketing .badges {
  gap: 4px;
}

.cell-products {
  min-width: 220px;
  white-space: normal;
}

.cell-promotion-goods {
  min-width: 260px;
  white-space: normal;
}

.promotion-goods-badges {
  gap: 4px;
}

.order-items-summary {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.order-items-summary span {
  padding: 0 6px;
  border-radius: 999px;
  background: #f5f5f5;
  color: var(--ant-text);
  line-height: 18px;
  font-size: 12px;
}

.action-sep {
  display: inline-block;
  margin: 0 4px;
  color: #bfbfbf;
}

.tag {
  display: inline-block;
  border: 1px solid;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 20px;
}

.tag.ok {
  color: #389e0d;
  border-color: #b7eb8f;
  background: #f6ffed;
}

.tag.warn {
  color: #d48806;
  border-color: #ffe58f;
  background: #fffbe6;
}

.tag.danger {
  color: #cf1322;
  border-color: #ffccc7;
  background: #fff2f0;
}

.tag.pending {
  color: #0958d9;
  border-color: #91caff;
  background: #e6f4ff;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: start;
}

.timeline {
  display: grid;
  gap: 6px;
}

.timeline-item {
  border: 1px solid var(--ant-border);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.timeline-item .muted {
  margin-top: 2px;
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.list li {
  border: 1px solid var(--ant-border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.list strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ant-text);
}

.category-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 8px;
  align-items: start;
}

.tree-panel {
  border: 1px solid var(--ant-border);
  border-radius: 8px;
  padding: 8px;
}

.tree-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.tree-item {
  border: 1px solid var(--ant-border);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 12px;
}

.tree-item.level-1 {
  font-weight: 500;
  background: #fafafa;
}

.tree-item.level-2 {
  margin-left: 14px;
}

.tree-item.active {
  border-color: #91caff;
  background: #e6f4ff;
}

.tree-meta {
  color: var(--ant-text-secondary);
}

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--ant-border);
  border-left: 3px solid #1677ff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ant-text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  animation: toast-in 0.18s ease-out;
}

.toast-success {
  border-left-color: var(--ant-success);
}

.toast-warn {
  border-left-color: var(--ant-warning);
}

.toast-error {
  border-left-color: var(--ant-error);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
}

.modal-root.open {
  display: block;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--ant-border);
  border-radius: 10px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2);
}

.modal-panel.drawer-panel {
  left: auto;
  right: 0;
  top: 0;
  transform: none;
  width: min(980px, calc(100vw - 24px));
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  border-right: 0;
}

.modal-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ant-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.modal-header h3 {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.modal-close {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
}

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

.modal-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ant-text-secondary);
  white-space: pre-line;
}

.modal-desc-rich {
  color: var(--ant-text);
  white-space: normal;
}

.flow-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.flow-table-wrap {
  max-height: calc(100vh - 220px);
}

.flow-table {
  min-width: 760px;
}

.flow-qty-up {
  color: var(--ant-success);
  font-weight: 600;
}

.flow-qty-down {
  color: var(--ant-error);
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 8px;
}

.form-item {
  display: grid;
  gap: 4px;
}

.form-item > span {
  font-size: 12px;
  color: var(--ant-text);
}

.form-item .req {
  color: var(--ant-error);
  margin-left: 2px;
}

.form-item input,
.form-item select {
  width: 100%;
}

.form-item textarea {
  width: 100%;
}

.inbound-items-editor {
  display: grid;
  gap: 6px;
}

.inbound-items-header,
.inbound-item-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 90px 110px 62px;
  gap: 6px;
  align-items: center;
}

.inbound-items-header {
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.inbound-item-row .inbound-item-remove {
  height: 28px;
  padding: 0 6px;
}

.inbound-item-add {
  justify-self: flex-start;
}

.outbound-items-editor {
  display: grid;
  gap: 6px;
}

.outbound-items-header,
.outbound-item-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 100px 62px;
  gap: 6px;
  align-items: center;
}

.outbound-items-header {
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.outbound-item-row .outbound-item-remove {
  height: 28px;
  padding: 0 6px;
}

.outbound-item-add {
  justify-self: flex-start;
}

.stocktake-items-editor {
  display: grid;
  gap: 6px;
}

.stocktake-items-header,
.stocktake-item-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 62px;
  gap: 6px;
  align-items: center;
}

.stocktake-items-header {
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.stocktake-item-row .stocktake-item-remove {
  height: 28px;
  padding: 0 6px;
}

.stocktake-item-add {
  justify-self: flex-start;
}

.store-offline-items-editor {
  display: grid;
  gap: 6px;
}

.store-offline-items-header,
.store-offline-item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(100px, 0.8fr) 80px 96px 96px 62px;
  gap: 6px;
  align-items: center;
}

.store-offline-items-header {
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.store-offline-item-row .store-offline-item-remove {
  height: 28px;
  padding: 0 6px;
}

.store-offline-item-add {
  justify-self: flex-start;
}

.store-offline-order-detail-row td {
  padding: 0;
  background: #fafafa;
}

.store-offline-order-detail {
  padding: 10px 12px;
  border-top: 1px solid var(--ant-border);
  background: linear-gradient(180deg, #fbfdff 0%, #f7faff 100%);
}

.store-offline-order-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.store-offline-order-detail-head h4 {
  margin: 0;
  font-size: 13px;
  line-height: 20px;
}

.store-offline-order-detail-head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ant-text-secondary);
}

.store-offline-order-detail-summary {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.store-offline-order-detail-marketing {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.store-offline-order-detail .muted {
  color: var(--ant-text-secondary);
}

.store-offline-order-detail-table-wrap {
  max-height: 320px;
}

.store-offline-order-detail-table {
  min-width: 820px;
}

.store-offline-order-detail-table td,
.store-offline-order-detail-table th {
  white-space: normal;
}

.modal-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--ant-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 1200px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

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

  .category-grid {
    grid-template-columns: 1fr;
  }

  .nav {
    gap: 6px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-panel.drawer-panel {
    width: 100vw;
  }

  .inbound-items-header {
    display: none;
  }

  .outbound-items-header {
    display: none;
  }

  .stocktake-items-header {
    display: none;
  }

  .inbound-item-row {
    grid-template-columns: 1fr 1fr;
  }

  .outbound-item-row {
    grid-template-columns: 1fr 1fr;
  }

  .stocktake-item-row {
    grid-template-columns: 1fr;
  }

  .store-offline-items-header {
    display: none;
  }

  .store-offline-item-row {
    grid-template-columns: 1fr 1fr;
  }

  .store-offline-item-row .store-offline-item-product,
  .store-offline-item-row .store-offline-item-spec,
  .store-offline-item-row .store-offline-item-status {
    grid-column: 1 / -1;
  }

  .inbound-item-row .inbound-item-product {
    grid-column: 1 / -1;
  }

  .outbound-item-row .outbound-item-product {
    grid-column: 1 / -1;
  }

  .stocktake-item-row .stocktake-item-product {
    grid-column: 1 / -1;
  }

  .inbound-item-row .inbound-item-remove {
    grid-column: 1 / -1;
    justify-self: flex-end;
  }

  .outbound-item-row .outbound-item-remove {
    grid-column: 1 / -1;
    justify-self: flex-end;
  }

  .stocktake-item-row .stocktake-item-remove {
    grid-column: 1 / -1;
    justify-self: flex-end;
  }

  .store-offline-order-detail-head {
    flex-direction: column;
  }
}

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

  .filters input {
    min-width: 100%;
  }
}
