:root {
  color-scheme: light;
  --bg: #fbfcff;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --quiet: #94a3b8;
  --line: #e2e8f0;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --emerald: #10b981;
  --emerald-soft: #ecfdf5;
  --amber: #f59e0b;
  --rose: #ef4444;
  --sky: #0284c7;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 9% 19%, rgba(124, 58, 237, 0.035), transparent 32%),
    radial-gradient(circle at 89% 78%, rgba(2, 132, 199, 0.04), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.88));
}

.portal {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 9vh 20px 56px;
}

.portal-inner {
  width: min(560px, 100%);
}

.hero {
  text-align: center;
  margin-bottom: 36px;
}

.logo {
  margin: 0;
  font-size: 46px;
  line-height: 1;
  font-weight: 850;
  letter-spacing: 0;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--quiet);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.load {
  margin-top: 24px;
  display: grid;
  justify-content: center;
  gap: 8px;
}

.load-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.load-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
}

.load-dots span.active {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
}

.load-text {
  margin: 0;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 1px;
}

.redeem-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.redeem-bar:focus-within {
  background: var(--panel);
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 18px 42px rgba(124, 58, 237, 0.12);
}

.redeem-bar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 12px 16px;
  color: #1e293b;
  font-weight: 750;
  font-size: 16px;
}

.icon-btn,
.primary-icon {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
}

.primary-icon {
  background: var(--ink);
  color: #fff;
}

.ghost-link {
  width: fit-content;
  margin: 16px auto 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--quiet);
  text-decoration: none;
  font-size: 13px;
  font-weight: 750;
}

.ghost-link:hover {
  color: var(--violet);
  border-color: #c4b5fd;
  background: var(--violet-soft);
}

.result-card,
.tool-panel,
.admin-panel,
.modal {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow);
}

.result-card {
  margin-top: 26px;
  border-radius: 30px;
  padding: 28px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status-pill.success {
  background: var(--emerald-soft);
  color: #047857;
}

.status-pill.waiting {
  background: var(--violet-soft);
  color: var(--violet);
}

.status-pill.error {
  background: #fef2f2;
  color: var(--rose);
}

.result-title {
  margin: 18px 0 6px;
  font-size: 24px;
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.secret-box {
  margin-top: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 18px;
  background: #f8fafc;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1e293b;
  line-height: 1.7;
}

.file-list {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.section-label {
  margin: 8px 0 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.file-row,
.code-row,
.product-row {
  display: grid;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.72);
}

.file-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.download-btn,
.btn,
.secondary-btn,
.danger-btn {
  border: 0;
  border-radius: 14px;
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  text-decoration: none;
}

.download-btn,
.btn {
  background: var(--ink);
  color: #fff;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
}

.danger-btn {
  background: #fef2f2;
  color: #dc2626;
}

.batch {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 40px 20px 70px;
}

.batch-inner {
  width: min(680px, 100%);
  margin: 0 auto;
}

.back {
  color: var(--quiet);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
  font-size: 14px;
}

.page-title {
  text-align: center;
  margin: 36px 0 28px;
}

.page-title h1 {
  margin: 0;
  font-size: 34px;
}

.page-title p {
  margin: 10px 0 0;
  color: var(--quiet);
  font-weight: 700;
}

.tool-panel {
  border-radius: 26px;
  padding: 18px;
}

.batch textarea,
.form-grid textarea,
.form-grid input,
.login-card input,
.filter-row input,
.filter-row select,
.qty-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  color: #1e293b;
  outline: 0;
}

.batch textarea {
  height: 170px;
  resize: vertical;
  padding: 18px;
  line-height: 1.65;
}

.tool-actions {
  margin-top: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.count {
  color: var(--muted);
  font-weight: 800;
}

.batch-results {
  margin-top: 26px;
  display: grid;
  gap: 12px;
}

.admin {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 28px;
}

.admin-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-header h1 {
  margin: 0;
  font-size: 30px;
}

.admin-header p {
  margin: 6px 0 0;
  color: var(--quiet);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  min-height: 96px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.stat span {
  color: var(--quiet);
  font-size: 13px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-panel {
  border-radius: 24px;
  padding: 20px;
}

.admin-panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-grid input,
.form-grid textarea,
.login-card input,
.filter-row input,
.filter-row select,
.qty-input {
  min-height: 44px;
  padding: 10px 12px;
}

.form-grid textarea {
  min-height: 116px;
  resize: vertical;
}

.hint-box {
  border: 1px solid #bae6fd;
  border-radius: 16px;
  background: #f0f9ff;
  padding: 12px 14px;
  color: #075985;
  font-size: 13px;
  line-height: 1.65;
}

.hint-box strong {
  display: block;
  margin-bottom: 4px;
}

.hint-box p {
  margin: 0;
}

.file-input {
  padding: 10px;
}

.file-picker-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.file-picker-summary strong,
.file-picker-summary span {
  display: block;
}

.file-picker-summary strong {
  color: var(--ink);
  font-size: 14px;
}

.file-picker-summary span {
  margin-top: 3px;
  color: var(--quiet);
  font-size: 12px;
  line-height: 1.45;
}

.selected-files {
  display: grid;
  max-height: 190px;
  overflow: auto;
  gap: 8px;
  padding-right: 2px;
}

.selected-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.72);
}

.selected-file-row strong,
.selected-file-row span {
  display: block;
}

.selected-file-row strong {
  overflow: hidden;
  color: #1e293b;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file-row span {
  margin-top: 2px;
  color: var(--quiet);
  font-size: 12px;
}

.icon-btn.light {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
}

.empty.compact {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  box-shadow: none;
  font-size: 13px;
}

.products,
.codes {
  display: grid;
  gap: 12px;
}

.product-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.product-title {
  margin: 0 0 6px;
  font-weight: 850;
}

.product-meta,
.code-meta {
  color: var(--quiet);
  font-size: 13px;
  line-height: 1.6;
}

.product-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qty-input {
  width: 82px;
  text-align: center;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  margin-bottom: 14px;
}

.code-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.code-row.used {
  opacity: 0.72;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  border-radius: 26px;
  padding: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.login-card h1 {
  margin: 0 0 8px;
}

.login-card p {
  margin: 0 0 18px;
  color: var(--quiet);
}

.login-card form {
  display: grid;
  gap: 12px;
}

.toast {
  position: fixed;
  z-index: 30;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
}

.empty {
  padding: 34px 18px;
  text-align: center;
  color: #cbd5e1;
  font-weight: 800;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

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

  .admin-header,
  .product-row,
  .code-row,
  .file-row {
    grid-template-columns: 1fr;
  }

  .admin-header {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .portal {
    padding-top: 7vh;
  }

  .logo {
    font-size: 38px;
  }

  .tool-actions,
  .product-actions,
  .filter-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .admin {
    padding: 18px;
  }
}
