:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f8fafc;
  --card: #fff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text2: #64748b;
  --text3: #94a3b8;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --nav-h: 56px;
  --tab-h: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

html {
  overflow-y: scroll;
}

.page {
  display: none;
  min-height: 100vh;
  padding-bottom: calc(var(--tab-h) + 50px);
}

.page.active {
  display: block;
}

/* ─── Header ─── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.header .back {
  border: none;
  background: none;
  font-size: 24px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}

/* ─── Bottom Tabs ─── */
.tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: none;
  z-index: 100;
  height: var(--tab-h);
}

.tabs.active {
  display: flex;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 11px;
  cursor: pointer;
  border: none;
  background: none;
  transition: color .2s;
}

.tab-item.active {
  color: var(--primary);
}

.tab-item .icon {
  font-size: 22px;
  margin-bottom: 2px;
}

/* ─── Cards ─── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Forms ─── */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  transition: border .2s;
  background: var(--bg);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-select {
  width: 100%;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 15px;
  background: var(--bg);
  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 d='M6 8L1 3h10z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-textarea {
  width: 100%;
  min-height: 80px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  resize: vertical;
  background: var(--bg);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-hint {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.form-input.error {
  border-color: var(--danger);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:active {
  background: var(--primary-dark);
}

.btn-outline {
  background: var(--card);
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: .5;
  pointer-events: none;
}

/* ─── Auth Page ─── */
.auth-logo {
  text-align: center;
  padding: 40px 0 20px;
}

.auth-logo .icon {
  font-size: 56px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-logo p {
  color: var(--text2);
  font-size: 14px;
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin: 0 16px 20px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.send-code {
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  min-width: 110px;
}

.send-code:disabled {
  opacity: .5;
}

.send-code.counting {
  background: var(--border);
  color: var(--text3);
  border-color: var(--border);
}

.phone-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* ─── Module Grid ─── */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px;
  margin-top: 4px;
}

.module-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s;
  border: 2px solid transparent;
}

.module-card:active {
  transform: scale(.97);
}

.module-card .icon {
  font-size: 44px;
  margin-bottom: 10px;
}

.module-card .name {
  font-size: 15px;
  font-weight: 600;
}

.module-card .desc {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

/* ─── Step Indicator ─── */
.steps {
  display: flex;
  padding: 12px 16px;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  position: sticky;
  top: var(--nav-h);
  z-index: 99;
  background: var(--bg);
}

.step {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 12px;
}

.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--border);
  color: var(--text3);
  flex-shrink: 0;
}

.step.active .step-dot {
  background: var(--primary);
  color: #fff;
}

.step.done .step-dot {
  background: var(--success);
  color: #fff;
}

.step-line {
  flex: 1;
  height: 2px;
  min-width: 20px;
  background: var(--border);
  border-radius: 1px;
}

.step.done .step-line {
  background: var(--success);
}

/* ─── Result Page ─── */
.result-content {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 14px;
}

.result-content h3 {
  font-size: 16px;
  margin: 16px 0 8px;
  color: var(--primary);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}

.tag-blue {
  background: var(--primary-light);
  color: var(--primary);
}

.tag-green {
  background: var(--success-light);
  color: var(--success);
}

/* ─── History List ─── */
.history-item {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item-left {
  flex: 1;
  min-width: 0;
}

.history-item .title {
  font-size: 15px;
  font-weight: 500;
}

.history-item .meta {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

.record-dl-btn {
  flex-shrink: 0;
  margin-left: 10px;
  padding: 5px 12px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 16px;
  cursor: pointer;
  transition: all .15s;
}

.record-dl-btn:active {
  background: var(--primary);
  color: #fff;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ─── Profile ─── */
.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 12px;
}

.profile-stats {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.profile-stat {
  flex: 1;
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
  cursor: pointer;
}

.profile-stat .num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.profile-stat .label {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

/* ─── Toast ─── */
.toast {
  position: fixed;
  top: 20px;
  left: 16px;
  right: 16px;
  z-index: 9999;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  color: #fff;
  text-align: center;
  animation: slideDown .3s;
}

.toast-error {
  background: var(--danger);
}

.toast-success {
  background: var(--success);
}

@keyframes slideDown {
  from {
    transform: translateY(-40px);
    opacity: 0
  }

  to {
    transform: translateY(0);
    opacity: 1
  }
}

/* ─── Misc ─── */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-divider {
  height: 8px;
  background: var(--bg);
  margin: 8px -16px;
  width: calc(100% + 32px);
}

.text-center {
  text-align: center;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

.loading-dots:after {
  content: '...';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0% {
    content: '.'
  }

  33% {
    content: '..'
  }

  66% {
    content: '...'
  }
}

/* ─── Date Picker Overlay ─── */
.date-box {
  display: flex;
  align-items: center;
  gap: 0;
}

.date-box .form-input {
  flex: 1;
}

.date-icon-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  margin-left: 6px;
}

.date-icon-btn {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.date-picker-native {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

/* ─── Stepper ─── */
.stepper {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  width: 100%;
}

.stepper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.stepper-input {
  flex: 1;
  text-align: center;
  border: none !important;
  padding: 10px 4px !important;
  font-weight: 600;
  font-size: 15px;
  background: transparent;
  -moz-appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-btn {
  width: 42px;
  border: none;
  background: #f1f5f9;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stepper-btn:active {
  background: var(--primary);
  color: #fff;
}

.stepper-btn:disabled {
  color: #cbd5e1;
}

/* ─── Progress Bar ─── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-wrap .stepper {
  flex: 1;
}

.progress-bar-outer {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  border-radius: 6px;
  transition: width .3s, background .3s;
}

.progress-pct {
  font-size: 13px;
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

/* ─── Region Bottom Sheet ─── */
.region-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 9998;
  display: none;
}

.region-overlay.active {
  display: block;
}

.region-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform .3s ease;
  max-height: 65vh;
  display: flex;
  flex-direction: column;
}

.region-sheet.active {
  transform: translateY(0);
}

.region-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.region-sheet-header .title {
  font-size: 15px;
  font-weight: 600;
}

.region-sheet-header .close {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text2);
}

.region-sheet-header .confirm {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.region-columns {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.region-col {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-right: 1px solid var(--border);
}

.region-col:last-child {
  border-right: none;
}

.region-col.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 13px;
  padding: 20px;
}

.region-item {
  padding: 14px 12px;
  font-size: 14px;
  cursor: pointer;
  text-align: center;
  border-bottom: 1px solid #f1f5f9;
  transition: background .15s;
}

.region-item:active {
  background: var(--bg);
}

.region-item.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.region-field {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.region-field .form-input {
  flex: 1;
  cursor: pointer;
}

.region-field .arrow {
  margin-left: 8px;
  color: var(--text3);
  font-size: 14px;
}

/* ─── Recharge ─── */
.recharge-plan {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border .2s, background .2s;
  display: flex;
  align-items: center;
  gap: 14px;
}

.recharge-plan.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.recharge-plan .plan-price {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  min-width: 70px;
}

.recharge-plan .plan-info {
  flex: 1;
}

.recharge-plan .plan-name {
  font-size: 15px;
  font-weight: 600;
}

.recharge-plan .plan-desc {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}

.recharge-plan .plan-badge {
  display: inline-block;
  background: var(--warning);
  color: #fff;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

.pay-methods {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}

.pay-method {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.pay-method.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.pay-method .pay-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 9996;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin: 0 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.modal-box .modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-box .modal-msg {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 20px;
}

.modal-box .modal-btns {
  display: flex;
  gap: 10px;
}

.modal-box .modal-btns .btn {
  flex: 1;
}

/* ─── Shop Grid ─── */
.shop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shop-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 0;
}

.shop-item .shop-name {
  font-size: 13px;
  color: var(--text2);
}

.shop-item .shop-stepper {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: 32px;
  width: 100%;
}

.shop-item .shop-stepper input {
  width: 28px;
  flex: none;
  text-align: center;
  border: none;
  font-size: 13px;
  font-weight: 600;
  -moz-appearance: textfield;
}

.shop-item .shop-stepper input::-webkit-outer-spin-button,
.shop-item .shop-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.shop-item .shop-stepper button {
  width: 28px;
  border: none;
  background: #f1f5f9;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.shop-item .shop-stepper button:active {
  background: var(--primary);
  color: #fff;
}

.fieldset-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ─── Radio Options ─── */
.radio-options {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  white-space: nowrap;
}

.radio-option:active {
  background: var(--bg);
}

.radio-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.radio-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
}

.radio-option.selected .radio-circle {
  border-color: var(--primary);
}

.radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: all .15s;
}

.radio-option.selected .radio-dot {
  background: var(--primary);
}

.radio-label {
  font-size: 14px;
}

/* ─── Inline Form Row ─── */
.form-group-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-label-inline {
  margin-bottom: 0 !important;
  min-width: 80px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
}