:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: 221 83% 53%;
  --primary-foreground: 210 40% 98%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --border: 240 5.9% 90%;
  --radius: 0.75rem;
  --destructive: 0 84% 60%;
}

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

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.container-wide {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.06);
  padding: 1.5rem;
}

.card + .card { margin-top: 1rem; }

.logo-wrap {
  text-align: center;
  margin-bottom: 1.5rem;
}

.logo-wrap img {
  max-width: 180px;
  height: auto;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.25rem;
}

.subtitle { display: none; }

/* Step track */
.step-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 1.25rem;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  min-width: 52px;
}

.step span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  border: 2px solid hsl(var(--border));
  background: white;
  font-size: 0.75rem;
  font-weight: 600;
}

.step.active span {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  background: hsl(221 83% 53% / 0.08);
}

.step.done span {
  border-color: hsl(var(--primary));
  background: hsl(var(--primary));
  color: white;
}

.step-line {
  flex: 1;
  height: 2px;
  background: hsl(var(--border));
  max-width: 48px;
  margin-bottom: 1rem;
}

.step-line.done { background: hsl(var(--primary)); }

/* Progress bar */
.progress-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  text-align: center;
}

.progress-bar {
  height: 8px;
  background: hsl(var(--muted));
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(221 83% 65%));
  border-radius: 9999px;
  transition: width 0.35s ease;
}

.progress-steps {
  list-style: none;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.progress-steps li {
  padding: 0.375rem 0;
  padding-left: 1.25rem;
  position: relative;
}

.progress-steps li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(var(--border));
}

.progress-steps li.active { color: hsl(var(--primary)); font-weight: 600; }
.progress-steps li.active::before { background: hsl(var(--primary)); }
.progress-steps li.done { color: #166534; }
.progress-steps li.done::before { background: #22c55e; }

.qr-label {
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

.footer { display: none; }

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  background: white;
  margin-bottom: 1rem;
}

textarea {
  min-height: 140px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover { opacity: 0.92; }

.btn-outline {
  background: white;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  width: auto;
  padding: 0.5rem 0.875rem;
}

.btn-sm { width: auto; padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

.input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.input-row input {
  flex: 1;
  margin-bottom: 0;
}

.btn-inline {
  width: auto;
  min-width: 88px;
  flex-shrink: 0;
}

.check-msg {
  font-size: 0.8125rem;
  padding: 0.625rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  margin-bottom: 1rem;
}

.check-ok {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.check-err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

[hidden] { display: none !important; }

textarea:disabled {
  background: hsl(var(--muted));
  cursor: not-allowed;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.payment-status {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-top: 0.875rem;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.45;
}

.payment-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  margin-top: 0.3rem;
  flex-shrink: 0;
}

.payment-pending {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.payment-pending .payment-dot {
  background: #f59e0b;
  animation: payment-pulse 1.2s ease-in-out infinite;
}

.payment-paid {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  font-weight: 600;
}

.payment-paid .payment-dot {
  background: #10b981;
}

.payment-failed,
.payment-timeout {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.payment-failed .payment-dot,
.payment-timeout .payment-dot {
  background: #ef4444;
}

@keyframes payment-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.qr-box {
  text-align: center;
  margin-top: 1rem;
}

.qr-box img {
  max-width: 280px;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}

.hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* Admin */
.admin-body { background: hsl(220 20% 97%); }

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-brand img { height: 40px; }

.admin-sub {
  display: block;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  font-weight: 400;
}

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.stat-card.stat-sold .num { color: #2563eb; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.gen-form, .search-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.gen-form input[type="number"] {
  width: 72px;
  margin: 0;
}

.search-input {
  width: min(280px, 100%);
  margin: 0;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.pill {
  display: inline-flex;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
  border: 1px solid transparent;
}

.pill:hover { background: hsl(var(--border)); }
.pill.active {
  background: hsl(var(--primary));
  color: white;
}

.pill-action { margin-left: auto; }

.table-meta {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.5rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
}

.admin-table { margin: 0; }

.admin-table tbody tr:hover { background: hsl(220 20% 98%); }

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

.empty-cell {
  text-align: center;
  color: hsl(var(--muted-foreground));
  padding: 2rem !important;
}

.toast-msg {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #166534;
  color: white;
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
  z-index: 100;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-card .num {
  font-size: 1.75rem;
  font-weight: 700;
  color: hsl(var(--primary));
}

.stat-card .lbl {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th, td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid hsl(var(--border));
}

th {
  background: hsl(var(--muted));
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge-unused { background: #dcfce7; color: #166534; }
.badge-sold { background: #dbeafe; color: #1d4ed8; }
.badge-used { background: #f3f4f6; color: #6b7280; }

.gen-result {
  margin-bottom: 1.25rem;
  border: 1px solid #93c5fd;
  background: #eff6ff;
}

.gen-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.gen-result-sub {
  display: block;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

.gen-keys-text {
  width: 100%;
  min-height: 8rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  padding: 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  background: #fff;
  resize: vertical;
}

code.key {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  background: hsl(var(--muted));
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
}
