:root {
  --page-bg: #f5f6fa;
  --page-panel: #ffffff;
  --sidebar-bg: #3b4a5c;
  --sidebar-text: rgba(255, 255, 255, 0.92);
  --sidebar-muted: rgba(255, 255, 255, 0.68);
  --sidebar-active: #ffffff;
  --line: #e8ebf0;
  --line-soft: #f2f3f5;
  --text: #303133;
  --muted: #909399;
  --accent: #409eff;
  --accent-soft: #ecf5ff;
  --stock: #67c23a;
  --stock-soft: #f0f9eb;
  --warning: #e6a23c;
  --warning-soft: #fdf6ec;
  --danger: #f56c6c;
  --danger-soft: #fef0f0;
  --shadow: 0 12px 32px rgba(31, 35, 41, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--page-bg);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

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

.global-sidebar {
  width: 176px;
  padding: 18px 14px;
  background: var(--sidebar-bg);
}

.global-brand {
  margin-bottom: 18px;
  color: var(--sidebar-active);
  font-size: 22px;
  font-weight: 700;
}

.global-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.global-nav-item {
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  cursor: pointer;
}

.global-nav-item.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--sidebar-active);
  font-weight: 600;
}

.workspace-main {
  flex: 1;
  padding: 22px;
}

.view-panel {
  display: block;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header h1,
.approval-title-row h2,
.modal-title-group h2,
.approval-block-title,
.section-head h3,
.workflow-title h3,
.parts-dialog-header h3 {
  margin: 0;
}

.page-header p,
.modal-title-group p,
.section-head p,
.workflow-content p,
.workflow-content span,
.footer-copy,
.parts-dialog-header p,
.approval-meta-line,
.approval-basic-grid span,
.item-note,
.summary-item span {
  color: var(--muted);
}

.page-link-button,
.primary-button,
.ghost-button,
.secondary-button,
.danger-outline-button,
.text-button,
.qty-button,
.header-link,
.parts-link,
.approval-side-link,
.approval-side-folder,
.approval-card,
.expand-link,
.icon-button {
  transition:
    background-color 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.page-link-button,
.primary-button {
  padding: 9px 18px;
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.demo-canvas {
  padding: 4px;
}

.modal-shell {
  width: 100%;
  max-width: 1180px;
  height: calc(100vh - 132px);
  min-height: 720px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header,
.approval-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 18px 24px 0;
}

.subcopy {
  margin: 6px 0 0;
  font-size: 13px;
}

.icon-button {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.order-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.order-meta {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fafbfd;
}

.order-meta strong,
.approval-basic-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 500;
}

.notice-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border-radius: 4px;
  background: var(--warning-soft);
  border: 1px solid #faecd8;
}

.notice-banner p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #606266;
}

.notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  color: var(--warning);
  font-weight: 700;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.summary-item span {
  display: block;
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 600;
}

.summary-item.stock {
  background: var(--stock-soft);
  border-color: #e1f3d8;
}

.summary-item.stock strong {
  color: var(--stock);
}

.summary-item.loss {
  background: var(--warning-soft);
  border-color: #faecd8;
}

.summary-item.loss strong {
  color: var(--warning);
}

.section-card,
.workflow-card,
.approval-block {
  margin-bottom: 18px;
}

.section-head,
.workflow-title,
.approval-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.section-head h3,
.workflow-title h3,
.approval-block-title {
  font-size: 15px;
  font-weight: 600;
}

.section-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.section-head-inline {
  margin-bottom: 8px;
}

.batch-actions,
.footer-actions,
.approval-detail-tabs {
  display: flex;
  gap: 10px;
}

.ghost-button,
.secondary-button,
.danger-outline-button,
.text-button {
  padding: 8px 15px;
  border-radius: 4px;
  border: 1px solid #dcdfe6;
  background: #fff;
  color: #606266;
  cursor: pointer;
}

.ghost-button.danger,
.danger-outline-button {
  color: var(--danger);
  border-color: #f5c2c7;
  background: #fff;
}

.text-button {
  border-color: transparent;
}

.table-shell,
.approval-table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.return-table,
.approval-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

.return-table thead th,
.approval-table thead th,
.parts-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: #606266;
  background: #f5f7fa;
  border-bottom: 1px solid var(--line);
}

.return-table tbody td,
.approval-table tbody td,
.parts-table td {
  padding: 12px 16px;
  vertical-align: middle;
  border-top: 1px solid #ebeef5;
  background: #fff;
  font-size: 14px;
}

.parent-row > td {
  background: #fff;
}

.child-row > td {
  background: #fbfcfe;
}

.approval-table .child-row > td {
  background: #f7f8fa;
}

.th-with-action {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-link,
.parts-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

.product-cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.product-cell-child {
  padding-left: 22px;
}

.product-thumb {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  background: linear-gradient(135deg, #eef4ff, #fff4e8);
  border: 1px solid #e6eaf2;
  overflow: hidden;
}

.product-thumb::before,
.product-thumb::after {
  content: "";
  position: absolute;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
}

.product-thumb::before {
  width: 14px;
  height: 10px;
  left: 6px;
  top: 8px;
}

.product-thumb::after {
  width: 11px;
  height: 13px;
  right: 6px;
  bottom: 5px;
}

.product-badge {
  position: absolute;
  left: -12px;
  top: 4px;
  width: 52px;
  transform: rotate(-45deg);
  background: #8fce74;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.product-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.product-name {
  margin: 0;
  color: var(--accent);
  font-weight: 400;
}

.expand-link {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.expand-link::after {
  content: "⌄";
  margin-left: 4px;
  font-size: 12px;
}

.expand-link.is-open::after {
  display: inline-block;
  transform: rotate(180deg);
}

.expanded-panel {
  padding-top: 6px;
}

.config-list {
  margin: 0;
  color: #606266;
  font-size: 12px;
  line-height: 1.55;
}

.config-list p {
  margin: 0;
}

.nested-list {
  padding-top: 6px;
}

.nested-item {
  display: grid;
  grid-template-columns: 1fr 84px 160px;
  align-items: center;
  min-height: 36px;
  border-top: 1px solid var(--line-soft);
  color: #606266;
  font-size: 13px;
}

.nested-item-allocation {
  grid-template-columns: 1fr 84px 260px;
}

.nested-item:first-child {
  border-top: 0;
}

.nested-item-subtext {
  color: var(--muted);
}

.nested-item-count {
  text-align: center;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.qty-button {
  width: 30px;
  height: 30px;
  border: 0;
  background: #f5f7fa;
  color: #909399;
  cursor: pointer;
}

.qty-input,
.split-input,
.approval-search input {
  height: 30px;
  border: 0;
  outline: none;
}

.qty-input {
  width: 44px;
  text-align: center;
}

.allocation-grid {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.allocation-card {
  display: flex;
  align-items: center;
  gap: 8px;
}

.allocation-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  white-space: nowrap;
}

.allocation-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.allocation-head strong.stock {
  color: var(--stock);
}

.allocation-head strong.loss {
  color: var(--warning);
}

.split-input {
  width: 48px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  text-align: center;
}

.item-note {
  font-size: 12px;
  line-height: 1.5;
}

.loss-reason-card,
.approval-loss-reason-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.loss-reason-card {
  padding: 14px 16px 12px;
}

.loss-reason-input {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  resize: vertical;
  outline: none;
  font: inherit;
  line-height: 1.6;
  color: var(--text);
}

.loss-reason-input:focus {
  border-color: #89c2ff;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.12);
}

.loss-reason-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.loss-reason-error {
  color: var(--danger);
  font-size: 12px;
}

.loss-reason-count {
  color: var(--muted);
  font-size: 12px;
}

.approval-loss-reason-card {
  padding: 14px 16px;
  color: #606266;
  line-height: 1.7;
  white-space: pre-wrap;
}

.return-mix-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}

.return-mix-line {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.return-sub-action {
  padding-left: 2px;
}

.workflow-bar {
  width: 4px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent);
}

.workflow-list,
.approval-flow-list {
  display: flex;
  flex-direction: column;
}

.workflow-item,
.approval-flow-item {
  position: relative;
  padding-left: 24px;
  min-height: 82px;
}

.workflow-line,
.approval-flow-line {
  position: absolute;
  left: 6px;
  top: 14px;
  bottom: -8px;
  width: 1px;
  border-left: 1px dashed #dcdfe6;
}

.workflow-dot,
.approval-flow-dot {
  position: absolute;
  left: 0;
  top: 6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px currentColor;
}

.workflow-item.active .workflow-dot,
.approval-flow-item.active .approval-flow-dot {
  background: var(--accent);
  color: var(--accent);
}

.workflow-item.pending .workflow-dot,
.approval-flow-item.pending .approval-flow-dot {
  background: var(--warning);
  color: var(--warning);
}

.workflow-user,
.approval-user-chip {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 6px 12px;
  border: 1px solid #ebeef5;
  border-radius: 16px;
  background: #fff;
  color: #606266;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
}

.footer-copy {
  font-size: 13px;
}

.approval-layout {
  display: grid;
  grid-template-columns: 316px 1fr;
  gap: 14px;
  min-height: calc(100vh - 128px);
}

.approval-sidebar,
.approval-detail {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.approval-sidebar {
  display: flex;
  flex-direction: column;
}

.approval-search {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.approval-search input {
  width: 100%;
  padding: 0 12px;
  border-radius: 6px;
  background: #f5f7fa;
}

.approval-side-group {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.approval-side-folder {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: #eaf2ff;
  color: var(--accent);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}

.approval-side-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0 0 26px;
}

.approval-side-link {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: #606266;
  text-align: left;
  cursor: pointer;
}

.approval-side-link.is-active {
  color: var(--accent);
}

.approval-list {
  flex: 1;
  overflow: auto;
  padding: 12px;
}

.approval-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.approval-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.approval-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid #f5dab1;
  border-radius: 4px;
  color: var(--warning);
  font-size: 12px;
}

.approval-card-meta,
.approval-card-copy {
  margin-top: 6px;
  color: #606266;
  font-size: 13px;
}

.approval-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.approval-detail-tabs button {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: #606266;
  cursor: pointer;
}

.approval-detail-tabs button.is-active {
  border-color: #d6e8ff;
  background: var(--accent-soft);
  color: var(--accent);
}

.approval-detail-body {
  height: calc(100vh - 278px);
  overflow: auto;
  padding: 18px 20px 0;
}

.approval-basic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 22px;
}

.approval-basic-grid span {
  display: block;
  font-size: 13px;
}

.approval-summary-chip {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  height: 28px;
  border-radius: 14px;
  background: #f5f7fa;
  color: #606266;
  font-size: 12px;
}

.approval-table td:nth-child(2),
.approval-table td:nth-child(3) {
  width: 120px;
}

.approval-type-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 0 6px;
  height: 20px;
  border-radius: 4px;
  background: #f4f4f5;
  color: #909399;
  font-size: 12px;
}

.approval-sublist {
  margin: 8px 0 0 42px;
  padding: 0;
  list-style: none;
  color: #606266;
  font-size: 12px;
  line-height: 1.6;
}

.approval-loss-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}

.approval-detail-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.parts-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
}

.parts-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(760px, calc(100vw - 40px));
  max-height: min(640px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  z-index: 20;
}

.parts-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.parts-dialog-body {
  overflow: auto;
  padding: 16px 22px 0;
}

.parts-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #ebeef5;
}

.parts-table td:nth-child(2) {
  width: 96px;
  text-align: center;
}

.parts-table td:nth-child(3) {
  width: 140px;
}

.parts-table td:nth-child(4) {
  width: 260px;
}

.parts-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 22px 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 18px;
  border-radius: 4px;
  background: rgba(48, 49, 51, 0.94);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .order-overview,
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .workspace-shell {
    flex-direction: column;
  }

  .global-sidebar {
    width: 100%;
  }

  .approval-layout {
    grid-template-columns: 1fr;
  }

  .approval-detail-body,
  .modal-shell {
    height: auto;
    min-height: 0;
  }

  .page-header,
  .modal-header,
  .approval-detail-header,
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  .workspace-main {
    padding: 12px;
  }

  .order-overview,
  .summary-strip,
  .approval-basic-grid {
    grid-template-columns: 1fr;
  }

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

  .nested-item,
  .nested-item-allocation {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 0;
  }

  .nested-item-count {
    text-align: left;
  }
}
