:root {
  --bg: #f5f6f7;
  --panel: #ffffff;
  --border: #e5e6eb;
  --border-soft: #f0f1f5;
  --text: #1d2129;
  --text-2: #4e5969;
  --muted: #86909c;
  --placeholder: #a9aeb8;
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --green: #00b42a;
  --orange: #ff7d00;
  --red: #f53f3f;
  --gray: #86909c;
  --radius: 4px;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;
  --row-grid: 44px 96px 120px 96px 132px minmax(150px, 1.2fr) 76px 82px minmax(150px, 1.4fr) 128px 88px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: rgba(22, 119, 255, 0.18);
}

/* 顶栏 */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

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

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* 页面容器 */
.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 20px 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(29, 33, 41, 0.03);
  overflow: hidden;
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-box {
  position: relative;
  flex: none;
  width: 340px;
  max-width: 100%;
}

.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 32px;
  padding: 0 12px 0 33px;
  border: 1px solid #d9dce3;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-box input::placeholder {
  color: var(--placeholder);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.search button {
  height: 32px;
  padding: 0 18px;
  border: 0;
  border-radius: 3px;
  background: var(--primary);
  color: #fff;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

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

.search button:focus-visible {
  outline: 2px solid rgba(22, 119, 255, 0.4);
  outline-offset: 1px;
}

.search button:disabled {
  background: #94bfff;
  cursor: not-allowed;
}

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

/* 提示条 */
.notice {
  margin: 12px 16px 0;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 3px;
  background: #f7f8fa;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.7;
}

.notice.is-error {
  border-left-color: var(--red);
  background: #fff2f0;
  color: #cb2634;
}

.notice a {
  color: var(--primary);
  text-decoration: none;
}

.notice a:hover {
  text-decoration: underline;
}

/* 结果 */
.result {
  padding-bottom: 4px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--muted);
}

.result-count {
  color: var(--text-2);
  font-weight: 500;
}

.result-time {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.result-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.result-sources {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 3px;
  background: #eef2f7;
  color: #334558;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.source-chip--failed {
  background: #fdecea;
  color: #b3261e;
}

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

.table-head,
.row {
  display: grid;
  grid-template-columns: var(--row-grid);
  align-items: center;
  gap: 0;
  min-width: 1180px;
  padding: 0 16px;
}

.table-head {
  height: 38px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
}

.th {
  padding: 0 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.th-index {
  color: var(--muted);
  font-family: var(--mono);
}

.row {
  min-height: 50px;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s;
  animation: row-in 0.3s both;
}

.row:last-child {
  border-bottom: 0;
}

.row:hover {
  background: #f7f8fa;
}

.cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 9px 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cell-index {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.cell-id {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
}

.cell-platform {
  color: var(--text-2);
}

.cell-source {
  color: var(--text-2);
  font-size: 11.5px;
}

.src {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  height: 20px;
  padding: 0 6px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.src--primary {
  background: #eaf1fb;
  color: #1c4f9c;
}

.src--secondary {
  background: #f3eefb;
  color: #5b3f9e;
}

.src--dual {
  background: linear-gradient(90deg, #eaf1fb 0 50%, #f3eefb 50% 100%);
  color: #3f3d7a;
}

.cell-none {
  color: var(--muted);
}

.cell-account strong {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.cell-course {
  color: var(--text);
  font-weight: 500;
}

.cell-remarks {
  color: var(--text-2);
  font-size: 12px;
}

.cell-time {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.cell-action {
  display: flex;
  align-items: center;
}

.btn-budan {
  height: 26px;
  padding: 0 9px;
  border: 1px solid var(--primary);
  border-radius: 3px;
  background: var(--panel);
  color: var(--primary);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-budan:hover:not(:disabled) {
  background: rgba(22, 119, 255, 0.08);
}

.btn-budan:active:not(:disabled) {
  background: rgba(22, 119, 255, 0.14);
}

.btn-budan:disabled {
  border-color: var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
}

/* 进度环 */
.progress {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.progress-ring {
  position: relative;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}

.progress-text {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
}

.progress--none {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

/* 状态 */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.status i {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gray);
}

.status--ok { color: var(--green); }
.status--ok i { background: var(--green); }

.status--doing { color: var(--primary); }
.status--doing i { background: var(--primary); }

.status--warn { color: var(--orange); }
.status--warn i { background: var(--orange); }

.status--danger { color: var(--red); }
.status--danger i { background: var(--red); }

.status--refund { color: var(--gray); }
.status--refund i { background: var(--gray); }

/* 空态 */
.empty {
  padding: 64px 24px 60px;
  text-align: center;
  color: var(--muted);
}

.empty svg {
  width: 42px;
  height: 42px;
  color: #c9cdd4;
}

.empty p {
  margin: 14px 0 0;
  font-size: 13px;
}

.footer {
  padding: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--placeholder);
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 窄屏：表格转卡片 */
@media (max-width: 920px) {
  .app {
    padding: 12px 12px 24px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .search {
    width: 100%;
  }

  .search-box {
    flex: 1;
    width: auto;
  }

  .toolbar-hint {
    display: none;
  }

  .table-head {
    display: none;
  }

  .result-head {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
  }

  .result-meta {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .result-sources {
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 4px;
  }

  .source-chip {
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
  }

  .result-time {
    font-size: 10px;
  }

  .row {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    padding: 14px 14px 16px;
    align-items: start;
  }

  .cell {
    display: block;
    padding: 0;
    white-space: normal;
    overflow: visible;
  }

  .cell::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    font-family: var(--sans);
    font-size: 11px;
    color: var(--muted);
  }

  .cell-index {
    display: none;
  }

  .cell-remarks {
    grid-column: auto;
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 30, 0.45);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 20px 22px;
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg);
}

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

.modal-value {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.modal-tip {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-btn {
  height: 32px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.modal-btn-cancel {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-2);
}

.modal-btn-cancel:hover {
  background: var(--bg);
}

.modal-btn-confirm {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
}

.modal-btn-confirm:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.modal-btn-confirm:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* QQ / 微信内置浏览器引导页 */
.open-tip {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: rgba(15, 20, 30, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.open-tip.hidden {
  display: none;
}

.open-tip-card {
  width: 100%;
  max-width: 360px;
  padding: 26px 22px 24px;
  border-radius: 10px;
  background: var(--panel);
  text-align: center;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  animation: modal-in 0.18s ease-out;
}

.open-tip-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 11px;
  background: rgba(22, 119, 255, 0.1);
  color: var(--primary);
  font-size: 12px;
  line-height: 1;
}

.open-tip-title {
  margin: 12px 0 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.open-tip-desc {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-2);
  text-align: left;
}

.open-tip-desc strong {
  color: var(--text);
  font-weight: 600;
}

.open-tip-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f7f8fa;
}

.open-tip-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-2);
  text-align: left;
}

.open-tip-copy {
  flex: none;
  height: 28px;
  padding: 0 14px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  background: var(--panel);
  color: var(--primary);
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.open-tip-copy:hover {
  background: rgba(22, 119, 255, 0.08);
}

.open-tip-copy:active {
  background: rgba(22, 119, 255, 0.14);
}

@media (max-width: 480px) {
  .search {
    flex-direction: column;
    align-items: stretch;
  }

  .search button {
    width: 100%;
  }

  .topbar-tag {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
