:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7688;
  --line: #e5e9f2;
  --primary: #3b5bdb;
  --primary-dark: #2f4bc0;
  --primary-soft: #eef2ff;
  --success: #0f9d58;
  --warn-bg: #fff8e6;
  --warn-line: #f5c26b;
  --danger: #d64545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.04), 0 8px 24px rgba(20, 30, 60, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}

p {
  margin: 0;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, #2c3e8f 0%, #3b5bdb 55%, #4c6ef5 100%);
  color: #fff;
  padding: 20px 0;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 700;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 0.3px;
}

.brand p {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.78);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  white-space: nowrap;
}

.status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7ef0b5;
  box-shadow: 0 0 0 3px rgba(126, 240, 181, 0.25);
}

.status.is-bad .dot {
  background: #ffb4b4;
  box-shadow: 0 0 0 3px rgba(255, 180, 180, 0.25);
}

/* ---------- 布局 ---------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.filter-card {
  padding: 16px 22px;
}

.card-head {
  margin-bottom: 14px;
}

.card-head.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-head h2 {
  font-size: 16px;
  margin-bottom: 2px;
}

.card-head p {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- 筛选 ---------- */
.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.filter-row:first-child {
  padding-top: 2px;
}

.filter-row:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.filter-label {
  flex: none;
  width: 42px;
  padding-top: 7px;
  font-size: 12px;
  color: var(--muted);
}

.chips-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chip-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  color: #46516a;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.chip-btn:hover {
  border-color: #c3cde6;
  background: #f7f9ff;
}

.chip-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}

.store-block {
  flex: 1;
  min-width: 0;
}

.chips-wrap {
  position: relative;
}

/* 默认只显示 3 行（每行 35px + 间距 8px），超出折叠 */
.chips-wrap.collapsed {
  max-height: 121px;
  overflow: hidden;
}

.expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

.expand-btn .chev {
  transition: transform 0.18s ease;
}

.expand-btn.is-open .chev {
  transform: rotate(180deg);
}

.keyword-input {
  flex: none;
  width: 100%;
  max-width: 280px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: 0.15s ease;
}

.keyword-input:focus,
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.12);
}

/* 搜索按钮与输入框等高 */
.filter-row .btn {
  height: 38px;
  padding: 0 20px;
  margin-top: 0;
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s ease;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  flex: none;
}

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

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

.btn-primary:disabled {
  background: #c9d2ea;
  cursor: not-allowed;
}

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  border-color: #c3cde6;
  background: #f7f9ff;
}

.btn-ghost:disabled {
  color: #b3bccd;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0 4px;
  font-size: 12.5px;
  font-family: inherit;
  text-decoration: none;
}

.btn-link.danger {
  color: var(--danger);
}

.icon-btn {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
}

.icon-btn:hover {
  background: #f2f4f9;
  color: var(--text);
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th,
.table td {
  text-align: center;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}

/* 第一列（会员）左对齐，其余居中 */
.table th:first-child,
.table td:first-child {
  text-align: left;
}

.table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  background: #fafbff;
}

.table tbody tr {
  cursor: pointer;
}

.table tbody tr:hover {
  background: #f8fafe;
}

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

.who strong {
  font-weight: 600;
  display: block;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}

.avatar.lg {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.meta {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.level {
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.lv-black {
  background: #2b2f3a;
  color: #f4d58d;
}

.lv-platinum {
  background: #eef2f8;
  color: #4a5c78;
  border-color: #dbe3ef;
}

.lv-gold {
  background: #fff6e0;
  color: #96650a;
  border-color: #f7e3b5;
}

.lv-normal {
  background: #f4f6fa;
  color: #6b7688;
  border-color: #e5e9f2;
}

.count {
  color: var(--primary);
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px 0;
}

.empty.sm {
  padding: 14px 0;
  font-size: 12.5px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  flex-wrap: wrap;
}

.pager-btns {
  display: flex;
  gap: 8px;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
}

.modal[hidden] {
  display: none;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(19, 26, 45, 0.45);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  width: min(760px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.member-brief {
  display: flex;
  align-items: center;
  gap: 12px;
}

.member-brief h3 {
  font-size: 16px;
}

.modal-body {
  padding: 18px 22px;
  overflow: auto;
}

.modal-body h4 {
  font-size: 13px;
  color: #33405a;
  margin: 4px 0 10px;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fbfcff;
  border-radius: 0 0 16px 16px;
  flex-wrap: wrap;
}

.foot-btns {
  display: flex;
  gap: 10px;
}

/* 历史报告 */
.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  flex-wrap: wrap;
}

.hi-main {
  min-width: 190px;
  flex: 1;
}

.hi-main .hint {
  display: block;
}

.hi-meta {
  font-size: 12.5px;
  color: #46516a;
}

.hi-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.warn-dot {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--warn-bg);
  color: #a8720a;
  font-size: 11px;
  margin-left: 4px;
}

/* 上传区 */
.dropzone {
  border: 1.5px dashed #c3cde6;
  border-radius: 12px;
  background: #fbfcff;
  text-align: center;
  transition: 0.15s ease;
  outline: none;
  padding: 24px 18px;
}

.dropzone.compact {
  padding: 18px 16px;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-icon {
  width: 38px;
  height: 38px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
}

.dropzone-icon.sm {
  width: 30px;
  height: 30px;
  font-size: 15px;
  margin-bottom: 6px;
}

.dropzone-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 9px;
}

.dropzone-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.upload-form {
  display: flex;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 210px;
}

.field.grow {
  flex: 1;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: 0.15s ease;
}

/* 识别结果 */
.parsed-summary {
  margin-top: 16px;
  border: 1px solid #dbe3ff;
  background: #f8faff;
  border-radius: 10px;
  padding: 14px;
}

.ps-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.ps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 620px) {
  .ps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ps-grid div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.ps-grid span {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.ps-grid strong {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chip {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid #dbe3ff;
  background: #eef2ff;
  color: #3b5bdb;
}

.chip.virtual {
  background: #e2f5ea;
  color: #0b7a47;
  border-color: #bde5cf;
}

.chip.real {
  background: #fde3e3;
  color: #b93b3b;
  border-color: #f2bcbc;
}

.ps-issue {
  font-size: 12.5px;
  color: #46516a;
}

.ps-warn {
  margin-top: 8px;
  font-size: 12.5px;
  color: #8a5a00;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 7px 10px;
}

.alert {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  background: #fdecec;
  color: #a53232;
  border: 1px solid #f6c9c9;
}

/* ---------- Toast / loading ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #1f2740;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(20, 30, 60, 0.25);
  z-index: 80;
  max-width: 80vw;
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.spinner.dark {
  border-color: rgba(59, 91, 219, 0.25);
  border-top-color: var(--primary);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
