:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef3f8 0%, var(--bg) 40%);
}

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1180px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 32px 0;
}

.login-panel,
.workbench {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(460px, 100%);
  margin: 8vh auto 0;
  padding: 28px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  font-size: 24px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.stack,
.toolbar {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 14px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.ghost {
  color: #344054;
  background: #eef2f6;
}

.ghost:hover:not(:disabled) {
  background: #e3e8ef;
}

.workbench {
  min-height: calc(100vh - 64px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.toolbar {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  padding: 20px 24px 10px;
  border-bottom: 0;
}

.toolbar-help {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 24px 18px;
  padding: 12px 14px;
  border: 1px solid #99f6e4;
  border-radius: 6px;
  color: #344054;
  background: #f0fdfa;
  font-size: 14px;
  box-shadow: 0 1px 0 var(--line);
}

.toolbar-help strong {
  color: var(--accent-dark);
}

.toolbar-help span {
  padding: 3px 8px;
  border-radius: 4px;
  color: #0f172a;
  background: #ccfbf1;
  font-weight: 800;
}

.toolbar-help em {
  color: var(--muted);
  font-style: normal;
}

.search-box {
  grid-column: span 2;
}

.block-keywords {
  grid-column: span 2;
}

.range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.range-inputs input {
  min-width: 0;
  padding: 0 10px;
}

.summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 24px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pager button {
  height: 34px;
}

.page-size-control {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.page-size-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.page-size-control select {
  width: 92px;
  height: 34px;
}

.progress-panel {
  padding: 12px 24px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.progress-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.progress-line span:first-child {
  color: #344054;
  font-weight: 700;
}

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e4e7ec;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #475467;
  background: #f8fafc;
  font-size: 13px;
}

th:nth-child(1),
td:nth-child(1) {
  min-width: 300px;
}

th:nth-child(2),
td:nth-child(2) {
  min-width: 92px;
}

th:nth-child(3),
td:nth-child(3),
th:nth-child(4),
td:nth-child(4) {
  min-width: 100px;
}

th:nth-child(5),
td:nth-child(5) {
  min-width: 120px;
}

th:nth-child(6),
td:nth-child(6) {
  min-width: 88px;
}

.goods-name {
  font-weight: 700;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.goods-name a,
.key-link {
  color: var(--ink);
  text-decoration: none;
}

.goods-name a:hover,
.key-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 58px;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.detail-link:hover {
  background: var(--accent-dark);
}

.goods-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 58px;
  height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

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

.badge.empty-stock {
  color: var(--warn);
  background: #fef0c7;
}

.badge.offline {
  color: #344054;
  background: #e4e7ec;
}

.badge.muted {
  color: #6941c6;
  background: #ebe9fe;
}

.price {
  font-weight: 800;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 16px;
  border-radius: 8px;
  color: #fff;
  background: #1d2939;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .app {
    width: min(100vw - 20px, 1180px);
    padding: 10px 0;
  }

  .login-panel {
    margin-top: 4vh;
    padding: 20px;
  }

  .topbar,
  .summary {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .summary {
    padding: 14px 16px;
  }

  .pager {
    justify-content: space-between;
  }

  table {
    min-width: 780px;
  }
}
