/* ==========================================================================
   销售大师 · 管理后台 设计系统
   令牌 → 基础元素 → 组件 → 布局 → 响应式
   与 App 端（lib/theme/tokens.dart）同一套品牌色与语义色
   ========================================================================== */

:root {
  /* 品牌 */
  --brand-700: #1d4ed8;
  --brand-600: #2563eb;
  --brand-500: #3b82f6;
  --brand-100: #dbeafe;
  --brand-50: #eff6ff;
  /* 中性 */
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --line: #e2e8f0;
  --line-2: #eef2f7;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  /* 语义 */
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  /* 形状 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sh-1: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --sh-2: 0 8px 24px rgba(15, 23, 42, .08);
  --sh-3: 0 18px 48px rgba(15, 23, 42, .18);
  /* 尺寸 */
  --nav-w: 238px;
  --top-h: 60px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--ink); font-weight: 650; letter-spacing: -.01em; }
a { color: var(--brand-600); text-decoration: none; }
button { font: inherit; }

/* 数字统一等宽，表格里对齐才好看 */
.num, .kpi-v, td.num, .money { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: 6px; }

/* ============================== 登录页 ============================== */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
}
.auth-brand {
  position: relative;
  padding: 56px 56px 48px;
  color: #fff;
  background: radial-gradient(120% 110% at 8% 0%, #3b82f6 0%, #2563eb 42%, #1e3a8a 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.auth-brand::after {
  content: "";
  position: absolute; right: -120px; bottom: -140px;
  width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 68%);
}
.auth-brand::before {
  content: "";
  position: absolute; left: -80px; top: 32%;
  width: 260px; height: 260px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.14);
}
.auth-logo { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; letter-spacing: .02em; }
.auth-logo .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  display: grid; place-items: center;
}
.auth-copy h1 { color: #fff; font-size: 30px; line-height: 1.32; letter-spacing: -.02em; }
.auth-copy p { margin-top: 14px; color: rgba(255,255,255,.78); font-size: 13.5px; max-width: 34em; }
.auth-points { margin-top: 28px; display: grid; gap: 12px; max-width: 380px; }
.auth-point { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: rgba(255,255,255,.9); }
.auth-point i { flex: 0 0 auto; margin-top: 2px; opacity: .9; }
.auth-foot { font-size: 12px; color: rgba(255,255,255,.55); }

.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-form { width: 100%; max-width: 360px; }
.auth-form h2 { font-size: 22px; letter-spacing: -.02em; }
.auth-form .sub { color: var(--ink-3); margin-top: 6px; margin-bottom: 26px; font-size: 13px; }

.pwd-wrap { position: relative; }
.pwd-wrap input { width: 100%; height: 44px; padding-right: 44px; font-size: 14px; }
.pwd-wrap .eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink-4);
  border-radius: 8px; cursor: pointer; display: grid; place-items: center;
}
.pwd-wrap .eye:hover { background: var(--surface-2); color: var(--ink-2); }

.auth-err {
  display: none; align-items: center; gap: 6px;
  margin-top: 10px; font-size: 12.5px; color: var(--danger);
}
.auth-err.on { display: flex; }

.btn-block { width: 100%; height: 44px; font-size: 14px; }

/* ============================== 布局 ============================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  /* 移动端以抽屉打开时必须盖住遮罩（60），否则菜单点不到 */
  z-index: 65;
  transition: transform .22s var(--ease);
}
.side-head {
  height: var(--top-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--line);
}
.side-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .28);
}
.side-title { font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.side-sub { font-size: 11px; color: var(--ink-4); }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.side-group { margin-top: 14px; }
.side-group:first-child { margin-top: 0; }
.side-group-t {
  font-size: 11px; font-weight: 700; color: var(--ink-4);
  letter-spacing: .06em; text-transform: uppercase;
  padding: 0 10px 6px;
}
.nav-item {
  position: relative;
  width: 100%; height: 36px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px; margin-bottom: 2px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--ink-2); font-size: 13px; font-weight: 550; cursor: pointer;
  transition: background .14s, color .14s;
}
.nav-item svg { flex: 0 0 auto; color: var(--ink-4); transition: color .14s; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover svg { color: var(--ink-3); }
.nav-item.on { background: var(--brand-50); color: var(--brand-700); font-weight: 650; }
.nav-item.on svg { color: var(--brand-600); }
.nav-item.on::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-600);
}
.nav-item .grow { flex: 1; text-align: left; }
.nav-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}
.nav-item.on .nav-badge { background: var(--brand-600); }

.side-foot {
  flex: 0 0 auto; border-top: 1px solid var(--line); padding: 10px;
}
.side-user { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 9px; }
.side-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  background: var(--brand-50); color: var(--brand-700);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.side-user .meta { flex: 1; min-width: 0; }
.side-user .n { font-size: 12.5px; font-weight: 650; color: var(--ink); }
.side-user .r { font-size: 11px; color: var(--ink-4); }

.main { flex: 1; min-width: 0; margin-left: var(--nav-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .page-t { font-size: 15px; font-weight: 700; color: var(--ink); }
.topbar .page-d { font-size: 12px; color: var(--ink-4); margin-top: -1px; }
.topbar .spacer { flex: 1; }

.icon-btn {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink-3); cursor: pointer;
  transition: .14s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: #cbd5e1; }
.menu-btn { display: none; }

.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(5,150,105,.12); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(180,83,9,.12); }

.content { padding: 20px 24px 56px; width: 100%; max-width: 1400px; }

/* ============================== 页头 ============================== */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head h2 { font-size: 20px; letter-spacing: -.02em; }
.page-head p { color: var(--ink-3); font-size: 12.5px; margin-top: 4px; max-width: 62em; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex: 0 0 auto; }

/* ============================== 卡片 ============================== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card-h {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line-2);
}
.card-h .t { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.card-h .d { font-size: 12px; color: var(--ink-4); margin-top: 1px; }
.card-h .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-b { padding: 16px; }
.card-b.tight { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }
.section { margin-top: 18px; }
.section-t { display: flex; align-items: baseline; gap: 8px; margin: 0 0 10px; }
.section-t h3 { font-size: 14px; }
.section-t span { font-size: 12px; color: var(--ink-4); }

/* ============================== KPI ============================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.kpi {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px 13px;
  box-shadow: var(--sh-1);
}
.kpi .k { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); font-weight: 550; }
.kpi .k i { color: var(--ink-4); display: inline-flex; }
.kpi-v { font-size: 25px; font-weight: 700; color: var(--ink); letter-spacing: -.025em; margin-top: 6px; line-height: 1.15; }
.kpi-v small { font-size: 13px; font-weight: 600; color: var(--ink-3); margin-left: 2px; }
.kpi .s { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--ink-4); }
.kpi.accent { background: linear-gradient(140deg, #2563eb, #1e40af); border-color: transparent; box-shadow: 0 10px 24px rgba(37,99,235,.22); }
.kpi.accent .k, .kpi.accent .s { color: rgba(255,255,255,.78); }
.kpi.accent .k i { color: rgba(255,255,255,.7); }
.kpi.accent .kpi-v { color: #fff; }
.kpi.accent .kpi-v small { color: rgba(255,255,255,.7); }

.trend-up { color: var(--ok); font-weight: 650; }
.trend-flat { color: var(--ink-4); }

/* ============================== 表格 ============================== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  color: var(--ink-3); font-size: 11.5px; font-weight: 700;
  letter-spacing: .02em; text-align: left;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 11px 14px; border-bottom: 1px solid var(--line-2);
  color: var(--ink-2); vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #fbfdff; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .strong { color: var(--ink); font-weight: 650; }
.tbl .muted { color: var(--ink-4); }
.tbl .ops { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tbl-empty { padding: 34px 16px; text-align: center; color: var(--ink-4); font-size: 12.5px; }

.row-2 { display: flex; align-items: center; gap: 10px; }
.cell-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  background: var(--brand-50); color: var(--brand-700);
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
}
.cell-main { min-width: 0; }
.cell-main .n { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.cell-main .m { font-size: 11.5px; color: var(--ink-4); }

/* ============================== 状态徽标 ============================== */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-3);
}
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.brand { background: var(--brand-50); color: var(--brand-700); }
.chip.plain { background: var(--surface-2); color: var(--ink-3); }
.chip.no-dot::before { display: none; }

/* ============================== 按钮 ============================== */
.btn {
  height: 34px; padding: 0 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .14s, border-color .14s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #cbd5e1; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: 0 2px 6px rgba(37,99,235,.22); }
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }
.btn-soft { background: var(--brand-50); border-color: transparent; color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: var(--danger-bg); border-color: #fca5a5; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-3); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 34px; padding: 0; }

.btn-group { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.btn-group button {
  height: 28px; padding: 0 11px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-3); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn-group button.on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ============================== 表单 ============================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .lbl { font-size: 12px; font-weight: 600; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.field > .lbl .unit { color: var(--ink-4); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--ink-4); line-height: 1.45; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font-size: 13px; font-family: inherit;
  transition: border-color .14s, box-shadow .14s;
  min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
input::placeholder { color: var(--ink-4); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
input[type=number] { font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.toolbar {
  display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}
.toolbar .grow { flex: 1; }
.toolbar-search { position: relative; min-width: 200px; }
.toolbar-search input { width: 100%; padding-left: 32px; }
.toolbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-4); pointer-events: none; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 34px; height: 20px; border-radius: 99px; background: #cbd5e1;
  position: relative; transition: background .16s; flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .16s var(--ease);
}
.switch input:checked + .track { background: var(--brand-600); }
.switch input:checked + .track::after { transform: translateX(14px); }

/* ============================== 图表 ============================== */
.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

.bars { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 62px; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-row .lab { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; background: var(--brand-500); transition: width .4s var(--ease); }
.bar-row .val { text-align: right; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* 漏斗 */
.funnel { display: grid; gap: 8px; }
.funnel-step {
  display: grid; grid-template-columns: 132px 1fr 92px;
  align-items: center; gap: 12px;
  padding: 8px 0;
}
.funnel-step .name { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.funnel-step .name small { display: block; color: var(--ink-4); font-weight: 500; font-size: 11px; }
.funnel-bar { height: 30px; background: var(--line-2); border-radius: 8px; overflow: hidden; position: relative; }
.funnel-bar span {
  display: block; height: 100%; border-radius: 8px;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-600));
  transition: width .5s var(--ease);
}
.funnel-step .fig { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-step .fig b { font-size: 14px; color: var(--ink); }
.funnel-step .fig em { display: block; font-style: normal; font-size: 11px; color: var(--ink-4); }

.meter { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; min-width: 60px; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--brand-500); }
.meter.ok span { background: var(--ok); }
.meter.warn span { background: var(--warn); }
.meter.danger span { background: var(--danger); }

/* ============================== 空 / 骨架 / 加载 ============================== */
.empty { padding: 44px 20px; text-align: center; }
.empty .ico {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px;
  background: var(--surface-2); color: var(--ink-4);
  display: grid; place-items: center;
}
.empty h4 { font-size: 13.5px; margin-bottom: 4px; }
.empty p { font-size: 12.5px; color: var(--ink-4); max-width: 34em; margin: 0 auto 14px; }

.skeleton { background: #eef2f7; border-radius: 6px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-kpi { height: 92px; border-radius: var(--r-md); }
.sk-row { height: 44px; margin-bottom: 8px; border-radius: 8px; }

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

/* ============================== 弹层 ============================== */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.overlay.on { opacity: 1; pointer-events: auto; }

.modal-wrap {
  position: fixed; inset: 0; z-index: 70;
  display: grid; place-items: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.modal-wrap.on { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 460px; max-height: calc(100vh - 40px);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); overflow: hidden;
  display: flex; flex-direction: column;
  transform: translateY(10px) scale(.99); transition: transform .2s var(--ease);
}
.modal-wrap.on .modal { transform: none; }
.modal.wide { max-width: 620px; }
.modal-h { display: flex; align-items: center; gap: 12px; padding: 16px 18px 6px; }
.modal-h h3 { font-size: 15px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 8px 18px 4px; overflow-y: auto; }
.modal-b p.desc { color: var(--ink-3); font-size: 12.5px; margin-bottom: 14px; line-height: 1.6; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 18px; }
.modal-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--brand-50); color: var(--brand-700);
}
.modal-icon.danger { background: var(--danger-bg); color: var(--danger); }

/* 抽屉（移动导航 + 用户详情） */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 70;
  width: min(430px, 92vw); background: var(--surface);
  box-shadow: var(--sh-3);
  transform: translateX(102%); transition: transform .24s var(--ease);
  display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-h { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-b { padding: 16px 18px 24px; overflow-y: auto; flex: 1; }

.sidebar.drawer-nav {
  transform: translateX(-102%);
  box-shadow: var(--sh-3);
}
.sidebar.drawer-nav.on { transform: none; }

/* 信息行 */
.info-list { display: grid; gap: 0; }
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.info-row:last-child { border-bottom: 0; }
.info-row .k { color: var(--ink-4); }
.info-row .v { color: var(--ink); font-weight: 600; text-align: right; }

/* ============================== Toast ============================== */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 90; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 8px;
  min-width: 200px; max-width: 360px;
  padding: 10px 13px; border-radius: 10px;
  background: var(--ink); color: #fff;
  font-size: 12.5px; font-weight: 550;
  box-shadow: var(--sh-2);
  animation: toastIn .2s var(--ease);
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.toast.out { animation: toastOut .2s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* ============================== 工具类 ============================== */
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.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; }
.muted { color: var(--ink-4); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hr { height: 1px; background: var(--line-2); margin: 14px 0; }
.hidden { display: none !important; }
.tag-soft { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--surface-2); color: var(--ink-3); }

/* ============================== 响应式 ============================== */
@media (max-width: 1180px) {
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--sh-3); }
  .sidebar.on { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 48px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel { padding: 32px 20px; align-items: flex-start; padding-top: 12vh; }
}

@media (max-width: 860px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tbody tr {
    border: 1px solid var(--line); border-radius: var(--r-md);
    margin: 0 0 10px; padding: 4px 0; background: var(--surface);
  }
  .tbl tbody td {
    border: 0; padding: 6px 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    text-align: right; font-size: 12.5px;
  }
  .tbl tbody td::before {
    content: attr(data-l);
    flex: 0 0 auto; color: var(--ink-4);
    font-size: 11.5px; font-weight: 600;
  }
  .tbl tbody td:not([data-l])::before { display: none; }
  .tbl tbody td.ops { justify-content: flex-end; padding-top: 8px; }
  .tbl tbody td.ops::before { display: none; }
  .table-wrap { overflow: visible; }
  .card-b.tight .table-wrap { padding: 10px; }
  .page-head { flex-direction: column; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi-v { font-size: 21px; }
  .funnel-step { grid-template-columns: 96px 1fr 74px; gap: 8px; }
  .funnel-step .name small { display: none; }
  .bar-row { grid-template-columns: 78px 1fr 54px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .toolbar { padding: 12px 14px; }
  .content { padding: 14px 14px 48px; }
  .section { margin-top: 14px; }
  .drawer { width: 100%; }
}

@media (max-width: 520px) {
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .kpi .s { display: none; }
  .page-head h2 { font-size: 18px; }
  .topbar .page-d { display: none; }
  .health span.txt { display: none; }
  .card-h { padding: 12px 13px; }
  .card-b { padding: 13px; }
  .modal { max-width: none; }
  .modal-wrap { padding: 12px; }
  .toasts { left: 12px; right: 12px; }
  .toast { max-width: none; }
}

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