:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #17202e;
  --muted: #637083;
  --line: #dce2ea;
  --accent: #176b87;
  --accent-strong: #0f566f;
  --ok: #14764b;
  --danger: #a83232;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

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

.redeem-shell {
  width: min(920px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 42px 0;
}

.redeem-shell--result-only {
  width: min(760px, calc(100% - 32px));
}

.redeem-shell--result-only .content-panel {
  width: 100%;
  margin: 0 auto;
}

.redeem-panel,
.content-panel,
.login-shell,
.admin-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(22, 32, 46, 0.08);
}

.redeem-panel {
  padding: clamp(24px, 5vw, 44px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #e7f3f6;
  color: var(--accent);
}

h1 {
  margin: 22px 0 24px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: 0;
}

.redeem-form label,
.admin-form span,
.login-shell span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.redeem-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: min(420px, 100%);
  padding: 6px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
}

.redeem-tab {
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.redeem-tab:hover {
  background: #eaf2f6;
}

.redeem-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(23, 107, 135, 0.18);
}

.redeem-mode-panel {
  margin-top: 0;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

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

textarea {
  resize: vertical;
  min-height: 180px;
}

.batch-redeem-form {
  display: grid;
  gap: 10px;
}

.batch-redeem-form textarea {
  min-height: 110px;
}

.batch-redeem-form button {
  width: fit-content;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

button,
.download-button,
.ghost-link {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:hover,
.download-button:hover,
.ghost-link:hover {
  background: var(--accent-strong);
}

.ghost {
  background: #eef2f6;
  color: var(--text);
}

.ghost:hover {
  background: #e1e7ef;
}

.message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.content-panel {
  padding: 24px;
}

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

.result-toolbar-copy {
  display: grid;
  gap: 8px;
}

.result-toolbar-copy strong {
  font-size: clamp(24px, 3.2vw, 32px);
  line-height: 1.2;
}

.result-pill {
  display: inline-flex;
  width: fit-content;
  padding: 6px 12px;
  border-radius: 999px;
  background: #dff4ff;
  color: #0f566f;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.result-reset-button {
  width: auto;
  white-space: nowrap;
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 700;
}

.copy-content-button {
  width: auto;
  padding: 9px 12px;
  background: #eef2f6;
  color: var(--text);
}

.copy-content-button:hover {
  background: #e1e7ef;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.single-download-actions {
  margin-bottom: 4px;
}

.account-download-actions {
  display: block;
}

.usage-guide {
  position: relative;
  margin: 0;
  padding: 18px 20px 18px 22px;
  border: 1px solid #b9d7ff;
  border-left: 6px solid #176b87;
  border-radius: 12px;
  background: linear-gradient(135deg, #f4fbff 0%, #eef8ff 100%);
  box-shadow: 0 12px 28px rgba(23, 107, 135, 0.08);
}

.usage-guide::before {
  content: "下载前先看";
  display: inline-flex;
  margin-bottom: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #176b87;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.usage-guide h2 {
  margin: 0 0 10px;
  color: #0f566f;
  font-size: 22px;
  line-height: 1.35;
}

.usage-guide ul {
  margin: 0;
  padding-left: 20px;
  color: #244155;
  line-height: 1.75;
  font-weight: 600;
}

.usage-guide li + li {
  margin-top: 6px;
}

.usage-guide a {
  color: var(--accent-strong);
  font-weight: 700;
}

pre {
  margin: 12px 0 0;
  padding: 18px;
  min-height: 130px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  line-height: 1.65;
}

.download-button {
  display: inline-flex;
  min-width: 150px;
  justify-content: center;
}

.single-download-button {
  min-width: 188px;
  min-height: 64px;
  align-items: center;
  border: 2px solid #99f6e4;
  background: #0f766e;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
  font-size: 20px;
  letter-spacing: 0;
}

.single-download-button:hover {
  background: #0b5f59;
}

.account-download-button {
  width: 100%;
  min-height: 72px;
  align-items: center;
  border: 2px solid #ffd166;
  background: #d9480f;
  box-shadow: 0 14px 28px rgba(217, 72, 15, 0.28);
  font-size: 22px;
  letter-spacing: 0;
}

.account-download-button:hover {
  background: #b83b0c;
}

.copy-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--ok);
  font-weight: 700;
}

.admin-page {
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

.login-shell,
.admin-shell {
  width: min(960px, 100%);
  padding: 28px;
}

.login-shell {
  width: min(420px, 100%);
}

.records-shell {
  width: min(1280px, 100%);
}

.login-shell h1,
.admin-shell h1 {
  margin: 0 0 22px;
  font-size: 28px;
}

.login-shell form,
.admin-form {
  display: grid;
  gap: 18px;
}

.admin-section {
  padding-top: 22px;
  margin-top: 22px;
  border-top: 1px solid var(--line);
}

.admin-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: 0;
}

.admin-section h2 {
  margin: 0 0 16px;
  font-size: 20px;
  letter-spacing: 0;
}

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

.admin-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.ghost-link {
  display: inline-flex;
  background: #eef2f6;
  color: var(--text);
}

.ghost-link:hover {
  background: #e1e7ef;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--danger);
  background: #fff1f1;
  border: 1px solid #ffd2d2;
}

.result {
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #b8e3cf;
  background: #eefbf4;
  color: var(--ok);
}

.result strong {
  display: block;
  margin: 8px 0;
  color: var(--text);
  font-size: 30px;
  letter-spacing: 0;
}

.result p {
  margin: 0;
}

.copy-box {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.copy-box label {
  color: var(--text);
  font-weight: 800;
}

.copy-box textarea {
  min-height: 92px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-button {
  width: fit-content;
}

.copy-status {
  min-height: 20px;
  color: var(--ok);
  font-weight: 700;
}

.bulk-codes {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.bulk-codes div {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #cfe9dc;
  border-radius: 8px;
  background: #ffffff;
}

.bulk-codes span {
  color: var(--text);
  word-break: break-all;
}

.bulk-codes code {
  color: var(--text);
  font-weight: 800;
}

.batch-errors {
  margin-top: 16px;
  color: var(--danger);
}

.batch-errors ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.batch-errors li + li {
  margin-top: 4px;
}

.search-form {
  grid-template-columns: 1fr 180px 160px auto;
  align-items: end;
}

.records-bulk-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.checkbox-label input,
.selection-cell input {
  width: 16px;
  height: 16px;
}

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

.bulk-delete-button {
  padding: 9px 12px;
}

.records-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 18px;
  padding: 14px 16px;
  background: #fff;
}

.records-summary span {
  color: var(--muted);
  font-weight: 800;
}

.records-summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.records-summary strong {
  font-size: 24px;
}

.records-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.pagination-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.pagination-link:hover {
  background: #eef7fa;
}

.pagination-link.disabled {
  color: var(--muted);
  background: #f4f6f8;
  cursor: not-allowed;
  opacity: 0.7;
}

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

.records-table-wrap {
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.records-table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
}

.records-table th,
.records-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.records-table th {
  color: var(--muted);
  background: #f9fbfd;
  font-weight: 800;
}

.records-table td {
  color: var(--text);
}

.records-table .selection-cell {
  width: 58px;
  text-align: center;
  vertical-align: middle;
}

.records-table tr:last-child td {
  border-bottom: 0;
}

.records-table tr.md5-duplicate-row td {
  background: #fff7f7;
}

.records-table tr.md5-duplicate-row td:first-child {
  border-left: 3px solid var(--danger);
}

.records-table small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  word-break: break-all;
}

.md5-warning {
  color: var(--danger) !important;
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.used {
  color: #0f5f3d;
  background: #e3f7ec;
}

.status-pill.unused {
  color: #725600;
  background: #fff3bf;
}

.table-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.danger-button {
  width: auto;
  padding: 7px 10px;
  background: #fff1f1;
  color: var(--danger);
  border: 1px solid #ffd2d2;
}

.danger-button:hover {
  background: #ffe5e5;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (max-width: 640px) {
  .code-row {
    grid-template-columns: 1fr;
  }

  .result-toolbar,
  .result-head,
  .admin-shell header {
    align-items: stretch;
    flex-direction: column;
  }

  .download-button,
  .ghost-link,
  button {
    width: 100%;
  }

  .download-actions {
    flex-direction: column;
  }

  .bulk-codes div {
    grid-template-columns: 1fr;
  }

  .copy-button {
    width: 100%;
  }

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

  .records-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .records-bulk-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .table-actions {
    align-items: flex-start;
    flex-direction: column;
    white-space: normal;
  }

  .danger-button {
    width: 100%;
  }
}
