:root {
  --ink: #1c1916;
  --muted: #6d655c;
  --line: #e3d9cc;
  --paper: #f3eee6;
  --card: #fffdf9;
  --green: #1a2420;
  --green-2: #24574a;
  --copper: #c56a3a;
  --copper-deep: #9a4e28;
  --danger: #9d2c2c;
  --ok: #1f7a4d;
  --shadow: 0 16px 40px rgba(48, 36, 22, 0.08);
  --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "Cascadia Mono", "Sarasa Mono SC", "Source Han Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(28, 36, 33, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 36, 33, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 40px;
  align-items: center;
  padding: 48px 8vw;
}
.brand-kicker {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: var(--copper-deep);
  font-size: 13px;
}
.login-copy h1 {
  margin: 0;
  font-size: clamp(48px, 6vw, 76px);
  letter-spacing: -0.04em;
  line-height: 1;
}
.lead {
  max-width: 36rem;
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
}
.steps {
  list-style: none;
  padding: 0;
  margin: 28px 0 0;
  display: grid;
  gap: 10px;
}
.steps li {
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(255, 253, 249, 0.8);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  max-width: 420px;
}
.steps span {
  flex: none;
  background: var(--green);
  color: #f6f1e8;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-card h2 { margin: 0 0 4px; font-size: 22px; }

.shell { display: flex; min-height: 100vh; }
aside {
  width: 232px;
  flex: none;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--green);
  color: #f4efe6;
  padding: 18px 12px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 18px; }
.brand strong { display: block; font-size: 18px; }
.brand small { color: #c9c1b4; }
aside nav { display: grid; gap: 4px; }
aside nav button {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #ddd6cb;
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
}
aside nav button.active { background: rgba(255, 255, 255, 0.08); color: white; }
aside nav button.active::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e08a55;
  margin-right: 8px;
}
.aside-foot { margin-top: auto; display: grid; gap: 8px; padding: 12px 8px 4px; }
.aside-foot small { color: #c9c1b4; }
.logout {
  background: transparent;
  color: #f4efe6;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 8px 12px;
}
.main { flex: 1; min-width: 0; padding: 28px 32px 72px; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.eyebrow { margin: 0 0 4px; color: var(--copper-deep); font-size: 13px; letter-spacing: 0.08em; }
.top h1 { margin: 0; font-size: 32px; letter-spacing: -0.03em; }
#header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid transparent;
  background: var(--green);
  color: #f6f3ec;
  border-radius: 999px;
  padding: 9px 14px;
  line-height: 1.2;
}
.btn.copper { background: var(--copper); }
.btn.copper:hover { background: var(--copper-deep); }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn.danger { background: transparent; color: var(--danger); border-color: transparent; padding-inline: 8px; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid #ddd4c6;
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--ink);
}
.dialog select { width: 0; min-width: 100%; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.picker { position: relative; min-width: 0; }
.picker-value, .picker-option {
  width: 100%;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  border-radius: 12px;
}
.picker-value {
  border: 1px solid #ddd4c6;
  background: white;
  padding: 10px 12px;
}
.picker.is-disabled .picker-value { background: #f7f4ee; cursor: default; }
.picker-menu {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 4px;
}
.picker-option { border: 0; background: transparent; padding: 8px 10px; }
.picker-option.on, .picker-option:hover { background: #f6f1e8; }
.form-error { min-height: 1.2em; margin: 0; color: var(--danger); font-size: 14px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat, .card, .goods-card, .panel, .dialog, .login-card {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat { border-radius: 18px; padding: 16px 16px 14px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 6px; font-size: 30px; letter-spacing: -0.04em; }
.stat em { font-style: normal; color: var(--muted); font-size: 13px; }

.panel-block, .card, .goods-card {
  border-radius: 18px;
  padding: 16px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin: 22px 0 10px;
}
.section-head h2 { margin: 0; font-size: 18px; }
.search-bar, .filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}
.search-bar input, .filters input, .filters select {
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
.search-bar input { flex: 1; min-width: 220px; }

.list { display: grid; gap: 10px; }
.goods-card { display: grid; gap: 8px; }
.goods-top, .card-top, .row-actions, .stepper {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.row-actions { flex-wrap: wrap; }
.row-actions > span:last-child { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.goods-top h3, .card h3 { margin: 0; font-size: 18px; }
.sku { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 13px; }
.loc { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: #f4efe6;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 13px;
}
.chip b { font-family: var(--mono); font-weight: 650; overflow-wrap: anywhere; }
.card h3, .goods-top h3 { overflow-wrap: anywhere; }
.chip span { color: var(--muted); margin-left: 4px; }
.stepper { justify-content: flex-start; gap: 8px; }
.stepper button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
}
.muted { color: var(--muted); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card p { margin: 6px 0; color: var(--muted); }

.empty {
  border: 1px dashed #d3c8b8;
  border-radius: 18px;
  padding: 28px 18px;
  text-align: center;
  background: rgba(255, 253, 249, 0.65);
}
.empty h3 { margin: 0 0 6px; }
.diagram {
  display: grid;
  grid-template-columns: 28px repeat(4, 1fr);
  gap: 6px;
  max-width: 360px;
  margin-top: 8px;
}
.diagram i {
  display: block;
  height: 28px;
  border-radius: 6px;
  background: #efe7dc;
  border: 1px solid var(--line);
  font-style: normal;
}
.diagram i.on { background: #f6dfd0; border-color: #e2b79a; }
.diagram b { font-size: 12px; color: var(--muted); align-self: center; }

.rack-scroll { overflow-x: auto; padding-bottom: 8px; }
.rack {
  background:
    linear-gradient(#d5cec2, #d5cec2) 0 0 / 8px 100% no-repeat,
    linear-gradient(#d5cec2, #d5cec2) 100% 0 / 8px 100% no-repeat,
    #e7e1d6;
  border-radius: 18px;
  padding: 14px 16px 10px;
  min-width: calc(72px + var(--cols) * 108px);
}
.rack-row {
  display: grid;
  grid-template-columns: 64px repeat(var(--cols), minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.layer-label, .col-head {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}
button.cell {
  text-align: left;
  border-radius: 12px;
  border: 1px solid #ddd4c8;
  background: rgba(255, 253, 249, 0.78);
  min-height: 84px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
button.cell b { font-size: 14px; line-height: 1.3; }
button.cell small { color: var(--muted); }
button.cell.busy {
  background: #fff8f3;
  border-color: #e2b79a;
  box-shadow: inset 3px 0 0 var(--copper);
}
button.cell:hover { transform: translateY(-1px); }
.cell-pos { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.map-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 8px; }
.map-tools .field { min-width: 180px; }
.legend { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: -1px; }
.swatch.is-empty { background: #fffdf9; border: 1px solid #ddd4c8; }
.swatch.is-busy { background: #fff8f3; border: 1px solid #e2b79a; box-shadow: inset 3px 0 0 var(--copper); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

#drawer, #modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
}
@media (min-width: 981px) {
  #drawer { left: 232px; }
}
#modal { z-index: 40; align-items: center; justify-content: center; padding: 18px; }
.backdrop { background: rgba(22, 18, 14, 0.38); }
#drawer .backdrop { flex: 1; }
.panel {
  width: min(440px, 100%);
  background: #fffdf9;
  overflow: auto;
  padding: 22px 20px 32px;
  box-shadow: var(--shadow);
}
.dialog {
  width: min(680px, calc(100vw - 36px));
  max-height: min(88vh, 820px);
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 20px;
  padding: 20px;
  background: var(--card);
}
.dialog h2, .panel h2 { margin: 0 0 6px; }
.dialog-actions, .panel-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.loc-banner {
  background: #f6f1e8;
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--green);
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  z-index: 50;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .login { grid-template-columns: 1fr; padding: 28px 18px 40px; gap: 18px; }
  .login-copy h1 { font-size: 48px; }
  .shell { flex-direction: column; }
  aside {
    width: auto;
    height: auto;
    position: sticky;
    z-index: 5;
    padding: 10px;
  }
  .brand small, .aside-foot small { display: none; }
  aside nav { display: flex; overflow: auto; }
  aside nav button { width: auto; white-space: nowrap; }
  .aside-foot { margin-top: 0; padding: 0; }
  .main { padding: 18px 14px 48px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .top { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
