:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-soft: #f3f7fb;
  --line: #e3e9f1;
  --line-strong: #cbd5e1;
  --text: #101828;
  --muted: #667085;
  --blue: #2563eb;
  --green: #0f9f6e;
  --orange: #f97316;
  --purple: #6d5dfc;
  --cyan: #0891b2;
  --red: #dc2626;
  --yellow: #b7791f;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial,
    sans-serif;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
  padding: 24px 38px 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: linear-gradient(145deg, #1d7cf2, #73d2ff);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.logo::before,
.logo::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.logo::before {
  left: 10px;
  top: 9px;
}

.logo::after {
  right: 9px;
  bottom: 9px;
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--text);
}

.badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.user-menu-wrap {
  position: relative;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 10px;
}

.user-dropdown-head {
  display: grid;
  gap: 4px;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--line);
}

.user-dropdown-head span {
  color: var(--muted);
  font-size: 12px;
}

.user-dropdown button {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  border: 0;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--red);
  font-weight: 800;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #eaf1ff;
  color: var(--blue);
  font-weight: 800;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 24px;
}

.module-card {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  color: var(--text);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.module-card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.module-card.is-disabled {
  cursor: default;
}

.module-card.is-disabled:hover {
  transform: none;
}

.module-icon {
  display: grid;
  place-items: center;
  width: 126px;
  height: 126px;
  border-radius: 50%;
}

.module-card h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: 0;
}

.page {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.subnav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 9px 14px;
  white-space: nowrap;
  font-weight: 700;
}

.nav-pill.active {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eaf1ff;
  color: var(--blue);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  white-space: nowrap;
  font-weight: 700;
}

.crumb span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
}

.crumb.active {
  border-color: rgba(37, 99, 235, 0.3);
  background: #f4f8ff;
  color: var(--blue);
}

.crumb.active span {
  background: var(--blue);
  color: #fff;
}

.page-title h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.page-title p {
  margin: 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.danger,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
}

.primary {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
}

.secondary {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.danger {
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: #fff4f4;
  color: var(--red);
}

.ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
  min-width: 0;
}

.panel-pad {
  padding: 18px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 150px;
  gap: 12px;
  margin-bottom: 14px;
}

.field,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.textarea {
  min-height: 78px;
  resize: vertical;
}

.hidden-input {
  display: none;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  min-width: 0;
  overscroll-behavior-x: contain;
  scrollbar-color: #b8c3d1 #eef2f6;
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #eef2f6;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #b8c3d1;
  border: 2px solid #eef2f6;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #8fa1b8;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.green {
  background: #e7f8ef;
  color: #087443;
}

.status.blue {
  background: #eaf1ff;
  color: #1d4ed8;
}

.status.yellow {
  background: #fff7df;
  color: var(--yellow);
}

.status.red {
  background: #fff1f1;
  color: var(--red);
}

.status.gray {
  background: #eef2f6;
  color: #475467;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.form-group {
  display: grid;
  gap: 7px;
}

.form-group label {
  color: #475467;
  font-size: 13px;
  font-weight: 700;
}

.upload-box {
  margin-top: 16px;
  border: 1.5px dashed #a7b5c8;
  border-radius: 8px;
  background: #f8fbff;
  padding: 28px;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 10px;
}

.upload-box input {
  display: none;
}

.upload-title {
  font-size: 18px;
  font-weight: 800;
}

.upload-sub {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  margin-top: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 10px 12px;
  font-weight: 700;
}

.error-notice {
  border-color: #fecaca;
  background: #fff1f1;
  color: var(--red);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin-top: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.login-page {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-logo {
  width: 54px;
  height: 54px;
}

.login-card h2,
.login-card p {
  margin: 0;
}

.login-card p {
  color: var(--muted);
}

.login-submit,
.login-back {
  width: 100%;
}

.system-grid {
  display: grid;
  gap: 14px;
}

.form-grid-compact {
  grid-template-columns: minmax(180px, 260px);
  margin-top: 14px;
}

.form-actions {
  margin-top: 14px;
  justify-content: flex-start;
}

.permission-check {
  display: inline-flex;
  margin-right: 12px;
  min-height: 28px;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.step strong {
  display: block;
  font-size: 13px;
}

.step span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.step.active {
  border-color: rgba(37, 99, 235, 0.35);
  background: #eef5ff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

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

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.inventory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.inventory-layout > * {
  min-width: 0;
}

.merge-workbench {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.task-workbench-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.task-title-block h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 24px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  color: var(--muted);
  font-size: 13px;
}

.uploaded-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.uploaded-strip h3,
.section-head h3,
.side-summary h3 {
  margin: 0;
  font-size: 18px;
}

.file-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.file-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.file-card strong,
.file-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card small {
  grid-column: 2;
  color: var(--muted);
}

.excel-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: #0f9f6e;
  color: #fff;
  font-weight: 900;
}

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}

.main-work-area,
.side-summary {
  display: grid;
  gap: 14px;
  min-width: 0;
}

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

.merge-filters {
  grid-template-columns: minmax(260px, 1fr) 130px 150px 130px 120px 100px;
}

.check-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  color: #475467;
  font-weight: 700;
  white-space: nowrap;
}

.check-filter input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.table-icon-btn {
  min-width: 30px;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 18px;
}

.sku-table th:first-child,
.sku-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 72px;
  width: 72px;
}

.sku-table th:nth-child(2),
.sku-table td:nth-child(2) {
  position: sticky;
  left: 72px;
  z-index: 4;
  min-width: 190px;
  width: 190px;
}

.sku-table th:nth-child(3),
.sku-table td:nth-child(3) {
  position: sticky;
  left: 262px;
  z-index: 4;
  min-width: 360px;
  width: 360px;
  white-space: normal;
  line-height: 1.35;
}

.sku-table th:first-child,
.sku-table th:nth-child(2),
.sku-table th:nth-child(3) {
  background: #f8fafc;
  z-index: 5;
}

.sku-table td:first-child,
.sku-table td:nth-child(2),
.sku-table td:nth-child(3) {
  background: #fff;
}

.sku-table tr.row-abnormal td:first-child,
.sku-table tr.row-abnormal td:nth-child(2),
.sku-table tr.row-abnormal td:nth-child(3) {
  background: #fff5f5;
}

.sku-table th:nth-child(3),
.sku-table td:nth-child(3) {
  box-shadow: 8px 0 10px -10px rgba(15, 23, 42, 0.35);
}

.sku-table {
  min-width: 1680px;
}

.detail-row > td {
  position: sticky !important;
  left: 0;
  z-index: 3;
  background: #fff !important;
  padding: 0;
  width: calc(100vw - 420px);
  max-width: calc(100vw - 420px);
  overflow: hidden;
}

.inline-detail {
  border-top: 1px solid var(--line);
  background: #fbfdff;
  padding: 14px 16px 16px;
  width: 100%;
  max-width: 100%;
  box-shadow: inset 0 1px 0 rgba(203, 213, 225, 0.7);
}

.detail-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.inline-detail-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inline-detail-table table {
  min-width: 1320px;
}

.detail-sticky-table th:first-child,
.detail-sticky-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 250px;
  width: 250px;
}

.detail-sticky-table th:nth-child(2),
.detail-sticky-table td:nth-child(2) {
  position: sticky;
  left: 250px;
  z-index: 4;
  min-width: 170px;
  width: 170px;
}

.detail-sticky-table th:nth-child(3),
.detail-sticky-table td:nth-child(3) {
  position: sticky;
  left: 420px;
  z-index: 4;
  min-width: 160px;
  width: 160px;
}

.detail-sticky-table th:first-child,
.detail-sticky-table th:nth-child(2),
.detail-sticky-table th:nth-child(3) {
  background: #f8fafc;
  z-index: 5;
}

.detail-sticky-table td:first-child,
.detail-sticky-table td:nth-child(2),
.detail-sticky-table td:nth-child(3) {
  background: #fff;
}

.detail-sticky-table th:nth-child(3),
.detail-sticky-table td:nth-child(3) {
  box-shadow: 8px 0 10px -10px rgba(15, 23, 42, 0.35);
}

.positive {
  color: var(--red);
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 800;
}

tr.row-abnormal td {
  background: #fff5f5;
}

tr.row-abnormal td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}

.detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 12px;
  color: var(--muted);
}

.detail-summary strong {
  color: var(--green);
}

.allocation-ok {
  color: var(--green);
  font-weight: 800;
}

.allocation-bad {
  color: var(--red);
  font-weight: 800;
}

.allocation-warning {
  margin-bottom: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f1;
  color: var(--red);
  padding: 10px 12px;
  font-weight: 800;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.pagination-info,
.jump-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.page-size .select {
  min-width: 112px;
}

.page-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.page-btn.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 2px;
}

.jump-input {
  width: 58px;
  min-height: 34px;
  text-align: center;
}

.side-metrics {
  display: grid;
  gap: 10px;
}

.side-metrics div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.side-metrics strong {
  color: var(--text);
}

.progress-box {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.side-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.side-actions button {
  width: 100%;
}

.export-note {
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fff8db;
  color: #7c5d10;
  padding: 12px;
  margin-top: 12px;
  font-size: 12px;
}

.export-note strong {
  display: block;
  margin-top: 8px;
  color: #6b4e08;
}

.export-note strong:first-child {
  margin-top: 0;
}

.export-note ul {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding-left: 16px;
  line-height: 1.45;
}

.export-note li {
  white-space: normal;
}

.detail-panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.detail-item strong {
  color: var(--text);
}

.reserved {
  min-height: 420px;
  display: grid;
  place-items: center;
  text-align: center;
}

.reserved h2 {
  margin: 12px 0 8px;
  font-size: 28px;
}

.reserved p {
  margin: 0;
  color: var(--muted);
}

.tiny-icon {
  width: 18px;
  height: 18px;
}

.big-icon {
  width: 74px;
  height: 74px;
}

.module-logistics {
  background: #fff3e8;
  color: var(--orange);
}

.module-purchase {
  background: #e7faf3;
  color: var(--green);
}

.module-inventory {
  background: #f0edff;
  color: var(--purple);
}

.module-profit {
  background: #eaf1ff;
  color: var(--blue);
}

.module-data {
  background: #e8fbff;
  color: var(--cyan);
}

.module-system {
  background: #edf4ff;
  color: var(--blue);
}

@media (max-width: 980px) {
  .app-shell {
    padding: 18px;
  }

  .home-grid,
  .form-grid,
  .summary-grid,
  .inventory-layout,
  .workbench-grid,
  .file-cards {
    grid-template-columns: 1fr;
  }

  .filters,
  .merge-filters {
    grid-template-columns: 1fr;
  }

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

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-controls {
    justify-content: flex-start;
  }

  .inline-detail {
    max-width: calc(100vw - 56px);
  }

  .detail-row > td {
    width: calc(100vw - 56px);
    max-width: calc(100vw - 56px);
  }
}

@media (max-width: 640px) {
  .topbar,
  .page-head,
  .task-workbench-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand h1 {
    font-size: 26px;
  }

  .module-card {
    min-height: 178px;
  }

  .module-card h2 {
    font-size: 24px;
  }
}
