/* =====================================================================
 * UAV-Trace · 云链追溯 — 现代 SaaS 后台样式
 * 设计原则：浅色主题、克制阴影、卡片化、统一设计令牌
 * 断点：手机 <768px  |  平板 768-1023px  |  桌面 ≥1024px
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * 设计令牌（CSS 变量）
 * ------------------------------------------------------------------- */
:root {
  /* 主色（保留品牌色：致睿蓝紫） */
  --brand:        #2E5BFF;
  --brand-600:    #234BD9;
  --brand-700:    #1B3FB8;
  --brand-50:     #EEF2FF;
  --brand-100:    #DCE4FF;
  --accent:       #6366F1;

  /* 中性色（Slate） */
  --bg:           #F7F8FB;   /* 页面背景 */
  --bg-elev:      #FFFFFF;   /* 卡片/面板 */
  --bg-soft:      #F1F4F9;   /* 二级背景 / hover */
  --bg-sunken:    #EDF1F7;   /* 凹陷 */
  --border:       #E3E8F0;
  --border-strong:#CBD5E1;
  --text:         #0F172A;
  --text-2:       #475569;
  --text-3:       #94A3B8;
  --text-on-brand:#FFFFFF;

  /* 状态色 */
  --ok:           #10B981;
  --ok-soft:      #D1FAE5;
  --warn:         #F59E0B;
  --warn-soft:    #FEF3C7;
  --err:          #EF4444;
  --err-soft:     #FEE2E2;
  --info:         #3B82F6;
  --info-soft:    #DBEAFE;
  --purple:       #8B5CF6;
  --purple-soft:  #EDE9FE;
  --gray:         #6B7280;

  /* 阴影（克制） */
  --shadow-xs:    0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:    0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04);
  --shadow:       0 2px 4px rgba(15,23,42,.06), 0 4px 8px rgba(15,23,42,.04);
  --shadow-md:    0 4px 6px rgba(15,23,42,.06), 0 8px 16px rgba(15,23,42,.05);
  --shadow-lg:    0 10px 15px rgba(15,23,42,.07), 0 20px 30px rgba(15,23,42,.05);

  /* 圆角 */
  --r-sm:         6px;
  --r:            8px;
  --r-md:         10px;
  --r-lg:         14px;
  --r-xl:         18px;
  --r-pill:       999px;

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

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

  /* 动效 */
  --ease:         cubic-bezier(.2, .8, .2, 1);
  --t-fast:       120ms;
  --t:            180ms;
}

/* ---------------------------------------------------------------------
 * Reset & 基础
 * ------------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
input, button, textarea, select {
  font: inherit; color: inherit;
}
button { background: none; border: 0; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
::selection { background: var(--brand-100); color: var(--brand-700); }

/* iOS 输入框聚焦不放大 */
@media (max-width: 767px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ---------------------------------------------------------------------
 * 通用组件
 * ------------------------------------------------------------------- */

/* 卡片 */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: var(--s-5); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 var(--s-4);
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text);
  font-size: 13.5px; font-weight: 500;
  transition: all var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand); color: var(--text-on-brand); border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn-danger:hover { background: #DC2626; }
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: 12.5px; }
.btn-lg { height: 44px; padding: 0 var(--s-6); font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* 字段（输入） */
.field { margin-bottom: var(--s-4); }
.field label {
  display: block; font-size: 12.5px; color: var(--text-2);
  margin-bottom: 6px; font-weight: 500;
}
.field input, .field textarea, .field select {
  width: 100%; height: 38px; padding: 0 var(--s-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13.5px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  outline: none;
}
.field textarea { height: auto; padding: var(--s-3); resize: vertical; min-height: 80px; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--border-strong); }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-50);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

/* 标签 / 徽章 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  font-size: 11.5px; font-weight: 500;
  border-radius: var(--r-sm);
  background: var(--bg-soft); color: var(--text-2);
  white-space: nowrap;
}
.tag-brand { background: var(--brand-50); color: var(--brand-700); }
.tag-ok    { background: var(--ok-soft);    color: #047857; }
.tag-warn  { background: var(--warn-soft);  color: #B45309; }
.tag-err   { background: var(--err-soft);   color: #B91C1C; }
.tag-info  { background: var(--info-soft);  color: #1D4ED8; }
.tag-purple{ background: var(--purple-soft);color: #6D28D9; }

/* 空状态 */
.empty {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
}
.empty .big { font-size: 32px; margin-bottom: var(--s-2); }

/* 列表项（行） */
.row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--bg-soft); }
.row .col { flex: 1; min-width: 0; }
.row .col.title { font-weight: 500; color: var(--text); }
.row .col.sub   { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.row .meta { font-size: 12px; color: var(--text-3); flex-shrink: 0; }

/* 列表（卡片网格） */
.grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* 空 header 风格 */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--s-4);
}
.section-head h2 { font-size: 16px; font-weight: 600; }
.section-head .desc { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* 搜索框 */
.search {
  position: relative;
}
.search input {
  width: 100%; height: 36px; padding: 0 var(--s-3) 0 36px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13.5px;
  outline: none;
  transition: all var(--t-fast) var(--ease);
}
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.search::before {
  content: ""; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* chips（水平滚动） */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  height: 28px; padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--bg-soft); color: var(--text-2);
  font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all var(--t-fast);
  cursor: pointer;
  border: 1px solid transparent;
}
.chip:hover { background: var(--bg-sunken); }
.chip.active {
  background: var(--brand); color: var(--text-on-brand);
}

/* 多选 chips（用于权限组） */
.cb-item {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-elev);
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.cb-item:hover { border-color: var(--border-strong); }
.cb-item input { display: none; }
.cb-item.on { border-color: var(--brand); background: var(--brand-50); color: var(--brand-700); font-weight: 600; }

/* 圆点状态 */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok    { background: var(--ok); }
.dot.warn  { background: var(--warn); }
.dot.err   { background: var(--err); }
.dot.info  { background: var(--info); }
.dot.purple{ background: var(--purple); }
.dot.gray  { background: var(--gray); }

/* Toast */
.toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(15,23,42,.92); color: #fff;
  padding: 10px 18px; border-radius: var(--r);
  font-size: 13.5px; z-index: 1000;
  box-shadow: var(--shadow-md);
  animation: toast-in .2s var(--ease);
  max-width: 80vw;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 8px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ---------------------------------------------------------------------
 * 登录页
 * ------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
}
@media (min-width: 900px) {
  .login-page {
    grid-template-columns: 1.05fr 1fr;
  }
}

/* ---- 桌面端左侧品牌区 ---- */
.login-hero {
  display: none;
  background: linear-gradient(160deg, #14226B 0%, #1E3FD8 48%, #4A56E8 100%);
  color: #fff;
  padding: clamp(32px, 6vh, 72px) clamp(32px, 5vw, 80px);
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-hero::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 18% 85%, rgba(255,255,255,.10), transparent 50%),
              radial-gradient(circle at 82% 15%, rgba(255,255,255,.08), transparent 50%);
  pointer-events: none;
}
.login-hero .brand-block { position: relative; }
/* 公司 LOGO：白色圆角底板承托（logo 为蓝色，深底上需要浅色衬底） */
.hero-logo {
  display: inline-flex; align-items: center;
  background: #fff;
  border-radius: 20px;
  padding: 24px 34px;
  box-shadow: 0 10px 30px rgba(10, 20, 60, .28);
}
.hero-logo img { height: 72px; width: auto; display: block; }
.login-hero .brand-block { text-align: center; }
.login-hero .brand-title {
  font-size: clamp(28px, 3.4vw, 58px); font-weight: 700;
  margin-top: clamp(24px, 5vh, 48px);
  letter-spacing: .5px; line-height: 1.4;
  white-space: nowrap;
}
.login-hero .brand-sub {
  margin-top: var(--s-3); font-size: clamp(15px, 1.3vw, 24px); opacity: .82;
  line-height: 1.8;
  white-space: nowrap;
}
.login-hero .features {
  position: relative;
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(2, 1fr);
}
.login-hero .feat {
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--r-md);
  padding: 14px 18px;
  font-size: 13px;
  backdrop-filter: blur(8px);
}
.login-hero .feat .t { font-weight: 600; margin-bottom: 3px; font-size: 13.5px; }
.login-hero .feat .d { opacity: .78; font-size: 12px; }
@media (min-width: 900px) {
  .login-hero { display: flex; }
}

/* ---- 右侧登录卡片 ---- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-6);
  min-height: 100vh;
}
.login-card {
  width: 100%; max-width: 430px;
  background: var(--bg-elev);
  border-radius: 20px;
  padding: 36px 28px 30px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
@media (min-width: 900px) {
  .login-card { padding: 48px 44px 36px; }
}
/* 公司 LOGO + 名称（手机 / 桌面均显示） */
.login-brand {
  text-align: center;
  margin-bottom: 26px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.login-brand img {
  height: 44px; width: auto;
  display: block; margin: 0 auto 14px;
}
.login-brand .lb-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  letter-spacing: .5px;
}
.login-brand .lb-sub {
  font-size: 12px; color: var(--text-3);
  margin-top: 5px; letter-spacing: 3px;
}
.login-card .card-title { font-size: 24px; font-weight: 700; margin-bottom: 6px; letter-spacing: .5px; }
.login-card .card-sub { font-size: 13.5px; color: var(--text-2); margin-bottom: 28px; }
/* 登录页输入放大：更好点按、更清晰 */
.login-card .field { margin-bottom: 18px; }
.login-card .field label { font-size: 13px; margin-bottom: 8px; }
.login-card .field input {
  height: 46px; font-size: 15px;
  border-radius: 10px; padding: 0 14px;
}
.login-card .btn-lg {
  height: 48px; font-size: 16px; font-weight: 600;
  letter-spacing: 10px; text-indent: 10px;   /* 视觉居中补偿 */
  margin-top: 8px; border-radius: 10px;
}
.login-error {
  color: var(--err); font-size: 12.5px;
  margin-top: var(--s-3); min-height: 16px;
}
.login-tips {
  margin-top: 18px;
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 12px 16px;
}
.login-tips p {
  font-size: 12px; color: var(--text-3); line-height: 1.9;
  display: flex; align-items: baseline; gap: 6px;
}
.login-tips p::before { content: "·"; color: var(--brand); font-weight: 700; }
.login-foot {
  display: none;
  text-align: center; color: var(--text-3); font-size: 11.5px;
  padding: var(--s-4);
}
@media (max-width: 899px) {
  .login-foot { display: block; }
}

/* ---------------------------------------------------------------------
 * 主应用 — 桌面端布局（≥1024px）
 * ------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .app {
    display: grid !important;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar main";
    min-height: 100vh;
  }
  /* 桌面端隐藏底部 tabbar（侧边栏已承担） */
  .tabbar { display: none !important; }
  /* 桌面端隐藏手机 topbar */
  .topbar { display: none !important; }
  /* 桌面端顶栏 */
  .app-topbar {
    grid-area: topbar;
    display: flex !important;
    align-items: center;
    padding: 0 var(--s-6);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    gap: var(--s-4);
  }
  /* 桌面端侧边栏 */
  .app-sidebar {
    grid-area: sidebar;
    display: flex !important;
    flex-direction: column;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    overflow: hidden;
  }
  /* 主内容区 */
  .main {
    grid-area: main;
    padding: var(--s-6) var(--s-8);
    overflow-y: auto;
    min-width: 0;
  }
}

/* 桌面端顶栏内部结构（移动端隐藏） */
.app-topbar { display: none; }
.app-sidebar { display: none; }

.app-topbar .crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-3);
}
.app-topbar .crumbs .now { color: var(--text); font-weight: 600; }
.app-topbar .crumbs .sep { opacity: .5; }
.app-topbar .right { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.app-topbar .user-chip {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 4px 10px 4px 4px;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  font-size: 13px;
}
.app-topbar .user-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 600;
}

/* ---------------------------------------------------------------------
 * 桌面端侧边栏内部
 * ------------------------------------------------------------------- */
.app-sidebar .sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px var(--s-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.app-sidebar .sb-brand .logo {
  display: flex; align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
}
.app-sidebar .sb-brand .logo img {
  height: 18px; width: auto; display: block;
}
.app-sidebar .sb-brand .name {
  font-size: 14px; font-weight: 600; line-height: 1.2;
}
.app-sidebar .sb-brand .name .sub {
  display: block; font-size: 11px; color: var(--text-3); font-weight: 400;
}
.app-sidebar .sb-section {
  padding: var(--s-4) var(--s-5) 6px;
  font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: .8px;
}
.app-sidebar .sb-nav { padding: 0 var(--s-3); flex: 1; overflow-y: auto; }
.app-sidebar .sb-foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-3);
  flex-shrink: 0;
}

/* tab 在桌面端 = 侧边栏导航项 */
.app-sidebar .tab {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3);
  margin-bottom: 2px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  user-select: none;
}
.app-sidebar .tab svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--text-3);
  transition: color var(--t-fast);
}
.app-sidebar .tab:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.app-sidebar .tab:hover svg { color: var(--text-2); }
.app-sidebar .tab.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.app-sidebar .tab.active svg { color: var(--brand); }

/* 扫码 tab 在侧边栏特殊样式 */
.app-sidebar .tab-scan .scan-btn {
  width: 32px; height: 32px;
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-right: var(--s-3);
  flex-shrink: 0;
}
.app-sidebar .tab-scan .scan-btn svg { width: 16px; height: 16px; color: #fff; }
.app-sidebar .tab-scan span { color: var(--text-2); }
.app-sidebar .tab-scan.active span { color: var(--brand-700); }

/* 平板（768-1023px）：折叠 sidebar 为图标列 */
@media (min-width: 768px) and (max-width: 1023px) {
  .app {
    display: grid !important;
    grid-template-columns: 72px 1fr;
    grid-template-rows: 60px 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar main";
  }
  .tabbar { display: none !important; }
  .topbar { display: none !important; }
  .app-topbar { grid-area: topbar; display: flex !important; }
  .app-sidebar { grid-area: sidebar; display: flex !important; }
  .main { grid-area: main; padding: var(--s-5); }
  .app-sidebar .sb-brand .name { display: none; }
  .app-sidebar .sb-brand { justify-content: center; padding: 18px 0; }
  .app-sidebar .sb-section { display: none; }
  .app-sidebar .tab {
    justify-content: center;
    padding: 12px 0;
  }
  .app-sidebar .tab span,
  .app-sidebar .tab-scan span { display: none; }
  .app-sidebar .tab-scan .scan-btn { margin-right: 0; }
}

/* ---------------------------------------------------------------------
 * 主应用 — 移动端布局（<768px）
 * ------------------------------------------------------------------- */
@media (max-width: 767px) {
  .app {
    display: flex; flex-direction: column;
    min-height: 100vh;
  }
  .topbar {
    display: flex;
    position: sticky; top: 0; z-index: 20;
    height: 52px; padding: 0 var(--s-4);
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: var(--s-3);
  }
  .topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .topbar-brand .logo {
    flex-shrink: 0;
    display: flex; align-items: center;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 3px 6px;
  }
  .topbar-brand .logo img { height: 15px; width: auto; display: block; }
  .topbar-text { min-width: 0; }
  .topbar-company { display: none; }
  .topbar-title { font-size: 15px; font-weight: 600; }
  .topbar-user {
    margin-left: auto;
    font-size: 12px; color: var(--text-2);
    padding: 4px 10px;
    border-radius: var(--r-pill);
    background: var(--bg-soft);
    max-width: 50%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .main { padding: var(--s-4); padding-bottom: 88px; flex: 1; }
}

/* ---------------------------------------------------------------------
 * tabbar（仅移动端）
 * ------------------------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 40;
  padding: 6px 0 max(8px, env(safe-area-inset-bottom));
}
.tabbar .tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 4px 0;
  color: var(--text-3);
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: color var(--t-fast);
}
.tabbar .tab svg { width: 22px; height: 22px; }
.tabbar .tab.active { color: var(--brand); }

/* 扫码 tab 居中高亮 */
.tabbar .tab-scan { position: relative; }
.tabbar .tab-scan .scan-btn {
  width: 50px; height: 50px;
  margin-top: -22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(46,91,255,.35);
  transition: transform var(--t-fast) var(--ease);
}
.tabbar .tab-scan .scan-btn svg { width: 24px; height: 24px; color: #fff; }
.tabbar .tab-scan:hover .scan-btn { transform: scale(1.05); }

/* ---------------------------------------------------------------------
 * 工作台首页
 * ------------------------------------------------------------------- */
.home-hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 60%, var(--purple) 100%);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-6);
  color: #fff;
  margin-bottom: var(--s-6);
  position: relative;
  overflow: hidden;
}
.home-hero::before {
  content: "";
  position: absolute; top: -50%; right: -10%;
  width: 60%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,.15), transparent 60%);
  pointer-events: none;
}
.home-hero h1 {
  font-size: 22px; font-weight: 700;
  position: relative; z-index: 1;
}
.home-hero .desc {
  margin-top: 6px; font-size: 13px; opacity: .9;
  position: relative; z-index: 1;
}
.home-hero .quick {
  margin-top: var(--s-5);
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  position: relative; z-index: 1;
}
.home-hero .quick .qbtn {
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--r);
  font-size: 13px;
  backdrop-filter: blur(4px);
  transition: all var(--t-fast);
}
.home-hero .quick .qbtn:hover { background: rgba(255,255,255,.28); }

/* 统计卡片 */
.stat-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-bottom: var(--s-6);
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: box-shadow var(--t-fast);
}
.stat:hover { box-shadow: var(--shadow-sm); }
.stat .label { font-size: 12.5px; color: var(--text-3); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--text); }
.stat .delta { font-size: 12px; margin-top: 4px; color: var(--text-3); }

/* 快捷模块卡片 */
.module-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.module {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  display: flex; align-items: flex-start; gap: var(--s-4);
}
.module:hover {
  border-color: var(--brand-100);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.module .icon {
  width: 40px; height: 40px;
  border-radius: var(--r);
  background: var(--brand-50); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.module .icon svg { width: 22px; height: 22px; }
.module .icon.purple { background: var(--purple-soft); color: var(--purple); }
.module .icon.green  { background: var(--ok-soft);    color: var(--ok); }
.module .icon.orange { background: var(--warn-soft);  color: var(--warn); }
.module .icon.blue   { background: var(--info-soft);  color: var(--info); }
.module .name { font-weight: 600; font-size: 14px; }
.module .desc { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

/* ---------------------------------------------------------------------
 * 设备列表 / 设备详情
 * ------------------------------------------------------------------- */
.dev-filter {
  display: flex; flex-direction: column; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.dev-filter .search-row {
  display: flex; gap: var(--s-2);
}
.dev-filter .search-row .search { flex: 1; }

.dev-list { display: flex; flex-direction: column; }
@media (min-width: 1024px) {
  /* 桌面端：列表改双列卡片 */
  .dev-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: var(--s-4);
  }
  /* 桌面端隐藏 .row 风格，改用 .dev-card */
  .dev-list .row { display: none; }
  .dev-list .dev-card { display: flex; }
}
.dev-card {
  display: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  flex-direction: column; gap: var(--s-3);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.dev-card:hover {
  border-color: var(--brand-100);
  box-shadow: var(--shadow);
}
.dev-card .head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
}
.dev-card .serial {
  font-family: var(--font-mono);
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.dev-card .body {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--s-2);
  font-size: 12.5px;
}
.dev-card .body .k { color: var(--text-3); }
.dev-card .body .v { color: var(--text); font-weight: 500; }

/* ---------------------------------------------------------------------
 * 全屏浮层（详情 / 业务模块）
 * ------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.overlay-head {
  flex-shrink: 0;
  display: flex; align-items: center;
  padding: var(--s-3) var(--s-5);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  gap: var(--s-3);
  height: 60px;
}
.overlay-back {
  width: 36px; height: 36px;
  border-radius: var(--r);
  background: var(--bg-soft);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.overlay-back:hover { background: var(--bg-sunken); }
.overlay-back svg { width: 18px; height: 18px; }
.overlay-title { font-size: 16px; font-weight: 600; }
.overlay-right { margin-left: auto; display: flex; gap: var(--s-2); }
.overlay-body {
  flex: 1; overflow-y: auto;
  padding: var(--s-5);
}
@media (min-width: 1024px) {
  .overlay-body { padding: var(--s-6) var(--s-8); }
}

/* 设备详情布局（桌面端双列） */
.dev-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-5);
  max-width: 1200px;
}
@media (min-width: 1024px) {
  .dev-detail {
    grid-template-columns: 1fr 360px;
    align-items: start;
  }
}
.dev-detail .timeline-card { min-height: 320px; }
.dev-detail .info-card { position: sticky; top: var(--s-5); }

/* ---------------------------------------------------------------------
 * 表单弹层（手机底部弹起 / 桌面居中模态）
 * ------------------------------------------------------------------- */
.sheet-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade-in var(--t) var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%; max-width: 480px;
  background: var(--bg-elev);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s-4) var(--s-5) max(var(--s-6), env(safe-area-inset-bottom));
  max-height: 85vh;
  display: flex; flex-direction: column;
  animation: sheet-up .25s var(--ease);
  box-shadow: var(--shadow-lg);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@media (min-width: 768px) {
  .sheet-mask { align-items: center; padding: var(--s-5); }
  .sheet {
    max-width: 520px;
    border-radius: var(--r-lg);
    max-height: 88vh;
    animation: sheet-zoom .2s var(--ease);
  }
  @keyframes sheet-zoom {
    from { opacity: 0; transform: scale(.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
}
.sheet-title { font-size: 16px; font-weight: 600; }
.sheet-close {
  width: 30px; height: 30px;
  border-radius: var(--r);
  background: var(--bg-soft);
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: background var(--t-fast);
}
.sheet-close:hover { background: var(--bg-sunken); }
.sheet-body {
  flex: 1; overflow-y: auto;
  padding-right: 4px; margin-right: -4px;
}
.sheet-foot {
  display: flex; gap: var(--s-3);
  padding-top: var(--s-4);
  margin-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.sheet-foot .btn { flex: 1; }

/* ---------------------------------------------------------------------
 * 扫码模块
 * ------------------------------------------------------------------- */
.scan-stage {
  display: flex; flex-direction: column; gap: var(--s-4);
  align-items: stretch;
}
.scan-frame {
  position: relative;
  width: 100%;
  max-width: 360px; margin: 0 auto;
  background: #0F172A;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
/* ⚠ 取景框尺寸必须跟着 video 走（下面的 video 保持原始比例），
   html5-qrcode 用 videoWidth/clientWidth、videoHeight/clientHeight 把「取景窗口 ↦ 视频采样区域」，
   这个换算只在画面等比映射时才成立。一旦给 video 固定高度或用 object-fit: cover/contain，
   采样区域就会整体放大并横向拉伸（4:3 画面进 1:1 框会被拉宽 1.33 倍），
   表现为「摄像头画面正常，但二维码怎么对都识别不出来」。
   所以：#qr-reader 只给宽度，video 用 width:100% + height:auto 保持原始比例，不许裁切。 */
.scan-frame #qr-reader { width: 100%; display: flex; align-items: center; }
.scan-frame #qr-reader video {
  width: 100% !important; height: auto !important;
  display: block;
}
.scan-frame .corner {
  position: absolute; width: 32px; height: 32px;
  border: 3px solid var(--brand);
}
.scan-frame .corner.tl { top: 16px; left: 16px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan-frame .corner.tr { top: 16px; right: 16px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.scan-frame .corner.bl { bottom: 16px; left: 16px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.scan-frame .corner.br { bottom: 16px; right: 16px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.scan-frame .scan-line {
  position: absolute; left: 16px; right: 16px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: scan-line 2.4s linear infinite;
}
@keyframes scan-line {
  0%, 100% { top: 32px; }
  50%      { top: calc(100% - 34px); }
}
.scan-frame .empty-state {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #94A3B8; font-size: 13px; padding: var(--s-5); text-align: center;
  gap: var(--s-2);
}
.scan-frame .empty-state svg { width: 48px; height: 48px; opacity: .4; }

.scan-tip {
  text-align: center; font-size: 12.5px; color: var(--text-3);
  margin-top: var(--s-2);
}
.scan-manual {
  display: flex; gap: var(--s-2);
  max-width: 360px; margin: 0 auto; width: 100%;
}

/* ---------------------------------------------------------------------
 * 公开追溯页（trace.html）
 * ------------------------------------------------------------------- */
.trace-page { min-height: 100vh; background: var(--bg); display: flex; flex-direction: column; }

/* 顶部品牌条 */
.trace-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: 14px var(--s-5);
  background: linear-gradient(120deg, var(--brand) 0%, var(--accent) 55%, var(--purple) 100%);
  color: #fff;
}
.trace-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.trace-mark {
  height: 32px; width: auto; max-width: 170px;
  object-fit: contain;
  display: block;
  flex: none;
  background: #fff;
  padding: 5px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.trace-brand-txt { min-width: 0; }
.trace-brand-name { font-weight: 600; font-size: 14.5px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trace-brand-sub { font-size: 11.5px; opacity: .82; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trace-verify {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
  padding: 5px 11px; border-radius: var(--r-pill); font-size: 12px; backdrop-filter: blur(4px);
}

/* 内容容器 */
.trace-wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: var(--s-5) var(--s-5) var(--s-8); flex: 1; }

/* 加载 / 错误 */
.trace-loading { text-align: center; padding: 72px 20px; color: var(--text-3); }
.trace-spin { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }

/* 公告 */
.trace-notice {
  border-left: 3px solid var(--brand); background: var(--brand-50);
  border-radius: var(--r); padding: 12px 14px; font-size: 13px; color: var(--brand-700);
  white-space: pre-wrap; line-height: 1.6; margin-bottom: var(--s-5);
}

/* 身份卡（产品概览） */
.t-idcard { margin-bottom: var(--s-5); padding: var(--s-5); }
.t-idcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.t-idcard-name { min-width: 0; }
.t-model { font-size: 21px; font-weight: 700; color: var(--text); line-height: 1.3; word-break: break-word; }
.t-serial { font-family: var(--font-mono); font-size: 13px; color: var(--brand); margin-top: 6px; word-break: break-all; }
.t-badges { display: flex; gap: 6px; flex-wrap: wrap; flex: none; }
.t-idcard-meta {
  margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--border);
  display: grid; gap: var(--s-3) var(--s-5);
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.t-kv { min-width: 0; }
.t-kv-k { font-size: 12px; color: var(--text-3); }
.t-kv-v { font-size: 14px; color: var(--text); margin-top: 3px; font-weight: 500; word-break: break-all; }
.t-kv-v.mono { font-family: var(--font-mono); font-size: 13px; }

/* 两栏布局 */
.trace-grid { display: grid; gap: var(--s-5); grid-template-columns: 1fr; }
.trace-col { display: flex; flex-direction: column; gap: var(--s-5); }

/* 规格列表 */
.t-spec { display: flex; flex-direction: column; }
.t-spec-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.t-spec-row:last-child { border-bottom: 0; }
.t-spec-row .k { color: var(--text-2); flex: none; }
.t-spec-row .v { color: var(--text); font-weight: 500; text-align: right; word-break: break-all; }

/* 电芯 */
.t-cells { display: flex; flex-wrap: wrap; gap: 8px; }
.t-cell { height: auto; padding: 8px 12px; font-size: 13px; }
.t-cell b { font-size: 14px; }
.t-cell i { color: var(--text-2); font-style: normal; font-size: 11.5px; margin-left: 4px; }

/* 时间线 */
.trace-timeline .tl-item { display: flex; gap: var(--s-4); padding: var(--s-3) 0; position: relative; }
.trace-timeline .tl-item:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 36px; bottom: -8px; width: 2px; background: var(--border); }
.trace-timeline .tl-dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-elev); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1;
}
.trace-timeline .tl-dot.ok     { border-color: var(--ok);     background: var(--ok-soft);    color: var(--ok); }
.trace-timeline .tl-dot.warn   { border-color: var(--warn);   background: var(--warn-soft);  color: var(--warn); }
.trace-timeline .tl-dot.info   { border-color: var(--info);   background: var(--info-soft);  color: var(--info); }
.trace-timeline .tl-dot.purple { border-color: var(--purple); background: var(--purple-soft);color: var(--purple); }
.trace-timeline .tl-body { flex: 1; min-width: 0; }
.trace-timeline .tl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.trace-timeline .tl-title { font-weight: 600; font-size: 14px; color: var(--text); }
.trace-timeline .tl-time { font-size: 12px; color: var(--text-3); flex: none; font-family: var(--font-mono); }
.trace-timeline .tl-desc { font-size: 13px; color: var(--text-2); margin-top: 3px; line-height: 1.6; }
.trace-timeline .tl-actor { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* 视频 */
.t-video { margin-bottom: 14px; }
.t-video:last-child { margin-bottom: 0; }
.t-video-title { font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.t-video video { width: 100%; border-radius: var(--r); background: #000; display: block; aspect-ratio: 16/9; }

/* 图片画廊 */
.t-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.t-img { text-decoration: none; color: inherit; }
.t-img img { width: 100%; height: 130px; object-fit: cover; border-radius: var(--r); border: 1px solid var(--border); background: var(--bg-soft); display: block; }
.t-img span { display: block; font-size: 12px; color: var(--text-2); margin-top: 6px; text-align: center; word-break: break-all; }

/* 文档列表 */
.t-doclist .row { text-decoration: none; color: inherit; border-radius: var(--r); border: 1px solid var(--border); }
.t-doclist .row .col.title { font-weight: 500; color: var(--text); }
.t-doclist .row .col.sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.t-doclist .row .go { color: var(--brand); font-weight: 600; font-size: 13px; flex: none; }

/* 页脚 */
.trace-foot {
  text-align: center; color: var(--text-3); font-size: 12px;
  padding: var(--s-5) var(--s-4);
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}

/* 桌面两栏 */
@media (min-width: 880px) {
  .trace-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
  .trace-wrap { padding-top: var(--s-6); }
  .t-gallery { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------------------------------------------------------------------
 * 响应式微调
 * ------------------------------------------------------------------- */
@media (max-width: 480px) {
  .home-hero { padding: var(--s-5); }
  .home-hero h1 { font-size: 18px; }
  .stat .value { font-size: 22px; }
  .trace-topbar { padding: 12px var(--s-4); }
  .trace-brand-sub { display: none; }
  .trace-mark { max-width: 130px; height: 28px; }
  .trace-wrap { padding: var(--s-4); }
  .t-model { font-size: 19px; }
}

/* 滚动条美化（Webkit） */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* focus-visible 键盘可达 */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
button:focus, input:focus, textarea:focus, select:focus { outline: none; }

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* =====================================================================
 * App 内容组件层（app.js 动态渲染专用）
 * 说明：app.js 用的是 badge / list-item / btn-mini / form-row / module-item /
 * grid-stats / kv / timeline 等类名，本层补齐其样式并按桌面端习惯优化。
 * ===================================================================== */

/* ---------- 卡片：默认留白，标题带分隔线 ---------- */
.card { padding: var(--s-4) var(--s-5); }
.card > .card-title {
  padding-bottom: var(--s-3);
  margin-bottom: var(--s-3);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
}
.card-title .badge { margin-left: 2px; }
.card > .card-title:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600; line-height: 1.6;
  white-space: nowrap; vertical-align: middle;
}

/* ---------- 通用文本 ---------- */
.mono { font-family: var(--font-mono); letter-spacing: .3px; }
.arrow { color: var(--text-3); font-size: 18px; line-height: 1; }

/* ---------- 按钮体系（app.js 直用类名，不带 .btn 基类） ---------- */
.btn-primary:not(.btn), .btn-ghost:not(.btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 var(--s-5);
  border-radius: var(--r);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.btn-primary:not(.btn) {
  background: var(--brand); color: var(--text-on-brand); border: 1px solid var(--brand);
}
.btn-primary:not(.btn):hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-primary:not(.btn):disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost:not(.btn) {
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
}
.btn-ghost:not(.btn):hover { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }

/* 小按钮 */
.btn-mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 34px; padding: 0 var(--s-4);
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text);
  font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.btn-mini:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.btn-mini:active { transform: translateY(1px); }
.btn-mini.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-mini.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-mini.green { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-mini.green:hover { background: #0DA271; border-color: #0DA271; }
.btn-mini.red { background: #FFF1F0; border-color: #FBCACA; color: var(--err); }
.btn-mini.red:hover { background: var(--err-soft); }
.btn-mini.ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-mini.ghost:hover { background: var(--bg-soft); color: var(--text); }

/* 浮层头部右侧按钮：旧代码写死白字（深色头部遗留），浅色头部下不可见，强制纠正 */
.overlay-right .btn-mini,
.overlay-right .btn-mini[style] {
  background: var(--brand-50) !important;
  color: var(--brand-700) !important;
  border: 1px solid var(--brand-100) !important;
}
.overlay-right .btn-mini:hover { background: var(--brand-100) !important; }

/* ---------- 搜索条 ---------- */
.search-bar { display: flex; gap: var(--s-2); align-items: center; max-width: 560px; }
.search-bar input {
  flex: 1; min-width: 0; height: 38px; padding: 0 var(--s-3);
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13.5px; outline: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.search-bar input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.search-bar button {
  flex-shrink: 0; height: 38px; padding: 0 var(--s-5);
  border-radius: var(--r); border: 1px solid var(--brand);
  background: var(--brand); color: #fff;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background var(--t-fast);
}
.search-bar button:hover { background: var(--brand-600); border-color: var(--brand-600); }

/* ---------- 统计卡片（.v 数字 / .l 标签） ---------- */
.grid-stats {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.grid-stats .stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  transition: box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.grid-stats .stat:hover { box-shadow: var(--shadow-sm); border-color: var(--brand-100); }
.grid-stats .stat .v { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.2; }
.grid-stats .stat .l { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- 模块入口（工作台 / 业务中心） ---------- */
/* 手机 2 列；桌面端列数由 JS 按模块数写入 --cols（取 1..4，尽量整除铺满不留空档） */
.module-grid {
  display: grid; gap: var(--s-3);
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
}
.module-item {
  display: flex; flex-direction: column; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer; user-select: none; text-align: center;
  transition: all var(--t-fast) var(--ease);
}
.module-item:hover {
  border-color: var(--brand-100);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  color: var(--brand-700);
}
.module-ico {
  width: 46px; height: 46px;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

/* ---------- 键值行 ---------- */
.kv {
  display: flex; align-items: baseline; gap: var(--s-4);
  padding: 9px 0;
}
.kv + .kv { border-top: 1px dashed var(--border); }
.kv .k { width: 104px; flex-shrink: 0; font-size: 12.5px; color: var(--text-3); }
.kv .v { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text); text-align: right; word-break: break-all; }
.kv .v.mono { font-size: 13px; }

/* ---------- 列表行 ---------- */
.list-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: background var(--t-fast);
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--bg-soft); }
.li-main { flex: 1; min-width: 0; }
.li-title {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  word-break: break-all;
}
.li-sub { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.55; word-break: break-all; }

/* ---------- 设备详情头部（渐变横幅） ---------- */
.dev-head {
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand) 55%, var(--accent) 100%);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-5) calc(var(--s-6) + 14px);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.dev-head::before {
  content: "";
  position: absolute; top: -60%; right: -8%;
  width: 55%; height: 220%;
  background: radial-gradient(circle, rgba(255,255,255,.14), transparent 62%);
  pointer-events: none;
}
.dev-head .dev-sn { font-size: 12.5px; opacity: .9; position: relative; }
.dev-head .dev-sn b {
  display: block; margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 19px; font-weight: 700; letter-spacing: .5px;
  word-break: break-all;
}
.dev-head .dev-status-line {
  margin-top: var(--s-3);
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  position: relative;
}
.dev-head + .card { margin-top: calc(-1 * (var(--s-6) + 2px)) !important; position: relative; }

/* ---------- 二维码盒子 ---------- */
.qr-box { display: flex; align-items: center; gap: var(--s-4); margin-top: var(--s-2); }
.qr-box img {
  width: 112px; height: 112px; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: #fff; padding: 6px;
}

/* ---------- 时间线 ---------- */
.timeline { padding-top: 2px; }
.timeline .tl-item { position: relative; padding: 0 0 var(--s-4) 26px; }
.timeline .tl-item:last-child { padding-bottom: 4px; }
.timeline .tl-item:not(:last-child)::before {
  content: "";
  position: absolute; left: 5px; top: 14px; bottom: 2px;
  width: 2px; background: var(--border);
}
.timeline .tl-dot {
  position: absolute; left: 0; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px var(--bg-elev), 0 0 0 4px var(--border);
}
.timeline .tl-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.timeline .tl-time { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 8px; }
.timeline .tl-desc { font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.6; }
.timeline .tl-actor { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- 底部操作栏（吸附，不随滚动消失） ---------- */
.action-bar {
  position: sticky; bottom: 0;
  display: flex; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-4) 0 var(--s-2);
  margin-top: var(--s-4);
  background: linear-gradient(to top, var(--bg) 78%, transparent);
}
.action-bar .btn-mini {
  flex: 1; min-width: 140px; height: 44px;
  font-size: 14px; border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

/* ---------- 表单 ---------- */
.form-row { margin-bottom: var(--s-4); }
.form-row > label {
  display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2);
  margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%; height: 38px; padding: 0 var(--s-3);
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--r);
  font-size: 13.5px; outline: none;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.form-row textarea { height: auto; min-height: 76px; padding: var(--s-3); resize: vertical; line-height: 1.6; }
.form-row input:hover, .form-row select:hover, .form-row textarea:hover { border-color: var(--border-strong); }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50);
}
.form-row input[type="file"] { padding-top: 7px; height: auto; min-height: 38px; font-size: 12.5px; }
.form-static {
  padding: 10px var(--s-3);
  background: var(--bg-soft); border-radius: var(--r);
  font-size: 13px; color: var(--text-2);
}
.req { color: var(--err); margin-left: 2px; }

/* 表单底部按钮：桌面端习惯「取消在左、主操作在右」 */
.form-actions {
  display: flex; gap: var(--s-3);
  padding-top: var(--s-4); margin-top: var(--s-2);
  border-top: 1px solid var(--border);
}
.form-actions button { min-width: 110px; }
.form-actions #f-ok { flex: 1; }
@media (min-width: 768px) {
  .form-actions { justify-content: flex-end; }
  .form-actions #f-ok { flex: 0 1 auto; min-width: 140px; }
}

/* ---------- 勾选项（质检检查项） ---------- */
.checks { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.check-item {
  padding: 7px 14px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--bg-elev); color: var(--text-2);
  font-size: 12.5px; cursor: pointer; user-select: none;
  transition: all var(--t-fast);
}
.check-item:hover { border-color: var(--border-strong); color: var(--text); }
.check-item.on {
  background: var(--brand-50); border-color: var(--brand);
  color: var(--brand-700); font-weight: 600;
}

/* ---------- 单选选项（修复/报废、启用/停用） ---------- */
.radio-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.radio-opt {
  padding: 10px var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-elev); color: var(--text-2);
  font-size: 13px; text-align: center; cursor: pointer; user-select: none;
  transition: all var(--t-fast);
}
.radio-opt:hover { border-color: var(--border-strong); }
.radio-opt.on {
  border-color: var(--brand); background: var(--brand-50);
  color: var(--brand-700); font-weight: 600;
}

/* ---------- 多选权限组 ---------- */
.cb-group { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- 电芯池 / 电芯行 ---------- */
.cell-pool {
  max-height: 260px; overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  padding: var(--s-2);
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-soft);
}
.cell-chip {
  padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--r-pill);
  background: var(--bg-elev); color: var(--text-2);
  font-size: 12px; font-family: var(--font-mono);
  cursor: pointer; user-select: none;
  transition: all var(--t-fast);
}
.cell-chip:hover { border-color: var(--brand-100); color: var(--text); }
.cell-chip.on {
  background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600;
}
.cell-tag {
  display: inline-block; padding: 1px 7px; margin-left: 4px;
  border-radius: var(--r-sm);
  background: var(--bg-soft); color: var(--text-2);
  font-size: 11px; font-weight: 500;
}
.cell-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.cell-row:last-of-type { border-bottom: 0; }
.cell-main { flex: 1; min-width: 0; font-size: 13.5px; }
.cell-main b { font-family: var(--font-mono); }
.cell-force {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: 12.5px; color: var(--text-2);
  margin-top: var(--s-2); cursor: pointer;
}
.cell-force input { width: auto; }

/* ---------- 零件行 / 资料行 ---------- */
.part-row, .doc-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.part-row:last-of-type, .doc-row:last-of-type { border-bottom: 0; }
.part-main { flex: 1; min-width: 0; font-size: 13.5px; }
.part-kv { font-size: 12px; color: var(--text-3); margin-top: 2px; word-break: break-all; }
.part-sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 4px; }
.doc-ico { font-size: 20px; flex-shrink: 0; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); border-radius: var(--r); }
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-size: 13.5px; font-weight: 600; color: var(--text); word-break: break-all; }
.doc-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.doc-upload-row {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  margin-top: var(--s-3); padding-top: var(--s-3);
  border-top: 1px dashed var(--border);
}

/* ---------- 我的页 ---------- */
.me-card { text-align: center; padding: var(--s-6) var(--s-5); }
.me-avatar {
  width: 64px; height: 64px; margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700;
}
.me-name { font-size: 17px; font-weight: 700; margin-top: var(--s-3); }
.me-role { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.cell {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-1);
  cursor: pointer; border-radius: var(--r);
  transition: background var(--t-fast);
}
.cell:hover { background: var(--bg-soft); }
.cell:hover .arrow { color: var(--err); }
.cell div div { font-size: 13.5px; font-weight: 500; color: var(--err); }
/* 普通功能入口（如「修改登录密码」）：不套用退出登录的危险红 */
.cell.safe div div { color: var(--text); }
.cell.safe:hover .arrow { color: var(--brand); }

/* ---------- 扫码页 ---------- */
.scan-page { display: flex; flex-direction: column; gap: var(--s-4); align-items: stretch; }
.scan-page .scan-manual {
  flex-direction: column; align-items: stretch;
  max-width: 460px; width: 100%; margin: 0 auto;
}

/* ---------- Toast 错误态 ---------- */
.toast.err { background: rgba(239,68,68,.95); }

/* ---------- 响应式微调 ---------- */
@media (max-width: 767px) {
  /* 手机上统计卡固定两列，避免过挤 */
  .grid-stats { grid-template-columns: repeat(2, 1fr) !important; }
  .kv .k { width: 92px; }
  .card { padding: var(--s-4); }
}

/* ---------- 工作台布局（数据看板 + 业务模块） ----------
 * 原「全局动态 / 我的动态」卡片已移除（日志仅后端留存）。
 * 宽屏下看板与模块左右分栏：左侧看板固定宽度，右侧模块卡片铺满剩余宽度，不留空档。 */
.home-split { display: grid; gap: var(--s-4); align-items: start; }
@media (min-width: 1180px) {
  .home-split {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: var(--s-5);
  }
}

/* ---------- 桌面端操作习惯优化 ---------- */
@media (min-width: 1024px) {
  /* 浮层内容限宽居中，避免全屏拉伸 */
  .overlay-body { padding: var(--s-6) var(--s-8) var(--s-8); }
  .overlay-body > * { max-width: 980px; margin-left: auto; margin-right: auto; }
  /* 主区内容同样限宽居中 */
  .main { max-width: 1280px; margin: 0 auto; width: 100%; }
  /* 模块磁贴放大；桌面 4 个一排并居中换行（末行自动居中，不再左偏） */
  .module-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-4); }
  .module-item {
    flex: 0 1 calc((100% - 3 * var(--s-4)) / 4);
    max-width: calc((100% - 3 * var(--s-4)) / 4);
    padding: var(--s-5) var(--s-4); font-size: 14px;
  }
  .module-ico { width: 52px; height: 52px; font-size: 25px; }
  /* 操作栏按钮不再平分宽度 */
  .action-bar { justify-content: flex-end; }
  .action-bar .btn-mini { flex: 0 1 auto; min-width: 160px; }
  /* 状态筛选 chips 桌面端换行展示（横向滚动是手机习惯） */
  .chips { flex-wrap: wrap; overflow-x: visible; padding-bottom: 0; }
  .search-bar { max-width: 480px; }
}

/* ---------- 各环节附件（生产批次 / 质检记录 / 库存流水 / 销售订单 / 维修工单 通用） ---------- */
.attach-line { margin-top: var(--s-2); display: flex; }

.att-btn { white-space: nowrap; }
.att-btn.has { background: var(--brand-50); color: var(--brand); border: 1px solid var(--brand-100); }
.att-btn b { font-weight: 700; }

.att-head {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin: var(--s-5) 0 var(--s-1); padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

.att-row {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px dashed var(--border);
}
.att-row:last-child { border-bottom: 0; }
.att-ico {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--bg-soft); border-radius: var(--r);
}
.att-main { flex: 1; min-width: 0; }
.att-title { font-size: 13.5px; font-weight: 600; word-break: break-all; line-height: 1.4; }
.att-meta { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.att-cat {
  display: inline-block; background: var(--brand-50); color: var(--brand);
  border-radius: 4px; padding: 0 6px; margin-right: 6px; font-size: 11px;
}
.att-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }
/* 「下载」是 <a>，补掉链接默认下划线 */
.att-acts a.btn-mini, .att-prev-foot a.btn-mini { text-decoration: none; }
.att-tip { font-size: 11.5px; color: var(--text-3); line-height: 1.6; margin: 0 0 var(--s-2); }

.att-preview { padding: 0 0 var(--s-4); }
.att-preview img { max-width: 100%; border-radius: var(--r); display: block; }
.att-preview video { width: 100%; max-height: 60vh; border-radius: var(--r); background: #000; display: block; }
.att-preview audio { width: 100%; }
.att-preview iframe { width: 100%; height: 62vh; border: 1px solid var(--border); border-radius: var(--r); background: #fff; }
.att-noprev {
  font-size: 12.5px; color: var(--text-3); background: var(--bg-soft);
  border-radius: var(--r); padding: var(--s-4); text-align: center;
}
.att-prev-foot { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-2); font-size: 11.5px; color: var(--text-3); }
.att-prev-foot .mono { word-break: break-all; }

/* 窄屏：附件行按钮换行到下方，避免挤掉标题 */
@media (max-width: 480px) {
  .att-row { flex-wrap: wrap; }
  .att-acts { width: 100%; justify-content: flex-start; padding-left: 46px; }
}

/* ================= 模板库：模板管理 / 在线填写 ================= */
.tpl-item {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) 0; border-bottom: 1px dashed var(--border);
}
.tpl-item:last-child { border-bottom: 0; }
.tpl-ico {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: #E6F7F0; border-radius: var(--r);
}
.tpl-main { flex: 1; min-width: 0; }
.tpl-name { font-size: 13.5px; font-weight: 600; line-height: 1.4; word-break: break-all; }
.tpl-name .badge { margin-left: 6px; font-weight: 500; }
.tpl-sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.tpl-item > .btn-mini { flex: 0 0 auto; }

/* 板块顶部「📋 可用模板」条（进入模块即可见） */
.tpl-bar { background: linear-gradient(180deg, #F2FBF6 0%, #FFFFFF 100%); border-color: #CFEBDF; }
.tpl-bar .card-title { margin-bottom: 2px; }
.tpl-bar-tip { font-weight: 400; font-size: 11.5px; color: var(--text-3); margin-left: 6px; }
.tpl-bar > .tpl-item:first-of-type { margin-top: 6px; }

/* 字段编辑器（导入模板时定义在线表单字段） */
.tpl-fields { display: flex; flex-direction: column; gap: 8px; }
.tpl-field {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r); padding: 8px 10px;
}
.tpl-field .tf-label { flex: 1 1 140px; min-width: 110px; }
.tpl-field .tf-type  { flex: 0 0 108px; }
.tpl-field .tf-opts  { flex: 1 1 100%; }
.tpl-field input, .tpl-field select { height: 34px; font-size: 13px; }
.tpl-field .tf-req {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
  font-size: 12.5px; color: var(--text-2); white-space: nowrap; cursor: pointer;
}
.tpl-field .tf-req input { width: auto; height: auto; margin: 0; flex: 0 0 auto; }
.tpl-field .tf-del {
  flex: 0 0 auto; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 6px; background: #FDECEC; color: #F5484D;
  font-size: 13px; line-height: 1; cursor: pointer;
}
.tpl-field .tf-del:hover { background: #FBD9D9; }

@media (max-width: 480px) {
  .tpl-item { flex-wrap: wrap; }
  .tpl-item > .btn-mini { margin-left: auto; }
  .tpl-field .tf-label { flex-basis: 100%; }
}