/* ===========================================================
   好来宝设计系统 - Design Tokens
   =========================================================== */
:root {
  /* ---------- Brand ---------- */
  --brand-50:  #EEF0FF;
  --brand-100: #DFE2FF;
  --brand-200: #C3C8FF;
  --brand-300: #9CA3FB;
  --brand-400: #7B7EF2;
  --brand-500: #5B5BD6;
  --brand-600: #4A47BE;
  --brand-700: #3B389B;
  --brand-800: #2C2A75;

  /* ---------- Accent (成交/激励) ---------- */
  --accent-50:  #FFF1EC;
  --accent-100: #FFDFD3;
  --accent-400: #FF8A62;
  --accent-500: #FF6B3D;
  --accent-600: #E85426;

  /* ---------- Semantic ---------- */
  --success-50: #E9F9F0; --success-500: #16A34A; --success-600: #128040;
  --warning-50: #FFF7E6; --warning-500: #F59E0B; --warning-600: #C97F06;
  --danger-50:  #FEECEC; --danger-500:  #EF4444; --danger-600:  #D22F2F;
  --info-50:    #EAF3FF; --info-500:    #3B82F6;

  /* ---------- Neutral ---------- */
  --ink-900: #12141A;
  --ink-800: #232733;
  --ink-700: #3C4252;
  --ink-600: #5A6172;
  --ink-500: #767E90;
  --ink-400: #98A0B3;
  --ink-300: #C3C9D6;
  --ink-200: #E2E6EF;
  --ink-100: #EFF2F7;
  --ink-50:  #F7F8FC;
  --white:   #FFFFFF;

  --bg-page: #F5F6FB;
  --bg-card: #FFFFFF;
  --bg-soft: #FAFBFE;
  --border:  #E6E9F2;

  /* ---------- Spacing (4px base) ---------- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* ---------- Radius ---------- */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 999px;

  /* ---------- Shadow ---------- */
  --sh-xs: 0 1px 2px rgba(18, 20, 26, .04);
  --sh-sm: 0 2px 8px rgba(18, 20, 26, .06);
  --sh-md: 0 6px 20px rgba(18, 20, 26, .08);
  --sh-lg: 0 14px 40px rgba(18, 20, 26, .12);
  --sh-brand: 0 8px 24px rgba(91, 91, 214, .24);

  /* ---------- Typography ---------- */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", "DIN Alternate", ui-monospace, Menlo, Consolas, monospace;

  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px;
  --fs-16: 16px; --fs-18: 18px; --fs-20: 20px; --fs-24: 24px; --fs-28: 28px;
  --fs-34: 34px; --fs-42: 42px;

  --lh-tight: 1.25; --lh-base: 1.6;

  /* ---------- Layout ---------- */
  --page-max: 1200px;
  --header-h: 64px;
  --tabbar-h: 56px;
  --z-header: 100; --z-tabbar: 100; --z-drawer: 200; --z-modal: 300; --z-toast: 400;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

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

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: var(--lh-base);
  color: var(--ink-800);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
img { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
p { margin: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }
::-webkit-scrollbar-track { background: transparent; }

/* ===================== 通用原子类 ===================== */
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-500); }
.dim { color: var(--ink-400); }
.strong { font-weight: 600; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.row { display: flex; align-items: center; }
.row-top { display: flex; align-items: flex-start; }
.col { display: flex; flex-direction: column; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }

.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
.mt-5{margin-top:20px}.mt-6{margin-top:24px}.mt-8{margin-top:32px}
.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-6{margin-bottom:24px}

/* ===================== 按钮 ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: var(--r-sm);
  font-size: var(--fs-14); font-weight: 500; white-space: nowrap;
  transition: all .18s var(--ease); border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--brand-500); color: #fff; box-shadow: 0 2px 8px rgba(91,91,214,.25); }
.btn-primary:hover:not([disabled]) { background: var(--brand-600); box-shadow: var(--sh-brand); }

.btn-accent { background: var(--accent-500); color: #fff; box-shadow: 0 2px 8px rgba(255,107,61,.28); }
.btn-accent:hover:not([disabled]) { background: var(--accent-600); }

.btn-ghost { background: var(--white); color: var(--ink-700); border-color: var(--border); }
.btn-ghost:hover:not([disabled]) { border-color: var(--brand-300); color: var(--brand-600); background: var(--brand-50); }

.btn-soft { background: var(--brand-50); color: var(--brand-600); }
.btn-soft:hover:not([disabled]) { background: var(--brand-100); }

.btn-primary-soft { background: var(--brand-50); color: var(--brand-600); }
.btn-primary-soft:hover:not([disabled]) { background: var(--brand-100); }

.btn-success-soft { background: var(--success-50); color: var(--success-600); }
.btn-success-soft:hover:not([disabled]) { background: #D7F2E3; }

.btn-danger-soft { background: var(--danger-50); color: var(--danger-600); }
.btn-danger-soft:hover:not([disabled]) { background: #FBDCDC; }

.btn-danger { background: var(--danger-50); color: var(--danger-600); }
.btn-danger:hover:not([disabled]) { background: #FBDCDC; }

.btn-text { height: auto; padding: 4px 6px; color: var(--brand-600); background: none; }
.btn-text:hover { color: var(--brand-700); text-decoration: underline; }

.btn-sm { height: 32px; padding: 0 12px; font-size: var(--fs-13); border-radius: var(--r-xs); }
.btn-lg { height: 48px; padding: 0 28px; font-size: var(--fs-16); border-radius: var(--r-md); }
.btn-block { width: 100%; }

/* ===================== 卡片 ===================== */
.card {
  background: var(--bg-card); border-radius: var(--r-lg);
  border: 1px solid var(--border); box-shadow: var(--sh-xs);
}
.card-pad { padding: var(--sp-5); }
.card-hover { transition: all .2s var(--ease); }
.card-hover:hover { box-shadow: var(--sh-md); border-color: var(--brand-200); transform: translateY(-2px); }

.panel-title {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-16); font-weight: 600; color: var(--ink-900);
  margin-bottom: var(--sp-4);
}
.panel-title::before {
  content: ''; width: 3px; height: 15px; border-radius: 2px;
  background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
}

/* ===================== 标签 ===================== */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: var(--r-xs);
  font-size: var(--fs-12); font-weight: 500; white-space: nowrap;
  background: var(--ink-100); color: var(--ink-600);
}
.tag-brand   { background: var(--brand-50);   color: var(--brand-600); }
.tag-accent  { background: var(--accent-50);  color: var(--accent-600); }
.tag-success { background: var(--success-50); color: var(--success-600); }
.tag-warning { background: var(--warning-50); color: var(--warning-600); }
.tag-danger  { background: var(--danger-50);  color: var(--danger-600); }
.tag-info    { background: var(--info-50);    color: var(--info-500); }
.tag-lg { height: 26px; padding: 0 10px; font-size: var(--fs-13); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===================== 表单 ===================== */
.field { margin-bottom: var(--sp-5); }
.field-label {
  display: block; margin-bottom: 8px;
  font-size: var(--fs-13); font-weight: 500; color: var(--ink-700);
}
.field-label .req { color: var(--danger-500); margin-left: 2px; }
.field-tip { margin-top: 6px; font-size: var(--fs-12); color: var(--ink-400); }
.field-error { margin-top: 6px; font-size: var(--fs-12); color: var(--danger-500); }

.input, .textarea, .select {
  width: 100%; padding: 0 14px; height: 42px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--white); color: var(--ink-800);
  transition: all .18s var(--ease); outline: none;
}
.textarea { height: auto; padding: 11px 14px; min-height: 96px; resize: vertical; line-height: 1.6; }
.input:hover, .textarea:hover, .select:hover { border-color: var(--ink-300); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand-400); box-shadow: 0 0 0 3px rgba(91, 91, 214, .12);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23767E90' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-400); font-size: var(--fs-14); pointer-events: none;
}
.input-prefix .input { padding-left: 30px; }

.checkbox, .radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox input, .radio input { width: 16px; height: 16px; accent-color: var(--brand-500); cursor: pointer; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; border-radius: var(--r-full); font-size: var(--fs-13);
  background: var(--white); border: 1px solid var(--border); color: var(--ink-600);
  cursor: pointer; transition: all .16s var(--ease);
}
.chip:hover { border-color: var(--brand-300); color: var(--brand-600); }
.chip.on { background: var(--brand-500); border-color: var(--brand-500); color: #fff; font-weight: 500; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--ink-300);
  border-radius: var(--r-full); transition: .2s var(--ease);
}
.switch span::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s var(--ease); box-shadow: var(--sh-xs);
}
.switch input:checked + span { background: var(--brand-500); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ===================== 状态：空/加载/错误 ===================== */
.empty { padding: var(--sp-16) var(--sp-5); text-align: center; color: var(--ink-400); }
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto var(--sp-4); border-radius: var(--r-lg);
  background: var(--ink-50); display: grid; place-items: center; font-size: 28px;
}
.empty-title { font-size: var(--fs-15); color: var(--ink-600); font-weight: 500; }
.empty-desc { margin-top: 6px; font-size: var(--fs-13); }

.skeleton {
  background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-50) 37%, var(--ink-100) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-xs);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner-dark { border-color: var(--ink-200); border-top-color: var(--brand-500); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== Toast ===================== */
.toast-wrap {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px;
  pointer-events: none; width: max-content; max-width: 90vw;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--r-md);
  background: rgba(24, 26, 34, .94); color: #fff; font-size: var(--fs-14);
  box-shadow: var(--sh-lg); backdrop-filter: blur(8px);
  animation: toastIn .26s var(--ease);
}
.toast.success { background: rgba(18, 128, 64, .95); }
.toast.error   { background: rgba(210, 47, 47, .95); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.96); } }

/* ===================== Modal ===================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(18, 20, 26, .48);
  z-index: var(--z-modal); display: grid; place-items: center; padding: 20px;
  animation: fadeIn .2s var(--ease); backdrop-filter: blur(2px);
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: hidden;
  background: var(--white); border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  display: flex; flex-direction: column; animation: modalIn .26s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(.97); } }
.modal-lg { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5); border-bottom: 1px solid var(--border); flex: none;
}
.modal-head h3 { font-size: var(--fs-17, 17px); }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--r-xs); color: var(--ink-400);
  display: grid; place-items: center; font-size: 20px; line-height: 1;
}
.modal-close:hover { background: var(--ink-100); color: var(--ink-700); }
.modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border);
  background: var(--bg-soft); flex: none;
}

/* ===================== 分页 ===================== */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; padding: var(--sp-6) 0; }
.pager button {
  min-width: 34px; height: 34px; padding: 0 10px; border-radius: var(--r-xs);
  border: 1px solid var(--border); background: var(--white);
  font-size: var(--fs-13); color: var(--ink-600); transition: all .16s var(--ease);
}
.pager button:hover:not([disabled]) { border-color: var(--brand-400); color: var(--brand-600); }
.pager button.on { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.pager button[disabled] { opacity: .4; cursor: not-allowed; }

/* ===================== 进度步骤 ===================== */
.steps { display: flex; align-items: flex-start; }
.step { flex: 1; text-align: center; position: relative; }
.step::before {
  content: ''; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px;
  background: var(--ink-200);
}
.step:first-child::before { display: none; }
.step.done::before, .step.on::before { background: var(--brand-400); }
.step-dot {
  position: relative; z-index: 1; width: 28px; height: 28px; margin: 0 auto 8px;
  border-radius: 50%; display: grid; place-items: center; font-size: var(--fs-12);
  background: var(--white); border: 2px solid var(--ink-200); color: var(--ink-400);
}
.step.done .step-dot { background: var(--brand-500); border-color: var(--brand-500); color: #fff; }
.step.on .step-dot {
  border-color: var(--brand-500); color: var(--brand-600); font-weight: 600;
  box-shadow: 0 0 0 4px rgba(91, 91, 214, .14);
}
.step-label { font-size: var(--fs-12); color: var(--ink-400); }
.step.done .step-label, .step.on .step-label { color: var(--ink-700); font-weight: 500; }

/* ===================== 金额 ===================== */
.money { font-family: var(--font-num); font-weight: 600; color: var(--ink-900); }
.money::before { content: '¥'; font-size: .78em; margin-right: 1px; font-weight: 500; opacity: .8; }
.money-in  { color: var(--success-600); }
.money-out { color: var(--danger-500); }
.money-brand { color: var(--brand-600); }
.money-lg { font-size: var(--fs-24); }
.money-xl { font-size: var(--fs-34); }

/* ===================== 头像 ===================== */
.avatar {
  width: 40px; height: 40px; border-radius: var(--r-full); flex: none;
  display: grid; place-items: center; font-size: var(--fs-14); font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 30px; height: 30px; font-size: var(--fs-12); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-18); }

/* ===================== 表格 ===================== */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
table.tbl th {
  text-align: left; padding: 12px 14px; background: var(--bg-soft);
  color: var(--ink-500); font-weight: 500; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--ink-100); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--bg-soft); }
table.tbl tbody tr:last-child td { border-bottom: none; }

/* ===================== 分割线 ===================== */
.hr { height: 1px; background: var(--border); margin: var(--sp-5) 0; border: none; }
.hr-dash { border-top: 1px dashed var(--border); background: none; }
