:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-strong: #fdfaf2;
  --text: #1f2428;
  --muted: #667071;
  --line: #d8ddd6;
  --focus: #167a72;
  --accent: #167a72;
  --accent-weak: #e5f3f0;
  --warn: #9b5c00;
  --warn-weak: #fff3d8;
  --danger: #a43d52;
  --shadow: 0 10px 28px rgba(37, 43, 45, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  padding: 0 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

button:hover,
.file-button:hover {
  filter: brightness(0.96);
}

button:focus-visible,
.file-button:focus-within,
input:focus,
select:focus {
  outline: 3px solid rgba(22, 122, 114, 0.22);
  outline-offset: 2px;
}

.ghost {
  background: #ffffff;
  color: var(--accent);
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 32px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 18px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px 32px 40px;
}

.paste-panel,
.filter-panel,
.data-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.paste-panel,
.filter-panel {
  padding: 20px;
}

.paste-panel {
  margin-bottom: 18px;
}

.paste-label {
  display: block;
}

.paste-label textarea {
  min-height: 168px;
  resize: vertical;
  line-height: 1.45;
  padding: 12px;
  white-space: pre;
  overflow: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  inline-size: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 12px;
}

textarea {
  padding-block: 10px;
}

.check-row {
  min-height: 44px;
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.check-row input {
  inline-size: 18px;
  min-height: 18px;
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.stat-card {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 28px;
  line-height: 1.2;
}

.stat-card.warning {
  background: var(--warn-weak);
}

.stat-card.warning strong {
  color: var(--warn);
}

.content-grid {
  display: grid;
  gap: 18px;
}

.data-panel {
  overflow: hidden;
}

.data-panel .section-title {
  padding: 18px 20px 0;
}

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

.table-wrap {
  overflow: auto;
  max-height: 520px;
  border-top: 1px solid var(--line);
}

table {
  inline-size: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-strong);
  color: #3d4648;
  font-size: 13px;
}

.sort-btn {
  min-height: 32px;
  inline-size: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.sort-btn.align-right {
  justify-content: flex-end;
  text-align: right;
}

.sort-btn:hover {
  background: var(--accent-weak);
  filter: none;
}

.sort-btn.active {
  color: var(--accent);
}

.sort-mark {
  min-width: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.sort-btn.active .sort-mark {
  color: var(--accent);
}

td {
  font-size: 14px;
}

tr:hover td {
  background: var(--accent-weak);
}

.number {
  text-align: right;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  padding: 28px 14px;
}

.code-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.copy-email-btn,
.copy-code-btn {
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  padding: 0;
  display: inline-block;
  cursor: copy;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
  white-space: nowrap;
}

.copy-email-btn {
  max-width: 280px;
}

.copy-code-btn {
  max-width: 320px;
  font-family: "Consolas", "SFMono-Regular", monospace;
}

.copy-email-btn:hover,
.copy-code-btn:hover {
  color: #0f5d57;
  filter: none;
}

.copy-email-btn:focus-visible,
.copy-code-btn:focus-visible {
  outline: 3px solid rgba(22, 122, 114, 0.22);
  outline-offset: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--accent-weak);
  color: var(--accent);
  font-weight: 700;
}

.kind-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 700;
  white-space: nowrap;
}

.kind-pill.normal {
  background: var(--accent-weak);
  color: var(--accent);
}

.kind-pill.payment {
  background: #eef0f2;
  color: #586066;
}

#toast {
  position: fixed;
  right: 20px;
  top: 20px;
  max-width: min(440px, calc(100vw - 40px));
  border-radius: 8px;
  background: #1f2428;
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .topbar {
    flex-direction: column;
  }

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

  .filter-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  main {
    padding-inline: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .actions,
  .actions button,
  .actions .file-button,
  .inline-actions,
  .inline-actions button {
    inline-size: 100%;
  }

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

  .check-row {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
