:root {
  --primary: #1677ff;
  --primary-dark: #0b5fd3;
  --primary-light: #42a5ff;
  --primary-bg: #eef6ff;
  --primary-glow: rgba(22, 119, 255, .16);
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --error: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #667085;
  --text-tertiary: #98a2b3;
  --bg-primary: #fff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #eef2f7;
  --border: #e5eaf2;
  --border-light: #f0f3f8;
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 28px rgba(16, 24, 40, .12);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --transition: all .22s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: #f3f6fb;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background:
    linear-gradient(135deg, rgba(22, 119, 255, .98), rgba(66, 165, 255, .96)),
    radial-gradient(circle at 18% 0, rgba(255, 255, 255, .28), transparent 32%);
}

.header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 14px;
}

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

.logo-icon {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-radius: 11px;
  background: #fff;
  object-fit: cover;
}

.logo-text {
  overflow: hidden;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.stat-value {
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: rgba(255, 255, 255, .78);
  font-size: 10px;
  font-weight: 600;
}

.stat-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, .28);
}

.header-stats-bar {
  width: 100%;
  background: rgba(0, 0, 0, .1);
  text-align: center;
}

.stats-bar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 0;
}

.stats-bar-item,
.stats-bar-dot {
  color: rgba(255, 255, 255, .82);
  font-size: 11px;
}

.stats-bar-item strong {
  color: #fff;
  font-weight: 800;
}

.main {
  padding: 12px 0 86px;
}

.gzh-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  box-shadow: 0 10px 24px rgba(16, 24, 40, .07);
}

.gzh-icon,
.gzh-modal-icon {
  display: block;
  border-radius: 15px;
  background: #08c66f;
  object-fit: cover;
}

.gzh-icon {
  width: 52px;
  height: 52px;
}

.gzh-copy {
  min-width: 0;
}

.gzh-copy h2 {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gzh-copy p {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gzh-copy strong {
  color: #06b76b;
  font-weight: 900;
}

.gzh-follow-btn {
  min-width: 76px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #dcfce7;
  color: #05a858;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
}

.info-card,
.submit-card,
.list-card {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
}

.info-card {
  padding: 12px 14px;
}

.submit-card,
.list-card {
  padding: 14px;
}

.submit-card--compact {
  padding: 12px 14px;
}

.info-details summary,
.history-summary {
  display: flex;
  align-items: center;
  list-style: none;
  user-select: none;
}

.info-details summary {
  gap: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.info-details summary::-webkit-details-marker,
.history-details summary::-webkit-details-marker {
  display: none;
}

.info-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--primary);
}

.info-content {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
}

.info-list li {
  position: relative;
  padding-left: 14px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.info-list li::before {
  position: absolute;
  left: 0;
  color: var(--primary);
  content: "•";
  font-weight: 900;
}

.submit-form {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr auto;
  align-items: start;
  gap: 10px;
}

.card-field {
  display: grid;
  gap: 4px;
}

.card-select,
.code-input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  transition: var(--transition);
}

.card-select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%) right 12px center / 6px 6px no-repeat,
    linear-gradient(135deg, var(--bg-secondary), #fff);
  cursor: pointer;
  font-weight: 700;
}

.card-match-hint {
  min-height: 16px;
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.card-select:focus,
.code-input:focus {
  border-color: var(--primary);
  outline: none;
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.code-input.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .1);
}

.code-input.success {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .1);
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.input-hint {
  min-height: 17px;
  margin-top: 6px;
  padding-left: 2px;
  font-size: 11px;
}

.input-hint.error {
  color: var(--error);
}

.input-hint.success {
  color: var(--success);
}

.submit-btn {
  height: 42px;
  flex-shrink: 0;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 2px 8px rgba(22, 119, 255, .25);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  transition: var(--transition);
}

.submit-btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.list-title {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 800;
}

.list-filter,
.history-tabs {
  display: flex;
  gap: 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  padding: 3px;
}

.list-filter {
  overflow-x: auto;
  scrollbar-width: none;
}

.list-filter::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  transition: var(--transition);
}

.filter-btn.active,
.history-tab--active {
  background: var(--bg-primary);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
  color: var(--primary);
}

.list-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.code-item.available {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.code-item.used {
  border-color: var(--border-light);
  background: var(--bg-secondary);
  opacity: .68;
}

.code-item:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.code-left {
  display: flex;
  align-items: flex-start;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.code-number,
.history-row-code {
  color: var(--text-primary);
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 1px;
  white-space: nowrap;
}

.code-number {
  max-width: 100%;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
}

.code-meta-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.code-time,
.code-ip {
  color: var(--text-tertiary);
  font-size: 11px;
  white-space: nowrap;
}

.code-ip {
  font-size: 10px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  max-width: 150px;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(22, 119, 255, .1);
  color: var(--primary-dark);
  font-size: 10px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge--target {
  background: #fff7e6;
  color: #b45309;
}

.role-badge--recommend {
  background: #fee2e2;
  color: #dc2626;
}

.role-badge--risk {
  background: #fef3c7;
  color: #a16207;
}

.code-right {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  align-self: center;
}

.used-badge,
.help-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.used-badge {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-size: 11px;
}

.help-btn {
  gap: 4px;
  padding: 7px 12px;
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 2px 6px rgba(22, 119, 255, .2);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: var(--transition);
}

.help-btn--go {
  background: linear-gradient(135deg, var(--success), #05a06e);
}

.loading-state,
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-height: 180px;
  color: var(--text-secondary);
  padding: 32px 20px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

.loading-state p,
.empty-state p {
  margin-top: 12px;
  font-size: 13px;
}

.history-summary {
  justify-content: space-between;
  cursor: pointer;
}

.history-summary-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-details[open] .history-summary {
  margin-bottom: 10px;
}

.history-panel {
  max-height: min(35vh, 260px);
  overflow-y: auto;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.history-row-code {
  color: var(--primary);
  font-size: 15px;
}

.history-row-time,
.history-meta {
  color: var(--text-tertiary);
  font-size: 11px;
  white-space: nowrap;
}

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

.history-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.history-clear-btn {
  border: 0;
  background: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
}

.footer {
  color: var(--text-tertiary);
  font-size: 11px;
  line-height: 1.8;
  padding: 24px 16px 16px;
  text-align: center;
}

.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  z-index: 3000;
  max-width: 90%;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--text-primary);
  box-shadow: var(--shadow-lg);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transform: translateX(-50%);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 40, .45);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden],
.toast[hidden],
[hidden] {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.modal-title {
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.modal-close {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.modal-body {
  padding: 20px 18px;
  text-align: center;
}

.modal-subtitle {
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 800;
}

.modal-desc {
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 12px;
}

.modal-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.modal-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.step-num {
  display: grid;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.step-text {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.modal-code {
  margin-bottom: 10px;
  padding: 14px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-family: "SF Mono", Consolas, "Courier New", monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 2px;
  overflow-wrap: anywhere;
}

.modal-copied {
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.gzh-modal-card {
  max-width: 380px;
}

.gzh-modal-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  box-shadow: 0 12px 24px rgba(5, 168, 88, .18);
}

.gzh-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.gzh-copy-btn,
.gzh-open-btn {
  min-height: 44px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
}

.gzh-copy-btn {
  border: 1.5px solid #08c66f;
  background: #fff;
  color: #05a858;
}

.gzh-open-btn {
  border: 0;
  background: linear-gradient(135deg, #08c66f, #05a858);
  color: #fff;
}

@media (max-width: 640px) {
  .header-main {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .logo-text {
    font-size: 15px;
  }

  .stat-value {
    font-size: 16px;
  }

  .stat-label {
    font-size: 9px;
  }

  .code-number {
    font-size: 15px;
  }

  .filter-btn {
    font-size: 11px;
    padding: 4px 10px;
  }

  .gzh-card {
    grid-template-columns: 48px 1fr auto;
    gap: 10px;
  }

  .gzh-icon {
    width: 46px;
    height: 46px;
  }

  .gzh-follow-btn {
    min-width: 68px;
    padding: 0 12px;
  }
}

@media (max-width: 380px) {
  .container {
    padding: 0 12px;
  }

  .logo-text {
    max-width: 150px;
  }

  .header-stats {
    gap: 10px;
  }

  .submit-btn {
    padding: 0 14px;
  }

  .submit-form {
    grid-template-columns: 1fr;
  }

  .gzh-card {
    grid-template-columns: 44px 1fr;
  }

  .gzh-follow-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .code-item {
    align-items: flex-start;
    flex-direction: column;
  }
}
