:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --ink: #172033;
  --muted: #64748b;
  --line: #d9e2ec;
  --primary: #1957d2;
  --primary-dark: #123f9b;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #c24141;
  --green: #15803d;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.access-locked .app-shell {
  display: none;
}

.access-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef6ff 0%, #f7fafc 45%, #eef9f3 100%);
}

.access-locked .access-screen {
  display: flex;
}

.access-card {
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-title-block {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 4px;
  text-align: center;
}

.login-brand-logo {
  display: block;
  width: min(300px, 100%);
  height: auto;
  object-fit: contain;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #111827;
  color: #38bdf8;
  font-size: 18px;
  font-weight: 900;
}

.access-card h1 {
  margin: 0;
  color: #111827;
  font-size: 28px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.access-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.login-hint {
  font-size: 12px;
  line-height: 1.55;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  background: #111827;
  color: #f8fafc;
}

.brand {
  display: grid;
  place-items: center;
  min-height: 62px;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
}

.sidebar-brand-logo {
  display: block;
  width: 100%;
  max-width: 204px;
  height: auto;
  object-fit: contain;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #38bdf8;
  color: #082f49;
  font-weight: 800;
}

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

.brand strong {
  font-size: 16px;
}

.brand div span {
  margin-top: 3px;
  color: #b6c4d8;
  font-size: 12px;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #dbe7f5;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #243349;
  color: #ffffff;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

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

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

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #b8c7dc;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.format-select {
  min-width: 132px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.section-head p,
.flow-step p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.scanner-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  background: #ecfdf5;
  color: #166534;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.scanner-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #22c55e;
}

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

.metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 29px;
  line-height: 1;
}

.metric.alert strong {
  color: var(--red);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.tight-head {
  margin-top: 18px;
  margin-bottom: 10px;
}

.button-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-ghost-btn {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 13px;
  font-weight: 700;
}

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

.primary-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn {
  border-color: #bfd0e4;
  background: #fff;
  color: #1d3557;
}

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

.danger-btn {
  border-color: #fecaca;
  color: #b91c1c;
}

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

.ghost-btn,
.danger-ghost-btn {
  width: 100%;
  border-color: #334155;
  background: #172033;
  color: #e2e8f0;
}

.danger-ghost-btn {
  color: #fecaca;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-btn input {
  display: none;
}

.form-grid,
.toolbar,
.scan-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.return-processing-form {
  border-color: #67e8f9;
  background: #ecfeff;
}

.return-batch-form {
  border-color: #c4b5fd;
  background: #f5f3ff;
}

.return-refurbish-form {
  border-color: #86efac;
  background: #f0fdf4;
}

.return-refused-form {
  border-color: #fdba74;
  background: #fff7ed;
}

.settlement-rates-form {
  border-color: #fde68a;
  background: #fffbeb;
}

.backup-settings-form {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

#customerAccountForm .permission-grid {
  display: none;
}

.permission-grid legend {
  padding: 0 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  font-size: 12px;
}

.permission-grid input {
  width: auto;
  min-height: auto;
}

.account-permission-row td {
  padding-top: 0;
  background: #f8fafc;
}

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

.permission-row-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 12px;
}

.permission-row-title span {
  color: var(--muted);
  font-weight: 600;
}

.permission-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 7px 12px;
}

.permission-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  font-size: 12px;
  font-weight: 700;
}

.permission-checks input {
  width: auto;
  min-height: auto;
}

.statement-sheet {
  margin-bottom: 16px;
}

.statement-sheet h3 {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fff7ed;
  font-size: 18px;
  text-align: center;
}

.statement-sheet .table-wrap {
  border-radius: 0 0 8px 8px;
}

.receivable-table {
  min-width: 620px;
}

.receivable-detail-wrap .receivable-table {
  min-width: 420px;
}

.receivable-table th {
  background: #facc15;
  color: #111827;
  text-align: center;
}

.receivable-table td {
  text-align: center;
}

.receivable-table td:nth-child(2) {
  text-align: left;
}

.receivable-total-row td {
  background: #0ea5e9;
  color: #061826;
  font-weight: 800;
}

.toolbar {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.scan-strip {
  grid-template-columns: minmax(220px, 340px) minmax(220px, 340px) minmax(0, 1fr);
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 87, 210, 0.12);
}

input[readonly] {
  background: #f1f5f9;
  color: #475569;
}

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

.selected-box,
.active-order,
.pick-result {
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: #334155;
  font-size: 13px;
}

.compact-box {
  min-width: 220px;
  min-height: 56px;
}

.account-actions {
  align-self: end;
  align-items: end;
}

.active-order {
  margin-bottom: 12px;
  background: #eef6ff;
}

.active-order span {
  display: block;
  margin-top: 6px;
}

.scan-field {
  margin-bottom: 12px;
}

.scan-input {
  border-color: #94a3b8;
  background: #fbfdff;
  font-size: 16px;
}

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

.flow-step {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.flow-step span {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--primary);
  font-weight: 800;
}

.flow-step strong {
  display: block;
  margin-bottom: 8px;
}

.warehouse-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-tile {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

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

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.summary-table-wrap {
  margin-bottom: 14px;
}

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

.all-info-table {
  min-width: 1400px;
}

.warehouse-detail-table {
  min-width: 1440px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #e5edf6;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
}

.return-process-col {
  background: #ecfeff;
}

th.return-process-col {
  background: #cffafe;
}

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

tr.row-alert td {
  background: #fff1f2;
}

tr.row-ok td {
  background: #f0fdf4;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.tag.green {
  background: #dcfce7;
  color: #166534;
}

.tag.red {
  background: #fee2e2;
  color: #991b1b;
}

.tag.amber {
  background: #fef3c7;
  color: #92400e;
}

.tag.teal {
  background: #ccfbf1;
  color: #115e59;
}

.pick-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.2fr);
  gap: 14px;
}

.pick-orders {
  max-height: 520px;
}

.subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 10px;
}

.subhead select {
  max-width: 170px;
}

.pick-result {
  margin-bottom: 12px;
  font-weight: 800;
}

.pick-result.ok {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.pick-result.error {
  border-color: #fca5a5;
  background: #fff1f2;
  color: #991b1b;
}

.pick-result.neutral {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 36px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

.block {
  display: block;
  margin-top: 4px;
}

.prealert-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 800;
}

.prealert-detail-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.prealert-line {
  display: grid;
  gap: 2px;
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}

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

.imei-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
}

.imei-list {
  max-height: 220px;
  margin-top: 8px;
  overflow: auto;
  white-space: pre;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
  color: #334155;
}

.return-imei-cell {
  min-width: 170px;
  max-width: 230px;
  white-space: normal;
}

.return-imei-details summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 700;
  white-space: normal;
}

.return-imei-list {
  display: grid;
  gap: 4px;
  max-height: 118px;
  overflow: auto;
}

.return-imei-details .return-imei-list {
  margin-top: 6px;
}

.return-imei-chip {
  width: max-content;
  max-width: 100%;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  padding: 2px 6px;
  background: #f8fafc;
  color: #1e293b;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.label-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.label-card {
  min-height: 118px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.label-card strong,
.label-card span {
  display: block;
}

.label-card strong {
  margin-bottom: 8px;
  font-size: 16px;
}

.label-card span {
  color: #334155;
  font-size: 12px;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(920px, 100%);
  max-height: min(720px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.password-modal-card {
  width: min(460px, 100%);
}

.single-column {
  grid-template-columns: 1fr;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.warning-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.warning-list span {
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 7px 9px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
}

.import-preview-wrap {
  max-height: 360px;
}

.nowrap {
  white-space: nowrap;
}

.mini-btn {
  min-height: 30px;
  border: 1px solid #bfd0e4;
  border-radius: 8px;
  padding: 0 9px;
  background: #fff;
  color: #1d3557;
  font-size: 12px;
  font-weight: 800;
}

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

.danger-mini-btn {
  border-color: #fecaca;
  color: #b91c1c;
}

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

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: block;
    padding: 14px;
  }

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

  .nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .nav-item {
    white-space: nowrap;
  }

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

  .form-grid,
  .form-grid.compact,
  .toolbar,
  .scan-strip,
  .pick-layout {
    grid-template-columns: 1fr;
  }

  .section-head,
  .topbar,
  .topbar-actions {
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    width: 100%;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

  h1 {
    font-size: 23px;
  }

  .metrics,
  .flow-grid,
  .warehouse-summary {
    grid-template-columns: 1fr;
  }

  .metric {
    padding: 13px;
  }

  table {
    min-width: 680px;
  }
}
