/* ══════════════════════════════════════════════════════════════════
   assets/ux.css —— 设计系统（唯一真源的另一半）

   两部分：
     ① :root 里的 token —— 由 design/tokens.json 生成，**不要手改**
        改 token → node scripts/design-sync.js
     ② 基础组件 —— 卡片 / 按钮 / 标签 / 列表行 / 入口格 / 底部导航 …
        页面可以覆盖，但默认值应该够用。

   平台产物：design/out/tokens.{css,dart,swift,kt,ts}
   规范文档：DESIGN.md
   在线规范页：/design/design-system.html（本地直接打开）

   ⚠️ 本文件会被逐字节内联进 user.html / admin.html
     （test-first-paint 校验）。改完跑 node scripts/design-sync.js 同步。
   ══════════════════════════════════════════════════════════════════ */

:root {
/* @tokens:start —— 由 scripts/design-sync.js 生成，勿手改 */
  /* 颜色 */
  --c-bg: #f7f9fc;
  --c-surface: #ffffff;
  --c-surface-alt: #fbfcfd;
  --c-line: #e9ebef;
  --c-line-soft: #f1f3f5;
  --c-ink-1: #101828;
  --c-ink-2: #475467;
  --c-ink-3: #667085;
  --c-ink-4: #98a2b3;
  --c-primary: #1677ff;
  --c-primary-press: #0b5fd1;
  --c-primary-soft: #eef4ff;
  --c-success: #067647;
  --c-success-bg: #ecfdf3;
  --c-warn: #b54708;
  --c-warn-bg: #fffaeb;
  --c-danger: #b42318;
  --c-danger-bg: #fef3f2;
  --c-info: #0b5fd1;
  --c-info-bg: #eff6ff;
  --c-on-primary: #ffffff;
  --c-success-bright: #0e9f6e;
  --c-warn-bright: #f79009;
  --c-danger-bright: #f04438;
  --c-info-bright: #2e90fa;
  --c-cat-blue: #2563eb;
  --c-cat-blue-bg: #dbeafe;
  --c-cat-violet: #7c3aed;
  --c-cat-violet-bg: #ede9fe;
  --c-cat-green: #059669;
  --c-cat-green-bg: #d1fae5;
  --c-cat-sky: #0284c7;
  --c-cat-sky-bg: #e0f2fe;
  --c-cat-amber: #d97706;
  --c-cat-amber-bg: #fef3c7;

  /* 兼容旧名（页面里已有引用，勿删） */
  --c-card: var(--c-surface);
  --c-text: var(--c-ink-1);
  --c-text-2: var(--c-ink-2);
  --c-text-3: var(--c-ink-3);
  --c-primary-text: var(--c-primary-press);
  --c-success-text: var(--c-success);
  --c-danger-text: var(--c-danger);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-caption: 12px;
  --fs-footnote: 13px;
  --fs-body: 14px;
  --fs-title: 16px;
  --fs-headline: 20px;
  --fs-display: 32px;
  --fs-xs: var(--fs-footnote);
  --fs-sm: var(--fs-body);
  --fs-md: var(--fs-title);
  --fs-lg: var(--fs-headline);
  --fs-xl: 26px;
  --fs-2xl: var(--fs-display);
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --lh-tight: 1.25;
  --lh-normal: 1.45;
  --lh-loose: 1.6;

  /* 间距 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* 圆角 / 阴影 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --sh-card: 0 1px 2px rgba(16,24,40,.04);
  --sh-sheet: 0 -8px 32px rgba(16,24,40,.16);

  /* 尺寸 / 层级 / 动效 */
  --tap-min: 44px;
  --size-topbar: 52px;
  --size-tabbar: 56px;
  --size-input: 44px;
  --size-button: 44px;
  --size-button-sm: 32px;
  --size-icon: 20px;
  --z-topbar: 20;
  --z-tabbar: 30;
  --z-sheet: 40;
  --z-modal: 50;
  --z-toast: 60;
  --mo-fast: 120ms;
  --mo-base: 180ms;
  --mo-slow: 240ms;
  --mo-ease: cubic-bezier(.2,.8,.2,1);
  --focus-ring: 2px solid var(--c-primary);
/* @tokens:end */
}

/* ── 基础 ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-ink-1);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* 数字统一等宽，金额和时间不再左右跳 */
.num, .ds-stat-num, .balance, .hero-num, .amount {
  font-variant-numeric: tabular-nums;
}

/* ── 文本层级 ─────────────────────────────────────────────────── */
.t-caption { font-size: var(--fs-caption); color: var(--c-ink-3); }
.t-footnote { font-size: var(--fs-footnote); color: var(--c-ink-3); }
.t-body { font-size: var(--fs-body); }
.t-title { font-size: var(--fs-title); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.t-headline { font-size: var(--fs-headline); font-weight: var(--fw-semibold); line-height: var(--lh-tight); letter-spacing: -.2px; }
.t-display { font-size: var(--fs-display); font-weight: var(--fw-semibold); line-height: 1.1; letter-spacing: -.8px; }

.muted { color: var(--c-ink-3); font-size: var(--fs-footnote); }

/* ── 卡片 ─────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: var(--sp-3);
  box-shadow: var(--sh-card);
}
.card.flush { padding: 0; overflow: hidden; }
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.card-hd b { font-size: var(--fs-title); font-weight: var(--fw-semibold); }

/* ── 按钮 ─────────────────────────────────────────────────────── */
.btn {
  width: 100%; height: var(--size-button);
  border: 0; border-radius: 10px;
  background: var(--c-primary); color: var(--c-on-primary);
  font: inherit; font-size: var(--fs-body); font-weight: var(--fw-semibold);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 16px;
  transition: background var(--mo-fast) var(--mo-ease), opacity var(--mo-fast) var(--mo-ease);
}
.btn:active { background: var(--c-primary-press); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.inline { width: auto; }
.btn.sm { height: var(--size-button-sm); width: auto; padding: 0 12px; font-size: var(--fs-footnote); border-radius: var(--r-sm); }
.btn.ghost { background: var(--c-surface); color: var(--c-ink-1); border: 1px solid var(--c-line); }
.btn.ghost:active { background: var(--c-surface-alt); }
.btn.soft { background: var(--c-primary-soft); color: var(--c-primary-press); }
.btn.danger { background: var(--c-danger); }
.btn.text { background: none; color: var(--c-primary-press); width: auto; padding: 0 6px; font-weight: var(--fw-medium); }
.btn.text:active { background: var(--c-primary-soft); }

.btn-big { width: 100%; height: 46px; border: 0; border-radius: 10px; font: inherit; font-size: var(--fs-body); font-weight: var(--fw-semibold); cursor: pointer; }

/* ── 标签 / 胶囊 ──────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  font-size: 11.5px; line-height: 18px; padding: 0 7px;
  border-radius: 6px; white-space: nowrap;
}
.tag.ok   { background: var(--c-success-bg); color: var(--c-success); }
.tag.fail { background: var(--c-danger-bg);  color: var(--c-danger); }
.tag.warn { background: var(--c-warn-bg);    color: var(--c-warn); }
.tag.off  { background: var(--c-line-soft);  color: var(--c-ink-3); }
.tag.info { background: var(--c-info-bg);    color: var(--c-info); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; line-height: 20px; padding: 0 8px;
  border-radius: var(--r-pill); white-space: nowrap;
}
.pill.ok   { background: var(--c-success-bg); color: var(--c-success); }
.pill.warn { background: var(--c-warn-bg);    color: var(--c-warn); }
.pill.off  { background: var(--c-line-soft);  color: var(--c-ink-3); }
.pill.blue { background: var(--c-primary-soft); color: var(--c-primary-press); }

/* ── 表单 ─────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: var(--fs-footnote); color: var(--c-ink-2); margin-bottom: 6px; }

input, select, textarea {
  width: 100%; height: var(--size-input);
  border: 1px solid var(--c-line); border-radius: 10px;
  padding: 0 12px; font: inherit; font-size: var(--fs-body);
  color: var(--c-ink-1); background: var(--c-surface); outline: none;
  transition: border-color var(--mo-fast) var(--mo-ease), box-shadow var(--mo-fast) var(--mo-ease);
}
textarea { height: auto; padding: 10px 12px; line-height: 1.6; }
input::placeholder, textarea::placeholder { color: var(--c-ink-4); }
input:focus, select:focus, textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-soft);
}
input:disabled, select:disabled, textarea:disabled { background: var(--c-surface-alt); color: var(--c-ink-4); cursor: not-allowed; }

/* select 自绘箭头（原生箭头各平台不一致） */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%23667085' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}

/* ── 列表行 ───────────────────────────────────────────────────── */
.ds-list { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); overflow: hidden; }
.ds-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 56px;
  font-size: var(--fs-body); color: var(--c-ink-1);
  cursor: pointer; text-align: left; width: 100%;
  background: none; border: 0; font-family: inherit;
  text-decoration: none;
}
.ds-row + .ds-row { border-top: 1px solid var(--c-line-soft); }
.ds-row:active { background: var(--c-surface-alt); }
.ds-row .ds-row-main { flex: 1; min-width: 0; }
.ds-row .ds-row-title { display: block; font-size: var(--fs-body); font-weight: var(--fw-medium); line-height: 1.35; }
.ds-row .ds-row-desc {
  display: block;
  font-size: var(--fs-caption); color: var(--c-ink-3); margin-top: 2px; line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ds-row .ds-chevron { color: #c3c8d0; flex: none; width: 16px; height: 16px; }

/* 图标块：34×34，圆角 10，浅灰底 */
.ds-ico {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-line-soft); color: var(--c-ink-2);
}
.ds-ico svg { width: 18px; height: 18px; display: block; }
.ds-ico.blue { background: var(--c-cat-blue-bg); color: var(--c-cat-blue); }
.ds-ico.warn { background: var(--c-cat-amber-bg); color: var(--c-cat-amber); }
.ds-ico.ok { background: var(--c-cat-green-bg); color: var(--c-cat-green); }
.ds-ico.danger { background: var(--c-danger-bg); color: var(--c-danger-bright); }
/* 分类色：统一用 50 底 / 500 前景，和主色同一明度带，避免「有的淡有的深」 */
.ds-ico.violet { background: var(--c-cat-violet-bg); color: var(--c-cat-violet); }
.ds-ico.teal { background: var(--c-cat-green-bg); color: var(--c-cat-green); }
.ds-ico.sky { background: var(--c-cat-sky-bg); color: var(--c-cat-sky); }

/* ── 入口格（2×2 / 4 宫格） ───────────────────────────────────── */
.ds-grid { display: grid; gap: 10px; margin-bottom: var(--sp-3); }
.ds-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.ds-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.ds-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.ds-tile {
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md);
  box-shadow: var(--sh-card); padding: 12px; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
  transition: background var(--mo-fast) var(--mo-ease);
}
.ds-tile:active { background: var(--c-surface-alt); }
.ds-tile-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ds-tile-top .ds-ico { width: 30px; height: 30px; border-radius: 9px; }
.ds-tile-top .ds-ico svg { width: 17px; height: 17px; }
.ds-tile-title { font-size: 13.5px; font-weight: var(--fw-semibold); line-height: 1.3; white-space: nowrap; }
.ds-tile-desc {
  font-size: 11.5px; color: var(--c-ink-3); line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ds-tile.tint-blue { background: #f5faff; border-color: #dbeafe; }
.ds-tile.tint-warn { background: #fffcf5; border-color: #fdecc8; }

.ds-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--c-primary); color: #fff;
  font-size: 11px; font-weight: var(--fw-semibold);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.ds-badge.gray { background: var(--c-line-soft); color: var(--c-ink-3); }

/* ── 数据块 ───────────────────────────────────────────────────── */
.ds-stat { display: flex; align-items: baseline; gap: 4px; }
.ds-stat-num { font-size: var(--fs-display); font-weight: var(--fw-semibold); letter-spacing: -.8px; line-height: 1.1; }
.ds-stat-unit { font-size: var(--fs-caption); color: var(--c-ink-3); }

/* ── 分区标题 ─────────────────────────────────────────────────── */
.ds-sec {
  display: flex; align-items: center; justify-content: space-between;
  margin: 18px 2px 8px;
}
.ds-sec h2 { margin: 0; font-size: var(--fs-footnote); font-weight: var(--fw-semibold); color: var(--c-ink-2); }
.ds-sec h2 em { font-style: normal; color: var(--c-ink-4); font-weight: var(--fw-regular); margin-left: 4px; }
.ds-sec-action {
  border: 0; background: none; font: inherit; font-size: var(--fs-footnote);
  font-weight: var(--fw-medium); color: var(--c-primary-press); padding: 6px 4px; cursor: pointer;
}

/* ── 内联提示（一个状态只留一条） ─────────────────────────────── */
.ds-notice {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 12px; border-radius: 10px;
  font-size: var(--fs-footnote); line-height: 1.5;
}
.ds-notice svg { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.ds-notice .txt { flex: 1; min-width: 0; }
.ds-notice.warn { background: var(--c-warn-bg); color: var(--c-warn); }
.ds-notice.danger { background: var(--c-danger-bg); color: var(--c-danger); }
.ds-notice.info { background: var(--c-info-bg); color: var(--c-info); }
.ds-notice.ok { background: var(--c-success-bg); color: var(--c-success); }

/* ── 空态 / 骨架 ──────────────────────────────────────────────── */
.empty { text-align: center; color: var(--c-ink-3); padding: 40px 0; font-size: var(--fs-body); }
.ds-empty { text-align: center; padding: 32px 16px; }
.ds-empty .ds-empty-title { font-size: var(--fs-body); font-weight: var(--fw-medium); color: var(--c-ink-1); }
.ds-empty .ds-empty-desc { font-size: var(--fs-footnote); color: var(--c-ink-3); margin-top: 4px; line-height: 1.6; }
.ds-skel { background: linear-gradient(90deg, #f1f3f5 25%, #e9ebef 37%, #f1f3f5 63%); background-size: 400% 100%; animation: ds-shimmer 1.4s ease infinite; border-radius: 6px; }
@keyframes ds-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ── 顶栏 ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--size-topbar);
  display: flex; align-items: center; justify-content: center;
  position: sticky; top: 0; z-index: var(--z-topbar);
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-line);
}
.topbar h1, .topbar .title { margin: 0; font-size: var(--fs-title); font-weight: var(--fw-semibold); letter-spacing: -.1px; }
.topbar-btn {
  position: absolute; right: 4px;
  width: 44px; height: 40px; border: 0; border-radius: 10px; background: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-ink-2); cursor: pointer;
}
.topbar-btn:active { background: var(--c-surface-alt); }
.topbar-btn svg { width: 22px; height: 22px; }
.topbar-btn .dot {
  position: absolute; top: 8px; right: 10px;
  width: 7px; height: 7px; border-radius: 50%; background: #f04438;
  border: 1.5px solid #fff;
}

/* ── 底部导航 ─────────────────────────────────────────────────── */
.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .97);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--c-line);
  position: sticky; bottom: 0; z-index: var(--z-tabbar);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  height: var(--size-tabbar);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10.5px; line-height: 1; color: #8b93a1;
  cursor: pointer; position: relative; user-select: none;
}
.tab-item svg { width: 22px; height: 22px; display: block; }
.tab-item.active { color: var(--c-primary); }
.tab-item:active { opacity: .7; }
.tab-badge {
  position: absolute; top: 5px; left: calc(50% + 4px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-pill); background: #f04438; color: #fff;
  font-size: 10px; font-weight: var(--fw-semibold); line-height: 16px; text-align: center;
  border: 1.5px solid #fff;
}
/* 兼容老的纯文字 tab（其它页面） */
.tabbar > div:not(.tab-item) {
  min-height: var(--size-tabbar);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-footnote); color: var(--c-ink-3); cursor: pointer;
}
.tabbar > div.active:not(.tab-item) { color: var(--c-primary); font-weight: var(--fw-semibold); }

/* ── 链接 ─────────────────────────────────────────────────────── */
.link { color: var(--c-primary-press); font-size: var(--fs-footnote); cursor: pointer; }
/* 独立操作（列表右侧）：给足触控面积 */
.link-btn, .rp {
  min-height: 36px; min-width: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 8px; color: var(--c-primary-press); font-size: var(--fs-footnote); cursor: pointer;
}

/* ── 焦点 / 动效 ──────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

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

/* ── Toast ────────────────────────────────────────────────────── */
.toast-host {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%);
  z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast-host .toast {
  pointer-events: auto; background: rgba(16, 24, 40, .92); color: #fff;
  font-size: var(--fs-body); line-height: 1.6; padding: 10px 16px;
  border-radius: 10px; max-width: 100%; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  transition: opacity var(--mo-base) var(--mo-ease);
}
.toast-host .toast.out { opacity: 0; }
.toast-host .toast-success { background: var(--c-success); }
.toast-host .toast-error { background: var(--c-danger); }
.toast-host .toast-warn { background: var(--c-warn); }

/* ── 服务状态卡（三态） ───────────────────────────────────────── */
.status-card { border-left: 3px solid var(--c-success); }
.status-card.svc-warn { border-left-color: #f79009; }
.status-card.svc-off { border-left-color: var(--c-danger); }

/* ── 消息内的操作跳转 ─────────────────────────────────────────── */
.msg-link {
  color: var(--c-primary-press); font-size: var(--fs-footnote); cursor: pointer;
  margin-left: var(--sp-2); display: inline-flex; align-items: center;
  min-height: 36px; padding: 0 6px;
}
