:root {
  --ink: #1b2428;
  --muted: #68757b;
  --line: #d8e0e2;
  --paper: #f5f7f6;
  --surface: #ffffff;
  --field: #fff8dc;
  --remark: #edf5f8;
  --fixed: #e8f3ee;
  --blue: #0b6f91;
  --green: #2f6b4f;
  --amber: #9a6a12;
  --danger: #a23b2a;
  --shadow: 0 18px 48px rgba(25, 38, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f2f5f4;
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.app-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
}

.headline,
.boundary,
.flow-step,
.upload-band,
.batch-panel,
.batch-results,
.batch-detail,
.history-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.headline {
  flex: 1;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}

.headline p {
  max-width: 780px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.boundary {
  width: min(360px, 34%);
  padding: 18px;
  display: grid;
  gap: 8px;
}

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

.boundary strong {
  font-size: 18px;
}

.boundary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
}

.status-pill {
  border: 1px solid var(--line);
  background: #f7faf9;
  padding: 8px 12px;
  color: var(--muted);
  min-width: 112px;
  text-align: center;
  border-radius: 999px;
  justify-self: start;
}

.status-pill.ok {
  border-color: #b8d7b6;
  color: var(--green);
  background: #f0faec;
}

.status-pill.bad {
  border-color: #efc0b8;
  color: var(--danger);
  background: #fff0ed;
}

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

.flow-step {
  padding: 14px;
  display: grid;
  gap: 5px;
}

.flow-step span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.flow-step strong {
  font-size: 17px;
}

.flow-step small {
  color: var(--muted);
  font-size: 13px;
}

.workspace-tabs {
  margin-top: 18px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.workspace-tab {
  border-radius: 8px 8px 0 0;
  border-color: var(--line);
  background: #edf2f2;
  color: var(--ink);
}

.workspace-tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.workspace-panel {
  display: none;
}

.workspace-panel.active {
  display: block;
}

.upload-band {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 18px;
}

.upload-copy p {
  margin: 6px 0 0;
  color: var(--muted);
}

.single-entry-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.single-file-card,
.single-status-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.single-upload-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.native-file-control {
  min-height: 50px;
  display: flex;
  align-items: center;
  border: 1px dashed #b7c5c8;
  border-radius: 8px;
  padding: 10px;
  background: #f8fbfb;
}

.native-file-control input {
  width: 100%;
}

.selected-file-meta {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8faf9;
  color: var(--muted);
}

.selected-file-meta span {
  word-break: break-word;
}

.clear-file-button {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

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

.status-list {
  margin: 0;
  padding: 0 16px 16px;
}

.status-list div {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.status-list div:last-child {
  border-bottom: 0;
}

.status-list dt {
  color: var(--muted);
}

.status-list dd {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}

.upload-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.file-drop {
  display: flex;
  align-items: center;
  min-width: 320px;
  height: 42px;
  border: 1px dashed #9cad9f;
  background: #f8fbf7;
  padding: 0 12px;
  cursor: pointer;
  color: var(--muted);
  border-radius: 6px;
}

.file-drop input {
  display: none;
}

button {
  height: 42px;
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 700;
  border-radius: 6px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.secondary-button,
.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

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

.summary-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 78px;
}

.summary-grid.compact {
  margin-top: 0;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.summary-grid strong {
  font-size: 18px;
  word-break: break-word;
}

.notice {
  margin-top: 14px;
  background: #fff8e6;
  border: 1px solid #efd78c;
  padding: 14px 16px;
  border-radius: 8px;
}

.notice ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.workspace {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}

.tabs {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.tab {
  width: 100%;
  height: auto;
  min-height: 38px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 9px 10px;
  font-weight: 600;
}

.tab.active {
  border-color: #b7d4c4;
  background: #edf7f0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 360px;
  overflow: hidden;
}

.panel-head {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.static-head {
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.section-remark {
  margin: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  padding: 12px;
}

.section-remark strong {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
}

.section-remark p {
  margin: 0;
  min-height: 24px;
  color: var(--ink);
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
  text-align: left;
  word-break: break-word;
}

th {
  background: #edf2ef;
  font-size: 13px;
}

td.value {
  background: var(--field);
}

td.note {
  background: var(--remark);
}

.size-net {
  background: #f0f7ec;
}

.size-finished {
  background: #fff6d8;
}

.size-row.size-group-start td {
  border-top: 3px solid #aebfb7;
}

.size-row.size-group-start:first-child td {
  border-top: 1px solid var(--line);
}

.empty {
  padding: 30px;
  color: var(--muted);
}

.submit-preview {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.preview-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.preview-body {
  padding: 16px;
}

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

.preview-meta article {
  border: 1px solid var(--line);
  padding: 12px;
  background: #fbfdfb;
}

.preview-meta span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.preview-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.preview-lists div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.preview-lists h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.preview-lists ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.review-card,
.feedback-card {
  margin-top: 12px;
  border: 1px solid #efd78c;
  background: #fffaf0;
  border-radius: 8px;
  overflow: hidden;
}

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

.review-head h3,
.feedback-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.review-head p,
.feedback-card p {
  margin: 0;
  color: var(--muted);
}

#reviewList {
  margin: 0;
  padding: 12px 18px 12px 34px;
}

#reviewList li {
  margin: 6px 0;
}

#reviewList strong,
#reviewList span {
  display: block;
}

#reviewList span {
  color: var(--muted);
}

.feedback-card {
  padding: 12px;
  border-color: #c8d9e3;
  background: #f3f8fb;
}

.feedback-card pre {
  margin: 10px 0 0;
  padding: 10px;
  max-height: 180px;
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  white-space: pre-wrap;
}

.alignment-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.alignment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #f7faf7;
}

.alignment-head h3 {
  margin: 0;
  font-size: 15px;
}

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

.alignment-card table {
  font-size: 13px;
}

.alignment-card td:nth-child(2) {
  width: 88px;
  font-weight: 700;
}

.alignment-filled td:nth-child(2) {
  color: var(--green);
}

.alignment-empty td:nth-child(2) {
  color: #8a6d1f;
}

.alignment-missing td:nth-child(2) {
  color: var(--danger);
}

.tech-alignments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.tech-alignments article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfb;
}

.tech-alignments h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.tech-alignments p {
  margin: 0 0 8px;
  color: var(--muted);
}

.tech-alignments ul {
  margin: 0;
  padding-left: 18px;
  color: var(--danger);
  max-height: 190px;
  overflow: auto;
}

.factory-submit-result {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fbfdfb;
  border-radius: 8px;
  overflow: hidden;
}

.factory-submit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.factory-submit-head h3 {
  margin: 0;
  font-size: 15px;
}

.factory-submit-head span {
  font-size: 13px;
  font-weight: 700;
}

.submit-ok {
  color: var(--green);
}

.submit-bad {
  color: var(--danger);
}

.factory-submit-result pre {
  margin: 0;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 29, 26, 0.44);
}

.order-modal {
  width: min(560px, 100%);
  position: relative;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(15, 29, 26, 0.2);
  padding: 22px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.order-modal h2 {
  padding-right: 42px;
}

.order-modal p {
  margin: 8px 0 14px;
  color: var(--muted);
  white-space: pre-wrap;
}

.modal-details {
  display: grid;
  grid-template-columns: 136px 1fr;
  gap: 8px 12px;
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.modal-details dt {
  color: var(--muted);
}

.modal-details dd {
  margin: 0;
  font-weight: 700;
  word-break: break-word;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.review-modal {
  width: min(640px, 100%);
}

.review-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.review-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fbfdfb;
}

.review-choice input {
  width: 18px;
  height: 18px;
}

.review-options select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: #fff;
}

.custom-review-input {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
}

.custom-review-input textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  padding: 10px;
  font: inherit;
  color: var(--ink);
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

#jsonPreview,
#batchJsonPreview {
  margin: 12px 0 0;
  padding: 14px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #ced9d4;
  background: #0f1d1a;
  color: #e7f4ed;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.json-details {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfb;
}

.json-details summary {
  cursor: pointer;
  font-weight: 700;
}

.batch-panel,
.history-panel {
  margin-top: 22px;
  overflow: hidden;
}

.batch-json-panel {
  margin-top: 16px;
}

.batch-json-panel .json-details {
  margin-top: 0;
}

.batch-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.batch-choice {
  display: grid;
  gap: 8px;
  min-height: 104px;
  border: 1px dashed #9cad9f;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  background: #f8fbfb;
}

.batch-choice span {
  font-weight: 700;
}

.batch-choice strong {
  color: var(--muted);
  font-size: 14px;
  word-break: break-word;
}

.batch-choice input {
  color: var(--muted);
}

.batch-actions {
  padding: 0 16px 16px;
  justify-content: flex-start;
}

.batch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.batch-results,
.batch-detail {
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
}

.history-table {
  min-width: 1180px;
}

.history-table th:not(.history-detail-col),
.history-table td:not(.history-detail-cell) {
  white-space: nowrap;
  word-break: keep-all;
}

.history-table .history-detail-col,
.history-table .history-detail-cell {
  min-width: 420px;
  white-space: normal;
  word-break: break-word;
}

.batch-row {
  cursor: pointer;
}

.batch-row.selected td {
  background: #e9f4f6;
}

.batch-detail-body {
  padding: 14px;
}

.notice-inline {
  margin: 12px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.notice-inline.ok {
  color: var(--green);
  border-color: #b8d7b6;
  background: #f0faec;
}

.notice-inline.warn {
  color: var(--amber);
  border-color: #efd78c;
  background: #fff9e8;
}

.notice-inline.bad {
  color: var(--danger);
  border-color: #efc0b8;
  background: #fff0ed;
}

.status-ready,
.status-submitted,
.status-success {
  color: var(--green);
  font-weight: 700;
}

.status-blocked,
.status-skipped {
  color: var(--amber);
  font-weight: 700;
}

.status-error,
.status-factoryRejected,
.status-failed {
  color: var(--danger);
  font-weight: 700;
}

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 10px;
  padding: 16px;
}

.history-toolbar input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px;
}

@media (max-width: 900px) {
  .app-header,
  .upload-band,
  .single-entry-grid,
  .workspace,
  .batch-tools,
  .batch-layout,
  .history-toolbar {
    grid-template-columns: 1fr;
  }

  .boundary {
    width: auto;
  }

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

  .upload-form,
  .app-header,
  .preview-head {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-actions {
    justify-content: stretch;
  }

  .preview-actions button {
    flex: 1 1 auto;
  }

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

  .preview-meta,
  .preview-lists,
  .tech-alignments {
    grid-template-columns: 1fr;
  }

  .file-drop {
    min-width: 0;
  }

  .modal-details {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 24px, 1440px);
  }

  h1 {
    font-size: 26px;
  }

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

  .workspace-tabs {
    overflow-x: auto;
  }

  .workspace-tab {
    flex: 0 0 auto;
  }
}
