:root {
  --ink: #17202a;
  --muted: #6b7888;
  --paper: #ffffff;
  --paper-soft: #f7f9fb;
  --line: #d9e2ea;
  --line-dark: #b9c6d1;
  --navy: #19283a;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --teal-soft: #e6f5f2;
  --gold: #b66a14;
  --gold-soft: #fff4df;
  --rose: #c23b3b;
  --rose-soft: #fff0f0;
  --blue: #2563eb;
  --shadow: 0 22px 60px rgba(23, 32, 42, 0.12);
  --shadow-soft: 0 12px 28px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #edf2f5;
}

body.user-page {
  background:
    linear-gradient(135deg, rgba(25, 40, 58, 0.96) 0 34%, transparent 34% 100%),
    linear-gradient(180deg, #f5f8fa 0, #edf2f5 100%);
  position: relative;
}

body.user-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, #000 0, transparent 48%);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

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

button,
.link-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), #16828a);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.link-button:hover {
  background: linear-gradient(135deg, var(--teal-dark), #126f77);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.ghost {
  background: #eef3f5;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.ghost:hover {
  background: #e4ecef;
}

.danger-btn {
  background: linear-gradient(135deg, #c23b3b, #9f2d2d);
  box-shadow: 0 10px 22px rgba(194, 59, 59, 0.18);
}

.danger-btn:hover {
  background: linear-gradient(135deg, #a92f2f, #882424);
}

.small-btn {
  min-height: 36px;
  padding: 0 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
}

input,
select {
  height: 46px;
  padding: 0 13px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--teal);
}

textarea {
  min-height: 96px;
  padding: 11px 13px;
  resize: vertical;
  line-height: 1.5;
}

code {
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 56px;
  position: relative;
}

.site-top {
  min-height: 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  color: #102030;
  background: linear-gradient(135deg, #ffffff, #d8f1ec);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.admin-link {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
}

.admin-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.ad-band {
  min-height: 96px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(248, 252, 251, 0.94)),
    #fff;
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ad-band::before {
  content: "公告";
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  color: #6c3c00;
  background: var(--gold-soft);
  border: 1px solid #efd2a3;
  font-weight: 800;
}

.ad-band:empty::after {
  content: "广告和通知内容可在后台编辑";
  color: var(--muted);
}

.ad-band strong {
  color: var(--gold);
}

.ad-band a {
  color: var(--teal);
  font-weight: 800;
}

.redeem-panel {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 253, 0.98)),
    #fff;
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.redeem-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: linear-gradient(90deg, var(--teal), var(--blue), var(--gold));
}

.redeem-copy {
  text-align: center;
  padding-top: 8px;
}

.redeem-copy p {
  margin-top: 10px;
  font-size: 15px;
}

.redeem-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 12px;
  margin-top: 24px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f3f7f8;
}

.redeem-form input {
  height: 52px;
  border: 0;
  background: #fff;
  font-size: 17px;
  text-align: center;
  font-family: Consolas, "Microsoft YaHei", monospace;
  box-shadow: inset 0 0 0 1px rgba(217, 226, 234, 0.7);
}

.redeem-form input:focus {
  box-shadow: inset 0 0 0 1px var(--teal), 0 0 0 4px rgba(15, 118, 110, 0.13);
}

.redeem-form button {
  min-height: 52px;
}

.batch-redeem-form {
  grid-template-columns: minmax(0, 1fr) 128px;
  align-items: stretch;
}

.batch-redeem-form textarea {
  min-height: 112px;
  border: 0;
  background: #fff;
  font-size: 15px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  box-shadow: inset 0 0 0 1px rgba(217, 226, 234, 0.7);
  resize: vertical;
}

.batch-redeem-form button {
  min-height: 112px;
}

.notice {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
  text-align: center;
}

.notice.error,
.error-text {
  color: var(--rose);
}

.notice.ok {
  color: var(--teal);
}

.result {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(360px, 0.96fr);
  gap: 18px;
  margin-top: 20px;
  align-items: start;
}

.batch-actions {
  margin-top: 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.batch-actions p {
  margin-top: 5px;
}

.batch-button-row,
.batch-json-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.batch-json-buttons {
  display: contents;
}

.result-list {
  margin-top: 20px;
  display: grid;
  gap: 18px;
}

.result-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.failed-card {
  border-color: #efc2c2;
  background: linear-gradient(180deg, #fffafa, #fff4f4);
}

.result-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.result-index {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-weight: 800;
  font-size: 12px;
  margin-bottom: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(340px, 0.96fr);
  gap: 18px;
  align-items: start;
}

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

.compact-panel {
  box-shadow: none;
  background: linear-gradient(180deg, #fff, #fbfdfe);
}

.account-panel,
.mail-panel,
.login-panel,
.admin-card,
.table-panel,
.admin-top,
.stat {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.account-panel,
.mail-panel {
  padding: 20px;
}

.panel-head,
.admin-top,
.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-head p,
.card-title span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label input,
label textarea {
  margin-top: 7px;
  color: var(--ink);
  font-weight: 400;
}

.wide {
  grid-column: 1 / -1;
}

.raw-box {
  margin-top: 12px;
  min-height: 82px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
  background: var(--paper-soft);
}

.download-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.download-row a {
  min-height: 46px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid #e5cfa9;
  color: #6f3d00;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fff9ed, #ffefd0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.download-row a:hover {
  border-color: #c58d37;
  box-shadow: 0 10px 20px rgba(182, 106, 20, 0.12);
}

.mail-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px 96px;
  gap: 10px;
  margin-top: 18px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 800;
}

.mode-badge:empty {
  display: none;
}

.mail-list {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.mail-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  background: linear-gradient(180deg, #fff, #f8fbfc);
}

.mail-item strong {
  display: block;
  margin-bottom: 7px;
}

.mail-meta {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.code-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  margin-top: 9px;
  font-weight: 800;
}

.admin-page {
  background:
    linear-gradient(180deg, #eef3f5 0, #f6f8f9 260px),
    #f6f8f9;
}

.admin-shell {
  width: min(1240px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 52px;
}

.login-panel {
  max-width: 440px;
  margin: 72px auto 0;
  padding: 28px;
}

.login-head {
  text-align: center;
}

.login-head p {
  margin-top: 9px;
}

.stack-form {
  display: grid;
  gap: 11px;
  margin-top: 18px;
}

.admin-app {
  display: grid;
  gap: 18px;
}

.admin-top {
  padding: 20px;
  align-items: center;
  background:
    linear-gradient(135deg, #ffffff, #f4faf9);
}

.admin-top p {
  margin-top: 7px;
}

.top-actions,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.stat {
  padding: 16px;
  overflow: hidden;
  position: relative;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.stat strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.stat span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1.12fr;
  gap: 18px;
}

.import-paths {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-soft);
  color: var(--muted);
}

.search-card {
  display: grid;
  gap: 14px;
}

.admin-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
}

.admin-search-results {
  display: grid;
  gap: 12px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.empty-result {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-dark);
  border-radius: 14px;
  color: var(--muted);
  background: var(--paper-soft);
}

.search-result-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f8fbfc);
}

.search-result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.search-result-head h3 {
  margin: 0;
  font-size: 17px;
}

.search-result-head p {
  margin-top: 5px;
  font-size: 13px;
}

.search-meta,
.search-cards {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.search-cards code {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 8px;
  border-radius: 8px;
  background: #eef3f5;
}

.search-result-card textarea {
  margin-top: 10px;
  min-height: 76px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
}

.admin-card,
.table-panel {
  padding: 20px;
}

.wide-card {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 12px;
}

#generatedCards,
#adHtml {
  margin-top: 12px;
  min-height: 132px;
  font-family: Consolas, "Microsoft YaHei", monospace;
}

pre {
  min-height: 84px;
  max-height: 220px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  background: #101b28;
  color: #dce8ef;
  border: 1px solid #253548;
  border-radius: 12px;
  white-space: pre-wrap;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

.table-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.table-toolbar select {
  width: auto;
  min-width: 150px;
}

.scroll-table {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.scroll-table table {
  margin: 0;
}

.scroll-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  text-align: left;
  padding: 12px 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 800;
  background: var(--paper-soft);
}

tbody tr:hover {
  background: #f8fbfc;
}

tbody tr.unredeemed-row {
  background: #fffdf8;
}

tbody tr.redeemed-row {
  background: #f8fcfa;
}

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 800;
}

.type-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  font-weight: 800;
  background: #eef3f5;
  color: var(--ink);
  white-space: nowrap;
}

.type-mail_json {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.type-rt,
.type-at {
  background: #e9efff;
  color: #244aa5;
}

.status-disabled,
.status.disabled {
  background: var(--rose-soft);
  color: var(--rose);
}

.status-active {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.status-available {
  background: #e8f7eb;
  color: #146c2e;
}

.status-assigned {
  background: var(--gold-soft);
  color: #8a4b00;
}

@media (max-width: 940px) {
  h1 {
    font-size: 32px;
  }

  .result,
  .result-grid,
  .admin-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .download-row {
    grid-template-columns: 1fr;
  }

  .batch-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .batch-button-row {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .shell,
  .admin-shell {
    width: min(100% - 22px, 1160px);
    padding-top: 16px;
  }

  body.user-page {
    background:
      linear-gradient(180deg, var(--navy) 0 220px, #edf2f5 220px),
      #edf2f5;
  }

  .site-top {
    margin-bottom: 14px;
  }

  .redeem-panel,
  .account-panel,
  .mail-panel,
  .admin-card,
  .table-panel,
  .admin-top,
  .login-panel,
  .ad-band {
    padding: 16px;
    border-radius: 16px;
  }

  h1 {
    font-size: 28px;
  }

  .redeem-form,
  .batch-redeem-form,
  .mail-controls,
  .field-grid,
  .admin-search-row {
    grid-template-columns: 1fr;
  }

  .redeem-form {
    padding: 7px;
  }

  .panel-head,
  .admin-top,
  .card-title,
  .result-card-head,
  .search-result-head {
    flex-direction: column;
  }

  .top-actions,
  .button-row,
  .table-toolbar {
    width: 100%;
  }

  .top-actions > *,
  .button-row > *,
  .batch-button-row > *,
  .table-toolbar > * {
    flex: 1;
  }
}
