:root {
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafb;
  --text: #1c252c;
  --muted: #62717c;
  --border: #dce2e6;
  --border-strong: #c6d0d7;
  --primary: #176b56;
  --primary-hover: #105845;
  --primary-soft: #e7f2ee;
  --focus: #0d76b7;
  --danger: #a33c30;
  --shadow: 0 12px 32px rgba(28, 37, 44, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(13, 118, 183, 0.25);
  outline-offset: 2px;
}

.app-header {
  color: #ffffff;
  background: #173f3a;
  border-bottom: 4px solid #d2a84e;
}

.header-inner,
main {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 0;
}

.header-inner > div:first-child {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.35;
  font-weight: 600;
  letter-spacing: 0;
}

.header-inner p {
  margin-top: 6px;
  color: #d2dfdc;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.result-total {
  min-width: 104px;
  text-align: right;
}

.result-total strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-total span {
  color: #d2dfdc;
  font-size: 13px;
}

main {
  padding: 24px 0 40px;
}

.query-panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}

label > span,
.search-field > span {
  display: block;
  margin-bottom: 7px;
  color: #40515d;
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
}

input::placeholder {
  color: #89959e;
}

.button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 600;
}

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

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

.button-secondary {
  color: #33434d;
  background: var(--surface);
  border-color: var(--border-strong);
}

.button-secondary:hover {
  background: var(--surface-subtle);
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.results {
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.results-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.results-toolbar p {
  color: var(--muted);
  font-size: 14px;
}

.page-size-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.page-size-label select {
  width: auto;
  height: 36px;
}

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

table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th,
td {
  padding: 12px 10px;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

th {
  color: #41515c;
  background: var(--surface-subtle);
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:hover {
  background: #fbfcfc;
}

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

th:nth-child(1), td:nth-child(1) { width: 90px; }
th:nth-child(2), td:nth-child(2) { width: 64px; }
th:nth-child(3), td:nth-child(3) { width: 80px; }
th:nth-child(4), td:nth-child(4) { width: 72px; }
th:nth-child(5), td:nth-child(5) { width: 72px; }
th:nth-child(6), td:nth-child(6) { width: 92px; }
th:nth-child(7), td:nth-child(7) { width: 360px; }
th:nth-child(8), td:nth-child(8) { width: 72px; }
th:nth-child(9), td:nth-child(9) { width: 104px; }
th:nth-child(10), td:nth-child(10) { width: 160px; }
th:nth-child(11), td:nth-child(11) { width: 128px; }

.number-cell,
.price-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.muted-value {
  color: #929da4;
}

.link-preview {
  display: -webkit-box;
  color: var(--muted);
  line-height: 1.55;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.small-action {
  min-height: 32px;
  padding: 0 10px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid #aac9c0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.small-action:hover {
  background: var(--primary-soft);
}

.small-action:disabled {
  color: #849089;
  background: #eef2f0;
  cursor: default;
}

.small-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
  color: var(--primary);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid #aac9c0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.small-link:hover {
  background: var(--primary-soft);
}

.empty-state {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.empty-state[hidden] {
  display: none;
}

.empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.pagination {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.page-button {
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  color: #40515d;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.page-button:hover:not(:disabled),
.page-button[aria-current="page"] {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.page-button:disabled {
  color: #a2abb1;
  background: #f2f4f5;
  cursor: default;
}

.page-ellipsis {
  min-width: 24px;
  color: var(--muted);
  text-align: center;
}

.detail-dialog {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100% - 40px);
  overflow: auto;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(18, 28, 33, 0.46);
}

.dialog-heading {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.dialog-heading h2 {
  font-size: 18px;
  font-weight: 600;
}

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

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 25px;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.detail-dialog dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  margin: 0;
  padding: 8px 20px;
}

.detail-dialog dt,
.detail-dialog dd {
  margin: 0;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.detail-dialog dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.detail-dialog dd {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px 20px;
}

.merchant-dialog {
  width: min(820px, calc(100% - 32px));
}

.merchant-link-list {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}

.merchant-link-item {
  padding: 14px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.merchant-link-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.merchant-link-heading strong {
  font-size: 14px;
  font-weight: 600;
}

.merchant-link-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.merchant-link-content {
  max-height: 180px;
  margin: 10px 0 12px;
  padding: 10px;
  overflow: auto;
  color: #3f4d55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.edit-form {
  padding: 16px 20px 20px;
}

.edit-form textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

.edit-status {
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
}

.load-error {
  color: var(--danger);
}

@media (max-width: 760px) {
  .header-inner,
  main {
    width: min(100% - 24px, 1480px);
  }

  .header-inner {
    min-height: 84px;
  }

  .search-row {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

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

  .detail-dialog dl {
    grid-template-columns: 90px minmax(0, 1fr);
  }
}

@media (max-width: 440px) {
  .header-inner {
    align-items: flex-end;
    gap: 8px;
  }

  .result-total {
    min-width: 68px;
  }

  h1 {
    font-size: 21px;
  }

  .result-total strong {
    font-size: 22px;
  }

  main {
    padding-top: 14px;
  }

  .query-panel {
    padding: 14px;
  }

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

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

  .pagination {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .detail-dialog dl {
    display: block;
  }

  .detail-dialog dt {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .detail-dialog dd {
    padding-top: 5px;
  }

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