:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --ink: #182026;
  --muted: #6f7d86;
  --line: #d9e0e4;
  --line-strong: #c4cdd3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #dff5f1;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --amber: #b7791f;
  --amber-soft: #fff4d9;
  --red: #c2413a;
  --red-soft: #ffe7e4;
  --green: #1f8a4c;
  --green-soft: #e4f6e8;
  --shadow: 0 16px 38px rgba(27, 39, 48, 0.08);
  --radius: 8px;
  --font: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #35414a;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #52616b;
}

.nav-item:hover {
  background: var(--panel-soft);
  border-color: var(--line);
}

.nav-item.is-active {
  background: var(--accent-soft);
  border-color: #a5ddd5;
  color: var(--accent-dark);
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.sidebar-note span,
.sidebar-note strong {
  display: block;
}

.sidebar-note span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-note strong {
  margin-top: 4px;
  color: var(--accent-dark);
}

.sidebar-logout {
  width: 100%;
  margin-top: 10px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(245, 247, 248, 0.96);
}

.login-screen[hidden] {
  display: none;
}

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

.login-card h2 {
  margin: 0;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.main-area {
  min-width: 0;
  padding: 22px 24px 40px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.top-actions,
.toolbar,
.row-actions,
.modal-foot,
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.button,
.icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.button {
  min-height: 36px;
  padding: 8px 12px;
  font-weight: 700;
}

.button:hover,
.icon-button:hover {
  border-color: #96a4ad;
  background: #f7fafb;
}

.button:active,
.icon-button:active {
  transform: translateY(1px);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

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

.button.ghost {
  background: #ffffff;
}

.button.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.view {
  display: grid;
  gap: 14px;
}

.section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section.flat {
  box-shadow: none;
}

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

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

.section-body {
  padding: 14px 16px 16px;
}

.factory-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.52fr) minmax(300px, 0.48fr);
  gap: 14px;
  padding: 14px 16px 16px;
}

.factory-workspace > .table-wrap {
  min-width: 0;
}

.factory-workspace > .table-wrap table {
  min-width: 980px;
  table-layout: fixed;
}

.factory-workspace > .table-wrap th:nth-child(1),
.factory-workspace > .table-wrap td:nth-child(1) {
  width: 16%;
}

.factory-workspace > .table-wrap th:nth-child(2),
.factory-workspace > .table-wrap td:nth-child(2) {
  width: 18%;
}

.factory-workspace > .table-wrap th:nth-child(3),
.factory-workspace > .table-wrap td:nth-child(3) {
  width: 11%;
}

.factory-workspace > .table-wrap th:nth-child(4),
.factory-workspace > .table-wrap td:nth-child(4) {
  width: 12%;
}

.factory-workspace > .table-wrap th:nth-child(5),
.factory-workspace > .table-wrap td:nth-child(5) {
  width: 15%;
}

.factory-workspace > .table-wrap th:nth-child(6),
.factory-workspace > .table-wrap td:nth-child(6) {
  width: 15%;
}

.factory-workspace > .table-wrap th:nth-child(7),
.factory-workspace > .table-wrap td:nth-child(7) {
  width: 13%;
}

.factory-workspace > .table-wrap td {
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.factory-workspace > .table-wrap td:nth-child(2) {
  white-space: normal;
  line-height: 1.35;
}

.factory-workspace > .table-wrap td:nth-child(3),
.factory-workspace > .table-wrap td:nth-child(4),
.factory-workspace > .table-wrap td:nth-child(5),
.factory-workspace > .table-wrap td:nth-child(6),
.factory-workspace > .table-wrap td:nth-child(7) {
  white-space: nowrap;
}

.factory-workspace > .table-wrap tbody tr[data-factory-row] {
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.factory-workspace > .table-wrap tbody tr[data-factory-row]:hover {
  background: #f5fbfa;
  box-shadow: inset 3px 0 0 var(--accent);
}

.factory-workspace > .table-wrap tbody tr[data-factory-row].is-selected td {
  background: var(--accent-soft);
}

.factory-workspace > .table-wrap td:nth-child(7) .row-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.factory-side-detail {
  min-width: 0;
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.factory-side-detail .detail-panel {
  gap: 10px;
}

.factory-side-detail .detail-block {
  padding: 11px;
}

.factory-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 14px;
  align-items: start;
}

.factory-layout > .section:first-child {
  min-width: 0;
}

.factory-layout > .section:last-child {
  position: sticky;
  top: 14px;
  min-width: 0;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.factory-layout > .section:first-child .section-head,
.factory-layout > .section:last-child > .section-head {
  align-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
}

.factory-layout > .section:first-child .table-wrap {
  padding: 0 10px 10px;
}

.factory-layout > .section:first-child table {
  min-width: 940px;
  table-layout: fixed;
}

.factory-layout > .section:first-child th:nth-child(1),
.factory-layout > .section:first-child td:nth-child(1) {
  width: 14%;
}

.factory-layout > .section:first-child th:nth-child(2),
.factory-layout > .section:first-child td:nth-child(2) {
  width: 17%;
}

.factory-layout > .section:first-child th:nth-child(3),
.factory-layout > .section:first-child td:nth-child(3) {
  width: 9%;
}

.factory-layout > .section:first-child th:nth-child(4),
.factory-layout > .section:first-child td:nth-child(4) {
  width: 10%;
}

.factory-layout > .section:first-child th:nth-child(5),
.factory-layout > .section:first-child td:nth-child(5) {
  width: 11%;
}

.factory-layout > .section:first-child th:nth-child(6),
.factory-layout > .section:first-child td:nth-child(6) {
  width: 13%;
}

.factory-layout > .section:first-child th:nth-child(7),
.factory-layout > .section:first-child td:nth-child(7) {
  width: 13%;
}

.factory-layout > .section:first-child th:nth-child(8),
.factory-layout > .section:first-child td:nth-child(8) {
  width: 13%;
}

.factory-layout > .section:first-child th {
  padding-top: 12px;
  padding-bottom: 12px;
  background: #f8fafb;
}

.factory-layout > .section:first-child td {
  padding-top: 12px;
  padding-bottom: 12px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.factory-layout > .section:first-child td:nth-child(2) {
  white-space: normal;
  line-height: 1.35;
}

.factory-layout > .section:first-child td:nth-child(3),
.factory-layout > .section:first-child td:nth-child(4),
.factory-layout > .section:first-child td:nth-child(5),
.factory-layout > .section:first-child td:nth-child(6),
.factory-layout > .section:first-child td:nth-child(7),
.factory-layout > .section:first-child td:nth-child(8) {
  white-space: nowrap;
}

.factory-layout > .section:first-child tbody tr[data-factory-row] {
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.factory-layout > .section:first-child tbody tr[data-factory-row]:hover {
  background: #f5fbfa;
  box-shadow: inset 3px 0 0 var(--accent);
}

.factory-layout > .section:first-child tbody tr[data-factory-row].is-selected td {
  background: var(--accent-soft);
}

.factory-layout > .section:first-child td:nth-child(8) .row-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.factory-layout > .section:last-child .section-body {
  padding: 12px;
}

.factory-layout .detail-block {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(31, 48, 57, 0.04);
}

tr.is-selected td {
  background: var(--accent-soft);
}

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

.kpi {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
}

.orders-layout {
  align-items: start;
}

.orders-layout > .section:first-child {
  min-width: 0;
}

.orders-layout > .section:last-child {
  position: sticky;
  top: 14px;
  min-width: 0;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
}

.orders-layout > .section:first-child .section-head,
.orders-layout > .section:last-child > .section-head {
  align-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
}

.orders-layout > .section:first-child .table-wrap {
  padding: 0 10px 10px;
}

.orders-layout > .section:first-child table {
  min-width: 1040px;
  table-layout: fixed;
}

.orders-layout > .section:first-child th:nth-child(1),
.orders-layout > .section:first-child td:nth-child(1) {
  width: 22%;
}

.orders-layout > .section:first-child th:nth-child(2),
.orders-layout > .section:first-child td:nth-child(2) {
  width: 10%;
}

.orders-layout > .section:first-child th:nth-child(3),
.orders-layout > .section:first-child td:nth-child(3) {
  width: 9%;
}

.orders-layout > .section:first-child th:nth-child(4),
.orders-layout > .section:first-child td:nth-child(4) {
  width: 7%;
}

.orders-layout > .section:first-child th:nth-child(5),
.orders-layout > .section:first-child td:nth-child(5) {
  width: 12%;
}

.orders-layout > .section:first-child th:nth-child(6),
.orders-layout > .section:first-child th:nth-child(7),
.orders-layout > .section:first-child td:nth-child(6),
.orders-layout > .section:first-child td:nth-child(7) {
  width: 12%;
  white-space: nowrap;
  font-size: 13px;
}

.order-date-cell {
  display: grid;
  gap: 3px;
  white-space: nowrap;
}

.order-date-cell strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.order-date-cell small {
  color: var(--muted);
  font-size: 12px;
}

.orders-layout > .section:first-child th:nth-child(8),
.orders-layout > .section:first-child td:nth-child(8) {
  width: 7%;
}

.orders-layout > .section:first-child th:nth-child(9),
.orders-layout > .section:first-child td:nth-child(9) {
  width: 9%;
}

.orders-layout > .section:first-child th {
  padding-top: 12px;
  padding-bottom: 12px;
  background: #f8fafb;
}

.orders-layout > .section:first-child td {
  padding-top: 12px;
  padding-bottom: 12px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.orders-layout > .section:first-child td:nth-child(2),
.orders-layout > .section:first-child td:nth-child(3),
.orders-layout > .section:first-child td:nth-child(4),
.orders-layout > .section:first-child td:nth-child(5),
.orders-layout > .section:first-child td:nth-child(8),
.orders-layout > .section:first-child td:nth-child(9) {
  white-space: nowrap;
}

.orders-layout > .section:first-child td:nth-child(9) .row-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.orders-layout > .section:first-child .main-cell strong {
  white-space: nowrap;
}

.orders-layout > .section:first-child tbody tr {
  transition: background 120ms ease, box-shadow 120ms ease;
}

.orders-layout > .section:first-child tbody tr[data-order-row] {
  cursor: pointer;
}

.orders-layout > .section:first-child tbody tr[data-order-row].is-selected td {
  background: var(--accent-soft);
}

.orders-layout > .section:first-child tbody tr[data-order-row].is-selected .main-cell strong {
  color: var(--accent);
}

.orders-layout > .section:first-child tbody tr:hover {
  background: #f5fbfa;
  box-shadow: inset 3px 0 0 var(--accent);
}

.orders-layout > .section:last-child .section-body {
  padding: 12px;
}

.orders-layout .detail-block {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(31, 48, 57, 0.04);
}

.orders-layout .detail-block:first-child {
  border-top: 3px solid var(--accent);
}

.orders-layout .order-product-card {
  padding: 13px;
}

.orders-layout .order-product-card > span {
  color: #53616b;
  line-height: 1.45;
}

.orders-layout .order-product-card > span:first-of-type {
  color: var(--ink);
  font-weight: 700;
}

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

.filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(3, minmax(140px, 0.8fr));
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.filter-grid.single {
  grid-template-columns: minmax(220px, 1fr);
}

.field {
  display: grid;
  gap: 5px;
}

.field label {
  color: #53616b;
  font-size: 12px;
  font-weight: 700;
}

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

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

.field small {
  color: var(--muted);
  font-size: 12px;
}

.file-dropzone {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--muted);
  cursor: pointer;
}

.file-dropzone:hover,
.file-dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.file-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.file-drop-title,
.file-drop-name {
  pointer-events: none;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.file-drop-title {
  font-weight: 800;
}

.file-drop-name {
  color: var(--muted);
}

.file-dropzone.has-file .file-drop-name {
  color: var(--ink);
  font-weight: 700;
}

.order-product-form-table .file-dropzone {
  min-width: 96px;
  min-height: 48px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--accent);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

th {
  color: #53616b;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: #27333a;
}

tbody tr:hover {
  background: #fbfdfd;
}

.main-cell strong,
.main-cell span {
  display: block;
}

.main-cell span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fafb;
  color: #42515a;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.green {
  border-color: #b8dfc2;
  background: var(--green-soft);
  color: var(--green);
}

.pill.amber {
  border-color: #e4c16e;
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.red {
  border-color: #efb1aa;
  background: var(--red-soft);
  color: var(--red);
}

.pill.blue {
  border-color: #b5c9ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.progress {
  display: grid;
  gap: 6px;
  min-width: 112px;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #edf1f3;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.progress small {
  color: var(--muted);
}

.detail-panel {
  display: grid;
  gap: 12px;
}

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

.product-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.product-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  min-height: 42px;
}

.product-card h3 {
  margin-bottom: 3px;
}

.product-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.product-card > .definition-grid {
  min-height: 174px;
  align-content: start;
}

.detail-block {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.detail-block.is-warning {
  border-color: #efb1aa;
  background: #fff8f7;
}

.detail-block h3 {
  margin-bottom: 8px;
}

.detail-text {
  margin: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

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

.definition-grid.mini {
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  min-width: 220px;
}

.definition-grid div {
  display: grid;
  gap: 3px;
}

.definition-grid span {
  color: var(--muted);
  font-size: 12px;
}

.definition-grid strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.order-product-card {
  border-left-width: 4px;
}

.order-product-card.outsourced {
  border-color: #e2b24f;
  border-left-color: #c98916;
  background: #fffaf0;
  box-shadow: 0 4px 14px rgba(185, 121, 31, 0.12);
}

.order-product-card.stock {
  border-left-color: var(--green);
  background: #f8fdf9;
}

.order-product-card.unassigned {
  border-left-color: var(--line-strong);
}

.order-product-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: flex-start;
  gap: 10px;
}

.order-product-card-title {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.order-product-card-head strong {
  min-width: 0;
}

.order-product-card-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.order-product-version,
.order-product-quantity {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
}

.order-product-version {
  border: 1px solid #a9c2ff;
  background: var(--blue-soft);
  color: #1d4ed8;
}

.order-product-quantity {
  border: 1px solid #b8dfc2;
  background: var(--green-soft);
  color: #18733b;
}

.fulfillment-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.order-product-card-head > .fulfillment-badge {
  justify-self: start;
}

.fulfillment-badge.outsourced {
  border: 1px solid #e2b24f;
  background: #fff0c9;
  color: #9a6100;
}

.fulfillment-badge.stock {
  border: 1px solid #b8dfc2;
  background: var(--green-soft);
  color: var(--green);
}

.fulfillment-badge.unassigned {
  border: 1px solid var(--line-strong);
  background: #f7fafb;
  color: var(--muted);
}

.list-item strong {
  overflow-wrap: anywhere;
}

.list-item span {
  color: var(--muted);
  font-size: 12px;
}

.inspection-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.inspection-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.inspection-card:hover {
  border-color: var(--line-strong);
  background: #fbfdfd;
}

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

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

.inspection-title strong {
  font-size: 17px;
  line-height: 1.25;
}

.inspection-card-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.inspection-summary {
  display: grid;
  grid-template-columns: minmax(170px, 0.95fr) minmax(220px, 1.25fr) minmax(150px, 0.75fr) minmax(170px, 0.85fr);
  gap: 10px;
}

.inspection-summary div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.inspection-summary span,
.inspection-record-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inspection-summary strong,
.inspection-summary small {
  overflow-wrap: anywhere;
}

.inspection-summary strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.inspection-summary small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.inspection-record {
  display: grid;
  gap: 8px;
}

.inspection-filter-grid {
  grid-template-columns: minmax(260px, 1.5fr) repeat(3, minmax(160px, 1fr));
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.factory-filter-grid,
.shipment-filter-grid {
  grid-template-columns: minmax(260px, 1.5fr) repeat(2, minmax(160px, 0.8fr));
}

.inspection-results-meta {
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: 12px;
}

.inspection-group-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.inspection-group {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.inspection-group.has-issues {
  border-color: #efb1aa;
  background: #fffafa;
}

.inspection-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.inspection-group-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.inspection-group-kpis {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.inspection-group-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.inspection-batches > summary,
.inspection-detail-expander > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.inspection-batch-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.inspection-batch-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 0.8fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.inspection-batch-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.inspection-batch-main span,
.inspection-batch-metrics {
  color: var(--muted);
  font-size: 12px;
}

.inspection-detail-expander {
  grid-column: 1 / -1;
}

.inspection-record-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.inspection-table-wrap,
.inspection-form-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.inspection-detail-table,
.inspection-form-table table {
  min-width: 620px;
}

.inspection-detail-table th,
.inspection-detail-table td,
.inspection-form-table th,
.inspection-form-table td {
  padding: 8px;
  font-size: 12px;
}

.inspection-detail-table th:first-child,
.inspection-detail-table td:first-child,
.inspection-form-table th:first-child,
.inspection-form-table td:first-child {
  width: 48px;
  text-align: center;
}

.inspection-form-table input,
.inspection-form-table select {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.inspection-form-table .icon-button {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.order-products-field {
  display: grid;
  gap: 8px;
}

.inline-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.inline-section-head > div {
  display: grid;
  gap: 4px;
}

.order-product-form-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.order-product-form-table table {
  min-width: 1180px;
}

.order-product-form-table th,
.order-product-form-table td {
  padding: 7px;
  font-size: 12px;
  vertical-align: top;
}

.order-product-form-table input,
.order-product-form-table select {
  width: 100%;
  min-width: 94px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.order-product-form-table input[type="file"] {
  min-width: 150px;
  padding: 4px;
}

.order-product-form-table input[readonly],
.order-product-form-table select:disabled,
.order-product-form-table input:disabled {
  background: var(--panel-soft);
  color: var(--muted);
}

.order-product-existing {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 8px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.order-product-form-table .icon-button {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.factory-product-form-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.factory-product-form-table table {
  min-width: 760px;
}

.factory-product-form-table th,
.factory-product-form-table td {
  padding: 7px;
  font-size: 12px;
  vertical-align: top;
}

.factory-product-form-table input,
.factory-product-form-table select {
  width: 100%;
  min-width: 120px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.factory-product-form-table .row-index {
  width: 44px;
  text-align: center;
}

.factory-product-form-table [data-factory-product-label] {
  display: block;
  min-width: 230px;
  padding: 8px 4px;
  color: var(--muted);
}

.factory-product-form-table .icon-button {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.shipment-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.shipment-lanes {
  display: grid;
  gap: 16px;
  padding: 14px;
}

.shipment-lane {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.shipment-lane-overseas {
  border-top: 4px solid #2563eb;
}

.shipment-lane-domestic {
  border-top: 4px solid #1f9d55;
}

.shipment-lane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 0;
}

.shipment-lane-head h3 {
  margin-bottom: 3px;
}

.shipment-lane-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.shipment-export-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.shipment-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

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

.shipment-title strong {
  font-size: 17px;
  line-height: 1.25;
}

.shipment-card-head p,
.shipment-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.shipment-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.shipment-summary div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.shipment-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.shipment-summary strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.shipment-items-wrap,
.shipment-form-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.shipment-items-table,
.shipment-form-table table {
  min-width: 840px;
}

.shipment-items-table th,
.shipment-items-table td,
.shipment-form-table th,
.shipment-form-table td {
  padding: 8px;
  font-size: 12px;
}

.shipment-form-table input,
.shipment-form-table select {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.shipment-form-table .icon-button {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

.file-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.alternate-version-files {
  align-items: center;
}

.file-missing {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.file-link {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid #b5c9ff;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.file-link:hover {
  border-color: #7da0f7;
  background: #dfe9ff;
}

button.file-link,
a.file-link,
.link-button {
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: left;
  appearance: none;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font-weight: 700;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.pdf-inline {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  overflow: hidden;
}

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

.pdf-inline-head strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.pdf-inline iframe {
  width: 100%;
  height: 260px;
  border: 0;
  background: #ffffff;
}

.modal.pdf-modal {
  width: min(1100px, calc(100vw - 28px));
}

.pdf-frame-wrap {
  height: min(78vh, 820px);
  background: #eef2f4;
}

.pdf-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 144px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.timeline-row time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline-row strong {
  display: block;
  margin-bottom: 2px;
}

.timeline-row span {
  color: var(--muted);
  font-size: 12px;
}

.modal {
  width: min(980px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  display: grid;
  max-height: min(88vh, 900px);
  background: #ffffff;
}

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

.modal-body {
  overflow-y: auto;
  padding: 16px;
}

.modal-foot {
  justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.product-factory-quote-list {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.product-factory-quote-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 220px) 34px;
  gap: 8px;
  align-items: center;
}

.product-factory-quote-row input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.notice {
  padding: 12px;
  border: 1px solid #b5c9ff;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #1d4ed8;
}

.danger-zone {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #efb1aa;
  border-radius: 8px;
  background: var(--red-soft);
}

.nowrap {
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

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

  .factory-side-detail,
  .factory-layout > .section:last-child {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .factory-layout > .section:first-child .table-wrap {
    overflow: visible;
  }

  .factory-layout > .section:first-child table,
  .factory-layout > .section:first-child thead,
  .factory-layout > .section:first-child tbody,
  .factory-layout > .section:first-child tr,
  .factory-layout > .section:first-child td {
    display: block;
  }

  .factory-layout > .section:first-child table {
    min-width: 0;
    width: 100%;
  }

  .factory-layout > .section:first-child thead {
    display: none;
  }

  .factory-layout > .section:first-child tbody {
    display: grid;
    gap: 10px;
  }

  .factory-layout > .section:first-child tbody tr[data-factory-row] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  .factory-layout > .section:first-child tbody tr[data-factory-row].is-selected td {
    background: transparent;
  }

  .factory-layout > .section:first-child tbody tr[data-factory-row].is-selected {
    border-color: #9bd7d1;
    background: var(--accent-soft);
  }

  .factory-layout > .section:first-child td {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: auto !important;
    min-width: 0;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal !important;
  }

  .factory-layout > .section:first-child td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .factory-layout > .section:first-child td:nth-child(1),
  .factory-layout > .section:first-child td:nth-child(2),
  .factory-layout > .section:first-child td:nth-child(8) {
    grid-column: 1 / -1;
  }

  .factory-layout > .section:first-child td:nth-child(8) {
    border-bottom: 0;
  }

  .factory-layout > .section:first-child td:nth-child(8) .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .factory-layout > .section:first-child .main-cell strong,
  .factory-layout > .section:first-child .main-cell span {
    display: inline;
  }

  .factory-layout > .section:first-child .main-cell span {
    margin-left: 8px;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand,
  .sidebar-note {
    display: none;
  }

  .nav-list {
    grid-template-columns: repeat(8, minmax(0, 1fr));
    overflow-x: auto;
  }

  .nav-item {
    justify-content: center;
    min-width: 112px;
    text-align: center;
  }

  .grid-two,
  .grid-three,
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .shipment-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden;
  }

  .sidebar {
    gap: 10px;
    padding: 8px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    overflow: visible;
  }

  .nav-item {
    min-width: 0;
    min-height: 42px;
    padding: 6px 4px;
    gap: 4px;
    font-size: 12px;
  }

  .nav-item span {
    width: 16px;
    height: 16px;
  }

  .main-area {
    padding: 14px 12px 28px;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  h1 {
    font-size: 20px;
  }

  .kpi-grid,
  .grid-two,
  .grid-three,
  .factory-workspace,
  .factory-layout,
  .product-grid,
  .filter-grid,
  .form-grid,
  .definition-grid,
  .inspection-summary,
  .shipment-summary,
  .shipment-export-fields {
    grid-template-columns: 1fr;
  }

  .orders-layout > .section:last-child {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .orders-layout > .section:first-child .table-wrap {
    overflow: visible;
    padding: 0 12px 12px;
  }

  .orders-layout > .section:first-child table,
  .orders-layout > .section:first-child thead,
  .orders-layout > .section:first-child tbody,
  .orders-layout > .section:first-child tr,
  .orders-layout > .section:first-child td {
    display: block;
  }

  .orders-layout > .section:first-child table {
    min-width: 0;
    width: 100%;
  }

  .orders-layout > .section:first-child thead {
    display: none;
  }

  .orders-layout > .section:first-child tbody {
    display: grid;
    gap: 10px;
  }

  .orders-layout > .section:first-child tbody tr[data-order-row] {
    display: grid;
    gap: 0;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  .orders-layout > .section:first-child tbody tr[data-order-row].is-selected td {
    background: transparent;
  }

  .orders-layout > .section:first-child tbody tr[data-order-row].is-selected {
    border-color: #9bd7d1;
    background: var(--accent-soft);
  }

  .orders-layout > .section:first-child td {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    width: auto !important;
    min-width: 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal !important;
  }

  .orders-layout > .section:first-child td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .orders-layout > .section:first-child td:first-child,
  .orders-layout > .section:first-child td:last-child {
    grid-template-columns: 1fr;
  }

  .orders-layout > .section:first-child td:first-child::before,
  .orders-layout > .section:first-child td:last-child::before {
    display: none;
  }

  .orders-layout > .section:first-child td:last-child {
    border-bottom: 0;
  }

  .orders-layout > .section:first-child td:last-child .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .orders-layout > .section:first-child .main-cell strong {
    white-space: normal;
  }

  .factory-side-detail {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .factory-layout > .section:first-child tbody tr[data-factory-row] {
    grid-template-columns: 1fr;
  }

  .factory-layout > .section:first-child td {
    grid-column: 1 / -1;
  }

  .inspection-card-head,
  .inspection-group-head,
  .inspection-batch-row,
  .inspection-record-head,
  .shipment-lane-head,
  .shipment-card-head {
    display: grid;
  }

  .inspection-group-kpis {
    justify-content: flex-start;
  }

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

  .top-actions,
  .toolbar,
  .row-actions,
  .inline-actions {
    width: 100%;
  }

  .top-actions .button,
  .toolbar .button {
    flex: 1 1 140px;
  }
}
