* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #edf2f7;
  color: #101828;
}

.page {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.topbar,
.panel {
  background: #fff;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .05);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 16px;
}

p, h1, h2 { margin: 0; }

.topbar p,
.panelTitle p {
  color: #64748b;
  font-size: 12px;
  margin-bottom: 4px;
}

.topbar h1 { font-size: 25px; }
.panelTitle h2 { font-size: 20px; }

nav {
  display: flex;
  gap: 8px;
}

nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  color: #334155;
  text-decoration: none;
  font-weight: 700;
}

nav a.active,
nav a:hover {
  background: #eff6ff;
  color: #1f6fd1;
}

.orderWorkspace {
  width: min(100%, 760px);
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 16px;
}

.leftColumn {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panelTitle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  margin-bottom: 16px;
}

.panelTitle p,
.panelTitle h2 {
  grid-column: 1;
}

.quickPanelButton {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 112px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1f6fd1;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.quickPanelButton:hover { background: #dbeafe; }

.listWorkspace { width: 100%; }

.listToolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.backButton { min-width: 96px; }

.listToolbar .panelTitle { margin-bottom: 0; }
.listToolbarActions { display: flex; align-items: center; gap: 10px; flex: none; }
.listToolbarActions .listRefreshButton,
.listToolbarActions .listBackLink {
  width: auto;
  min-width: 0;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.listToolbarActions .listRefreshButton {
  border: 1px solid #d6e2f1;
  background: #f8fbff;
  color: #2865ad;
}
.listToolbarActions .listRefreshButton:hover { background: #edf5ff; }
.listToolbarActions .listBackLink {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  color: #50627b;
  text-decoration: none;
}
.listToolbarActions .listBackLink:hover { background: #f3f6fa; color: #1d4f89; }

.orderForm {
  display: grid;
  gap: 12px;
}

.primaryFields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.extraFields {
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #f8fafc;
}

.extraFieldsTitle {
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  padding: 0 12px;
  color: #475569;
  font-weight: 800;
}

.extraFieldsTitle small {
  width: 100%;
  padding-left: 26px;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.infoIcon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #eff6ff;
  color: #1f6fd1;
  font-size: 12px;
  font-weight: 900;
}

.extraFields fieldset {
  border: 0;
  border-top: 1px solid #d8e0ea;
  border-radius: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

@media (max-width: 720px) {
  .extraFields fieldset { grid-template-columns: 1fr; }
}

.extraFields button {
  height: 42px;
}

fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: #1f2937;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: #475569;
  font-weight: 700;
  font-size: 13px;
}

input,
select,
button {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(31, 111, 209, .2);
  border-color: #1f6fd1;
}

button {
  border-color: #1f6fd1;
  background: #1f6fd1;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  opacity: .75;
}

.emptyState {
  min-height: 116px;
  display: grid;
  place-items: center;
  padding: 28px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #64748b;
  text-align: center;
  line-height: 1.7;
  background: #f8fafc;
}

.resultCard {
  display: grid;
  gap: 10px;
}

.statusLine {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  background: #ecfdf3;
  color: #067647;
  font-weight: 900;
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #e5eaf1;
}

dt {
  color: #64748b;
}

dd {
  margin: 0;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.hint {
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  line-height: 1.6;
}

.error {
  padding: 14px;
  border-radius: 8px;
  background: #fff1f3;
  color: #b42318;
  font-weight: 800;
}

.hidden {
  display: none;
}

.salesPanel {
  margin-top: 0;
}

.salesOrderList {
  overflow-x: auto;
}

.salesOrderTable {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.salesOrderTable th,
.salesOrderTable td {
  padding: 11px 12px;
  border-bottom: 1px solid #e5eaf1;
  text-align: left;
  vertical-align: middle;
  font-size: 12px;
}

.salesOrderTable th {
  background: #f8fafc;
  color: #475569;
  font-weight: 900;
}

.salesOrderTable td {
  color: #111827;
}

.salesOrderTable tbody tr:hover,
.salesOrderTable tbody tr.selected {
  background: #eff6ff;
  outline: none;
}

.salesOrderTable tbody tr:last-child td {
  border-bottom: 0;
}

.salesOrderTable strong,
.salesOrderTable td {
  overflow-wrap: anywhere;
}

.salesOrderTable em {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 5px;
  background: #f4f6f9;
  font-style: normal;
  font-weight: 700;
}

.salesOrderTable em.ok { background: #eaf7f0; }
.salesOrderTable em.warn { background: #fff5e6; }
.salesOrderTable em.bad { background: #fef0ef; }
.salesOrderTable td:last-child { min-width: 108px; }
.salesOrderTable .rowActions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.salesOrderTable th:nth-child(8),
.salesOrderTable td:nth-child(8) { white-space: nowrap; }
.salesOrderTable .pushAction {
  width: auto;
  min-width: 0;
  min-height: 26px;
  padding: 2px 4px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #2367b7;
  font-size: 12px;
  font-weight: 700;
}
.salesOrderTable .pushAction:not(:disabled):hover {
  background: #e8f2ff;
  color: #15569e;
}
.salesOrderTable .pushAction:disabled {
  background: transparent;
  color: #9aa8ba;
  cursor: not-allowed;
  opacity: 1;
}
.salesOrderTable .actionUnavailable { color: #aab5c3; }
.pushFeedback {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #bdd8fb;
  border-radius: 6px;
  background: #f0f7ff;
  color: #15569e;
  font-size: 13px;
}
.pushFeedback.bad { border-color: #f4c5c2; background: #fff4f3; color: #b42318; }

.ok { color: #0f7a4f; }
.run { color: #1f6fd1; }
.warn { color: #9a6200; }
.bad { color: #b42318; }

.emptySmall {
  color: #64748b;
  font-size: 13px;
}

.modalOpen { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal.hidden { display: none; }

.modalBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
}

.modalCard {
  position: relative;
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-radius: 12px;
  background: #fbfcfe;
  box-shadow: 0 22px 64px rgba(30, 41, 59, .22);
}

.modalHeader {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #e8edf3;
  background: #fbfcfe;
}

.modalHeader p { margin-bottom: 3px; color: #7a8ba3; font-size: 11px; }
.modalHeader h2 { color: #25324a; font-size: 19px; font-weight: 700; }

.modalClose {
  width: 38px;
  min-height: 38px;
  padding: 0;
  border-color: #d8e0ea;
  background: #f8fafc;
  color: #475569;
  font-size: 25px;
  line-height: 1;
}

.modalClose:hover { background: #eef2f6; }
.modalBody { padding: 18px 20px 20px; }

.detailOrderHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(135deg, #f3f7fc, #f8fafc);
  border: 1px solid #e1e9f2;
  border-bottom: 0;
}

.detailOrderHead div { display: grid; gap: 5px; }
.detailOrderHead span { color: #7a8ba3; font-size: 11px; }
.detailOrderHead strong { color: #34435a; font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.detailOrderHead em {
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .08);
  font-style: normal;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.detailGrid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  padding: 7px 18px 15px;
  border: 1px solid #e1e9f2;
  border-top: 0;
  border-radius: 0 0 10px 10px;
}

.detailGrid div {
  grid-template-columns: 104px minmax(0, 1fr);
  min-height: 47px;
  align-items: center;
  padding: 9px 0;
}

.detailGrid dt { color: #7a8ba3; font-size: 12px; }
.detailGrid dd {
  color: #3d4b61;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.detailGrid .productField dd {
  white-space: nowrap;
  font-size: 13px;
}

.detailGrid .customField dd {
  justify-self: start;
  padding: 4px 9px;
  border-radius: 6px;
  color: #41546e;
  font-size: 13px;
  font-weight: 700;
}

.detailGrid .customerField dd { background: #eef4ff; color: #3f6090; }
.detailGrid .colorField dd { background: #edf4f8; color: #476579; }
.detailGrid .color-green dd { background: #eaf7f0; color: #377258; }
.detailGrid .color-orange dd { background: #fff1e7; color: #a15c2c; }
.detailGrid .color-black dd,
.detailGrid .color-graphite_black dd { background: #edf0f3; color: #3f4854; }
.detailGrid .color-white dd,
.detailGrid .color-showroom_white dd { background: #f7f8fa; color: #606b78; box-shadow: inset 0 0 0 1px #e2e7ed; }
.detailGrid .color-light_gray dd,
.detailGrid .color-gray dd,
.detailGrid .color-grey dd { background: #f0f2f4; color: #66717d; }
.detailGrid .markField dd { background: #f5f0fb; color: #705887; }
.detailGrid .weightField dd,
.detailGrid .toleranceField dd { background: #fff5e8; color: #8b6538; }

/* Mobile order preview */
.orderPage { background: #f5f7f4; color: #20322a; }
.orderPage .page { width: min(760px, calc(100vw - 32px)); }
.orderPage .topbar { border: 0; box-shadow: none; background: transparent; padding: 14px 2px 5px; }
.orderPage .topbar h1 { font-size: 27px; letter-spacing: -.04em; }
.orderSubtitle { display: block; margin-top: 7px; color: #78857d; font-size: 14px; }
.orderPage .orderForm { display: block; padding: 0; border: 0; border-radius: 20px; overflow: hidden; box-shadow: 0 14px 40px rgba(29,63,43,.07); }
.selectionSection, .customSection { padding: 24px; background: white; }
.customSection { border-top: 8px solid #f5f7f4; }
.sectionHeading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.sectionHeading h2 { font-size: 19px; }
.sectionHeading p { margin-top: 3px; color: #87948b; font-size: 12px; }
.stepNumber { display: grid; place-items: center; flex: none; width: 37px; height: 37px; border-radius: 12px; background: #e8f5eb; color: #298657; font-weight: 900; font-size: 13px; }
.productChoices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; padding: 0; border: 0; }
.productChoice { position: relative; display: block; cursor: pointer; }
.productChoice input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.choiceCard { display: block; overflow: hidden; border: 2px solid #e8ede9; border-radius: 15px; background: #fafbf9; transition: border-color .15s, transform .15s; }
.choiceCard img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.choiceMeta { display: grid; gap: 3px; padding: 10px 9px 11px; }
.choiceMeta strong { font-size: 14px; color: #28372e; }
.choiceMeta small { color: #89958d; font-size: 11px; font-weight: 400; }
.choiceCheck { position: absolute; top: 8px; right: 8px; display: none; width: 23px; height: 23px; place-items: center; border-radius: 50%; background: #258b5a; color: white; font-size: 13px; }
.productChoice input:checked + .choiceCard { border-color: #258b5a; box-shadow: 0 3px 13px rgba(37,139,90,.13); }
.productChoice input:checked + .choiceCard .choiceCheck { display: grid; }
.productChoice input:focus-visible + .choiceCard { outline: 3px solid #9ad1b0; outline-offset: 2px; }
.markLabel { display: flex; justify-content: space-between; margin: 2px 0 9px; font-size: 14px; color: #2f4236; }
.markLabel span { font-size: 12px; color: #9aa79e; font-weight: 400; }
.orderPage #markText { height: 50px; border-color: #e0e7e1; border-radius: 11px; background: #fafcf9; font-size: 14px; }
.fieldHelp { margin: 8px 0 20px; color: #9aa79e; font-size: 12px; }
.quantityRow { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #edf1ec; padding-top: 18px; }
.quantityRow > div:first-child { display: grid; gap: 3px; }
.quantityRow strong { font-size: 14px; }
.quantityRow small { color: #9aa79e; font-size: 12px; }
.quantityControl { display: flex; align-items: center; border: 1px solid #e3ebe4; border-radius: 10px; overflow: hidden; }
.quantityControl button { width: 39px; height: 39px; min-height: 39px; padding: 0; border: 0; background: #f6faf6; color: #33875c; font-size: 21px; }
.quantityControl input { width: 42px; height: 39px; min-height: 39px; padding: 0; border: 0; border-radius: 0; text-align: center; font-size: 15px; font-weight: 800; appearance: textfield; }
.quantityControl input::-webkit-inner-spin-button, .quantityControl input::-webkit-outer-spin-button { appearance: none; }
.orderSubmitBar { display: flex; align-items: center; gap: 15px; padding: 16px 24px; background: #fff; border-top: 1px solid #edf1ec; }
.orderSummary { display: grid; gap: 4px; min-width: 0; flex: 1; }
.orderSummary span { color: #9aa79e; font-size: 12px; }
.orderSummary strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orderSubmitBar button { width: auto; min-width: 158px; height: 46px; border: 0; border-radius: 12px; background: #268d59; font-size: 14px; }
.orderSubmitBar button span { margin-left: 9px; }
.orderPage .resultPanel { margin-top: 8px; border: 0; border-radius: 18px; }
@media (max-width: 520px) {
  .orderPage .page { width: 100%; padding: 0 0 35px; }
  .orderPage .topbar { padding: 31px 22px 22px; margin: 0; }
  .orderPage .topbar h1 { font-size: 25px; }
  .orderPage .orderForm { border-radius: 22px 22px 0 0; }
  .selectionSection, .customSection { padding: 22px 18px; }
  .productChoices { gap: 8px; }
  .choiceCard { border-radius: 12px; }
  .choiceMeta { padding: 8px 6px 10px; }
  .choiceMeta strong { font-size: 12px; }
  .choiceMeta small { font-size: 10px; }
  .orderSubmitBar { position: sticky; bottom: 0; z-index: 3; padding: 13px 18px max(13px, env(safe-area-inset-bottom)); box-shadow: 0 -8px 22px rgba(25,45,29,.05); }
  .orderSubmitBar button { min-width: 143px; }
  .orderPage .resultPanel { margin: 10px 16px; }
}

@media (max-width: 820px) {
  .topbar .desktopOrderTools,
  .orderForm .desktopOrderTools { display: none; }
  .topbar,
  .orderWorkspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .primaryFields,
  .extraFields fieldset {
    grid-template-columns: 1fr;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  dl div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .panelTitle { grid-template-columns: 1fr; }
  .quickPanelButton { grid-column: 1; grid-row: auto; margin-top: 6px; }
  .detailGrid { grid-template-columns: 1fr; }
  .detailGrid div { grid-template-columns: 1fr; }
  .listToolbar { align-items: flex-start; }
  .listToolbarActions { gap: 4px; }
  .listToolbarActions .listRefreshButton,
  .listToolbarActions .listBackLink { padding: 0 8px; }
}
