:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-strong: #ffffff;
  --ink: #152033;
  --muted: #6a7485;
  --line: rgba(126, 145, 171, 0.22);
  --accent: #1f6feb;
  --accent-2: #0f766e;
  --accent-soft: rgba(31, 111, 235, 0.08);
  --danger: #dc2626;
  --success: #059669;
  --warning: #b45309;
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow-lg: 0 24px 70px rgba(37, 52, 79, 0.12);
  --shadow-md: 0 14px 38px rgba(37, 52, 79, 0.08);
  --shadow-sm: 0 8px 20px rgba(37, 52, 79, 0.06);
  --fast: 160ms cubic-bezier(0.2, 0, 0, 1);
  --smooth: 260ms cubic-bezier(0.2, 0, 0, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 249, 252, 0.94)),
    #f7f9fc;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 20px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(31, 111, 235, 0.16);
  cursor: pointer;
  font-weight: 800;
  transform: translateZ(0);
  transition: transform var(--fast), box-shadow var(--fast), opacity var(--fast), filter var(--fast);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(31, 111, 235, 0.2);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  outline: 0;
  padding: 0 15px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast), transform var(--fast);
}

textarea {
  min-height: 118px;
  padding: 14px 15px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.52);
  background: #fff;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.1);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 6vw, 64px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.12;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted,
small {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.redeem-shell {
  width: min(1160px, calc(100% - 34px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 36px 0;
}

.redeem-minimal-shell {
  width: min(100% - 32px, 520px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.minimal-redeem {
  width: 100%;
  display: grid;
  gap: 24px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 52px rgba(17, 24, 39, 0.06);
  backdrop-filter: blur(18px);
  padding: clamp(24px, 7vw, 42px);
}

.minimal-head {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 8px;
}

.minimal-head h1 {
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.1;
  font-weight: 850;
}

.minimal-head p {
  color: var(--muted);
  font-size: 14px;
}

.minimal-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.04);
  font-weight: 950;
}

.minimal-form {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.minimal-form label {
  text-align: center;
  color: #6b7280;
  font-size: 12px;
  font-weight: 800;
}

.minimal-form #codeInput {
  width: min(100%, 420px);
  min-height: 142px;
  border-color: rgba(17, 24, 39, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
  color: #111827;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.7;
  padding: 42px 18px 18px;
}

.minimal-form button {
  width: min(100%, 420px);
  min-height: 50px;
  border-radius: 18px;
  background: #111827;
  box-shadow: 0 12px 26px rgba(17, 24, 39, 0.12);
  color: #fff;
  font-weight: 850;
}

.minimal-form button:hover {
  box-shadow: 0 16px 32px rgba(17, 24, 39, 0.16);
}

.minimal-form .message {
  width: min(100%, 420px);
  text-align: center;
}

.minimal-redeem .download-area {
  width: min(100%, 420px);
  justify-self: center;
  margin-top: 0;
}

.minimal-redeem .download-card {
  border-color: rgba(17, 24, 39, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: none;
  text-align: center;
}

.minimal-redeem .zip-link {
  justify-self: center;
  color: #111827;
}

.redeem-panel {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(360px, 1.08fr);
  gap: 22px;
  animation: shell-in var(--smooth) both;
}

.redeem-hero,
.redeem-card,
.admin-sidebar,
.admin-workspace,
.tab,
.tool-block,
.bulk-bar,
.item,
.download-card,
.stat,
.toast,
.dialog {
  will-change: transform, opacity;
}

.redeem-hero,
.redeem-card,
.admin-sidebar,
.admin-workspace,
.tool-block,
.bulk-bar,
.item,
.download-card,
.stat {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px);
}

.redeem-hero {
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: var(--radius-lg);
  padding: 34px;
  overflow: hidden;
  position: relative;
}

.redeem-card {
  border-radius: var(--radius-lg);
  padding: 30px;
  align-self: center;
}

.brand-row,
.admin-head,
.section-title,
.actions-row,
.form-line,
.item-actions,
.login-form,
.inline-check,
.row-select {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row {
  position: relative;
  z-index: 1;
}

.mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: #111827;
  color: #dbeafe;
  box-shadow: var(--shadow-sm);
  font-weight: 950;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
  color: #405064;
  font-size: 18px;
  line-height: 1.8;
}

.hero-metrics {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.hero-metrics div {
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.5);
  padding: 16px;
}

.hero-metrics strong {
  display: block;
  font-size: 22px;
}

.hero-metrics span {
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 18px;
}

.redeem-form label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-weight: 800;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
}

#codeInput {
  min-height: 160px;
  text-transform: uppercase;
  font-size: 18px;
  font-weight: 850;
}

.message {
  min-height: 24px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.download-area {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.download-card {
  display: grid;
  gap: 8px;
  border-radius: 22px;
  padding: 16px;
  animation: item-in var(--smooth) both;
  transition: transform var(--fast), box-shadow var(--fast), border-color var(--fast);
}

.download-card:hover,
.item:hover,
.stat:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: var(--shadow-lg);
}

.bundle-card {
  background: rgba(255, 255, 255, 0.88);
}

.zip-link {
  width: max-content;
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  padding: 0 16px;
  font-weight: 900;
  text-decoration: none;
  transition: transform var(--fast), box-shadow var(--fast), color var(--fast);
}

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

.admin-shell {
  width: min(1440px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
}

.admin-panel {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  min-height: calc(100vh - 48px);
  animation: shell-in var(--smooth) both;
}

.admin-sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  min-height: calc(100vh - 48px);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.admin-workspace {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.admin-head {
  justify-content: space-between;
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr;
  margin: 24px 0;
}

.tabs {
  display: grid;
  gap: 10px;
}

.tab {
  justify-content: flex-start;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  box-shadow: none;
}

.tab:hover {
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.tab.active {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 12px 26px rgba(31, 111, 235, 0.16);
}

.admin-content {
  display: grid;
  gap: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  border-radius: 26px;
  padding: 20px;
  transition: transform var(--fast), box-shadow var(--fast), border-color var(--fast);
}

.stat span {
  display: block;
  font-size: 34px;
  line-height: 1;
  font-weight: 950;
}

.stat small {
  display: block;
  margin-top: 8px;
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: grid;
  gap: 14px;
  animation: item-in var(--smooth) both;
}

.tool-block {
  display: grid;
  gap: 14px;
  border-radius: 26px;
  padding: 18px;
}

.form-line {
  align-items: stretch;
}

.form-grid {
  display: grid;
  grid-template-columns: 0.65fr 0.75fr 0.9fr 1.1fr 1.25fr;
  gap: 12px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid datalist {
  display: none;
}

.file-picker {
  position: relative;
  min-width: 126px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(37, 99, 235, 0.36);
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
  cursor: pointer;
  transition: transform var(--fast), background var(--fast), border-color var(--fast);
}

.file-picker:hover {
  transform: translateY(-1px);
  background: rgba(37, 99, 235, 0.14);
  border-color: rgba(37, 99, 235, 0.56);
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.bulk-bar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border-radius: 24px;
  padding: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.group-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.group-panel {
  position: sticky;
  top: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
  padding: 14px;
}

.group-title {
  margin: 2px 4px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.group-list {
  display: grid;
  gap: 8px;
}

.group-chip {
  min-height: 42px;
  justify-content: space-between;
  display: flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  box-shadow: none;
  padding: 0 12px;
}

.group-chip span {
  min-width: 28px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(31, 111, 235, 0.08);
  color: var(--accent);
  font-size: 12px;
}

.group-chip:hover {
  border-color: rgba(31, 111, 235, 0.22);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.group-chip.active {
  border-color: rgba(31, 111, 235, 0.25);
  background: rgba(31, 111, 235, 0.08);
  color: var(--accent);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: none;
}

.ghost-btn:hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.danger-btn {
  background: var(--danger);
  box-shadow: 0 14px 28px rgba(220, 38, 38, 0.18);
}

.danger-btn:hover {
  box-shadow: 0 20px 34px rgba(220, 38, 38, 0.24);
}

.actions-row {
  flex-wrap: wrap;
}

.inline-check,
.row-select {
  color: var(--muted);
  font-weight: 800;
}

.inline-check input,
.row-select input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border-radius: 24px;
  padding: 16px;
  transform: translateZ(0);
  animation: item-in var(--smooth) both;
  transition: transform var(--fast), box-shadow var(--fast), border-color var(--fast), background var(--fast);
}

.item strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.item-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.mini-btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
}

.pill {
  display: inline-grid;
  min-height: 24px;
  place-items: center;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  padding: 3px 10px;
  font-weight: 900;
}

.pill.used {
  background: rgba(180, 83, 9, 0.12);
  color: var(--warning);
}

.pill.expired,
.pill.disabled {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.is-loading {
  pointer-events: none;
  opacity: 0.66;
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  padding: 14px 16px;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  backdrop-filter: blur(18px);
  transition: opacity var(--smooth), transform var(--smooth);
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-error {
  color: var(--danger);
}

.dialog-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--smooth);
}

.dialog-root.open {
  opacity: 1;
  pointer-events: auto;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
}

.dialog {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transform: translateY(14px) scale(0.98);
  transition: transform var(--smooth);
}

.dialog-root.open .dialog {
  transform: translateY(0) scale(1);
}

.dialog h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.dialog p {
  color: var(--muted);
  line-height: 1.7;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@keyframes shell-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes item-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1080px) {
  .redeem-panel,
  .admin-panel {
    grid-template-columns: 1fr;
  }

  .redeem-hero,
  .admin-sidebar {
    min-height: auto;
    position: static;
  }

  .tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .redeem-shell,
  .admin-shell {
    width: min(100% - 18px, 1440px);
    padding: 9px 0;
  }

  .redeem-hero,
  .redeem-card,
  .admin-sidebar,
  .admin-workspace {
    border-radius: 26px;
    padding: 20px;
  }

  .hero-metrics,
  .group-layout,
  .stats-grid,
  .form-grid,
  .settings-grid,
  .code-row,
  .form-line,
  .bulk-bar,
  .item {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-head,
  .section-title,
  .item-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
