:root {
  --bg: #0b0f17;
  --bg-2: #101827;
  --panel: rgba(18, 25, 38, 0.92);
  --panel-solid: #121926;
  --panel-2: #172033;
  --panel-3: #202b40;
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #eef4ff;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --accent-3: #22d3ee;
  --ok-bg: rgba(34, 197, 94, 0.14);
  --ok-text: #86efac;
  --err-bg: rgba(244, 63, 94, 0.14);
  --err-text: #fda4af;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-text: #fcd34d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(91, 140, 255, .22), transparent 34%),
    radial-gradient(circle at 88% 15%, rgba(124, 92, 255, .18), transparent 32%),
    linear-gradient(180deg, var(--bg), #080b11 100%);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; filter: brightness(1.08); }

.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 46px; height: 42px; padding: 0 9px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 12px 32px rgba(91, 140, 255, .35);
  flex: 0 0 auto;
}
.brand-name { color: var(--muted); font-weight: 700; letter-spacing: .5px; }
.eyebrow { text-transform: uppercase; letter-spacing: 2.4px; font-size: 12px; color: var(--accent-3); margin: 0 0 8px; font-weight: 800; }

/* ---------- front redeem ---------- */
.redeem-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 34px;
}
.redeem-hero-panel {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 24px;
  align-items: stretch;
}
.redeem-hero-copy,
.redeem-workspace {
  background: linear-gradient(180deg, rgba(18,25,38,.92), rgba(18,25,38,.78));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.redeem-hero-copy {
  min-height: 640px;
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.redeem-hero-copy::after {
  content: "";
  position: absolute;
  width: 280px; height: 280px;
  right: -90px; bottom: -90px;
  background: radial-gradient(circle, rgba(34, 211, 238, .24), transparent 68%);
  pointer-events: none;
}
.redeem-hero-copy h1 { margin: 0; font-size: clamp(38px, 5vw, 68px); line-height: 1.02; letter-spacing: -2px; }
.hero-desc { color: var(--muted); max-width: 520px; font-size: 17px; margin: 20px 0 0; }
.hero-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 42px; }
.hero-metrics div { background: rgba(255,255,255,.045); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.hero-metrics strong { display: block; font-size: 22px; }
.hero-metrics span { color: var(--muted); font-size: 13px; }
.redeem-workspace { padding: 22px; display: grid; gap: 16px; align-content: center; }
.redeem-card { background: rgba(11, 15, 23, .42); border: 1px solid var(--line); border-radius: 22px; padding: 22px; }
.redeem-card.active-card { border-color: rgba(91, 140, 255, .38); }
.card-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-heading span { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(91, 140, 255, .14); color: #bcd0ff; font-weight: 800; }
.card-heading h2 { margin: 0; font-size: 18px; }
.redeem-note { color: var(--muted); font-size: 13px; margin: 0 4px; }
.flow-list { display: grid; gap: 10px; color: var(--muted); font-size: 14px; }
.flow-list p { margin: 0; }
.flow-list b { color: #dbeafe; }
.flow-list code { background: rgba(255,255,255,.06); color: #c7d2fe; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.register-status-shell .code-overview { margin-top: 16px; }
.secondary-overview { opacity: .88; }
.secondary-overview strong { font-size: 18px; letter-spacing: 0; }
.ops-shell { max-width: 1480px; }
.ops-frame-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); }
.ops-frame { display: block; width: 100%; height: calc(100vh - 145px); min-height: 760px; border: 0; background: #0b0f17; }

/* ---------- common forms ---------- */
.login-form, .redeem-form { display: grid; gap: 14px; }
.form-row-compact { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
label { display: grid; gap: 7px; font-size: 13px; color: #cbd5e1; font-weight: 700; }
input, select, textarea {
  width: 100%; padding: 13px 14px;
  background: rgba(15, 23, 42, .9); color: var(--text);
  border: 1px solid var(--line); border-radius: 13px;
  font-size: 15px; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
textarea { resize: vertical; min-height: 106px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: rgba(91, 140, 255, .8); box-shadow: 0 0 0 4px rgba(91, 140, 255, .14); }
input::placeholder, textarea::placeholder { color: rgba(148, 163, 184, .62); }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border: none; border-radius: 13px;
  font-size: 14px; font-weight: 800; cursor: pointer;
  text-align: center;
  box-shadow: 0 12px 28px rgba(91, 140, 255, .24);
}
button:hover, .btn:hover { filter: brightness(1.07); }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }
.btn.secondary { background: rgba(15, 23, 42, .78); color: #cbd5e1; border: 1px solid var(--line); box-shadow: none; }
.btn.mini { padding: 7px 11px; font-size: 12px; border-radius: 10px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.hint code, code.mono { background: rgba(255,255,255,.06); padding: 1px 6px; border-radius: 6px; }
.alert { padding: 13px 15px; border-radius: 14px; margin: 0 0 16px; font-size: 14px; border: 1px solid transparent; }
.alert.error { background: var(--err-bg); color: var(--err-text); border-color: rgba(244, 63, 94, .24); }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); border-color: rgba(34, 197, 94, .24); }
.alert.pre { white-space: pre-line; }

/* ---------- login ---------- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(430px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 30px; box-shadow: var(--shadow); }
.redeem-copy { margin: 18px 0 22px; }
.redeem-copy h1 { margin: 0 0 8px; font-size: 28px; }
.redeem-copy p { margin: 0; color: var(--muted); }
.login-account-hint { margin-top: 10px !important; color: #c7d2fe !important; }
.login-account-hint code { background: rgba(91, 140, 255, .14); border: 1px solid rgba(129, 140, 248, .28); border-radius: 8px; padding: 2px 8px; color: #dbeafe; }

/* ---------- admin shell ---------- */
.admin-shell { max-width: 1280px; margin: 0 auto; padding: 24px; }
.admin-top {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 18px;
  background: rgba(18,25,38,.72);
  border: 1px solid var(--line);
  border-radius: 22px;
  margin-bottom: 16px;
  backdrop-filter: blur(16px);
}
.admin-title h1 { margin: 0; font-size: 22px; }
.admin-title .eyebrow { margin-bottom: 2px; }
.admin-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.logout { color: var(--muted); font-size: 14px; font-weight: 700; }
.admin-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 0 0 18px; }
.admin-nav .btn { box-shadow: none; }
.admin-nav .btn.secondary { background: rgba(18,25,38,.58); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.stat span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat strong { font-size: 30px; letter-spacing: -1px; }
.clean-stats { grid-template-columns: repeat(4, 1fr); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: 0 16px 44px rgba(0,0,0,.18); }
.card-box h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: -.2px; }
.card-box form { display: grid; gap: 12px; }
.generated-box { border-color: rgba(34, 197, 94, .28); }
.inline-form { display: inline-grid; margin-top: 12px; }

/* ---------- code manager redesigned ---------- */
.code-manager-page { display: grid; gap: 16px; }
.section-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px;
  background: linear-gradient(135deg, rgba(91, 140, 255, .16), rgba(34, 211, 238, .06)), var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.section-toolbar h2 { margin: 0 0 6px; font-size: 26px; }
.section-toolbar p:not(.eyebrow) { margin: 0; color: var(--muted); }
.code-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.code-overview div { background: rgba(18,25,38,.86); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.code-overview span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.code-overview strong { display: block; margin-top: 6px; font-size: 26px; }
.status-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.status-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(18,25,38,.68);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-weight: 800;
}
.status-tab span { color: #cbd5e1; }
.status-tab strong { color: var(--muted); font-size: 18px; }
.status-tab.active {
  border-color: rgba(91, 140, 255, .55);
  background: linear-gradient(135deg, rgba(91, 140, 255, .18), rgba(124, 92, 255, .08));
}
.status-tab.active strong { color: #dbeafe; }
.code-filter-panel {
  display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 12px; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px;
}
.filter-actions { display: flex; gap: 10px; }
.bulk-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: rgba(18,25,38,.62); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.bulk-actions span { color: var(--muted); font-size: 13px; }
.copy-source { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { color: var(--muted); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; background: rgba(15, 23, 42, .48); }
tbody tr:hover { background: rgba(255,255,255,.028); }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
td.small, .small { font-size: 12px; color: var(--muted); }
td.empty, .empty { text-align: center; color: var(--muted); padding: 28px; }
.code-cell { display: grid; gap: 2px; }
.code-cell small { color: var(--muted-2); font-size: 11px; }
.code-full { user-select: all; color: #dbeafe; }
.file-name { color: #cbd5e1; }
.row-actions { text-align: right; }
.muted-code { color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-pill.unused { background: var(--ok-bg); color: var(--ok-text); }
.status-pill.unused i { background: #22c55e; }
.status-pill.activated { background: var(--warn-bg); color: var(--warn-text); }
.status-pill.activated i { background: #f59e0b; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge.free { background: var(--ok-bg); color: var(--ok-text); }
.badge.used { background: var(--err-bg); color: var(--err-text); }


.status-action-row { display: flex; align-items: stretch; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.status-action-row .alert { flex: 1; margin: 0; display: flex; align-items: center; }
.status-action-row .btn { min-width: 150px; box-shadow: none; }
.badge.running { background: rgba(91, 140, 255, .14); color: #bfdbfe; }
.badge.queued { background: rgba(148, 163, 184, .14); color: #cbd5e1; }

.status-cell { display: inline-flex; align-items: center; gap: 10px; }
.row-download { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 5px 12px; border-radius: 999px; background: rgba(91, 140, 255, .16); color: #bfdbfe; border: 1px solid rgba(91, 140, 255, .35); font-size: 12px; font-weight: 900; text-decoration: none; }
.row-download:hover { background: rgba(91, 140, 255, .28); color: #fff; }

.row-retry-form { display: inline-flex; margin: 0; }
.row-retry { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 5px 12px; border-radius: 999px; background: rgba(245, 158, 11, .16); color: #fde68a; border: 1px solid rgba(245, 158, 11, .36); font-size: 12px; font-weight: 900; text-decoration: none; cursor: pointer; }
.row-retry:hover { background: rgba(245, 158, 11, .28); color: #fff7ed; transform: none; box-shadow: none; }
@media (max-width: 640px) { .status-action-row { flex-direction: column; } .status-action-row .btn { width: 100%; } }

/* ---------- other admin views ---------- */
.nav-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.nav-card { display: block; color: var(--text); text-decoration: none; min-height: 120px; }
.nav-card:hover { border-color: var(--accent); }
.nav-card h2 { margin-bottom: 8px; }
.mini-stat { margin-top: 12px; }

@media (max-width: 1024px) {
  .redeem-hero-panel { grid-template-columns: 1fr; }
  .redeem-hero-copy { min-height: auto; }
  .admin-nav { grid-template-columns: repeat(3, 1fr); }
  .stat-row, .clean-stats, .code-overview { grid-template-columns: repeat(2, 1fr); }
  .status-tabs { grid-template-columns: 1fr 1fr 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .code-filter-panel { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .redeem-page { padding: 16px; }
  .redeem-hero-copy, .redeem-workspace { padding: 20px; border-radius: 22px; }
  .hero-metrics { grid-template-columns: 1fr; }
  .admin-shell { padding: 14px; }
  .admin-top { align-items: flex-start; flex-direction: column; }
  .admin-actions { justify-content: flex-start; }
  .admin-nav { grid-template-columns: 1fr; }
  .form-row-compact { grid-template-columns: 1fr; }
  .stat-row, .clean-stats, .code-overview { grid-template-columns: 1fr; }
  .status-tabs { grid-template-columns: 1fr; }
  .section-toolbar { align-items: flex-start; flex-direction: column; }
  .filter-actions { flex-direction: column; }
}
.download-list-card .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.download-groups { display: grid; gap: 10px; }
.download-group { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid rgba(148,163,184,.22); border-radius: 14px; background: rgba(15,23,42,.34); }
.download-email { font-weight: 700; word-break: break-all; }
.download-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
@media (max-width: 720px) { .download-list-card .section-head, .download-group { align-items: stretch; flex-direction: column; } .download-buttons { justify-content: flex-start; } }
