/* ============================================================
   设计系统 · 组件层
   ── 按钮 / 表单 / 卡片 / 表格 / 标签 / 浮层 / 各种状态
   所有过渡统一 150–300ms，统一缓动曲线；
   所有尺寸取自 base.css 的间距与圆角刻度。
   ============================================================ */

/* ============ 1. 按钮 ============ */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  line-height: 1;
  white-space: nowrap;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--gray-400);
}
.btn:active {
  transform: translateY(.5px);
  background: var(--surface-2);
}
.btn:disabled,
.btn.is-loading {
  opacity: .5;
  pointer-events: none;
}
.btn:disabled { opacity: .45; }

/* 主按钮 */
.btn--primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(79, 70, 229, .25), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn--primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
  box-shadow: 0 2px 8px rgba(79, 70, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn--primary:active {
  background: var(--brand-800);
  box-shadow: 0 1px 2px rgba(79, 70, 229, .25);
}
[data-theme="dark"] .btn--primary { color: #1E1B4B; }
[data-theme="dark"] .btn--primary:hover { background: var(--brand-300); border-color: var(--brand-300); }

/* 幽灵按钮 */
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn--ghost:hover {
  background: var(--surface-hover);
  border-color: transparent;
  color: var(--text);
}

/* 危险（描边式，克制） */
.btn--danger-plain {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  background: transparent;
}
.btn--danger-plain:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

/* 尺寸 */
.btn--xs { height: 24px; padding: 0 var(--sp-2); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn--sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--lg { height: 42px; padding: 0 var(--sp-6); font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn--block { width: 100%; }

/* 加载中：文字让位给 spinner */
.btn.is-loading .btn__text { opacity: 0; }

.spinner {
  position: absolute;
  left: 50%; top: 50%;
  width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0;
  animation: spin .6s linear infinite;
  transition: opacity var(--dur-fast) var(--ease);
}
.btn.is-loading .spinner { opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 2. 图标按钮 ============ */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  color: var(--text-2);
  background: transparent;
  border-radius: var(--r-md);
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.icon-btn:active { transform: scale(.94); }

/* ============ 3. 侧边栏导航项 ============ */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 38px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  border-radius: var(--r-md);
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}
.nav-item svg { color: var(--gray-400); transition: color var(--dur-fast) var(--ease); }
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-item:hover svg { color: var(--text-2); }

/* 选中态：左侧一根短指示条 + 淡主色底 */
.nav-item.is-active {
  background: var(--brand-050);
  color: var(--brand);
  font-weight: var(--fw-semi);
}
.nav-item.is-active svg { color: var(--brand); }
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%;
  width: 3px; height: 18px;
  margin-top: -9px;
  background: var(--brand);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
  animation: fadeIn var(--dur-base) var(--ease) both;
}
[data-theme="dark"] .nav-item.is-active {
  background: rgba(129, 140, 248, .12);
}

.nav-item__badge {
  margin-left: auto;
  min-width: 22px;
  padding: 0 6px;
  font-size: var(--fs-xs);
  font-style: normal;
  font-weight: var(--fw-semi);
  line-height: 18px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--r-full);
  font-variant-numeric: tabular-nums;
}
.nav-item.is-active .nav-item__badge {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, transparent);
}

/* ============ 4. 表单 ============ */
.form { display: flex; flex-direction: column; gap: var(--sp-5); }

.form__item { display: flex; flex-direction: column; gap: var(--sp-2); }

.form__label {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
}
.form__label em { font-style: normal; color: var(--danger); }
.form__label small {
  margin-left: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-normal);
  color: var(--gray-400);
}

.form__control { position: relative; display: flex; align-items: center; }

.form__icon {
  position: absolute;
  left: var(--sp-3);
  color: var(--gray-400);
  pointer-events: none;
  transition: color var(--dur-fast) var(--ease);
}
.form__control:focus-within .form__icon { color: var(--brand); }

.form__suffix {
  position: absolute;
  right: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--muted);
  border-radius: var(--r-sm);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.form__suffix:hover { color: var(--text); background: var(--surface-hover); }

/* 输入框 / 下拉 / 多行文本 */
.input,
.select,
.textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease);
}
.textarea {
  height: auto;
  min-height: 160px;        /* 跟进备注要写很多行，给够高度，仍可手动往下拉 */
  padding: var(--sp-2) var(--sp-3);
  line-height: var(--lh-snug);
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder { color: var(--gray-400); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-400); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

.input:disabled, .select:disabled, .textarea:disabled {
  color: var(--muted);
  background: var(--surface-2);
  cursor: not-allowed;
}

/* 带前置图标的输入 */
.form__control .form__icon ~ .input { padding-left: 34px; }
.form__control .form__icon ~ .input:last-child { padding-right: var(--sp-3); }
.form__control .input:not(:last-child) { padding-right: 56px; }

.select {
  appearance: none;
  padding-right: var(--sp-8);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' width='16' height='16'%3E%3Cpath fill='%2378716C' d='M5 7.5l5 5 5-5H5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* 校验错误 */
.form__item.is-error .input,
.form__item.is-error .select,
.form__item.is-error .textarea {
  border-color: var(--danger);
}
.form__item.is-error .input:focus,
.form__item.is-error .select:focus,
.form__item.is-error .textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent);
}
.form__err {
  min-height: 0;
  font-size: var(--fs-sm);
  color: var(--danger);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.form__item.is-error .form__err { opacity: 1; transform: none; }

/* 字段下方元信息（字数计数等） */
.form__meta {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* 密码强度条 */
.pwd-bar {
  display: flex;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
}
.pwd-bar i {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: var(--r-full);
  transition: background-color var(--dur-base) var(--ease);
}
.pwd-bar i.on:nth-child(1) { background: var(--danger); }
.pwd-bar i.on:nth-child(2) { background: var(--warning); }
.pwd-bar i.on:nth-child(3) { background: var(--success); }

/* 勾选框 */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-base);
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.checkbox input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.checkbox input + span {
  position: relative;
  display: inline-block;
  padding-left: 24px;
  line-height: 18px;
}
.checkbox input + span::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 16px; height: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-xs);
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.checkbox input + span::after {
  content: '';
  position: absolute;
  left: 5px; top: 4.5px;
  width: 5px; height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--dur-fast) var(--ease-spring);
}
.checkbox input:hover + span::before { border-color: var(--brand); }
.checkbox input:checked + span::before {
  background: var(--brand);
  border-color: var(--brand);
}
.checkbox input:checked + span::after { transform: rotate(45deg) scale(1); }
.checkbox input:focus-visible + span::before {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

/* 原生勾选框（表格行选） */
input[type="checkbox"].row-check,
input[type="checkbox"]#check-all {
  width: 15px; height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
}

/* 开关 */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative;
  display: block;
  width: 34px; height: 20px;
  background: var(--gray-300);
  border-radius: var(--r-full);
  transition: background-color var(--dur-base) var(--ease);
}
.switch__track i {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track i { transform: translateX(14px); }
.switch input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.switch__label { transition: color var(--dur-fast) var(--ease); }
.switch input:checked ~ .switch__label { color: var(--text); }

/* 表单栅格与分区 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-5) var(--sp-4);
}
.field-inline { display: flex; align-items: center; gap: var(--sp-3); }

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-5) 0;
  border-top: 1px solid var(--border);
}
.form-section:first-child { border-top: none; padding-top: 0; }
.form-section__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--text);
}
.form-section__head small {
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  color: var(--muted);
}

.form-footer {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}
.form-footer__info { font-size: var(--fs-sm); color: var(--muted); }

/* ============ 5. 卡片 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}
.card__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--text);
}
.card__sub {
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  color: var(--muted);
}
.card__head > :last-child { margin-left: auto; }
.card__head > .card__sub { margin-left: 0; }

.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }

.card-list { display: flex; flex-direction: column; gap: var(--sp-4); }

/* ============ 6. 页头 ============ */
.page-head {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.page-head__title {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-bold);
  letter-spacing: -.02em;
  line-height: 1.25;
  color: var(--text);
}
.page-head__desc {
  margin-top: var(--sp-1);
  font-size: var(--fs-base);
  color: var(--muted);
}
.page-head__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
  flex-wrap: wrap;
}

/* 面包屑 */
.crumb {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--brand); }
.crumb span { color: var(--gray-300); }

/* ============ 7. 统计卡 ============ */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  transition: box-shadow var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease),
              transform var(--dur-base) var(--ease-out);
}
.stat:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
/* 左上角一小块淡色，替代花哨的渐变 */
.stat::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 88px; height: 88px;
  background: var(--brand-050);
  border-radius: 0 0 100% 0;
  opacity: .7;
  pointer-events: none;
}

.stat__icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  color: var(--brand);
  background: var(--brand-050);
  border-radius: var(--r-md);
}
.stat__icon svg { width: 17px; height: 17px; }

.stat__label {
  position: relative;
  font-size: var(--fs-sm);
  color: var(--muted);
}

.stat__value {
  position: relative;
  font-family: var(--font-num);
  font-size: var(--fs-4xl);
  font-weight: var(--fw-bold);
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat__unit {
  margin-left: 3px;
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--muted);
}

.stat__foot {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--muted);
}
.stat__trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  font-weight: var(--fw-semi);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.stat__trend.up   { color: var(--success); background: var(--success-bg); }
.stat__trend.down { color: var(--danger);  background: var(--danger-bg); }

/* ============ 8. 图表 ============ */
.grid-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}
.grid-charts--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.chart-box {
  width: 100%;
  min-height: 232px;
}
.chart-box svg { width: 100%; height: auto; display: block; overflow: visible; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-4);
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.chart-legend i {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex: none;
}

/* ============ 9. 渠道排行 ============ */
.rank { display: flex; flex-direction: column; gap: var(--sp-4); }
.rank__item { display: flex; flex-direction: column; gap: var(--sp-2); }
.rank__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
}
.rank__name { font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--text); }
.rank__val {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rank__bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.rank__bar i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease-out);
}

/* ============ 10. 工具栏 ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  border-bottom: none;
}
.toolbar__grow { min-width: 140px; }
.toolbar .input, .toolbar .select { height: 34px; }

/* 搜索框（顶栏） */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search svg {
  position: absolute;
  left: var(--sp-3);
  color: var(--gray-400);
  pointer-events: none;
}
.search input {
  width: 210px;
  height: 34px;
  padding: 0 var(--sp-3) 0 34px;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              width var(--dur-base) var(--ease-out);
}
.search input::placeholder { color: var(--gray-400); }
.search input:hover { background: var(--surface-hover); }
.search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
  width: 260px;
}

/* 分段控件 */
.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.segmented button {
  height: 28px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--muted);
  border-radius: var(--r-sm);
  transition: color var(--dur-fast) var(--ease),
              background-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

/* 批量操作条 */
.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: var(--brand-050);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-bottom: none;
  animation: fadeIn var(--dur-base) var(--ease) both;
}
.bulkbar__ops { display: flex; gap: var(--sp-2); margin-left: auto; }
[data-theme="dark"] .bulkbar { background: rgba(129, 140, 248, .1); }

/* ============ 11. 表格 ============ */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  background: var(--surface);
}
.table-wrap:first-child { border-top: 1px solid var(--border); border-radius: var(--r-xl); }

.table { width: 100%; min-width: 860px; }

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  text-align: left;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-base);
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr {
  transition: background-color var(--dur-fast) var(--ease);
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-checked { background: var(--brand-050); }
.table tbody tr:last-child td { border-bottom: none; }

.col-check { width: 40px; }
.col-ops   { width: 132px; }

.cell-name {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
  line-height: var(--lh-snug);
}
.cell-sub {
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row-ops {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  opacity: .62;
  transition: opacity var(--dur-fast) var(--ease);
}
tr:hover .row-ops { opacity: 1; }
.row-ops .btn { padding: 0 var(--sp-2); }

/* ============ 12. 标签 ============ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  white-space: nowrap;
}
.tag i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* 八种业务状态 */
.tag--lead       { color: #B45309; background: #FEF3C7; }
.tag--contacted  { color: #1D4ED8; background: #DBEAFE; }
.tag--collecting { color: #6D28D9; background: #EDE9FE; }
.tag--planned    { color: #0E7490; background: #CFFAFE; }
.tag--submitted  { color: var(--brand-700); background: var(--brand-100); }
.tag--disbursed  { color: #047857; background: #D1FAE5; }
.tag--rejected   { color: #B91C1C; background: #FEE2E2; }
.tag--lost       { color: #57534E; background: #F5F5F4; }

[data-theme="dark"] .tag--lead       { color: #FBBF24; background: rgba(251, 191, 36, .14); }
[data-theme="dark"] .tag--contacted  { color: #60A5FA; background: rgba(96, 165, 250, .14); }
[data-theme="dark"] .tag--collecting { color: #A78BFA; background: rgba(167, 139, 250, .14); }
[data-theme="dark"] .tag--planned    { color: #22D3EE; background: rgba(34, 211, 238, .14); }
[data-theme="dark"] .tag--submitted  { color: var(--brand-300); background: rgba(129, 140, 248, .16); }
[data-theme="dark"] .tag--disbursed  { color: #34D399; background: rgba(52, 211, 153, .14); }
[data-theme="dark"] .tag--rejected   { color: #F87171; background: rgba(248, 113, 113, .14); }
[data-theme="dark"] .tag--lost       { color: #A8A29E; background: rgba(168, 162, 158, .14); }

/* ============ 13. 移动端数据卡片 ============ */
.data-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.data-card.is-checked {
  border-color: var(--brand);
  background: var(--brand-050);
}
.data-card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}
.data-card__title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--text);
  line-height: var(--lh-snug);
}
.data-card__amount {
  font-family: var(--font-num);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.data-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.data-card__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

/* ============ 14. 分页 ============ */
.pager {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.pager__info {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pager__pages {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  margin-left: auto;
}
.pager__btn {
  min-width: 30px;
  height: 30px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
  font-variant-numeric: tabular-nums;
}
.pager__btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.pager__btn:disabled { opacity: .4; }
.pager__btn.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}
[data-theme="dark"] .pager__btn.is-active { color: #1E1B4B; }
.pager__dots {
  padding: 0 var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--gray-400);
}
.select--page-size { width: auto; min-width: 92px; height: 30px; font-size: var(--fs-sm); }

/* ============ 15. 状态块（空 / 失败） ============ */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-16) var(--sp-6);
  text-align: center;
  animation: fadeUp var(--dur-slow) var(--ease-out) both;
}
.state__art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  color: var(--gray-300);
  background: var(--surface-2);
  border-radius: var(--r-full);
  margin-bottom: var(--sp-1);
}
.state__art svg { width: 26px; height: 26px; }
.state__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semi);
  color: var(--text);
}
.state__desc {
  max-width: 380px;
  font-size: var(--fs-base);
  color: var(--muted);
}
.state__ops {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

/* ============ 16. 骨架屏 ============ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    color-mix(in srgb, var(--surface) 80%, transparent) 50%,
    transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-row {
  height: 12px;
  margin: var(--sp-3) 0;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.skeleton-table { padding: var(--sp-2) 0; }

/* ============ 17. 提示块 ============ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-3);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  animation: fadeIn var(--dur-base) var(--ease) both;
}
.alert svg { flex: none; margin-top: 1px; }
.alert--error   { color: var(--danger);  background: var(--danger-bg);  border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert--success { color: var(--success); background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert--warning { color: var(--warning); background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 24%, transparent); }
.alert--info    { color: var(--info);    background: var(--info-bg);    border-color: color-mix(in srgb, var(--info) 22%, transparent); }

/* ============ 18. Toast ============ */
.toast-root {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  width: 336px;
  max-width: calc(100vw - var(--sp-8));
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideInRight var(--dur-base) var(--ease-out) both;
}
.toast.is-out {
  animation: fadeOut var(--dur-base) var(--ease) both;
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(16px); }
}

.toast__ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  margin-top: 1px;
  flex: none;
  border-radius: var(--r-full);
  color: var(--info);
}
.toast__ico svg { width: 18px; height: 18px; }
.toast--success .toast__ico { color: var(--success); }
.toast--error   .toast__ico { color: var(--danger); }
.toast--warning .toast__ico { color: var(--warning); }
.toast--info    .toast__ico { color: var(--info); }

.toast__body { flex: 1; min-width: 0; }
.toast__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
  line-height: var(--lh-snug);
}
.toast__desc {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: var(--lh-snug);
}
.toast__close {
  flex: none;
  width: 20px; height: 20px;
  font-size: 12px;
  color: var(--gray-400);
  border-radius: var(--r-xs);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.toast__close:hover { color: var(--text); background: var(--surface-hover); }

/* ============ 19. 弹窗 ============ */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background: rgba(12, 10, 9, .42);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--dur-base) var(--ease) both;
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - var(--sp-12));
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: scaleIn var(--dur-base) var(--ease-out) both;
}

.modal__head {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
}
.modal__ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  flex: none;
  color: var(--warning);
  background: var(--warning-bg);
  border-radius: var(--r-md);
}
.modal__ico svg { width: 18px; height: 18px; }
.modal--danger .modal__ico { color: var(--danger); background: var(--danger-bg); }
.modal--info .modal__ico { color: var(--info); background: var(--info-bg); }

.modal__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semi);
  color: var(--text);
  line-height: var(--lh-snug);
}
.modal__desc {
  margin-top: var(--sp-1);
  font-size: var(--fs-base);
  color: var(--muted);
  line-height: var(--lh-base);
}
.modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--sp-5) var(--sp-4);
  font-size: var(--fs-base);
  color: var(--text-2);
}
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

/* ============ 20. 用户菜单 ============ */
.user { position: relative; }

.user__btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  height: 38px;
  padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--r-lg);
  transition: background-color var(--dur-fast) var(--ease);
}
.user__btn:hover { background: var(--surface-hover); }
.user__btn > svg { color: var(--gray-400); }

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  flex: none;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semi);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  border-radius: var(--r-full);
  user-select: none;
}

.user__info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.25;
}
.user__info b {
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  color: var(--text);
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user__info small { font-size: var(--fs-xs); color: var(--muted); }

.user__drop {
  position: absolute;
  top: calc(100% + var(--sp-2));
  right: 0;
  min-width: 188px;
  padding: var(--sp-1);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--dur-base) var(--ease-out) both;
  transform-origin: top right;
  z-index: 10;
}
.user__drop-head {
  padding: var(--sp-3);
  margin-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border);
}
.user__drop-head b {
  display: block;
  font-size: var(--fs-base);
  font-weight: var(--fw-semi);
  color: var(--text);
}
.user__drop-head small { font-size: var(--fs-xs); color: var(--muted); }

.user__drop-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-base);
  color: var(--text-2);
  text-align: left;
  border-radius: var(--r-sm);
  transition: background-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
}
.user__drop-item svg { color: var(--gray-400); }
.user__drop-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.user__drop-item:hover svg { color: var(--text-2); }
.user__drop-item--danger { color: var(--danger); }
.user__drop-item--danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.user__drop-item--danger:hover svg { color: var(--danger); }

/* ============ 21. 快照项 ============ */
.snap-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
}
.snap-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.snap-item__info { flex: 1; min-width: 0; }
.snap-item__title {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text);
}
.snap-item__title em {
  font-style: normal;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--brand);
  padding: 1px 6px;
  background: var(--brand-050);
  border-radius: var(--r-full);
}
.snap-item__meta {
  margin-top: 2px;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.snap-item__empty {
  margin-left: var(--sp-2);
  padding: 1px 6px;
  font-size: var(--fs-xs);
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: var(--r-full);
}

/* ============ 22. 响应式：组件级 ============ */
@media (max-width: 1280px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-charts--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search input { width: 168px; }
  .search input:focus { width: 200px; }
}

@media (max-width: 900px) {
  .page-head { flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
  .page-head__actions { margin-left: 0; width: 100%; }
  .grid-charts, .grid-charts--3 { grid-template-columns: minmax(0, 1fr); }
  .topbar__actions .switch { display: none; }
  .search { display: none; }
}

@media (max-width: 768px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .table { min-width: 720px; }
  .toolbar { padding: var(--sp-3) var(--sp-4); }
  .toolbar > * { flex: 1 1 auto; }
  .pager { padding: var(--sp-3) var(--sp-4); }
  .pager__pages { width: 100%; margin-left: 0; justify-content: center; }
  .stat__value { font-size: var(--fs-3xl); }
  .modal { max-width: 100%; }
  .modal-foot, .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
}

@media (max-width: 640px) {
  .grid-stats { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .stat { padding: var(--sp-4); }
  .page-head__title { font-size: var(--fs-2xl); }
  .toast-root {
    top: auto;
    bottom: var(--sp-4);
    left: var(--sp-3);
    right: var(--sp-3);
  }
  .toast { width: 100%; }
  .user__info { display: none; }
  .user__btn { padding: 0 var(--sp-1); }
  .card__body { padding: var(--sp-4); }
  .card__head { padding: var(--sp-3) var(--sp-4); }
  .state { padding: var(--sp-10) var(--sp-4); }
}

/* ============================================================
   转化漏斗（数据看板 · 2026-10-15）
   近似累计口径，说明文字在卡片里
   ============================================================ */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel__row {
  display: grid;
  grid-template-columns: 44px 1fr 60px 52px;
  align-items: center;
  gap: 10px;
}
.funnel__name { font-size: var(--fs-sm); color: var(--text-2); }
.funnel__track {
  height: 22px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.funnel__track i {
  display: block;
  height: 100%;
  border-radius: var(--r-sm);
  transition: width var(--dur-slow) var(--ease-out);
}
.funnel__val { font-size: var(--fs-sm); color: var(--text); font-weight: var(--fw-semi); text-align: right; }
.funnel__rate { font-size: var(--fs-xs); color: var(--muted); text-align: right; }

@media (max-width: 720px) {
  .funnel__row { grid-template-columns: 36px 1fr 48px 44px; gap: 8px; }
}

/* 筛选提示条 + 操作痕迹徽章（2026-10-18） */
.filter-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #FFF7ED;
  border-left: 3px solid #F59E0B;
  border-radius: var(--r-md);
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: var(--fs-sm);
  color: #92400E;
  line-height: 1.6;
}
html[data-theme="dark"] .filter-hint {
  background: rgba(245,158,11,.12);
  color: #FBBF24;
  border-left-color: #F59E0B;
}
.filter-hint b { color: inherit; font-weight: var(--fw-semi); }
.filter-hint .btn {
  margin-left: auto;
  padding: 3px 10px;
  font-size: var(--fs-xs);
}

.trace-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  line-height: 1.5;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--muted);
  vertical-align: middle;
  font-weight: var(--fw-normal);
  white-space: nowrap;
}
.trace-badge--ai { background: #EEEDFE; color: #534AB7; }
html[data-theme="dark"] .trace-badge--ai { background: rgba(127,119,221,.2); color: #AFA9EC; }
