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

/* hidden 属性全局生效：防止 .modal/.login-wrap 等 display 规则覆盖默认的 [hidden]{display:none} */
[hidden] {
  display: none !important;
}

/* 主界面浅色主题（对齐 zdbms.cn / Element Plus） */
:root {
  --primary: #409eff;
  --bg: #f0f2f5;
  --bg-card: #ffffff;
  --bg-card-2: #f5f7fa;
  --border: #ebeef5;
  --text: #303133;
  --text-secondary: #606266;
  --text-dim: #909399;
  --green: #67c23a;
  --blue: #409eff;
  --cyan: #38bdf8;
  --orange: #e6a23c;
  --red: #f56c6c;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  min-height: 100vh;
}

/* ============ 登录（保持深色现状，不动） ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0a0e14;
}
.login-card {
  background: #11161f;
  border: 1px solid #1f2937;
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-title {
  font-size: 20px;
  text-align: center;
  margin-bottom: 8px;
  color: #e6edf3;
}
.login-card .input {
  height: 44px;
  background: #161d28;
  border: 1px solid #1f2937;
  border-radius: 8px;
  color: #e6edf3;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
}
.login-card .input:focus {
  border-color: #00e676;
}
.login-error {
  color: #ef4444;
  font-size: 13px;
  min-height: 18px;
}

/* ============ 通用按钮 / 输入 ============ */
.btn {
  height: 44px;
  border-radius: 8px;
  border: none;
  font-size: 15px;
  cursor: pointer;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  filter: brightness(1.05);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 0 16px;
  height: 36px;
  font-size: 13px;
  border-radius: 6px;
}
.btn-ghost:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.input {
  height: 40px;
  background: var(--bg-card);
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}
.input:focus {
  border-color: var(--primary);
}

/* ============ 整体布局：深色侧边栏 + 右侧 ============ */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* 侧边栏 */
.aside {
  width: 220px;
  background: linear-gradient(#001529 0%, #001f3f 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}
.logo {
  cursor: pointer;
  background: linear-gradient(90deg, rgba(64, 158, 255, 0.1) 0%, rgba(0, 0, 0, 0) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  justify-content: center;
  align-items: center;
  gap: 10px;
  height: 64px;
  display: flex;
  flex-shrink: 0;
}
.logo-icon {
  color: #fff;
  background: linear-gradient(135deg, #409eff 0%, #667eea 100%);
  border-radius: 8px;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  display: flex;
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}
.logo-icon svg {
  width: 18px;
  height: 18px;
}
.logo-text {
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
  display: flex;
  overflow: hidden;
}
.company-name {
  color: #fff;
  letter-spacing: 1px;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
}
.system-name {
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 1px;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  overflow: hidden;
}
.sidebar-menu {
  list-style: none;
  padding: 12px 0;
  flex: 1;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  margin: 4px 12px;
  padding: 0 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}
.menu-item:hover {
  color: rgba(255, 255, 255, 0.85);
  background: rgb(0, 17, 33);
}
.menu-item.active {
  color: #fff;
  background: var(--primary);
}
/* 父菜单箭头（CSS 三角），展开时旋转朝下 */
.menu-parent .menu-arrow {
  margin-left: auto;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgba(255, 255, 255, 0.5);
  transition: transform 0.3s;
  flex-shrink: 0;
}
.menu-group.open > .menu-parent .menu-arrow {
  transform: rotate(180deg);
}
/* 子菜单：默认收起，父项 open 时展开 */
.submenu {
  list-style: none;
  padding: 0;
  display: none;
}
.menu-group.open > .submenu {
  display: block;
}
/* 子菜单项：无图标，左缩进对齐父项文字，稍矮 */
.submenu .menu-item {
  height: 36px;
  margin: 2px 12px;
  padding: 0 14px 0 44px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
}
.menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.menu-icon svg {
  width: 20px;
  height: 20px;
}
.sidebar-footer {
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  display: flex;
  margin: 0 auto 20px;
  transition: all 0.3s;
}
.sidebar-footer:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* 右侧容器 */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶栏 */
.header {
  background: #fff;
  border-bottom: 1px solid #ebeef5;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: center;
  height: 64px;
  padding: 0 24px;
  display: flex;
  box-shadow: 0 2px 8px rgba(0, 21, 41, 0.06);
}
.header-left {
  flex: 1;
  align-items: center;
  gap: 16px;
  display: flex;
}
.header-title {
  color: #303133;
  font-size: 16px;
  font-weight: 600;
}
.header-center {
  flex: 1;
  justify-content: center;
  display: flex;
}
.sidebar-toggle {
  cursor: pointer;
  color: #606266;
  background: #f5f7fa;
  border: none;
  border-radius: 6px;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  display: flex;
  font-size: 16px;
  transition: all 0.3s;
}
.sidebar-toggle:hover {
  color: #409eff;
  background: #e4e7ed;
}
.breadcrumb {
  color: #909399;
  font-size: 14px;
  font-weight: 400;
}
.header-right {
  flex: 1;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  display: flex;
}
.notification {
  position: relative;
}
.icon-btn {
  cursor: pointer;
  background: #f5f7fa;
  border: none;
  border-radius: 50%;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  display: flex;
  font-size: 16px;
  transition: all 0.3s;
  position: relative;
}
.icon-btn:hover {
  color: #409eff;
  background: #e4e7ed;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #f56c6c;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  line-height: 1;
  padding: 3px 5px;
  transform: translate(30%, -30%);
}
.user-dropdown {
  position: relative;
  cursor: pointer;
}
.user-info {
  align-items: center;
  gap: 10px;
  display: flex;
}
.user-avatar {
  background: #409eff;
  color: #fff;
  border-radius: 50%;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  display: flex;
  font-size: 15px;
}
.user-detail {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.user-name {
  color: #303133;
  font-size: 14px;
  font-weight: 500;
}
.user-role-label {
  color: #909399;
  font-size: 12px;
}
.user-arrow {
  color: #909399;
  font-size: 12px;
  transition: transform 0.2s;
}
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 21, 41, 0.12);
  min-width: 160px;
  padding: 6px 0;
  z-index: 1000;
}
.user-menu-item {
  color: #606266;
  font-size: 14px;
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.user-menu-item:hover {
  color: #409eff;
  background: #f5f7fa;
}
.user-menu-divider {
  height: 1px;
  background: #ebeef5;
  margin: 6px 0;
}

/* 内容区 */
.main {
  flex: 1;
  background: #f0f2f5;
  padding: 20px 20px 48px;
  overflow-y: auto;
}
.page {
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 21, 41, 0.06);
  padding: 20px;
}
.card-header {
  justify-content: space-between;
  align-items: center;
  display: flex;
  margin-bottom: 16px;
}
.card-title {
  color: #303133;
  font-size: 16px;
  font-weight: 600;
}
.btn-mini {
  cursor: pointer;
  color: #409eff;
  background: transparent;
  border: 1px solid #409eff;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-mini:hover {
  color: #fff;
  background: #409eff;
}

/* 表格操作列链接按钮（对齐 Element Plus is-link 文字样式） */
.link-btn {
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}
.link-btn.primary { color: #409eff; }
.link-btn.warning { color: #e6a23c; }
.link-btn.danger { color: #f56c6c; }
.link-btn.info { color: #909399; }
.link-btn:hover { text-decoration: underline; }

/* ============ 主页：KPI 卡片 ============ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0, 21, 41, 0.06);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}
.stat-card.alarm::before { background: linear-gradient(#f56c6c 0%, #e64980 100%); }
.stat-card.online::before { background: linear-gradient(#67c23a 0%, #52c41a 100%); }
.stat-card.offline::before { background: linear-gradient(#909399 0%, #6b7280 100%); }
.stat-card.fault::before { background: linear-gradient(#e6a23c 0%, #d48806 100%); }
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.stat-content {
  align-items: center;
  gap: 16px;
  display: flex;
}
.stat-icon {
  border-radius: 12px;
  justify-content: center;
  align-items: center;
  width: 56px;
  height: 56px;
  display: flex;
  flex-shrink: 0;
}
.stat-icon svg {
  width: 26px;
  height: 26px;
}
.stat-card.alarm .stat-icon { background: rgba(245, 108, 108, 0.12); color: #f56c6c; }
.stat-card.online .stat-icon { background: rgba(103, 194, 58, 0.12); color: #67c23a; }
.stat-card.offline .stat-icon { background: rgba(144, 147, 153, 0.12); color: #909399; }
.stat-card.fault .stat-icon { background: rgba(230, 162, 60, 0.12); color: #e6a23c; }
.stat-info {
  flex: 1;
}
.stat-value {
  color: #303133;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  font-family: 'DIN Alternate', 'Roboto Mono', monospace;
}
.stat-label {
  color: #909399;
  margin-top: 4px;
  font-size: 14px;
}

/* 主页网格：地图 + 报警统计 + 快捷操作 */
.home-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
.map-card {
  grid-row: span 2;
  min-height: 420px;
}
.alarm-card {
  min-height: 200px;
}
.quick-card {
  min-height: 200px;
}
.quick-actions {
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  display: grid;
}
.quick-btn {
  cursor: pointer;
  background: #f5f7fa;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  height: 56px;
  color: #606266;
  font-size: 14px;
  transition: all 0.3s;
}
.quick-btn:hover {
  color: #409eff;
  border-color: #409eff;
  background: #ecf5ff;
}

/* 报警统计饼图 */
.alarm-chart {
  min-height: 180px;
}
.alarm-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.alarm-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #606266;
}
.alarm-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alarm-legend-name {
  flex: 1;
}
.alarm-legend-val {
  color: #303133;
  font-weight: 600;
}
.alarm-legend-pct {
  color: #909399;
  width: 40px;
  text-align: right;
}
.alarm-total {
  text-align: center;
  font-size: 13px;
  color: #909399;
  margin-bottom: 8px;
}
.alarm-empty-tip {
  text-align: center;
  font-size: 13px;
  color: #c0c4cc;
  padding: 16px 0;
}

/* ============ 地图 ============ */
.map {
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card-2);
  position: relative;
  z-index: 0; /* 锁定 Leaflet 内部 pane 的高 z-index(400~800)，避免盖过移动端抽屉侧边栏 */
}
.map-large {
  height: calc(100vh - 140px);
}
.map-fallback {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ============ 工具栏 / 设备列表 ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.search-input {
  flex: 1;
  max-width: 360px;
}
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.filter-toggle input {
  accent-color: var(--primary);
}
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.section-title {
  font-size: 16px;
  font-weight: 600;
}
.section-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.devices {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.customer-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.customer-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.customer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}
.customer-count {
  font-size: 12px;
  color: var(--text-dim);
}
.customer-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.device-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.device-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.15);
}
.device-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.device-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.device-del {
  background: transparent;
  border: 1px solid rgba(245, 108, 108, 0.4);
  color: var(--red);
  border-radius: 6px;
  font-size: 12px;
  padding: 2px 10px;
  cursor: pointer;
}
.device-del:hover {
  background: rgba(245, 108, 108, 0.12);
}
.device-serial {
  font-weight: 600;
  font-size: 15px;
}
.badge-alarm {
  color: var(--red);
  background: rgba(245, 108, 108, 0.12);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
}
.loc-src {
  display: inline-block;
  font-style: normal;
  font-size: 10px;
  line-height: 1;
  border-radius: 4px;
  padding: 2px 5px;
  margin-right: 4px;
  vertical-align: 1px;
}
.loc-src-gps { color: #38bdf8; background: rgba(56, 189, 248, 0.14); }
.loc-src-lbs { color: #e6a23c; background: rgba(230, 162, 60, 0.14); }
.device-name {
  color: var(--text-secondary);
  font-size: 13px;
}
.device-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  background: var(--bg-card-2);
  border-radius: 8px;
  padding: 10px 4px;
}
.m-k {
  font-size: 11px;
  color: var(--text-dim);
}
.m-v {
  font-size: 15px;
  font-weight: 600;
  font-family: 'DIN Alternate', 'Roboto Mono', monospace;
}
.device-status {
  font-size: 13px;
}
.device-foot {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.device-foot .loc {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
  word-break: break-all;
}
.device-foot .time {
  flex-shrink: 0;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px;
}
.placeholder-card {
  text-align: center;
  color: var(--text-dim);
  padding: 80px 20px;
  font-size: 15px;
}

/* ============ 弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 860px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text);
}
.report-head,
.report-row {
  display: grid;
  grid-template-columns: 150px 60px 70px 70px 60px 60px 130px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.report-head {
  padding: 10px 20px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-2);
}
.report-row {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.report-row:last-child {
  border-bottom: none;
}
.r-time {
  color: var(--text);
}
.r-soc,
.r-v,
.r-c {
  font-family: 'DIN Alternate', 'Roboto Mono', monospace;
}
.r-alarm {
  color: var(--red);
}
.r-loc {
  color: var(--text-dim);
  font-size: 11px;
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
}
.detail-map {
  height: 260px;
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.report-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}
.detail-loading {
  padding: 32px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ============ 固件管理 ============ */
.fw-panel {
  max-width: 720px;
}
.fw-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}
.fw-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.fw-row {
  display: flex;
  gap: 12px;
}
.fw-row .input {
  flex: 1;
}
.fw-upload {
  align-items: center;
}
.fw-upload input[type='file'] {
  flex: 1;
  color: var(--text-secondary);
  font-size: 13px;
}
.fw-upload-btn {
  height: 40px;
  padding: 0 20px;
}
.fw-msg {
  font-size: 13px;
  min-height: 18px;
  color: var(--text-secondary);
}
.fw-msg.ok {
  color: var(--green);
}
.fw-msg.err {
  color: var(--red);
}
.fw-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fw-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.fw-item-main {
  flex: 1;
  min-width: 0;
}
.fw-item-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  flex-wrap: wrap;
}
.fw-tag {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 6px;
}
.fw-tag-sw {
  margin-left: 0;
}
.fw-sw {
  color: var(--primary);
  font-weight: 600;
  font-family: 'DIN Alternate', 'Roboto Mono', monospace;
}
.fw-item-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.fw-del {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(245, 108, 108, 0.4);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.fw-del:hover {
  background: rgba(245, 108, 108, 0.12);
}

/* 固件弹窗标签页 */
.fw-tabs {
  display: flex;
  gap: 6px;
}
.fw-tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
}
.fw-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}

/* 网关升级包 */
.gw-send-row {
  align-items: center;
}
.gw-send-label {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.gw-target {
  flex: 1;
  cursor: pointer;
}
/* 型号下拉：不抢文件输入框的宽度，但要够放 "Air8000A (LuatOS)" */
.gw-model {
  flex: 0 0 auto;
  cursor: pointer;
}
/* 老包的型号标签：model 为空（加列之前上传的），提醒别把它当成当前型号的包 */
.gw-tag-nomodel {
  color: var(--orange);
}
.gw-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.gw-send-btn {
  height: 32px;
  padding: 0 14px;
  font-size: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.gw-send-btn:hover {
  filter: brightness(1.1);
}
.gw-item-note {
  color: var(--text-secondary);
}

/* ============ BMS 升级进度条 ============ */
.ota-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ota-progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}
.ota-pct {
  font-family: 'DIN Alternate', 'Roboto Mono', monospace;
  color: var(--text);
}
.ota-bar {
  height: 10px;
  background: var(--bg-card-2);
  border-radius: 6px;
  overflow: hidden;
}
.ota-bar-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 6px;
  transition: width 0.3s ease;
}
.ota-status {
  font-size: 14px;
  text-align: center;
  padding: 8px;
  color: var(--text-secondary);
}
.ota-status.ok { color: #16a34a; font-weight: 600; }
.ota-status.err { color: var(--red); font-weight: 600; }

/* 移动端侧边栏遮罩（默认隐藏，仅 ≤768px 生效） */
.aside-mask {
  display: none;
}

/* ============ 移动端 ============ */
@media (max-width: 768px) {
  /* 侧边栏滑出抽屉 */
  .aside {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  .aside.open {
    transform: none;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  .aside-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
  }
  .aside-mask.show {
    opacity: 1;
    pointer-events: auto;
  }

  /* 顶栏：收窄高度，隐藏面包屑与用户文字，只留头像 */
  .header {
    height: 56px;
    padding: 0 12px;
  }
  .header-center {
    display: none;
  }
  .header-left {
    gap: 10px;
  }
  .header-title {
    font-size: 15px;
  }
  .user-detail,
  .user-arrow {
    display: none;
  }
  .header-right {
    gap: 10px;
  }

  /* 内容区与卡片 */
  .main {
    padding: 12px 12px 48px;
  }
  .card {
    padding: 12px;
  }

  /* 工具栏换行，搜索框占满一行 */
  .toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  .search-input {
    max-width: none;
    flex-basis: 100%;
  }

  /* KPI 卡片：两列 + 缩小字号 */
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-card {
    padding: 14px;
  }
  .stat-icon {
    width: 44px;
    height: 44px;
  }
  .stat-icon svg {
    width: 22px;
    height: 22px;
  }
  .stat-value {
    font-size: 24px;
  }
  .stat-content {
    gap: 10px;
  }

  /* 主页网格单列 */
  .home-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .map-card {
    grid-row: auto;
    min-height: 260px;
  }
  .customer-cards {
    grid-template-columns: 1fr;
  }

  /* 定位地图高度 */
  .map-large {
    height: 55vh;
  }

  /* BMS：6 列指标 → 2 列，4 列参数 → 2 列 */
  .bms-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .bms-param-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* 弹窗：近全屏 + 表单竖排 */
  .modal {
    padding: 8px;
  }
  .modal-panel {
    max-width: 100%;
    max-height: 92vh;
  }
  .fw-row {
    flex-direction: column;
  }
  .fw-row .input,
  .fw-row select {
    width: 100%;
    flex: none;
  }
  .fw-upload input[type='file'] {
    width: 100%;
  }

  /* 详情弹窗内上报轨迹表横向滚动 */
  .report-head {
    overflow-x: auto;
  }
  .report-head,
  .report-row {
    min-width: 600px;
  }
  .detail-map {
    height: 200px;
  }

  /* 分页居中换行 */
  .pager {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ============ 系统管理：用户管理 ============ */
.table-wrap {
  overflow-x: auto;
}
.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.user-table th,
.user-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.user-table thead th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  background: var(--bg-card-2);
}
.user-table tbody tr:hover {
  background: var(--bg-card-2);
}
.user-ops {
  display: flex;
  gap: 8px;
  align-items: center;
}
.role-tag {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
}
.role-tag.admin {
  color: var(--primary);
  background: rgba(64, 158, 255, 0.12);
}
.role-tag.consumer {
  color: var(--text-secondary);
  background: rgba(144, 147, 153, 0.12);
}
.role-tag.enabled {
  color: #67c23a;
  background: rgba(103, 194, 58, 0.12);
}
.role-tag.disabled {
  color: #909399;
  background: rgba(144, 147, 153, 0.12);
}
/* 告警高级别用红色。注意 .role-tag.disabled 是灰色 —— 不能拿它当「高」，那个语义是反的 */
.role-tag.danger {
  color: var(--red);
  background: rgba(245, 108, 108, 0.12);
}
/* 归属/续费关联不上时的提示标签（让「数据没接上」在界面上看得见，而不是留空） */
.tag-warn {
  display: inline-block;
  color: var(--orange);
  background: rgba(230, 162, 60, 0.12);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}
.cell-sub {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 4px;
}
.cell-expired {
  color: var(--red);
}
/* 待标识（尚未读到 Bms_id）：只做标注，**不隐藏编号** —— 编号是管理员把台机器对上号的唯一线索 */
.cell-pending {
  color: #e6a23c;
  cursor: help;
  border-bottom: 1px dashed #e6a23c;
}

/* 设备合并弹窗 */
.merge-info {
  padding: 8px 10px;
  margin-bottom: 10px;
  background: #f5f7fa;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.6;
}
.merge-info code {
  padding: 1px 4px;
  background: #eef1f6;
  border-radius: 3px;
}
.merge-label {
  display: block;
  font-size: 12px;
  color: var(--text-sub, #909399);
  margin: 6px 0 4px;
}
.merge-candidates {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #ebeef5;
  border-radius: 4px;
}
.merge-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  border-bottom: 1px solid #f5f7fa;
  cursor: pointer;
}
.merge-item:last-child { border-bottom: none; }
.merge-item:hover { background: #fafbfc; }
.merge-serial { flex: 1; }
.merge-serial code { color: var(--text-sub, #606266); }
.merge-meta { font-size: 12px; color: var(--text-sub, #909399); }
.merge-empty { padding: 12px; font-size: 13px; color: var(--text-sub, #909399); }

/* 设备详情：最新一条上报的参数面板（设备端只上报聚合值，没接 BMS 时后端存 NULL → 显示 —） */
.detail-params {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card-2);
  flex-shrink: 0;
}
.param-group {
  min-width: 190px;
}
.param-title {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.param-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
}
.param-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  min-width: 0;
}
.param-k {
  color: var(--text-dim);
  white-space: nowrap;
}
.param-v {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 分组标题旁的小字：「保留」/「共 N 个」 */
.param-sub {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.75;
}
/* 逐节电压 / 各点温度的格子图 */
.cell-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 440px;
}
.cell-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
  padding: 4px 6px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: #67c23a;
  font-size: 11px;
  line-height: 1.25;
}
.cell-idx { font-size: 10px; opacity: 0.65; }
.cell-val { font-weight: 600; }
/* 偏离平均 20mV 以上：偏高的标红、偏低的标蓝，其余绿色 */
.cell-box.high { color: var(--red); border-color: rgba(245, 108, 108, 0.4); }
.cell-box.low { color: #409eff; border-color: rgba(64, 158, 255, 0.4); }
/* 逐节明细还没数据时的说明（保留位）—— 虚线框表示「位置留好了，等设备端上报」 */
.cell-empty {
  max-width: 440px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}
/* 告警处理弹窗顶部的告警信息摘要 */
.alarm-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.me-tag {
  color: var(--primary);
  font-size: 12px;
}
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.pager-total {
  color: #909399;
  font-size: 13px;
  margin-right: 8px;
}
.pager-btn {
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
  border-radius: 4px;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  font-size: 13px;
  transition: all 0.2s;
}
.pager-btn:hover {
  color: #409eff;
  border-color: #409eff;
}
.pager-btn.active {
  color: #fff;
  background: #409eff;
  border-color: #409eff;
}
.wallet-balance {
  color: #303133;
  font-size: 14px;
  margin-right: 8px;
}
.wallet-balance b {
  color: #f56c6c;
  font-size: 18px;
}
.text-success { color: #67c23a; }
.text-danger { color: #f56c6c; }
.toolbar-label { color: #606266; font-size: 14px; }
.bms-metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.bms-metric { background: #f5f7fa; border-radius: 8px; padding: 16px; text-align: center; }
.bms-metric span { display: block; color: #909399; font-size: 13px; margin-bottom: 6px; }
.bms-metric b { color: #303133; font-size: 22px; font-weight: 600; }
.bms-param-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.bms-param { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #f5f7fa; border-radius: 6px; }
.bms-param span { color: #909399; font-size: 13px; }
.bms-param b { color: #303133; font-size: 14px; font-weight: 500; }
.bms-switches { display: flex; flex-wrap: wrap; gap: 12px; }
.bms-switch { display: flex; align-items: center; gap: 10px; background: #f5f7fa; padding: 10px 16px; border-radius: 8px; }
.bms-switch span { color: #606266; font-size: 14px; }
.switch { cursor: pointer; border: none; border-radius: 14px; padding: 4px 14px; font-size: 13px; transition: all 0.2s; }
.switch.on { background: #409eff; color: #fff; }
.switch.off { background: #dcdfe6; color: #606266; }
.protect-tag { font-size: 13px; color: #f56c6c; }
.protect-tag.ok { color: #67c23a; }
.bms-cells { color: #909399; font-size: 14px; padding: 8px 0; }
.icp-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 5px 0;
  background: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  z-index: 9999;
}
.icp-footer a { color: #909399; text-decoration: none; }
.icp-footer a:hover { color: #409eff; }
.input:disabled {
  background: var(--bg-card-2);
  color: var(--text-dim);
  cursor: not-allowed;
}
.user-panel {
  max-width: 420px;
}
.user-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.user-form-actions {
  display: flex;
  justify-content: flex-end;
}
.user-form-actions .btn {
  height: 40px;
  padding: 0 24px;
}

/* ============ 电子围栏 ============ */
.locate-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.fence-stat {
  font-size: 13px;
  color: #606266;
}
.fence-pick-bar {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: #fff;
  border: 1px solid #ebeef5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 21, 41, 0.12);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #303133;
  white-space: nowrap;
}
.fence-pick-cancel {
  border-color: #f56c6c;
  color: #f56c6c;
}
.fence-pick-cancel:hover {
  background: #f56c6c;
  color: #fff;
}
.fence-panel {
  max-width: 560px;
}
.fence-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}
.fence-actions {
  padding: 0 20px 20px;
  justify-content: center;
}
.fence-type-row {
  gap: 20px;
  align-items: center;
}
.fence-type-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #606266;
  cursor: pointer;
}
.fence-type-label input {
  accent-color: #409eff;
}
.fence-scope-label {
  font-size: 14px;
  font-weight: 600;
  color: #303133;
}
#fence-customer {
  width: 100%;
}
.fence-device-list {
  width: 100%;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  background: #fff;
}
.fence-device-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #606266;
  cursor: pointer;
  padding: 3px 8px;
  border: 1px solid #e4e7ed;
  border-radius: 3px;
}
.fence-device-item input {
  accent-color: #409eff;
}
.fence-device-item:has(input:checked) {
  border-color: #409eff;
  color: #409eff;
  background: #ecf5ff;
}
