/* ============================================================================
   旺旺接码平台 · Design System
   ----------------------------------------------------------------------------
   这一层加载在 styles.css 之后，用来覆盖历史样式，建立统一的设计语言。
   旧文件继续提供结构兜底，本文件负责：token 体系、排版、留白、层级、
   色彩、动效与响应式。

   目录
     01 Token
     02 基础与排版
     03 应用框架
     04 导航
     05 表面与卡片
     06 按钮
     07 表单
     08 表格
     09 提示 / 徽标 / Toast
     10 弹窗与抽屉
     11 页面级
     12 响应式
     13 动效与降级
   ========================================================================= */

/* ==========================================================================
   01 Token
   ========================================================================== */

:root {
  color-scheme: light;

  /* ---- 品牌色阶：azure，带一点青，冷静但不呆板 ---- */
  --brand-50:  #eef4ff;
  --brand-100: #dde8ff;
  --brand-200: #c0d3ff;
  --brand-300: #97b4ff;
  --brand-400: #6a8dff;
  --brand-500: #2f6bff;
  --brand-600: #1f52e6;
  --brand-700: #1a41b8;
  --brand-800: #1a3891;
  --brand-900: #1a3272;
  --brand-ink: #0f2255;

  /* 信号色：仅用于关键强调与品牌渐变 */
  --signal-400: #22d3ee;
  --signal-500: #06b6d4;
  --signal-600: #0891b2;

  /* ---- 中性色阶：偏冷的石板灰，保证长时间阅读不刺眼 ---- */
  --n-0:   #ffffff;
  --n-25:  #fbfcfe;
  --n-50:  #f4f6fb;
  --n-100: #eceff6;
  --n-150: #e6ebf4;
  --n-200: #dde3ee;
  --n-300: #c6cfdd;
  --n-400: #9aa6b8;
  --n-500: #6b7789;
  --n-600: #4d5768;
  --n-700: #363f4e;
  --n-800: #232b38;
  --n-900: #131a26;
  --n-950: #0a0f18;

  /* ---- 语义色 ---- */
  --success-50:  #e8f8f0;
  --success-100: #c9efdc;
  --success-500: #0f9d63;
  --success-600: #0b7d4e;
  --success-700: #0a6440;

  --warn-50:  #fff6e6;
  --warn-100: #ffe8c2;
  --warn-500: #d98207;
  --warn-600: #b96a04;
  --warn-700: #8f5203;

  --danger-50:  #fdeeee;
  --danger-100: #fbd8d6;
  --danger-500: #d92d20;
  --danger-600: #b42318;
  --danger-700: #912018;

  --gold-50:  #fff8e8;
  --gold-100: #ffeec4;
  --gold-500: #d99a25;
  --gold-600: #b87d13;
  --gold-700: #8f6109;

  /* ---- 语义映射（浅色） ---- */
  --bg: var(--n-50);
  --bg-glow: rgba(47, 107, 255, 0.07);
  --panel: var(--n-0);
  --surface: var(--n-0);
  --surface-raised: var(--n-0);
  --surface-sunken: var(--n-100);
  --surface-hover: var(--n-50);
  --surface-glass: rgba(255, 255, 255, 0.82);

  --text: var(--n-900);
  --text-secondary: var(--n-600);
  --muted: #5d6878;
  --text-faint: var(--n-400);
  --text-inverse: var(--n-0);

  --line: var(--n-150);
  --line-strong: var(--n-200);
  --line-faint: var(--n-100);

  --primary: var(--brand-500);
  --primary-dark: var(--brand-600);
  --primary-soft: var(--brand-50);
  --on-primary: #ffffff;

  --success: var(--success-500);
  --warn: var(--warn-500);
  --danger: var(--danger-500);
  --gold: var(--gold-500);

  /* 侧边栏（浅色主题下依旧是深色，作为品牌的锚点） */
  --nav-bg: #0b1220;
  --nav-bg-2: #0e1a2e;
  --nav-text: #aab6ca;
  --nav-text-active: #ffffff;
  --nav-line: rgba(255, 255, 255, 0.07);
  --nav-hover: rgba(255, 255, 255, 0.06);
  --nav-active: rgba(255, 255, 255, 0.10);

  /* ---- 间距刻度：4px 基准 ---- */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ---- 圆角刻度 ---- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-full: 999px;

  /* ---- 阴影：多层叠加 + 品牌色染色，避免灰扑扑 ---- */
  --sh-xs: 0 1px 2px rgba(16, 26, 48, 0.05);
  --sh-sm: 0 1px 2px rgba(16, 26, 48, 0.05), 0 2px 6px rgba(16, 26, 48, 0.04);
  --sh-md: 0 2px 4px rgba(16, 26, 48, 0.04), 0 8px 20px rgba(16, 26, 48, 0.06);
  --sh-lg: 0 4px 8px rgba(16, 26, 48, 0.05), 0 18px 40px rgba(16, 26, 48, 0.09);
  --sh-xl: 0 8px 16px rgba(16, 26, 48, 0.06), 0 32px 72px rgba(16, 26, 48, 0.14);
  --sh-brand: 0 2px 6px rgba(31, 82, 230, 0.22), 0 10px 24px rgba(31, 82, 230, 0.18);
  --sh-brand-lg: 0 4px 10px rgba(31, 82, 230, 0.24), 0 18px 40px rgba(31, 82, 230, 0.22);
  --ring-brand: 0 0 0 3px rgba(47, 107, 255, 0.22);
  --ring-danger: 0 0 0 3px rgba(217, 45, 32, 0.20);
  --ring-success: 0 0 0 3px rgba(15, 157, 99, 0.20);

  /* 兼容旧变量名 */
  --shadow: var(--sh-lg);

  /* ---- 字体 ---- */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC",
    "Source Han Sans SC", "Microsoft YaHei UI", "Microsoft YaHei",
    "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    "SF Mono", "JetBrains Mono", "Cascadia Mono", "Roboto Mono",
    ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;

  /* 字号刻度
     注意：原版 styles.css 的 body 没有设 font-size，所以基准是浏览器默认 16px。
     第一版我把 body 设成 14px、导航设成 13px，整体明显比原来小。
     这里把刻度整体上调，让基准回到 15px、导航回到 15px。 */
  --fs-2xs: 11px;
  --fs-xs:  12px;
  --fs-sm:  13px;
  --fs-base: 14px;
  --fs-md:  15px;
  --fs-lg:  17px;
  --fs-xl:  20px;
  --fs-2xl: 24px;
  --fs-3xl: 29px;
  --fs-4xl: 37px;
  --fs-5xl: 47px;

  --lh-tight: 1.25;
  --lh-snug: 1.4;
  --lh-normal: 1.6;
  --lh-relaxed: 1.75;

  --ls-tight: -0.02em;
  --ls-snug: -0.01em;
  --ls-wide: 0.06em;

  /* ---- 动效 ---- */
  --dur-instant: 90ms;
  --dur-fast: 140ms;
  --dur-base: 220ms;
  --dur-slow: 360ms;
  --dur-slower: 560ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);

  /* ---- 层级 ---- */
  --z-sticky: 20;
  --z-drawer: 60;
  --z-modal: 80;
  --z-toast: 120;

  /* ---- 尺寸 ---- */
  --sidebar-w: 264px;
  --topbar-h: 52px;
  --field-h: 40px;
}

/* ---- 深色主题 ---- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #070b13;
  --bg-glow: rgba(47, 107, 255, 0.13);
  --panel: #0e1524;
  --surface: #0e1524;
  --surface-raised: #141d31;
  --surface-sunken: #0a1120;
  --surface-hover: #172033;
  --surface-glass: rgba(11, 17, 30, 0.78);

  --text: #e9eef8;
  --text-secondary: #a8b4c8;
  --muted: #7d8a9f;
  --text-faint: #5d6a80;
  --text-inverse: #0a0f18;

  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.13);
  --line-faint: rgba(255, 255, 255, 0.05);

  --primary: #5b8cff;
  --primary-dark: #4374ff;
  --primary-soft: rgba(47, 107, 255, 0.14);
  --on-primary: #ffffff;

  --success: #2fbd85;
  --warn: #e0a030;
  --danger: #f0655a;
  --gold: #e0a830;

  --nav-bg: #070d19;
  --nav-bg-2: #0b1527;
  --nav-line: rgba(255, 255, 255, 0.06);

  --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.5);
  --sh-sm: 0 1px 2px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.4);
  --sh-md: 0 2px 4px rgba(0, 0, 0, 0.45), 0 10px 24px rgba(0, 0, 0, 0.5);
  --sh-lg: 0 4px 10px rgba(0, 0, 0, 0.5), 0 22px 48px rgba(0, 0, 0, 0.6);
  --sh-xl: 0 10px 20px rgba(0, 0, 0, 0.55), 0 40px 88px rgba(0, 0, 0, 0.7);
  --sh-brand: 0 2px 8px rgba(47, 107, 255, 0.35), 0 12px 28px rgba(47, 107, 255, 0.28);
  --ring-brand: 0 0 0 3px rgba(91, 140, 255, 0.28);
}

/* ==========================================================================
   02 基础与排版
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 620px at 8% -8%, var(--bg-glow), transparent 62%),
    radial-gradient(900px 520px at 100% 0%, rgba(6, 182, 212, 0.05), transparent 58%);
  background-repeat: no-repeat;
  /* 不要用 background-attachment: fixed —— 它会让整页背景在每次滚动时
     重新绘制（无法走合成器快路径），是长页面滚动卡顿的经典原因。
     改成随内容滚动，视觉差异很小。 */
  background-attachment: scroll;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-slow) var(--ease-out),
              color var(--dur-slow) var(--ease-out);
}

/* 中文界面里数字等宽，表格和金额列不会跳动 */
body,
table,
input,
button,
select,
textarea {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "kern" 1;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 650;
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-tight);
  color: var(--text);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); letter-spacing: var(--ls-snug); }
h4 { font-size: var(--fs-md); }

p { margin: 0; }

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover { color: var(--primary-dark); }

::selection {
  background: rgba(47, 107, 255, 0.22);
  color: var(--text);
}

/* 细腻的滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--n-300) transparent;
}

[data-theme="dark"] * {
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--n-300);
  border: 3px solid transparent;
  border-radius: var(--r-full);
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--n-400);
  background-clip: content-box;
  border: 3px solid transparent;
}

[data-theme="dark"] *::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  background-clip: content-box;
  border: 3px solid transparent;
}

/* 统一可见焦点环，键盘可达性 */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* 小工具类 */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  line-height: 1.4;
}

.eyebrow::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand-500), var(--signal-400));
}

.muted {
  color: var(--muted);
  line-height: var(--lh-relaxed);
}

.error {
  min-height: 20px;
  color: var(--danger);
  font-size: var(--fs-base);
  font-weight: 500;
}

.hidden { display: none !important; }

/* 跳转到主内容（无障碍） */
.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--sp-3);
  z-index: 999;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--sh-lg);
  font-weight: 600;
}

.skip-link:focus {
  left: var(--sp-3);
}

/* ==========================================================================
   03 应用框架
   ========================================================================== */

.app-shell,
.admin-reference {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

.content {
  min-width: 0;
  /* 上边距从 28px 收到 12px：顶栏变薄后，这里再留 28px 会把标题压得太低 */
  padding: var(--sp-3) var(--sp-8) var(--sp-16);
  max-width: 1680px;
  width: 100%;
}

/* 顶部栏：吸附 + 毛玻璃，滚动时始终能看见当前页与操作 */
.agent-topbar,
.client-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  /* 页名回到顶栏左侧后，顶栏重新用 space-between：标题靠左、按钮靠右。 */
  justify-content: space-between;
  gap: var(--sp-5);
  /* 顶栏里的页名隐藏后，这一条只剩右侧几个按钮，
     原来 74px 的高度会留下一大片空白。收紧高度与间距，让页内标题顶上来。 */
  margin: calc(var(--sp-4) * -1) calc(var(--sp-8) * -1) var(--sp-3);
  padding: var(--sp-2) var(--sp-8);
  min-height: var(--topbar-h);
  /* 吸顶元素上不要加 backdrop-filter：它会强制每帧重新模糊背后的内容，
     是已知的性能杀手（原版 styles.css 里 backdrop-filter 是 0 处）。
     这里改用不透明底色，视觉几乎一致但没有任何持续开销。 */
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

/* 页名只保留顶栏那一份，隐藏页内重复的标题（与顶栏 <h2 id="pageTitle"> 文字相同）。
   ⚠️ 三条必须守住的边界：
   1. 选择器限定为 `.tab-page > .page-header:first-child`（tab 页的**第一个**子级页头），
      这是页名所在的那个。**必须加 `:first-child`**：像 usdtRecharge / settings 这类页面里
      还有若干"区块标题"也是 `.page-header`（如充值记录），
      那些是页内信息，隐藏它们会丢内容。
      实测每个 tab 的页名页头都是其第一个子元素，区块标题都在其后。
   2. 只隐藏 <h3> 这个纯文字元素，绝不对 .page-header 容器本身做 display:none
      —— 之前就是这样把「自动封禁设置」按钮一起藏掉的。
   3. 顶栏元素 #pageTitle 必须留在 DOM 里：app.js 第 660 行每次切页都会写它，
      删掉会导致 JS 抛错、切页失效。所以这里是"藏页内那份"，不是"删顶栏那份"。

   命中的页头里如果只剩操作按钮，那一行仍然有内容；
   没有按钮的会变成高度 0 的空行（padding 已是 0、背景透明），不会留下空盒子。 */
.tab-page > .page-header:first-child h3 {
  display: none;
}

/* 页名移到顶栏后，页头这一行只剩操作按钮。用 margin-left:auto 把它们推到右侧，
   与顶栏的按钮成一条竖线。
   刻意不改 justify-content —— settings 那种「说明文字 + 按钮」的页头
   需要保持文字在左、按钮在右，改 justify-content 会把说明也推到右边。 */
.tab-page > .page-header:first-child > button,
.tab-page > .page-header:first-child > a,
.tab-page > .page-header:first-child > .topbar-actions {
  margin-left: auto;
}

.agent-topbar h1,
.agent-topbar h2,
.client-topbar h1,
.client-topbar h2 {
  font-size: var(--fs-xl);
  letter-spacing: var(--ls-tight);
}

.agent-topbar .topbar-actions,
.client-topbar .client-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

/* 页面切换时的内容容器 */
.tab-page {
  /* No transform: fixed project popovers use viewport coordinates. */
  animation: none;
}

/* ==========================================================================
   04 导航
   ========================================================================== */

.sidebar,
.user-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  border-right: 1px solid var(--nav-line);
  background:
    radial-gradient(520px 320px at 50% -10%, rgba(47, 107, 255, 0.24), transparent 70%),
    linear-gradient(180deg, var(--nav-bg-2), var(--nav-bg));
  color: #fff;
  overflow: hidden;
  z-index: var(--z-drawer);
}

.sidebar::-webkit-scrollbar-thumb,
.user-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  background-clip: content-box;
  border: 3px solid transparent;
}

/* 品牌区 */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--nav-line);
  margin-bottom: var(--sp-1);
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  /* 品牌图加载失败时的兜底底色 */
  background: linear-gradient(140deg, var(--brand-500), var(--signal-500));
  color: #fff;
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: var(--ls-tight);
  /* 中性投影：品牌图是红金配色，原来那圈蓝色辉光会打架 */
  box-shadow: 0 6px 16px rgba(8, 15, 33, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* 旺旺品牌图：撑满圆角方块。
   用 border-radius: inherit 而不是父级 overflow:hidden，
   否则会把下面那圈 inset:-3px 的外环一并裁掉。 */
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: center;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  pointer-events: none;
}

.brand strong {
  display: block;
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: var(--ls-snug);
  color: #fff;
}

.brand small {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-sm);
  color: var(--nav-text);
  font-weight: 500;
}

/* 导航容器：内部滚动，品牌与退出按钮始终固定可见 */
.sidebar nav,
.user-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-right: -4px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.sidebar nav::-webkit-scrollbar,
.user-sidebar nav::-webkit-scrollbar {
  width: 6px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
}

.nav-group + .nav-group {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--nav-line);
}

.nav-group-label {
  display: block;
  padding: 0 var(--sp-3) var(--sp-2);
  color: rgba(255, 255, 255, 0.52);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* 导航项 */
.nav-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--sp-3);
  width: 100%;
  min-height: 42px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--nav-text);
  /* 原版导航继承 body 的 16px；第一版被我压到 13px，明显偏小。
     现在回到 15px（刻度里的 --fs-md），264px 侧栏宽度足够，不会挤。 */
  font-size: var(--fs-md);
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  isolation: isolate;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.nav-button .nav-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  opacity: 0.72;
  transition: opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-base) var(--ease-out);
}

/* 增强脚本注入的图标统一尺寸，避免 SVG 撑满容器 */
.sidebar svg,
.user-sidebar svg,
.theme-toggle svg,
.skip-link svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.sidebar .ghost-button svg,
.user-sidebar .ghost-button svg {
  width: 16px;
  height: 16px;
}

.nav-button .nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 悬停：轻微右移 + 提亮 */
.nav-button:hover,
.nav-button:focus-visible {
  background: var(--nav-hover);
  color: var(--nav-text-active);
}

.nav-button:hover .nav-icon {
  opacity: 1;
  transform: translateX(1px);
}

/* 激活：柔和的填充 + 左侧指示条 + 图标染色 */
.nav-button.active {
  background: linear-gradient(90deg, rgba(47, 107, 255, 0.26), rgba(47, 107, 255, 0.08));
  color: var(--nav-text-active);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.nav-button.active .nav-icon {
  opacity: 1;
  color: #7ea6ff;
}

.nav-button.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 0 var(--r-full) var(--r-full) 0;
  background: linear-gradient(180deg, var(--brand-400), var(--signal-400));
  box-shadow: 0 0 14px rgba(90, 160, 255, 0.85);
  transform: translateY(-50%) scaleY(1);
  animation: nav-indicator var(--dur-base) var(--ease-out);
}

/* 未读角标 */
.nav-count {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  background: var(--danger-500);
  color: #fff;
  font-size: var(--fs-2xs);
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  box-shadow: 0 0 0 2px rgba(217, 45, 32, 0.22);
}

/* 侧边栏文字的最终裁决权：深色适配层里 [data-theme] .nav-button 这类规则
   特异度是 (0,2,0)，会盖掉单类的 .nav-button，所以这里用同等特异度重申。 */
.sidebar .nav-button,
.user-sidebar .nav-button {
  color: var(--nav-text);
}

.sidebar .nav-button.active,
.user-sidebar .nav-button.active {
  color: var(--nav-text-active);
}

.sidebar .nav-button:hover,
.user-sidebar .nav-button:hover,
.sidebar .nav-button:focus-visible,
.user-sidebar .nav-button:focus-visible {
  color: var(--nav-text-active);
}

.sidebar .ghost-button,
.user-sidebar .ghost-button {
  color: var(--nav-text);
}

.sidebar .brand small,
.user-sidebar .brand small {
  color: var(--nav-text);
}

.sidebar .brand strong,
.user-sidebar .brand strong {
  color: #ffffff;
}

/* 侧边栏底部操作 */
.sidebar .ghost-button,
.user-sidebar .ghost-button {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 40px;
  margin-top: auto;
  padding: 0 var(--sp-3);
  border: 1px solid var(--nav-line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03);
  color: var(--nav-text);
  font-size: var(--fs-base);
  font-weight: 550;
  text-align: center;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.sidebar .ghost-button:hover,
.user-sidebar .ghost-button:hover {
  background: rgba(217, 45, 32, 0.14);
  border-color: rgba(217, 45, 32, 0.4);
  color: #ffb4ad;
}

/* ==========================================================================
   05 表面与卡片
   ========================================================================== */

/* 基础卡片 */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition:
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

/* 页面级工具条：顶栏、页头、筛选条统一成"轻表面"，不再和内容卡抢重量 */
.page-header,
.filter-bar,
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: none;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
}

/* 页头：标题在左、操作按钮在右，与原版一致。
   ⚠️ 这里曾经有两条规则把 .page-header 的 h3 和"不含 .topbar-actions 的页头"
   整个 display:none 掉。结果「用户取号线路统计」页头里的
   #autoBlockSettingsBtn（自动封禁设置）被连带隐藏 —— 那是真实功能，不是装饰。
   教训：美化层绝对不能对"可能承载功能"的容器做 display:none。 */
.page-header {
  justify-content: space-between;
  gap: var(--sp-2);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  margin-bottom: var(--sp-4);
}

.page-header .topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* 筛选条：做成"控制条"而不是又一张卡片，避免整页都是白盒子 */
.filter-bar {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-3);
  background: var(--surface-sunken);
  border-color: var(--line-faint);
}

.filter-bar + .filter-bar {
  margin-top: calc(var(--sp-3) * -1 + 2px);
}

.filter-bar input,
.filter-bar select {
  min-height: 36px;
  background: var(--surface);
}

.filter-bar button {
  min-height: 36px;
}

/* 筛选条里的标签 */
.filter-label {
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 650;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* 数据卡容器 */
.panel-header,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
  font-weight: 650;
}

/* ---- 仪表盘统计卡 ---- */
.stat-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.stat-item {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 124px;
  padding: var(--sp-5);
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), transparent 42%),
    var(--surface);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition:
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

[data-theme="dark"] .stat-item {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 42%),
    var(--surface);
}

/* 顶部一根细渐变线作为识别色 */
.stat-item::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-500), var(--signal-400));
  opacity: 0.9;
}

.stat-item:nth-child(2)::before { background: linear-gradient(90deg, var(--success-500), #5fd39b); }
.stat-item:nth-child(3)::before { background: linear-gradient(90deg, var(--signal-500), #7dd3fc); }
.stat-item:nth-child(4)::before { background: linear-gradient(90deg, var(--warn-500), #fbbf5c); }
.stat-item:nth-child(5)::before { background: linear-gradient(90deg, var(--gold-500), #f0c860); }

/* 右上角一层极淡的光晕，避免大色块发死 */
.stat-item::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -34px;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 107, 255, 0.10), transparent 68%);
  pointer-events: none;
}

.stat-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
  border-color: var(--line-strong);
}

.stat-item > span,
.stat-item > small {
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stat-item > strong {
  display: block;
  font-size: var(--fs-3xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: var(--ls-tight);
  color: var(--text);
}

.stat-item > small {
  align-self: flex-start;
  margin-top: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: 650;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.stat-item > small:hover { background: var(--brand-100); }

/* ---- 功能入口 ---- */
.quick-entry {
  display: block;
  padding: var(--sp-5);
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--sh-sm);
  margin-bottom: var(--sp-5);
}

.quick-entry h3 {
  margin-bottom: var(--sp-4);
  font-size: var(--fs-md);
  font-weight: 650;
  color: var(--text-secondary);
}

.quick-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
}

.quick-btn {
  min-width: 0;
  min-height: 52px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--sh-xs);
}

.quick-btn:hover {
  background: var(--primary-soft);
  border-color: var(--brand-200);
  color: var(--primary-dark);
  box-shadow: var(--sh-sm);
}

/* ==========================================================================
   06 按钮
   ========================================================================== */

button,
.link-button,
.secondary-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--field-h);
  padding: 0 var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  color: var(--on-primary);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--sh-brand);
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

button:hover:not(:disabled):not(.user-project-preview),
.link-button:hover,
.secondary-button:hover {
  background: linear-gradient(180deg, var(--brand-400), var(--brand-500));
  box-shadow: var(--sh-brand-lg);
  transform: translateY(-1px);
}

button:active:not(:disabled):not(.user-project-preview) {
  transform: translateY(0) scale(0.985);
  box-shadow: var(--sh-brand);
  transition-duration: var(--dur-instant);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

button:disabled:hover {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  box-shadow: none;
  transform: none;
}

/* 保存类按钮禁用态：明确的"不可用"而不是半透明 */
#userSaveBtn:disabled,
#projectSaveBtn:disabled,
#templateSaveBtn:disabled,
#announcementSaveBtn:disabled,
#userSaveBtn:disabled:hover,
#projectSaveBtn:disabled:hover,
#templateSaveBtn:disabled:hover,
#announcementSaveBtn:disabled:hover {
  background: var(--surface-sunken);
  color: var(--text-faint);
  border-color: var(--line);
  opacity: 1;
  box-shadow: none;
}

/* ---- 次级按钮 ---- */
.secondary,
.link-button,
.secondary-button {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--line-strong);
  box-shadow: var(--sh-xs);
}

.secondary:hover,
.link-button:hover,
.secondary-button:hover {
  background: var(--surface-hover);
  border-color: var(--n-300);
  color: var(--text);
  box-shadow: var(--sh-sm);
}

[data-theme="dark"] .secondary:hover,
[data-theme="dark"] .link-button:hover,
[data-theme="dark"] .secondary-button:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

/* ---- 尺寸变体 ---- */
.small,
.compact-button {
  min-height: 32px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-base);
  border-radius: var(--r-sm);
}

.icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: 1;
  box-shadow: none;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: none;
  transform: none;
}

.full-button {
  width: 100%;
  margin-top: var(--sp-3);
}

/* ---- 筛选胶囊 ---- */
.status-filter {
  min-height: 32px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  box-shadow: none;
}

.status-filter:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--n-300);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.status-filter.active {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--sh-brand);
}

.status-filter.active:hover {
  background: linear-gradient(180deg, var(--brand-400), var(--brand-500));
  color: #fff;
}

/* ---- 项目选择块 ---- */
.project-select-btn {
  width: 100%;
  min-height: 52px;
  justify-content: space-between;
  text-align: left;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--sh-xs);
}

.project-select-btn:hover {
  background: var(--surface-hover);
  border-color: var(--brand-300);
  box-shadow: var(--sh-sm);
}

/* ---- 分段控件（API 语言切换、范围切换等） ----
   用"滑块"语言而不是"填色"语言：两种主题下都不存在对比度问题，也更耐看。 */
.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}

.segmented-control button {
  min-height: 30px;
  padding: 0 var(--sp-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  box-shadow: none;
}

.segmented-control button:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.segmented-control button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--sh-xs);
}

[data-theme="dark"] .segmented-control {
  background: var(--surface-sunken);
}

[data-theme="dark"] .segmented-control button.active {
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--sh-sm);
}

/* ---- 分页 ----
   由 app.js 动态渲染，旧样式是白色小方块 + 蓝色填充，和新的控件语言不搭。
   这里统一成"文字按钮"：默认无底色，悬停淡底，当前页才是实心品牌色。 */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  min-height: 48px;
  padding: var(--sp-3) 0 var(--sp-1);
}

.pagination-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.pagination-info,
.pagination-jump {
  color: var(--muted);
  font-size: var(--fs-base);
  white-space: nowrap;
}

.pagination-current {
  color: var(--text);
  font-size: var(--fs-base);
  font-weight: 650;
  white-space: nowrap;
}

.pagination-size-select {
  width: auto;
  min-width: 96px;
  min-height: 34px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-base);
}

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.pagination-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  box-shadow: none;
}

.pagination-button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.pagination-button.active,
.pagination-button.active:hover {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: transparent;
  color: #ffffff;
  box-shadow: var(--sh-sm);
}

.pagination-button:disabled {
  background: transparent;
  opacity: 0.35;
  cursor: not-allowed;
}

.pagination-ellipsis {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 34px;
  color: var(--text-faint);
  font-size: var(--fs-base);
}

.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: var(--sp-1);
}

.pagination-jump input {
  width: 56px;
  min-width: 56px;
  min-height: 34px;
  padding: 0 var(--sp-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.pagination-jump-button {
  min-width: 48px;
  min-height: 34px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  box-shadow: var(--sh-xs);
}

.pagination-jump-button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--n-300);
  color: var(--text);
  transform: none;
  box-shadow: var(--sh-sm);
}

.pagination-inline {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--surface-sunken);
}

/* ---- 危险操作 ---- */
button.danger,
.danger-button,
button[data-danger="true"] {
  background: linear-gradient(180deg, var(--danger-500), var(--danger-600));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 6px rgba(217, 45, 32, 0.24), 0 10px 24px rgba(217, 45, 32, 0.18);
}

button.danger:hover,
.danger-button:hover,
button[data-danger="true"]:hover {
  background: linear-gradient(180deg, #e5544a, var(--danger-500));
}

/* ==========================================================================
   07 表单
   ========================================================================== */

input,
select,
textarea {
  width: 100%;
  min-height: var(--field-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-md);
  line-height: 1.5;
  box-shadow: var(--sh-xs);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

textarea {
  min-height: 120px;
  padding: var(--sp-3);
  line-height: var(--lh-normal);
  resize: vertical;
}

select[multiple] {
  min-height: 112px;
  padding: var(--sp-2);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) {
  border-color: var(--n-300);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: var(--ring-brand);
  background: var(--surface);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-sunken);
  color: var(--text-faint);
  cursor: not-allowed;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-sunken);
  border-color: var(--line-strong);
}

[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"] {
  background: var(--surface);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  accent-color: var(--brand-500);
  cursor: pointer;
}

/* 文件选择控件：原生按钮在深色界面里是一块刺眼的白，浅色下也是系统灰按钮，
   两种主题都跟设计语言不搭。::file-selector-button 可以完全接管它。 */
input[type="file"] {
  padding: var(--sp-1) var(--sp-2);
  line-height: 1.6;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

input[type="file"]::file-selector-button {
  appearance: none;
  -webkit-appearance: none;
  margin-right: var(--sp-2);
  padding: 0 var(--sp-2);
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

input[type="file"]::file-selector-button:hover {
  background: var(--surface-hover);
  border-color: var(--n-300);
  color: var(--text);
}

[data-theme="dark"] input[type="file"]::file-selector-button {
  background: var(--surface-raised);
  color: var(--text-secondary);
  border-color: var(--line-strong);
}

[data-theme="dark"] input[type="file"]::file-selector-button:hover {
  background: var(--surface-hover);
  color: var(--text);
}

label {
  display: block;
  min-width: 0;
}

label > span {
  display: block;
  margin-bottom: var(--sp-2);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.form {
  display: grid;
  gap: var(--sp-5);
}

/* 表单网格：旧样式用了大量固定列，这里统一节奏 */
form {
  gap: var(--sp-4);
}

/* 复选/单选组 */
.project-check-list,
.manager-template-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--sp-2);
  max-height: 340px;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  overflow: auto;
}

.manager-template-select {
  display: block;
  max-height: none;
  overflow: visible;
}

.project-check-list label,
.manager-template-select label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-base);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.project-check-list label:hover,
.manager-template-select label:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.project-check-list label > span,
.manager-template-select label > span {
  margin: 0;
  font-weight: 500;
}

/* 开关 */
.phone-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
}

.phone-filter-switch {
  position: relative;
  width: 40px;
  height: 23px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--n-200);
  transition: background-color var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.phone-filter-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
  transition: transform var(--dur-base) var(--ease-spring);
}

.phone-filter-toggle input:checked + .phone-filter-switch {
  background: linear-gradient(180deg, var(--brand-400), var(--brand-500));
  border-color: transparent;
}

.phone-filter-toggle input:checked + .phone-filter-switch::after {
  transform: translateX(17px);
}

.phone-filter-toggle input:focus-visible + .phone-filter-switch {
  box-shadow: var(--ring-brand);
}

/* ==========================================================================
   08 表格
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--r-lg);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-base);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--sp-3);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--line-strong);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  white-space: nowrap;
}

tbody td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--line-faint);
  color: var(--text);
  vertical-align: middle;
  line-height: 1.5;
}

/* 标识型列（订单号 / 用户名 / 手机号…）由 enhance.js 打标，禁止折行。
   "#120" 被折成 "#12 / 0" 是会读错的。 */
th.is-nowrap,
td.is-nowrap {
  white-space: nowrap;
}

/* 列数很多的密集表格（≥10 列）自动降一档字号与内边距。
   这类表如果按常规密度排，一定会宽出容器，逼用户横向滚动才能看到操作列。 */
table:has(thead tr th:nth-child(10)) {
  font-size: var(--fs-sm);
}

table:has(thead tr th:nth-child(10)) th,
table:has(thead tr th:nth-child(10)) td {
  padding: var(--sp-2) var(--sp-3);
}

table:has(thead tr th:nth-child(10)) .status,
table:has(thead tr th:nth-child(10)) .record-amount-badge {
  min-height: 20px;
  font-size: var(--fs-2xs);
}

tbody tr {
  transition: background-color var(--dur-fast) var(--ease-out);
}

tbody tr:hover {
  background: var(--surface-hover);
}

tbody tr:last-child td {
  border-bottom: 0;
}

/* 数字与金额仍保留等宽数字，但与表头统一左对齐。 */
td.num,
th.num,
td[data-type="number"] {
  text-align: left;
  font-variant-numeric: tabular-nums;
}

/* 表格空状态 */
tbody td[colspan] {
  color: var(--muted);
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
}

/* 排序表头 */
th[data-sort],
th.sortable {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover,
th.sortable:hover {
  color: var(--text);
  background: var(--n-100);
}

[data-theme="dark"] thead th {
  background: rgba(255, 255, 255, 0.035);
}

[data-theme="dark"] th[data-sort]:hover,
[data-theme="dark"] th.sortable:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ==========================================================================
   09 提示 / 徽标 / Toast
   ========================================================================== */

/* 中性提示条：公告、说明 */
.notice-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
  margin-bottom: var(--sp-4);
}

.notice-bar strong {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.notice-bar strong::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--n-400);
}

.notice-bar > span {
  flex: 1 1 auto;
  min-width: 240px;
}

/* 系统公告 */
.notice-bar.system-announcement-bar {
  background: linear-gradient(90deg, var(--primary-soft), transparent 72%), var(--surface);
  border-color: var(--brand-200);
  color: var(--brand-800);
}

[data-theme="dark"] .notice-bar.system-announcement-bar {
  background: linear-gradient(90deg, rgba(47, 107, 255, 0.16), transparent 72%), var(--surface);
  border-color: rgba(47, 107, 255, 0.32);
  color: #b9cdff;
}

.notice-bar.system-announcement-bar strong { color: var(--primary-dark); }
.notice-bar.system-announcement-bar strong::before { background: var(--brand-500); }
[data-theme="dark"] .notice-bar.system-announcement-bar strong { color: #cddcff; }

/* 演示账号 */
.notice-bar.demo-account-notice {
  background: linear-gradient(90deg, var(--warn-50), transparent 72%), var(--surface);
  border-color: var(--warn-100);
  color: var(--warn-700);
}

.notice-bar.demo-account-notice strong { color: var(--warn-700); }
.notice-bar.demo-account-notice strong::before { background: var(--warn-500); }

[data-theme="dark"] .notice-bar.demo-account-notice {
  background: linear-gradient(90deg, rgba(217, 130, 7, 0.16), transparent 72%), var(--surface);
  border-color: rgba(217, 130, 7, 0.34);
  color: #f0c169;
}

[data-theme="dark"] .notice-bar.demo-account-notice strong { color: #f5cf85; }

/* 需要处理：上游鉴权告警 */
.notice-bar.qqzc-auth-alert {
  background: linear-gradient(90deg, var(--danger-50), transparent 72%), var(--surface);
  border-color: var(--danger-100);
  color: var(--danger-700);
}

.notice-bar.qqzc-auth-alert strong { color: var(--danger-700); }
.notice-bar.qqzc-auth-alert strong::before {
  background: var(--danger-500);
  animation: pulse-dot 2s var(--ease-in-out) infinite;
}

[data-theme="dark"] .notice-bar.qqzc-auth-alert {
  background: linear-gradient(90deg, rgba(217, 45, 32, 0.16), transparent 72%), var(--surface);
  border-color: rgba(217, 45, 32, 0.34);
  color: #f5a49c;
}

[data-theme="dark"] .notice-bar.qqzc-auth-alert strong { color: #ffbdb6; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  right: var(--sp-6);
  bottom: var(--sp-6);
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: min(400px, calc(100vw - 32px));
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(13, 20, 33, 0.97);
  color: #f2f5fb;
  font-size: var(--fs-base);
  font-weight: 550;
  line-height: var(--lh-snug);
  box-shadow: var(--sh-xl);
  animation: toast-in var(--dur-slow) var(--ease-spring) both;
}

.toast::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal-400);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.18);
}

/* ==========================================================================
   10 弹窗与抽屉
   ========================================================================== */

.modal-backdrop,
.template-users-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  /* 去掉全屏 backdrop-filter：它要每帧重新模糊整个视口背后的内容，
     而这个元素还带入场动画。改用略深的半透明底色达到同样的"压暗"效果。 */
  background: rgba(9, 14, 26, 0.62);
  animation: backdrop-in var(--dur-base) var(--ease-out) both;
}

.template-users-drawer-backdrop {
  z-index: var(--z-drawer);
  display: flex;
  justify-content: flex-end;
  padding: 0;
  animation: backdrop-in var(--dur-base) var(--ease-out) both;
}

/* 弹窗本体：旧样式用 .modal / .modal-panel / 裸 section 三种写法，统一处理 */
.modal-backdrop > section,
.modal-backdrop > div,
.modal-backdrop > form,
.modal,
.modal-panel {
  position: relative;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--sp-6);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  background: var(--surface);
  box-shadow: var(--sh-xl);
  animation: modal-in var(--dur-slow) var(--ease-spring) both;
}

/* 宽度只做"兜底默认值"。
   每个弹窗都有自己的宽度（agent-profit 1240px、batch-user 880px、
   conversation 760px、phone-filter 720px…），这里必须用 :where() 把特异度降到 0，
   否则一条通配规则会把它们全部压成同一个宽度。 */
:where(.modal-backdrop > section, .modal-backdrop > div, .modal-backdrop > form, .modal, .modal-panel) {
  width: min(560px, calc(100vw - 32px));
}

/* 表单网格里的 label 统一底对齐：
   标签换行时输入框不会被顶下去，一行里的控件基线保持一致。 */
.grid-form > label,
.compact-form > label,
.hidden-balance-form-grid > label {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}

/* 抽屉 */
.template-users-drawer-backdrop > section,
.template-users-drawer-backdrop > div {
  width: min(520px, 100vw);
  height: 100%;
  max-height: 100%;
  overflow: auto;
  padding: var(--sp-6);
  border-radius: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--sh-xl);
  animation: drawer-in var(--dur-slow) var(--ease-out) both;
}

/* 弹窗标题行 */
.modal h3,
.modal h2,
.modal-backdrop h3,
.template-users-drawer-backdrop h3 {
  margin-bottom: var(--sp-5);
  font-size: var(--fs-lg);
  font-weight: 650;
  letter-spacing: var(--ls-snug);
}

.modal-backdrop h3 + p,
.modal-backdrop .muted {
  margin-bottom: var(--sp-4);
}

/* 弹窗底部操作区 */
.modal-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}

/* ==========================================================================
   11 登录页
   ========================================================================== */

.login-shell,
.client-login {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  overflow: hidden;
}

/* 登录页背景：极淡的网格 + 两团品牌光晕 */
.login-shell::before,
.client-login::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(16, 26, 48, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 26, 48, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(1000px 620px at 50% 42%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(1000px 620px at 50% 42%, #000 0%, transparent 78%);
  pointer-events: none;
}

[data-theme="dark"] .login-shell::before,
[data-theme="dark"] .client-login::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
}

.login-panel,
.client-login-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.06fr 0.94fr;
  align-items: stretch;
  gap: 0;
  width: min(940px, 100%);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  background: var(--surface);
  box-shadow: var(--sh-xl);
  animation: rise-in var(--dur-slower) var(--ease-out) both;
}

.client-login-card {
  width: min(860px, 100%);
}

/* 品牌栏 */
.login-panel > div:first-child,
.client-login-card > div:first-child {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-12) var(--sp-10);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 88% 8%, rgba(34, 211, 238, 0.30), transparent 58%),
    radial-gradient(90% 80% at 4% 96%, rgba(47, 107, 255, 0.42), transparent 62%),
    linear-gradient(150deg, #08101f 0%, #102449 46%, #0a2f4d 100%);
  color: #fff;
}

/* 品牌栏内的极淡网格，增加材质感 */
.login-panel > div:first-child > .login-grid,
.client-login-card > div:first-child > .client-login-grid {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(160deg, #000, transparent 72%);
  -webkit-mask-image: linear-gradient(160deg, #000, transparent 72%);
  pointer-events: none;
}

/* 装饰：同心信号环 */
.login-panel > div:first-child::before,
.client-login-card > div:first-child::before {
  content: "";
  position: absolute;
  right: -128px;
  bottom: -148px;
  width: 396px;
  height: 396px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 0 0 36px rgba(255, 255, 255, 0.05),
    0 0 0 72px rgba(255, 255, 255, 0.032),
    0 0 0 108px rgba(255, 255, 255, 0.02);
  animation: signal-ring 8s var(--ease-in-out) infinite;
  pointer-events: none;
}

.login-panel > div:first-child::after,
.client-login-card > div:first-child::after {
  content: "";
  position: absolute;
  left: -70px;
  top: -90px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 107, 255, 0.55), transparent 66%);
  filter: blur(10px);
  pointer-events: none;
}

.login-panel > div:first-child > *,
.client-login-card > div:first-child > * {
  position: relative;
  z-index: 1;
}

.login-panel .eyebrow,
.client-login-card .eyebrow {
  color: #8ab4ff;
}

.login-panel .eyebrow::before,
.client-login-card .eyebrow::before {
  background: linear-gradient(90deg, #8ab4ff, var(--signal-400));
}

.login-panel h1,
.client-login-card h1 {
  font-size: var(--fs-4xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: #fff;
}

/* 品牌栏文案 */
.login-tagline,
.client-login-tagline {
  max-width: 34ch;
  color: rgba(255, 255, 255, 0.66);
  font-size: var(--fs-md);
  line-height: var(--lh-relaxed);
}

.login-highlights,
.client-login-highlights {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: var(--sp-2) 0 0;
  padding: 0;
  list-style: none;
}

.login-highlights li,
.client-login-highlights li {
  position: relative;
  padding-left: var(--sp-6);
  color: rgba(255, 255, 255, 0.82);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
}

.login-highlights li::before,
.client-login-highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(138, 180, 255, 0.5);
  background:
    radial-gradient(circle at center, #7ea6ff 0 2px, transparent 2px);
}

/* 表单栏 */
.login-panel > form,
.client-login-card > form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-5);
  padding: var(--sp-12) var(--sp-10) var(--sp-12);
}

/* 表单栏标题，补上右栏缺失的层级起点 */
.login-form-head {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-1);
}

.login-form-head h2 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: var(--ls-tight);
  color: var(--text);
}

.login-form-head p {
  color: var(--muted);
  font-size: var(--fs-base);
  line-height: var(--lh-snug);
}

.login-panel > form input,
.client-login-card > form input {
  min-height: 46px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-md);
}

.login-panel > form button[type="submit"],
.client-login-card > form button[type="submit"] {
  width: 100%;
  min-height: 48px;
  margin-top: var(--sp-2);
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: 0.01em;
}

.login-panel .error,
.client-login-card .error {
  text-align: left;
}

/* ==========================================================================
   12 用户端框架与页面级
   ========================================================================== */

.user-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  background: transparent;
}

.user-content {
  min-width: 0;
  padding: var(--sp-7) var(--sp-8) var(--sp-16);
  max-width: 1680px;
  width: 100%;
}

.user-workbench {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}

/* 紧凑筛选条：把"次数 / 检测项目 / 充值"排成一条可扫读的工具行 */
.compact-filter-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-6);
  padding: var(--sp-3) var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-xs);
}

.compact-filter-bar > label,
.compact-filter-bar > label:not(.phone-filter-toggle) {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
}

.compact-filter-bar > label > span {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-base);
  font-weight: 600;
  white-space: nowrap;
}

.compact-filter-bar select {
  max-width: 200px;
  min-height: 34px;
}

/* 筛选次数：把数字做成唯一的重音，去掉输入框外观 */
.compact-filter-bar .phone-filter-wallet {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.compact-filter-bar .phone-filter-wallet > div {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
}

.compact-filter-bar .phone-filter-wallet span {
  color: var(--muted);
  font-size: var(--fs-base);
  font-weight: 600;
}

.compact-filter-bar .phone-filter-wallet strong {
  display: inline-block;
  color: var(--primary);
  font-size: var(--fs-lg);
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

/* 注：这里原本有一条 `.compact-filter-bar .phone-filter-preview-note { display:none }`，
   把原版元素「每次成功筛选扣 1 次」这句话隐藏了。美化层不该隐藏原版信息，已删除。 */

/* ---- 用户端卡片（与 .panel 同规格） ---- */
.client-card {
  position: relative;
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--sh-sm);
  transition:
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.client-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.client-card-head h2 {
  margin-top: var(--sp-1);
  font-size: var(--fs-xl);
  font-weight: 650;
  letter-spacing: var(--ls-tight);
}

.client-label {
  display: block;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* 取号监控空态 */
.monitor-empty {
  display: grid;
  place-items: center;
  gap: var(--sp-2);
  min-height: 220px;
  padding: var(--sp-8);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: var(--fs-base);
  text-align: center;
}

.audio-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 30px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.audio-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--n-300);
}

.audio-toggle input {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--brand-500);
}

/* USDT */
.usdt-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(440px, 1.18fr);
  gap: var(--sp-5);
  align-items: start;
}

/* API 文档页 */
.openapi-page > .page-header {
  margin-bottom: var(--sp-4);
}

.openapi-reference-block {
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
}

.openapi-reference-block h4 {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-md);
  font-weight: 650;
}

/* 代码块：遗留样式给 .openapi-endpoint-list pre 设了浅底，
   必须用同等特异度覆盖，否则会出现浅字浅底。 */
pre,
code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

code {
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  color: var(--brand-700);
  word-break: break-all;
}

[data-theme="dark"] code {
  color: #a8c4ff;
  background: rgba(255, 255, 255, 0.05);
}

pre,
.openapi-endpoint-list pre,
.openapi-endpoint-list details > pre,
.openapi-reference-block pre {
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: #0c1320;
  color: #dbe6f7;
  overflow-x: auto;
  line-height: 1.65;
}

pre code,
.openapi-endpoint-list pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

/* 表格编辑器 / 模板编辑器 */
.template-editor {
  margin-top: var(--sp-5);
}

.auto-block-settings-rows {
  display: grid;
  gap: var(--sp-3);
  max-height: 60vh;
  overflow-y: auto;
}

.auto-block-rule {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
  padding: var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
}

.auto-block-rule strong { min-width: 130px; }
.auto-block-rule label { display: inline-flex; gap: var(--sp-2); align-items: center; }

/* 项目申请会话气泡 */
.project-request-message.is-mine {
  align-self: flex-end;
  border-color: var(--brand-200);
  background: var(--primary-soft);
}

.project-request-message.is-other {
  align-self: flex-start;
  border-color: var(--success-100);
  background: var(--success-50);
}

[data-theme="dark"] .project-request-message.is-mine {
  border-color: rgba(47, 107, 255, 0.3);
  background: rgba(47, 107, 255, 0.14);
}

[data-theme="dark"] .project-request-message.is-other {
  border-color: rgba(15, 157, 99, 0.3);
  background: rgba(15, 157, 99, 0.12);
}

/* 主题切换按钮 */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--sh-xs);
}

.theme-toggle:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--n-300);
  transform: none;
  box-shadow: var(--sh-sm);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

/* ==========================================================================
   13 响应式
   ========================================================================== */

/* 中等屏：收窄侧边栏与内边距 */
@media (max-width: 1280px) {
  :root {
    --sidebar-w: 232px;
  }

  .content,
  .user-content {
    padding: var(--sp-6) var(--sp-6) var(--sp-12);
  }

  .agent-topbar,
  .client-topbar {
    margin: calc(var(--sp-6) * -1) calc(var(--sp-6) * -1) var(--sp-5);
    padding: var(--sp-4) var(--sp-6);
  }

  .user-workbench {
    grid-template-columns: 330px minmax(0, 1fr);
  }
}

/* 平板：侧边栏折叠为顶部横条 */
/* 中等屏：内容区先塌陷，但侧栏仍是左侧竖向（原版形态），
   一直到 768px 才改成顶部横排。 */
@media (max-width: 1024px) {
  .content,
  .user-content {
    padding: var(--sp-5) var(--sp-5) var(--sp-12);
  }

  .user-workbench,
  .usdt-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-section {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

/* 窄屏／手机：侧栏改为顶部两行（品牌+退出 / 横向可滚动的导航）。
   原版在窄屏是把 14 个按钮竖向堆叠成约 846px 的"导航墙"，
   手机上要滑过整屏才看得到内容。 */
@media (max-width: 768px) {
  .app-shell,
  .admin-reference,
  .user-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  .user-sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-3);
    padding: var(--sp-3);
    border-right: 0;
    border-bottom: 1px solid var(--nav-line);
    overflow: visible;
    z-index: var(--z-drawer);
  }

  /* 第一行：品牌 + 退出；第二行：横向滚动的导航 */
  .sidebar .brand,
  .user-sidebar .brand {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    border-bottom: 0;
    margin-bottom: 0;
  }

  .brand strong,
  .brand small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar nav,
  .user-sidebar nav {
    order: 3;
    flex: 1 1 100%;
    flex-direction: row;
    gap: var(--sp-2);
    overflow-x: auto;
    overflow-y: hidden;
    padding-right: 0;
    margin-right: 0;
    padding-bottom: var(--sp-1);
    scrollbar-width: none;
  }

  .sidebar nav::-webkit-scrollbar,
  .user-sidebar nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    width: auto;
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 var(--sp-3);
    white-space: nowrap;
  }

  .nav-button.active::before {
    left: 50%;
    top: auto;
    bottom: 0;
    width: 18px;
    height: 2px;
    border-radius: var(--r-full) var(--r-full) 0 0;
    transform: translateX(-50%);
  }

  .sidebar .ghost-button,
  .user-sidebar .ghost-button {
    order: 2;
    flex: 0 0 auto;
    width: auto;
    min-height: 34px;
    margin: 0;
    padding: 0 var(--sp-3);
    align-self: center;
  }

  .agent-topbar,
  .client-topbar {
    position: static;
    margin: 0 0 var(--sp-5);
    padding: var(--sp-4) 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: 1px solid var(--line);
  }
}

/* 手机 */
@media (max-width: 720px) {
  body {
    font-size: var(--fs-base);
  }

  .content,
  .user-content {
    padding: var(--sp-4) var(--sp-4) var(--sp-16);
  }

  .login-shell,
  .client-login {
    padding: var(--sp-4);
    place-items: start center;
    padding-top: var(--sp-6);
  }

  .login-panel,
  .client-login-card {
    grid-template-columns: minmax(0, 1fr);
    border-radius: var(--r-xl);
  }

  .login-panel > div:first-child,
  .client-login-card > div:first-child {
    padding: var(--sp-8) var(--sp-6) var(--sp-7);
    gap: var(--sp-3);
  }

  .login-panel h1,
  .client-login-card h1 {
    font-size: var(--fs-3xl);
  }

  .login-highlights,
  .client-login-highlights {
    display: none;
  }

  .login-panel > form,
  .client-login-card > form {
    padding: var(--sp-7) var(--sp-6) var(--sp-8);
  }

  .agent-topbar,
  .client-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-3);
  }

  .agent-topbar .topbar-actions,
  .client-topbar .client-actions {
    width: 100%;
  }

  .stat-section {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-3);
  }

  .stat-item {
    min-height: 104px;
    padding: var(--sp-4);
  }

  .stat-item > strong {
    font-size: var(--fs-2xl);
  }

  .page-header,
  .filter-bar,
  .notice-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header .topbar-actions {
    width: 100%;
  }

  .page-header .topbar-actions > button {
    flex: 1 1 auto;
  }

  button,
  .link-button {
    min-height: 42px;
  }

  .modal-backdrop {
    padding: 0;
    place-items: end center;
  }

  .modal-backdrop > section,
  .modal-backdrop > div,
  .modal-backdrop > form,
  .modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    padding: var(--sp-5);
    animation: sheet-in var(--dur-slow) var(--ease-out) both;
  }

  .template-users-drawer-backdrop > section,
  .template-users-drawer-backdrop > div {
    width: 100vw;
  }

  .toast {
    left: var(--sp-4);
    right: var(--sp-4);
    bottom: var(--sp-4);
    max-width: none;
  }

  table {
    font-size: var(--fs-sm);
  }

  thead th,
  tbody td {
    padding: var(--sp-2) var(--sp-3);
  }

  /* 移动端表格允许横向滑动，不挤压内容 */
  .table-wrap,
  .panel > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* 超窄屏 */
@media (max-width: 420px) {
  .quick-buttons,
  .stat-section {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 触屏设备去掉 hover 位移，避免"粘住" */
@media (hover: none) {
  .stat-item:hover,
  button:hover:not(:disabled):not(.user-project-preview),
  .link-button:hover {
    transform: none;
  }
}

/* ==========================================================================
   14 动效与降级
   ========================================================================== */

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes drawer-in {
  from { opacity: 0.4; transform: translateX(36px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes nav-indicator {
  from { transform: translateY(-50%) scaleY(0.2); opacity: 0; }
  to   { transform: translateY(-50%) scaleY(1); opacity: 1; }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(217, 45, 32, 0.42); }
  50%      { opacity: 0.75; box-shadow: 0 0 0 5px rgba(217, 45, 32, 0); }
}

@keyframes signal-ring {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50%      { transform: scale(1.05); opacity: 0.62; }
}

/* 数字滚动：由 enhance.js 打标后触发 */
.stat-item > strong.is-counting {
  animation: count-pop var(--dur-slow) var(--ease-out);
}

@keyframes count-pop {
  0%   { opacity: 0.2; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* 表格行入场 */
tbody tr.row-enter {
  animation: row-in var(--dur-base) var(--ease-out) both;
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-4);
  color: var(--muted);
  text-align: center;
}

.empty-state::before {
  content: "";
  width: 44px;
  height: 44px;
  margin-bottom: var(--sp-2);
  border-radius: var(--r-lg);
  border: 1px dashed var(--line-strong);
  background:
    radial-gradient(circle at 50% 40%, var(--n-300) 0 3px, transparent 3px),
    linear-gradient(180deg, transparent 58%, var(--n-150) 58% 62%, transparent 62%);
}

.empty-state strong {
  color: var(--text-secondary);
  font-size: var(--fs-md);
  font-weight: 600;
}

/* 尊重系统降级设置 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* 打印：去掉装饰，保留信息 */
@media print {
  .sidebar,
  .user-sidebar,
  .agent-topbar,
  .client-topbar,
  .toast,
  .theme-toggle {
    display: none !important;
  }

  .app-shell,
  .user-app {
    grid-template-columns: minmax(0, 1fr);
  }

  body {
    background: #fff;
    background-image: none;
  }

  .panel,
  .stat-item {
    box-shadow: none;
    border-color: #ccc;
  }
}

/* ==========================================================================
   15 历史遗留问题修补
   ----------------------------------------------------------------------------
   审计发现的几处具体缺陷，单独集中在这里，便于日后回溯。
   ========================================================================== */

/* 宽表缺少滚动容器 → 曾导致整页横向滚动 */
.phone-check-history-card,
.agent-profit-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 排序按钮命中区过小（原 14×18px），且文字对比度不足 */
#reportHead button.report-sort-button {
  flex: 0 0 auto;
  width: 22px;
  min-width: 22px;
  height: 22px;
  min-height: 22px;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  box-shadow: none;
  transition: background-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

#reportHead button.report-sort-button:hover {
  background: var(--surface-sunken);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

/* 对比度不足的辅助文字（原 #94a3b8 仅 2.4:1） */
.auto-block-rule-project small {
  color: var(--muted);
}

/* 状态徽标：遗留的绿色 #0f9d63 落在 #dcfce7 上只有 3.2:1 */
.status {
  min-height: 24px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--success-700);
}

/* 所有小徽标都不该被折行 */
.record-amount-badge,
.nav-count,
.manager-template-option,
.http-method {
  white-space: nowrap;
}

.record-amount-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

[data-theme="dark"] .status {
  color: #74dfae;
}

/* 统计卡上的"查看明细"胶囊 */
.stat-item > small {
  color: var(--brand-700);
}

/* 内容区在浅色下带一条很淡的渐变（遗留样式），
   深色下它会在内容高度处切出一条色块边界，所以直接让画布透上来。 */
[data-theme="dark"] .admin-reference .content,
[data-theme="dark"] .admin-reference > .content,
[data-theme="dark"] .user-content {
  background: transparent;
  background-image: none;
}

[data-theme="dark"] .stat-item > small {
  color: #a8c4ff;
}

.stat-item > small:hover {
  color: var(--brand-800);
}

[data-theme="dark"] .stat-item > small:hover {
  color: #c7daff;
}

/* 激活态按钮：深色下底色是品牌蓝，文字必须是白的 */
[data-theme="dark"] button.active,
[data-theme="dark"] .secondary.active,
[data-theme="dark"] .status-filter.active,
[data-theme="dark"] .link-button.active {
  color: #ffffff;
}

/* 原生下拉选项在深色下需要显式着色，否则是白底浅字 */
select option,
select optgroup {
  background-color: var(--surface);
  color: var(--text);
}

[data-theme="dark"] select option,
[data-theme="dark"] select optgroup {
  background-color: var(--surface-raised);
  color: var(--text);
}

/* 跳转链接在深色下的对比度 */
[data-theme="dark"] .skip-link {
  color: var(--text);
}

/* 曾被漏掉外观定义的次要按钮，避免渲染成主色 */
.secondary-button {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--line-strong);
  box-shadow: var(--sh-xs);
}

/* 骨架屏：加载中不再是一片空白 */
.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xs);
  background: var(--surface-sunken);
  color: transparent;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  animation: skeleton-sweep 1.4s var(--ease-in-out) infinite;
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
}

@keyframes skeleton-sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
