/* === Reset & Base === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  color: #333;
  background: #f5f5f5;
  -webkit-text-size-adjust: 100%;
}

/* === Layout === */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: #1677ff;
  color: #fff;
  text-align: center;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 20px 16px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}

/* === Form === */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: #1677ff;
}

.field-hint {
  font-size: 12px;
  margin-top: 4px;
  min-height: 18px;
  color: #999;
}

.field-hint.error {
  color: #ff4d4f;
}

.field-hint.success {
  color: #52c41a;
}

/* === Buttons === */
.btn {
  display: block;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-appearance: none;
}

.btn-link {
  text-decoration: none;
  text-align: center;
  line-height: 48px;
}

.btn:active {
  opacity: 0.8;
}

.btn-scan {
  background: #fff;
  color: #1677ff;
  border: 1px solid #1677ff;
  margin-bottom: 20px;
}

.btn-primary {
  background: #1677ff;
  color: #fff;
}

.btn-primary.disabled,
.btn-primary:disabled {
  background: #a0c4ff;
  cursor: not-allowed;
}

.btn-scan.disabled,
.btn-scan:disabled {
  color: #9bb6d9;
  border-color: #cbd8ea;
  background: #f5f8fc;
  cursor: not-allowed;
}

/* === Order Info === */
.order-info {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.order-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 4px;
}

.order-id {
  font-size: 15px;
  font-family: monospace;
  color: #333;
  word-break: break-all;
}

.order-status {
  font-size: 13px;
  margin-top: 6px;
}

.order-status.valid {
  color: #52c41a;
}

.order-status.invalid {
  color: #ff4d4f;
}

/* === QR Reader === */
#qr-reader {
  display: none;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
}

/* === Footer Hint === */
.hint {
  text-align: center;
  font-size: 13px;
  color: #999;
  padding: 16px 0;
}

/* === Dashboard === */
.page-link {
  display: inline-block;
  margin-bottom: 16px;
}

.summary-card {
  background: linear-gradient(135deg, #1677ff, #51a8ff);
  border-radius: 16px;
  padding: 18px 16px;
  color: #fff;
  margin: 20px 0 24px;
  box-shadow: 0 12px 30px rgba(22, 119, 255, 0.16);
}

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

.section-eyebrow {
  font-size: 12px;
  opacity: 0.85;
  margin-bottom: 6px;
}

.member-name {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
}

.member-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 4px;
}

.text-link {
  color: #1677ff;
  text-decoration: none;
  font-size: 13px;
}

.summary-card .text-link {
  color: #fff;
  opacity: 0.95;
}

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

.metric-item {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 14px 12px;
  backdrop-filter: blur(8px);
}

.metric-label {
  font-size: 12px;
  opacity: 0.85;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
}

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

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.section-meta {
  font-size: 12px;
  color: #999;
}

.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 4px;
}

.filter-chip {
  flex: 0 0 auto;
  border: 1px solid #d9e1ef;
  background: #fff;
  color: #5f6f85;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.filter-chip.active {
  border-color: #1677ff;
  background: #1677ff;
  color: #fff;
}

.transaction-item {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.transaction-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.transaction-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.transaction-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
}

.transaction-type.is-expense,
.transaction-amount.is-expense {
  color: #ff4d4f;
}

.transaction-type.is-expense {
  background: rgba(255, 77, 79, 0.12);
}

.transaction-type.is-recharge,
.transaction-amount.is-recharge {
  color: #1677ff;
}

.transaction-type.is-recharge {
  background: rgba(22, 119, 255, 0.12);
}

.transaction-type.is-refund,
.transaction-amount.is-refund {
  color: #52c41a;
}

.transaction-type.is-refund {
  background: rgba(82, 196, 26, 0.14);
}

.transaction-type.is-default,
.transaction-amount.is-default {
  color: #666;
}

.transaction-type.is-default {
  background: rgba(0, 0, 0, 0.06);
}

.transaction-device,
.transaction-time {
  font-size: 12px;
  color: #999;
}

.transaction-amount {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}

.transaction-empty {
  background: #fff;
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.pagination-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}

.pagination-btn {
  height: 40px;
  margin-bottom: 0;
  line-height: 38px;
  font-size: 14px;
}

.pagination-info {
  min-width: 88px;
  text-align: center;
  font-size: 13px;
  color: #666;
}

/* === Result Pages === */
.result-icon {
  text-align: center;
  font-size: 64px;
  margin: 40px 0 16px;
}

.result-title {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
}

.result-title.success {
  color: #52c41a;
}

.result-title.fail {
  color: #ff4d4f;
}

.result-detail {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: center;
}

.result-detail .label {
  font-size: 14px;
  color: #999;
  margin-bottom: 4px;
}

.result-detail .value {
  font-size: 24px;
  font-weight: 600;
  color: #333;
}

.result-detail .value.highlight {
  color: #1677ff;
}

.result-detail .divider {
  height: 1px;
  background: #eee;
  margin: 12px 0;
}

.result-message {
  text-align: center;
  font-size: 15px;
  color: #666;
  margin-bottom: 24px;
  padding: 0 16px;
}

/* === Toast === */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
}

@media (max-width: 375px) {
  .summary-top,
  .transaction-main,
  .pagination-bar {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .pagination-bar {
    display: flex;
    width: 100%;
  }

  .pagination-info {
    width: 100%;
  }
}
