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

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #1a1a24;
  --border: #2a2a3a;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --text: #e8e8f0;
  --text-muted: #6b6b80;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(108,99,255,0.15);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* GRID BG */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(108,99,255,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(108,99,255,.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

/* HEADER */
.site-header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 32px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.2rem; font-weight: 500; color: var(--text);
}
.logo-icon { font-size: 1.4rem; }
.logo strong { color: var(--accent2); }

/* HERO */
.hero {
  position: relative; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 80px;
  gap: 24px;
}

/* CARD */
.card {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  transition: all .3s ease;
}
.card.hidden { display: none; }

.glow-card {
  box-shadow: var(--shadow), 0 0 0 1px rgba(108,99,255,.1);
}

/* BADGE */
.card-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgba(108,99,255,.2), rgba(167,139,250,.2));
  border: 1px solid rgba(108,99,255,.3);
  color: var(--accent2);
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  padding: 4px 12px; border-radius: 20px;
  margin-bottom: 16px;
}
.card-title { font-size: 1.8rem; font-weight: 700; margin-bottom: 10px; }
.card-sub { color: var(--text-muted); font-size: .95rem; margin-bottom: 28px; }

/* FORM */
.redeem-form { display: flex; flex-direction: column; gap: 16px; }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: .85rem; font-weight: 500; color: var(--text-muted); }
.input-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 1rem; font-family: 'Inter', monospace;
  letter-spacing: .05em;
  transition: border-color .2s;
  outline: none;
}
.input-group input:focus { border-color: var(--accent); }

.toggle-row { display: flex; align-items: center; }
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; color: var(--text-muted); }
.toggle-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* BUTTONS */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 15px 24px; font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: opacity .2s, transform .1s;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 20px; font-size: .9rem; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: border-color .2s;
  width: 100%; margin-top: 16px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent2); }

/* SPINNER */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* STATUS CARD */
.status-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.status-icon { font-size: 2rem; }
.status-title { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }
.status-msg { color: var(--accent2); font-size: .9rem; font-weight: 500; }

.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.progress-bar-wrap {
  background: var(--surface2); border-radius: 99px; height: 6px;
  margin-bottom: 20px; overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .5s ease;
}

.log-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 200px; overflow-y: auto;
}
.log-item {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem; color: var(--text-muted);
  padding: 8px 12px; background: var(--surface2);
  border-radius: var(--radius-sm); border-left: 3px solid transparent;
}
.log-item.success { border-color: var(--success); color: var(--text); }
.log-item.error { border-color: var(--error); color: #fca5a5; }
.log-item.info { border-color: var(--accent); }

/* RESULT CARD */
.result-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.result-icon { font-size: 2.5rem; }
.result-header h2 { font-size: 1.4rem; font-weight: 700; }
.result-header p { color: var(--text-muted); font-size: .9rem; }

.result-grid { display: flex; flex-direction: column; gap: 10px; }
.result-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px; gap: 12px;
}
.result-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.result-value {
  font-family: 'Courier New', monospace; font-size: .9rem;
  color: var(--accent2); word-break: break-all; text-align: right;
}
.copy-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1rem; padding: 4px;
  flex-shrink: 0; transition: color .2s;
}
.copy-btn:hover { color: var(--accent2); }

/* REVIEW NOTICE */
.review-notice {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 20px;
  background: rgba(245,158,11,.07);
  border: 1px solid rgba(245,158,11,.2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .88rem; color: #fcd34d;
}
.review-icon { flex-shrink: 0; font-size: 1rem; }

/* ERROR CARD */
.error-card { text-align: center; }
.error-icon { font-size: 3rem; margin-bottom: 16px; }
.error-card h2 { font-size: 1.3rem; margin-bottom: 8px; }
.error-card p { color: var(--text-muted); font-size: .9rem; margin-bottom: 24px; }

/* FOOTER */
.site-footer {
  position: relative; z-index: 10; text-align: center;
  padding: 24px; color: var(--text-muted); font-size: .85rem;
}
.site-footer a { color: var(--accent2); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }


/* ─────────── ADMIN ─────────── */
.admin-page { background: #0d0d14; }

.admin-layout {
  display: flex; min-height: 100vh;
}

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 0;
}
.sidebar-logo {
  padding: 0 20px 24px;
  font-size: 1rem; font-weight: 700;
  color: var(--accent2); border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar-logo span { color: var(--text-muted); font-weight: 400; font-size: .8rem; display: block; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; font-size: .9rem; cursor: pointer;
  color: var(--text-muted); border-left: 3px solid transparent;
  transition: all .2s; text-decoration: none;
}
.nav-item:hover, .nav-item.active {
  color: var(--text); background: rgba(108,99,255,.08);
  border-left-color: var(--accent);
}
.nav-item .nav-icon { font-size: 1rem; }

.sidebar-spacer { flex: 1; }
.sidebar-user {
  padding: 16px 20px; border-top: 1px solid var(--border);
  font-size: .8rem; color: var(--text-muted);
}

.admin-content {
  flex: 1; padding: 32px; overflow-y: auto;
}

.page-title {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 4px;
}
.page-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.admin-card-title {
  font-size: .95rem; font-weight: 600; margin-bottom: 16px;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  font-size: .8rem;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px;
}
.stat-num { font-size: 2rem; font-weight: 700; color: var(--accent2); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: 10px 12px; color: var(--text-muted); font-weight: 500; font-size: .8rem; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,.04); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(108,99,255,.04); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 500;
}
.badge-green { background: rgba(34,197,94,.15); color: #4ade80; }
.badge-red { background: rgba(239,68,68,.15); color: #f87171; }
.badge-gray { background: rgba(107,114,128,.15); color: #9ca3af; }
.badge-yellow { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-purple { background: rgba(108,99,255,.15); color: #a78bfa; }

.admin-form { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-input, .admin-textarea, .admin-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: .9rem; font-family: inherit;
  outline: none; width: 100%; transition: border-color .2s;
}
.admin-input:focus, .admin-textarea:focus, .admin-select:focus { border-color: var(--accent); }
.admin-textarea { resize: vertical; min-height: 120px; }
.form-label { font-size: .82rem; color: var(--text-muted); font-weight: 500; margin-bottom: 5px; display: block; }

.admin-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 10px 20px; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: opacity .2s;
}
.admin-btn:hover { opacity: .88; }
.admin-btn-sm {
  padding: 5px 12px; font-size: .8rem; border-radius: 6px;
}
.admin-btn-danger {
  background: rgba(239,68,68,.15); color: #f87171; border: 1px solid rgba(239,68,68,.3);
}
.admin-btn-danger:hover { background: rgba(239,68,68,.25); }

.flex-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ml-auto { margin-left: auto; }

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-item {
  padding: 8px 16px; font-size: .875rem; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; transition: all .2s;
}
.tab-item.active { color: var(--accent2); border-bottom-color: var(--accent2); }

.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
  font-size: .875rem;
}
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.2); color: #4ade80; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.2); color: #f87171; }
.alert.hidden { display: none; }

/* LOGIN */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; width: 100%; max-width: 380px;
}
.login-logo { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .admin-content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
