:root {
  --brand-start: #667eea;
  --brand-end: #764ba2;
  --green-start: #4caf50;
  --green-end: #45a049;
  --page-bg: #f5f5f5;
  --text: #333;
  --muted: #666;
  --line: #e1e5e9;
  --card-radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #e9e9e9;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--page-bg);
  box-shadow: 0 0 22px rgba(0, 0, 0, 0.08);
}

.view {
  min-height: 100dvh;
}

.site-footer {
  padding: 18px 16px calc(18px + var(--safe-bottom));
  color: #8a8a8a;
  background: var(--page-bg);
  text-align: center;
  font-size: 12px;
  line-height: 1.5;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer.has-fixed-action {
  padding-bottom: calc(98px + var(--safe-bottom));
}

.site-footer.is-login-footer {
  position: fixed;
  right: 50%;
  bottom: 0;
  left: 50%;
  z-index: 40;
  width: min(100%, 480px);
  padding: 11px 16px calc(11px + var(--safe-bottom));
  transform: translateX(-50%);
  color: #555;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08);
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px 0 calc(58px + var(--safe-bottom));
  background: url("assets/dragon-boat-bg.jpg") center / 100% 100% no-repeat;
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

.login-container {
  width: calc(100% - 60px);
  max-width: 500px;
  overflow: hidden;
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.login-header {
  padding: 30px 20px;
  color: #fff;
  text-align: center;
  background: linear-gradient(45deg, var(--green-start), var(--green-end));
}

.login-header h1 {
  margin: 0 0 10px;
  font-size: 21px;
  font-weight: 300;
  line-height: 1.4;
}

.login-header p {
  margin: 0;
  font-size: 14px;
}

.login-form-wrap {
  padding: 30px 20px;
}

.input-group {
  position: relative;
  margin-bottom: 25px;
}

.input-icon {
  position: absolute;
  top: 50%;
  left: 15px;
  z-index: 1;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
}

.voucher-input {
  width: 100%;
  height: 52.5px;
  padding: 15px 15px 15px 45px;
  border: 2px solid #e1e5e9;
  border-radius: 8px;
  outline: 0;
  background: #fafafa;
  color: #000;
  font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.voucher-input:focus {
  border-color: var(--green-start);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.12);
}

.password-input {
  padding-right: 64px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  z-index: 2;
  min-width: 42px;
  padding: 8px 4px;
  transform: translateY(-50%);
  color: #3d8d41;
  background: transparent;
  font-size: 13px;
}

.login-helper-row {
  display: flex;
  min-height: 28px;
  align-items: center;
  margin: -10px 0 16px;
  color: #777;
  font-size: 12px;
}

.input-group.compact {
  margin-bottom: 14px;
}

.security-notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-left: 3px solid #4caf50;
  color: #526152;
  background: #f3faf3;
  font-size: 13px;
  line-height: 1.65;
}

.secondary-login-action {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  color: #4b7f4e;
  background: transparent;
  font-size: 14px;
}

.login-submit {
  width: 100%;
  height: 52.5px;
  margin: 0 0 20px;
  padding: 15px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(45deg, var(--green-start), var(--green-end));
  font-size: 16px;
  font-weight: 600;
}

.login-submit:disabled {
  cursor: wait;
  opacity: 0.75;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -3px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.login-result {
  display: none;
  margin: 0 0 20px;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
}

.login-result.error {
  display: block;
  border: 1px solid #ffcdd2;
  color: #b71c1c;
  background: #ffebee;
}

.service-info {
  margin: 0;
  color: #666;
  text-align: center;
  font-size: 13px;
}

@media (max-height: 760px) {
  .login-page {
    align-items: flex-start;
  }
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68.8px;
  padding: 20px;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.page-header.tall {
  min-height: 108px;
  text-align: left;
}

.page-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 28.8px;
}

.header-icon-btn {
  position: absolute;
  top: 19.4px;
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  padding: 0;
  color: #fff;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.header-icon-btn.back {
  left: 20px;
}

.header-icon-btn.share {
  right: 20px;
  font-size: 18px;
}

.selected-count {
  height: 30px;
  margin-top: 9px;
  padding: 5px 15px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
}

.catalog-view {
  padding-bottom: calc(92px + var(--safe-bottom));
}

.product-list {
  padding: 15px;
}

.product-card {
  display: flex;
  align-items: center;
  min-height: 94px;
  margin-bottom: 15px;
  padding: 12px;
  border-radius: var(--card-radius);
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.product-card:active {
  transform: translateY(1px);
}

.product-card.selected {
  box-shadow: 0 0 0 2px var(--brand-start), 0 3px 10px rgba(102, 126, 234, 0.18);
}

.product-checkbox {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-right: 15px;
  place-items: center;
  border: 2px solid #d8dce0;
  border-radius: 50%;
  color: #fff;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.product-card.selected .product-checkbox {
  border-color: var(--brand-start);
  background: var(--brand-start);
}

.product-thumb {
  flex: 0 0 70px;
  width: 70px;
  height: 70px;
  margin-right: 15px;
  border-radius: 8px;
  object-fit: cover;
}

.product-card-info {
  min-width: 0;
  flex: 1;
}

.product-card-name {
  margin-bottom: 8px;
  color: #000;
  font-size: 15px;
  font-weight: 600;
}

.product-card-hint {
  color: #999;
  font-size: 12px;
}

.catalog-bottom,
.submit-bar {
  position: fixed;
  right: 50%;
  bottom: 0;
  left: 50%;
  z-index: 30;
  display: flex;
  width: min(100%, 480px);
  min-height: calc(76.5px + var(--safe-bottom));
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px calc(15px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.quota-copy {
  padding-right: 12px;
  color: #666;
  font-size: 13px;
  line-height: 1.45;
}

.primary-pill {
  flex: 0 0 auto;
  min-width: 124px;
  min-height: 46.5px;
  padding: 12px 30px;
  border-radius: 25px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
  font-size: 16px;
  font-weight: 600;
}

.primary-pill.inactive {
  opacity: 0.5;
}

.detail-view {
  padding-bottom: calc(78px + var(--safe-bottom));
  background: var(--page-bg);
}

.detail-media {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.detail-image {
  width: 100%;
  aspect-ratio: 1600 / 1337;
  object-fit: cover;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  font-size: 22px;
}

.carousel-btn.prev { left: 25px; }
.carousel-btn.next { right: 25px; }

.detail-summary,
.detail-content {
  margin-bottom: 12px;
  padding: 20px 25px;
  background: #fff;
}

.detail-title {
  margin: 0 0 18px;
  color: #333;
  font-size: 16px;
  font-weight: 600;
}

.product-meta {
  display: flex;
  gap: 28px;
  color: #666;
  font-size: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.detail-section-title {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
  color: #333;
  font-size: 15px;
  font-weight: 600;
}

.detail-lines p {
  margin: 0 0 8px;
  color: #555;
  font-size: 13px;
  line-height: 1.65;
}

.detail-lines p.group-title {
  margin-top: 15px;
  color: #333;
  font-weight: 600;
}

.detail-action-bar {
  position: fixed;
  right: 50%;
  bottom: 0;
  left: 50%;
  z-index: 30;
  display: grid;
  width: min(100%, 480px);
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 10px 15px calc(10px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}

.detail-action {
  min-height: 42.5px;
  padding: 10px;
  border-radius: 25px;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}

.detail-action.exchange { background: #ffa726; }
.detail-action.return { background: linear-gradient(135deg, var(--brand-start), var(--brand-end)); }

.confirm-view {
  padding-bottom: calc(96px + var(--safe-bottom));
  background: var(--page-bg);
}

.content-wrap {
  padding: 15px;
}

.order-card {
  margin-bottom: 15px;
  padding: 18px 10px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card-title {
  margin: 0 0 16px;
  padding: 0 5px 12px;
  border-bottom: 1px solid #eee;
  color: #333;
  font-size: 15px;
  font-weight: 600;
}

.order-product {
  display: flex;
  align-items: center;
  padding: 0 5px;
}

.order-product img {
  width: 70px;
  height: 58px;
  margin-right: 15px;
  border-radius: 8px;
  object-fit: cover;
}

.order-product-name {
  min-width: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.order-product-qty {
  color: #999;
  font-size: 13px;
}

.address-grid {
  display: grid;
  gap: 10px;
  padding: 0 5px;
}

.address-select,
.form-input {
  width: 100%;
  min-height: 44px;
  padding: 12px 15px;
  border: 2px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: #000;
  background: #fff;
  font-size: 14px;
}

.address-select {
  min-height: 45.5px;
  padding: 12px 10px;
}

.form-input:focus,
.address-select:focus {
  border-color: var(--brand-start);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-field {
  padding: 0 5px;
  margin-bottom: 14px;
}

.form-field:last-child {
  margin-bottom: 0;
}

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

.required-mark {
  margin-left: 3px;
  color: #e74c3c;
}

.phone-invalid {
  border-color: #e74c3c;
}

.total-copy {
  color: #666;
  font-size: 14px;
}

.total-copy strong {
  margin-left: 3px;
  color: #e74c3c;
  font-size: 22px;
}

.submit-order-btn {
  width: 180px;
  min-height: 52.5px;
  border-radius: 25px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
  font-size: 16px;
  font-weight: 600;
}

.success-view {
  display: flex;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 40px 25px;
  text-align: center;
  background: #fff;
}

.success-icon {
  display: grid;
  width: 88px;
  height: 88px;
  margin: 0 auto 26px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #4caf50;
  box-shadow: 0 10px 24px rgba(76, 175, 80, 0.23);
  font-size: 50px;
}

.success-title {
  margin-bottom: 12px;
  color: #333;
  font-size: 24px;
  font-weight: 600;
}

.success-message {
  margin-bottom: 28px;
  color: #777;
  font-size: 14px;
  line-height: 1.8;
}

.order-number-box {
  margin-bottom: 30px;
  padding: 18px 24px;
  border-radius: 8px;
  background: #f6f7fb;
}

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

.order-number-value {
  color: var(--brand-end);
  font-size: 18px;
  font-weight: 600;
}

.success-order-btn {
  width: 100%;
  min-height: 52.5px;
  border-radius: 25px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
  font-size: 16px;
  font-weight: 600;
}

.order-detail-view {
  padding-bottom: 24px;
}

.order-status-band {
  padding: 24px 20px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
}

.order-status-band h2 {
  margin: 0 0 7px;
  font-size: 21px;
  font-weight: 600;
}

.order-status-band p {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.order-info-row {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 5px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  line-height: 1.6;
}

.order-info-row:last-child {
  border-bottom: 0;
}

.order-info-label {
  flex: 0 0 auto;
  color: #999;
}

.order-info-value {
  min-width: 0;
  text-align: right;
  word-break: break-word;
}

.timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 12px 0 2px;
}

.timeline::before {
  position: absolute;
  top: 20px;
  right: 12.5%;
  left: 12.5%;
  height: 2px;
  background: #e5e5e5;
  content: "";
}

.timeline-step {
  position: relative;
  z-index: 1;
  color: #aaa;
  text-align: center;
  font-size: 11px;
}

.timeline-dot {
  width: 18px;
  height: 18px;
  margin: 0 auto 7px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #ddd;
  box-shadow: 0 0 0 1px #ddd;
}

.timeline-step.active {
  color: var(--brand-start);
  font-weight: 600;
}

.timeline-step.active .timeline-dot {
  background: var(--brand-start);
  box-shadow: 0 0 0 1px var(--brand-start);
}

.logistics-empty {
  padding: 14px 5px 4px;
  color: #999;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
}

.secondary-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border: 1px solid var(--brand-start);
  border-radius: 22px;
  color: var(--brand-start);
  background: #fff;
  font-size: 14px;
  font-weight: 600;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1000;
  max-width: min(320px, calc(100% - 48px));
  padding: 12px 24px;
  border-radius: 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.82);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -40%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%);
}

@media (min-width: 481px) {
  .app-shell {
    min-height: 100vh;
  }
}

@media (max-width: 350px) {
  .login-container {
    width: calc(100% - 36px);
  }

  .login-header h1 {
    font-size: 18px;
  }

  .catalog-bottom {
    padding-right: 14px;
    padding-left: 14px;
  }

  .primary-pill {
    min-width: 112px;
    padding-right: 22px;
    padding-left: 22px;
  }
}

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