:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --ink: #1c2430;
  --muted: #667085;
  --card: #ffffff;
  --line: #e8e1d7;
  --green: #19a974;
  --orange: #ff8a3d;
  --pink: #f45d8f;
  --blue: #4385f5;
  --shadow: 0 18px 45px rgba(32, 38, 48, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 138, 61, 0.22), transparent 28rem),
    radial-gradient(circle at 90% 12%, rgba(67, 133, 245, 0.18), transparent 18rem),
    var(--bg);
}

.page-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.hero {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px 4px 22px;
}

.hero-badge {
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  box-shadow: 0 10px 22px rgba(244, 93, 143, 0.28);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 14px;
  max-width: 10em;
  font-size: clamp(34px, 11vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero p {
  margin-top: 14px;
  max-width: 24em;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.claim-panel,
.merchant-section {
  border: 1px solid rgba(232, 225, 215, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.claim-panel {
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 20px;
}

.section-head span {
  flex: 0 0 auto;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.claim-form {
  display: grid;
  gap: 14px;
}

.notice-bar {
  margin-bottom: 16px;
  padding: 12px 13px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
  background: #fff7ed;
}

.notice-bar strong {
  font-size: 16px;
  letter-spacing: 0;
}

.wechat-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid #d9efe6;
  border-radius: 8px;
  background: #f0fbf6;
}

.wechat-status strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.wechat-status p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-button {
  flex: 0 0 auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  background: var(--green);
}

.is-hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 14px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  font: inherit;
  background: #fbfaf8;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(67, 133, 245, 0.14);
}

button {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, #1c2430, #34506f);
  box-shadow: 0 14px 28px rgba(28, 36, 48, 0.22);
  cursor: pointer;
}

button:disabled {
  background: #98a2b3;
  box-shadow: none;
  cursor: not-allowed;
}

.form-message {
  min-height: 20px;
  color: #d92d20;
  font-size: 13px;
}

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

.admin-hero {
  min-height: 190px;
}

.small-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: none;
}

.muted-button {
  color: #344054;
  background: #eef2f6;
}

.muted-button:disabled {
  color: #98a2b3;
  background: #f2f4f7;
}

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

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

.stats-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.stats-grid strong {
  display: block;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

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

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  color: #344054;
  font-size: 13px;
  box-shadow: none;
  background: #eef2f6;
}

.filter-button.is-active {
  color: #ffffff;
  background: #1c2430;
}

.admin-status {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.admin-status.unused {
  color: #0f7a53;
  background: #dcfae6;
}

.admin-status.used {
  color: #344054;
  background: #e4e7ec;
}

.admin-card-list {
  display: grid;
  gap: 12px;
}

.admin-merchant-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.admin-merchant-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.admin-merchant-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.admin-controls {
  display: grid;
  gap: 10px;
}

.admin-controls select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  background: #fbfaf8;
}

.redeem-confirm {
  width: 100%;
  margin-top: 16px;
}

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

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

th {
  color: #344054;
  font-weight: 800;
  background: #fbfaf8;
}

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

.mono-cell {
  max-width: 180px;
  overflow: hidden;
  font-family: Consolas, "SFMono-Regular", monospace;
  text-overflow: ellipsis;
}

.codes-cell {
  min-width: 220px;
}

.codes-cell span {
  display: block;
  margin-bottom: 5px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.codes-cell strong {
  display: inline-block;
  min-width: 72px;
  color: #344054;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.codes-cell em {
  display: block;
  margin: 2px 0;
  color: #667085;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-style: normal;
}

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

.merchant-section {
  margin-top: 18px;
  padding: 18px;
}

.merchant-section.is-hidden {
  display: none;
}

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

.merchant-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.coupon-card {
  align-items: start;
}

.coupon-card.is-redeemed {
  border-color: #d0d5dd;
  background: #f2f4f7;
}

.coupon-card.is-redeemed::after {
  content: "已核销";
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  padding: 7px 11px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  background: rgba(52, 64, 84, 0.92);
}

.coupon-card.is-redeemed .merchant-photo {
  filter: grayscale(0.95) brightness(0.88);
}

.coupon-card.is-redeemed .merchant-body {
  opacity: 0.78;
}

.merchant-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  object-position: center;
  background: #eef2f6;
  filter: brightness(1.04) contrast(1.04) saturate(1.03);
  image-rendering: auto;
}

.merchant-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
}

.small-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  font-size: 16px;
}

.merchant-body {
  padding: 14px;
}

.merchant-body h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.coupon-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.title-with-icon {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
}

.coupon-title-row h3 {
  margin-bottom: 0;
}

.merchant-body p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.merchant-location {
  margin-top: 7px;
  color: #344054 !important;
  font-weight: 700;
}

.merchant-bonus,
.merchant-time {
  margin-top: 5px;
}

.merchant-bonus {
  color: #d45b14 !important;
  font-weight: 700;
}

.merchant-time {
  color: #0f7a53 !important;
}

.coupon-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #0f7a53;
  font-size: 12px;
  font-weight: 800;
  background: #dcfae6;
}

.redeemed-tag {
  color: #344054;
  background: #e4e7ec;
}

.coupon-meta {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.coupon-meta div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.coupon-meta dt,
.coupon-meta dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

.coupon-meta dt {
  color: #667085;
}

.coupon-meta dd {
  color: #1c2430;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.code-text {
  color: #d45b14 !important;
  font-family: Consolas, "SFMono-Regular", monospace;
  letter-spacing: 0;
}

.multi-line {
  min-width: 220px;
  white-space: pre-line;
  line-height: 1.55;
}

.redeem-box {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #d9efe6;
  border-radius: 8px;
  background: #f0fbf6;
}

.redeem-qr {
  width: 92px;
  height: 92px;
  display: block;
  border-radius: 6px;
  background: #ffffff;
}

.redeem-box strong {
  display: block;
  margin-bottom: 5px;
  color: #0f7a53;
  font-size: 15px;
}

.redeem-box p {
  color: #344054;
  font-size: 13px;
}

.merchant-qr-list {
  display: grid;
  gap: 14px;
}

.merchant-qr-card {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  background: #ffffff;
}

.merchant-qr-card h2 {
  font-size: 22px;
}

.merchant-qr-card p {
  color: var(--muted);
  font-size: 14px;
}

.merchant-qr-card img {
  width: min(100%, 260px);
  height: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.merchant-qr-card strong {
  color: #0f7a53;
}

.merchant-qr-card small {
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.redeem-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.redeem-panel {
  width: min(100%, 520px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.redeem-panel h1 {
  max-width: none;
  margin-top: 12px;
  font-size: 32px;
}

.redeem-panel > p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.redeem-badge {
  width: fit-content;
  padding: 7px 12px;
  border-radius: 999px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  background: #eef2f6;
}

.redeem-badge.success {
  color: #0f7a53;
  background: #dcfae6;
}

.redeem-badge.warning {
  color: #b54708;
  background: #fef0c7;
}

.redeem-badge.error {
  color: #b42318;
  background: #fee4e2;
}

.redeem-detail {
  margin-top: 18px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: #fbfaf8;
}

.verify-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.verify-result strong {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
}

.verify-result p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.verify-result.valid {
  border-color: #a9e8c8;
  background: #f0fbf6;
}

.verify-result.invalid {
  border-color: #fecaca;
  background: #fff5f5;
}

@media (min-width: 680px) {
  .page-shell {
    padding-top: 34px;
  }

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

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

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

  .admin-controls {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .page-shell {
    width: 100%;
    padding: 12px;
  }

  .hero,
  .claim-panel,
  .verify-form,
  #verifyResult,
  #clearButton {
    display: none !important;
  }

  .merchant-section {
    margin-top: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .merchant-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .merchant-qr-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .merchant-card {
    break-inside: avoid;
    box-shadow: none;
  }

  .merchant-photo {
    aspect-ratio: 16 / 9;
    filter: brightness(1.03) contrast(1.05);
  }

  .redeem-box {
    border-color: #b7e4ca;
  }

  .redeem-qr {
    width: 82px;
    height: 82px;
  }
}
