:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #dce5e7;
  --text: #1d2527;
  --muted: #6d7f82;
  --accent: #1d9aa6;
  --accent-dark: #137780;
  --warn: #c65f00;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.topbar {
  padding: 18px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 760;
}

h2 {
  font-size: 17px;
}

.topbar p,
label,
.panel-head span {
  color: var(--muted);
}

button,
.button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  text-decoration: none;
}

button:hover,
.button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

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

button.danger {
  border-color: #efc9c0;
  color: #b74732;
}

button.danger:hover {
  border-color: #d86c57;
  color: #9e321f;
}

button.small {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

button:disabled {
  border-color: #e1e7e8;
  background: #f3f5f5;
  color: #98a5a7;
  cursor: not-allowed;
}

main {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 18px 24px 36px;
}

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

.metrics div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics div {
  padding: 14px 16px;
}

.metrics span {
  display: block;
  min-height: 34px;
  font-size: 25px;
  font-weight: 780;
  color: var(--accent-dark);
}

.panel {
  margin-top: 16px;
  overflow: hidden;
}

.data-panel {
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--line);
  background: #fbfdfd;
}

.tab {
  height: 38px;
  border-color: transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-color: var(--line);
  border-bottom-color: #ffffff;
  background: #ffffff;
  color: var(--accent-dark);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 + span {
  display: block;
  margin-top: 4px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.inline-field input {
  width: 76px;
  height: 36px;
}

input {
  width: min(420px, 100%);
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.product-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex: 1 1 760px;
  flex-wrap: wrap;
}

.product-tools input {
  flex: 1 1 260px;
  min-width: 180px;
}

.page-info {
  min-width: 150px;
  text-align: center;
  white-space: nowrap;
}

.page-jump {
  width: 72px;
  min-width: 72px;
  height: 28px;
  text-align: center;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fbfdfd;
}

.table-wrap {
  overflow: auto;
  max-height: 470px;
}

.table-wrap.compact {
  max-height: 420px;
}

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

.merchant-table {
  min-width: 1120px;
}

.product-table {
  min-width: 1660px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid #edf2f2;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f8fbfb;
  color: #425356;
  font-size: 12px;
  z-index: 1;
}

.th-filter {
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 12px;
  text-align: left;
}

.th-filter::after {
  content: "筛";
  display: inline-block;
  margin-left: 5px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #edf2f2;
  color: #7a8b8d;
  font-size: 10px;
}

.th-filter.filtered {
  color: var(--accent-dark);
}

.th-filter.filtered::after {
  background: #dff2f4;
  color: var(--accent-dark);
}

.filter-popover {
  position: fixed;
  z-index: 20;
  width: 280px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 32px rgba(22, 37, 40, 0.16);
}

.filter-title {
  margin-bottom: 10px;
  font-weight: 760;
}

.filter-body {
  display: grid;
  gap: 10px;
}

.filter-body label {
  display: grid;
  gap: 5px;
  color: var(--text);
  font-size: 12px;
}

.filter-body input,
.filter-body select {
  width: 100%;
}

.filter-tip {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.filter-body .check-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-body .check-line input {
  width: 16px;
  height: 16px;
}

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

td a {
  color: var(--accent-dark);
  font-weight: 650;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.merchant-table .select-col,
.merchant-table td:first-child {
  width: 72px;
  text-align: center;
}

.merchant-table th:nth-child(2),
.merchant-table td:nth-child(2) {
  width: 220px;
}

.merchant-table th:nth-child(3),
.merchant-table td:nth-child(3) {
  width: 240px;
}

.merchant-table th:nth-child(4),
.merchant-table td:nth-child(4) {
  width: 180px;
}

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

.merchant-table th:nth-child(6),
.merchant-table td:nth-child(6) {
  width: auto;
}

.merchant-table th:nth-child(7),
.merchant-table td:nth-child(7) {
  width: 100px;
  text-align: right;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  vertical-align: middle;
}

.product-table th:nth-child(1),
.product-table td:nth-child(1) {
  width: 130px;
}

.product-table th:nth-child(2),
.product-table td:nth-child(2) {
  width: 300px;
}

.product-table th:nth-child(8),
.product-table td:nth-child(8),
.product-table th:nth-child(9),
.product-table td:nth-child(9) {
  width: 112px;
}

.product-table th:nth-child(3),
.product-table td:nth-child(3),
.product-table th:nth-child(4),
.product-table td:nth-child(4),
.product-table th:nth-child(5),
.product-table td:nth-child(5),
.product-table th:nth-child(6),
.product-table td:nth-child(6),
.product-table th:nth-child(7),
.product-table td:nth-child(7) {
  width: 92px;
}

.product-table th:nth-child(10),
.product-table td:nth-child(10) {
  width: 76px;
}

.product-table th:nth-child(11),
.product-table td:nth-child(11) {
  width: 110px;
}

.product-table th:nth-child(12),
.product-table td:nth-child(12),
.product-table th:nth-child(13),
.product-table td:nth-child(13) {
  width: 86px;
}

.product-table th:nth-child(14),
.product-table td:nth-child(14) {
  width: 120px;
}

.product-table th:nth-child(15),
.product-table td:nth-child(15),
.product-table th:nth-child(16),
.product-table td:nth-child(16) {
  width: 78px;
}

.merchant-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 28px;
  border: 1px solid #b8dadd;
  border-radius: 6px;
  background: #edf8f9;
  color: var(--accent-dark);
}

.open-link:hover {
  background: #dff2f4;
  text-decoration: none;
}

.muted,
.note-text {
  color: var(--muted);
}

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef5f5;
  color: #53696c;
  font-size: 12px;
}

.status.success {
  background: #e9f8ef;
  color: #247346;
}

.status.failed {
  background: #fff2e7;
  color: var(--warn);
}

.adapter {
  display: inline-block;
  min-width: 86px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #edf7f2;
  color: #247346;
  font-size: 12px;
  text-align: center;
}

.adapter.unsupported {
  background: #f3f5f5;
  color: #7a888a;
}

.logs {
  height: 210px;
  overflow: auto;
  padding: 12px 16px;
  background: #101618;
  color: #d7e4e5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.7;
}

.logs div.error {
  color: #ffb199;
}

.logs div.success {
  color: #95e1b5;
}

@media (max-width: 860px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .product-tools {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .pagination-bar {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .toolbar {
    justify-content: flex-start;
  }
}
