:root {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    sans-serif;
  color: #243046;
  background: #f4f6fa;
  font-size: 14px;
  --accent: #2459c4;
  --line: #e3e8f0;
  --muted: #778396;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 9px 15px;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 550;
}
button:hover {
  filter: brightness(0.95);
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.secondary {
  color: #35455e;
  background: #fff;
  border-color: #d6deea;
}
a {
  color: var(--accent);
  text-decoration: none;
}
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 36px;
  padding: 0 36px;
}
.brand {
  font-weight: 750;
  font-size: 18px;
  color: #163363;
}
.topbar nav {
  display: flex;
  gap: 28px;
  height: 100%;
  align-items: center;
}
.topbar nav a {
  height: 100%;
  display: flex;
  align-items: center;
  color: #788396;
}
.topbar nav .active {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
}
#identity {
  margin-left: auto;
  color: var(--muted);
}
main {
  max-width: 1920px;
  margin: auto;
  padding: 32px;
}
.page-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}
h1 {
  font-size: 29px;
  letter-spacing: -0.5px;
  margin: 5px 0 10px;
}
h2 {
  font-size: 19px;
  margin: 20px 0 12px;
}
.eyebrow {
  letter-spacing: 2px;
  font-size: 10px;
  font-weight: 750;
  color: #6884b1;
  margin: 0;
}
.muted {
  color: var(--muted);
}
.notice {
  padding: 13px 17px;
  border: 1px solid #ead7a5;
  background: #fff9e9;
  color: #826522;
  border-radius: 8px;
  margin: 0 0 20px;
}
.tabs {
  display: flex;
  gap: 24px;
  margin-bottom: 19px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  border: 0;
  background: none;
  color: var(--muted);
  border-radius: 0;
  padding: 13px 3px;
}
.tabs .selected {
  color: var(--accent);
  border-bottom: 3px solid var(--accent);
}
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  box-shadow: 0 4px 16px #25376304;
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 17px;
  flex-wrap: wrap;
}
.push {
  margin-left: auto;
}
input,
select,
textarea {
  border: 1px solid #d6deea;
  border-radius: 6px;
  background: white;
  padding: 9px;
  color: #293953;
  max-width: 100%;
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #9fc4ff;
  outline-offset: 1px;
}
input[type="checkbox"] {
  accent-color: var(--accent);
}
#search {
  width: 270px;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}
th {
  font-size: 12px;
  color: #7d8a9e;
  text-align: left;
  font-weight: 550;
  background: #f8faff;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 14px 10px;
  border-bottom: 1px solid #edf0f5;
  font-size: 13px;
}
td small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}
tbody tr:hover {
  background: #fbfcff;
}
.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.quantity {
  font-weight: 700;
  color: #235ba7;
}
.badge {
  border-radius: 4px;
  padding: 4px 7px;
  background: #edf3ff;
  color: #426baf;
  font-size: 11px;
}
.badge.warn {
  background: #fff5df;
  color: #916b22;
}
.badge.ok {
  background: #e8f5ed;
  color: #2b7a4e;
}
.error {
  color: #b34242;
}
.empty {
  text-align: center;
  padding: 48px;
  color: var(--muted);
  white-space: normal;
}
.pager {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  font-size: 12px;
}
.pager button {
  font-size: 12px;
  padding: 7px 12px;
}
.entry {
  max-width: 500px;
  margin: 100px auto;
  background: white;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.checks {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}
.checks label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mapping-row {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.mapping-main {
  display: flex;
  align-items: end;
  gap: 18px;
}
.mapping-main > label:first-child {
  flex: 1;
  max-width: 480px;
}
.mapping-main > button {
  margin-left: auto;
}
.mapping-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}
.mapping-row .blacklake-toggle {
  flex-direction: row;
  align-items: center;
  white-space: nowrap;
  padding: 10px 0;
  color: var(--text);
}
.blacklake-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.blacklake-fields[hidden] {
  display: none;
}
.mapping-row input {
  min-width: 0;
}
.order-card {
  display: flex;
  gap: 20px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 18px 0;
  cursor: pointer;
}
.order-card:first-child {
  border-top: 0;
}
.order-card .main {
  flex: 1;
}
.order-card strong {
  display: block;
  margin-bottom: 8px;
}
.order-card .summary {
  font-size: 12px;
  color: var(--muted);
}
dialog {
  border: 0;
  border-radius: 12px;
  width: min(1280px, 96vw);
  padding: 28px;
  max-height: 92vh;
  box-shadow: 0 25px 90px #10213b33;
}
dialog::backdrop {
  background: #0d1c3766;
}
.dialog-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dialog-title h2 {
  margin: 5px 0;
}
.icon {
  background: none;
  color: #7e8c9e;
  border: 0;
  font-size: 26px;
  padding: 3px 12px;
}
.fields {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin: 25px 0;
}
.fields label,
.block {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #6c7b90;
  font-size: 12px;
}
.block {
  margin-top: 20px;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  padding-top: 23px;
}
.dialog-actions .error {
  margin-right: auto;
}
.dialog-actions button {
  white-space: nowrap;
}
#draftLines input {
  width: 115px;
}
#draftLines input[type="date"] {
  width: 140px;
}
#draftLines select {
  width: 180px;
}
#detailBody .fields {
  background: #f7f9fd;
  padding: 18px;
  border-radius: 8px;
}
.execution {
  display: flex;
  gap: 14px;
  margin: 18px 0;
}
.execution > div {
  flex: 1;
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 8px;
}
.execution small {
  display: block;
  color: var(--muted);
  margin-top: 7px;
}
.audit {
  font-size: 12px;
  color: var(--muted);
  line-height: 2;
}
.price-edit {
  width: 110px;
}
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 13px 22px;
  background: #203651;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 5px 24px #0002;
  max-width: 90vw;
  z-index: 100;
}
.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  white-space: normal;
}
[hidden] {
  display: none !important;
}
@media (max-width: 850px) {
  main {
    padding: 18px;
  }
  .topbar {
    padding: 0 16px;
    gap: 20px;
  }
  .topbar nav {
    gap: 15px;
  }
  .fields {
    grid-template-columns: repeat(2, 1fr);
  }
  .mapping-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .page-title {
    gap: 15px;
  }
  .execution {
    flex-direction: column;
  }
  #identity {
    font-size: 11px;
  }
  .tabs {
    gap: 12px;
  }
  .panel {
    padding: 14px;
  }
}
@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
  }
  .topbar .brand {
    white-space: nowrap;
  }
  .topbar nav {
    order: 3;
    flex-basis: 100%;
    gap: 20px;
  }
  .topbar nav a {
    white-space: nowrap;
  }
  .topbar #identity {
    margin-left: auto;
  }
  .page-title > button {
    min-width: 110px;
  }
  .pager {
    flex-wrap: wrap;
  }
  .pager button {
    white-space: nowrap;
  }
  .pager .push {
    flex-basis: 100%;
    margin-left: 0;
  }
}
.filters {
  padding-top: 0;
}
.filters > select {
  max-width: 230px;
}
.filters label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

/* Lingxing-style plan grid: fixed identifiers with a scrollable detail region. */
.plans-table-wrap {
  max-height: max(340px, calc(100dvh - 365px));
  position: relative;
}
.plans-table {
  table-layout: fixed;
  width: 1928px;
  border-collapse: separate;
  border-spacing: 0;
}
.col-select {
  width: 42px;
}
.col-image {
  width: 92px;
}
.col-plan {
  width: 158px;
}
.col-sku {
  width: 130px;
}
.col-name {
  width: 220px;
}
.col-qty {
  width: 166px;
}
.col-date {
  width: 162px;
}
.col-person {
  width: 106px;
}
.col-warehouse {
  width: 164px;
}
.col-remark {
  width: 252px;
}
.col-status {
  width: 120px;
}
.col-stock {
  width: 210px;
}
.plans-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 44px;
}
.plans-table td {
  padding: 10px;
  vertical-align: middle;
  overflow-wrap: anywhere;
  white-space: normal;
  background: white;
}
.plans-table tbody tr:hover td {
  background: #f7faff;
}
.plans-table :is(th, td):nth-child(-n + 4) {
  position: sticky;
  z-index: 2;
}
.plans-table :is(th, td):nth-child(1) {
  left: 0;
}
.plans-table :is(th, td):nth-child(2) {
  left: 42px;
}
.plans-table :is(th, td):nth-child(3) {
  left: 134px;
}
.plans-table :is(th, td):nth-child(4) {
  left: 292px;
  box-shadow: 3px 0 4px #1b365710;
}
.plans-table th:nth-child(-n + 4) {
  z-index: 4;
}
.plans-table td:nth-child(7) {
  font-size: 12px;
}
.plans-table .error {
  color: #b34242;
}
.long-text {
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
}
.long-text summary {
  cursor: pointer;
  list-style: none;
}
.long-text summary::-webkit-details-marker {
  display: none;
}
.long-text summary span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.long-text[open] summary span {
  display: block;
}
.long-text summary:hover {
  color: var(--accent);
}
.stock-button {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 12px;
  font-weight: normal;
  padding: 7px 9px;
  color: #35455e;
  background: #f6f9fe;
  border: 1px solid #e3eafa;
}
.stock-button > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.6;
}
.stock-button small {
  color: #3465a4;
  font-size: 11px;
}
#inventoryDialog {
  width: min(1000px, calc(100vw - 32px));
}
#inventoryDialog .dialog-title p {
  font-size: 12px;
  margin-bottom: 0;
}
.inventory-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding: 14px 0 20px;
}
.inventory-summary b {
  margin-left: 10px;
  color: #235ba7;
}
.inventory-summary small {
  flex-basis: 100%;
}
.inventory-table-wrap {
  max-height: 55dvh;
}
.inventory-table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.inventory-table-wrap td {
  padding: 10px;
}
@media (max-width: 600px) {
  /* Leave room for scrolling on touch screens while retaining selection and image. */
  .plans-table :is(th, td):nth-child(3),
  .plans-table :is(th, td):nth-child(4) {
    position: static;
  }
}

/* Product image presentation follows the existing group-order hall. */
.product-image {
  background: #edf1f4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: var(--product-image-size);
  overflow: hidden;
  width: var(--product-image-size);
}

.product-image img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.hall-product-image-preview {
  cursor: zoom-in;
}

.hall-product-image-preview:focus-visible {
  box-shadow: 0 0 0 3px rgba(21, 112, 95, 0.22);
  outline: none;
}

.image-hover-preview {
  background: #ffffff;
  border: 1px solid rgba(23, 36, 48, 0.14);
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.24);
  box-sizing: border-box;
  height: 400px;
  opacity: 0;
  overflow: hidden;
  padding: 8px;
  pointer-events: none;
  position: fixed;
  transform: translateY(4px) scale(0.985);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  visibility: hidden;
  width: 400px;
  z-index: 3000;
}

.image-hover-preview.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
}

.image-hover-preview img {
  border-radius: 7px;
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

@media (hover: none), (pointer: coarse) {
  .hall-product-image-preview {
    cursor: default;
  }

  .image-hover-preview {
    display: none !important;
  }
}

.image-fallback {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 800;
  height: 100%;
  justify-content: center;
}

:root {
  --product-image-size: 72px;
}
.ordering-product {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
}
.ordering-product .product-image {
  flex-shrink: 0;
}
.ordering-product > div:last-child {
  min-width: 0;
}
.order-product-images {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.order-product-thumb {
  width: 80px;
}
.order-product-thumb small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#draftLines .ordering-product,
#detailBody .ordering-product {
  min-width: 200px;
}
.product-image img[hidden],
.image-fallback[hidden] {
  display: none;
}
@media (max-width: 700px) {
  .blacklake-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mapping-main {
    flex-wrap: wrap;
    align-items: center;
  }
  .mapping-main > label:first-child {
    flex-basis: 100%;
    max-width: none;
  }
  .product-image {
    --product-image-size: 64px;
  }
}
