:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --surface-tint: #eef7f4;
  --text: #14211c;
  --muted: #66736f;
  --line: #dce5e1;
  --line-strong: #c6d3ce;
  --accent: #12805f;
  --accent-dark: #0b5e46;
  --blue: #245fa8;
  --blue-soft: #eaf1fb;
  --amber: #a96f00;
  --amber-soft: #fff4dd;
  --red: #b42318;
  --red-soft: #fff1ef;
  --shadow: 0 16px 42px rgba(20, 33, 28, 0.08);
  --shadow-soft: 0 10px 24px rgba(20, 33, 28, 0.06);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), transparent 22rem),
    var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  user-select: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(220, 229, 225, 0.82);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  width: min(1200px, calc(100% - 2rem));
  min-height: 4.5rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  font-weight: 900;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(135deg, var(--accent), var(--blue));
  box-shadow: 0 8px 20px rgba(18, 128, 95, 0.18);
  font-size: 0.78rem;
}

.brand-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  color: var(--muted);
  font-weight: 800;
}

.nav-link,
.link-button,
.origin-chip {
  min-height: 2.35rem;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  white-space: nowrap;
}

.nav-link {
  padding: 0 0.8rem;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--accent-dark);
  background: var(--surface-tint);
}

.origin-chip {
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  color: var(--blue);
  background: var(--blue-soft);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.86rem;
}

.link-button {
  border: 0;
  padding: 0 0.8rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.link-button:hover {
  color: var(--accent-dark);
  background: var(--surface-tint);
}

.redeem-shell {
  width: min(940px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3.5rem 0 4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: start;
}

.hero-area {
  min-height: auto;
  display: grid;
  justify-items: center;
  text-align: center;
}

.hero-copy {
  width: min(760px, 100%);
  padding-top: 0.5rem;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: 3rem;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1rem;
}

.intro-copy {
  margin: 1rem 0 0;
  max-width: none;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.75;
}

.stat,
.account-grid div,
.format-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.signal-board {
  width: min(100%, 34rem);
  margin-top: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(198, 211, 206, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(18, 128, 95, 0.9), rgba(13, 34, 45, 0.95)),
    #10231f;
  box-shadow: var(--shadow);
  color: #ffffff;
}

.signal-top {
  height: 3rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.signal-top span {
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.62);
}

.signal-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.signal-grid div {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.06);
}

.signal-grid small {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.72rem;
  font-weight: 900;
}

.signal-grid b {
  display: block;
  margin-top: 0.45rem;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.95rem;
}

.panel {
  border: 1px solid rgba(220, 229, 225, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.redeem-panel {
  width: 100%;
  justify-self: center;
  padding: 1.5rem;
}

.panel-title,
.result-head,
.section-head,
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-title {
  margin-bottom: 1.2rem;
}

.soft-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0 0.7rem;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--surface-tint);
  font-size: 0.85rem;
  font-weight: 900;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(4.5rem, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mode-button {
  min-height: 2.35rem;
  border: 0;
  border-radius: 6px;
  padding: 0 0.9rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.mode-button.active {
  color: #ffffff;
  background: var(--accent);
}

.stack {
  display: grid;
  gap: 0.75rem;
}

label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 850;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input,
select {
  min-height: 3.15rem;
  padding: 0 0.95rem;
}

textarea {
  min-height: 8.5rem;
  padding: 0.9rem 0.95rem;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(18, 128, 95, 0.13);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
}

.primary-button,
.ghost-button {
  min-height: 3.15rem;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 1rem;
  cursor: pointer;
  font-weight: 900;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(18, 128, 95, 0.22);
}

.primary-button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.64;
  transform: none;
}

.ghost-button {
  color: var(--accent-dark);
  border-color: var(--line);
  background: #ffffff;
}

.ghost-button:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.full {
  width: 100%;
}

.message {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-tint);
  line-height: 1.55;
}

.message.success {
  border-color: rgba(18, 128, 95, 0.25);
  color: var(--accent-dark);
}

.message.error {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--red);
  background: var(--red-soft);
}

.result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.account-grid div {
  padding: 0.9rem;
  background: var(--surface-soft);
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

dd {
  margin: 0.35rem 0 0;
  overflow-wrap: anywhere;
  font-family: Consolas, "Courier New", monospace;
}

.result textarea {
  margin: 0.5rem 0 1rem;
  font-family: Consolas, "Courier New", monospace;
}

.result-actions {
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.code-panel {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid rgba(18, 128, 95, 0.22);
  border-radius: 8px;
  background: var(--surface-tint);
}

.code-panel span,
.code-panel small {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.code-panel strong {
  display: block;
  margin-top: 0.25rem;
  font-family: Consolas, "Courier New", monospace;
  font-size: 2rem;
  line-height: 1;
}

.code-panel small {
  grid-column: 1 / -1;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.admin-layout {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.login-shell {
  width: min(28rem, 100%);
  min-height: calc(100vh - 8rem);
  margin: 0 auto;
  display: grid;
  align-items: center;
}

.login-visual {
  min-height: 25rem;
  padding: 1.5rem;
  display: grid;
  align-content: space-between;
  color: #ffffff;
  background:
    linear-gradient(145deg, rgba(18, 128, 95, 0.96), rgba(31, 65, 112, 0.96)),
    #173a36;
}

.login-visual .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.login-visual h1 {
  font-size: 3rem;
}

.login-metric {
  display: grid;
  gap: 0.45rem;
}

.login-metric span {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 900;
}

.login-metric strong {
  font-family: Consolas, "Courier New", monospace;
  font-size: 2.1rem;
}

.login-lines {
  display: grid;
  gap: 0.7rem;
}

.login-lines span {
  display: block;
  height: 0.65rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
}

.login-lines span:nth-child(2) {
  width: 76%;
}

.login-lines span:nth-child(3) {
  width: 54%;
}

.auth-panel {
  padding: 1.5rem;
}

.auth-panel h1 {
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
}

.admin-head {
  margin-bottom: 1.25rem;
}

.admin-head h1 {
  font-size: 2rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(7rem, 1fr));
  gap: 0.75rem;
}

.stat {
  padding: 0.95rem;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: none;
}

.stat span {
  display: block;
  margin-top: 0.4rem;
  font-size: 1.9rem;
  line-height: 1;
  font-weight: 900;
}

.stat small {
  color: var(--muted);
  font-weight: 900;
}

.stat-available {
  border-color: rgba(18, 128, 95, 0.24);
}

.stat-redeemed {
  border-color: rgba(169, 111, 0, 0.24);
}

.import-panel,
.table-panel {
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.section-head {
  margin-bottom: 1rem;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 0.36fr);
  gap: 1rem;
  align-items: start;
}

.import-grid-single {
  grid-template-columns: 1fr;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 2.55rem;
  padding: 0 0.85rem;
  border-radius: 6px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 900;
}

.segmented input:checked + span {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(18, 128, 95, 0.18);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(10rem, 16rem);
}

.inventory-input {
  min-height: 14rem;
  font-family: Consolas, "Courier New", monospace;
}

.generate-form {
  display: grid;
  grid-template-columns: minmax(10rem, 16rem) auto;
  gap: 0.75rem;
  align-items: end;
}

.format-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: var(--surface-soft);
}

.format-panel h3 {
  margin-bottom: 0.75rem;
}

.format-row {
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem;
}

.format-row + .format-row {
  margin-top: 0.55rem;
}

.format-row span {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 8px;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
}

.format-row code,
.import-result code,
.mono {
  font-family: Consolas, "Courier New", monospace;
}

.import-result {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
  color: var(--muted);
}

.import-result code {
  color: var(--text);
  overflow-wrap: anywhere;
}

.toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.toolbar select {
  width: 8rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  color: var(--muted);
  font-weight: 800;
}

.pagination-actions {
  display: inline-flex;
  gap: 0.5rem;
}

table {
  width: 100%;
  min-width: 58rem;
  border-collapse: collapse;
}

th,
td {
  padding: 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8faf9;
  font-size: 0.84rem;
}

td {
  overflow-wrap: anywhere;
}

tbody tr:hover {
  background: #fbfdfc;
}

.account-raw {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 4.5rem;
  min-height: 1.8rem;
  padding: 0 0.5rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 900;
}

.badge.available {
  color: var(--accent-dark);
  background: var(--surface-tint);
}

.badge.redeemed {
  color: var(--amber);
  background: var(--amber-soft);
}

@media (max-width: 900px) {
  h1 {
    font-size: 2.7rem;
  }

  .redeem-shell,
  .login-shell {
    grid-template-columns: 1fr;
  }

  .hero-area {
    min-height: auto;
  }

  .login-visual {
    min-height: 18rem;
  }

  .admin-head,
  .section-head,
  .panel-title,
  .result-head {
    display: grid;
    justify-items: stretch;
  }

  .stats,
  .import-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .redeem-shell,
  .admin-layout {
    width: min(100% - 1rem, 100%);
  }

  .topbar-inner {
    min-height: 4rem;
  }

  .brand-text,
  .origin-chip {
    display: none;
  }

  h1 {
    font-size: 2.35rem;
  }

  .redeem-shell {
    padding-top: 2rem;
  }

  .signal-grid,
  .input-row,
  .account-grid,
  .field-row,
  .generate-form {
    grid-template-columns: 1fr;
  }

  .redeem-panel,
  .import-panel,
  .table-panel,
  .auth-panel,
  .login-visual {
    padding: 1rem;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .pagination {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pagination-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .result-actions,
  .code-panel {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar select,
  .toolbar button,
  .result-actions button {
    width: 100%;
  }

  .segmented {
    display: grid;
    grid-template-columns: 1fr;
  }
}
