:root {
  color-scheme: light;
  --text: #1d2528;
  --muted: #647174;
  --line: #dce4e5;
  --panel: #ffffff;
  --bg: #f5f7f7;
  --teal: #0097a7;
  --teal-strong: #007482;
  --amber: #c77900;
  --green: #168a53;
  --red: #d64545;
  --shadow: 0 14px 30px rgba(17, 35, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(0, 151, 167, 0.08), transparent 340px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

.brand img {
  width: 34px;
  height: 34px;
}

.nav {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.nav a:hover,
.link-button:hover {
  color: var(--teal-strong);
}

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

.shell.narrow {
  width: min(720px, calc(100vw - 32px));
}

.redeem-shell {
  width: min(560px, calc(100vw - 32px));
  min-height: calc(100vh - 68px);
  margin: 0 auto;
  padding: 70px 0;
}

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

.recharge-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
  padding: 28px 38px;
  background: linear-gradient(135deg, #0c352f, #146b60 58%, #3e7d8d);
  border-radius: 8px;
  color: #fff;
  box-shadow: var(--shadow);
}

.recharge-hero .eyebrow {
  color: #79ddc9;
}

.terminal-brand.inline {
  grid-template-columns: auto 1fr;
  justify-items: start;
  text-align: left;
  margin: 0;
}

.terminal-brand.inline img {
  width: 48px;
  height: 48px;
}

.portal-tabs {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.portal-tabs a {
  min-width: 118px;
  padding: 10px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  font-weight: 900;
}

.portal-tabs a span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 12px;
}

.portal-tabs a.active {
  background: #fff;
  color: #13584f;
}

.portal-tabs a.active span {
  color: #6b787a;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  margin-bottom: 18px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.status-strip strong {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: #edf8fa;
  color: #266d7c;
  text-transform: uppercase;
  font-size: 12px;
}

.status-strip span {
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

.redeem-terminal {
  display: grid;
  gap: 16px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.terminal-brand {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-bottom: 10px;
  text-align: center;
}

.terminal-brand img {
  width: 58px;
  height: 58px;
}

.terminal-brand h1 {
  font-size: 30px;
}

.terminal-card {
  display: grid;
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.step-title > span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #15846f;
  color: #fff;
  font-weight: 900;
}

.step-title h2 {
  font-size: 22px;
}

.terminal-card > small {
  color: var(--muted);
  text-align: center;
}

.details-card {
  gap: 18px;
}

.product-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid #cfe4e6;
  border-radius: 8px;
  background: #f0fbfc;
}

.product-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.extract-preview div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid #cfe4e6;
  border-radius: 8px;
  background: #f6fbfb;
}

.extract-preview span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.extract-preview strong {
  display: block;
  color: var(--text);
  word-break: break-word;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 34px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

.hero-copy {
  margin: 12px 0 0;
  color: var(--muted);
}

.hero-panel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

.signal {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(22, 138, 83, 0.12);
}

.page-title {
  margin-bottom: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel.flat {
  box-shadow: none;
}

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

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

.form-grid.compact {
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  line-height: 1.5;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd9db;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 151, 167, 0.14);
}

.span-2 {
  grid-column: span 2;
}

.inline-check {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
}

.primary,
.secondary,
.tab,
.link-button,
.status-btn,
.linklike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

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

.primary:hover {
  background: var(--teal-strong);
}

.secondary,
.linklike {
  background: #fff;
  color: var(--teal-strong);
  border-color: #b8d6da;
}

.secondary:hover,
.linklike:hover {
  background: #eaf7f8;
}

.link-button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0;
}

.notice {
  border: 1px solid rgba(199, 121, 0, 0.28);
  background: #fff8ec;
  color: #7b4d00;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.6;
  font-size: 14px;
}

.result {
  margin-top: 18px;
}

.lookup-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.lookup-help,
.lookup-board {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lookup-help {
  align-self: start;
  padding: 24px 22px;
}

.lookup-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 20px;
  border-radius: 8px;
  background: #147c74;
  color: #fff;
  font-weight: 900;
}

.lookup-help h1 {
  margin-bottom: 14px;
  font-size: 24px;
}

.lookup-help p {
  margin: 0 0 24px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.7;
}

.lookup-steps {
  display: grid;
  gap: 10px;
}

.lookup-steps div {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 0 12px;
  border: 1px solid #bdded9;
  border-radius: 8px;
  background: #f4fbf8;
  font-weight: 800;
}

.lookup-steps strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #15846f;
  color: #fff;
}

.lookup-board {
  min-height: 560px;
  padding: 26px;
}

.lookup-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.lookup-head h1 {
  font-size: 26px;
}

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

.lookup-form input {
  font-size: 18px;
  font-weight: 900;
  text-transform: uppercase;
}

.lookup-result {
  padding-top: 18px;
}

.empty-state,
.lookup-error {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed #cbd8d9;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.lookup-error {
  gap: 8px;
  border-color: rgba(214, 69, 69, 0.32);
  background: #fff6f6;
  color: var(--red);
}

.lookup-summary {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.lookup-actions span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.lookup-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.lookup-summary strong {
  font-size: 22px;
  letter-spacing: 0;
  word-break: break-word;
}

.progress-line {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  min-height: 48px;
  margin-bottom: 18px;
  padding: 0 12px;
  border: 1px solid #d7e2df;
  border-radius: 8px;
  background: #fbfdfb;
}

.lookup-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #a0a9ad;
  font-weight: 900;
  white-space: nowrap;
}

.lookup-step:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -8px;
  width: 10px;
  height: 10px;
  border-top: 2px solid #b9c3c7;
  border-right: 2px solid #b9c3c7;
  transform: rotate(45deg);
}

.lookup-step i {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  line-height: 1;
}

.lookup-step.done {
  color: #13836f;
}

.lookup-step.current {
  color: #c77900;
}

.lookup-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lookup-info {
  min-height: 88px;
  padding: 16px;
  border: 1px solid #e0e8e6;
  border-radius: 8px;
  background: #fff;
}

.lookup-info.wide {
  grid-column: span 2;
  min-height: 96px;
  background: #fbfdfb;
}

.lookup-info span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.lookup-info strong {
  color: var(--text);
  line-height: 1.55;
  word-break: break-word;
}

.state-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  padding: 0 16px;
  background: #eef3f3;
  color: var(--muted);
  font-style: normal;
  font-size: 14px;
}

.state-pill.queued {
  background: #fff3d9;
  color: #8a5600;
}

.state-pill.accepted {
  background: #edf4ff;
  color: #2f5f9f;
}

.state-pill.processing {
  background: #eaf7f8;
  color: var(--teal-strong);
}

.state-pill.need_confirm {
  background: #f2ecff;
  color: #6b4ab0;
}

.state-pill.completed,
.state-pill.redeemed {
  background: #e7f6ee;
  color: var(--green);
}

.state-pill.failed,
.state-pill.canceled,
.state-pill.void {
  background: #fdecec;
  color: var(--red);
}

.result h2 {
  margin-bottom: 10px;
}

.result p {
  margin: 8px 0;
  color: var(--muted);
}

.success {
  color: var(--green);
  font-weight: 800;
}

.error {
  color: var(--red);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.admin-shell {
  width: min(1280px, calc(100vw - 32px));
}

.login-panel {
  width: min(460px, 100%);
  margin: 56px auto;
}

.login-panel h1 {
  margin-bottom: 22px;
}

.msg {
  min-height: 22px;
  color: var(--red);
}

.admin-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stat {
  min-width: 86px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
}

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

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
}

.tab.active {
  color: #fff;
  background: var(--text);
  border-color: var(--text);
}

.toolbar {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr) auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.list {
  display: grid;
  gap: 10px;
}

.row-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.row-card.order-queued {
  border-color: #c9dcd7;
  box-shadow: 0 0 0 3px rgba(21, 132, 111, 0.08);
}

.row-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.note {
  margin-top: 10px;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
}

.customer-text {
  margin-top: 12px;
}

.customer-text span {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.customer-text pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid #d8e4e6;
  border-radius: 8px;
  background: #f8fbfb;
  color: var(--text);
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 0 10px;
  background: #eef3f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.queued {
  background: #fff3d9;
  color: #8a5600;
}

.badge.accepted {
  background: #edf4ff;
  color: #2f5f9f;
}

.badge.processing {
  background: #eaf7f8;
  color: var(--teal-strong);
}

.badge.need_confirm {
  background: #f2ecff;
  color: #6b4ab0;
}

.badge.completed,
.badge.redeemed {
  background: #e7f6ee;
  color: var(--green);
}

.badge.failed,
.badge.void {
  background: #fdecec;
  color: var(--red);
}

.badge.canceled,
.badge.locked {
  background: #eef0f2;
  color: #5e6669;
}

.actions {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 140px;
}

.status-btn {
  min-height: 34px;
  background: #fff;
  border-color: var(--line);
  color: var(--text);
  font-size: 13px;
}

.status-btn:hover {
  border-color: var(--teal);
  color: var(--teal-strong);
}

.status-btn.danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.admin-notice {
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid #bfe0d7;
  border-radius: 8px;
  background: #f0fbf7;
  color: #0d6f5c;
  font-weight: 900;
}

.admin-note {
  min-height: 36px;
}

.code-output {
  max-height: 220px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 12px;
  background: #101819;
  color: #d5fbf7;
  border-radius: 8px;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .topbar {
    padding: 0 16px;
  }

  .shell,
  .recharge-shell,
  .admin-shell,
  .lookup-shell {
    width: min(100% - 24px, 1120px);
    padding-top: 28px;
  }

  .hero,
  .recharge-hero,
  .admin-head,
  .split,
  .row-card,
  .lookup-shell,
  .lookup-form,
  .lookup-cards,
  .extract-preview {
    grid-template-columns: 1fr;
  }

  .recharge-hero {
    align-items: stretch;
    flex-direction: column;
    padding: 22px;
  }

  .portal-tabs {
    flex-direction: column;
  }

  .lookup-board,
  .lookup-help {
    padding: 20px;
  }

  .lookup-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .progress-line {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

  .lookup-step {
    justify-content: flex-start;
  }

  .lookup-step:not(:last-child)::after {
    display: none;
  }

  .lookup-info.wide {
    grid-column: span 1;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .inline-check {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  .stats {
    justify-content: flex-start;
  }

  .actions {
    min-width: 0;
  }
}
