:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --line: #dce1e4;
  --line-strong: #aeb8bf;
  --text: #171b1f;
  --muted: #69767f;
  --orange: #ff5a00;
  --orange-dark: #d94e00;
  --orange-soft: #fff1e8;
  --green: #13724b;
  --green-soft: #eaf7ef;
  --blue: #255aa8;
  --blue-soft: #edf3ff;
  --amber: #a96800;
  --amber-soft: #fff6df;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 7px 20px rgba(23, 27, 31, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.app {
  min-height: 100vh;
}

.shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  min-height: 112px;
  padding: 24px 0 0;
  background: transparent;
}

.topbar-card {
  min-height: 112px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.logo {
  height: 58px;
  width: auto;
  display: block;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
  margin-top: 6px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.page {
  margin: 16px auto 28px;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-header {
  min-height: 48px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

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

.panel-body {
  padding: 16px;
}

.parameter-grid {
  display: grid;
  grid-template-columns: 300px minmax(620px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.container-selector {
  display: grid;
  gap: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.mode-warning {
  grid-column: 1 / -1;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
  white-space: nowrap;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfcfd;
}

.mode-pill {
  border: 0;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}

.mode-pill.active {
  background: var(--orange);
  color: white;
  box-shadow: 0 3px 8px rgba(255, 90, 0, 0.2);
}

.field-label-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.field-label-line label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 36px;
  padding: 7px 34px 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: var(--text);
  font: inherit;
}

.rule {
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: #2b3338;
}

.rule strong {
  display: block;
  color: var(--orange-dark);
  margin-bottom: 2px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-weight: 800;
}

.btn.primary {
  border-color: var(--orange);
  background: var(--orange);
  color: white;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn.primary:disabled {
  border-color: #9aa4aa;
  background: #9aa4aa;
  color: white;
}

.btn.danger {
  border-color: #f0b2a8;
  background: var(--red-soft);
  color: var(--red);
}

.icon {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-size: 12px;
  line-height: 1;
}

.primary .icon {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.danger .icon {
  background: #ffd6ce;
  color: var(--red);
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge {
  background: var(--orange-soft);
  color: var(--orange-dark);
}

.status.ok {
  background: var(--green-soft);
  color: var(--green);
}

.status.split {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.bad {
  background: var(--red-soft);
  color: var(--red);
}

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

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

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

th:last-child,
td:last-child {
  border-right: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  background: #fff4bf;
  color: #30383e;
  font-size: 12px;
  font-weight: 800;
}

.cell-input {
  min-width: 76px;
  min-height: 30px;
  padding: 5px 7px;
  border-color: #c7d0d5;
}

.delete-row-btn {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid #f0b2a8;
  border-radius: 6px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.action-cell {
  text-align: center;
  width: 48px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.summary-card,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.summary-card {
  min-height: 32px;
  padding: 5px 10px;
  display: grid;
  align-content: center;
  gap: 0;
}

.summary-card label {
  font-size: 11px;
}

.summary-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.08;
}

.summary-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 9px;
}

.metric {
  min-height: 72px;
  padding: 12px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  line-height: 1.2;
}

.metric-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.result-layout {
  display: grid;
  gap: 16px;
}

.two-load-layout {
  display: grid;
  gap: 16px;
}

.prototype-note {
  padding: 10px 12px;
  border: 1px solid #e8c481;
  border-radius: 8px;
  background: #fff8e8;
  color: #5f4300;
  font-weight: 800;
}

.result-alert {
  padding: 10px 12px;
  border: 1px solid #efb0aa;
  border-radius: 8px;
  background: var(--red-soft);
  color: #7f261d;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.result-alert strong {
  display: block;
  margin-bottom: 2px;
  color: var(--red);
  font-size: 13px;
}

.factory-picker {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.factory-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.picker-hint {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

.two-load-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.15fr) minmax(420px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.role-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.role-card {
  min-height: 260px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  display: grid;
  gap: 8px;
}

.role-card strong {
  display: block;
  font-size: 16px;
}

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

.assignment-list {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.assignment-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.assignment-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 82px minmax(150px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.assignment-name {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.assignment-name strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-name span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.assignment-row select {
  min-height: 30px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 12px;
}

.priority-flow {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.priority-step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.priority-no {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-size: 11px;
  font-weight: 900;
}

.priority-step strong {
  display: block;
  margin-bottom: 2px;
}

.priority-step .small-note {
  font-size: 10px;
}

.remark-preview table {
  min-width: 1080px;
  font-size: 11px;
}

.remark-preview th,
.remark-preview td {
  padding: 5px 6px;
}

.remark-preview .status {
  min-height: 20px;
  padding: 0 6px;
  font-size: 11px;
}

.result-preview-grid {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) 420px;
  gap: 16px;
  align-items: start;
}

.subsection {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.subsection-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-table table {
  min-width: 1420px;
}

.base-copy table {
  min-width: 920px;
}

.compact-table table {
  font-size: 12px;
}

.compact-table th,
.compact-table td {
  padding: 6px 7px;
}

.small-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: normal;
  line-height: 1.3;
}

.loading-factory-note {
  color: var(--red);
  font-weight: 900;
}

.container-map {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fcfdfd;
}

.map-top {
  min-height: 34px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-body {
  position: relative;
  height: 270px;
  padding: 16px;
}

.box-outline {
  position: relative;
  height: 100%;
  border: 3px solid #31383e;
  border-radius: 4px;
  background: linear-gradient(90deg, #fff8f3 0 50%, #f8fbff 50% 100%);
}

.mid-y {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  transform: translateX(-1px);
  background: repeating-linear-gradient(0deg, #7b868d 0 8px, transparent 8px 14px);
}

.mid-x {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 2px;
  transform: translateY(-1px);
  background: repeating-linear-gradient(90deg, #7b868d 0 8px, transparent 8px 14px);
}

.door {
  position: absolute;
  right: -10px;
  top: 32%;
  width: 10px;
  height: 36%;
  border: 2px solid #31383e;
  border-left: 0;
  border-radius: 0 4px 4px 0;
  background: white;
}

.lane {
  position: absolute;
  left: 4%;
  right: 4%;
  height: 36px;
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.04);
}

.lane-1 {
  top: 24%;
}

.lane-2 {
  top: 53%;
}

.carton {
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  font-weight: 800;
  min-width: 0;
  line-height: 1.15;
  text-align: center;
  padding: 2px 4px;
}

.carton small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 700;
  opacity: 0.92;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-stack {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carton.empty {
  visibility: hidden;
}

.a {
  background: var(--orange);
}

.b {
  background: var(--blue);
}

.c {
  background: var(--green);
}

.map-arrow {
  position: absolute;
  left: 11%;
  right: 11%;
  bottom: 18px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-arrow::before {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--orange);
  margin: 0 10px;
}

.map-arrow::after {
  content: "";
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid var(--orange);
}

.map-label {
  position: absolute;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.label-inside {
  left: 22px;
  top: 14px;
}

.label-door {
  right: 22px;
  top: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  justify-self: end;
  width: min(420px, 100%);
}

.center-summary {
  display: none;
}

.center-summary-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.center-summary-card strong {
  display: block;
  margin-bottom: 7px;
  color: var(--orange-dark);
  font-size: 15px;
}

.center-summary-card span {
  display: inline-flex;
  margin-right: 16px;
  color: var(--text);
  font-weight: 800;
}

.summary-tr td {
  background: #fff7d6;
  color: var(--text);
  font-weight: 800;
}

.summary-tr strong {
  color: var(--orange-dark);
  margin-right: 12px;
}

.metric.pass {
  background: var(--green-soft);
  border-color: #a8d8bd;
}

.metric.warn {
  background: var(--amber-soft);
  border-color: #e3c37a;
}

.metric.fail {
  background: var(--red-soft);
  border-color: #efb0aa;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  color: #2b3338;
  min-width: 0;
}

.check-dot {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.check-dot.warn {
  background: var(--amber);
}

.dialog-preview {
  border: 1px solid #e2c5b3;
  border-radius: 8px;
  background: #fff8f3;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.dialog-preview-title {
  font-weight: 800;
  color: var(--orange-dark);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 27, 31, 0.42);
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(23, 27, 31, 0.22);
  display: grid;
  gap: 12px;
}

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

textarea {
  width: 100%;
  min-height: 260px;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  resize: vertical;
  font: 13px/1.5 Consolas, "Microsoft YaHei", monospace;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #171b1f;
  color: white;
  box-shadow: 0 12px 30px rgba(23, 27, 31, 0.24);
  font-weight: 700;
}

.page-signature {
  position: fixed;
  right: 14px;
  bottom: 6px;
  z-index: 20;
  color: rgba(105, 118, 127, 0.78);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 1180px) {
  .parameter-grid,
  .settings-grid,
  .result-layout,
  .result-preview-grid,
  .two-load-grid,
  .role-card-grid,
  .factory-picker-grid {
    grid-template-columns: 1fr;
  }

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

  .center-summary,
  .check-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    width: calc(100vw - 20px);
  }

  .topbar {
    padding-top: 10px;
  }

  .topbar-card {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .brand {
    align-items: flex-start;
  }

  .logo {
    height: 42px;
  }

  .page {
    margin-top: 10px;
  }

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

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