:root {
  --canvas: #f4f7f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --text: #182230;
  --text-soft: #475467;
  --muted: #667085;
  --line: #d9e1e7;
  --line-strong: #becbd4;
  --accent: #0f766e;
  --accent-strong: #0b5d57;
  --accent-soft: #e6f5f2;
  --blue: #1769aa;
  --blue-soft: #eaf3fb;
  --success: #087443;
  --success-soft: #ddf5e6;
  --warning: #a75b08;
  --warning-soft: #fff0d5;
  --danger: #b42318;
  --danger-soft: #fee9e7;
  --shadow: 0 14px 32px rgba(24, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.28);
  outline-offset: 2px;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  letter-spacing: 0;
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
}

.hidden {
  display: none !important;
}

.login-panel {
  width: min(470px, 100%);
  margin: clamp(28px, 11vh, 110px) auto 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-lockup,
.app-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  font-size: 23px;
  font-weight: 800;
}

.brand-mark-small {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  font-size: 18px;
}

.eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.08em;
}

.brand-lockup h1 {
  margin-top: 2px;
  font-size: 28px;
  line-height: 1.2;
}

.brand-copy {
  margin-top: 5px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 17px;
  margin-top: 30px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder {
  color: #98a2b3;
}

input:hover,
select:hover {
  border-color: #93a4b1;
}

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

.platform-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #a8d7cf;
  border-radius: 6px;
  color: var(--text-soft);
  background: var(--accent-soft);
}

.platform-field span {
  font-size: 13px;
  font-weight: 700;
}

.platform-field strong {
  color: var(--accent-strong);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
  line-height: 1;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button-primary {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button-secondary {
  color: var(--text-soft);
  border-color: var(--line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled),
.button-tertiary:hover:not(:disabled) {
  color: var(--text);
  border-color: #aebdc8;
  background: #eef3f5;
}

.button-tertiary {
  color: var(--text-soft);
  border-color: var(--line);
  background: var(--surface-muted);
}

.button-danger {
  color: var(--danger);
  border-color: #f4c7c3;
  background: var(--danger-soft);
}

.button-danger:hover:not(:disabled) {
  color: #8f1d15;
  border-color: #ebaaa4;
  background: #fbdad7;
}

.login-submit {
  width: 100%;
  margin-top: 4px;
}

.login-note {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.workbench {
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.app-brand h1 {
  margin-top: 1px;
  font-size: 20px;
  line-height: 1.15;
}

.header-actions,
.pager,
.result-metrics,
.result-toolbar,
.result-actions,
.active-filters {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 12px;
}

.account-status {
  max-width: min(360px, 38vw);
  overflow: hidden;
  color: var(--text-soft);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--success);
  content: "";
}

.query-panel {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: #fcfdfd;
}

.query-row {
  display: grid;
  grid-template-columns: minmax(220px, 2.2fr) minmax(110px, 0.8fr) minmax(130px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.query-row .button {
  height: 42px;
  white-space: nowrap;
}

.search-field {
  min-width: 0;
}

.search-submit {
  min-width: 106px;
}

.filter-toggle {
  min-width: 94px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px 12px;
  align-items: end;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed #c9d5dd;
}

.price-range {
  grid-column: span 1;
}

.range-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

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

.clear-filters {
  justify-self: end;
  min-width: 100px;
}

.active-filters {
  min-height: 0;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 24px 0;
  background: var(--surface);
}

.filter-chip {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  border: 1px solid #bedbd5;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 800;
}

button.filter-chip {
  cursor: pointer;
}

button.filter-chip:hover {
  border-color: #82bfb4;
  background: #d8efe9;
}

.filter-chip .chip-close {
  color: var(--accent-strong);
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}

.progress-panel {
  margin: 18px 24px 0;
  padding: 13px 14px;
  border: 1px solid #b6d7ed;
  border-radius: 6px;
  background: var(--blue-soft);
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-soft);
  font-size: 13px;
}

.progress-heading span:first-child {
  color: var(--blue);
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #cddfea;
}

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

.results-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.results-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px 15px;
}

.results-header h2 {
  font-size: 17px;
  line-height: 1.25;
}

.results-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.result-metrics {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.result-metrics span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.result-metrics b {
  color: var(--text);
  font-size: 17px;
}

.result-toolbar {
  justify-content: space-between;
  gap: 14px;
  padding: 11px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.page-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.page-size-control select {
  width: 88px;
  height: 34px;
  padding: 0 8px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.pager {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pager .button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

#pageText {
  min-width: 74px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

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

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

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

th {
  color: var(--text-soft);
  background: #fbfcfd;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover:not(:has(.empty)) {
  background: #f8fbfa;
}

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

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

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

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

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

.goods-name {
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 800;
  line-height: 1.45;
}

.goods-name a,
.key-link {
  color: inherit;
  text-decoration: none;
}

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

.goods-meta {
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  color: var(--success);
  background: var(--success-soft);
}

.badge.empty-stock {
  color: var(--warning);
  background: var(--warning-soft);
}

.badge.offline {
  color: #4b5563;
  background: #e9edf0;
}

.badge.muted {
  color: var(--blue);
  background: var(--blue-soft);
}

.stock-value {
  color: var(--text-soft);
  font-weight: 800;
}

.price {
  color: #9a4a05;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.key-link {
  overflow-wrap: anywhere;
  color: var(--blue);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.result-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.copy-button,
.detail-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.copy-button {
  border: 1px solid var(--line-strong);
  color: var(--text-soft);
  background: var(--surface);
}

.copy-button:hover {
  border-color: #aebdc8;
  background: #eef3f5;
}

.detail-link {
  color: #ffffff;
  border: 1px solid var(--accent);
  background: var(--accent);
}

.detail-link:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.empty {
  height: 250px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(400px, calc(100vw - 32px));
  border: 1px solid #aebbc6;
  border-radius: 7px;
  padding: 12px 14px;
  color: #ffffff;
  background: #344054;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
}

.toast.success {
  border-color: var(--success);
  background: var(--success);
}

.toast.info {
  border-color: var(--blue);
  background: var(--blue);
}

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

.clipboard-helper {
  position: fixed;
  top: -1000px;
  left: -1000px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1080px) {
  .query-row {
    grid-template-columns: minmax(200px, 2fr) minmax(110px, 1fr) minmax(130px, 1fr) auto;
  }

  .filter-toggle {
    grid-column: 4;
  }

  .search-submit {
    grid-column: 3;
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .clear-filters {
    justify-self: stretch;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .login-panel {
    width: calc(100% - 24px);
    margin-top: 24px;
    padding: 24px 20px;
  }

  .workbench {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .app-header,
  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header,
  .query-panel,
  .results-header,
  .result-toolbar {
    padding-right: 16px;
    padding-left: 16px;
  }

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

  .account-status {
    max-width: calc(100vw - 140px);
  }

  .query-row,
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .search-submit,
  .filter-toggle {
    grid-column: auto;
  }

  .filter-panel {
    margin-top: 16px;
    padding-top: 16px;
  }

  .price-range,
  .block-keywords {
    grid-column: auto;
  }

  .clear-filters {
    justify-self: stretch;
  }

  .active-filters {
    padding-right: 16px;
    padding-left: 16px;
  }

  .progress-panel {
    margin-right: 16px;
    margin-left: 16px;
  }

  .progress-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .results-header {
    gap: 12px;
  }

  .result-metrics {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .result-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .table-wrap {
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody tr {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }

  tbody tr:hover:not(:has(.empty)) {
    background: transparent;
  }

  tbody tr:last-child {
    border-bottom: 0;
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 12px;
    min-width: 0 !important;
    padding: 7px 0;
    border: 0;
  }

  td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 800;
  }

  td:first-child {
    display: block;
    padding-top: 0;
  }

  td:first-child::before {
    display: none;
  }

  td:last-child {
    padding-bottom: 0;
  }

  .empty {
    display: flex !important;
    min-height: 190px;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    text-align: center;
  }

  .empty::before {
    display: none;
  }
}

@media (max-width: 420px) {
  .brand-lockup h1 {
    font-size: 25px;
  }

  .login-panel {
    padding: 22px 16px;
  }

  .pager {
    gap: 6px;
  }

  .pager .button {
    padding: 0 8px;
  }

  #pageText {
    min-width: 65px;
    font-size: 12px;
  }
}
