/* app.css — CWS V2 后台设计系统
 *
 * 设计依据（来自 ui-ux-pro-max skill 数据）：
 *   风格：Minimalism & Swiss Style
 *         来源 styles.csv#1 —— Best For: "Enterprise apps, dashboards, SaaS platforms, professional tools"
 *         性能 Excellent / 无障碍 WCAG AAA / 复杂度 Low
 *         要点：clean, spacious, functional, white space, high contrast, geometric, sans-serif, grid-based
 *   字体：Minimal Swiss（Inter 单字族多字重）
 *         来源 typography.csv#5 —— Best For: "Dashboards, admin panels, documentation, enterprise apps"
 *         要点：single font family with weight variations, ultimate simplicity
 *   配色：B2B Service
 *         来源 colors.csv#6 —— Primary #0F172A / CTA #0369A1 / BG #F8FAFC / Border #E2E8F0
 *         要点：Professional navy + blue CTA
 *
 * ⚠ 刻意偏离 skill 数据的两处（有理由）：
 *   1) skill 说 `--border-radius: 0px`（纯 Swiss 直角）。
 *      纯直角在现代屏幕上偏"上世纪"，且不利于触摸目标识别 ⇒ 用 6px 小圆角。
 *   2) skill 说 `--shadow: none`。列表/弹层完全无阴影会丢失层级感 ⇒
 *      只在**浮层**（下拉/模态框）用极轻阴影，卡片和表格一律无阴影。
 */

/* ══════════════════════════════════════════════════════════════════════════
   Design Tokens
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── 色板（B2B Service）───────────────────────────────────────────────── */
  --c-primary: #0f172a;        /* 主色：深海军蓝（侧栏、标题） */
  --c-primary-600: #1e293b;    /* 主色亮一档（hover） */
  --c-primary-400: #334155;    /* 主色再亮（次要文本/图标） */
  --c-accent: #0369a1;         /* 强调色：CTA、链接、选中态 */
  --c-accent-600: #075985;     /* 强调色深一档（hover） */
  --c-accent-50: #f0f9ff;      /* 强调色极浅（选中背景） */
  --c-bg: #f8fafc;             /* 页面背景 */
  --c-surface: #ffffff;        /* 卡片/表格背景 */
  --c-surface-alt: #f1f5f9;    /* 斑马纹/次级背景 */
  --c-border: #e2e8f0;         /* 主边框 */
  --c-border-strong: #cbd5e1;  /* 强调边框（输入框 focus 前） */
  --c-text: #020617;           /* 正文（近黑） */
  --c-text-secondary: #475569; /* 次要文本 */
  --c-text-tertiary: #64748b;  /* 三级文本（标签/提示） */
  --c-text-inverse: #f8fafc;   /* 深底上的文本 */

  /* ── 语义色（状态徽章、告警）──────────────────────────────────────────── */
  --c-success: #15803d;
  --c-success-bg: #f0fdf4;
  --c-success-border: #bbf7d0;
  --c-warning: #b45309;
  --c-warning-bg: #fffbeb;
  --c-warning-border: #fde68a;
  --c-danger: #b91c1c;
  --c-danger-bg: #fef2f2;
  --c-danger-border: #fecaca;
  --c-info: #0369a1;
  --c-info-bg: #f0f9ff;
  --c-info-border: #bae6fd;
  --c-neutral: #475569;
  --c-neutral-bg: #f1f5f9;
  --c-neutral-border: #e2e8f0;

  /* ── 字体（Minimal Swiss）─────────────────────────────────────────────── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, 'Courier New', monospace;

  /* 字阶（1.250 Major Third 的实用变体） */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;   /* 后台正文用 13px（比 16px 紧凑，一屏信息量更大） */
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 32px;

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;

  /* ── 间距（4px 基准）──────────────────────────────────────────────────── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* ── 圆角（刻意用 6px 而非 skill 建议的 0px，见文件头说明）────────────── */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --radius-full: 999px;

  /* ── 阴影（只在浮层用）────────────────────────────────────────────────── */
  --shadow-none: none;
  --shadow-overlay: 0 4px 16px rgba(15, 23, 42, 0.10), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 3px rgba(3, 105, 161, 0.18);

  /* ── 布局尺寸 ─────────────────────────────────────────────────────────── */
  --sidebar-w: 216px;
  --topbar-h: 52px;
  --content-max: 1440px;

  /* ── 动效（skill 建议 200-250ms）──────────────────────────────────────── */
  --t-fast: 120ms ease;
  --t-base: 200ms ease;
  --t-slow: 250ms ease;
}

/* ══════════════════════════════════════════════════════════════════════════
   Reset & Base
   ══════════════════════════════════════════════════════════════════════════ */

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 数字用等宽，表格对齐更好看 */
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

p { margin: 0; }

a {
  color: var(--c-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* 焦点可见性（无障碍：不能只靠颜色变化） */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* 滚动条（Webkit） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--c-border-strong);
  border-radius: var(--radius-full);
  border: 2px solid var(--c-bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--c-text-tertiary); }

/* ══════════════════════════════════════════════════════════════════════════
   布局：侧栏 + 主区
   ══════════════════════════════════════════════════════════════════════════ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── 侧栏 ─────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--c-primary);
  color: var(--c-text-inverse);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid rgba(248, 250, 252, 0.08);
  flex-shrink: 0;
}

.sidebar__logo {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--c-accent);
  display: grid;
  place-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: #fff;
  flex-shrink: 0;
}

.sidebar__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sidebar__subtitle {
  font-size: var(--fs-xs);
  color: rgba(248, 250, 252, 0.45);
  margin-top: 1px;
  white-space: nowrap;
  /* 英文名较长，超出时省略（不换行破坏品牌区高度） */
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar__group {
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: rgba(248, 250, 252, 0.38);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ══════════════════════════════════════════════════════════════════════════
   侧栏二级节点（2026-11-22 用户要求："左边的目录树，能不能放二级节点？"）
   ══════════════════════════════════════════════════════════════════════════
   设计要点（为什么这么做，而不是简单缩进）：

   ① **父项本身可点**：一级节点既是"分组标题"又是"可跳转的页面"。
      所以父项是一个带箭头的按钮：点文字跳页面，点箭头才折叠/展开。
      —— 纯折叠标题（点了只展开）会让"概览/设备池"这类页面失去入口。

   ② **缩进用左竖线**而不是纯 padding：
      二级节点左侧有一条 2px 竖线（border-left），视觉上明确"我属于上面那一项"。
      这比单纯缩进更能表达层级，也是成熟后台的常见做法。

   ③ **折叠状态存在 localStorage**：
      刷新后保持用户上次的展开状态，不会每次都回到默认。

   ④ **只有含 children 的项才显示箭头**：没有子项的项不显示箭头（不留空位）。
   ────────────────────────────────────────────────────────────────────────── */

/* 一级父项容器 */
.nav-parent {
  display: flex;
  flex-direction: column;
}

/* 父项行：左侧是链接，右侧是折叠箭头 */
.nav-parent__row {
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-parent__row .nav-item {
  flex: 1;
  min-width: 0;
}

/* 折叠箭头按钮（只有含子项的父项才有） */
.nav-toggle {
  width: 26px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  cursor: pointer;
  color: rgba(248, 250, 252, 0.5);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--t-fast), transform var(--t-base);
}

.nav-toggle:hover {
  color: var(--c-text-inverse);
  background: rgba(248, 250, 252, 0.08);
}

/* 展开时箭头转 90°（▶ → ▼ 用旋转表达，不用两个图标） */
.nav-toggle.is-open {
  transform: rotate(90deg);
  color: rgba(248, 250, 252, 0.85);
}

/* 二级节点容器 */
.nav-children {
  display: flex;
  flex-direction: column;
  gap: 1px;
  /* ⚠ 左侧竖线 + 缩进：表达"我属于上一项" */
  margin-left: var(--sp-3);
  padding-left: var(--sp-3);
  border-left: 1px solid rgba(248, 250, 252, 0.14);
  margin-bottom: var(--sp-1);
}

/* 二级节点本身比一级略小、略暗 */
.nav-children .nav-item {
  font-size: var(--fs-sm);
  padding-top: 5px;
  padding-bottom: 5px;
  color: rgba(248, 250, 252, 0.62);
}

.nav-children .nav-item:hover {
  color: var(--c-text-inverse);
}

.nav-children .nav-item.is-active {
  color: #fff;
}

/* ⚠ 二级节点被选中时，父项显示"弱高亮"（不是满色块，避免两个高亮抢注意力） */
.nav-item.is-active-parent {
  background: rgba(248, 250, 252, 0.07);
  color: var(--c-text-inverse);
}

/* 二级节点没有图标时不留空位 */
.nav-children .nav-item__icon:empty {
  display: none;
}

/* ⚠⚠ 第 2 条：父节点**不可点**（noLink）时的样式
 *
 *   用户原话："如果完成这样的话，父节点就不要能点进去了，
 *              直接子节点筛选这个类型的设备就行了。"
 *
 *   ⇒ 父项渲染成 <div>，视觉上必须让人一眼看出"这是标题不是链接"：
 *     · 没有 hover 背景变化（.nav-item:hover 的规则要用 :not(.nav-item--label) 排除）
 *     · 没有 cursor: pointer
 *     · 颜色比一级链接略淡（它是分组标题，不是可点的项）
 */
.nav-item--label {
  cursor: default;
  color: rgba(248, 250, 252, 0.86);
  font-weight: var(--fw-semibold);
  user-select: none;
}

.nav-item--label:hover {
  background: none;
  color: rgba(248, 250, 252, 0.86);
}

/* ⚠ 父项在有子节点被选中时仍要弱高亮（提示"你在这个模块里"） */
.nav-item--label.is-active-parent {
  background: rgba(248, 250, 252, 0.07);
  color: var(--c-text-inverse);
}

.nav-item--label.is-active-parent:hover {
  background: rgba(248, 250, 252, 0.07);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  color: rgba(248, 250, 252, 0.72);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(248, 250, 252, 0.08);
  color: var(--c-text-inverse);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--c-accent);
  color: #fff;
}

.nav-item__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-item__badge {
  margin-left: auto;
  background: rgba(248, 250, 252, 0.16);
  color: var(--c-text-inverse);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.nav-item.is-active .nav-item__badge {
  background: rgba(255, 255, 255, 0.22);
}

.sidebar__footer {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(248, 250, 252, 0.08);
  font-size: 10px;
  color: rgba(248, 250, 252, 0.38);
  flex-shrink: 0;
  line-height: 1.5;
}

/* 页脚两行：产品名 + 版本（分两行避免长名被折断） */
.sidebar__footer-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.sidebar__footer-line--dim {
  color: rgba(248, 250, 252, 0.26);
}

/* ── 主区 ─────────────────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.topbar__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
}

.topbar__breadcrumb {
  font-size: var(--fs-sm);
  color: var(--c-text-tertiary);
}

.topbar__spacer { flex: 1; }

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--c-text-secondary);
  border: 1px solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.topbar__user:hover {
  background: var(--c-surface-alt);
  border-color: var(--c-border);
}

.topbar__avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--c-accent-50);
  color: var(--c-accent);
  display: grid;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  flex-shrink: 0;
}

.content {
  flex: 1;
  overflow-y: auto;
  /* ⚠ V6 审核：留白层级扁平是"不像成熟产品"的核心原因
     → 内容区 padding 24px→32px，区块间距也提到 24px 起 */
  padding: var(--sp-8);
}

.content__inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* 区块之间统一 24px 间距（原来各页手写 mt-4=16px，太挤） */
.content__inner > * + * {
  margin-top: var(--sp-6);
}

/* ── 页头（标题 + 操作按钮）────────────────────────────────────────────
 * ⚠ 用户 2026-11-21 要求：UI 上不放说明性文字
 *   ⇒ 页头只有「标题 + 操作」，没有副标题说明。用户靠按钮和表格自己理解。
 */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.page-head__title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.page-head__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ══════════════════════════════════════════════════════════════════════════
   通用组件
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 卡片 ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  /* Swiss 风格：不用阴影 */
}

.card__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
}

.card__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
}

.card__subtitle {
  font-size: var(--fs-sm);
  color: var(--c-text-tertiary);
  margin-top: 3px;
}

.card__actions {
  margin-left: auto;
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

/* ⚠ V6 审核：卡片 padding 从 20px 提到 24px（Swiss 风格要"大留白"） */
.card__body {
  padding: var(--sp-6);
}

.card__body--flush {
  padding: 0;
}

/* ── 统计卡片 ─────────────────────────────────────────────────────────── */
/*
 * ⚠ 2026-11-21 V6 审核 §5.2 的 3 条修正：
 *   ① "5 等分无主次" → 显式 5 列网格，主指标 .stat--wide 跨 2 列
 *   ② "标题与数字太挤" → 标题→数字间距 8px→12px
 *   ③ "说明文字对比度不足"（#94A3B8 on #FFF ≈ 2.8:1，低于 WCAG AA 4.5:1）
 *      → 统一改用 --c-text-tertiary(#64748B)，对比度 4.9:1 ✔
 */
.stat-grid {
  display: grid;
  /* ⚠ 6 列网格：主卡占 2 列 + 4 张次卡 = 正好 6 格排满一行
     （之前用 5 列，主卡占 2 后总共 6 格 ⇒ 第 5 张卡换行，视觉很别扭） */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat--wide { grid-column: span 2; }
}

@media (max-width: 720px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat--wide { grid-column: span 2; }
}

.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--sp-5) var(--sp-5);
}

/* 主指标卡：占 2 列 + 更大字号（建立视觉主次） */
.stat--wide {
  grid-column: span 2;
  background: linear-gradient(180deg, #ffffff 0%, var(--c-accent-50) 100%);
  border-color: var(--c-accent);
}

.stat__label {
  font-size: var(--fs-sm);
  color: var(--c-text-tertiary);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.stat__value {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  margin-top: var(--sp-3);
  line-height: 1;
}

/* 主指标数字更大 */
.stat--wide .stat__value {
  font-size: 40px;
}

.stat__hint {
  font-size: var(--fs-xs);
  /* ⚠ 对比度修正：原 #94A3B8 只有 2.8:1，改 #64748B 达 4.9:1 */
  color: var(--c-text-tertiary);
  margin-top: var(--sp-2);
}

.stat--accent .stat__value { color: var(--c-accent); }
.stat--success .stat__value { color: var(--c-success); }
.stat--warning .stat__value { color: var(--c-warning); }
.stat--danger .stat__value { color: var(--c-danger); }

/* ── 按钮 ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 32px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.btn:hover:not(:disabled) {
  background: var(--c-surface-alt);
  border-color: var(--c-text-tertiary);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--c-accent-600);
  border-color: var(--c-accent-600);
}

.btn--danger {
  background: var(--c-danger);
  border-color: var(--c-danger);
  color: #fff;
}

.btn--danger:hover:not(:disabled) {
  background: #991b1b;
  border-color: #991b1b;
}

.btn--ghost {
  border-color: transparent;
  background: transparent;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--c-surface-alt);
  border-color: var(--c-border);
}

.btn--sm {
  height: 26px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
}

.btn--icon {
  width: 32px;
  padding: 0;
}

.btn--block {
  width: 100%;
}

/* ── 表单 ─────────────────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}

.field__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.field__label--required::after {
  content: ' *';
  color: var(--c-danger);
}

/* 标签前图标 */
.field__label-icon {
  display: inline-flex;
  align-items: center;
  color: var(--c-text-tertiary);
}

/* 锁定标记（替代"建后不可改"这类说明文字） */
.field__label-lock {
  display: inline-flex;
  align-items: center;
  color: var(--c-text-tertiary);
  margin-left: auto;
}

/* ⚠ 按用户要求移除 .field__hint（说明文字）—— 保留选择器只为兼容旧引用，实际不渲染 */
.field__hint {
  display: none;
}

.field__error {
  font-size: var(--fs-xs);
  color: var(--c-danger);
  font-weight: var(--fw-medium);
}

.input,
.select,
.textarea {
  height: 32px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
}

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

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: var(--shadow-focus);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--c-surface-alt);
  color: var(--c-text-tertiary);
  cursor: not-allowed;
}

.input--error,
.select--error {
  border-color: var(--c-danger);
}

.input::placeholder { color: var(--c-text-tertiary); }

/* 复选框 */
.checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--c-accent);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

/* ── 表格（后台核心组件）──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

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

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--c-surface-alt);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--t-fast);
}

.table tbody tr:hover {
  background: var(--c-accent-50);
}

.table tbody tr.is-selected {
  background: var(--c-accent-50);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table--compact tbody td {
  padding: var(--sp-1) var(--sp-3);
}

/* ⚠ 2026-11-23：列数多的表（≥10 列）专用 —— 水平内边距从 sp-3 收到 sp-2。
   起因：设备池加了一个行尾「批准」按钮之后变成 11 列，1280 宽窗口下
   最后一列（批准/配置）会被挤到横向滚动区外，用户看不到入口。
   11 列 × 每列省 8px ≈ 88px，正好补回缺口。 */
.table--dense thead th,
.table--dense tbody td {
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

/* ⚠⚠ 2026-11-25 用户要求：**已删除 / 未登记的 UID** 要用灰色字体
   （原话："用灰色字体表示（毕竟是没有实际在系统中使用）"）。
   只在这一张表上生效，不污染主表。 */
.table--muted,
.table--muted tbody td,
.table--muted thead th {
  color: var(--c-text-tertiary);
}
.table--muted tbody tr:hover {
  background: transparent;
}

/* ⚠ 2026-11-23：把**最后一列（操作列）钉在右侧**。
   列多 + 窗口窄 ⇒ 表格会横向滚动，但「批准 / 配置」这两个入口必须永远看得见
   （这一轮用户报的问题正是"找不到批准入口"）。
   `background: inherit` 让它跟着 tr 的 hover / 选中背景一起变色，不突兀。 */
.table--sticky-right thead th:last-child,
.table--sticky-right tbody td:last-child {
  position: sticky;
  right: 0;
  background: inherit;
  box-shadow: -6px 0 6px -6px rgba(0, 0, 0, 0.18);
}

.table--sticky-right thead th:last-child {
  background: var(--c-surface-alt);
  z-index: 2;
}

.table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table__mono {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}

.table__empty {
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  color: var(--c-text-tertiary);
}

/* ── 徽章（状态）──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 20px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

.badge--success {
  color: var(--c-success);
  background: var(--c-success-bg);
  border-color: var(--c-success-border);
}

.badge--warning {
  color: var(--c-warning);
  background: var(--c-warning-bg);
  border-color: var(--c-warning-border);
}

.badge--danger {
  color: var(--c-danger);
  background: var(--c-danger-bg);
  border-color: var(--c-danger-border);
}

.badge--info {
  color: var(--c-info);
  background: var(--c-info-bg);
  border-color: var(--c-info-border);
}

.badge--neutral {
  color: var(--c-neutral);
  background: var(--c-neutral-bg);
  border-color: var(--c-neutral-border);
}

.badge--plain::before { display: none; }

/* ── 进度条（额度使用率）──────────────────────────────────────────────── */
/* ⚠ V6 审核 §5.2：原来 6px 太细，提到 8px */
.progress {
  height: 8px;
  background: var(--c-surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 64px;
}

.progress__bar {
  height: 100%;
  background: var(--c-accent);
  border-radius: var(--radius-full);
  transition: width var(--t-base);
}

.progress__bar--warning { background: var(--c-warning); }
.progress__bar--danger { background: var(--c-danger); }
.progress__bar--success { background: var(--c-success); }

/* ── 工具栏（筛选栏）──────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface);
}

.toolbar__spacer { flex: 1; }

.toolbar .input,
.toolbar .select {
  width: auto;
  min-width: 140px;
}

.toolbar__search {
  min-width: 220px !important;
}

/* ⚠⚠ 2026-11-22 用户要求（认证日志页）：
 *   "计算一下宽度不要把自定义时间这个挤到第二行了"
 *
 *   ⇒ 日志页筛选控件多（设备ID + 4 个下拉 + 时间段 + 2 个日期框 + 每页条数 + 2 按钮），
 *     默认 min-width 140px 会把整行撑到换行。这里做**紧凑版**：
 *       · 下拉 120px（组名/类型名都不长）
 *       · 设备 ID 输入 200px
 *       · 日期框 152px（datetime-local 的原生宽度约 150px，再小会截断秒）
 *     一行总宽 ≈ 200+120*5+152*2+间隙 ≈ 1,030px，
 *     内容区可用宽 = min(1440, 视口-216侧栏-64内边距)，1280 视口下 ≈ 1,000px ⇒ 刚好放得下。
 */
.toolbar--tight {
  gap: var(--sp-2);
}

.toolbar--tight .select {
  min-width: 120px;
}

.toolbar--tight .input {
  min-width: 200px;
}

.toolbar--tight .input--datetime {
  min-width: 152px !important;
  width: 152px;
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

/* ⚠ 2026-11-23（审计日志页分页配套）：两个文本框要**显式收窄**。
 *   审计页第一行有 8 个控件（账号 / 动作 / 起 / 止 / 每页条数 / 查询 / 重置筛选），
 *   如果文本框吃 .toolbar--tight .input 的 200px 默认值，
 *   整行 ≈ 1050px > 内容区 998px（1280 视口实测）⇒ 「重置筛选」被挤到第二行。
 *   收窄后 ≈ 950px，一行放得下（实测截图确认）。
 *   ⚠ 账号名很短（admin / yisheng），120px 够；动作名最长是 device.force_pull_permit，
 *     190px 能露出前 20 个字符，剩下的靠 placeholder 提示 + 输入时可见。 */
.toolbar--tight .input--short {
  min-width: 120px !important;
  width: 120px;
  flex: 0 0 auto;
}

.toolbar--tight .input--mid {
  min-width: 190px !important;
  width: 190px;
  flex: 0 0 auto;
}

/* ── 空态 / 加载 / 错误 ───────────────────────────────────────────────── */
.state {
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
}

/* ⚠ V6 审核 §5.2：整块空态占 150px 太浪费，用于"额度预警"这类次要区块时压到 60px */
.state--compact {
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-align: left;
  color: var(--c-text-tertiary);
  font-size: var(--fs-sm);
}

.state--compact .state__icon {
  width: 20px;
  height: 20px;
  margin: 0;
  flex-shrink: 0;
  font-size: 11px;
}

.state__icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--sp-3);
  border-radius: var(--radius-full);
  background: var(--c-surface-alt);
  display: grid;
  place-items: center;
  color: var(--c-text-tertiary);
}

.state__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  color: var(--c-text-secondary);
}

.state__desc {
  font-size: var(--fs-sm);
  color: var(--c-text-tertiary);
  margin-top: var(--sp-1);
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.state__actions {
  margin-top: var(--sp-4);
  display: flex;
  gap: var(--sp-2);
  justify-content: center;
}

.state--error .state__icon {
  background: var(--c-danger-bg);
  color: var(--c-danger);
}

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-alt) 25%, var(--c-border) 37%, var(--c-surface-alt) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  height: 14px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ── 模态框 ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: var(--sp-4);
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ⚠ 2026-11-22 用户要求：分组详情太窄，宽度 +50%（760 → 1140） */
/* ⚠ 2026-11-22 用户要求：分组详情再加宽 20%（1140 → 1368） */
.modal--wide { max-width: 1368px; }

.modal__header {
  display: flex;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.modal__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}

.modal__close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  border-radius: var(--radius);
  color: var(--c-text-tertiary);
  font-size: var(--fs-lg);
  line-height: 1;
}

.modal__close:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
}

.modal__body {
  padding: var(--sp-5);
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-alt);
  flex-shrink: 0;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  min-width: 260px;
  max-width: 420px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-overlay);
  font-size: var(--fs-base);
  animation: toast-in var(--t-base);
}

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

.toast--success { border-left: 3px solid var(--c-success); }
.toast--error { border-left: 3px solid var(--c-danger); }
.toast--info { border-left: 3px solid var(--c-info); }
.toast--warning { border-left: 3px solid var(--c-warning); }

.toast__text { flex: 1; }

.toast__close {
  border: none;
  background: none;
  color: var(--c-text-tertiary);
  font-size: var(--fs-md);
  line-height: 1;
  padding: 0;
}

/* ── 登录页 ───────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 440px;
  background: var(--c-bg);
}

.login__aside {
  background: var(--c-primary);
  color: var(--c-text-inverse);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-12);
  position: relative;
  overflow: hidden;
}

/* 几何装饰（Swiss 风格的网格感，不用渐变） */
.login__aside::before {
  content: '';
  position: absolute;
  top: -120px;
  right: -120px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(248, 250, 252, 0.08);
  border-radius: 50%;
}

.login__aside::after {
  content: '';
  position: absolute;
  bottom: -80px;
  left: -80px;
  width: 240px;
  height: 240px;
  border: 1px solid rgba(248, 250, 252, 0.06);
}

.login__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
  position: relative;
  z-index: 1;
}

.login__brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--c-accent);
  display: grid;
  place-items: center;
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.login__brand-text {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

/* 英文名（副行） */
.login__brand-en {
  font-size: var(--fs-sm);
  color: rgba(248, 250, 252, 0.5);
  margin-top: 2px;
  letter-spacing: 0.01em;
}

/* 右下角版本标签 */
.login__version {
  margin-top: var(--sp-4);
  font-size: var(--fs-xs);
  color: var(--c-text-tertiary);
  text-align: center;
  letter-spacing: 0.01em;
}

/* ⚠⚠ 2026-11-28：ICP 备案号（工信部要求网站底部必须公示 + 链接到查询网站）。
   放在版本号下面，字号比版本号再小一档（它是合规信息，不是产品信息），
   颜色用 tertiary 但可点（hover 变主色 + 下划线）。
   ⚠ 不要用 `pointer-events: none` 或去掉 href —— 那样就不是"链接"，备案不合规。 */
.login__beian {
  margin-top: var(--sp-2);
  font-size: var(--fs-xs);
  text-align: center;
  letter-spacing: 0.01em;
}

.login__beian-link {
  color: var(--c-text-tertiary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.login__beian-link:hover,
.login__beian-link:focus-visible {
  color: var(--c-primary);
  text-decoration: underline;
}

/* 键盘焦点可见（无障碍）：不用默认 outline，改用与主色一致的描边 */
.login__beian-link:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

.login__headline {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  line-height: 1.2;
  letter-spacing: -0.025em;
  position: relative;
  z-index: 1;
  max-width: 480px;
}

.login__desc {
  font-size: var(--fs-md);
  color: rgba(248, 250, 252, 0.62);
  margin-top: var(--sp-4);
  max-width: 420px;
  line-height: var(--lh-relaxed);
  position: relative;
  z-index: 1;
}

.login__features {
  margin-top: var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: relative;
  z-index: 1;
}

.login__feature {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-base);
  color: rgba(248, 250, 252, 0.78);
}

.login__feature-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-accent);
  flex-shrink: 0;
}

.login__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8);
  background: var(--c-surface);
}

.login__form {
  width: 100%;
  max-width: 320px;
}

.login__title {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
}

.login__subtitle {
  font-size: var(--fs-base);
  color: var(--c-text-tertiary);
  margin: var(--sp-1) 0 var(--sp-6);
}

.login__error {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius);
  background: var(--c-danger-bg);
  border: 1px solid var(--c-danger-border);
  color: var(--c-danger);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
}

.login__footer {
  margin-top: var(--sp-6);
  font-size: var(--fs-xs);
  color: var(--c-text-tertiary);
  text-align: center;
  line-height: var(--lh-relaxed);
}

/* ── 改密提示遮罩（仅提示，不拦人）─────────────────────────────────────── */
.must-change-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-warning-bg);
  border: 1px solid var(--c-warning-border);
  border-radius: var(--radius);
  margin-bottom: var(--sp-5);
  font-size: var(--fs-base);
  color: var(--c-warning);
}

.must-change-banner__text { flex: 1; }

/* ── 只读信息网格（替代"客户：xxx"这类句子式罗列）──────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface-alt);
  border-radius: var(--radius);
}

.meta-grid__k {
  color: var(--c-text-tertiary);
  white-space: nowrap;
}

.meta-grid__v {
  color: var(--c-text);
  font-weight: var(--fw-medium);
  text-align: right;
}

/* ── 工具类 ───────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--sp-2); }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-tertiary { color: var(--c-text-tertiary); }
.text-secondary { color: var(--c-text-secondary); }
.text-danger { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.text-warning { color: var(--c-warning); }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-semibold { font-weight: var(--fw-semibold); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── 响应式 ───────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform var(--t-base);
  }
  .sidebar.is-open { transform: translateX(0); }
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .toolbar .input,
  .toolbar .select { min-width: 0; flex: 1; }
  .toolbar__search { min-width: 0 !important; }
}

/* 打印（导出报表时） */
@media print {
  .sidebar, .topbar, .toolbar, .btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { border: none; }
}
