:root {
  --paper: #fff5fa;
  --surface: #fffafd;
  --surface-strong: #ffffff;
  --ink: #3d1734;
  --ink-soft: #633d5a;
  --muted: #926f87;
  --line: #f0d6e5;
  --line-dark: #d9aac5;
  --deep: #611847;
  --deep-2: #992d70;
  --lime: #ffb4d4;
  --orange: #f57f9b;
  --orange-soft: #fff0f5;
  --green: #b02d72;
  --green-soft: #ffe9f3;
  --red: #c54b64;
  --red-soft: #fff0f3;
  --shadow: 0 18px 60px rgba(111, 24, 78, 0.1);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Menlo,
    monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.35;
  background-image:
    linear-gradient(to right, rgba(174, 56, 124, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(174, 56, 124, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 70%);
  pointer-events: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

code,
pre {
  font-family: var(--font-mono);
}

[hidden] {
  display: none !important;
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: 0 40px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 245, 250, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  text-decoration: none;
  font-weight: 700;
}

.brand-mark {
  width: 34px;
  height: 34px;
  background-color: #ffd6e6;
  background-image: url("/assets/sanjiu.jpeg");
  background-position: 50% 6%;
  background-size: 280% auto;
  border: 2px solid var(--surface-strong);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line-dark);
}

.brand-text {
  font-size: 15px;
  letter-spacing: 0;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 253, 0.86);
}

.nav-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 92px;
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    color 160ms ease,
    background-color 160ms ease;
}

.nav-user-dot {
  position: absolute;
  top: 7px;
  right: 9px;
  width: 5px;
  height: 5px;
  background: var(--orange);
  border-radius: 50%;
}

.nav-button .icon {
  width: 16px;
  height: 16px;
}

.nav-button:hover {
  color: var(--ink);
}

.nav-button.is-active {
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 1px 4px rgba(126, 31, 88, 0.12);
}

.upstream-state {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c3a5b6;
}

.upstream-state.is-ready .status-dot {
  background: #d84b93;
  box-shadow: 0 0 0 4px rgba(216, 75, 147, 0.12);
}

.upstream-state.is-warning .status-dot {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(245, 127, 155, 0.14);
}

.app-shell {
  width: min(1240px, calc(100% - 64px));
  margin: 0 auto;
}

.view {
  padding: 68px 0 96px;
  animation: view-in 300ms ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.redeem-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, 0.9fr);
  gap: clamp(48px, 7vw, 110px);
  align-items: center;
  min-height: 530px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.eyebrow-line {
  width: 58px;
  height: 1px;
  background: var(--green);
}

.redeem-main h1,
.page-heading h1,
.admin-login h1 {
  margin: 0;
  font-size: clamp(42px, 5.1vw, 68px);
  font-weight: 650;
  line-height: 1.06;
  letter-spacing: 0;
}

.lede {
  max-width: 610px;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.8;
}

.redeem-form {
  max-width: 680px;
  margin-top: 40px;
}

.field-label {
  display: block;
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.redeem-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .icon {
  position: absolute;
  left: 17px;
  z-index: 1;
  color: var(--muted);
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  height: 58px;
  padding: 0 18px 0 49px;
  border: 1px solid var(--line-dark);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: var(--surface-strong);
  font-family: var(--font-mono);
  font-size: 14px;
  text-transform: uppercase;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.input-with-icon input::placeholder {
  color: #b698aa;
  text-transform: none;
}

.input-with-icon input:focus {
  border-color: var(--deep-2);
  box-shadow: 0 0 0 4px rgba(176, 45, 114, 0.11);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.button-primary {
  min-height: 58px;
  padding: 0 22px;
  color: var(--surface-strong);
  background: var(--deep);
  border-color: var(--deep);
}

.button-primary:hover {
  background: var(--deep-2);
  border-color: var(--deep-2);
}

.button-quiet {
  color: var(--ink-soft);
  background: transparent;
  border-color: var(--line);
}

.button-quiet:hover {
  background: var(--surface-strong);
  border-color: var(--line-dark);
}

.button-wide {
  width: 100%;
  margin-top: 12px;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  min-height: 22px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.form-error {
  margin: 0;
  color: var(--red);
  font-size: 12px;
  text-align: right;
}

.fact-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 680px;
  margin: 38px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
}

.fact-strip div {
  padding: 0 20px;
  border-left: 1px solid var(--line);
}

.fact-strip div:first-child {
  padding-left: 0;
  border-left: 0;
}

.fact-strip dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
}

.fact-strip dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.card-stage {
  position: relative;
  min-height: 390px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-stage::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 150px;
  height: 150px;
  content: "";
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 0 150px;
}

.stage-label {
  position: relative;
  z-index: 1;
  margin-bottom: 18px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.gift-card {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 234px;
  padding: 24px 25px 22px;
  color: #fff8fc;
  background-color: var(--deep);
  border: 1px solid #410d31;
  border-radius: 8px;
  box-shadow:
    0 20px 40px rgba(82, 11, 58, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.gift-card::before {
  position: absolute;
  right: -54px;
  bottom: -80px;
  width: 250px;
  height: 250px;
  content: "";
  border: 36px solid rgba(255, 180, 212, 0.95);
  border-radius: 50%;
}

.gift-card::after {
  position: absolute;
  right: 26px;
  top: 48px;
  width: 96px;
  height: 96px;
  content: "";
  background-color: #ffd6e6;
  background-image: url("/assets/sanjiu.jpeg");
  background-position: 50% 8%;
  background-size: cover;
  border: 4px solid rgba(255, 248, 252, 0.62);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 10px 24px rgba(40, 5, 29, 0.2);
}

.gift-card-top,
.card-bottom {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-brand {
  width: 38px;
  height: 38px;
  background-color: #ffd6e6;
  background-image: url("/assets/sanjiu.jpeg");
  background-position: 50% 6%;
  background-size: 280% auto;
  border: 2px solid rgba(255, 248, 252, 0.74);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(65, 13, 49, 0.5);
}

.card-chip {
  display: block;
  width: 36px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 5px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1)),
    var(--deep-2);
}

.card-chip::before,
.card-chip::after {
  display: block;
  width: 1px;
  height: 100%;
  margin-left: 12px;
  content: "";
  background: rgba(255, 255, 255, 0.2);
  float: left;
}

.card-chip::after {
  margin-left: 10px;
}

.card-amount {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  margin-top: 28px;
}

.currency {
  margin-top: 8px;
  margin-right: 5px;
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
}

.amount {
  font-size: 72px;
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: 0;
}

.amount-note {
  align-self: flex-end;
  margin: 0 0 9px 12px;
  color: rgba(255, 248, 252, 0.66);
  font-size: 10px;
}

.card-bottom {
  margin-top: 33px;
}

.card-caption {
  display: block;
  margin-bottom: 5px;
  color: rgba(255, 248, 252, 0.52);
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0;
}

.card-bottom strong {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.card-serial {
  display: flex;
  gap: 10px;
  color: rgba(255, 248, 252, 0.74);
  font-family: var(--font-mono);
  font-size: 10px;
}

.stage-note {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 14px;
  margin-top: 24px;
}

.stage-index {
  color: var(--orange);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.stage-note p {
  max-width: 270px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.docs-band {
  display: grid;
  grid-template-columns: minmax(260px, 0.65fr) minmax(0, 1.35fr);
  gap: 70px;
  margin-top: 68px;
  padding-top: 64px;
  border-top: 1px solid var(--line);
}

.section-kicker {
  display: block;
  margin-bottom: 12px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

.docs-heading h2,
.panel-heading h2,
.generate-copy h2,
.connect-intro h2,
.modal h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: 0;
}

.docs-heading p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

code {
  font-size: 0.92em;
}

.docs-heading code {
  padding: 2px 5px;
  color: var(--ink-soft);
  background: #f8e7f0;
  border-radius: 3px;
}

.code-window {
  min-width: 0;
  color: #ffeaf4;
  background: #421237;
  border: 1px solid #310828;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.code-toolbar {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px 0 18px;
  color: #c6a8b9;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 10px;
}

.window-dots {
  display: flex;
  gap: 5px;
  margin-right: auto;
}

.window-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7c506d;
}

.window-dots span:nth-child(2) {
  background: #ad8199;
}

.window-dots span:nth-child(3) {
  background: var(--lime);
}

.code-toolbar > span {
  margin-right: 18px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition:
    color 150ms ease,
    background-color 150ms ease,
    border-color 150ms ease;
}

.icon-button:hover {
  color: var(--ink);
  background: rgba(148, 42, 105, 0.07);
}

.copy-button {
  color: #bca0b0;
}

.code-window .copy-button:hover {
  color: var(--lime);
  background: rgba(255, 255, 255, 0.06);
}

.code-window pre {
  margin: 0;
  padding: 26px 28px 30px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.75;
  tab-size: 2;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 36px;
}

.page-heading h1 {
  font-size: clamp(38px, 4.2vw, 54px);
}

.heading-actions {
  display: flex;
  gap: 8px;
}

.connect-panel {
  max-width: 760px;
  margin: 80px auto;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.75fr);
  gap: clamp(40px, 7vw, 96px);
  align-items: center;
  min-height: 480px;
}

.auth-index {
  display: block;
  margin-bottom: 22px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.auth-intro h2 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(36px, 4.5vw, 58px);
  font-weight: 650;
  line-height: 1.16;
  letter-spacing: 0;
}

.auth-intro > p {
  max-width: 580px;
  margin: 22px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.8;
}

.auth-benefits {
  display: grid;
  gap: 10px;
  margin: 26px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 12px;
  list-style: none;
}

.auth-benefits li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-benefits .icon {
  width: 15px;
  height: 15px;
  color: var(--green);
}

.auth-box {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  height: 54px;
  padding: 0 18px;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--muted);
  background: #faedf5;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.auth-tab:first-child {
  border-left: 0;
}

.auth-tab.is-active {
  color: var(--ink);
  background: var(--surface);
}

.auth-form {
  padding: 26px;
}

.field-gap {
  margin-top: 17px;
}

.auth-form .input-with-icon input {
  height: 50px;
  font-family: var(--font-sans);
  font-size: 13px;
  text-transform: none;
}

.auth-submit {
  min-height: 50px;
  margin-top: 22px;
}

.auth-error,
.link-error {
  margin-top: 10px;
  text-align: left;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 82px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbeaf3;
}

.user-avatar {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--deep);
  background: var(--lime);
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
}

.user-identity {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.user-identity strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-identity span {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
}

.user-profile-actions .text-link {
  margin-top: 0;
}

.user-stats {
  margin-top: 18px;
}

.user-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.65fr);
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}

.user-account-panel,
.user-link-panel {
  margin-top: 0;
}

.user-link-panel {
  position: sticky;
  top: 96px;
}

.panel-copy {
  margin: -4px 0 20px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.75;
}

.user-link-panel .input-with-icon input {
  height: 50px;
  font-size: 11px;
  text-transform: none;
}

.user-link-panel .button {
  min-height: 48px;
  margin-top: 10px;
}

.connect-intro {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.connect-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--deep);
  background: var(--lime);
  border-radius: 50%;
}

.connect-intro p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.connect-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 28px;
}

.connect-form .button {
  height: 58px;
  min-height: 58px;
  padding: 0 28px;
}

#connect-error {
  margin-top: 9px;
  text-align: left;
}

.balance-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
  gap: 70px;
  align-items: end;
  padding: 42px 46px;
  color: #fff8fc;
  background: var(--deep);
  border-radius: 8px;
  overflow: hidden;
}

.balance-label {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 248, 252, 0.6);
  font-size: 11px;
}

.balance-primary > div {
  display: flex;
  align-items: flex-start;
}

.balance-currency {
  margin-top: 9px;
  margin-right: 7px;
  color: var(--lime);
  font-family: var(--font-mono);
  font-size: 20px;
}

#balance-value {
  font-family: var(--font-mono);
  font-size: clamp(48px, 6vw, 72px);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: 0;
}

.balance-primary p {
  margin: 17px 0 0;
  color: rgba(255, 248, 252, 0.6);
  font-size: 11px;
}

.text-separator {
  padding: 0 8px;
  color: rgba(255, 248, 252, 0.28);
}

.balance-progress-wrap {
  padding-bottom: 2px;
}

.balance-progress-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  color: rgba(255, 248, 252, 0.66);
  font-size: 11px;
}

.balance-progress {
  height: 7px;
  background: rgba(255, 255, 255, 0.11);
  border-radius: 99px;
  overflow: hidden;
}

.balance-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--lime);
  border-radius: inherit;
  transition: width 500ms ease;
}

.account-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  color: rgba(255, 248, 252, 0.58);
  font-family: var(--font-mono);
  font-size: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  height: 23px;
  padding: 0 8px;
  border-radius: 4px;
  color: var(--green);
  background: var(--green-soft);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 650;
}

.status-badge.is-warning {
  color: #855017;
  background: #fff1d9;
}

.status-badge.is-danger {
  color: var(--red);
  background: var(--red-soft);
}

.balance-hero .status-badge {
  color: var(--deep);
  background: var(--lime);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat-item {
  min-width: 0;
  padding: 23px 25px;
  border-left: 1px solid var(--line);
}

.stat-item:first-child {
  border-left: 0;
}

.stat-label,
.stat-note {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.stat-item strong {
  display: block;
  margin: 8px 0 7px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-item .stat-time {
  font-family: var(--font-sans);
  font-size: 18px;
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.75fr);
  gap: 24px;
  margin-top: 24px;
}

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

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.panel-heading h2 {
  font-size: 20px;
}

.panel-heading .section-kicker {
  margin-bottom: 7px;
}

.panel-caption {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  min-height: 192px;
  padding-top: 12px;
}

.bar-column {
  display: flex;
  min-width: 0;
  height: 160px;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.bar-value {
  height: 5px;
  width: min(32px, 70%);
  min-height: 5px;
  background: var(--line-dark);
  border-radius: 3px 3px 1px 1px;
  transition: height 450ms ease;
}

.bar-column.has-usage .bar-value {
  background: var(--deep-2);
}

.bar-label {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.copy-row:first-of-type {
  border-top: 0;
}

.copy-row span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 9px;
}

.copy-row code {
  display: block;
  max-width: 340px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-button {
  border-color: var(--line);
}

.key-state {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  color: var(--green) !important;
  white-space: nowrap;
}

.key-state .icon {
  width: 14px;
  height: 14px;
  margin: 0;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
  padding: 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.text-link .icon {
  width: 15px;
  height: 15px;
}

.curl-preview {
  max-width: 100%;
  margin: 16px 0 0;
  padding: 14px;
  overflow: auto;
  color: #ffe5f1;
  background: var(--deep);
  border-radius: 5px;
  font-size: 9px;
  line-height: 1.65;
}

.table-panel {
  margin-top: 24px;
  padding-bottom: 8px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th {
  height: 38px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

td {
  height: 52px;
  color: var(--ink-soft);
  border-bottom: 1px solid #f7e6ef;
  white-space: nowrap;
}

th,
td {
  padding: 0 14px;
}

th:first-child,
td:first-child {
  padding-left: 0;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

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

tbody tr:hover td {
  background: rgba(163, 47, 116, 0.035);
}

.align-right {
  text-align: right;
}

.table-code {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
}

.table-secondary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.table-action {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
  cursor: pointer;
}

.table-action:hover {
  color: var(--ink);
  border-color: var(--line-dark);
}

.table-action.is-danger:hover {
  color: var(--red);
  border-color: #e6b7b7;
}

.empty-state {
  display: flex;
  min-height: 185px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-state .icon {
  width: 24px;
  height: 24px;
  margin-bottom: 12px;
}

.empty-state p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.empty-state span {
  margin-top: 5px;
  font-size: 11px;
}

.empty-state.compact {
  min-height: 110px;
}

.admin-login {
  max-width: 470px;
  margin: 72px auto 110px;
  text-align: center;
}

.admin-login-mark {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  margin: 0 auto 28px;
  color: var(--deep);
  background: var(--lime);
  border: 1px solid var(--ink);
  border-radius: 50%;
}

.admin-login-mark .icon {
  width: 28px;
  height: 28px;
}

.admin-login h1 {
  font-size: 44px;
}

.admin-login > p {
  margin: 16px auto 30px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.admin-login form {
  padding: 24px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-login .form-error {
  margin-top: 9px;
}

.admin-heading {
  margin-bottom: 30px;
}

.admin-stats {
  margin-top: 0;
}

.admin-stats .stat-item strong {
  font-size: 23px;
}

.generate-panel {
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(0, 1.2fr);
  gap: 40px;
  align-items: end;
  margin-top: 24px;
  padding: 30px 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbeaf3;
}

.generate-copy h2 {
  font-size: 22px;
}

.generate-copy p {
  max-width: 390px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.generate-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.generate-form label > span {
  display: block;
  margin-bottom: 8px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
}

.input-unit {
  display: flex;
  align-items: center;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: var(--surface-strong);
}

.input-unit span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.input-unit input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 6px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
}

.generate-form .button {
  height: 46px;
  min-height: 46px;
}

.generate-error {
  grid-column: 2;
  margin-top: -29px;
  transform: translateY(30px);
  text-align: left;
}

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 34px;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 32px 90px rgba(68, 8, 49, 0.26);
}

.modal::backdrop {
  background: rgba(53, 7, 39, 0.64);
  backdrop-filter: blur(6px);
}

.modal[open] {
  animation: modal-in 220ms ease both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.modal-icon {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 50%;
}

.success-icon {
  color: var(--deep);
  background: var(--lime);
}

.modal h2 {
  font-size: 32px;
}

.modal-lede {
  margin: 12px 0 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.issued-amount-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.issued-amount-row span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.issued-amount-row strong {
  display: block;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 10px 10px 16px;
  color: #ffe9f4;
  background: var(--deep);
  border-radius: 6px;
}

.secret-box code {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.5;
}

.secret-box .icon-button {
  color: var(--lime);
  background: rgba(255, 255, 255, 0.07);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 26px;
}

.modal-actions .button {
  min-height: 44px;
}

.batch-code-list {
  display: grid;
  max-height: 300px;
  gap: 1px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.batch-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 43px;
  padding: 9px 13px;
  background: var(--surface-strong);
  font-family: var(--font-mono);
  font-size: 10px;
}

.batch-code-row span:last-child {
  color: var(--muted);
}

.batch-actions {
  justify-content: space-between;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  color: #fff8fc;
  background: var(--deep);
  border-radius: 6px;
  box-shadow: 0 12px 36px rgba(68, 8, 49, 0.24);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast .icon {
  width: 16px;
  height: 16px;
  color: var(--lime);
}

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

@media (max-width: 1020px) {
  .app-shell {
    width: min(100% - 40px, 900px);
  }

  .topbar {
    padding: 0 20px;
  }

  .redeem-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 38px;
  }

  .card-stage {
    padding: 28px;
  }

  .amount {
    font-size: 62px;
  }

  .console-grid {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 34px;
    min-height: 0;
  }

  .auth-intro h2 {
    font-size: clamp(34px, 6vw, 48px);
  }

  .auth-box {
    max-width: 620px;
  }

  .user-grid {
    grid-template-columns: 1fr;
  }

  .user-link-panel {
    position: static;
  }

  .generate-panel {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .generate-error {
    grid-column: 1;
    margin: 0;
    transform: none;
  }
}

@media (max-width: 780px) {
  body::before {
    background-size: 32px 32px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    min-height: 64px;
    padding: 0 16px;
  }

  .brand-text,
  .upstream-state span:last-child {
    display: none;
  }

  .main-nav {
    justify-self: end;
  }

  .upstream-state {
    display: none;
  }

  .nav-button {
    min-width: 42px;
    padding: 0 10px;
  }

  .nav-button span {
    display: none;
  }

  .app-shell {
    width: calc(100% - 32px);
  }

  .view {
    padding: 44px 0 70px;
  }

  .redeem-layout {
    grid-template-columns: 1fr;
    gap: 48px;
    min-height: 0;
  }

  .redeem-main h1 {
    font-size: clamp(38px, 11vw, 52px);
  }

  .lede {
    margin-top: 18px;
    font-size: 15px;
  }

  .redeem-form {
    margin-top: 30px;
  }

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

  .redeem-input-row .button {
    width: 100%;
  }

  .field-meta {
    flex-direction: column;
    gap: 5px;
  }

  .field-meta .form-error {
    text-align: left;
  }

  .fact-strip {
    margin-top: 28px;
  }

  .fact-strip div {
    padding: 0 12px;
  }

  .fact-strip dd {
    font-size: 11px;
    line-height: 1.5;
  }

  .card-stage {
    min-height: auto;
    padding: 24px;
  }

  .gift-card {
    min-height: 210px;
    padding: 20px;
  }

  .amount {
    font-size: 58px;
  }

  .card-bottom {
    margin-top: 27px;
  }

  .docs-band {
    grid-template-columns: 1fr;
    gap: 26px;
    margin-top: 48px;
    padding-top: 42px;
  }

  .code-window pre {
    padding: 20px;
    font-size: 10px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 26px;
  }

  .page-heading h1 {
    font-size: 40px;
  }

  .heading-actions {
    width: 100%;
  }

  .heading-actions .button {
    flex: 1;
  }

  .connect-panel {
    margin: 40px 0;
    padding: 24px;
  }

  .auth-intro h2 {
    font-size: 36px;
  }

  .auth-intro > p {
    font-size: 13px;
  }

  .user-profile {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .user-profile-actions {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .connect-intro {
    flex-direction: column;
  }

  .connect-form {
    grid-template-columns: 1fr;
  }

  .balance-hero {
    grid-template-columns: 1fr;
    gap: 34px;
    padding: 30px 24px;
  }

  #balance-value {
    font-size: 56px;
  }

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

  .stat-item {
    border-top: 1px solid var(--line);
  }

  .stat-item:nth-child(1),
  .stat-item:nth-child(2) {
    border-top: 0;
  }

  .stat-item:nth-child(3) {
    border-left: 0;
  }

  .console-grid {
    gap: 16px;
  }

  .data-panel {
    padding: 22px 18px;
  }

  .bar-chart {
    gap: 7px;
  }

  .table-panel {
    padding-bottom: 6px;
  }

  .admin-stats .stat-item strong {
    font-size: 20px;
  }

  .generate-panel {
    padding: 24px 20px;
  }

  .auth-form {
    padding: 22px 18px;
  }

  .generate-form {
    grid-template-columns: 1fr 1fr;
  }

  .generate-form .button {
    grid-column: 1 / -1;
  }

  .generate-error {
    margin-top: 0;
  }

  .admin-login {
    margin: 32px auto 72px;
  }

  .admin-login h1 {
    font-size: 38px;
  }

  .modal {
    padding: 28px 20px 22px;
  }

  .modal h2 {
    font-size: 27px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }

  .batch-actions {
    flex-direction: column-reverse;
  }
}

@media (max-width: 460px) {
  .fact-strip {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .fact-strip div,
  .fact-strip div:first-child {
    padding: 0;
    border: 0;
  }

  .fact-strip dt {
    margin-bottom: 3px;
  }

  .stage-note {
    margin-top: 18px;
  }

  .card-serial {
    gap: 5px;
  }

  .stat-item {
    padding: 19px 16px;
  }

  .stat-item strong {
    font-size: 20px;
  }

  .stat-item .stat-time {
    font-size: 14px;
  }

  .generate-form {
    grid-template-columns: 1fr;
  }

  .generate-form .button {
    grid-column: 1;
  }

  .modal-lede {
    padding-right: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
