* { box-sizing: border-box; }

:root {
  font-family: "Segoe UI Variable", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #172c46;
  background: #f3f6fa;
  --ink: #172c46;
  --subtle: #4b6077;
  --line: #dce5f0;
  --input-line: #aabbd1;
  --accent: #174578;
  --accent-hover: #0e3562;
  --soft: #ecf4ff;
  --white: #fff;
  --shadow: 0 3px 12px #213d6410, 0 18px 38px #213d6408;
  --gutter: clamp(18px, 3.7vw, 58px);
  --content: 1660px;
  color-scheme: light;
  text-rendering: optimizeLegibility;
}

body { margin: 0; min-width: 300px; }
[hidden], .mobile-only { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid #376ec5; outline-offset: 3px; }

.topbar {
  position: relative;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  width: min(var(--content), 100%);
  min-height: 74px;
  margin-inline: auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-group, .brand, .toolbar, .actions, .pages {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-group { gap: 22px; min-width: 0; }

.brand {
  color: #10283f;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: -.025em;
  white-space: nowrap;
}

.brand-mark {
  display: block;
  flex: 0 0 40px;
  height: 42px;
  position: relative;
  overflow: hidden;
}

.brand-mark img {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 70px;
  height: 70px;
  max-width: none;
  transform: translateX(-50%);
}

.portal-context {
  border-left: 1px solid var(--line);
  padding-left: 22px;
  color: var(--subtle);
  font-size: .875rem;
  font-weight: 650;
  white-space: nowrap;
}

.toolbar { flex-shrink: 0; }
.toolbar .button { min-height: 40px; }
#logout { color: var(--subtle); }
#language { color: var(--accent); }

main {
  width: min(var(--content), 100%);
  margin-inline: auto;
  padding: clamp(25px, 4vw, 48px) var(--gutter) max(40px, 5vw);
}

.workspace-heading {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: clamp(146px, 16vw, 194px);
  border-radius: 23px;
  border: 1px solid #d3e2f6;
  background: linear-gradient(110deg, #fafdff 8%, #eef5ff 54%, #dceafd 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: clamp(24px, 3.3vw, 43px);
  margin-bottom: 23px;
}

.workspace-heading::before,
.workspace-heading::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
}

.workspace-heading::before {
  right: -2%;
  top: 0;
  width: 47%;
  height: 100%;
  background: linear-gradient(120deg, transparent 9%, #fafdff55 9% 28%, transparent 28% 47%, #ffffff65 47% 65%, transparent 65%);
}

.workspace-heading::after {
  inset: 0 0 0 auto;
  width: 56%;
  background-image: radial-gradient(#789ac6 1px, transparent 1.2px);
  background-size: 15px 15px;
  opacity: .25;
  mask-image: linear-gradient(90deg, transparent, #000 81%);
}

h1 {
  font-size: clamp(2rem, 3.6vw, 3.15rem);
  font-weight: 730;
  line-height: 1.16;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}

:lang(zh) h1 { letter-spacing: -.025em; }

h2 {
  font-size: clamp(1.16rem, 2vw, 1.4rem);
  line-height: 1.3;
  font-weight: 720;
  letter-spacing: -.025em;
}

.subtitle { color: var(--subtle); margin-top: 10px; font-size: 1rem; }
.workspace-heading .button { min-height: 47px; padding-inline: 19px; box-shadow: 0 4px 12px #163b6b24; }

body:has(.signed-out) {
  --login-surface: #fbfcfe;
  background: var(--login-surface);
}

body:has(.signed-out) .topbar {
  background: var(--login-surface);
}

.signed-out {
  position: relative;
  isolation: isolate;
  overflow: clip;
  width: 100%;
  min-height: calc(100vh - 75px);
  min-height: calc(100dvh - 75px);
  display: grid;
  place-items: center;
  padding-block: clamp(48px, 9vh, 100px);
  background:
    radial-gradient(ellipse at 21% 34%, #f0f6fc, transparent 59%),
    linear-gradient(170deg, transparent 47%, #eff5fb 100%);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  align-items: center;
  width: min(1240px, 100%);
}

.login-scene {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

.login-scene::before {
  /* The receiving yard runs through both halves of the page. */
  content: "";
  position: absolute;
  inset: 50% -2% -12%;
  background:
    repeating-linear-gradient(153deg, transparent 0 87px, #83a6c634 88px 89px),
    repeating-linear-gradient(27deg, transparent 0 87px, #83a6c62b 88px 89px);
  mask-image:
    linear-gradient(transparent, #000 38%),
    radial-gradient(ellipse at 38% 88%, #000 17%, #000a 50%, transparent 78%);
  mask-composite: intersect;
}

.login-scene img {
  position: absolute;
  top: 50%;
  left: max(-24px, calc(50% - 675px));
  width: clamp(500px, 65vw, 865px);
  height: auto;
  transform: translateY(-50%);
  mix-blend-mode: multiply;
  mask-image: radial-gradient(ellipse closest-side, #000 82%, transparent);
}

.login-content {
  grid-column: 2;
  position: relative;
  isolation: isolate;
  width: min(100%, 410px);
  justify-self: center;
}

.login-content::before {
  /* Feather the backdrop so the ground lines frame the form. */
  content: "";
  position: absolute;
  z-index: -1;
  inset: -30% -29% -38% -36%;
  background: radial-gradient(ellipse, #fbfcfe 45%, #fbfcfeee 56%, #fbfcfe00 75%);
  pointer-events: none;
}

.login-content h1 { font-size: clamp(2rem, 3.6vw, 3rem); }
.login-description { margin-top: 11px; color: var(--subtle); line-height: 1.6; }
.login-content form { margin: 30px 0 22px; }
.login-content form label { margin-bottom: 17px; }
.login-content input { min-height: 49px; }

.login-content button[type=submit] {
  min-height: 49px;
  width: 100%;
  margin-top: 8px;
}

.login-switch {
  border-top: 1px solid var(--line);
  padding-top: 17px;
  font-size: .9rem;
  font-weight: 650;
}

.login-switch a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.login-switch a::after {
  content: "";
  width: 6px;
  height: 6px;
  border-top: 1.5px solid;
  border-right: 1.5px solid;
  transform: rotate(45deg);
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.company-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.company-toolbar .button {
  min-height: 38px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.company-toolbar .button[aria-pressed="true"] {
  background: #e1edfc;
  border-color: #a0bade;
  color: #113d71;
  box-shadow: inset 0 -2px #2f5a98;
}

.filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.panel .filters {
  padding: 18px 22px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.panel .filters label { margin: 0; }
.filters .search-field { flex: 1 1 300px; max-width: 565px; }
.filters .status-field { flex: 0 1 210px; }
.filters .button { min-height: 44px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 42px;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid #c1d0e2;
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

.button:hover { background: #edf4fe; border-color: #9eb9db; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--white); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.quiet { background: transparent; border-color: transparent; }
.button.quiet:hover { background: #ecf4ff; border-color: #d4e3f6; }
.button.compact { min-height: 34px; padding: 5px 9px; border-radius: 8px; }
.button:disabled { opacity: .58; cursor: default; }

input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--input-line);
  border-radius: 9px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--white);
}

input::placeholder, textarea::placeholder { color: #586c82; opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #6c8bb2; }

select {
  appearance: none;
  padding-right: 32px;
  background:
    linear-gradient(45deg, transparent 50%, #435a75 50%) calc(100% - 16px) 50% / 5px 5px no-repeat,
    linear-gradient(135deg, #435a75 50%, transparent 50%) calc(100% - 11px) 50% / 5px 5px no-repeat,
    var(--white);
}

textarea { resize: vertical; }
label { display: grid; gap: 6px; margin-bottom: 14px; font-size: .9rem; font-weight: 650; }

.table-frame { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }

th, td {
  padding: 13px 13px;
  border-bottom: 1px solid #e1e9f2;
  vertical-align: middle;
  font-size: .9rem;
}

th { background: #edf3fb; color: #314a67; font-weight: 700; white-space: nowrap; }
td { overflow-wrap: anywhere; }
.order-table { min-width: 1120px; }
.order-table th:first-child, .order-table td:first-child { padding-left: 21px; }
.order-table th:last-child, .order-table td:last-child { padding-right: 21px; }
.order-table .company-name { min-width: 106px; font-weight: 630; }
.order-table .check-cell { width: 35px; padding-right: 5px; }

.check-cell label {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 8px;
  margin: 0;
  cursor: pointer;
}

.check-cell input {
  width: 17px;
  height: 17px;
  min-height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.orders-row { background: var(--white); }
.orders-row:nth-child(even) { background: #f9fbfe; }
.orders-row:hover { background: #eef5ff; }
.orders-row:last-child td { border-bottom: 0; }
.selecting .orders-row:has(input:checked) { background: #e7f0ff; }
.time { min-width: 133px; color: #314a67; font-variant-numeric: tabular-nums; }
.order-id { min-width: 90px; color: #153c71; font-weight: 750; font-variant-numeric: tabular-nums; }
.time small, .muted { display: block; margin-top: 4px; color: var(--subtle); font-size: .82rem; }
.row-actions .actions { gap: 5px; flex-wrap: wrap; }
.row-actions .button { color: #174578; }

button[data-action="view"], button[data-action="history"] {
  border-color: transparent;
  background: transparent;
  color: #174578;
}

button[data-action="view"]:hover, button[data-action="history"]:hover { background: #e2edfc; border-color: #c3d8f2; }
button[data-action="view"] { text-decoration: underline; text-underline-offset: 3px; }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .82rem;
  font-weight: 680;
  line-height: 1.3;
  white-space: nowrap;
  background: #eaf0f7;
  color: #39516c;
}

.status.production { background: #e4efff; color: #204b84; }
.status.shipped { background: #dff3f5; color: #105963; }
.status.received, .status.paid { background: #e3f4e9; color: #17583e; }
.status.partial, .status.unpaid { background: #fff0d8; color: #76460a; }
.status.exception { background: #fde8ea; color: #8e2939; }

.note {
  white-space: pre-wrap;
  min-width: 112px;
  max-width: 270px;
  margin-top: 6px;
  color: #792938;
  font-size: .855rem;
  line-height: 1.42;
}

.empty { padding: 52px 20px; text-align: center; color: var(--subtle); }
.pages { justify-content: flex-end; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--subtle); }

.export-toolbar, .import-toolbar, .item-controls, .item-page-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.export-toolbar {
  border-bottom: 1px solid #cbdcf3;
  padding: 12px 20px;
  background: var(--soft);
  color: #2e496a;
  font-size: .9rem;
}

#selection-count {
  margin-right: auto;
  color: #163e72;
  background: #dceafa;
  font-weight: 700;
  border-radius: 6px;
  padding: 5px 8px;
}

dialog {
  border: 1px solid #cddbef;
  box-shadow: 0 20px 75px #152d5250;
  border-radius: 18px;
  width: min(calc(100% - 28px), 760px);
  max-height: min(88vh, 900px);
  max-height: min(88dvh, 900px);
  overflow: auto;
  padding: 0;
  background: var(--white);
  color: var(--ink);
}

#items-dialog { width: min(calc(100% - 28px), 850px); }
dialog::backdrop { background: #152d52a1; }
.dialog-body { padding: 0 clamp(17px, 3.4vw, 28px) clamp(17px, 3.4vw, 28px); }

.dialog-head {
  position: sticky;
  z-index: 2;
  top: 0;
  margin: 0 0 20px;
  padding: 16px 0 13px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-head h2 { overflow-wrap: anywhere; min-width: 0; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; }

.dialog-body .actions {
  position: sticky;
  z-index: 1;
  bottom: 0;
  padding: 13px 0 0;
  border-top: 1px solid var(--line);
  background: var(--white);
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

.form-error {
  border: 1px solid #efc4ca;
  border-radius: 8px;
  padding: 9px 12px;
  margin: 8px 0;
  background: #fff1f3;
  color: #8a2436;
  font-weight: 650;
  font-size: .9rem;
}

.import-help { margin: 8px 0 12px; line-height: 1.55; }
.item-controls { justify-content: space-between; margin: 12px 0; }
.item-page-buttons { margin: 6px 0 10px; color: var(--subtle); font-size: .88rem; }
.sku-list { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(72px, .65fr) auto; align-items: start; gap: 10px; }
.sku-list label { margin-bottom: 9px; }
.sku-list > button { margin-top: 23px; }

.announcement {
  position: fixed;
  z-index: 5;
  bottom: 18px;
  right: 18px;
  max-width: calc(100% - 36px);
  border-radius: 11px;
  padding: 12px 17px;
  color: white;
  background: #143760;
  box-shadow: 0 8px 24px #172c4633;
}

.history-entry { padding: 14px 0; border-bottom: 1px solid var(--line); }
.history-entry pre {
  font-size: .875rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #eef4fc;
  padding: 11px;
  border-radius: 8px;
}

@media (max-width: 1000px) {
  .order-table, .order-table tbody { display: block; min-width: 0; }
  .order-table thead {
    position: absolute;
    overflow: hidden;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
  }
  .order-table.selecting thead { position: static; display: block; clip-path: none; width: auto; height: auto; }
  .order-table.selecting thead tr { display: block; padding: 0 15px; }
  .order-table.selecting thead th:not(.check-cell) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  .order-table.selecting thead .check-cell { display: block; padding: 10px 13px; min-width: max-content; border-radius: 8px; border-bottom: 0; }
  .mobile-only { display: inline !important; }
  .order-table tbody {
    display: grid;
    padding: 15px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
    background: #f0f5fb;
  }
  .orders-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-content: start;
    align-items: start;
    column-gap: 12px;
    row-gap: 12px;
    border: 1px solid #d1deee;
    border-radius: 13px;
    padding: 13px;
  }
  .orders-row:nth-child(even) { background: var(--white); }
  .orders-row:hover { background: #f9fbff; }
  .order-table .orders-row td { display: block; min-width: 0; border: 0; padding: 0; }
  .order-table .orders-row td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--subtle);
    font-size: .78rem;
    font-weight: 650;
  }
  .order-table .orders-row .check-cell { grid-column: 1 / -1; order: -5; width: auto; }
  .order-table .orders-row .order-id { order: -4; font-size: 1.02rem; }
  .order-table .orders-row .company-name { order: -3; }
  .order-table .orders-row .time { order: -2; grid-column: 1 / -1; }
  .order-table .orders-row .detail-cell { order: -1; }
  .order-table .orders-row .warehouse-cell:has(.note), .order-table .orders-row .row-actions { grid-column: 1 / -1; }
  .order-table .orders-row .row-actions { padding-top: 10px; border-top: 1px solid var(--line); }
  .order-table .orders-row .row-actions::before { content: none; }
  .order-table .orders-row .note { min-width: 0; max-width: none; }
}

@media (max-width: 720px) {
  .portal-context { display: none; }
  .signed-out {
    min-height: calc(100dvh - 75px);
    place-items: start center;
    padding-block: 34px 0;
    background:
      radial-gradient(ellipse at 50% 97%, #dceaf8, transparent 53%),
      var(--login-surface);
  }
  .login-layout { width: min(100%, 450px); grid-template-columns: minmax(0, 1fr); }
  .login-content { grid-column: 1; width: 100%; padding-inline: clamp(12px, 3vw, 22px); }
  .login-content::before { display: none; }
  .login-content input { font-size: 16px; }
  .login-scene {
    position: relative;
    width: calc(100% + var(--gutter) * 2);
    justify-self: center;
    height: clamp(225px, 68vw, 340px);
    margin-top: -12px;
  }
  .login-scene::before {
    inset: 57% 0 0;
    mask-image: radial-gradient(ellipse at 50% 99%, #000 10%, transparent 81%);
  }
  .login-scene img {
    top: 49%;
    left: 50%;
    width: min(100%, 460px);
    transform: translate(-50%, -50%);
  }
  .workspace-heading { min-height: 140px; padding: 20px; border-radius: 16px; }
  .panel .filters { padding: 15px; }
  .filters .search-field { max-width: none; flex: 1 1 100%; }
  .filters .status-field { flex: 1 1 100px; }
  .order-table tbody { grid-template-columns: 1fr; }
}

@media (max-width: 470px) {
  :root { --gutter: 13px; }
  .topbar-inner { min-height: 63px; gap: 7px; }
  .signed-out { min-height: calc(100dvh - 64px); }
  .toolbar { gap: 3px; }
  .toolbar .button { min-height: 36px; padding-inline: 8px; font-size: .78rem; }
  .brand { font-size: .9rem; gap: 5px; }
  .brand-mark { flex-basis: 32px; height: 37px; }
  .brand-mark img { top: -4px; width: 60px; height: 60px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .sku-list { grid-template-columns: minmax(0, 1fr) minmax(90px, 1fr); margin-bottom: 12px; border-bottom: 1px solid var(--line); }
  .sku-list > label:first-child { grid-column: 1 / -1; }
  .sku-list > button { margin: 0 0 10px auto; grid-column: 1 / -1; }
  .export-toolbar { padding-inline: 15px; }
}

@media (max-width: 350px) {
  .brand > span:last-child { max-width: 94px; white-space: normal; line-height: 1.1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
