:root {
  --primary: #e60012;
  --primary-dark: #c80010;
  --primary-soft: rgba(230, 0, 18, 0.08);
  --primary-glow: rgba(230, 0, 18, 0.18);
  --bg: #f2f3f5;
  --card: #ffffff;
  --surface: #f6f7f9;
  --text: #1f2329;
  --text-secondary: #646a73;
  --muted: #a8adb5;
  --border: #eef0f3;
  --success: #00a870;
  --success-soft: rgba(0, 168, 112, 0.1);
  --radius: 12px;
  --radius-sm: 10px;
  --radius-md: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.page {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.page-stack {
  border-radius: 18px;
  overflow: hidden;
  background: var(--card);
  box-shadow: 0 6px 24px rgba(31, 35, 41, 0.07);
}

/* ── Top banner header ── */
.page-header {
  position: relative;
  background: transparent;
}

.banner-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #fff5f6;
}
.banner-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36px;
  background: linear-gradient(to bottom, transparent, #fff);
  pointer-events: none;
  z-index: 1;
}

.banner-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 750 / 320;
  object-fit: cover;
  object-position: center top;
}

.banner-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  z-index: 2;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn--glass {
  background: rgba(255, 255, 255, 0.85);
  color: #333;
  box-shadow: none;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* ── Main unified card ── */
.main-content {
  position: relative;
  z-index: 2;
  margin-top: -6px;
  padding: 0;
}

.order-card {
  background: var(--card);
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

.order-card-cap {
  padding: 20px 20px 0;
  text-align: center;
}

.pkg-head {
  margin: 16px 16px 0;
  padding: 14px 14px 12px;
  background: var(--surface);
  border-radius: var(--radius);
}

.product-tc-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.area-notice {
  margin: 8px 4px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--primary);
}

.area-notice--modal {
  margin: 0 0 14px;
  text-align: center;
}

.welcome-body {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}

.welcome-body p {
  margin: 0 0 12px;
}

.welcome-body strong {
  color: var(--primary);
}

.sheet-panel--welcome {
  text-align: center;
}

.sheet-panel--welcome .welcome-body {
  text-align: left;
  padding: 0 4px;
}

.product-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 12px;
}

.tc-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tc-list li {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.tc-list li.active {
  color: #fff;
  background: var(--primary);
}
.tc-list li.tc-empty {
  cursor: default;
  background: var(--surface);
  color: var(--muted);
}

.order-section {
  padding: 18px 16px 0;
}

.section-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 10px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 14px 14px 14px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s;
}
.task-item:active {
  background: #eceef2;
}

.task-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.task-status {
  font-size: 13px;
  margin-right: 6px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-arrow {
  width: 7px;
  height: 7px;
  border-top: 1.5px solid #c4c8cf;
  border-right: 1.5px solid #c4c8cf;
  transform: rotate(45deg);
  flex-shrink: 0;
}

.field-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: block;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.field-input {
  width: 100%;
  padding: 13px 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field-input::placeholder {
  color: #b0b5bd;
}
.field-input:focus {
  background: #fff;
  border-color: rgba(230, 0, 18, 0.35);
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding-right: 4px;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.field--code:focus-within .field-row {
  background: #fff;
  border-color: rgba(230, 0, 18, 0.35);
}
.field-row .field-input {
  background: transparent;
  border: none;
}
.field-row .field-input:focus {
  border: none;
}

.btn-code {
  flex-shrink: 0;
  height: 36px;
  padding: 0 12px;
  margin: 4px 0;
  border: none;
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}
.btn-code:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}
.badge-pending {
  color: var(--text-secondary);
  background: #fff;
}
.badge-done, .badge.ok {
  color: var(--success);
  background: var(--success-soft);
}

.order-footer {
  padding: 20px 16px 18px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.btn-primary:active {
  background: var(--primary-dark);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.input-group {
  display: block;
}
.input-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.input-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  color: var(--text);
  background: #f7f7f7;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
}
.input-field::placeholder {
  color: #bbb;
}
.input-field:focus {
  border-color: var(--primary);
  background: #fff;
}
.input-row {
  display: flex;
  gap: 10px;
}
.input-row .input-field {
  flex: 1;
  min-width: 0;
}

.btn-outline {
  flex-shrink: 0;
  padding: 0 14px;
  height: 40px;
  font-size: 14px;
  color: var(--primary);
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.btn-outline:active {
  background: #fef5f5;
}
.btn-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-sm {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-ghost {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-ghost:active {
  background: var(--bg);
}

.page-footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 14px 16px 10px;
}

/* ── Bottom sheet ── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 26, 0.45);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 430px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
.sheet-panel--tall {
  max-height: 92vh;
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: #dde1e8;
  border-radius: 2px;
  margin: 8px auto 16px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}
.sheet-desc {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Real-name sheet ── */
.sheet-panel--realname {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.rn-header {
  text-align: center;
  margin-bottom: 20px;
}
.rn-header-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff0f0, #ffe8e8);
  border-radius: 16px;
  color: var(--primary);
}
.rn-header-icon svg {
  width: 28px;
  height: 28px;
}
.rn-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.rn-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.rn-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 20px;
  padding: 0 8px;
}
.rn-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  transition: color 0.25s;
}
.rn-step.done {
  color: var(--success);
}
.rn-step.active {
  color: var(--primary);
}
.rn-step-dot {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  background: #eef0f4;
  color: var(--muted);
  transition: all 0.25s;
}
.rn-step.done .rn-step-dot {
  background: var(--success);
  color: #fff;
  font-size: 0;
}
.rn-step.done .rn-step-dot::after {
  content: "✓";
  font-size: 13px;
}
.rn-step.active .rn-step-dot {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.rn-step-line {
  flex: 1;
  height: 2px;
  background: #eef0f4;
  margin: 0 4px;
  margin-bottom: 20px;
  max-width: 40px;
  border-radius: 1px;
  transition: background 0.25s;
}
.rn-step-line.done {
  background: var(--success);
}

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

.rn-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: #fafbfc;
  border: 1.5px solid #eef0f4;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.22s ease;
  position: relative;
  overflow: hidden;
}
.rn-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(230,0,18,0.03));
  pointer-events: none;
}
.rn-item:active {
  transform: scale(0.985);
  border-color: rgba(230, 0, 18, 0.3);
}
.rn-item.done {
  border-color: rgba(0, 181, 120, 0.45);
  background: linear-gradient(135deg, #f6fffb, #f0fdf8);
}
.rn-item--locked {
  opacity: 0.52;
  pointer-events: none;
  cursor: not-allowed;
}
.rn-item--active {
  border-color: rgba(230, 0, 18, 0.35);
  box-shadow: 0 0 0 2px rgba(230, 0, 18, 0.08);
}
.rn-item.failed {
  border-color: rgba(230, 0, 18, 0.45);
  background: linear-gradient(135deg, #fff8f8, #fff5f5);
}
.rn-item.failed .rn-item-hint {
  color: var(--primary);
}
.rn-item.loading {
  opacity: 0.7;
  pointer-events: none;
}
.rn-item.loading .rn-item-action {
  animation: pulse 1s ease infinite;
}

.rn-preview {
  width: 72px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(145deg, #e8ecf2, #f4f6f9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.rn-preview--round {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}
.rn-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.rn-preview.has-img .rn-placeholder-icon {
  display: none;
}
.rn-placeholder-icon {
  width: 36px;
  height: auto;
  color: #b8c0cc;
}
.rn-preview--round .rn-placeholder-icon {
  width: 28px;
}

.rn-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rn-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.rn-item-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.rn-item.done .rn-item-hint {
  color: var(--success);
  font-weight: 600;
}
.rn-item.loading .rn-item-hint {
  color: var(--primary);
}

.rn-item-action {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  color: var(--primary);
}
.rn-item-action svg {
  width: 18px;
  height: 18px;
}
.rn-item.done .rn-item-action {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,181,120,0.3);
}
.rn-item.done .rn-item-action svg {
  display: none;
}
.rn-item.done .rn-item-action::after {
  content: "✓";
  font-size: 16px;
  font-weight: 700;
}

.rn-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #f8f9fb;
  border-radius: 10px;
  margin-bottom: 4px;
}
.rn-notice svg {
  width: 16px;
  height: 16px;
  color: #8b95a5;
  flex-shrink: 0;
}
.rn-notice span {
  font-size: 12px;
  color: #8b95a5;
  line-height: 1.4;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* legacy upload classes removed */

/* ── Search & numbers ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.search-bar svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex-shrink: 0;
}
.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  outline: none;
  min-width: 0;
  padding: 10px 0;
}

.number-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.number-tip {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.btn-refresh-num {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding: 0 12px;
  height: 34px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  background: #fff;
  border: 1px solid #ffd6d6;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-refresh-num svg {
  width: 15px;
  height: 15px;
}
.btn-refresh-num:active {
  background: #fef5f5;
}
.btn-refresh-num:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 8px;
  padding: 2px;
}
.num-item {
  padding: 14px 10px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-align: center;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.num-item:active {
  transform: scale(0.97);
}
.num-item.selected {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* ── Selects ── */
.select-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.select-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.select-group span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.select-group select {
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa3b2' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.select-group select:focus {
  border-color: rgba(230, 0, 18, 0.4);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ── Loading & toast ── */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 200;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm {
  width: 24px;
  height: 24px;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.mini-loading {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.mini-loading-box {
  pointer-events: auto;
  min-width: 140px;
  padding: 18px 22px;
  border-radius: 14px;
  background: rgba(30, 30, 30, 0.88);
  backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100% - 48px);
  padding: 12px 20px;
  background: rgba(26, 29, 38, 0.92);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  border-radius: 999px;
  z-index: 300;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease forwards;
}
@keyframes toastIn {
  to { transform: translateX(-50%) translateY(0); }
}

.empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  font-size: 13px;
  color: var(--muted);
}
