/* 设备监控中心 — 严格按参考效果图高还原
   配色：主蓝 #3B82F6 / 绿 #10B981 / 橙 #F59E0B / 红 #EF4444 / 灰 #6B7280 */
:root {
  --sidebar-w: 184px;
  --primary: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray: #6b7280;
  --gray-bg: #f3f4f6;
  --text: #1f2937;
  --text-dark: #111827;
  --border: #e5e7eb;
  --card-shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: #f5f7fa;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.layout { min-height: 100vh; }
.main { margin-left: var(--sidebar-w); padding: 0 24px 20px; min-width: 0; }

/* ════════ 左侧导航栏 ════════ */
.sidebar {
  width: var(--sidebar-w);
  position: fixed; top: 0; left: 0; bottom: 0;
  background: #fff;
  border-right: 1px solid #e8ecf0;
  display: flex; flex-direction: column;
  padding: 16px 16px 12px;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 2px 2px 16px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(59,130,246,.35);
}
.brand-text { min-width: 0; white-space: nowrap; }
.brand-title { font-size: 13px; font-weight: 700; color: var(--text-dark); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: #9ca3af; line-height: 1.3; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: 8px;
  color: #374151; text-decoration: none; font-size: 14px;
  transition: background .15s;
}
.nav-item .nav-ic { display: flex; color: #6b7280; }
.nav-item:hover { background: #f5f7fb; }
.nav-item.active {
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 10px rgba(59,130,246,.3);
}
.nav-item.active .nav-ic { color: #fff; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600; min-width: 20px; height: 20px;
  padding: 0 6px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.sidebar-foot { margin-top: auto; }
.promo {
  position: relative; overflow: hidden; border-radius: 12px;
  background: linear-gradient(135deg, #e0edff, #d7e7ff 45%, #bfdbfe);
  padding: 16px 14px;
  box-shadow: inset 0 0 0 1px rgba(96,165,250,.25), 0 6px 14px rgba(59,130,246,.14);
}
.promo-blob { position: absolute; right: -18px; top: -20px; width: 88px; height: 88px; border-radius: 50%; background: rgba(255,255,255,.55); }
.promo-ill { position: absolute; right: 6px; bottom: 6px; opacity: .95; }
.promo-txt { position: relative; z-index: 2; color: #1e40af; font-size: 13px; font-weight: 700; line-height: 1.7; }
.version { text-align: center; margin-top: 12px; font-size: 11px; color: #9ca3af; }

/* ════════ 顶部栏 ════════ */
.topbar {
  position: relative;
  display: flex; align-items: center; gap: 18px;
  height: 60px; padding: 0 4px;
}
.page-head { flex: 1; min-width: 0; }
.page-title { font-size: 20px; font-weight: 600; color: var(--text-dark); white-space: nowrap; }
.page-sub { font-size: 13px; color: var(--gray); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-utils { flex: 0 0 auto; display: flex; align-items: center; gap: 16px; }
.search-pill {
  display: flex; align-items: center; gap: 8px;
  width: 250px; height: 36px; padding: 0 14px;
  background: var(--gray-bg); border-radius: 999px;
}
.search-pill input { border: none; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--text); }
.search-pill input::placeholder { color: #9ca3af; }
.icon-btn { position: relative; border: none; background: none; cursor: pointer; display: flex; }
.notif-dot { position: absolute; top: 1px; right: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,#3b82f6,#60a5fa); color: #fff; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.user-name { font-size: 14px; color: var(--text); }
.clock { position: absolute; right: 4px; bottom: -2px; font-size: 12px; color: #9ca3af; }

/* ════════ 顶部统计卡 ════════ */
.stats {
  display: flex; align-items: stretch; gap: 14px;
  margin-top: 4px;
}
.stat-card {
  flex: 1; background: #fff; border-radius: 12px;
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--card-shadow);
}
.stat-ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: 0 0 44px; }
.ic-blue { background: var(--primary); }
.ic-green { background: var(--success); }
.ic-gray { background: var(--gray); }
.ic-red { background: var(--danger); }
.stat-label { font-size: 13px; color: var(--gray); }
.stat-values { display: flex; align-items: baseline; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--text-dark); line-height: 1.1; }
.stat-delta { font-size: 12px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--success); }
.stat-delta.sub { color: var(--gray); }
.stat-delta.danger { color: var(--danger); }

/* 生成报告（克制的白色卡片：小图标 + 蓝色文字，不抢主视觉） */
.report-btn {
  flex: 1; background: #fff; border-radius: 12px;
  border: 1px solid #eef0f4; box-shadow: var(--card-shadow); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px; min-width: 0;
}
.report-ic {
  width: 44px; height: 44px; border-radius: 12px;
  background: #eef4ff; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.report-txt { font-size: 14px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.report-btn:hover { box-shadow: 0 6px 16px rgba(59,130,246,.2); }

/* ════════ 内容区：两列网格（>=1280 参考图布局） ════════
   设备列表 | 设备详情
   设备趋势 | 最新告警
   <1280 由底部媒体查询改为单列纵向（表格获得整页宽度）。 */
.content {
  display: grid;
  grid-template-columns: 1fr 300px;
  grid-template-rows: auto auto;
  gap: 18px;
  margin-top: 16px;
  align-items: stretch;
}
.device-card { grid-column: 1; grid-row: 1; min-width: 0; }
.detail-card { grid-column: 2; grid-row: 1; }
.trend-card  { grid-column: 1; grid-row: 2; min-width: 0; }
.alert-card  { grid-column: 2; grid-row: 2; }

.card { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; color: var(--text-dark); }
.card-count { font-size: 13px; color: var(--gray); font-weight: 400; }

/* 表格筛选 */
.table-filters { display: flex; align-items: center; gap: 10px; }
.sel {
  height: 34px; padding: 0 12px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; font-size: 13px; color: var(--text);
  outline: none; cursor: pointer;
}
.mini-search {
  display: flex; align-items: center; gap: 6px; height: 34px; width: 210px;
  padding: 0 12px; background: var(--gray-bg); border-radius: 999px;
}
.mini-search input { border: none; background: transparent; outline: none; flex: 1; font-size: 13px; }
.mini-search input::placeholder { color: #9ca3af; }

/* 数据表格：table-layout:fixed + 按比例列宽 → 8 列始终可见，避免横向滚动 */
.table-wrap { overflow-x: hidden; }
.dt { width: 100%; table-layout: fixed; border-collapse: collapse; }
.dt thead th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--gray);
  padding: 9px 6px; border-bottom: 1px solid var(--border); background: #fafbfc;
  white-space: normal; line-height: 1.4; word-break: break-word;
}
.dt thead th:nth-child(1) { width: 17%; }
.dt thead th:nth-child(2) { width: 11%; }
.dt thead th:nth-child(3) { width: 13%; }
.dt thead th:nth-child(4) { width: 16%; }
.dt thead th:nth-child(5) { width: 11%; }
.dt thead th:nth-child(6) { width: 11%; }
.dt thead th:nth-child(7) { width: 10%; }
.dt thead th:nth-child(8) { width: 11%; }
.dt tbody td { padding: 9px 6px; border-bottom: 1px solid #f3f4f6; font-size: 12px; color: var(--text); vertical-align: middle; word-break: break-word; overflow-wrap: break-word; }
.dt tbody tr { border-left: 4px solid transparent; }
.dt tbody tr.selected { background: #f0f6ff; border-left: 4px solid var(--primary); }
.dt tbody tr:hover { background: #f7f9fc; }
.dt .cell-acct { font-weight: 600; color: var(--text-dark); }
.dt .cell-sub { color: var(--gray); font-size: 12px; }

/* 状态徽标（圆角胶囊） */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-normal { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger, .badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-offline { background: #e5e7eb; color: #4b5563; }

/* 设备详情 */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.detail-top { display: flex; align-items: flex-start; gap: 10px; }
.online-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); margin-top: 6px; box-shadow: 0 0 0 4px rgba(16,185,129,.15); }
.detail-name { font-size: 16px; font-weight: 600; color: var(--text-dark); }
.detail-store { font-size: 12px; color: var(--gray); margin-top: 2px; }
.detail-actions { display: flex; align-items: center; gap: 8px; }
.connect-btn {
  border: 1px solid var(--primary); color: var(--primary); background: #fff;
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.connect-btn:hover { background: #f0f6ff; }
.more-btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; width: 34px; height: 34px; font-size: 14px; color: var(--gray); cursor: pointer; }
.detail-list { margin: 0; }
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13px; }
.detail-row dt { color: var(--gray); }
.detail-row dd { color: var(--text); font-weight: 500; text-align: right; }
.detail-row dd.ok { color: var(--success); }
.detail-row dd.bad { color: var(--danger); }

/* 趋势图 */
.range-toggle { display: flex; background: var(--gray-bg); border-radius: 999px; padding: 3px; }
.range { border: none; background: transparent; padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--gray); cursor: pointer; }
.range.active { background: var(--primary); color: #fff; font-weight: 500; }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }

/* 最新告警 */
.alert-card { padding: 14px 20px; }
.view-all { color: var(--primary); font-size: 13px; text-decoration: none; }
.alert-list { display: flex; flex-direction: column; }
.alert-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 4px;
  border-left: 4px solid transparent; border-radius: 6px;
}
.alert-item.crit { border-left-color: var(--danger); }
.alert-item.warn { border-left-color: var(--warning); }
.alert-ic { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 32px; }
.alert-ic.crit { background: #fee2e2; color: var(--danger); }
.alert-ic.warn { background: #fef3c7; color: var(--warning); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.alert-sub { font-size: 12px; color: var(--gray); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-time { font-size: 12px; color: var(--gray); white-space: nowrap; }

/* ════════ 窄屏响应式（<1280）：单列纵向，表格获得整页宽度，禁止横向挤压 ════════
   顺序：设备列表 → 设备详情 → 设备在线趋势 → 最新告警 */
@media (max-width: 1279.98px) {
  .content {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .device-card,
  .detail-card,
  .trend-card,
  .alert-card {
    grid-column: 1; grid-row: auto;
  }
  .detail-card { grid-row: auto; }
  .alert-card  { grid-row: auto; }
}

/* ════════ 前端交互（视图切换 / 空态 / 轻提示） ════════ */
.view { margin-top: 16px; }
[hidden] { display: none !important; }
.nav-item, .view-all, .range, .connect-btn, .report-btn, .more-btn, .sel { cursor: pointer; }
.build-state {
  background: #fff; border-radius: 12px; box-shadow: var(--card-shadow);
  padding: 64px 20px; text-align: center;
}
.build-ic { display: flex; justify-content: center; margin-bottom: 16px; }
.build-text { font-size: 18px; font-weight: 600; color: #6b7280; }
.build-sub { font-size: 13px; color: #9ca3af; margin-top: 6px; }
#toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%);
  background: rgba(17,24,39,.92); color: #fff; font-size: 13px;
  padding: 10px 20px; border-radius: 8px; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .2s; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ════════ 设备管理页 / 完整详情（真正功能页） ════════ */
/* 设备名/ID 不折断：单行 + 省略 + hover 完整 */
.dt .cell-id { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

/* 设备管理表格：横向可滚动，禁止把列压没 */
.mng-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mng-table { min-width: 1180px; width: max-content; }
.mng-table th, .mng-table td { white-space: nowrap; }
.mng-table td:first-child { font-weight: 600; }
.mng-count { color: var(--gray); }
.view-link-btn {
  border: 1px solid var(--primary); color: var(--primary); background: #fff;
  border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.view-link-btn:hover { background: #f0f6ff; }

/* 首页摘要卡 → 完整详情入口 */
.detail-view-link { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); text-align: center; }
.view-full-btn {
  width: 100%; border: 1px solid var(--primary); color: var(--primary); background: #fff;
  border-radius: 8px; padding: 9px 0; font-size: 14px; font-weight: 600; cursor: pointer;
}
.view-full-btn:hover { background: #f0f6ff; }

/* 详情页 */
.detail-page-card { min-height: 320px; }
.detail-page-head { justify-content: flex-start; gap: 16px; }
.back-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer;
}
.back-btn:hover { background: #f5f7fb; }
.detail-section { margin-bottom: 24px; }
.detail-section > h3 {
  font-size: 15px; font-weight: 600; color: var(--text-dark);
  border-left: 3px solid var(--primary); padding-left: 10px; margin-bottom: 12px;
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; }
.detail-grid .d-item dt { color: var(--gray); font-size: 12px; margin-bottom: 2px; }
.detail-grid .d-item dd { color: var(--text); font-size: 14px; font-weight: 500; word-break: break-word; }
.detail-empty { color: #9ca3af; font-weight: 400; font-size: 13px; }

/* 趋势空态（移除 MOCK 曲线后的占位） */
.trend-empty {
  height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: #9ca3af; font-size: 14px;
}
.trend-empty .te-ic { opacity: .6; }

/* ════════ 立即刷新按钮（前台仅手动触发；30 分钟自动不动） ════════ */
.refresh-now {
  border: 1px solid var(--border); background: #fff; color: var(--primary);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--card-shadow); white-space: nowrap;
}
.refresh-now:hover:not(:disabled) { background: #f0f6ff; }
.refresh-now:disabled { color: #9ca3af; cursor: not-allowed; opacity: .75; }