:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #65707d;
  --line: #dde2dc;
  --green: #246b55;
  --green-dark: #174b3b;
  --blue: #3158a8;
  --orange: #b86824;
  --red: #b54242;
  --shadow: 0 18px 50px rgba(38, 45, 54, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(36, 107, 85, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(184, 104, 36, 0.09), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  margin-bottom: 18px;
}

.ad-banner {
  position: relative;
  isolation: isolate;
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px 24px;
  overflow: hidden;
  border: 1px solid rgba(247, 196, 80, 0.55);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, rgba(247, 196, 80, 0.23), transparent 34%),
    linear-gradient(135deg, #0f3a3c 0%, #164f49 48%, #9a4d18 100%);
  color: #fff;
  box-shadow: 0 20px 52px rgba(50, 58, 55, 0.18);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.ad-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px,
      transparent 14px
    );
  opacity: 0.55;
}

.ad-banner:hover {
  border-color: rgba(255, 216, 107, 0.9);
  box-shadow: 0 24px 58px rgba(50, 58, 55, 0.24);
  transform: translateY(-1px);
}

.ad-banner:focus-visible {
  outline: 3px solid rgba(247, 196, 80, 0.55);
  outline-offset: 3px;
}

.ad-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
}

.ad-kicker {
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  padding: 5px 10px;
  color: #ffe8a5;
  font-size: 12px;
  font-weight: 900;
}

.ad-content strong {
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
}

.ad-content span:last-child {
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.5;
}

.ad-services {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: #fff;
}

.ad-services span {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  padding: 6px 10px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.ad-cta {
  position: relative;
  z-index: 1;
  min-height: 44px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: #ffd66b;
  color: #24302c;
  padding: 0 18px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(28, 30, 28, 0.2);
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

.admin-link,
.ghost,
.primary {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  font-weight: 800;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}

.admin-link,
.ghost {
  background: #f8faf7;
  border-color: var(--line);
  color: var(--ink);
}

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

.primary:hover {
  background: var(--green-dark);
}

.ghost:hover,
.admin-link:hover {
  border-color: #b8c0b8;
  background: #fff;
}

.primary:active,
.ghost:active,
.admin-link:active {
  transform: translateY(1px);
}

.compact {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

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

.redeem-form,
.result-panel,
.import-panel,
.inventory-panel,
.login-panel {
  padding: 20px;
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  color: var(--ink);
  outline: none;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 107, 85, 0.13);
}

textarea {
  min-height: 290px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

.actions,
.inline-form,
.filters {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.inline-form {
  align-items: stretch;
}

.form-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

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

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

.summary-grid div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 12px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1;
}

.empty {
  min-height: 170px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed #cbd3ca;
  border-radius: var(--radius);
  background: #fbfcfa;
}

.results {
  display: grid;
  gap: 12px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.result-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.code {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.badge {
  min-width: 64px;
  border-radius: 999px;
  padding: 5px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.success {
  background: rgba(36, 107, 85, 0.12);
  color: var(--green-dark);
}

.failed {
  background: rgba(181, 66, 66, 0.12);
  color: var(--red);
}

.disabled {
  background: rgba(49, 88, 168, 0.12);
  color: var(--blue);
}

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

.field {
  min-height: 54px;
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 9px 10px;
  overflow: hidden;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.25;
}

.message {
  margin: 0;
  color: var(--muted);
}

.login-panel {
  max-width: 560px;
}

.hidden {
  display: none !important;
}

.filters {
  margin-bottom: 12px;
}

.filters select {
  width: 140px;
  flex: 0 0 140px;
}

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

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  background: #f8faf7;
  font-size: 12px;
  font-weight: 900;
}

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

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tiny {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.tiny.danger {
  border-color: rgba(181, 66, 66, 0.3);
  color: var(--red);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 28px));
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #20242a;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  .shell {
    width: min(100vw - 20px, 680px);
    padding: 10px 0;
  }

  .hero,
  .ad-banner,
  .section-head,
  .actions,
  .inline-form,
  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .ad-banner {
    min-height: 0;
    padding: 18px;
  }

  .ad-cta {
    width: 100%;
  }

  .redeem-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .admin-stats,
  .card-grid {
    grid-template-columns: 1fr;
  }

  textarea {
    min-height: 210px;
  }

  .filters select {
    width: 100%;
    flex-basis: auto;
  }
}
