:root {
  --bg: #f4f7f8;
  --surface: #fff;
  --text: #14212b;
  --muted: #60717c;
  --line: #dce6e8;
  --teal: #0f827c;
  --red: #bd3d3d;
  --amber: #bc7a19;
  --green: #2f855a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 33, 43, 0.56);
  backdrop-filter: blur(6px);
}

.login-overlay[hidden] {
  display: none;
}

body.auth-locked {
  grid-template-columns: 1fr;
}

body.auth-locked .sidebar,
body.auth-locked .main {
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  width: min(420px, calc(100vw - 28px));
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(20, 38, 50, 0.26);
}

.login-card h1 {
  margin-bottom: 6px;
  font-size: 24px;
}

.login-card p {
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
}

.sidebar {
  background: #17242b;
  color: #fff;
  padding: 22px 14px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  padding: 8px 8px 20px;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #a8b8bd;
  font-size: 13px;
  font-weight: 500;
}

.nav {
  width: 100%;
  border: 0;
  margin: 4px 0;
  padding: 12px;
  border-radius: 8px;
  text-align: left;
  color: #d8e4e7;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.nav.active,
.nav:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

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

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-name {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.primary,
.ghost {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

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

.primary:disabled,
.ghost:disabled {
  opacity: 0.68;
  cursor: not-allowed;
}

.danger-button {
  background: var(--red);
}

.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(20, 38, 50, 0.05);
}

.metric {
  min-height: 110px;
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
}

.grid {
  display: grid;
  gap: 14px;
}

.two {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

input {
  min-height: 38px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

textarea {
  min-height: 86px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  resize: vertical;
  font: inherit;
}

input:disabled {
  background: #eef3f4;
  color: #8a9aa1;
  cursor: not-allowed;
}

select {
  min-height: 38px;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
}

.area-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.area {
  min-height: 124px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.area:hover {
  border-color: var(--teal);
  box-shadow: 0 10px 28px rgba(15, 130, 124, 0.12);
  transform: translateY(-1px);
}

.area strong {
  display: block;
  font-size: 18px;
}

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

.area-total {
  flex: 0 0 auto;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
}

.area-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.area small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
}

.inventory-summary {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

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

.area-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 14px;
}

.area-tab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.area-tab.active,
.area-tab:hover {
  border-color: var(--teal);
  background: #eefaf8;
  color: var(--teal);
}

.inventory-area-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.inventory-area-card {
  display: grid;
  gap: 14px;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.inventory-area-card:hover {
  border-color: var(--teal);
  box-shadow: 0 10px 28px rgba(15, 130, 124, 0.1);
}

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

.inventory-area-card strong {
  margin-bottom: 4px;
  font-size: 18px;
}

.inventory-area-card span {
  color: var(--muted);
  line-height: 1.4;
}

.area-card-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.area-card-metrics span {
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e7eef0;
  color: #334650;
  font-size: 12px;
  font-weight: 800;
}

.area-card-metrics .warn-text {
  background: #fff0cf;
  color: var(--amber);
}

.selected-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.selected-area h3 {
  margin-bottom: 4px;
  font-size: 18px;
}

.selected-area p {
  color: var(--muted);
}

.inventory-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.status-card {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status-card span {
  color: var(--muted);
  font-size: 13px;
}

.status-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.label-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.label-note {
  display: grid;
  gap: 4px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #b9d8d4;
  border-radius: 8px;
  background: #eefaf8;
}

.label-note strong {
  color: var(--teal);
}

.label-note span {
  color: #334650;
  line-height: 1.6;
}

.muted-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.label-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.transaction-toolbar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin: 12px 0 14px;
}

.transaction-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.transaction-toolbar input,
.transaction-toolbar select {
  width: 100%;
}

.table-actions label,
.file-picker {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.file-picker input {
  padding: 7px;
  background: #fff;
}

.busy-box strong::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: busyDots 1.2s steps(4, end) infinite;
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
}

@keyframes busyDots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.import-result {
  margin-top: 12px;
}

.import-list {
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  padding-left: 18px;
}

.import-list li {
  margin: 4px 0;
  line-height: 1.45;
}

.download-fallback {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.import-list .ok {
  color: #0f5f5a;
}

.import-list .fail {
  color: #9d2f2f;
}

.item-create-form {
  border-top: 0;
}

.created-item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.created-item img {
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.created-item strong,
.created-item span,
.created-item small {
  display: block;
}

.created-item strong {
  margin-bottom: 8px;
  font-size: 20px;
  line-height: 1.35;
}

.created-item span {
  margin-bottom: 8px;
  color: var(--teal);
  font-weight: 900;
  word-break: break-word;
}

.created-item small {
  color: var(--muted);
  line-height: 1.6;
}

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

.created-batch-head strong,
.created-batch-head span,
.created-batch-head small {
  display: block;
}

.created-batch-head strong {
  margin-bottom: 6px;
  font-size: 20px;
  line-height: 1.35;
}

.created-batch-head span {
  margin-bottom: 4px;
  color: var(--teal);
  font-weight: 900;
  word-break: break-word;
}

.created-batch-head small {
  color: var(--muted);
  line-height: 1.5;
}

.created-location-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}

.created-location-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.created-location-card img {
  width: 100%;
  max-width: 128px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

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

.created-location-card strong {
  font-size: 15px;
  line-height: 1.35;
}

.created-location-card span {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  word-break: break-word;
}

.stack-form {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.stack-form:first-of-type {
  border-top: 0;
}

.stack-form h3 {
  font-size: 17px;
}

.stack-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.area-choice-group {
  display: grid;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfd;
}

.area-choice-group legend {
  padding: 0 6px;
  color: #3d515b;
  font-size: 13px;
  font-weight: 800;
}

.area-choice-grid {
  display: grid;
  gap: 8px;
}

.area-choice-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack-form label.area-choice {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.stack-form label.area-choice:hover {
  border-color: #8fc8c4;
  background: #f5fbfa;
}

.stack-form label.area-choice:has(input:checked) {
  border-color: var(--teal);
  background: #eaf8f6;
  box-shadow: 0 0 0 2px rgba(15, 130, 124, 0.1);
}

.area-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-marker {
  width: 18px;
  height: 18px;
  border: 2px solid #a8b8bd;
  border-radius: 50%;
  background: #fff;
}

.area-choice:has(input:checked) .choice-marker {
  border: 5px solid var(--teal);
}

.choice-content {
  display: grid;
  gap: 3px;
}

.choice-content strong {
  color: #243943;
  font-size: 14px;
  line-height: 1.3;
}

.choice-content small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.form-row input,
.form-row textarea,
.stack-form input,
.stack-form textarea,
.stack-form select {
  min-width: 0;
  width: 100%;
}

.autocomplete-input {
  position: relative;
  display: block;
  width: 100%;
}

.autocomplete-input input {
  position: relative;
  z-index: 1;
  background: transparent;
}

.autocomplete-ghost {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: transparent;
  font: inherit;
  white-space: pre;
  pointer-events: none;
  overflow: hidden;
}

.autocomplete-ghost .typed {
  color: transparent;
}

.autocomplete-ghost .suffix {
  color: rgba(96, 113, 124, 0.42);
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.wide-field {
  grid-column: span 2;
}

.checkbox-field {
  align-self: start;
}

.checkbox-field span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  min-width: 0;
  min-height: 0;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

.area-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.area-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.area-chip.active,
.area-chip:hover {
  border-color: var(--teal);
  background: #eefaf8;
}

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

.area-chip em {
  grid-column: 1;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.area-chip b {
  grid-row: 1 / span 3;
  grid-column: 2;
  align-self: center;
  border: 1px solid #efb4b4;
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.rack-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.rack-card {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 1.6fr;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

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

.rack-card span {
  color: var(--muted);
  font-size: 13px;
}

.rack-stats {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.rack-stats span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7eef0;
  color: #334650;
  font-weight: 800;
}

.danger-link {
  min-height: 28px;
  border: 1px solid #efb4b4;
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

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

.label-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
}

.label-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.label-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.label-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.label-check input {
  min-width: 0;
  min-height: 0;
}

.label-preview {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 12px;
  align-items: center;
}

.label-preview img {
  width: 104px;
  height: 104px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

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

.label-preview strong {
  font-size: 18px;
  margin-bottom: 6px;
}

.label-preview span {
  color: var(--text);
  font-weight: 800;
  margin-bottom: 6px;
}

.label-preview small {
  color: var(--muted);
  line-height: 1.5;
}

.binding-mode {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  margin: 14px 0;
  border-radius: 8px;
  background: #e7eef0;
}

.mode-btn {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.mode-btn.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 38, 50, 0.08);
}

.binding-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.binding-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.binding-result {
  min-height: 58px;
}

.success-box,
.error-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
}

.success-box {
  border: 1px solid #9ad5cb;
  background: #e6f7f3;
  color: #0f5f5a;
}

.error-box {
  border: 1px solid #efb4b4;
  background: #fff0f0;
  color: #9d2f2f;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 33, 43, 0.42);
}

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

.modal-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 64px rgba(20, 38, 50, 0.24);
  padding: 20px;
}

.modal-dialog h2 {
  font-size: 21px;
  line-height: 1.3;
}

.modal-dialog .modal-message {
  margin-top: 10px;
  font-size: 15px;
  line-height: 1.6;
}

.modal-dialog .modal-detail {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
}

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

.finalize-form .field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.finalize-form .field-wide {
  grid-column: 1 / -1;
}

.finalize-form .field span {
  color: var(--muted);
}

.finalize-form input,
.finalize-form select,
.finalize-form textarea {
  width: 100%;
  border-radius: 8px;
}

.modal-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.modal-dialog .modal-content {
  margin-top: 4px;
}

.modal-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #efb4b4;
  border-radius: 8px;
  background: #fff0f0;
  color: #9d2f2f;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e1f4ef;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.badge.warn {
  color: var(--amber);
  background: #fff0cf;
}

.badge.danger {
  color: var(--red);
  background: #ffe2e2;
}

.badge.ok {
  color: var(--green);
  background: #e7f6ed;
}

.badge.neutral {
  color: #60717c;
  background: #e7eef0;
}

.small-btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.users-grid.two {
  grid-template-columns: minmax(0, 1.45fr) minmax(380px, 0.85fr);
}

.wecom-config {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.config-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.config-card.ready {
  border-color: #9ad5cb;
  background: #e6f7f3;
}

.config-card.warn {
  border-color: #f0c27c;
  background: #fff8e7;
}

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

.config-card strong {
  margin-bottom: 4px;
}

.config-card span {
  color: #334650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 13px;
}

.user-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.user-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.users-table {
  min-width: 860px;
}

.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 18%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 24%;
}

.users-table th:nth-child(6),
.users-table td:nth-child(6) {
  width: 92px;
}

.user-area-editor {
  display: grid;
  gap: 10px;
}

.user-area-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.user-area-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.user-area-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 30px;
  padding: 4px 6px 4px 10px;
  border-radius: 999px;
  background: #e6f7f3;
  color: #075b56;
  font-size: 13px;
  font-weight: 800;
}

.user-area-tag button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 130, 124, 0.14);
  color: #075b56;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.card {
  padding: 14px;
}

.card h3 {
  margin-bottom: 8px;
}

.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.card-topline h3 {
  margin-bottom: 0;
}

.card p {
  color: var(--muted);
  line-height: 1.6;
}

.card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.table-wrap.has-column-filter {
  padding-bottom: 170px;
}

.compact-table-wrap {
  overflow-x: hidden;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pager button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.pager button:disabled {
  color: #aab7bc;
  cursor: not-allowed;
}

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

.compact-table {
  min-width: 0;
  table-layout: fixed;
}

.location-table th:nth-child(1),
.location-table td:nth-child(1) {
  width: 44%;
}

.location-table th:nth-child(2),
.location-table td:nth-child(2) {
  width: 22%;
}

.location-table th:nth-child(3),
.location-table td:nth-child(3),
.location-table th:nth-child(4),
.location-table td:nth-child(4) {
  display: none;
}

.location-table th:nth-child(5),
.location-table td:nth-child(5) {
  width: 34%;
}

.location-table td {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.location-table .badge {
  max-width: 100%;
  white-space: normal;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

td strong,
td span,
td small {
  display: block;
}

td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

td {
  vertical-align: top;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  background: #f8fafb;
  position: relative;
}

.column-filter-trigger {
  width: 100%;
  min-height: 28px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.column-filter-trigger span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.column-filter-icon {
  flex: 0 0 auto;
  color: #1493a3;
  font-size: 12px;
}

th.column-filter-active {
  color: var(--text);
  background: #e7f7fa;
}

.column-filter-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 8px;
  width: 240px;
  padding: 12px;
  border: 1px solid #a8d7df;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(20, 62, 72, 0.18);
  color: var(--text);
}

.column-filter-popover label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.column-filter-popover input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.status-filter-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.column-filter-popover .status-filter-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  background: #f9fbfb;
}

.status-filter-option input {
  min-height: 0;
  width: 14px;
  min-width: 14px;
  height: 14px;
  padding: 0;
}

.column-sort-actions,
.column-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.column-sort-actions {
  justify-content: stretch;
  margin-bottom: 10px;
}

.column-sort-actions button {
  flex: 1;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.column-sort-actions button.active {
  border-color: #1493a3;
  background: #e7f7fa;
  color: #0f6f7d;
}

.column-filter-actions button {
  min-height: 32px;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

tr.risk-active td {
  background: #fff8dc;
}

tr.risk-overdue td {
  background: #fff0f0;
}

tr.risk-active td:first-child {
  box-shadow: inset 4px 0 0 var(--amber);
}

tr.risk-overdue td:first-child {
  box-shadow: inset 4px 0 0 var(--red);
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .brand {
    flex: 0 0 auto;
    padding: 0 8px 0 0;
    margin-right: 4px;
    font-size: 18px;
    line-height: 1.1;
  }

  .brand span {
    white-space: nowrap;
  }

  .nav {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    white-space: nowrap;
    padding: 10px 12px;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }

  .top-actions {
    justify-content: space-between;
    width: 100%;
  }

  .metrics,
  .two,
  .users-grid.two,
  .area-map,
  .inventory-area-grid,
  .inventory-status-grid,
  .transaction-toolbar,
  .form-row,
  .rack-card,
  .label-grid,
  .binding-form,
  .created-item {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 12px;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .inventory-actions {
    justify-content: stretch;
  }

  .inventory-actions > * {
    width: 100%;
  }

  .selected-area {
    flex-direction: column;
    align-items: stretch;
  }

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

  .config-grid,
  .user-toolbar {
    grid-template-columns: 1fr;
  }

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

  .area-chip {
    width: 100%;
  }

  .rack-stats {
    justify-content: flex-start;
  }

  .label-preview {
    grid-template-columns: 92px 1fr;
  }

  .label-preview img,
  .created-item img {
    width: 92px;
    height: 92px;
  }

  .created-location-card img {
    max-width: 96px;
  }

  .binding-mode {
    width: 100%;
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-btn {
    width: 100%;
  }

  .modal-dialog {
    width: min(100%, 420px);
    padding: 14px;
    border-radius: 10px;
  }

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

  table {
    min-width: 680px;
  }

  .compact-table {
    min-width: 0;
  }

  .location-table th:nth-child(1),
  .location-table td:nth-child(1) {
    width: 50%;
  }

  .location-table th:nth-child(2),
  .location-table td:nth-child(2),
  .location-table th:nth-child(3),
  .location-table td:nth-child(3),
  .location-table th:nth-child(4),
  .location-table td:nth-child(4) {
    display: none;
  }

  .location-table th:nth-child(5),
  .location-table td:nth-child(5) {
    width: 50%;
  }
}

@media (max-width: 640px) {
  body {
    background: #eef3f2;
  }

  .sidebar {
    gap: 6px;
    padding: 10px 10px 8px;
    background: rgba(23, 36, 43, 0.97);
  }

  .brand {
    font-size: 16px;
  }

  .brand span {
    display: none;
  }

  .nav {
    min-height: 34px;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 13px;
  }

  .nav.active {
    color: #17242b;
    background: #fff;
  }

  .main {
    padding: 8px 10px 16px;
  }

  .topbar {
    gap: 8px;
    margin-bottom: 10px;
    padding: 2px 2px 0;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .topbar p {
    display: none;
  }

  .top-actions {
    gap: 8px;
  }

  .login-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions .primary {
    min-height: 34px;
    padding: 7px 12px;
  }

  .grid {
    gap: 10px;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .metric {
    min-height: 72px;
    padding: 10px;
    box-shadow: none;
  }

  .metric strong {
    margin-top: 6px;
    font-size: clamp(21px, 8vw, 28px);
    line-height: 1;
  }

  .metric span {
    font-size: 12px;
  }

  #view-dashboard .two {
    display: block;
  }

  #view-dashboard .panel {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #view-dashboard .panel + .panel {
    margin-top: 14px;
  }

  #view-dashboard .panel h2 {
    padding: 0 2px 8px;
    font-size: 17px;
  }

  #view-dashboard .area-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 0;
  }

  #view-dashboard .area {
    min-height: 118px;
    padding: 11px;
    border: 0;
    box-shadow: 0 6px 18px rgba(20, 38, 50, 0.07);
  }

  #view-dashboard .area:nth-child(2n) {
    transform: translateY(8px);
  }

  #view-dashboard .area:hover {
    transform: translateY(-1px);
  }

  #view-dashboard .area:nth-child(2n):hover {
    transform: translateY(6px);
  }

  .area-head {
    display: grid;
    gap: 5px;
    margin-bottom: 10px;
  }

  .area strong {
    font-size: 16px;
    line-height: 1.25;
  }

  .area-total {
    font-size: 18px;
  }

  .area-flags {
    gap: 5px;
  }

  .area small {
    margin-top: 9px;
    font-size: 12px;
  }

  #view-dashboard .list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 0;
  }

  #view-dashboard .card {
    min-height: 116px;
    padding: 11px;
    border: 0;
    box-shadow: 0 6px 18px rgba(20, 38, 50, 0.07);
  }

  #view-dashboard .card:nth-child(2n) {
    transform: translateY(8px);
  }

  .card-topline {
    display: grid;
    gap: 7px;
  }

  .card h3 {
    font-size: 15px;
    line-height: 1.35;
  }

  .card p,
  .card small {
    font-size: 12px;
  }

  .inventory-status-grid {
    grid-template-columns: 1fr 1fr;
  }

  .status-card {
    min-height: 72px;
    padding: 10px;
  }

  .status-card strong {
    font-size: 22px;
  }

  .panel,
  .card {
    border-radius: 6px;
  }

  .area,
  .inventory-area-card,
  .created-item,
  .label-card,
  .rack-card,
  .area-chip,
  .stack-form input,
  .stack-form select,
  input,
  select,
  .primary,
  .ghost,
  .danger-link,
  .area-tab,
  .pager button,
  .mode-btn {
    border-radius: 6px;
  }

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

  .label-preview,
  .created-item {
    gap: 10px;
  }

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

  .created-batch-head {
    flex-direction: column;
    align-items: stretch;
  }

  .created-item strong {
    font-size: 18px;
  }

  .table-wrap {
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 12px;
  }

  table {
    min-width: 620px;
  }

  .location-table th:nth-child(1),
  .location-table td:nth-child(1) {
    width: 58%;
  }

  .location-table th:nth-child(5),
  .location-table td:nth-child(5) {
    width: 42%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}
