:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #6b7688;
  --line: #e4e8ef;
  --brand: #2f6bff;
  --brand-dark: #1f4fcc;
  --green: #1ca672;
  --red: #e0556b;
  --amber: #d98a1f;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.06), 0 8px 24px rgba(20, 30, 60, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: inherit;
}
.btn:hover { border-color: #c8cfdb; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); border-color: transparent; }
.btn-danger { color: var(--red); border-color: #f0c4cc; background: #fff5f6; }
.btn-danger:hover { background: #fdeef0; border-color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- login ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef2fb 0%, #e6ecfa 100%);
}
.login-card {
  position: relative;
  width: 360px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
}
.login-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  letter-spacing: 1px;
}
.login-card h1 { font-size: 20px; text-align: center; margin: 0; }
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 24px; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  color: var(--ink);
}
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,0.12); }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }

/* ---------- topbar ---------- */
.topbar {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.wh-select { display: flex; align-items: center; gap: 8px; }
.wh-label { color: var(--muted); font-size: 13px; }
#warehouse-select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.user-box { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--muted); font-size: 13px; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: none; background: transparent;
  text-align: left;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
}
.nav-item:hover { background: #f1f4f9; }
.nav-item.active { background: rgba(47,107,255,0.1); color: var(--brand); font-weight: 600; }
.nav-icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 14px;
  background: rgba(0,0,0,0.05);
}
.nav-item.active .nav-icon { background: var(--brand); color: #fff; }

.main { flex: 1; padding: 24px 28px; overflow: auto; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 15px; margin: 0 0 16px; }
.panel h3 { font-size: 14px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }
.page-title { font-size: 20px; margin: 0 0 20px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
.input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,0.12); }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:disabled, select:disabled { background: #f1f3f7; color: var(--muted); }
.row { display: flex; gap: 12px; align-items: flex-end; }
.row > * { flex: 1; }
.row-auto { flex: 0 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- combobox ---------- */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 240px; overflow: auto; z-index: 20;
}
.combo-item { padding: 9px 12px; cursor: pointer; font-size: 14px; }
.combo-item:hover, .combo-item.active { background: rgba(47,107,255,0.08); }
.combo-item .cid { color: var(--muted); font-size: 12px; margin-left: 6px; }
.combo-new { color: var(--brand); border-top: 1px solid var(--line); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfd; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbfd; }
.empty-row td { text-align: center; color: var(--muted); padding: 28px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- badges / pills ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-open { background: #e8f0ff; color: var(--brand); }
.badge-closed { background: #e9f7f1; color: var(--green); }
.badge-Restock { background: #e9f7f1; color: var(--green); }
.badge-Repack { background: #fff3e0; color: var(--amber); }
.badge-RepackPrint { background: #e8f0ff; color: var(--brand); }
.badge-Discard { background: #fdeef0; color: var(--red); }
.badge-none { background: #eef0f4; color: var(--muted); }

/* ---------- pagination ---------- */
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.pager .info { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar select, .toolbar .input { width: auto; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .input { min-width: 220px; }

/* ---------- return flow ---------- */
.flow-step { margin-bottom: 18px; }
.flow-step.done { opacity: 0.75; }
.flow-step .step-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.step-num { width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.step-num.muted-num { background: #c8cfdb; }
.scan-input { font-size: 16px; padding: 13px 14px; }
.flow-active-card { border: 2px solid rgba(47,107,255,0.3); }
.disp-options { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.disp-btn {
  flex: 1; min-width: 120px;
  padding: 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 15px; font-weight: 600; font-family: inherit;
}
.disp-btn:hover { border-color: var(--brand); }
.disp-btn.sel { border-color: var(--brand); background: rgba(47,107,255,0.08); color: var(--brand); }
.current-track { font-size: 18px; font-weight: 700; }
.kvs { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 6px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 14px; font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1d2433; color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 100; max-width: 80vw;
}
.toast.ok { background: #1ca672; }
.toast.err { background: var(--red); }

/* ---------- audit ---------- */
.audit-detail { color: var(--muted); font-size: 12px; max-width: 420px; white-space: normal; }

/* ---------- language switch ---------- */
.lang-switch, .login-lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.login-lang { position: absolute; top: 14px; right: 14px; }
.lang-btn {
  padding: 5px 9px; font-size: 12px; font-weight: 600; line-height: 1;
  background: #fff; color: var(--muted); border: 0; cursor: pointer; font-family: inherit;
  border-left: 1px solid var(--line);
}
.lang-btn:first-child { border-left: 0; }
.lang-btn.active { background: var(--brand); color: #fff; }
