:root {
  color-scheme: dark;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --page: #101114;
  --surface: #191b20;
  --surface-raised: #22252b;
  --line: #343840;
  --line-strong: #515761;
  --text: #f6f7f8;
  --muted: #9da3ac;
  --muted-strong: #c8ccd2;
  --green: #27c499;
  --green-strong: #18a87e;
  --blue: #2f86eb;
  --blue-strong: #1f6fcc;
  --violet: #7c6df2;
  --danger: #ff6b6b;
  --warning: #f4b942;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #71b7ff;
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 58px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 17, 20, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100% - 32px, 560px);
  height: 100%;
  margin: 0 auto;
  gap: 9px;
  color: var(--text);
}

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

.brand strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell {
  width: min(100% - 32px, 560px);
  margin: 0 auto;
  padding: 22px 0 44px;
}

.cashier-form,
.state-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-section {
  padding: 20px;
}

.form-section + .form-section {
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-height: 24px;
  margin: 0 0 14px;
  gap: 14px;
}

.section-heading h2,
.section-heading label {
  margin: 0;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 650;
}

.channel-label {
  max-width: 58%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount-input-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 74px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #131519;
  gap: 6px;
}

.amount-input-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 134, 235, 0.16);
}

.amount-input-wrap span {
  color: var(--muted-strong);
  font-size: 23px;
}

.amount-input-wrap input {
  width: min(12ch, 76%);
  min-width: 4ch;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.amount-input-wrap input::placeholder {
  color: #718090;
  font-size: 16px;
  font-weight: 500;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  gap: 10px;
}

.range-row strong {
  color: var(--muted-strong);
  font-weight: 600;
}

.range-row span:last-child {
  text-align: right;
}

.progress-track {
  overflow: hidden;
  height: 4px;
  margin-top: 8px;
  border-radius: 2px;
  background: #2a2d33;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 160ms ease, background-color 160ms ease;
}

.progress-track span.is-wechat {
  background: var(--green);
}

.adjust-tip {
  width: fit-content;
  margin: 12px auto 0;
  padding: 6px 10px;
  border: 1px solid rgba(244, 185, 66, 0.45);
  border-radius: 6px;
  background: rgba(244, 185, 66, 0.1);
  color: #ffd67c;
  font-size: 12px;
  font-weight: 650;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 14px;
  gap: 8px;
}

.amount-grid button,
.keypad button {
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.amount-grid button:hover,
.keypad button:hover {
  border-color: var(--line-strong);
  background: #292d33;
}

.amount-grid button.is-selected {
  border-color: var(--blue);
  background: rgba(47, 134, 235, 0.14);
  color: #b9dcff;
}

.amount-grid button.is-selected.is-wechat {
  border-color: var(--green);
  background: rgba(39, 196, 153, 0.12);
  color: #9ce9d2;
}

.amount-grid button:disabled {
  border-color: #2a2d32;
  background: #16181c;
  color: #616770;
  cursor: not-allowed;
  text-decoration: line-through;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  gap: 8px;
}

.keypad button {
  min-height: 48px;
  font-size: 16px;
}

.keypad button.is-delete {
  color: var(--muted);
  font-size: 21px;
}

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

.payment-methods.is-single {
  grid-template-columns: 1fr;
}

.pay-method {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr 18px;
  align-items: center;
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
  cursor: pointer;
  text-align: left;
  gap: 10px;
}

.pay-method:hover {
  border-color: var(--line-strong);
}

.pay-method.is-selected.is-alipay {
  border-color: var(--violet);
  background: rgba(124, 109, 242, 0.11);
}

.pay-method.is-selected.is-wechat {
  border-color: var(--green);
  background: rgba(39, 196, 153, 0.1);
}

.pay-method img {
  width: 44px;
  height: 44px;
}

.pay-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.pay-copy strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.pay-copy small {
  color: var(--muted);
  font-size: 11px;
}

.radio-mark {
  width: 17px;
  height: 17px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.pay-method.is-selected .radio-mark {
  border: 5px solid var(--blue);
  background: #fff;
}

.pay-method.is-selected.is-wechat .radio-mark {
  border-color: var(--green);
}

.form-actions {
  padding: 16px 20px 18px;
  border-top: 1px solid var(--line);
  background: #15171b;
}

.submit-button,
.secondary-button,
.retry-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 7px;
  font-weight: 750;
  cursor: pointer;
}

.submit-button {
  background: #2e3238;
  color: #858b94;
}

.submit-button.is-ready.is-alipay {
  background: var(--blue-strong);
  color: #fff;
}

.submit-button.is-ready.is-wechat {
  background: var(--green-strong);
  color: #fff;
}

.submit-button:disabled {
  cursor: not-allowed;
}

.security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 13px;
  color: var(--muted);
  font-size: 11px;
  gap: 6px;
}

.security-note svg {
  width: 14px;
  height: 14px;
  color: var(--green);
}

.error-banner,
.availability-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 107, 107, 0.42);
  border-radius: 6px;
  background: rgba(255, 107, 107, 0.08);
  color: #ffb0b0;
  font-size: 13px;
  line-height: 1.5;
}

.availability-note {
  margin-top: 12px;
  margin-bottom: 0;
}

.state-panel {
  padding: 34px 24px;
  text-align: center;
}

.loading-panel {
  display: flex;
  min-height: 210px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.loading-panel p,
.state-panel > p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #343840;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.result-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  margin: 0 auto 16px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--muted-strong);
  font-size: 25px;
  font-weight: 800;
}

.result-mark.is-success {
  border-color: rgba(39, 196, 153, 0.5);
  background: rgba(39, 196, 153, 0.1);
  color: #80e1c4;
}

.result-mark.is-danger {
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.1);
  color: #ff9c9c;
}

.state-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 750;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #14161a;
}

.summary > span {
  display: flex;
  min-width: 0;
  padding: 14px 10px;
  flex-direction: column;
  gap: 5px;
}

.summary > span + span {
  border-left: 1px solid var(--line);
}

.summary small {
  color: var(--muted);
  font-size: 11px;
}

.summary strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 16px;
}

.order-number {
  display: block;
  margin: 0 0 18px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.secondary-button,
.retry-button {
  margin-top: 10px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted-strong);
}

.secondary-button:hover,
.retry-button:hover {
  border-color: var(--muted);
  color: var(--text);
}

.countdown {
  position: relative;
  display: grid;
  width: 112px;
  height: 112px;
  place-items: center;
  margin: 22px auto 10px;
}

.countdown svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.countdown circle {
  fill: none;
  stroke-width: 7;
}

.countdown .track {
  stroke: #30343a;
}

.countdown .progress {
  stroke: var(--blue);
  stroke-linecap: round;
  transition: stroke-dashoffset 200ms linear;
}

.countdown-value {
  display: flex;
  flex-direction: column;
}

.countdown-value strong {
  font-size: 27px;
}

.countdown-value small {
  color: var(--muted);
  font-size: 10px;
}

.processing-copy {
  max-width: 380px;
  margin: 0 auto !important;
}

.qr-panel {
  margin: 20px auto;
}

.qr-box {
  display: grid;
  width: 240px;
  min-height: 240px;
  place-items: center;
  margin: 0 auto;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}

.qr-box canvas {
  max-width: 100%;
  height: auto;
}

.qr-copy {
  max-width: 320px;
  margin: 12px auto 0 !important;
}

noscript {
  display: block;
  margin: 24px;
  color: var(--danger);
  text-align: center;
}

@media (max-width: 620px) {
  .topbar {
    height: 54px;
  }

  .shell {
    width: 100%;
    padding: 10px 10px 34px;
  }

  .cashier-form,
  .state-panel {
    box-shadow: none;
  }

  .form-section {
    padding: 17px 14px;
  }

  .form-actions {
    padding: 14px;
  }

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

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

  .pay-method {
    grid-template-columns: 40px 1fr 16px;
    min-height: 72px;
    padding: 10px;
    gap: 8px;
  }

  .pay-method img {
    width: 40px;
    height: 40px;
  }

  .pay-copy small {
    display: none;
  }

  .amount-input-wrap input {
    font-size: 29px;
  }
}

@media (max-width: 350px) {
  .payment-methods {
    grid-template-columns: 1fr;
  }

  .pay-copy small {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
