/* W3-2 界面骨架：左图标栏 + 二级侧栏 + 内容区（原创样式，浅色） */

:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #e5e9f1;
  --line-soft: #f0f3f8;
  --ink: #1f2a3a;
  --muted: #6b7787;
  --brand: #2377e6;
  --brand-dark: #1a63c4;
  --brand-soft: #e9f2ff;
  --ok: #1f9d55;
  --ok-soft: #e8f8ee;
  --bad: #d93a3a;
  --bad-soft: #fdecec;
  --warn: #b26a00;
  --warn-soft: #fff4e5;
  --rail-bg: #232b38;
  --rail-ink: #93a0b2;
  --rail-hover: #2c3646;
  --rail-active: #31405a;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: 13px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
code { background: #f1f4f9; border-radius: 4px; padding: 1px 5px; font-size: 12px; color: #33415c; }
.spacer { flex: 1; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #eef4ff 0%, #f6f8fc 45%, #eef7f3 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 30px 28px; box-shadow: 0 18px 50px rgba(31, 42, 58, .12);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .2px; }
.login-card h1 span { color: var(--brand); }
.login-card .sub { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  background: #fff; border: 1px solid #d8dfea; border-radius: 7px;
  padding: 9px 10px; color: var(--ink); outline: none; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(35, 119, 230, .12);
}
.btn { border: 0; border-radius: 7px; padding: 9px 15px; cursor: pointer; font-size: 13px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid #d8dfea; }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.error { color: var(--bad); font-size: 12px; min-height: 18px; margin-top: 8px; white-space: pre-wrap; }

/* ---------- 外壳 ---------- */
.app { height: 100vh; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 54px; flex: 0 0 54px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: #fff; border-bottom: 1px solid var(--line); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand .mark {
  width: 22px; height: 22px; border-radius: 6px; display: inline-block;
  background: linear-gradient(135deg, #3d8bfd, #19b6a5);
}
.brand small { font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.crumb { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--ink); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: #f1f4f9; color: #54617a; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.role { background: #eef4ff; color: #3d64a8; }
.pill.role.admin { background: var(--warn-soft); color: var(--warn); }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 64px 206px minmax(0, 1fr); }

/* 左图标栏 */
.rail { background: var(--rail-bg); display: flex; flex-direction: column; align-items: stretch; padding: 10px 0; gap: 4px; overflow: visible; }
.rail-item {
  position: relative; border: 0; background: transparent; color: var(--rail-ink);
  height: 46px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.rail-item:hover { background: var(--rail-hover); color: #dfe7f3; }
.rail-item.active { background: var(--rail-active); color: #fff; }
.rail-item.active::after { content: ""; position: absolute; right: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px 0 0 2px; background: #4f9bff; }
.rail-item svg { width: 21px; height: 21px; }
.rail-item .rail-label {
  position: absolute; left: 70px; top: 50%; transform: translateY(-50%);
  background: #111827; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 5px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 30;
}
.rail-item:hover .rail-label { opacity: 1; }

/* 二级侧栏 */
.subnav { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; padding-bottom: 16px; }
.subnav-title { padding: 18px 16px 10px; font-size: 15px; font-weight: 600; color: var(--ink); }
.subnav-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 16px; color: #4b5563; font-size: 13px; cursor: pointer;
}
.subnav-item:hover { background: #f6f8fc; color: var(--brand); }
.subnav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }

/* 内容区 */
.content { min-width: 0; min-height: 0; overflow: auto; padding: 16px 20px 22px; }
.view { min-height: 0; }
.loading { color: var(--muted); padding: 26px 4px; }

/* ---------- 通用块 ---------- */
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card { padding: 14px 16px; margin-bottom: 14px; }
.panel { padding: 4px 14px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card h3 { margin: 0; font-size: 14px; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 12px; }
.page-head h1 { margin: 0 0 3px; font-size: 18px; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 12px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px; margin-bottom: 12px; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
input.ctl, select.ctl, textarea.ctl {
  height: 32px; background: #fff; border: 1px solid #d8dfea; border-radius: 6px;
  padding: 0 9px; color: var(--ink); outline: none;
}
textarea.ctl { height: auto; padding: 8px 9px; resize: vertical; }
input.ctl:focus, select.ctl:focus, textarea.ctl:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(35, 119, 230, .12); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.link-btn { border: 0; background: none; color: var(--brand); padding: 3px 5px; cursor: pointer; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }
.link-btn + .link-btn { margin-left: 2px; }
.empty { color: var(--muted); font-size: 13px; padding: 26px 4px; text-align: center; }
.notice { display: none; font-size: 12px; padding: 8px 10px; border-radius: 6px; margin-top: 10px; }
.notice.err { display: block; background: var(--bad-soft); color: #a12626; }
.notice.ok { display: block; background: var(--ok-soft); color: #176c3b; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfe;
}
table.grid td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.grid tbody tr:hover td { background: #fafcff; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: #f1f4f9; color: #5b6675; white-space: nowrap; }
.tag.blue { background: var(--brand-soft); color: #1d5cb5; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--bad-soft); color: var(--bad); }
.tag.line { background: transparent; border: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #b9c2d0; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.pager { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; padding: 10px 4px; }
.pager .spacer { flex: 1; }

/* ---------- 监控大屏 ---------- */
.monitor { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 14px; min-height: 0; }
.dev-side { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 10px; overflow: auto; max-height: calc(100vh - 130px); }
.dev-side h2 { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin: 2px 8px 10px; }
.dev-main { min-width: 0; }
.device-item { padding: 9px 10px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; margin-bottom: 4px; }
.device-item:hover { background: #f6f8fc; }
.device-item.active { background: var(--brand-soft); border-color: #cfe1ff; }
.device-item .name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.device-item .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.device-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.device-head h1 { margin: 0 0 4px; font-size: 20px; }
.device-head .meta { color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.sensor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 10px; margin-bottom: 14px; }
.sensor-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; transition: .12s; }
.sensor-card:hover { border-color: #b9d2f7; box-shadow: 0 4px 14px rgba(35, 119, 230, .07); }
.sensor-card.active { border-color: var(--brand); box-shadow: 0 0 0 1px rgba(35, 119, 230, .25) inset; }
.sensor-card .label { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.sensor-card .value { font-size: 24px; font-weight: 650; margin-top: 7px; font-variant-numeric: tabular-nums; }
.sensor-card .value small { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.sensor-card .ts { color: var(--muted); font-size: 11px; margin-top: 5px; }
.chart-wrap { width: 100%; overflow: hidden; }
svg#chart { width: 100%; height: 280px; display: block; }
.chart-meta { color: var(--muted); font-size: 12px; display: flex; gap: 14px; flex-wrap: wrap; }
.chart-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
/* W4-5 设备组分组（监控中心左栏） */
.dev-group { margin-bottom: 10px; }
.dev-group-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; color: var(--muted); font-size: 11.5px; letter-spacing: .04em; }
.dev-group-head .count { margin-left: auto; font-variant-numeric: tabular-nums; }
.alarm-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.alarm-row:last-child { border-bottom: 0; }
.alarm-row .time { color: var(--muted); font-size: 12px; min-width: 132px; }
.alarm-row .msg { flex: 1; }
.status { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status.FIRING { background: var(--bad-soft); color: var(--bad); }
.status.RESOLVED { background: var(--ok-soft); color: var(--ok); }

/* ---------- 地图 ---------- */
.map-view { display: flex; flex-direction: column; gap: 10px; height: calc(100vh - 88px); }
.map-legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; align-items: center; }
.map-legend .key { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.map-wrap { flex: 1; min-height: 260px; border: 1px solid var(--line); border-radius: var(--radius); background: #f7faff; position: relative; overflow: hidden; }
.map-wrap svg { width: 100%; height: 100%; display: block; }
.map-grid { stroke: #dfe8f5; stroke-width: 1; }
/* W4-4 离线底图：经纬网 / 城市点 / 比例尺 / 指北针 */
.map-graticule { stroke: #dbe6f4; stroke-width: 1; }
.map-grid-label { fill: #93a3b8; font-size: 10px; }
.map-city { fill: #8fa0b6; }
.map-city-label { fill: #7f8fa5; font-size: 10px; }
.map-scale line, .map-scale path { stroke: #6b7787; stroke-width: 1.5; fill: none; }
.map-scale text { fill: #6b7787; font-size: 10px; }
.map-north line, .map-north path { stroke: #6b7787; stroke-width: 1.5; fill: none; }
.map-north text { fill: #6b7787; font-size: 10px; font-weight: 600; }
.map-dot { cursor: pointer; }
.map-dot.online { fill: var(--ok); }
.map-dot.offline { fill: #9aa7b8; }
.map-dot.alarm { fill: var(--bad); animation: mapPulse 1.2s ease-in-out infinite; }
@keyframes mapPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.map-ring { fill: none; stroke: var(--bad); stroke-width: 2; animation: mapRing 1.6s ease-out infinite; }
@keyframes mapRing { 0% { r: 10; opacity: .85; } 100% { r: 24; opacity: 0; } }
.map-label { fill: #33415c; font-size: 11px; pointer-events: none; }
.map-coord { fill: #8794a8; font-size: 10px; pointer-events: none; }
.map-axis { fill: #8794a8; font-size: 10px; }
.map-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .42); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.modal-card { width: 640px; max-width: 100%; max-height: 88vh; background: #fff; border-radius: 10px; display: flex; flex-direction: column; box-shadow: 0 22px 60px rgba(15, 23, 42, .28); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .close { margin-left: auto; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field { margin: 0; }
.hint { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.check-row { display: flex; flex-wrap: wrap; gap: 14px; padding: 4px 0; }
.check-row label { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink); }
.perm-group { border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; margin-bottom: 8px; }
.perm-group .perm-title { font-weight: 600; font-size: 12.5px; margin-bottom: 6px; }
.perm-group label { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; margin-right: 14px; }

/* ---------- 云组态（W4-1 固定模板） ---------- */
svg#compChart { width: 100%; height: 280px; display: block; }
.comp-view .comp-top { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.comp-gauge-card svg { width: 100%; height: 190px; display: block; }
.comp-view.gauge .comp-gauge-card svg { height: 260px; }
.comp-view.curve .comp-gauge-card svg { height: 150px; }
.comp-view.gauge #compChart { height: 200px; }
.comp-view.curve #compChart { height: 360px; }
.comp-info-card .comp-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; padding: 6px 2px; }
.comp-info-card .comp-kpis div { display: flex; flex-direction: column; gap: 4px; }
.comp-info-card .comp-kpis b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 1000px) { .comp-view .comp-top { grid-template-columns: 1fr; } }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 56px 170px minmax(0, 1fr); }
  .monitor { grid-template-columns: 1fr; }
  .dev-side { max-height: 200px; }
}

/* ---------- W5-1b 用户前台（portal） ---------- */
body.portal-mode .workspace { grid-template-columns: 64px minmax(0, 1fr); }
body.portal-mode .subnav { display: none; }
body.portal-mode .content { padding: 16px 20px 26px; }

.sensor-grid.sensor-list { display: flex; flex-direction: column; gap: 8px; }
.sensor-row {
  display: grid; grid-template-columns: minmax(150px, 1.1fr) 160px 150px auto;
  align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.sensor-row:hover { border-color: #b9d2f7; box-shadow: 0 3px 12px rgba(35,119,230,.06); }
.sensor-row.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px rgba(35,119,230,.22); }
.sensor-row .name { font-weight: 600; font-size: 13.5px; }
.sensor-row-status .tag { display: inline-block; margin-bottom: 3px; }
.sensor-row-value { font-size: 20px; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.sensor-row-value small { font-size: 12px; color: var(--muted); margin-left: 3px; font-weight: 400; }
.sensor-row-actions { display: flex; gap: 4px; justify-content: flex-end; white-space: nowrap; }

@media (max-width: 900px) {
  body.portal-mode .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 56px; }
  body.portal-mode .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 0; gap: 0; overflow: hidden; }
  /* W7-4：前台 12 个入口时按可用宽度均分，图标略缩小，避免底部导航溢出 */
  body.portal-mode .rail-item { flex: 1 1 0; min-width: 0; height: 56px; }
  body.portal-mode .rail-item svg { width: 19px; height: 19px; }
  body.portal-mode .rail-item .rail-label { display: none; }
  body.portal-mode .rail-item.active::after {
    top: auto; bottom: 0; left: 18px; right: 18px; width: auto; height: 3px; border-radius: 2px 2px 0 0;
  }
  body.portal-mode .topbar { padding: 0 10px; gap: 6px; }
  body.portal-mode #tenantPill, body.portal-mode #refreshHint { display: none; }
  body.portal-mode .topbar .btn { padding: 6px 9px; }
  body.portal-mode .card-head { flex-wrap: wrap; gap: 6px; }
  body.portal-mode .topbar .brand small, body.portal-mode #crumb { display: none; }
  body.portal-mode .content { padding: 12px; }
  body.portal-mode .monitor { grid-template-columns: 1fr; }
  body.portal-mode .dev-side { max-height: 220px; }
  .sensor-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name value" "status actions"; row-gap: 6px; }
  .sensor-row-name { grid-area: name; }
  .sensor-row-value { grid-area: value; }
  .sensor-row-status { grid-area: status; }
  .sensor-row-actions { grid-area: actions; }
  .sensor-row-actions .link-btn { font-size: 11.5px; }
  body.portal-mode .page-head h1 { font-size: 16px; }
  body.portal-mode .chart-wrap svg#chart { height: 200px; }
}

/* ---------- W5-4 企业概览 ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 6px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--brand); color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat-card.warn { border-color: #f0b7b7; background: #fff8f8; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11.5px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 48px; align-items: center; gap: 8px; padding: 5px 0; }
.bar-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: #eef3f9; border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #3d8bfd, #73b1ff); border-radius: 4px; }
.bar-value { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.trend { display: flex; flex-direction: column; gap: 4px; }
.trend-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 96px; align-items: center; gap: 8px; }
.trend-date { font-size: 11px; color: var(--muted); }
.trend-bars { display: flex; flex-direction: column; gap: 2px; }
.trend-bars i { display: block; height: 4px; border-radius: 2px; min-width: 0; }
.trend-nums { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.t-devices { background: #3d8bfd; }
.t-users { background: #35b37e; }
.t-active { background: #f0a020; }
i.legend { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 8px; vertical-align: -1px; }

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

/* ---------- W5-5 白标 ---------- */
.login-logo { width: 72px; height: 72px; object-fit: contain; display: block; margin: 0 auto 12px; border-radius: 14px; }
.login-card h1 #loginTitle { letter-spacing: -.3px; }
.brand .mark { background-size: cover; background-position: center; }
.brand-logo-preview {
  width: 96px; height: 96px; margin: 8px 0; border: 1px dashed var(--line);
  border-radius: 10px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fafcff;
}
.brand-logo-preview img { max-width: 100%; max-height: 100%; }

/* ---------- W5-7 云组态素材库 ---------- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.asset-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.asset-card img { width: 100%; height: 96px; object-fit: cover; border-radius: 6px; background: #f4f7fb; display: block; margin-bottom: 6px; }
/* ---------- W8-3 云组态拖拽编辑器 ---------- */
.comp-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.comp-editor-canvas-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.comp-stage { position: relative; margin: 12px auto; }
.comp-canvas { position: relative; width: 1000px; height: 600px; background: #fff; }
.comp-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(15, 23, 42, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, .06) 1px, transparent 1px);
  background-size: 20px 20px;
}
.comp-widget {
  position: absolute; box-sizing: border-box; border: 1px dashed transparent; border-radius: 6px;
  overflow: hidden; cursor: move; user-select: none;
}
.comp-widget.selected { border-color: #4f9bff; box-shadow: 0 0 0 2px rgba(79, 155, 255, .18); z-index: 3; }
.comp-widget.text { display: flex; align-items: center; padding: 2px 6px; font-weight: 600; }
.comp-widget.value {
  display: flex; flex-direction: column; justify-content: center; padding: 6px 10px;
  background: rgba(255, 255, 255, .78); border: 1px solid #e5eaf2;
}
.comp-widget .cw-label { font-size: 12px; color: #6b7280; }
.comp-widget .cw-value { font-size: 26px; font-weight: 600; color: #111827; }
.comp-widget.curve {
  display: flex; flex-direction: column; padding: 6px 8px;
  background: rgba(255, 255, 255, .82); border: 1px solid #e5eaf2;
}
.comp-widget.curve svg { flex: 1; width: 100%; min-height: 0; }
.comp-widget.image { display: flex; align-items: center; justify-content: center; background: #f7f9fc; }
.comp-widget.image img { width: 100%; height: 100%; object-fit: contain; }
.comp-widget .cw-empty { color: #9aa7b8; font-size: 12px; }
.comp-props {
  position: sticky; top: 12px; padding: 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px;
}
.comp-props-title { margin-bottom: 10px; font-weight: 600; }
.comp-props .field { margin-bottom: 8px; }
@media (max-width: 1100px) {
  .comp-editor-layout { grid-template-columns: minmax(0, 1fr); }
  .comp-props { position: static; }
}
/* ---------- W8-5 固件升级 ---------- */
.check-list {
  display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow: auto;
  padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.check-list .check-row { display: flex; padding: 3px 0; }
/* ---------- W8-6 计算规则 ---------- */
.check-item { display: flex; gap: 6px; align-items: flex-start; padding: 3px 0; font-size: 13px; }
.check-item input[type="checkbox"] { width: auto; flex: 0 0 auto; margin-top: 2px; }
.check-item > span { flex: 1; }
.field input[type="checkbox"] { width: auto; flex: 0 0 auto; }
/* ---------- W8-7 边缘运行时 ---------- */
.token-box {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: #f7f9fc; word-break: break-all; user-select: all;
}
.code-block {
  margin: 0; padding: 10px; border-radius: 6px; background: #0f172a; color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px;
  line-height: 1.55; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
/* ---------- W8-8 实时计算流程画布 ---------- */
.flow-canvas {
  position: relative; height: 430px; margin-top: 12px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px;
  background-color: #fbfcfe;
  background-image: radial-gradient(#d7e0ea 1px, transparent 1px);
  background-size: 18px 18px;
}
.flow-edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.flow-node {
  position: absolute; width: 250px; background: #fff; border: 1px solid #cfd9e5;
  border-radius: 8px; box-shadow: 0 6px 18px rgba(20, 40, 70, .08);
}
.flow-node.flow-function { width: 300px; }
.flow-node.flow-output { width: 230px; }
.flow-node-head {
  padding: 8px 10px; font-size: 12.5px; font-weight: 650; color: #24425f;
  background: #f0f5fb; border-bottom: 1px solid #dce6f0; border-radius: 8px 8px 0 0;
  cursor: move; user-select: none;
}
.flow-node-body { padding: 10px; }
.flow-node .field { margin-bottom: 8px; }
.flow-node .field input, .flow-node .field select { width: 100%; }
.flow-node .field input[type="checkbox"] { width: auto; flex: 0 0 auto; }
.flow-stage { border: 1px solid #e2e9f3; border-radius: 7px; padding: 7px; margin-bottom: 7px; background: #f8faff; }
.flow-stage-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #5b6b83; margin-bottom: 5px; }
.flow-stage .flow-stage-expr { width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.flow-function .flow-node-body { max-height: 470px; overflow-y: auto; }
.dag-palette { display: flex; align-items: center; gap: 6px; margin: 10px 0 8px; }
.dag-toolbar { display: flex; align-items: center; gap: 6px; margin: 0 0 8px;
  padding: 5px 8px; background: #f4f8ff; border: 1px solid #e2eaf6; border-radius: 8px; }
.dag-toolbar .btn { padding: 3px 8px; }
.dag-sep { width: 1px; height: 18px; background: #d8e2f0; margin: 0 3px; }
.dag-marquee { position: absolute; z-index: 4; border: 1px dashed #4f7fc4;
  background: rgba(79, 127, 196, .10); pointer-events: none; }
.dag-node.selected { border-color: #2f6fd0; box-shadow: 0 0 0 2px rgba(47, 111, 208, .25), 0 2px 8px rgba(30, 55, 90, .08); }
.brand-logo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 12px; }
.dag-canvas { position: relative; height: 470px; border: 1px solid #dbe4f0; border-radius: 10px;
  background: #f7faff radial-gradient(#dfe8f5 1px, transparent 1px); background-size: 18px 18px; overflow: hidden; }
.dag-edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  transform-origin: 0 0; }
#dagNodes { position: absolute; inset: 0; transform-origin: 0 0; }
.dag-node { position: absolute; width: 176px; background: #fff; border: 1px solid #d8e2f0;
  border-radius: 8px; box-shadow: 0 2px 8px rgba(30, 55, 90, .08); z-index: 2; }
.dag-node-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 7px;
  font-size: 12px; color: #40526b; background: #f2f6fc; border-bottom: 1px solid #e5ecf6;
  cursor: move; border-radius: 8px 8px 0 0; }
.dag-node-body { padding: 6px; }
.dag-node-body .ctl { width: 100%; font-size: 12px; }
.dag-node.dag-condition { border-color: #f0c98c; }
.dag-node.dag-output { border-color: #9fd6b4; }
.dag-port { position: absolute; width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2px solid #4f7fc4; cursor: crosshair; z-index: 3; }
.dag-in { left: -6px; top: 34px; }
.dag-out { right: -6px; top: 34px; background: #4f7fc4; }
.dag-out.dag-true { top: 24px; background: #2f9e63; border-color: #2f9e63; }
.dag-out.dag-false { top: 48px; background: #d8822a; border-color: #d8822a; }
.dag-edge-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: pointer; }
.dag-edge-line { fill: none; stroke: #6b86a8; stroke-width: 1.8; }
.dag-edge-line.true { stroke: #2f9e63; }
.dag-edge-line.false { stroke: #d8822a; }
.dag-edge-label { font-size: 10px; fill: #6b7c94; }
/* ---------- W8-9 远程连接视图 ---------- */
.remote-tabs {
  display: flex; gap: 2px; margin: 4px 0 12px; border-bottom: 1px solid var(--line);
}
.remote-tab {
  border: 0; background: transparent; padding: 8px 14px; font-size: 13px; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent;
}
.remote-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 650; }
.remote-tab:hover { color: var(--ink); }
.inline-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.remote-screen-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.remote-screen-grid.layout-1 { grid-template-columns: minmax(0, 1fr); }
.remote-screen-grid.layout-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.remote-screen-card { border: 1px solid #22344d; border-radius: 8px; overflow: hidden; background: #0f172a; }
.remote-screen-head {
  display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px;
  background: #17233a; color: #dbeafe; font-size: 12px;
}
.remote-screen-body {
  height: 150px; display: flex; align-items: center; justify-content: center;
  color: #7f93ad; font-size: 12.5px; letter-spacing: .3px;
  background: repeating-linear-gradient(45deg, #0f172a, #0f172a 9px, #121c30 9px, #121c30 18px);
}
.remote-screen-frame { width: 100%; height: 252px; border: 0; display: block; background: #000; }
.remote-screen-grid.layout-1 .remote-screen-frame { height: 420px; }
.remote-screen-grid.layout-2 .remote-screen-frame { height: 252px; }
.remote-screen-grid.layout-4 .remote-screen-frame { height: 190px; }
.rule-expr {
  display: inline-block; font-size: 12px; padding: 1px 5px; border-radius: 4px;
  background: #f3f6f9; color: #1f4f7a; word-break: break-all;
}
/* W8-47 站内消息 */
.notify-btn { position: relative; }
.notify-badge { position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 9px; background: #e05a4f; color: #fff; font-size: 11px;
  line-height: 16px; text-align: center; font-weight: 600; }
.notify-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow: auto; }
.notify-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fff; }
.notify-item.unread { border-left: 3px solid #4f9bff; background: #f7fbff; }
.notify-item .n-title { font-weight: 600; }
.notify-item .n-body { color: #52637a; font-size: 13px; margin-top: 3px; }
.notify-item .n-time { color: #8a9bb2; font-size: 12px; margin-top: 4px; }
/* W8-55c 产品行内「更多」与连接参数表单 */
.more { display: inline-block; position: relative; }
.more > summary { list-style: none; display: inline-block; cursor: pointer; color: var(--brand);
  font-size: 12px; padding: 3px 5px; }
.more > summary::-webkit-details-marker { display: none; }
.more[open] > summary { text-decoration: underline; }
.more-menu { display: flex; flex-direction: column; align-items: flex-start; padding: 2px 0 2px 10px; }
.more-menu button { font-size: 12px; }
.conn-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
.conn-sample { background: #0f172a; color: #d7e3f4; border-radius: 8px; padding: 10px 12px;
  font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; white-space: pre-wrap;
  word-break: break-all; margin-top: 6px; }
.mapping-cell { color: var(--brand); cursor: pointer; font-size: 12px; }
.mapping-cell.empty { color: #9aa7b8; }
.icon-input { width: 46px; text-align: center; }

/* W8-53 监控中心左栏：搜索 / 状态页签 / 分页 / 设备组管理 */
.dev-side-head { display: flex; align-items: center; gap: 8px; margin: 0 8px 8px; }
.dev-side-head h2 { margin: 0; }
.dev-side-head .link-btn { margin-left: auto; font-size: 11.5px; }
.dev-search { width: 100%; height: 30px; margin-bottom: 8px; }
.dev-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.dev-tab { flex: 1; border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px; padding: 6px 4px; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.dev-tab .cnt { display: inline-block; min-width: 16px; margin-left: 2px; padding: 0 4px;
  border-radius: 8px; background: #eef2f8; color: #5b6675; font-size: 11px; font-variant-numeric: tabular-nums; }
.dev-tab.active { background: var(--brand-soft); border-color: #cfe1ff; color: var(--brand); font-weight: 600; }
.dev-tab.active .cnt { background: #dbe8ff; color: var(--brand); }
.dev-pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 4px 2px;
  border-top: 1px solid var(--line); margin-top: 6px; }
.dev-pager .link-btn[disabled] { color: #b6c1d0; cursor: not-allowed; text-decoration: none; }
.dev-pager select { height: 24px; font-size: 11.5px; padding: 0 4px; margin-left: auto; }
.device-item .alarm-tag { background: var(--bad-soft); color: var(--bad); border-radius: 999px;
  padding: 0 6px; font-size: 10.5px; font-weight: 600; }
.device-item .tag-stack { margin-top: 3px; display: flex; gap: 6px; align-items: center; }

/* W8-53：左栏内部滚动，分页条固定在底部（不被设备列表挤出去） */
.dev-side { display: flex; flex-direction: column; overflow: hidden; }
.dev-side-head, .dev-search, .dev-tabs, .dev-pager { flex: 0 0 auto; }
.dev-side #deviceList { flex: 1 1 auto; min-height: 0; overflow: auto; }
.dev-tab { font-size: 11px; padding: 6px 3px; }

/* W8-54 企业概览：推送分析 / 周期指标 / 省份与使用时长 */
.t-devices-active { background: #8a63d2; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fbfcfe; }
.metric .m-label { font-size: 11.5px; color: var(--muted); }
.metric .m-value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.metric .m-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.metric.alarm { border-color: #f0b7b7; background: #fff8f8; }
.metric.alarm .m-value { color: var(--bad); }
@media (max-width: 1100px) { .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* W8-57 账号设置：账户安全摘要行 */
.kv-list { display: flex; flex-direction: column; }
.kv-row { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; align-items: center;
  gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv-row:last-child { border-bottom: 0; }
.kv-label { color: var(--muted); font-size: 12px; }
.kv-value { color: var(--text); }
