:root {
  color-scheme: light dark;
  --canvas: #fff;
  --page: #f5f5f7;
  --surface: #fff;
  --fill: #f5f5f7;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #86868b;
  --line: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --link: #06c;
  --success: #248a3d;
  --warning: #b25000;
  --danger: #e30000;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #000;
    --page: #000;
    --surface: #1d1d1f;
    --fill: #2c2c2e;
    --text: #f5f5f7;
    --secondary: #a1a1a6;
    --tertiary: #86868b;
    --line: #424245;
    --link: #2997ff;
    --success: #30d158;
    --warning: #ff9f0a;
    --danger: #ff453a;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 17px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1,
h2,
p,
dl,
dd {
  margin: 0;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

/* 顶栏 */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1024px;
  height: 52px;
  margin: 0 auto;
  padding: 0 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}

.brand:hover {
  text-decoration: none;
}

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

.nav-actions {
  display: flex;
  gap: 20px;
}

/* 按钮 */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.button:disabled {
  opacity: 0.4;
  cursor: default;
}

.text-button {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  cursor: pointer;
}

.text-button:hover {
  text-decoration: underline;
}

.text-button:disabled {
  color: var(--tertiary);
  text-decoration: none;
  cursor: default;
}

.block {
  width: 100%;
}

.more::after,
.row::after {
  content: "";
  flex: none;
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  margin-left: 0.3em;
  border: solid currentColor;
  border-width: 0.09em 0.09em 0 0;
  transform: rotate(45deg);
  vertical-align: 0.1em;
}

.error {
  color: var(--danger);
  font-size: 14px;
}

/* 首页 */

.home {
  background: var(--canvas);
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 22px;
  text-align: center;
}

.hero img {
  width: 72px;
  height: 72px;
}

.hero h1 {
  margin-top: 20px;
  font-size: clamp(48px, 9vw, 80px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.lead {
  margin-top: 14px;
  color: var(--secondary);
  font-size: clamp(19px, 2.6vw, 24px);
  line-height: 1.33;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 32px;
  margin-top: 26px;
  font-size: clamp(17px, 2.2vw, 21px);
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 18px 22px;
  color: var(--tertiary);
  font-size: 12px;
}

.foot a {
  color: inherit;
}

/* 收银台 */

.sheet {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 24px 16px 56px;
}

.card {
  width: 100%;
  max-width: 420px;
  padding: 40px 32px 28px;
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.merchant {
  color: var(--secondary);
  font-size: 14px;
}

.amount {
  margin-top: 6px;
  font-size: 56px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.amount span {
  margin-right: 4px;
  font-size: 28px;
  font-weight: 500;
  vertical-align: 0.42em;
}

.order-name {
  margin-top: 8px;
  color: var(--secondary);
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.panel {
  margin-top: 32px;
}

.panel h2 {
  font-size: 21px;
  font-weight: 600;
  line-height: 1.2;
}

.panel h2 + p {
  margin-top: 6px;
  color: var(--secondary);
  font-size: 14px;
}

.panel .button {
  margin-top: 24px;
}

.list {
  overflow: hidden;
  border-radius: 12px;
  background: var(--fill);
  text-align: left;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 0 18px 0 14px;
  border: 0;
  background: none;
  cursor: pointer;
}

.row + .row {
  box-shadow: inset 0 1px 0 var(--line);
}

.row:hover {
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.row:disabled {
  opacity: 0.4;
  cursor: default;
}

.row::after {
  margin-left: auto;
  color: var(--tertiary);
}

.badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  color: #fff;
  font-size: 15px;
  font-style: normal;
  font-weight: 600;
}

.badge.wxpay {
  background: #07c160;
}

.badge.alipay {
  background: #1677ff;
}

.qr {
  width: 220px;
  max-width: 100%;
  margin: 0 auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.qr img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.hint {
  margin-top: 16px;
  font-size: 14px;
}

.touch-only {
  display: none;
}

@media (hover: none) {
  .touch-only {
    display: inline;
  }
}

.timer {
  margin-top: 2px;
  color: var(--secondary);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

#qrPanel .text-button {
  margin-top: 8px;
  font-size: 14px;
}

.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 0;
  color: var(--secondary);
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.check {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--success);
}

.card > .error {
  margin-top: 20px;
}

.meta {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--tertiary);
  font-size: 12px;
  text-align: left;
}

.meta div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.meta div + div {
  margin-top: 4px;
}

.meta dt {
  flex: none;
}

.meta dd {
  text-align: right;
  overflow-wrap: anywhere;
}

.back {
  margin-top: 20px;
  font-size: 14px;
}

/* 管理 */

.login {
  margin-top: 8vh;
}

.login h1 {
  font-size: 28px;
  font-weight: 600;
}

.login input {
  display: block;
  width: 100%;
  height: 52px;
  margin: 24px 0 16px;
  padding: 0 16px;
  border: 1px solid var(--tertiary);
  border-radius: 12px;
  background: none;
}

.login input:focus {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: 0;
}

.login .error {
  margin-top: 16px;
}

.orders {
  width: 100%;
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px 22px 56px;
}

.orders h1 {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.15;
}

.caption {
  color: var(--secondary);
  font-size: 14px;
}

.orders > .error {
  margin-top: 12px;
}

.table {
  overflow-x: auto;
  margin-top: 20px;
  border-radius: 16px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}

th,
td {
  padding: 13px 18px;
  text-align: left;
}

th {
  color: var(--secondary);
  font-size: 12px;
  font-weight: 400;
}

td {
  border-top: 1px solid var(--line);
}

td.name {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.amount-cell,
td.time {
  font-variant-numeric: tabular-nums;
}

td.paid {
  color: var(--success);
}

td.uncertain {
  color: var(--warning);
}

td.new,
td.creating,
td.pending,
td.time,
td.empty {
  color: var(--secondary);
}

td.empty {
  padding: 48px 18px;
  text-align: center;
}

@media (max-width: 520px) {
  .pay {
    background: var(--surface);
  }

  .sheet {
    padding: 8px 0 32px;
  }

  .card {
    padding: 20px 22px;
  }

  .amount {
    font-size: 48px;
  }

  .login {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}
