/* ============================================================================
   LPS 后台设计系统
   ----------------------------------------------------------------------------
   设计原则：
   1. 层次靠「暖度差」而不是「边框」—— 背景分三层，从外到内逐层变亮/变深
   2. 间距有节奏 —— 4/8/12/16/24/32 六档，不再一个值铺满
   3. 阴影轻且低 —— 卡片的浮起感靠极淡的阴影 + 1px 内描边，不靠黑框
   4. 圆角分级 —— 小元素 6px，卡片 14px，按钮 9px，形成视觉层级
   5. 强调色克制 —— 只有主操作、当前态、关键数字上色，其余全是中性灰
   6. 字重成对 —— 数字 600、标题 600、正文 400、辅助 400+低饱和
   ============================================================================ */

/* ---------------------------------------------------------------- 设计令牌 */
:root {
  /* 间距节奏 */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  /* 圆角分级 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* 动效 */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: 160ms;
}

/* ---------------------------------------------------------------- 暗色主题 */
:root,
html[data-theme="dark"] {
  color-scheme: dark;

  /* 三层背景：页面 → 卡片 → 卡片内凹区 */
  --bg: #0a0c10;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, rgba(56, 110, 240, .07), transparent 70%);
  --surface: #10131a;
  --surface-2: #161a23;
  --surface-3: #1c212c;
  --inset: #0c0f15;

  /* 描边：极淡，主要靠层次区分 */
  --border: rgba(255, 255, 255, .07);
  --border-strong: rgba(255, 255, 255, .12);
  --border-focus: rgba(93, 136, 255, .55);

  /* 文字四级 */
  --text: #e9edf5;
  --text-2: #a8b3c4;
  --text-3: #6e7a8d;
  --text-4: #4a5464;

  /* 主色：干净的科技蓝，去掉紫调 */
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, .12);
  --accent-text: #93bbfd;

  /* 语义色 */
  --ok: #35d07f;
  --ok-soft: rgba(53, 208, 127, .12);
  --ok-text: #7ce8b0;
  --warn: #f0b429;
  --warn-soft: rgba(240, 180, 41, .12);
  --warn-text: #ffd666;
  --err: #ff6b6b;
  --err-soft: rgba(255, 107, 107, .12);
  --err-text: #ff9b9b;

  /* 阴影：低透明度、大扩散，模拟真实光源 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 48px -8px rgba(0, 0, 0, .7);
  --shadow-glow: 0 0 0 1px rgba(93, 136, 255, .2), 0 8px 32px -8px rgba(93, 136, 255, .3);

  --row-hover: rgba(255, 255, 255, .025);
  --mask: rgba(5, 7, 11, .78);
}

/* ---------------------------------------------------------------- 亮色主题 */
html[data-theme="light"] {
  color-scheme: light;

  --bg: #fbfbfd;
  --bg-grad: radial-gradient(1200px 600px at 50% -10%, rgba(93, 136, 255, .05), transparent 70%);
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f4;
  --inset: #f4f5f8;

  --border: rgba(16, 24, 40, .07);
  --border-strong: rgba(16, 24, 40, .13);
  --border-focus: rgba(61, 107, 245, .5);

  --text: #12161f;
  --text-2: #4e5867;
  --text-3: #838d9d;
  --text-4: #aab3c0;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, .08);
  --accent-text: #1d4ed8;

  --ok: #0f9d58;
  --ok-soft: rgba(15, 157, 88, .09);
  --ok-text: #0a7d45;
  --warn: #c77700;
  --warn-soft: rgba(199, 119, 0, .09);
  --warn-text: #9a5b00;
  --err: #e03e3e;
  --err-soft: rgba(224, 62, 62, .08);
  --err-text: #c22d2d;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 14px -2px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 48px -12px rgba(16, 24, 40, .16);
  --shadow-glow: 0 0 0 3px rgba(61, 107, 245, .1);

  --row-hover: rgba(16, 24, 40, .022);
  --mask: rgba(16, 24, 40, .4);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

a { color: var(--accent-text); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-soft); color: var(--accent-text); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: content-box; }

/* ================================================================ 应用骨架 */
.app {
  display: flex;
  min-height: 100vh;
}

/* ================================================================ 侧边栏 */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  width: 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: width 220ms var(--ease), transform 220ms var(--ease);
}

/* 品牌区 */
.sidebar-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  height: 64px;
  padding: 0 var(--sp-3) 0 var(--sp-4);
  flex-shrink: 0;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  min-width: 0;
}
.brand-link:hover { text-decoration: none; }

/* Logo 图形 */
.brand-mark {
  display: flex;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  transition: transform 220ms var(--ease);
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-link:hover .brand-mark { transform: scale(1.06) rotate(-3deg); }

/* Logo 文字：主名 + 副标题双层 */
.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  line-height: 1.15;
  white-space: nowrap;
}
.brand-name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--text);
}
.brand-sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--text-4);
  margin-top: 2px;
}

/* 收起按钮：常驻但低调，hover 才变明显 */
.sidebar-collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  opacity: .55;
  transition: all var(--dur) var(--ease);
}
.sidebar-brand:hover .sidebar-collapse { opacity: 1; }
.sidebar-collapse:hover {
  background: var(--surface-3);
  color: var(--text);
}
.sidebar-collapse svg { transition: transform 220ms var(--ease); }

/* ------------------------------------------------------------------
   展开按钮：收起态下固定悬浮在侧栏右边缘
   做成圆形浮标，跟侧栏边线融为一体，不再是那个丑陋的方框
   ------------------------------------------------------------------ */
.sidebar-expand {
  position: fixed;
  top: 50%;
  left: 64px;
  z-index: 125;
  display: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 44px;
  margin-top: -22px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-3);
  color: var(--text-3);
  cursor: pointer;
  box-shadow: 2px 0 12px -4px rgba(0, 0, 0, .35);
  transition: all var(--dur) var(--ease);
}
.sidebar-expand:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 23px;
  box-shadow: 2px 0 16px -2px var(--accent);
}
.sidebar-expand svg { transition: transform var(--dur) var(--ease); }
.sidebar-expand:hover svg { transform: translateX(1px); }

/* 导航区 */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-2) var(--sp-2) var(--sp-3);
  scrollbar-width: thin;
}
.nav-group { margin-bottom: var(--sp-3); }
.nav-group:last-child { margin-bottom: 0; }

.nav-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  margin-bottom: 5px;
  color: var(--text-4);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  height: 22px;
}
.nav-site-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  text-align: right;
}

/* 导航项 */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  margin-bottom: 2px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav-item.on {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.nav-item.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2.5px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .85;
}
.nav-item.on .nav-icon { opacity: 1; }
.nav-text { overflow: hidden; text-overflow: ellipsis; }

/* 侧栏底部 */
.sidebar-foot {
  flex-shrink: 0;
  padding: var(--sp-2);
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  overflow: hidden;
}
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  font-size: 12.5px;
  font-weight: 650;
  text-transform: uppercase;
}
.user-meta { min-width: 0; overflow: hidden; }
.user-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role { color: var(--text-3); font-size: 11px; margin-top: 1px; }

.sidebar-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  padding: 0 2px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.icon-btn .tm-icon { font-size: 14px; line-height: 1; transition: transform var(--dur) var(--ease); }
.icon-btn:hover .tm-icon { transform: rotate(20deg); }
html[data-theme="dark"] .tm-icon::after { content: "☾"; }
html[data-theme="light"] .tm-icon::after { content: "☀"; }

/* ================================================================ 主内容 */
.main {
  flex: 1;
  min-width: 0;
  margin-left: 232px;
  transition: margin-left 220ms var(--ease);
}

/* ================================================================ 收起态 */
html[data-sidebar="collapsed"] .sidebar { width: 64px; }
html[data-sidebar="collapsed"] .main { margin-left: 64px; }
html[data-sidebar="collapsed"] .brand-text,
html[data-sidebar="collapsed"] .nav-text,
html[data-sidebar="collapsed"] .nav-label,
html[data-sidebar="collapsed"] .user-meta { display: none; }
html[data-sidebar="collapsed"] .sidebar-brand {
  justify-content: center;
  padding: 0;
  height: 64px;
}
html[data-sidebar="collapsed"] .sidebar-collapse { display: none; }
/* 收起态显示悬浮展开按钮 */
html[data-sidebar="collapsed"] .sidebar-expand { display: flex; }
html[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 0; gap: 0; }
html[data-sidebar="collapsed"] .nav-item.on::before { top: 6px; bottom: 6px; }
html[data-sidebar="collapsed"] .sidebar-nav { padding-left: 8px; padding-right: 8px; }
html[data-sidebar="collapsed"] .user-chip { justify-content: center; padding: 7px 0; }
html[data-sidebar="collapsed"] .sidebar-actions { flex-direction: column; align-items: center; }
html[data-sidebar="collapsed"] .nav-group { margin-bottom: var(--sp-2); }

/* 收起时 hover 显示 tooltip */
html[data-sidebar="collapsed"] .nav-item::after {
  content: attr(data-title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%) scale(.95);
  padding: 5px 10px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: all 140ms var(--ease);
  z-index: 130;
}
html[data-sidebar="collapsed"] .nav-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ================================================================ 移动端 */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--mask);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 220ms var(--ease);
}
.mobile-bar { display: none; }

@media (max-width: 900px) {
  .sidebar {
    width: 248px;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  html[data-sidebar="open"] .sidebar { transform: none; }
  html[data-sidebar="open"] .sidebar-mask { display: block; opacity: 1; }
  .main { margin-left: 0 !important; }
  /* 移动端抽屉里：收起按钮改成关闭按钮显示，悬浮展开按钮不出现 */
  .sidebar-collapse { display: flex; opacity: 1; }
  .sidebar-expand { display: none !important; }
  html[data-sidebar="collapsed"] .sidebar-expand { display: none !important; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    height: 52px;
    padding: 0 var(--sp-3);
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 90;
  }
  .mobile-title {
    flex: 1;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 移动端忽略收起态 */
  html[data-sidebar="collapsed"] .sidebar { width: 248px; }
  html[data-sidebar="collapsed"] .brand-text,
  html[data-sidebar="collapsed"] .nav-text,
  html[data-sidebar="collapsed"] .nav-label,
  html[data-sidebar="collapsed"] .user-meta { display: revert; }
  html[data-sidebar="collapsed"] .nav-item {
    justify-content: flex-start;
    padding: 0 10px;
    gap: 10px;
  }
}

/* ---------------------------------------------------------------- 布局容器 */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  /* 左边多留一点，内容和侧边栏之间有呼吸，不贴死 */
  padding: var(--sp-5) var(--sp-5) var(--sp-6) calc(var(--sp-5) + 4px);
}
.wrap.narrow { max-width: 720px; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.card:hover { border-color: var(--border-strong); }

.card > h3 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 var(--sp-4);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.008em;
  color: var(--text);
  flex-wrap: wrap;
}
.card > h3 small {
  color: var(--text-3);
  font-weight: 400;
  font-size: 12.5px;
  letter-spacing: 0;
  /* 说明文字和标题之间留出呼吸，别贴死 */
  padding-left: 2px;
  line-height: 1.5;
}

/* 卡片头部带操作区 */
.card-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.card-head h3 { margin: 0; }

/* 卡片顶部的一句话说明：比 <small> 更轻，占一行不抢标题 */
.card-desc {
  margin: -8px 0 var(--sp-4);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
}
.card-desc code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-2);
}

/* ---------------------------------------------------------------- 栅格 */
.grid { display: grid; gap: var(--sp-3); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

@media (max-width: 1100px) { .grid.c6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid.c2, .grid.c3, .grid.c4, .grid.c6 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------- KPI 指标卡 */
.kpi {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  /* 描边更明显一点，六张并排时每张的边界要一眼可分 */
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  transition: all var(--dur) var(--ease);
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.kpi:hover {
  background: var(--surface-3);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kpi:hover::after { opacity: 1; }

.kpi .label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: var(--sp-2);
  letter-spacing: .01em;
}
.kpi .val {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--text);
}
.kpi .sub {
  color: var(--text-3);
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.4;
}
/* 强调卡用淡色底 + 左侧色条，而不是整体染色 */
.kpi.hl {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
}
.kpi.hl::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.kpi.hl .val { color: var(--accent-text); }
.kpi.hl .label { color: var(--accent-text); }

/* ---------------------------------------------------------------- 表单 */
label.field { display: block; margin-bottom: var(--sp-3); }
label.field > span {
  display: block;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
  letter-spacing: .005em;
}
label.field > span b { color: var(--err); font-weight: 600; }

input[type=text], input[type=url], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-glow);
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--text-4); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e7a8d' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
  cursor: pointer;
}

textarea {
  min-height: 80px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
}

input[type=checkbox] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  border-radius: var(--r-xs);
}

input[type=date]::-webkit-calendar-picker-indicator {
  opacity: .5;
  cursor: pointer;
  filter: var(--cal-filter, none);
}
html[data-theme="dark"] input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(.7);
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: all var(--dur) var(--ease);
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}
.btn:active { transform: scale(.985); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 550;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .16);
}
.btn.primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px -2px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.btn.danger {
  color: var(--err-text);
  border-color: color-mix(in srgb, var(--err) 28%, transparent);
  background: transparent;
}
.btn.danger:hover {
  background: var(--err-soft);
  border-color: color-mix(in srgb, var(--err) 50%, transparent);
}

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-3); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }

.btn.sm { height: 29px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-xs); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none; pointer-events: none; }

/* ---------------------------------------------------------------- 行与工具条 */
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- 表格 */
.scroll { overflow-x: auto; border-radius: var(--r-md); }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  /* 全表数字等宽，纵向对齐才不会跳 */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  color: var(--text-2);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
  /* 表头比卡片深一档，才分得出「这是表头」 */
  background: var(--surface-3);
  position: sticky;
  top: 0;
  z-index: 1;
}
th:first-child { border-top-left-radius: var(--r-md); }
th:last-child { border-top-right-radius: var(--r-md); }

tbody tr { transition: background-color var(--dur) var(--ease); }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }

/* 数字列：右对齐 + 等宽 + 稍重 */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num {
  font-weight: 550;
  letter-spacing: -.005em;
  font-feature-settings: "tnum" 1;
  color: var(--text);
  min-width: 52px;
}
th.num { text-align: right; }

/* 表格里的次要说明文字 */
td .sub-line {
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-weight: 400;
}

/* ---------------------------------------------------------------- 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: .01em;
  white-space: nowrap;
  color: var(--text-3);
  background: var(--surface-3);
  border: 1px solid transparent;
}
.tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: var(--r-full);
  background: currentColor;
  opacity: .8;
  flex-shrink: 0;
}
.tag:empty::before { display: none; }
.tag.plain::before { display: none; }

.tag.ok { color: var(--ok-text); background: var(--ok-soft); }
.tag.warn { color: var(--warn-text); background: var(--warn-soft); }
.tag.err { color: var(--err-text); background: var(--err-soft); }
.tag.brand { color: var(--accent-text); background: var(--accent-soft); }

/* ---------------------------------------------------------------- 复选行 */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin: 0 0 var(--sp-2);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.check:hover { background: var(--surface-2); border-color: var(--border); }
.check input { margin-top: 2px; flex-shrink: 0; }
.check .t { font-size: 13.5px; font-weight: 500; color: var(--text); }
.check .d { color: var(--text-3); font-size: 12px; margin-top: 2px; line-height: 1.45; }

/* ---------------------------------------------------------------- 文本工具 */
.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0;
  /* 等宽字体默认字距太紧，时间戳之类的会粘在一起 */
  font-feature-settings: "tnum" 1;
}
.dim { color: var(--text-3); }
.hidden { display: none !important; }

/* 时间戳：强制保留空格，防止等宽字体压缩 */
.ts {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  white-space: nowrap;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 提示条 */
.toast {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  max-width: 420px;
  opacity: 0;
  transform: translateY(10px) scale(.97);
  transition: all 220ms var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.toast.err { color: var(--err-text); border-color: color-mix(in srgb, var(--err) 30%, transparent); }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  background: var(--mask);
  backdrop-filter: blur(6px);
  animation: fadeIn 180ms var(--ease);
}
.modal {
  width: 100%;
  max-width: 600px;
  max-height: 86vh;
  overflow: auto;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: popIn 200ms var(--ease);
}
.modal h2 { margin: 0 0 var(--sp-4); font-size: 17px; font-weight: 600; letter-spacing: -.015em; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(8px); } }

/* ---------------------------------------------------------------- 进度条 */
.bar {
  height: 6px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #8b5cf6));
  transition: width 400ms var(--ease);
}

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; height: 180px; display: block; }
.chart rect { fill: var(--accent); opacity: .85; rx: 3; transition: opacity var(--dur) var(--ease); }
.chart rect:hover { opacity: 1; }
.chart text { fill: var(--text-3); font-size: 10px; font-family: var(--font); }
.chart-bar { fill: var(--accent); }
.chart-bar-muted { fill: var(--border-strong); }

/* ---------------------------------------------------------------- 登录页 */
.login-box {
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-5);
}

/* 登录页品牌区：Logo + 标题并排 */
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: var(--sp-5);
}
.login-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(59, 130, 246, .28));
}
.login-brand h1 {
  margin: 0 0 3px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.02em;
}
.login-brand p {
  margin: 0;
  color: var(--text-3);
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- 配置块 */
.copy-field { display: flex; gap: var(--sp-2); }
.copy-field input { flex: 1; }

.slot-card {
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease);
}
.slot-card:hover { border-color: var(--border-strong); }
.slot-card .hd {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------- 代码块 */
pre.codeblock,
pre.mono {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  background: var(--inset);
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.75;
  overflow: auto;
  white-space: pre;
  max-height: 340px;
  tab-size: 2;
}

/* ---------------------------------------------------------------- 空状态 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  /* 高度压到 120px：居中但不至于让整块表格空出一大片 */
  min-height: 120px;
  padding: var(--sp-4);
  color: var(--text-3);
  font-size: 13.5px;
  line-height: 1.6;
  text-align: center;
}
.empty::before {
  content: "";
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background:
    linear-gradient(135deg, var(--surface-3), transparent),
    var(--surface-2);
  border: 1px dashed var(--border-strong);
  opacity: .85;
}
/* 表格里的空状态：不要再额外撑高 */
tbody td > .empty { min-height: 120px; }

/* ---------------------------------------------------------------- 分隔线 */
hr.divider {
  height: 1px;
  border: none;
  background: var(--border);
  margin: var(--sp-4) 0;
}

/* ---------------------------------------------------------------- 徽标数字 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 涨跌 */
.delta { font-variant-numeric: tabular-nums; font-weight: 550; }
.delta.up { color: var(--ok-text); }
.delta.down { color: var(--err-text); }
.delta.flat { color: var(--text-3); }

/* ---------------------------------------------------------------- 移动端 */
@media (max-width: 820px) {
  .wrap { padding: var(--sp-4) var(--sp-3) var(--sp-5); }
  .card { padding: var(--sp-4); border-radius: var(--r-md); }
  .kpi { padding: var(--sp-3); }
  .kpi .val { font-size: 21px; }
  th, td { padding: 9px 8px; font-size: 12.5px; }
  .toast { left: var(--sp-3); right: var(--sp-3); bottom: var(--sp-3); max-width: none; }
}

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