:root {
  --primary: #ff5000;
  --primary-dark: #e64500;
  --primary-light: #ff7a26;
  --primary-bg: #fff5f0;
  --primary-glow: rgba(255, 80, 0, .15);
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --error: #ef4444;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --bg-primary: #fff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, .08), 0 4px 10px rgba(0, 0, 0, .04);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --transition: all .25s cubic-bezier(.4, 0, .2, 1);
}

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

body {
  min-height: 100vh;
  background: #f5f5f7;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", 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, var(--primary), var(--primary-light));
}

.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: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .35);
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  font-size: 19px;
  font-weight: 900;
}

.logo-text {
  overflow: hidden;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  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: 800;
  font-variant-numeric: tabular-nums;
}

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

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

.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, .8);
  font-size: 11px;
}

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

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

.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 {
  cursor: pointer;
}

.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);
  font-size: 13px;
  font-weight: 600;
}

.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: 700;
}

.submit-form {
  position: relative;
  display: flex;
  gap: 10px;
}

.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: 15px;
  font-variant-numeric: tabular-nums;
  transition: var(--transition);
}

.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(255, 80, 0, .25);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  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: 700;
}

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

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

.filter-btn.active,
.history-tab--active {
  background: var(--bg-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .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: center;
  gap: 12px;
  min-width: 0;
}

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

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

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

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

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

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

.used-badge,
.help-btn {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  font-weight: 600;
  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(255, 80, 0, .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;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.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: 500;
  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(0, 0, 0, .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: 700;
}

.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: 600;
}

.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: 700;
}

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

.modal-code {
  margin-bottom: 10px;
  padding: 14px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  color: var(--primary);
  font-family: "SF Mono", "Courier New", monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
}

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

@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: 16px;
  }

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

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

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

  .header-stats {
    gap: 10px;
  }

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

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