:root {
  --blue: #4f8cff;
  --blue-dark: #3a78e8;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --ink: #1f2d3d;
  --muted: #7a8aa0;
  --line: #e4eaf3;
  --line-strong: #d7e2f0;
  --green: #22a06b;
  --green-soft: #e6f7ef;
  --orange: #e8890c;
  --orange-soft: #fdf1e0;
  --red: #e05151;
  --red-soft: #fdecec;
  --purple: #7c5cff;
  --purple-soft: #efeaff;
  --gray: #8a97a8;
  --gray-soft: #eef1f6;
  --shadow: 0 1px 4px rgba(20, 45, 90, 0.07);
  --shadow-raised: 0 8px 24px rgba(20, 45, 90, 0.1);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 14% 12%, rgba(79, 140, 255, 0.2), transparent 30%),
    linear-gradient(145deg, #173258 0%, #0f2140 68%, #142c51 100%);
}

.login-panel {
  width: min(420px, 100%);
  padding: 30px 32px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(4, 18, 42, 0.3);
}

.login-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 11px;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 5px 14px rgba(79, 140, 255, 0.3);
}

.brand-mark .icon {
  width: 21px;
  height: 21px;
}

.login-brand strong,
.sidebar-brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.login-brand span:not(.brand-mark),
.sidebar-brand span:not(.brand-mark) {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.login-copy {
  margin: 32px 0 24px;
}

.login-copy h1 {
  margin: 0;
  color: #17325a;
  font-size: 25px;
  line-height: 1.3;
  letter-spacing: 0;
}

.login-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form label,
.form-field {
  display: block;
  margin-bottom: 16px;
}

.login-form label > span,
.form-field > span,
.field-label {
  display: block;
  margin-bottom: 6px;
  color: #52627a;
  font-size: 13px;
  font-weight: 600;
}

.login-form input,
.form-field input,
.form-field select,
.form-field textarea,
.search-input,
.toolbar select {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-form input:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.search-input:focus,
.toolbar select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.form-error {
  margin: 0 0 14px;
  color: var(--red);
  font-size: 13px;
}

.form-spacer {
  height: 14px;
}

.login-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 12px;
}

.login-meta .icon {
  width: 14px;
  height: 14px;
}

/* Application shell */
.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 216px;
  display: flex;
  flex-direction: column;
  color: #dbe6f7;
  background: linear-gradient(180deg, #173258, #0f2140);
}

.sidebar-brand {
  min-height: 78px;
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand > div {
  min-width: 0;
}

.sidebar-brand strong {
  color: #fff;
}

.sidebar-brand span:not(.brand-mark) {
  color: #8fa8cc;
  font-size: 12px;
}

.mobile-side-account {
  display: none;
}

.side-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-button {
  position: relative;
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 4px;
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  color: #c4d4ec;
  background: transparent;
  font-size: 14.5px;
  text-align: left;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.nav-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-button.active {
  color: #fff;
  background: var(--blue);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(79, 140, 255, 0.35);
}

.nav-button .icon {
  width: 19px;
  height: 19px;
}

.nav-badge {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 20px;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 600;
}

.nav-button.active .nav-badge {
  background: rgba(255, 255, 255, 0.28);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.account-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 0;
  border-radius: 9px;
  color: #eef4ff;
  background: transparent;
  text-align: left;
}

.account-card:hover {
  background: rgba(255, 255, 255, 0.07);
}

.account-card > .icon {
  width: 16px;
  height: 16px;
  color: #8fa8cc;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  color: #fff;
  background: rgba(79, 140, 255, 0.75);
  font-size: 13px;
  font-weight: 700;
}

.account-copy {
  min-width: 0;
  flex: 1;
}

.account-copy strong,
.account-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy strong {
  font-size: 13px;
}

.account-copy small {
  margin-top: 2px;
  color: #8fa8cc;
  font-size: 11.5px;
}

.workspace {
  min-height: 100vh;
  margin-left: 216px;
}

/* The original page keeps the page title inside each content view. */
.topbar {
  display: none;
}

.view-root {
  width: 100%;
  padding: 22px 26px 60px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-intro {
  min-width: 0;
  flex: 1;
}

.page-intro h2 {
  margin: 0;
  color: #1f2d3d;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

.page-intro p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.btn-primary:hover {
  border-color: var(--blue-dark);
  color: #fff;
  background: var(--blue-dark);
}

.btn-danger {
  border-color: #f0c8c8;
  color: var(--red);
  background: #fff;
}

.btn-danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.btn-ghost {
  border-color: transparent;
  color: var(--blue);
  background: transparent;
}

.btn-ghost:hover {
  border-color: transparent;
  color: var(--blue-dark);
  background: var(--blue-soft, #e8f0ff);
}

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 13px;
}

.btn-icon {
  width: 34px;
  min-height: 34px;
  padding: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #5e6f86;
  background: #fff;
}

.icon-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.btn-block {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  min-height: 88px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(20, 45, 90, 0.06);
}

.stat-card .stat-label {
  color: var(--muted);
  font-size: 12.5px;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  color: #17325a;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: 0;
}

.stat-card .stat-unit {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.panel {
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 12px;
  padding: 0;
  border: 0;
}

.panel-head h3 {
  flex: 1;
  margin: 0;
  font-size: 15px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 0;
  border: 0;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 430px;
}

.search-wrap .icon {
  position: absolute;
  top: 10px;
  left: 11px;
  width: 17px;
  height: 17px;
  color: #8b9ab0;
}

.search-input {
  min-height: 36px;
  padding-left: 36px;
}

.toolbar select {
  width: auto;
  min-width: 132px;
  min-height: 36px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.stock-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(125px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.stock-filter-field > span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.stock-filter-field input,
.stock-filter-field select {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.stock-filter-field input:focus,
.stock-filter-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.stock-filter-grid .btn {
  min-height: 36px;
}

.stock-query-placeholder {
  min-height: 120px;
  display: grid;
  place-items: center;
  margin-top: 12px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
  text-align: center;
}

.movement-filter-grid {
  grid-template-columns:
    minmax(180px, 1.4fr)
    minmax(150px, 1.1fr)
    minmax(125px, 0.8fr)
    minmax(120px, 0.75fr)
    minmax(135px, 0.75fr)
    minmax(135px, 0.75fr)
    auto;
}

.stock-location-table {
  min-width: 1180px;
}

.stock-movement-table {
  min-width: 1280px;
}

.stock-aggregate-table {
  min-width: 1080px;
}

.aggregate-locations {
  display: grid;
  gap: 5px;
  min-width: 250px;
}

.aggregate-location-line {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.aggregate-location-line.with-actions {
  grid-template-columns: minmax(110px, auto) 1fr auto auto;
}

.aggregate-location-line .stock-quick-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.aggregate-location-line strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.aggregate-location-line strong .cell-sub {
  display: block;
  margin-top: 2px;
  text-align: right;
}

.movement-delta {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.movement-delta.positive {
  color: var(--green);
}

.movement-delta.negative {
  color: var(--red);
}

.movement-delta.neutral {
  color: var(--muted);
}

.movement-reason {
  max-width: 280px;
  margin-top: 5px;
  color: #61708a;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: normal;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pagination-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.data-table td {
  border-bottom-color: #f0f4fa;
  font-size: 14px;
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table .num {
  color: #17325a;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.data-table .code {
  color: #17325a;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.cell-main {
  font-weight: 500;
}

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

.cell-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

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

.nowrap {
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-draft,
.badge-readonly,
.badge-inactive {
  color: var(--gray);
  background: var(--gray-soft);
}

.badge-pending {
  color: var(--orange);
  background: var(--orange-soft);
}

.badge-approved,
.badge-active,
.badge-ok {
  color: var(--green);
  background: var(--green-soft);
}

.badge-rejected,
.badge-cancelled,
.badge-frozen {
  color: var(--red);
  background: var(--red-soft);
}

.badge.movement-type-inbound {
  color: var(--green);
  background: var(--green-soft);
}

.badge.movement-type-outbound {
  color: var(--red);
  background: var(--red-soft);
}

.badge.movement-type-transfer_out {
  color: var(--orange);
  background: var(--orange-soft);
}

.badge.movement-type-transfer_in {
  color: var(--blue-dark);
  background: #e9f1ff;
}

.badge.movement-type-stocktake {
  color: #526176;
  background: #edf2f7;
}

.badge-lock {
  color: var(--orange);
  background: var(--orange-soft);
}

.badge-supplier {
  color: var(--blue-dark);
  background: #e9f1ff;
}

.badge-customer {
  color: var(--green);
  background: var(--green-soft);
}

.badge-shipped {
  color: var(--green);
  background: var(--green-soft);
}

.badge-admin {
  color: var(--orange);
  background: var(--orange-soft);
}

.badge-operator {
  color: var(--blue-dark);
  background: #e8f0ff;
}

.empty-state {
  padding: 36px 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state .icon {
  width: 28px;
  height: 28px;
  display: block;
  margin: 0 auto 8px;
  color: #a4b2c6;
}

.loading-state {
  padding: 36px 12px;
  color: var(--muted);
  text-align: center;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
  padding: 0;
  overflow-x: auto;
  border: 0;
  background: transparent;
}

.tab-button {
  min-height: 32px;
  padding: 5px 12px;
  border: 0;
  border-radius: 20px;
  color: var(--muted);
  background: var(--gray-soft);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.tab-button:hover {
  color: var(--blue);
}

.tab-button.active {
  color: #fff;
  background: var(--blue);
  font-weight: 600;
  box-shadow: 0 3px 9px rgba(79, 140, 255, 0.25);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.overview-tile {
  min-height: 104px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(20, 45, 90, 0.06);
}

.overview-tile .icon {
  color: var(--blue);
}

.overview-tile strong {
  display: block;
  margin-top: 8px;
  color: #17325a;
  font-size: 23px;
  line-height: 1.2;
}

.overview-tile span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.info-band {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-left: 3px solid var(--orange);
  border-radius: 6px;
  color: #536176;
  background: var(--orange-soft);
  font-size: 13px;
}

.info-band .icon {
  margin-top: 2px;
  color: var(--orange);
}

.info-band strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

/* Modal and forms */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  background: rgba(15, 30, 55, 0.45);
}

.modal {
  width: min(640px, 100%);
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 48px rgba(10, 25, 60, 0.25);
  animation: modal-in 0.18s ease;
}

.modal-wide {
  width: min(1000px, 100%);
}

.modal-small {
  width: min(440px, 100%);
}

@keyframes modal-in {
  from {
    opacity: 0.4;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
}

.modal-head .icon-btn {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.modal-head .icon-btn:hover {
  color: var(--blue);
  background: var(--gray-soft);
}

.modal-body {
  max-height: min(62vh, 720px);
  overflow-y: auto;
  padding: 18px 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
}

#numpad-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  pointer-events: none;
}

#numpad-root:not(:empty) {
  pointer-events: auto;
}

.numpad {
  width: min(420px, calc(100% - 24px));
  margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 32px rgba(15, 30, 55, 0.18);
  animation: numpad-in 0.16s ease;
}

@keyframes numpad-in {
  from {
    opacity: 0.4;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.numpad-actions,
.numpad-toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.numpad-key {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
}

.numpad-key:hover {
  background: #eef2f8;
}

.numpad-key:active {
  background: #e2e8f0;
  transform: translateY(1px);
}

.numpad-actions .numpad-key,
.numpad-toolbar .numpad-key {
  font-size: 15px;
}

.numpad-key-wide {
  grid-column: span 2;
}

input.numpad-active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
}

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

.form-field[hidden] {
  display: none;
}

.location-wizard {
  display: grid;
  gap: 14px;
}

.wizard-step {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.wizard-step.is-disabled {
  opacity: 0.55;
}

.wizard-step-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.wizard-step-title span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.area-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.area-toolbar input {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
}

.area-toolbar input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

.location-zone-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 110px 110px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid #e8eef7;
  border-radius: 10px;
  background: #fff;
}

.location-zone-row .form-field {
  margin: 0;
}

.location-zone-remove {
  min-height: 38px;
  white-space: nowrap;
}

.location-batch-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
}

.location-batch-summary .icon {
  flex: none;
}

.location-batch-summary strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.location-batch-summary span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.location-batch-summary.is-valid {
  border-style: solid;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.06);
  color: var(--ink);
}

.location-batch-summary.is-valid strong {
  color: #166534;
}

.location-batch-summary.is-valid .icon {
  color: #22c55e;
}

.zone-row-hint {
  grid-column: 1 / -1;
  margin-top: -2px;
  color: var(--muted);
  font-size: 11.5px;
}

.zone-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-bottom: 12px;
}

.zone-detail-summary {
  display: grid;
  gap: 2px;
}

.zone-detail-summary strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.zone-detail-summary span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.zone-detail-toolbar .btn {
  margin-left: auto;
}

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

.form-field .field-hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.form-field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.permission-fieldset {
  margin: 2px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.permission-fieldset legend {
  padding: 0 5px;
  color: #314b62;
  font-size: 13px;
  font-weight: 650;
}

.permission-fieldset > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11.5px;
}

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

.permission-grid .checkbox-label {
  align-items: flex-start;
  line-height: 1.45;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.line-editor {
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.line-editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.line-editor-head strong {
  flex: 1;
  font-size: 13px;
}

.line-list {
  padding: 10px;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(150px, 1fr) 104px 110px minmax(120px, 1fr) 34px;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
  padding: 9px;
  border: 1px solid #e8eef7;
  border-radius: 10px;
  background: #fff;
}

.line-row:last-child {
  margin-bottom: 0;
}

.line-delete {
  color: var(--red);
  background: var(--red-soft);
}

.line-delete:hover {
  border-color: var(--red);
  color: var(--red);
}

.line-field {
  min-width: 0;
}

.line-field label,
.line-field > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.line-field input,
.line-field select {
  width: 100%;
  min-height: 35px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: #fff;
  font-size: 13px;
}

.line-field input:focus,
.line-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12);
}

.line-note-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -1px;
}

.line-note-row input {
  flex: 1;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: none;
  color: var(--muted);
  background: transparent;
  font-size: 11.5px;
}

.line-stock-hint {
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

.new-product-fields,
.new-location-fields {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.new-product-fields {
  grid-template-columns: minmax(150px, 1.2fr) minmax(180px, 1.5fr) minmax(120px, 1fr) minmax(120px, 1fr) 90px;
}

.new-location-fields {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr);
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

.detail-meta.stock-operation-meta {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.detail-cell {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.detail-cell span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.detail-cell strong {
  display: block;
  overflow-wrap: anywhere;
  color: #17325a;
  font-size: 12.5px;
}

.stock-reason-field {
  grid-column: 1 / -1;
}

.stock-row-actions {
  flex-wrap: wrap;
  white-space: normal;
}

.detail-note {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #526176;
  background: var(--surface-soft);
  font-size: 12.5px;
}

.review-box {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid #f0d4a5;
  border-radius: 8px;
  background: var(--orange-soft);
}

.review-box h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.review-box textarea {
  width: 100%;
  min-height: 74px;
  padding: 8px 10px;
  border: 1px solid #ebc98e;
  border-radius: 8px;
  outline: none;
  resize: vertical;
  background: #fff;
}

.review-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
}

/* Account menu */
.account-sheet {
  display: grid;
  gap: 8px;
}

.account-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.account-summary .avatar {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.account-summary strong,
.account-summary span {
  display: block;
}

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

.sheet-action {
  width: 100%;
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.sheet-action:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.sheet-action.danger {
  color: var(--red);
}

/* Toast */
.toast-root {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 120;
  width: min(420px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
  background: #1f2d3d;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  animation: toast-in 0.18s ease;
}

.toast.success {
  background: var(--green);
}

.toast.error {
  background: var(--red);
}

.toast .icon {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Mobile navigation is replaced by the original horizontal top navigation. */
.mobile-nav {
  display: none;
}

.import-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle, #f7f9fc);
}

.import-copy {
  display: grid;
  gap: 3px;
  min-width: 220px;
}

.import-copy span,
.import-file-name,
.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.import-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.import-file-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.readonly-code {
  background: #eef3f8;
  color: #33475b;
}

.location-code-preview {
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f8;
  color: #33475b;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.field-hint {
  margin-top: 5px;
}

.badge.progress-completed {
  background: #e7f6ec;
  color: #17663a;
}

.badge.progress-receiving,
.badge.progress-putting_away,
.badge.progress-awaiting_pick {
  background: #fff4dc;
  color: #8a5a00;
}

.badge.progress-awaiting_receipt,
.badge.progress-awaiting_putaway,
.badge.progress-awaiting_ship {
  background: #e8f1ff;
  color: #22589e;
}

.batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.batch-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  background: #fff;
}

.batch-panel h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.batch-item {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.batch-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.batch-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
}

.batch-head span,
.batch-note,
.batch-empty {
  color: var(--muted);
  font-size: 0.8rem;
}

.batch-lines {
  margin-top: 6px;
  font-size: 0.85rem;
  line-height: 1.7;
}

.batch-note {
  margin-top: 5px;
}

.batch-form-note {
  margin-top: 14px;
}

.stock-inline {
  font-size: 0.83rem;
  line-height: 1.6;
}

.data-table input[type="number"],
.data-table select {
  min-width: 145px;
  width: 100%;
}

.putaway-table {
  min-width: 980px;
}

.putaway-location-builder {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  min-width: 440px;
}

.putaway-batch-panel {
  margin-bottom: 14px;
  padding: 13px 14px;
  border: 1px solid #cfe0ef;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5faff 0%, #eef6fd 100%);
}

.putaway-batch-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.putaway-batch-heading > div {
  display: grid;
  gap: 2px;
}

.putaway-batch-heading strong {
  color: #1f4162;
  font-size: 14px;
}

.putaway-batch-heading span {
  color: #61798d;
  font-size: 12px;
}

.putaway-scope-badge {
  flex: none;
  padding: 2px 8px;
  border: 1px solid #bdd8eb;
  border-radius: 999px;
  color: #245d88 !important;
  background: #fff;
  font-weight: 600;
}

.putaway-batch-controls {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.putaway-batch-controls .putaway-location-builder {
  flex: 1 1 440px;
}

.putaway-batch-controls > .btn {
  flex: none;
  min-height: 34px;
}

.putaway-command-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid #e1e9f2;
  border-radius: 9px;
  background: #fbfdff;
  flex-wrap: wrap;
}

.putaway-search {
  min-width: 250px;
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid #d6e0eb;
  border-radius: 8px;
  background: #fff;
}

.putaway-search .icon {
  width: 16px;
  height: 16px;
  margin: 0;
}

.putaway-search input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
}

.putaway-command-bar > strong {
  margin-left: auto;
  color: #1f5f92;
  font-size: 12.5px;
  white-space: nowrap;
}

.putaway-location-builder select {
  min-width: 0;
  padding: 7px 8px;
  font-size: 13px;
}

.putaway-location-code {
  min-height: 18px;
  margin-top: 5px;
  color: #17325a;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.putaway-location-preset {
  display: flex;
  align-items: center;
  min-height: 35px;
}

.putaway-location-preset .code {
  color: #17325a;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

@media (max-width: 720px) {
  .putaway-location-builder {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 260px;
  }

  .putaway-batch-controls {
    flex-direction: column;
  }

  .putaway-batch-controls .putaway-location-builder {
    width: 100%;
    flex-basis: auto;
  }

  .putaway-batch-controls > .btn {
    width: 100%;
  }

  .putaway-command-bar > strong {
    width: 100%;
    margin-left: 0;
  }

  .import-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .import-actions {
    justify-content: flex-start;
  }

  .import-file-name {
    max-width: 100%;
    flex-basis: 100%;
  }

  .batch-head {
    flex-direction: column;
    gap: 2px;
  }
}

@media (max-width: 1120px) {
  .overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .line-row {
    grid-template-columns: minmax(160px, 1.5fr) minmax(140px, 1fr) 92px 100px 34px;
  }

  .line-row > .line-field:nth-child(5) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  body {
    background: var(--bg);
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    display: block;
  }

  .sidebar-brand {
    min-height: 0;
    padding: 12px 16px;
  }

  .sidebar-brand strong {
    font-size: 17px;
  }

  .sidebar-brand span:not(.brand-mark) {
    margin-top: 1px;
    font-size: 11px;
  }

  .mobile-side-account {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    margin-left: auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 9px;
    color: #dbe6f7;
    background: rgba(255, 255, 255, 0.08);
  }

  .mobile-side-account:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
  }

  .side-nav {
    display: flex;
    gap: 2px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .side-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    width: auto;
    min-height: 38px;
    flex: none;
    gap: 0;
    margin: 0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13.5px;
  }

  .nav-button .icon {
    display: none;
  }

  .nav-badge {
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    font-size: 10px;
  }

  .sidebar-foot {
    display: none;
  }

  .workspace {
    min-height: 0;
    margin-left: 0;
  }

  .topbar {
    display: none;
  }

  .view-root {
    padding: 14px 14px 50px;
  }

  .page-head {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-intro h2 {
    font-size: 19px;
  }

  .page-intro p {
    font-size: 12.5px;
  }

  .page-actions {
    gap: 8px;
  }

  .panel {
    padding: 14px;
    border-radius: 12px;
  }

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

  .stat-card {
    min-height: 78px;
    padding: 12px 13px;
  }

  .stat-card strong {
    font-size: 21px;
  }

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

  .overview-tile {
    min-height: 92px;
    padding: 12px 13px;
  }

  .overview-tile strong {
    font-size: 20px;
  }

  .toolbar {
    align-items: stretch;
  }

  .search-wrap {
    min-width: 100%;
    max-width: none;
  }

  .toolbar select {
    min-width: 0;
    flex: 1;
  }

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

  .stock-filter-grid .btn {
    grid-column: span 2;
  }

  .panel-head {
    flex-wrap: wrap;
  }

  .modal-mask {
    padding: 20px 12px;
  }

  .modal {
    border-radius: 16px;
  }

  .modal-body {
    max-height: calc(100vh - 180px);
  }

  .login-shell {
    align-items: start;
    padding: 14vh 16px 24px;
  }

  .login-panel {
    padding: 25px 22px;
  }
}

@media (max-width: 720px) {
  .data-table.mobile-cards {
    min-width: 0;
  }

  .data-table.mobile-cards thead {
    display: none;
  }

  .data-table.mobile-cards,
  .data-table.mobile-cards tbody,
  .data-table.mobile-cards tr,
  .data-table.mobile-cards td {
    display: block;
    width: 100%;
  }

  .data-table.mobile-cards tbody {
    padding-top: 1px;
  }

  .data-table.mobile-cards tr {
    margin-bottom: 9px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
  }

  .data-table.mobile-cards tr:last-child {
    margin-bottom: 0;
  }

  .data-table.mobile-cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    border: 0;
    text-align: right;
  }

  .data-table.mobile-cards td::before {
    flex: none;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 400;
    content: attr(data-label);
  }

  .data-table.mobile-cards td .table-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .data-table.mobile-cards td .stock-row-actions {
    flex: 1;
    min-width: 0;
  }

  .data-table.mobile-cards .num {
    text-align: right;
  }

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

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

  .area-toolbar {
    grid-template-columns: 1fr;
  }

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

  .location-zone-remove {
    grid-column: span 2;
    width: 100%;
  }

  .line-row {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .line-row > .line-field:nth-child(1),
  .line-row > .line-field:nth-child(2) {
    grid-column: 1 / -1;
  }

  .line-row > .line-field:nth-child(5) {
    grid-column: 1 / 2;
  }

  .new-product-fields {
    grid-template-columns: 1fr 1fr;
  }

  .line-row .line-delete {
    align-self: end;
    justify-self: end;
  }

  .detail-meta {
    grid-template-columns: 1fr 1fr;
  }

  .stock-filter-grid {
    grid-template-columns: 1fr;
  }

  .stock-filter-grid .btn {
    grid-column: span 1;
  }
}

@media (max-width: 460px) {
  .view-root {
    padding-right: 10px;
    padding-left: 10px;
  }

  .sidebar-brand,
  .side-nav {
    padding-right: 10px;
    padding-left: 10px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .stats-grid,
  .overview-grid {
    gap: 8px;
  }

  .detail-meta {
    grid-template-columns: 1fr;
  }

  .modal-mask {
    padding: 12px 8px;
  }

  .modal-body,
  .modal-head,
  .modal-footer {
    padding-right: 14px;
    padding-left: 14px;
  }

  .new-product-fields,
  .new-location-fields {
    grid-template-columns: 1fr;
  }

  .account-summary {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* New-document editor only. The edit-existing-document dialog keeps its original styles. */
.document-create-mask {
  align-items: stretch;
  padding: 18px;
  background: rgba(12, 27, 45, 0.58);
}

.modal.document-create-modal {
  width: min(1600px, calc(100vw - 36px));
  height: calc(100vh - 36px);
  max-height: 1050px;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(28, 54, 79, 0.24);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(4, 17, 33, 0.32);
}

.document-create-modal .modal-head {
  min-height: 46px;
  flex: none;
  padding: 0 16px;
  background: #f8fafc;
}

.document-create-modal .modal-head h2 {
  color: #21394e;
  font-size: 16px;
  font-weight: 650;
}

.document-create-modal .modal-head .icon-btn {
  width: 30px;
  height: 30px;
}

.document-create-modal .modal-body {
  min-height: 0;
  max-height: none;
  flex: 1;
  overflow: hidden;
  padding: 0;
}

.document-create-modal .modal-footer {
  min-height: 58px;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #fbfcfe;
}

.create-document-form {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  color: #25384b;
  background: #eef2f7;
}

.create-document-summary {
  flex: none;
  padding: 12px 16px 11px;
  border-bottom: 1px solid #d4dee9;
  background: #fff;
}

.create-document-title {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 10px;
}

.create-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.create-title-line h3 {
  margin: 0;
  color: #1d3348;
  font-size: 18px;
  font-weight: 650;
}

.create-document-title p {
  margin: 2px 0 0;
  color: #7a8b9b;
  font-size: 12px;
}

.create-status-badge {
  padding: 1px 7px;
  border: 1px solid #e7c994;
  border-radius: 3px;
  color: #936118;
  background: #fff8ea;
  font-size: 11px;
  font-weight: 600;
}

.create-document-type {
  padding: 1px 5px;
  border: 1px solid #c9dceb;
  border-radius: 3px;
  color: #4c7898;
  background: #f3f9fd;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.create-title-note {
  margin: 2px 0 0 auto;
  color: #8493a2;
  font-size: 11px;
}

.create-meta-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.15fr 1.15fr 1fr;
  gap: 8px 14px;
}

.create-meta-field {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.create-meta-field > span {
  color: #5d7184;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.create-meta-field input,
.create-meta-field select {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid #d4dee9;
  border-radius: 3px;
  outline: none;
  color: #263c50;
  background: #fff;
  font-size: 13px;
}

.create-meta-field input:focus,
.create-meta-field select:focus {
  border-color: #2b78b7;
  box-shadow: 0 0 0 2px rgba(43, 120, 183, 0.12);
}

.create-meta-field input:disabled {
  color: #8191a0;
  background: #f5f7f9;
}

.create-workflow-bar {
  min-height: 34px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 5px 16px;
  border-bottom: 1px solid #d4dee9;
  color: #687b8d;
  background: #f8fafc;
  font-size: 11.5px;
}

.create-workflow-bar strong {
  margin-right: 4px;
  color: #334b60;
  font-weight: 600;
}

.create-workflow-bar b {
  color: #315c7f;
  font-weight: 650;
}

.create-flow {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.create-flow i {
  width: 22px;
  height: 1px;
  background: #bccbd8;
}

.create-flow > span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.create-flow > span > b {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9eb1c2;
}

.create-flow > span.current {
  color: #1f68a2;
  font-weight: 600;
}

.create-flow > span.current > b {
  background: #2d7ebd;
  box-shadow: 0 0 0 2px #d7eafb;
}

.create-details {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 7px 12px 12px;
}

.create-details-toolbar {
  min-height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
}

.create-details-toolbar h4 {
  margin: 0;
  color: #263d52;
  font-size: 14px;
  font-weight: 650;
}

.create-line-count-badge {
  min-width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 9px;
  color: #436d91;
  background: #e3edf6;
  font-size: 10.5px;
  font-weight: 600;
}

.create-toolbar-hint {
  color: #8191a1;
  font-size: 11.5px;
}

.create-add-line {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 0 11px;
  border: 1px solid #c5d9e9;
  border-radius: 3px;
  color: #286b9f;
  background: #f6fbff;
  font-size: 12px;
}

.create-add-line .icon {
  width: 14px;
  height: 14px;
}

.create-table-scroll {
  min-height: 0;
  flex: 1;
  overflow: auto;
  border: 1px solid #b7c7d5;
  border-radius: 3px;
  background: #fff;
}

.create-line-table {
  min-width: 1120px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.create-line-head,
.create-line-row {
  display: grid;
  grid-template-columns:
    36px minmax(190px, 1.4fr) 78px 92px 48px 140px
    74px 84px 82px 92px minmax(120px, 1fr) 42px;
}

.create-line-head {
  min-height: 34px;
  flex: none;
  color: #344d63;
  background: #dce9f6;
  border-bottom: 1px solid #b7c7d5;
  font-size: 12px;
  font-weight: 650;
}

.create-line-head > span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border-right: 1px solid #bfd0df;
  white-space: nowrap;
}

.create-line-head > span:last-child {
  border-right: 0;
}

.create-line-list {
  min-height: 0;
  flex: 1;
  padding: 0;
}

.document-create-modal .create-line-row {
  min-height: 43px;
  display: grid;
  align-items: stretch;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #dce4ec;
  border-radius: 0;
  background: #fff;
}

.document-create-modal .create-line-row:nth-child(even) {
  background: #f8fbfe;
}

.document-create-modal .create-line-row:hover {
  background: #f1f7fd;
}

.create-line-number,
.create-line-cell {
  min-width: 0;
  min-height: 42px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-right: 1px solid #e0e7ee;
}

.create-line-number {
  justify-content: center;
  color: #718393;
  background: rgba(226, 235, 244, 0.52);
  font-size: 11.5px;
}

.create-line-cell input,
.create-line-cell select {
  width: 100%;
  height: 41px;
  min-height: 41px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  outline: none;
  color: #2c4154;
  background: transparent;
  font-size: 12.5px;
}

.create-line-cell select {
  padding-right: 19px;
}

.create-line-cell input:focus,
.create-line-cell select:focus {
  position: relative;
  z-index: 1;
  background: #fff;
  box-shadow: inset 0 0 0 1px #3b85c4;
}

.create-line-cell input::placeholder {
  color: #a3b0bd;
}

.create-meta-cell {
  padding: 0 7px;
  overflow: hidden;
  color: #3e5366;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.create-number-cell input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.create-stock-cell {
  padding: 0 7px;
}

.document-create-modal .create-stock-cell .line-stock-hint {
  width: 100%;
  overflow: hidden;
  color: #61798d;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.create-amount-cell {
  justify-content: flex-end;
  padding: 0 8px;
  color: #293f53;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 600;
}

.document-create-modal .create-line-delete {
  width: 26px;
  height: 26px;
  align-self: center;
  justify-self: center;
  border: 0;
  border-radius: 3px;
  color: #9aabb9;
  background: transparent;
  opacity: 1;
}

.document-create-modal .create-line-delete:hover {
  color: #c73737;
  background: #fbecec;
}

.document-create-modal .create-line-delete .icon {
  width: 14px;
  height: 14px;
}

.document-create-modal .create-aux-fields {
  grid-column: 1 / -1;
  gap: 8px;
  margin: 0 8px 8px;
  padding: 8px 9px;
  border: 1px dashed #bfd1e1;
  border-radius: 3px;
  background: #f5f9fd;
}

.document-create-modal .new-product-fields {
  grid-template-columns: 1.15fr 1.4fr 0.9fr 0.9fr 0.65fr;
}

.document-create-modal .new-location-fields {
  grid-template-columns: 1fr 1.4fr;
}

.document-create-modal .create-aux-fields .line-field {
  display: block;
}

.document-create-modal .create-aux-fields .line-field > span {
  margin-bottom: 3px;
  color: #6b7f91;
  font-size: 11px;
}

.document-create-modal .create-aux-fields input {
  width: 100%;
  min-height: 33px;
  padding: 5px 8px;
  border: 1px solid #d0dce7;
  border-radius: 3px;
  background: #fff;
  font-size: 12px;
}

.create-total-row {
  min-height: 37px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
  padding: 0 12px;
  border-top: 1px solid #c4d1de;
  color: #5b7083;
  background: #f1f6fa;
  font-size: 11.5px;
}

.create-total-row strong {
  color: #304b61;
  font-size: 12px;
}

.create-total-row b {
  margin-left: 3px;
  color: #243f56;
  font-weight: 650;
}

.create-footer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #8291a1;
  font-size: 11.5px;
}

.create-footer-status > span {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #d59a3d;
}

.create-footer-actions {
  display: flex;
  gap: 8px;
}

.create-btn {
  min-width: 78px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 14px;
  border: 1px solid #c6d3df;
  border-radius: 4px;
  color: #3b5267;
  background: #fff;
  font-size: 12.5px;
}

.document-create-modal input::placeholder,
.document-create-modal textarea::placeholder {
  color: transparent;
  opacity: 0;
}

.create-btn:hover {
  border-color: #6c9bc2;
  color: #24679d;
}

.create-btn .icon {
  width: 14px;
  height: 14px;
}

.create-btn-primary {
  min-width: 104px;
  border-color: #246fb4;
  color: #fff;
  background: #246fb4;
}

.create-btn-primary:hover {
  border-color: #195b98;
  color: #fff;
  background: #195b98;
}

.create-inbound-meta-grid {
  grid-template-columns: 0.9fr 1.3fr 1.2fr;
}

.create-inbound-line-table {
  min-width: 1160px;
}

.create-inbound-line-head,
.document-create-modal .create-inbound-row {
  grid-template-columns:
    36px 90px 108px 132px 76px 46px 72px 56px 56px 62px
    72px 88px minmax(120px, 1fr) 42px;
}

.create-required-head::before {
  content: "*";
  margin-right: 2px;
  color: #c73737;
  font-weight: 700;
}

.document-create-modal .create-inbound-row.has-product-conflict {
  box-shadow: inset 3px 0 0 #d54c4c;
}

.document-create-modal .create-inbound-row.has-product-conflict [data-line-field="product_sku"] {
  color: #b32e2e;
  background: #fff7f7;
}

.document-create-modal .create-inbound-row.has-packing-conflict {
  box-shadow: inset 3px 0 0 #d54c4c;
}

.document-create-modal .create-inbound-row.has-location-conflict {
  box-shadow: inset 3px 0 0 #d54c4c;
}

.document-create-modal .create-inbound-row.has-location-conflict [data-line-field="location_code"] {
  color: #b32e2e;
  background: #fff7f7;
}

.document-create-modal .create-inbound-row [data-inbound-total] {
  color: #243f56;
  background: #f5f8fb;
  font-weight: 650;
}

.outbound-lookup-panel {
  grid-column: 1 / -1;
  padding: 8px 10px 10px;
  border-top: 1px solid #dce6ef;
  background: #f7fbff;
}

.outbound-result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.outbound-result-head > div {
  min-width: 0;
}

.outbound-result-head strong,
.outbound-result-head span {
  display: block;
}

.outbound-result-head strong {
  color: #29445a;
  font-size: 12px;
}

.outbound-result-head span {
  margin-top: 1px;
  color: #7a8b9b;
  font-size: 10.5px;
}

.outbound-product-results,
.outbound-location-results {
  display: grid;
  gap: 5px;
}

.outbound-product-result {
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(170px, 1.5fr) 100px 82px 105px 90px;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid #d6e2ed;
  border-radius: 4px;
  color: #52687b;
  background: #fff;
  font-size: 11px;
  text-align: left;
}

.outbound-product-result:hover {
  border-color: #77a8cd;
  background: #f3f9fe;
}

.outbound-product-result:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.outbound-result-main strong {
  color: #203c54;
  font-size: 12px;
}

.outbound-result-main span {
  margin-top: 1px;
  color: #708397;
  font-size: 10.5px;
}

.outbound-result-stock {
  color: #176e57;
  white-space: nowrap;
}

.outbound-location-results {
  grid-template-columns: repeat(auto-fill, minmax(190px, 240px));
}

.outbound-location-result {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid #d6e2ed;
  border-radius: 4px;
  color: #536a7e;
  background: #fff;
  font-size: 10.5px;
  text-align: left;
}

.outbound-location-result:hover,
.outbound-location-result.selected {
  border-color: #3c87bf;
  background: #eef8ff;
}

.outbound-location-result strong {
  color: #203f58;
  font-size: 11.5px;
}

.outbound-location-result.selected::after {
  content: "已选择";
  justify-self: start;
  padding: 1px 5px;
  border-radius: 3px;
  color: #176e57;
  background: #e7f6f0;
  font-size: 9.5px;
}

.outbound-result-empty {
  padding: 9px 10px;
  border: 1px dashed #ccd9e4;
  color: #8091a1;
  background: #fff;
  font-size: 11px;
}

.outbound-research {
  margin-left: auto;
  padding: 2px 7px;
  border: 1px solid #c4d7e7;
  border-radius: 3px;
  color: #2c6e9e;
  background: #fff;
  font-size: 10px;
}

.outbound-selected-location {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.outbound-selected-location > div {
  min-width: 0;
  margin-right: auto;
}

.outbound-selected-location strong,
.outbound-selected-location span {
  display: block;
}

.outbound-selected-location strong {
  color: #29445a;
  font-size: 11.5px;
}

.outbound-selected-location span {
  margin-top: 1px;
  color: #718596;
  font-size: 10.5px;
}

.receipt-packing-table {
  min-width: 1110px;
  table-layout: fixed;
}

.receipt-packing-table th,
.receipt-packing-table td {
  padding-right: 5px;
  padding-left: 5px;
}

.receipt-packing-table th:nth-child(1) { width: 98px; }
.receipt-packing-table th:nth-child(2) { width: 118px; }
.receipt-packing-table th:nth-child(n+3) { width: 58px; }

.receipt-packing-table input[type="number"] {
  width: 62px;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  padding: 4px 5px;
  font-size: 12px;
}

.modal.packing-modal {
  width: min(1240px, calc(100vw - 40px));
}

.modal-mask.putaway-workbench-mask {
  align-items: stretch;
  padding: 16px;
  overflow: hidden;
}

.modal.putaway-workbench {
  width: min(1480px, 100%);
  height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
}

.putaway-workbench .modal-head,
.putaway-workbench .modal-footer {
  flex: none;
}

.putaway-workbench .modal-body {
  min-height: 0;
  max-height: none;
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 14px 16px;
}

.putaway-workbench #putaway-form {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.putaway-workbench #putaway-form > * {
  flex: none;
}

.putaway-workbench #putaway-form > .table-wrap {
  min-height: 180px;
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid #e2eaf2;
  border-radius: 8px;
  background: #fff;
}

.putaway-workbench .putaway-table thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

.putaway-workbench .putaway-table thead th {
  background: #f4f8fc;
  box-shadow: inset 0 -1px 0 #dbe6f0;
}

.putaway-table {
  min-width: 1120px;
}

.putaway-table [data-putaway-qty],
.putaway-table [data-putaway-spec] {
  width: 64px;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  padding: 4px 5px;
  font-size: 12px;
}

.receipt-packing-table .has-packing-conflict td,
.putaway-table .has-packing-conflict td {
  background: #fff7f7;
}

.pick-packing-table {
  min-width: 1110px;
  table-layout: fixed;
}

.pick-packing-table th:nth-child(1) { width: 138px; }
.pick-packing-table th:nth-child(2) { width: 96px; }
.pick-packing-table th:nth-child(n+3) { width: 58px; }

.pick-packing-table input[type="number"] {
  width: 62px;
  min-width: 0;
  height: 30px;
  min-height: 30px;
  padding: 4px 5px;
  font-size: 12px;
}

.pick-packing-table .has-packing-conflict td {
  background: #fff7f7;
}

/* Keep every numeric field at the same five-digit visual width. */
input[type="number"],
.data-table input[type="number"],
.receipt-packing-table input[type="number"],
.pick-packing-table input[type="number"],
.putaway-table [data-putaway-qty],
.putaway-table [data-putaway-spec] {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  flex: 0 0 80px;
  box-sizing: border-box;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1120px) {
  .create-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .create-inbound-meta-grid {
    grid-template-columns: 1fr 1fr;
  }

  .create-workflow-bar .create-flow {
    display: none;
  }
}

@media (max-width: 720px) {
  .document-create-mask {
    padding: 0;
    background: #eef2f7;
  }

  .modal.document-create-modal {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .modal.packing-modal {
    width: 100vw;
    border-radius: 0;
  }

  .modal-mask.putaway-workbench-mask {
    padding: 0;
  }

  .modal.putaway-workbench {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .putaway-workbench .modal-body {
    padding: 10px;
  }

  .document-create-modal .modal-head {
    min-height: 44px;
    padding: 0 12px;
  }

  .create-document-summary {
    padding: 10px 12px;
  }

  .create-meta-grid {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .create-inbound-meta-grid {
    grid-template-columns: 1fr;
  }

  .create-meta-field {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .create-title-note,
  .create-toolbar-hint {
    display: none;
  }

  .create-workflow-bar {
    gap: 12px;
    padding: 5px 12px;
  }

  .create-details {
    padding: 7px 8px 8px;
  }

  .create-line-table {
    min-width: 1080px;
  }

  .create-inbound-line-table {
    min-width: 1160px;
  }

  .document-create-modal .modal-footer {
    min-height: 56px;
    padding: 9px 10px;
  }

  .create-footer-status {
    display: none;
  }

  .create-footer-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .create-btn {
    min-width: 70px;
    padding: 0 11px;
  }

  .create-btn-primary {
    min-width: 100px;
  }
}

@media print {
  @page {
    margin: 12mm;
  }

  body.printing-document {
    overflow: visible;
    background: #fff;
  }

  body.printing-document #app-view,
  body.printing-document #login-view,
  body.printing-document #toast-root,
  body.printing-document #numpad-root {
    display: none !important;
  }

  body.printing-document #modal-root,
  body.printing-document .modal-mask {
    position: static;
    display: block;
    padding: 0;
    background: #fff;
  }

  body.printing-document .modal {
    width: 100%;
    max-width: none;
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.printing-document .modal-head,
  body.printing-document .modal-body {
    padding: 0;
  }

  body.printing-document .modal-head {
    margin-bottom: 12px;
    border-bottom: 2px solid #111;
  }

  body.printing-document .modal-head .icon-btn,
  body.printing-document .modal-footer,
  body.printing-document .review-box {
    display: none !important;
  }

  body.printing-document .modal-body {
    max-height: none;
    overflow: visible;
  }

  body.printing-document .table-wrap {
    overflow: visible;
  }

  body.printing-document .data-table {
    min-width: 0;
    font-size: 10.5px;
  }

  body.printing-document thead {
    display: table-header-group;
  }

  body.printing-document tr {
    break-inside: avoid;
  }

  body.printing-document .batch-grid {
    grid-template-columns: 1fr;
  }
}
