:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #6b7686;
  --line: #d9e0e9;
  --line2: #e8edf3;
  --primary: #1f5fbf;
  --primary-dark: #17498f;
  --primary-weak: #e9f0fb;
  --green: #1f8a5b;
  --green-weak: #e8f5ee;
  --amber: #b7791f;
  --amber-weak: #fdf4e3;
  --red: #c23b3b;
  --red-weak: #fbecec;
  --sidebar: #172131;
  --sidebar-hover: #1d293b;
  --sidebar-active: #223149;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 框架 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0;
  width: 208px; z-index: 50;
  background: var(--sidebar);
  display: flex; flex-direction: column;
}
.main { flex: 1; min-width: 0; margin-left: 208px; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: 54px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.content { padding: 16px 20px 40px; }

/* ---------- 侧边栏 ---------- */
.side-brand {
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid #243147;
}
.d-mark {
  display: block; flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 5px;
  border: 1px solid #33415a;
}
.side-brand-text b { display: block; color: #f0f4fa; font-size: 14px; line-height: 1.25; }
.side-brand-text span { display: block; color: #7e8da2; font-size: 10px; letter-spacing: .3px; }
.side-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.side-nav button {
  width: 100%; height: 38px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border: 0; border-left: 3px solid transparent;
  background: transparent; color: #aab6c6;
  font-size: 13px; text-align: left;
}
.side-nav button svg {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}
.side-nav button:hover { background: var(--sidebar-hover); color: #e5ecf6; }
.side-nav button.active {
  background: var(--sidebar-active);
  border-left-color: #6b9bff;
  color: #fff;
}
.side-foot { flex-shrink: 0; padding: 12px 16px 15px; border-top: 1px solid #243147; }
.erp-pill {
  display: block; width: 100%;
  padding: 6px 9px;
  border: 1px solid #34445c; border-radius: 4px;
  background: #1d293b; color: #9fb0c6;
  font-size: 11.5px; text-align: left;
}
.erp-pill:hover { border-color: #4a5e7a; color: #d5dfec; }
.erp-pill.on { border-color: #256b4d; background: #173a2c; color: #79d3aa; }
.erp-pill.warn { border-color: #6b4e20; background: #352a17; color: #e0b36a; }

/* ---------- 顶栏 ---------- */
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.back-btn {
  height: 28px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 4px;
  background: #fff; color: var(--muted);
  font-size: 12px; white-space: nowrap;
}
.back-btn:hover:not(:disabled) { color: var(--ink); border-color: #a9b6c8; background: #f7f9fc; }
.back-btn:disabled { opacity: .45; cursor: not-allowed; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.crumb i { font-style: normal; color: #b3bcc8; }
.crumb b { color: var(--ink); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.search-box { display: flex; gap: 6px; }
.search-box input {
  width: 240px; height: 32px;
  padding: 0 10px;
  border: 1px solid #c9d2de; border-radius: 4px;
  background: #fff; outline: none;
  font-size: 12.5px;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  height: 32px; padding: 0 13px;
  border: 1px solid #c9d2de; border-radius: 4px;
  background: #fff; color: var(--ink);
  font-size: 12.5px; white-space: nowrap;
}
.btn:hover { border-color: #a9b6c8; background: #f7f9fc; }
.btn:active { background: #eef2f7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--red); border-color: #e4b7b7; }
.btn-danger:hover { background: var(--red-weak); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #e4b7b7; }
.btn.danger:hover { background: var(--red-weak); }
.input {
  height: 32px; padding: 0 10px;
  border: 1px solid #c9d2de; border-radius: 4px;
  background: #fff; outline: none; font-size: 12.5px;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.check input { accent-color: var(--primary); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  width: 28px; height: 28px;
  border: 0; border-radius: 4px; background: transparent;
  color: var(--muted); font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: #eef2f7; color: var(--ink); }

/* ---------- 汇总条 ---------- */
.ops-bar {
  display: flex; align-items: stretch;
  min-height: 56px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-bottom: 12px;
  overflow: hidden;
}
.ops-item {
  padding: 7px 18px;
  border-right: 1px solid var(--line2);
  display: flex; flex-direction: column; justify-content: center;
  min-width: 92px;
}
.ops-item span { font-size: 10.5px; color: var(--muted); }
.ops-item b { font-family: var(--mono); font-size: 19px; line-height: 1.3; font-weight: 600; }
.ops-item.good b { color: var(--green); }
.ops-item.warn b { color: var(--amber); }
.ops-item.bad b { color: var(--red); }
.ops-progress {
  flex: 1; min-width: 150px;
  padding: 10px 18px;
  border-right: 1px solid var(--line2);
  display: flex; flex-direction: column; justify-content: center;
}
.ops-progress .cap { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 4px; }
.track { height: 6px; background: #e3e9f1; border-radius: 2px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--primary); }
.ops-sync {
  padding: 7px 18px;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 126px; text-align: right;
}
.ops-sync b { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.ops-sync span { font-size: 10.5px; color: var(--muted); }

.notice {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px;
  border: 1px solid #ead6a8;
  border-left: 3px solid var(--amber);
  background: #fdf8ec;
  color: #7a5310;
  font-size: 12.5px;
  border-radius: 4px;
  margin-bottom: 10px;
}
.notice.bad { border-color: #ecc0c0; border-left-color: var(--red); background: var(--red-weak); color: #962c2c; }
.notice .link-btn { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---------- 货架地图 ---------- */
.floor-head { display: flex; align-items: baseline; gap: 8px; margin: 16px 0 8px; }
.floor-head:first-child { margin-top: 0; }
.floor-head h3 {
  margin: 0; padding-left: 8px;
  border-left: 3px solid var(--primary);
  font-size: 13px; font-weight: 700; line-height: 1.2;
}
.floor-head span { font-size: 10.5px; color: var(--muted); }
.rack-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 10px 14px;
  align-items: start;
}
.row-group {
  min-width: 0;
  padding: 7px 8px 8px;
  background: #f7f9fc;
  border: 1px solid #e1e7ef;
  border-radius: 5px;
}
.row-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; }
.row-head b { font-size: 11.5px; color: #4a5668; }
.row-head span { font-size: 10px; color: var(--muted); }
.rack-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.rack-card {
  min-width: 0;
  padding: 5px 6px 6px;
  background: #fff;
  border: 1px solid #dce2ea;
  border-radius: 4px;
}
.rack-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 4px;
  margin-bottom: 4px; padding-bottom: 4px;
  border-bottom: 1px solid #eef1f5;
}
.rack-head b { font-family: var(--mono); font-size: 13px; letter-spacing: .3px; }
.rack-meta { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.rack-meta strong { color: var(--green); font-weight: 600; }
.rack-meta strong.full { color: var(--red); }
.rack-slots { display: flex; flex-direction: column; gap: 3px; }
.slot {
  display: flex; align-items: center; gap: 4px;
  width: 100%; min-height: 28px; min-width: 0;
  padding: 1px 5px;
  border: 1px solid #e7ebf1; border-radius: 3px;
  background: #fff;
  text-align: left;
  transition: .1s;
}
.slot:hover { border-color: #9fb7dd; background: #f7faff; }
.slot-level { width: 20px; flex-shrink: 0; font-family: var(--mono); font-size: 9px; color: #929baa; }
.slot-main { flex: 1; min-width: 0; }
.slot-main b {
  display: block;
  font-family: var(--mono); font-size: 11px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-main span {
  display: block; font-size: 9.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot.empty .slot-main b { color: #a4adbb; font-family: inherit; font-size: 10.5px; font-weight: 400; }
.slot.used {
  background: #eaf1fd;
  border-color: #c4d6f4;
  box-shadow: inset 2px 0 0 var(--primary);
}
.slot.used .slot-main b { color: #163f80; font-weight: 700; }
.slot.used:hover { background: #e1ecff; }
.slot-more {
  flex-shrink: 0;
  padding: 0 3px;
  border-radius: 2px;
  background: #cfdefa; color: #1b4b99;
  font-family: var(--mono); font-size: 9px;
}
.slot.flash { animation: flash .9s ease 2; }
@keyframes flash { 0%, 100% { box-shadow: inset 2px 0 0 var(--primary); } 50% { box-shadow: 0 0 0 3px rgba(31, 95, 191, .3); } }
.map-legend { display: flex; align-items: center; gap: 16px; padding: 10px 2px 0; font-size: 11.5px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.dot.empty { background: #fff; border: 1px solid #cfd6e4; }
.dot.used { background: #cfe0ff; border: 1px solid #a9c6ff; }
.map-legend .legend-note { margin-left: auto; }

/* ---------- 页面标题 / 表格 ---------- */
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  margin: 2px 0 12px; flex-wrap: wrap;
}
.section-head h1 { margin: 0; font-size: 16px; font-weight: 700; }
.section-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  padding: 7px 10px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px; font-weight: 600;
  text-align: left; white-space: nowrap;
}
.data-table td { padding: 7px 10px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f9fbff; }
.data-table .num { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.data-table .nowrap { white-space: nowrap; }
.data-table .muted-cell { color: var(--muted); font-size: 11.5px; }
.data-table tr.erp-row-off td { color: #a6adba; }
.order-shelf { font-family: var(--mono); font-weight: 700; color: #1b4b99; }
.order-shelf.none { color: #9aa3b2; font-family: inherit; font-weight: 400; }
.empty-state { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 10.5px; font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}
.badge.in { background: var(--green-weak); color: var(--green); }
.badge.void { background: #f0f2f6; color: #7b8494; }
.badge.soft { background: #eef2f7; color: #59657a; font-weight: 500; }
.badge.hin { background: var(--green-weak); color: var(--green); }
.badge.hmove { background: var(--primary-weak); color: var(--primary); }
.badge.hout { background: var(--red-weak); color: var(--red); }
.badge.hrein { background: var(--amber-weak); color: var(--amber); }

.history-strip {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 14px; margin-bottom: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 5px;
  font-size: 11.5px; color: var(--muted);
}
.history-strip b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.history-strip .sep { color: #c4cbd5; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding-top: 10px; font-size: 11.5px; color: var(--muted); }
.history-place { font-family: var(--mono); font-size: 11.5px; }
.history-place .arrow { color: #9aa3b2; padding: 0 3px; }
.log-head {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
  font-size: 11.5px; font-weight: 600; color: #4a5668;
}

/* ---------- 设置 ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 14px 16px;
}
.panel-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line2);
}
.panel-title h2 {
  margin: 0; padding-left: 8px;
  border-left: 3px solid var(--primary);
  font-size: 13.5px; font-weight: 700; line-height: 1.2;
}
.hint { font-size: 11.5px; color: var(--muted); line-height: 1.7; margin: 8px 0 0; }
.hint b { color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; margin: 12px 0; }
.form-grid label { display: block; font-size: 11px; color: var(--muted); }
.form-grid input {
  width: 100%; height: 32px; margin-top: 3px;
  padding: 0 9px;
  border: 1px solid #c9d2de; border-radius: 4px;
  background: #fff; outline: none;
}
.form-grid input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.shelf-list-simple { margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line); }
.cred-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.erp-account-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.erp-conn-line { display: flex; align-items: center; gap: 10px; padding: 5px 0 8px; }
.erp-avatar-sm {
  width: 34px; height: 34px; border-radius: 5px;
  background: var(--green-weak); color: var(--green);
  display: grid; place-items: center; font-weight: 700;
}
.erp-conn-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- 登录 ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 300;
  background: var(--sidebar);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: min(360px, 92vw);
  padding: 28px 26px 20px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo { width: 44px; height: 44px; border-radius: 6px; border: 1px solid #33415a; }
.login-card h1 { margin: 12px 0 2px; font-size: 19px; }
.login-sub { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.login-card input {
  width: 100%; height: 36px; margin-bottom: 10px;
  padding: 0 10px;
  border: 1px solid #c9d2de; border-radius: 4px;
  outline: none;
}
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-weak); }
.login-card .btn { width: 100%; height: 36px; }
.login-error { min-height: 18px; margin-top: 8px; font-size: 12px; color: var(--red); }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal-card {
  width: min(540px, 100%);
  max-height: 90vh;
  display: flex; flex-direction: column;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
}
.modal-card.wide { width: min(860px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.modal-head .muted { margin-top: 2px; }
.modal-body { padding: 15px 16px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
}
.modal-error {
  margin-top: 10px; padding: 8px 10px;
  background: var(--red-weak); color: #962c2c;
  border-radius: 4px; font-size: 12px; word-break: break-all;
}

/* ---------- 货位明细弹窗 ---------- */
.order-card {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: #f8faff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
}
.order-card-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.order-card-top b { font-family: var(--mono); font-size: 13px; }
.order-card-top .style { font-size: 12px; color: #44506a; }
.order-card-meta { margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.order-card-note {
  margin-top: 5px; padding: 4px 7px;
  background: var(--amber-weak); color: #7a5310;
  border-radius: 3px; font-size: 11.5px;
}

/* ---------- 提示 ---------- */
.toast-root { position: fixed; top: 66px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 7px; }
.toast {
  max-width: 380px;
  padding: 8px 12px;
  border-radius: 4px;
  background: #1f2937; color: #fff;
  font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .25);
}
.toast.err { background: #a52f2f; }
.toast.ok { background: #176a4b; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .settings-grid { grid-template-columns: 1fr; }
  .search-box input { width: 170px; }
}
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar {
    position: static; width: auto; height: auto;
    flex-direction: row; align-items: center;
  }
  .side-brand { border-bottom: 0; padding: 0 10px; height: 56px; }
  .d-mark { width: 28px; height: 28px; }
  .side-brand-text { display: none; }
  .side-nav { display: flex; flex: 1; padding: 0; height: 56px; }
  .side-nav button { width: auto; height: 56px; padding: 0 12px; border-left: 0; border-bottom: 3px solid transparent; }
  .side-nav button.active { border-left: 0; border-bottom-color: #6b9bff; }
  .side-nav button svg { width: 15px; height: 15px; }
  .side-foot { display: none; }
  .main { margin-left: 0; }
  .topbar { height: auto; min-height: 52px; flex-wrap: wrap; padding: 7px 12px; }
  .content { padding: 12px 12px 30px; }
  .rack-group-grid { grid-template-columns: 1fr; }
  .rack-grid { grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
  .ops-bar { flex-wrap: wrap; }
  .ops-item { flex: 1; min-width: 90px; border-bottom: 1px solid var(--line2); }
  .ops-progress { flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line2); }
  .ops-sync { margin-left: auto; }
  .search-box input { width: 150px; }
}
