:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: #f5f7f8;
  color: #182326;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.shell {
  min-height: 100vh;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: #ffffff;
  border-bottom: 1px solid #dfe7ea;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

p,
span,
select,
button {
  font-size: 14px;
}

.toolbar p {
  margin-top: 6px;
  color: #607076;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-tabs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.tab {
  height: 32px;
  background: #ffffff;
  border-color: #bfd0d5;
  color: #365057;
  font-weight: 700;
}

.tab.active {
  background: #1f6f78;
  border-color: #1f6f78;
  color: #ffffff;
}

.hidden {
  display: none !important;
}

select,
button,
.file-button span {
  height: 38px;
  border: 1px solid #bfd0d5;
  border-radius: 6px;
  background: #ffffff;
  color: #182326;
}

select {
  min-width: 220px;
  max-width: 360px;
  padding: 0 10px;
}

button,
.file-button span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  cursor: pointer;
}

button {
  background: #1f6f78;
  border-color: #1f6f78;
  color: #ffffff;
  font-weight: 700;
}

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

.file-button input {
  display: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: #dfe7ea;
  border-bottom: 1px solid #dfe7ea;
}

.metrics div {
  padding: 18px 32px;
  background: #ffffff;
}

.metrics span {
  display: block;
  color: #607076;
  margin-bottom: 6px;
}

.metrics strong {
  font-size: 24px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(340px, 0.8fr);
  gap: 20px;
  padding: 20px 32px 32px;
}

.file-selection {
  margin: 20px 32px 0;
}

.file-selection .panel-head {
  align-items: flex-start;
}

.file-selection .panel-head div span {
  display: block;
  margin-top: 4px;
  white-space: normal;
}

.file-selection-list {
  display: grid;
  gap: 1px;
  background: #edf2f3;
}

.file-selection-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #ffffff;
  cursor: pointer;
}

.file-selection-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.file-selection-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #182326;
}

.file-selection-status {
  color: #1f6f78;
  font-weight: 700;
}

.file-selection-row.excluded .file-selection-name {
  color: #8a999e;
  text-decoration: line-through;
}

.file-selection-row.excluded .file-selection-status {
  color: #8a4a3b;
}

.bundle-panel {
  margin: 20px 32px 32px;
}

.bundle-actions {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  justify-content: flex-end;
}

.bundle-actions select {
  min-width: 120px;
}

.bundle-action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.bundle-excel-actions {
  padding-top: 8px;
  border-top: 1px solid #dfe7ea;
}

.hint {
  padding: 12px 16px 0;
  color: #607076;
}

.bundle-messages {
  padding: 8px 16px 16px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 168px;
}

.secondary-button {
  background: #ffffff;
  border-color: #bfd0d5;
  color: #365057;
}

.danger-button {
  background: #8a4a3b;
  border-color: #8a4a3b;
}

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

.bundle-table-wrap table {
  min-width: 980px;
  width: 100%;
  table-layout: fixed;
}

.bundle-barcode-col {
  width: 18%;
}

.bundle-name-col {
  width: 55%;
}

.bundle-count-col {
  width: 12%;
}

.bundle-actions-col {
  width: 15%;
}

.bundle-table-wrap th,
.bundle-table-wrap td {
  vertical-align: middle;
}

.bundle-table-wrap th {
  height: 38px;
  text-align: center;
}

.bundle-table-wrap td {
  height: 58px;
}

.bundle-table-wrap .barcode-cell {
  font-family: "Consolas", "Microsoft YaHei", monospace;
  white-space: nowrap;
  text-align: center;
}

.bundle-table-wrap .bundle-name-cell {
  line-height: 1.6;
  cursor: pointer;
  outline: none;
  text-align: center;
}

.bundle-table-wrap .bundle-name-cell:hover,
.bundle-table-wrap .bundle-name-cell:focus-visible {
  color: #1f6f78;
  background: #f7fbfb;
}

.bundle-table-wrap .bundle-count-cell {
  color: #607076;
  white-space: nowrap;
  text-align: center;
}

.bundle-table-wrap .actions-cell {
  text-align: center;
}

.bundle-master-row.expanded td {
  background: #fbfdfd;
  border-bottom-color: #d4e2e5;
}

.bundle-detail-row.hidden {
  display: none;
}

.bundle-detail-row > td {
  height: auto;
  padding: 0 16px 14px max(18%, 180px);
  background: #fbfdfd;
}

.component-summary-list {
  display: grid;
  gap: 0;
  width: min(760px, 100%);
  border: 1px solid #dfe7ea;
  border-radius: 6px;
  overflow: hidden;
  background: #ffffff;
}

.component-summary-head,
.component-summary-item {
  display: grid;
  grid-template-columns: 170px minmax(260px, 1fr) 90px;
  column-gap: 14px;
  align-items: center;
}

.component-summary-head {
  padding: 8px 10px;
  background: #f1f6f6;
  color: #607076;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.component-summary-item {
  min-height: 42px;
  padding: 9px 10px;
  border-top: 1px solid #e8eff1;
}

.component-code {
  color: #365057;
  font-family: "Consolas", "Microsoft YaHei", monospace;
}

.component-name {
  white-space: normal;
  overflow-wrap: anywhere;
}

.component-quantity {
  color: #607076;
  text-align: center;
  white-space: nowrap;
}

.empty-cell {
  color: #607076;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(24 35 38 / 0.45);
}

.modal-card {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #dfe7ea;
  box-shadow: 0 18px 48px rgb(24 35 38 / 0.18);
}

.modal-head,
.modal-foot,
.component-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e7eef0;
}

.modal-head span {
  color: #607076;
  display: block;
  margin-top: 4px;
}

.modal-foot {
  border-top: 1px solid #e7eef0;
  border-bottom: 0;
  justify-content: flex-end;
}

.bundle-modal-main {
  display: grid;
  grid-template-columns: 170px minmax(260px, 1fr);
  gap: 12px;
  padding: 14px 16px;
}

.bundle-modal-main label,
.component-edit-row {
  min-width: 0;
}

.bundle-modal-main label {
  display: grid;
  gap: 5px;
}

.bundle-modal-main label span {
  color: #607076;
  font-size: 12px;
}

.bundle-modal-main input,
.component-edit-row input {
  height: 34px;
  border: 1px solid #bfd0d5;
  border-radius: 6px;
  padding: 0 10px;
  min-width: 0;
}

.component-list-head {
  padding-bottom: 10px;
}

.component-list-head h3 {
  margin: 0;
  font-size: 14px;
}

.component-edit-list {
  display: grid;
  gap: 8px;
  padding: 12px 16px 16px;
}

.component-edit-row {
  display: grid;
  grid-template-columns: 170px minmax(260px, 1fr) 110px 112px;
  gap: 10px;
  align-items: center;
}

.panel {
  background: #ffffff;
  border: 1px solid #dfe7ea;
  border-radius: 8px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e7eef0;
}

.panel-head span {
  color: #607076;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 235px);
}

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

th,
td {
  border-bottom: 1px solid #edf2f3;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f1f6f6;
  z-index: 1;
  color: #365057;
  font-weight: 700;
}

td:nth-child(4),
td:nth-child(5),
td:nth-child(6),
td:nth-child(10) {
  text-align: right;
}

.bundle-table-wrap td:nth-child(4),
.bundle-table-wrap td:nth-child(5),
.bundle-table-wrap td:nth-child(6),
.bundle-table-wrap td:nth-child(10) {
  text-align: left;
}

.issues {
  padding: 8px 16px 16px;
  max-height: calc(100vh - 235px);
  overflow: auto;
}

.issue {
  border-left: 4px solid #d08c28;
  padding: 10px 12px;
  background: #fff8ec;
  margin-top: 10px;
  border-radius: 4px;
}

.issue.error {
  border-left-color: #bf3a30;
  background: #fff0ee;
}

.issue strong {
  display: block;
  margin-bottom: 4px;
}

.empty {
  color: #607076;
  padding: 18px 0;
}

@media (max-width: 920px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .actions > * {
    flex: 1 1 160px;
  }

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

  .workspace {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .bundle-panel {
    margin: 0 16px 16px;
  }

  .bundle-modal-main,
  .component-edit-row {
    grid-template-columns: 1fr;
  }

  .component-summary-list {
    min-width: 0;
    max-width: none;
  }

  .component-summary-head,
  .component-summary-item {
    grid-template-columns: 1fr;
    row-gap: 4px;
  }

  .component-quantity {
    text-align: left;
  }
}
