:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d7e2f0;
  --line-strong: #b9c9dc;
  --text: #102033;
  --muted: #5d7088;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --red: #b91c1c;
  --amber: #b45309;
  --nav: #101928;
  --nav-soft: #1d2939;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: #fff;
  padding: 18px 12px 14px;
  overflow: hidden;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 16px;
  flex: 0 0 auto;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  background: #fff;
  color: var(--nav);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
}

.brand-name {
  font-weight: 800;
  font-size: 28px;
  line-height: 1;
}

.brand-subtitle {
  color: #c9d5e7;
  margin-top: 6px;
  font-size: 13px;
}

.module-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.module-nav::-webkit-scrollbar {
  width: 8px;
}

.module-nav::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 8px;
}

.nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #e7eef9;
  text-align: left;
  padding: 10px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 2px;
}

.nav-button:hover,
.nav-button.active {
  background: var(--nav-soft);
  color: #fff;
}

.side-card {
  flex: 0 0 auto;
  border: 1px solid #334155;
  background: #162235;
  border-radius: 7px;
  padding: 10px;
  margin-top: 10px;
}

.side-title {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 8px;
}

.side-input {
  width: 100%;
  min-height: 32px;
  border: 1px solid #cdd8e6;
  border-radius: 4px;
  padding: 7px 9px;
  margin-bottom: 6px;
  background: #fff;
  color: #0f172a;
}

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 6px 0;
}

.side-note {
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

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

.page-root {
  min-height: calc(100vh - 28px);
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--muted);
  margin-top: 6px;
}

.header-actions,
.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  margin-bottom: 12px;
}

.panel.tight {
  padding: 10px;
}

.panel-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800;
}

.hint {
  color: var(--muted);
  line-height: 1.55;
}

.button {
  border: 1px solid #c7d5e8;
  background: #edf4ff;
  color: #102033;
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
}

.button:hover {
  border-color: #9bb2d0;
}

.button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

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

.button.success {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.button.danger {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.button.ghost {
  background: #eef4fb;
  color: #102033;
}

.button.full {
  width: 100%;
}

.button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}

.tab-button {
  border: 1px solid #c9d8eb;
  background: #fff;
  color: #18324f;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
}

.tab-button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.grid-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.warehouse-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 360px;
  gap: 12px;
  align-items: start;
}

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

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

.form-field label {
  display: block;
  font-weight: 700;
  color: #334155;
  margin-bottom: 5px;
}

.input {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cdd8e6;
  border-radius: 5px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

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

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

.data-table th,
.data-table td {
  padding: 10px 9px;
  border-bottom: 1px solid #e7eef7;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  background: #f0f5fb;
  font-weight: 800;
}

.data-table tr:hover td {
  background: #f8fbff;
}

.data-table tr.selected td {
  background: #eaf2ff;
}

.pager {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 0 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  min-width: 48px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8f7ef;
  color: #047857;
  font-weight: 800;
}

.image-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
}

.target-image-box {
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbff;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.target-image-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.match-list {
  display: grid;
  gap: 8px;
  max-height: 610px;
  overflow-y: auto;
}

.match-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 8px;
  cursor: pointer;
}

.match-card:hover,
.match-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .12);
}

.match-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: #eef4fb;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.match-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rank {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
}

.match-title {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.45;
}

.cart-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: grid;
  place-items: center;
  z-index: 50;
}

.cart-modal {
  width: min(720px, calc(100vw - 36px));
  max-height: calc(100vh - 60px);
  overflow: auto;
  background: #fff;
  border-radius: 9px;
  border: 1px solid var(--line);
  padding: 18px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .22);
}

.cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 82px;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid #e6eef8;
  padding: 10px 0;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}

.toast {
  position: fixed;
  top: 14px;
  right: 18px;
  min-width: 260px;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: 7px;
  background: #102033;
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .2);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: .18s ease;
}

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

.status-line {
  border: 1px solid #cfe0f5;
  background: #f5f9ff;
  border-radius: 7px;
  padding: 10px 12px;
  color: #214263;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.control-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

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

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

.check-card strong {
  display: block;
  margin-bottom: 6px;
}

@media (max-width: 1180px) {
  .warehouse-layout,
  .image-workbench,
  .grid-two,
  .grid-three,
  .module-check-grid {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: relative;
    height: auto;
    min-height: 0;
  }

  .module-nav {
    max-height: 260px;
  }
}
