/* ==========================================================================
   渡须物联 · 控制台样式
   --------------------------------------------------------------------------
   一、布局
       登录后的控制台为「左侧固定白色侧边栏（深色主题为深色面板）+ 右侧主内容区」两栏结构：
       浅色下侧边栏与内容区同属「白 / 淡蓝 + 细线」体系，只靠 1px 分隔线区分，与登录页同源。

       #mainContent (flex 容器，铺满视口)
         ├─ #navbar.sidebar   左侧侧边栏（浅色为白底细线；≥1100px 常驻 216px）
         └─ .main-area        右侧
              ├─ .topbar      工具栏：页面标题 + 搜索 + 用户
              └─ .content     可滚动内容区（四个视图）

       body 默认带 16px 内边距，供登录页居中布局使用；进入控制台后由
       showPage() 给 body 挂 .console-mode，取消内边距与限宽，让两栏贴边。

   二、主题
       基础配色即浅色（默认主题），深色通过 body.dark-theme 覆盖同一批
       自定义属性（--bg / --surface / --ink ...）来实现，规则不必重写。
       登录页样式独立成段（文件末尾），不参与主题切换，一行未动。
   ========================================================================== */

/* ---------- 基础重置 ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

html {
    -webkit-text-size-adjust: 100%;
}

/* 浅色是默认主题：变量先在此定义，深色主题只覆盖变量 */
body {
    /* 面 */
    --bg: #e9f2ff;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --surface-3: #f0f2f7;
    --line: #eef1f6;
    --line-strong: #e2e6ee;
    /* 控制台外壳：与登录页统一为「白底 + 细线 + 主蓝点缀」，不再使用实心蓝色块 */
    --sidebar-bg: #ffffff;
    --sidebar-line: #e8eef6;
    --card-line: #e9eef6;
    --nav-ink: #4e5969;
    --nav-hover-bg: #f2f7ff;
    --nav-active-bg: #eaf2ff;
    --nav-active-ink: #1668dc;
    /* 字（三级 + 补充色阶，正文/次要/辅助均 ≥4.5:1） */
    --ink: #101828;
    --ink-2: #475467;
    --ink-3: #5f6b7d;
    --ink-4: #667085;
    /* 品牌与语义色 */
    /* --brand 用于实心填充与白底上的文字，两主题恒定以保证白字对比度 */
    --brand: #1668dc;
    --brand-dark: #0e5bc4;
    /* --brand-accent 只用于图标/描边等装饰元素，深色主题下需要提亮 */
    --brand-accent: #3b82f6;
    --brand-soft: #eef3fd;
    --ok: #0a6b3f;
    --ok-soft: #e8f8f0;
    --warn: #b45309;
    --warn-soft: #fef3e2;
    --danger: #c0341d;
    --danger-soft: #fdeceb;
    /* 语义色：数值分类着色（深色主题需提亮，否则在深底上不可读） */
    --temp: #d92d20;
    --humi: #0e7490;
    /* 阴影 */
    --shadow-card: 0 2px 10px rgba(16, 24, 40, .05);
    --shadow-hover: 0 10px 24px rgba(16, 24, 40, .10);

    min-height: 100vh;
    padding: 16px;
    color: var(--ink);
    background: var(--bg);
    transition: background-color .3s ease, color .3s ease;
}

body.dark-theme {
    --bg: #0f1522;
    --surface: #141c2e;
    --surface-2: #182135;
    --surface-3: #1b2438;
    --line: #22304a;
    --line-strong: #2a3a56;
    /* 深色下侧边栏比内容区略亮一档，用 1px 细线分隔，不再铺深蓝渐变 */
    --sidebar-bg: #111a2b;
    --sidebar-line: #22304a;
    --card-line: #22304a;
    --nav-ink: #b9c6dd;
    --nav-hover-bg: rgba(255, 255, 255, .06);
    --nav-active-bg: rgba(22, 104, 220, .18);
    --nav-active-ink: #6aa9ff;
    --ink: #e8eefc;
    --ink-2: #b9c6dd;
    --ink-3: #93a1bb;
    --ink-4: #7d8ca8;
    --brand-accent: #6aa9ff;
    --brand-soft: #16233c;
    --ok: #4ade9b;
    --ok-soft: #10241c;
    --warn: #fbbf6b;
    --warn-soft: #241a0e;
    --danger: #ff8f85;
    --danger-soft: #2a1416;
    --temp: #ff9a8f;
    --humi: #5eead4;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .28);
    --shadow-hover: 0 10px 24px rgba(0, 0, 0, .38);
}

#app {
    max-width: 1280px;
    margin: 0 auto;
}

/* 进入控制台：取消登录页的内边距/限宽，改为整屏两栏 */
body.console-mode {
    padding: 0;
    overflow: hidden;
}

body.console-mode #app {
    max-width: none;
    margin: 0;
}

.hidden {
    display: none !important;
}

/* ---------- 两栏骨架 ---------- */
#mainContent {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* 控制台背景层：与登录页同源的「白 → 淡蓝」渐变 + 两团极淡蓝晕，
   铺在 .main-area 上（不铺 body，避免侧边栏被染色）。
   装饰块 .console-deco-* 以 absolute 定位在内容区内，
   因此 .main-area 需要 position: relative + overflow: hidden 作为裁剪容器。 */
.main-area {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    background-image:
        radial-gradient(520px 520px at 92% 4%, rgba(180, 210, 255, .28), transparent 70%),
        radial-gradient(420px 420px at 4% 94%, rgba(198, 222, 255, .18), transparent 72%),
        linear-gradient(180deg, #f0f6ff 0%, #e4efff 55%, #d5e6ff 100%);
}

/* 深色主题：同样的晕光位置，换成低亮度的深蓝，避免浅蓝晕在深底上发灰 */
body.dark-theme .main-area {
    background-image:
        radial-gradient(520px 520px at 92% 4%, rgba(58, 110, 200, .20), transparent 70%),
        radial-gradient(420px 420px at 4% 94%, rgba(40, 80, 150, .14), transparent 72%),
        linear-gradient(180deg, #0f1522 0%, #101827 55%, #0d1526 100%);
}

/* ---------- 侧边栏 ---------- */
/* 白底 + 右侧 1px 细线：与登录页「白卡 + 细边框」同一套语言。
   hover/激活态由 --nav-* 变量给值，深色主题只覆盖变量。 */
#navbar.sidebar {
    display: flex;
    flex-direction: column;
    flex: 0 0 216px;
    width: 216px;
    height: 100%;
    padding: 20px 14px 16px;
    overflow-y: auto;
    border-right: 1px solid var(--sidebar-line);
    color: var(--nav-ink);
    background: var(--sidebar-bg);
    transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}

/* 品牌区：logo 本身是蓝底白图，白侧边栏上可以直接看清，不再加白底衬 */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding: 2px 6px 22px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.sidebar-logo img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 7px;
}

.sidebar-brand-name {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--ink);
    white-space: nowrap;
}

/* 导航项：默认半透明白字，激活为白色胶囊 + 品牌蓝字 */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-height: 0;
}

.sidebar-foot {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    height: 42px;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--nav-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .16s ease, color .16s ease;
}

.sidebar-link i {
    flex: 0 0 16px;
    width: 16px;
    color: inherit;
    font-size: 15px;
    text-align: center;
}

.sidebar-link-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link:hover {
    /* 深色主题下 --brand 在深底上对比不足，hover/激活统一走 --nav-active-ink */
    color: var(--nav-active-ink);
    background: var(--nav-hover-bg);
}

/* 激活项：淡蓝底 + 主蓝字 + 左侧 3px 蓝条（白底侧边栏上白底胶囊会完全看不见） */
.sidebar-link.is-active {
    color: var(--nav-active-ink);
    font-weight: 600;
    background: var(--nav-active-bg);
}

.sidebar-link.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: currentColor;
    transform: translateY(-50%);
}

.sidebar-link.is-active i {
    color: var(--nav-active-ink);
}

/* 底部按钮（主题切换 / 退出登录）文字略浅，弱化但不失可读性 */
.sidebar-foot .sidebar-link {
    color: var(--ink-3);
}

.sidebar-foot .sidebar-link:hover {
    color: var(--nav-active-ink);
}

/* #themeToggle 是 <button>，需要抹掉浏览器默认样式 */
.sidebar-link-btn {
    width: 100%;
    text-align: left;
}

.sidebar-link:focus-visible {
    outline: 2px solid rgba(22, 104, 220, .45);
    outline-offset: 2px;
}

/* ---------- 顶部工具栏（无卡片外框，直接浮在浅灰底上） ---------- */
/* z-index: 1 把工具栏抬到 .console-deco 装饰层（z-index: 0）之上。
   两者都未设定位上下文时会互相遮挡，加 position: relative 让层级生效。 */
.topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex: 0 0 auto;
    height: 72px;
    padding: 0 32px;
}

.topbar-title {
    overflow: hidden;
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.topbar-tools {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 260px;
    width: 260px;
}

.topbar-search > i {
    position: absolute;
    left: 14px;
    color: var(--ink-4);
    font-size: 13px;
    pointer-events: none;
}

.topbar-search input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 36px;
    border: none;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color .16s ease, box-shadow .16s ease;
}

.topbar-search input::placeholder {
    color: var(--ink-4);
}

.topbar-search input:focus {
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(22, 104, 220, .14);
}

.topbar-search input::-webkit-search-cancel-button {
    cursor: pointer;
}

/* 用户胶囊：替代原来的蓝色 .badge */
#userDisplay {
    display: inline-flex;
    align-items: center;
    flex: 0 1 auto;
    max-width: 200px;
    height: 36px;
    padding: 0 14px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ---------- 内容区 ---------- */
/* 同样抬到装饰层之上；自身背景透明，装饰块可以透过卡片间隙露出 */
.content {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 32px 40px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
}

.view-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 4px 0 18px;
}

.view-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 16px;
    font-weight: 600;
}

.view-title i {
    color: var(--brand-accent);
    font-size: 14px;
}

/* 连接状态徽章紧跟在标题文字右侧：flex gap 8px + 2px = 10px，不做两端对齐 */
.view-title .realtime-badge {
    margin-left: 2px;
}

.view-desc {
    margin-top: 4px;
    color: var(--ink-3);
    font-size: 13px;
    line-height: 1.5;
}

.view-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- 统计卡片 ---------- */
.stats-container {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    padding: 18px 20px 20px;
    border: 1px solid var(--card-line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    transition: transform .18s ease, box-shadow .18s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    border-radius: 12px;
    color: #fff;
    font-size: 16px;
}

.stat-icon-blue {
    background: linear-gradient(135deg, #3b82f6, #1668dc);
}

.stat-icon-green {
    background: linear-gradient(135deg, #34d399, #10b981);
}

.stat-icon-orange {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.stat-icon-purple {
    background: linear-gradient(135deg, #a78bfa, #7c5cff);
}

.stat-value {
    overflow: hidden;
    max-width: 100%;
    color: var(--ink);
    font-size: clamp(20px, 1.9vw, 28px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -.01em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.stat-label {
    margin-top: 4px;
    color: var(--ink-3);
    font-size: 13px;
    white-space: nowrap;
}

/* ---------- 设备网格与卡片 ---------- */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.device-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 22px 20px 20px;
    border: 1px solid var(--card-line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

/* 顶部 3px 状态条：在线绿 / 离线橙 */
.device-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #10b981;
}

.device-card.offline::before {
    background: #f59e0b;
}

.device-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.device-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.device-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.device-title > div {
    min-width: 0;
}

.device-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6, #1668dc);
    color: #fff;
    font-size: 17px;
}

.device-card.offline .device-icon {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.device-name {
    overflow: hidden;
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.device-location {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    margin-top: 3px;
    color: var(--ink-3);
    font-size: 12.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.device-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.device-status.online {
    background: var(--ok-soft);
    color: var(--ok);
}

.device-status.offline {
    background: var(--warn-soft);
    color: var(--warn);
}

/* ---------- 设备头部右侧：传感器异常警示 + 在线徽章 ----------
   组包一层 flex 容器，让头部仍只有「标题 / 右侧组」两个 flex 子项，
   加入徽章不会左右挪动原有元素。
   警示徽章只在「传感器状态 ≠ 正常」且 ≥700px 时出现：
   <700px 由温度/湿度两格的 .sub-sensor 副标题胶囊承载，避免重复。
   徽章高度（约 22px）小于头部内容高度（图标 36px），因此不改变卡片高度。 */
.device-status-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.device-alert {
    display: none;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.device-alert i {
    font-size: 10px;
}

.device-alert.is-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.device-alert.is-warn {
    background: var(--warn-soft);
    color: var(--warn);
}

@media (min-width: 700px) {
    .device-alert:not(.hidden) {
        display: inline-flex;
    }
}

.device-data {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.data-item {
    min-width: 0;
    padding: 12px;
    border-radius: 12px;
    background: var(--surface-2);
}

.data-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.data-label i {
    font-size: 11px;
}

.data-value {
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* 覆盖旧版渐变文字：白底上渐变字对比度不达标，改为实色 */
.data-value.temperature,
.data-value.humidity {
    background: none;
    -webkit-background-clip: border-box;
    background-clip: border-box;
    -webkit-text-fill-color: currentColor;
}

.data-value.temperature {
    color: var(--temp);
}

.data-value.humidity {
    color: var(--humi);
}

.data-unit {
    margin-left: 2px;
    color: var(--ink-4);
    font-size: 12px;
    font-weight: 600;
}

.data-subtext {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    margin-top: 8px;
    padding: 3px 8px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--ink-3);
    font-size: 11.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.data-subtext i {
    font-size: 10px;
}

.data-subtext.good {
    background: var(--ok-soft);
    color: var(--ok);
}

.data-subtext.warning {
    background: var(--warn-soft);
    color: var(--warn);
}

.data-subtext.error {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ---------- 卡片内：温度趋势 sparkline（纯手写 SVG，无图表库） ----------
   默认隐藏（<700px 手机端保持原 2×2 模板不变），≥700px 由下方媒体查询打开。
   结构由 renderDeviceCard() 一次生成，updateSensorCardFromData() 只改
   polyline/path 的 points 与 d 属性，不重建 innerHTML，因此不会闪烁。 */
.device-spark {
    display: none;
    margin: -4px 0 14px;
}

.spark-svg {
    display: block;
    width: 100%;
    height: 38px;
    overflow: visible;
}

/* 只有 1 个点（或 0 个点）时画一条极淡虚线的占位，绝不画假直线误导用户 */
.spark-base {
    display: none;
    stroke: var(--line-strong);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
}

.device-spark.is-empty .spark-base {
    display: inline;
}

.spark-line {
    fill: none;
    stroke: #1668dc;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* viewBox 被非等比拉伸，用 non-scaling-stroke 保证线宽恒定 */
    vector-effect: non-scaling-stroke;
}

body.dark-theme .spark-line {
    stroke: #6aa9ff;
}

.spark-area {
    stroke: none;
}

/* ---------- 卡片内：状态徽章（≥1680px 才出现，正常/异常用颜色暗示） ---------- */
.device-badges {
    display: none;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.badge-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 3px 9px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 11.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.badge-chip i {
    font-size: 10px;
}

.badge-chip.good {
    background: var(--ok-soft);
    color: var(--ok);
}

.badge-chip.warning {
    background: var(--warn-soft);
    color: var(--warn);
}

.badge-chip.error {
    background: var(--danger-soft);
    color: var(--danger);
}

/* 卡片底部最后上报时间（≥1680px 才出现） */
.device-lastseen {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    color: var(--ink-3);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.device-lastseen i {
    color: var(--brand-accent);
    font-size: 11px;
}

/* ---------- 卡片内：数据格副标题按断点收敛（避免大屏重复信息） ----------
   温度/湿度两格共用同一句「传感器状态」副标题；
   手机端（<700px）保留，≥700px 收起（异常状态改由头部的警示徽章承载）。 */
.sub-sensor {
    display: inline-flex;
}

/* 卡片底部：运行时长 / 通道 / 详细按钮 */
.detail-item {
    min-width: 0;
}

.device-details {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.device-details .detail-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 12px;
    white-space: nowrap;
}

.device-details .detail-item i {
    color: var(--brand-accent);
    font-size: 11px;
}

.btn-details {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    margin-left: auto;
    padding: 0 14px;
    border: none;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .16s ease;
}

.btn-details:hover {
    background: var(--brand-dark);
}

/* 分区标题（离线传感器 / 二级区块） */
.offline-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 30px 0 14px;
    color: var(--warn);
    font-size: 15px;
    font-weight: 600;
}

.offline-title i {
    color: #f59e0b;
}

.offline-hint {
    color: var(--ink-4);
    font-size: 13px;
    font-weight: 400;
}

/* ---------- 卡片通用外壳 ---------- */
.glass-card {
    padding: 20px 22px;
    border: 1px solid var(--card-line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.empty-card {
    padding: 36px 22px;
    color: var(--ink-3);
    font-size: 14px;
    text-align: center;
}

/* ---------- 表格 ---------- */
.table-card {
    padding: 6px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 13px 14px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

th:first-child {
    border-radius: 10px 0 0 10px;
}

th:last-child {
    border-radius: 0 10px 10px 0;
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-size: 13.5px;
    vertical-align: middle;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: var(--surface-2);
}

td .btn {
    margin: 0 2px;
}

#alertConfigsBody .btn-sm {
    margin: 2px;
}

/* script.js 用内联样式渲染告警表格里的接收人 / QQ 标签（浅色底 + 继承文字色），
   深色主题下继承色会变成浅色字压在浅色底上；这里把标签内文字固定为深灰。
   破折号占位符（内联 color:#999）对比度不足，用 !important 覆盖内联值。 */
#alertConfigsBody td span[style*="background"] {
    color: #334155;
}

#alertConfigsBody td span[style*="color:#999"] {
    color: #6b7688 !important;
}

body.dark-theme #alertConfigsBody td span[style*="color:#999"] {
    color: var(--ink-4) !important;
}

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    border: none;
    border-radius: 9px;
    background: var(--surface-3);
    color: var(--ink-2);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .16s ease, box-shadow .16s ease, transform .1s ease;
}

.btn:hover {
    background: var(--line-strong);
}

.btn:active {
    transform: translateY(1px);
}

.btn-success,
.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-success:hover,
.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
    box-shadow: inset 0 0 0 1px currentColor;
}

.btn-secondary {
    background: var(--surface-3);
    color: var(--ink-2);
}

.btn-sm {
    height: 30px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 12.5px;
}

/* ---------- 表单控件 ---------- */
input,
select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus,
select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(22, 104, 220, .12);
}

input::placeholder {
    color: var(--ink-4);
}

.assign-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.assign-controls select {
    flex: 1 1 220px;
    max-width: 250px;
}

#thresholdInputContainer input,
#thresholdInputContainer select,
#comparisonContainer select {
    width: 100%;
}

/* ---------- 详情视图 ---------- */
.detail-card {
    padding: 26px 28px;
}

.detail-title {
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.detail-title .badge {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    vertical-align: middle;
}

.realtime-large {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin: 14px 0 6px;
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.realtime-large i {
    margin-right: 6px;
    font-size: 18px;
}

.realtime-large .temp {
    color: var(--temp);
}

.realtime-large .humi {
    color: var(--humi);
}

.sensor-meta {
    margin-bottom: 18px;
    color: var(--ink-3);
    font-size: 13px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-top: 8px;
}

.category-card {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-2);
}

.category-card h3 {
    margin-bottom: 10px;
    padding-left: 9px;
    border-left: 3px solid var(--brand-accent);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.category-card .detail-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}

.category-card .detail-item:last-child {
    border-bottom: none;
}

.category-card .detail-key {
    flex: 0 0 auto;
    color: var(--ink-3);
}

.category-card .detail-value {
    max-width: 60%;
    color: var(--ink);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
}

.chart-vertical {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.chart-container {
    width: 100%;
    height: 300px;
    padding: 8px;
    border-radius: 14px;
    background: var(--surface-2);
}

.realtime-badge {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 11px;
    border-radius: 999px;
    background: #10b981;
    color: #fff;
    font-size: 11.5px;
    font-weight: 600;
    animation: pulse 2s infinite;
    /* script.js 直接用内联样式改 background 表示连接状态（绿/琥珀/红）：
       用 !important 叠一层 35% 黑蒙版，既保留状态色相，又让白字对比度≥4.5:1 */
    background-image: linear-gradient(rgba(0, 0, 0, .35), rgba(0, 0, 0, .35)) !important;
}

/* 呼吸效果只动外发光，不动 opacity：
   若用透明度做闪烁，半透明瞬间会同时拉低文字与底色的对比度 */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); }
    70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ---------- 模态框 ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: rgba(16, 24, 40, .45);
    overflow-y: auto;
}

body.dark-theme .modal {
    background: rgba(4, 8, 16, .68);
}

.modal-content {
    width: 100%;
    max-width: 450px;
    max-height: calc(100vh - 48px);
    margin: auto;
    padding: 26px 26px 24px;
    border: none;
    border-radius: 18px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 24px 60px rgba(16, 24, 40, .24);
    overflow-y: auto;
}

.modal-content h3 {
    color: var(--ink);
    font-size: 17px;
    font-weight: 600;
}

.close {
    float: right;
    color: var(--ink-4);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: color .16s ease;
}

.close:hover {
    color: var(--ink);
}

/* 模态框内的错误提示条（JS 会重写 className 为 alert alert-error [hidden]） */
.alert-error {
    margin-bottom: 18px;
    padding: 10px 12px;
    border-radius: 9px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
}

/* ---------- 断点 1：700–1099px 侧边栏收窄为 72px 图标条（≥1100px 常驻 216px） ---------- */
@media (max-width: 1099.98px) {
    #navbar.sidebar {
        flex-basis: 72px;
        width: 72px;
        align-items: center;
        padding: 18px 0 14px;
    }

    .sidebar-brand {
        justify-content: center;
        padding: 0 0 18px;
    }

    .sidebar-brand-name {
        display: none;
    }

    .sidebar-nav,
    .sidebar-foot {
        align-items: center;
        width: 100%;
    }

    .sidebar-link {
        justify-content: center;
        gap: 0;
        width: 44px;
        height: 44px;
        padding: 0;
    }

    .sidebar-link-text {
        display: none;
    }

    .topbar {
        height: 64px;
        padding: 0 22px;
    }

    .content {
        padding: 0 22px 32px;
    }

    .topbar-search {
        flex: 0 1 200px;
        width: 200px;
    }
}

/* ---------- 断点 2：≤699.98px 侧边栏改为顶部横向条 ----------
   用 699.98px 而不是 700px：移动断点(max-width)与卡片渐进增强断点
   (min-width:700px) 首尾相接，700 整点不再同时命中，避免出现
   「移动顶栏 + 仍显示曲线」这种现实中不存在的混合态。
   与项目既有的 1099.98px 写法保持一致。 */
@media (max-width: 699.98px) {
    #mainContent {
        flex-direction: column;
    }

    #navbar.sidebar {
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        width: 100%;
        height: auto;
        padding: 10px 14px;
        overflow: visible;
    }

    .sidebar-brand {
        flex: 0 0 auto;
        justify-content: flex-start;
        padding: 0;
    }

    .sidebar-logo {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
        border-radius: 9px;
    }

    .sidebar-nav {
        flex: 1 1 auto;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        width: auto;
        overflow: hidden;
    }

    .sidebar-foot {
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        width: auto;
        margin: 0 0 0 4px;
        padding: 0 0 0 8px;
        border-top: none;
        border-left: 1px solid var(--sidebar-line);
    }

    .sidebar-link {
        flex: 0 0 38px;
        width: 38px;
        height: 38px;
    }

    .main-area {
        flex: 1 1 auto;
        min-height: 0;
    }

    .topbar {
        height: 56px;
        gap: 10px;
        padding: 0 14px;
    }

    .topbar-title {
        font-size: 17px;
    }

    /* 移动端隐藏搜索框（列表本身已足够短，避免挤压标题与用户胶囊） */
    .topbar-search {
        display: none;
    }

    #userDisplay {
        max-width: 120px;
        height: 32px;
        padding: 0 10px;
        font-size: 12px;
    }

    .content {
        padding: 0 14px 28px;
    }

    .stats-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 14px 16px 16px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
        border-radius: 10px;
        font-size: 14px;
    }

    .stat-value {
        font-size: 22px;
    }

    .device-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .view-title {
        font-size: 15px;
    }

    .detail-card {
        padding: 18px 16px;
    }

    .realtime-large {
        gap: 14px;
        font-size: 22px;
    }

    .assign-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .assign-controls select {
        max-width: none;
    }
}

/* ==========================================================================
   卡片内容渐进增强（min-width 方向叠加，切换视口不需要重新请求数据）
   <700px   保持现有 2×2 数据格模板，无曲线、无次要数据行
   700px+   2×2 数据格 + 温度曲线
   1280px+  再加次要数据行（运行时长 / 传输通道）
   1680px+  再加「空闲内存」与状态徽章、最后上报时间
   ========================================================================== */
@media (min-width: 700px) {
    .device-spark {
        display: block;
    }

    /* 温度/湿度两格重复展示同一个「传感器状态」，≥700px 收敛掉 */
    .sub-sensor {
        display: none;
    }
}

@media (min-width: 1280px) {
    /* 运行时长 / 传输通道改由卡片底部的 .device-details 一行承载，
       具体覆盖写在文件末尾的三栏卡片样式段里 */
    .device-details .detail-item {
        display: none;
    }
}

@media (min-width: 1680px) {
    /* 状态徽章行与最后上报时间在超宽屏补出（三栏卡片段里会把徽章行关掉） */
    .device-badges {
        display: flex;
    }

    .device-lastseen {
        display: inline-flex;
    }
}

/* ---------- 尊重系统「减少动态效果」偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .device-card,
    .btn,
    .sidebar-link {
        transition: none;
    }

    .realtime-badge {
        animation: none;
    }
}

/* ==========================================================================
   以下为登录页样式块（原文件第 1001–1578 行原样保留，未做任何修改）
   ========================================================================== */
/* ==========================================================================
   登录页（浅色极简门户页）
   设计定调：整页固定浅色，不跟随 body.dark-theme / body.light-theme。
   因此本段所有颜色直接写死浅色值，且关键规则统一带 #loginPage 前缀提高优先级，
   用于覆盖全局 input/button 的深色基础样式与 body.light-theme/dark-theme 的输入框覆盖，
   避免深色主题用户登出后看到"深色文字留在浅底上"。
   影响范围仅限 #loginPage 内部，不修改任何既有控制台样式。
   ========================================================================== */

/* ---------- 外层容器：视口垂直居中（body 已有 16px padding） ---------- */
#loginPage.login-page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 32px);
    padding: 32px 0 56px;
    background: none;
    color: #1f2329;
}

/* 浅色渐变底 + 两团极淡蓝晕，固定定位铺满视口，
   绕开 body 的 16px 内边距与 #app 的 1280 限宽，四周不留白边 */
#loginPage.login-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        radial-gradient(560px 560px at 84% 10%, rgba(180, 210, 255, 0.30), transparent 70%),
        radial-gradient(460px 460px at 8% 86%, rgba(198, 222, 255, 0.22), transparent 72%),
        linear-gradient(180deg, #ffffff 0%, #f2f7ff 55%, #eaf3ff 100%);
}

/* 极淡网格：只在画面中部透出，越到边缘越淡，避免抢内容 */
#loginPage.login-page::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(22, 104, 220, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 104, 220, 0.055) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(circle at 50% 38%, #000 0%, transparent 74%);
    mask-image: radial-gradient(circle at 50% 38%, #000 0%, transparent 74%);
}

/* 几何装饰块：2 个淡蓝圆形 + 1 个斜置圆角方块，纯氛围 */
.login-deco {
    position: fixed;
    z-index: 0;
    pointer-events: none;
}

.login-deco-a {
    width: 300px;
    height: 300px;
    top: 6%;
    left: -84px;
    border-radius: 50%;
    background: rgba(180, 210, 255, 0.18);
    animation: decoDriftA 28s ease-in-out infinite;
    will-change: transform;
}

/* 背景装饰的缓慢漂浮：周期拉到 20 秒以上，只在余光里察觉 */
@keyframes decoDriftA {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50%      { transform: translate3d(30px, -24px, 0) scale(1.07); }
}

@keyframes decoDriftB {
    0%, 100% { transform: rotate(18deg) translate3d(0, 0, 0); }
    50%      { transform: rotate(27deg) translate3d(-28px, -20px, 0); }
}

@keyframes decoDriftC {
    0%, 100% { transform: rotate(-12deg) translate3d(0, 0, 0); }
    50%      { transform: rotate(-3deg) translate3d(22px, 18px, 0); }
}

.login-deco-b {
    width: 188px;
    height: 188px;
    right: 5%;
    bottom: 9%;
    border-radius: 30px;
    transform: rotate(18deg);
    background: rgba(180, 210, 255, 0.16);
    animation: decoDriftB 23s ease-in-out infinite;
    will-change: transform;
}

.login-deco-c {
    width: 116px;
    height: 116px;
    right: 25%;
    top: 12%;
    border-radius: 26px;
    transform: rotate(-12deg);
    background: rgba(198, 222, 255, 0.20);
    animation: decoDriftC 19s ease-in-out infinite;
    animation-delay: -7s;
    will-change: transform;
}

/* ---------- 两栏骨架：左文案 + 右白卡（约 57% / 380px） ---------- */
.login-shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    align-items: center;
    gap: 72px;
    width: 100%;
    max-width: 1060px;
}

/* ---------- 左侧：品牌文案，无卡片无边框，直接浮在背景上 ---------- */
.login-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.brand-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 34px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    display: block;
}

.brand-name {
    font-size: 20px;
    font-weight: 700;
    color: #1f2329;
    letter-spacing: 0.01em;
}

.brand-heading {
    margin: 0 0 16px;
    font-size: 32px;
    line-height: 1.28;
    font-weight: 700;
    color: #1f2329;
    letter-spacing: -0.01em;
}

.brand-desc {
    margin: 0 0 22px;
    font-size: 17px;
    line-height: 1.6;
    font-weight: 400;
    color: #4e5969;
}

.brand-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #86909c;
}

.brand-tags-dot {
    color: #c9cdd4;
}

/* ---------- 右侧：白色登录卡片 ---------- */
.login-panel {
    justify-self: end;
    width: 100%;
    max-width: 380px;
    padding: 32px 28px 26px;
    background: #ffffff;
    border: 1px solid #e5e6eb;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(31, 45, 61, 0.08);
}

.login-form-wrap {
    width: 100%;
}

/* Tab 栏：激活项蓝字 + 2px 蓝线 */
.login-tabs {
    display: flex;
    align-items: center;
    gap: 28px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e5e6eb;
}

.login-tab {
    position: relative;
    margin: 0 0 -1px;
    padding: 0 0 12px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: #4e5969;
    cursor: pointer;
    transition: color 0.18s ease;
}

.login-tab:hover {
    color: #1668dc;
}

.login-tab.is-active {
    color: #1668dc;
    font-weight: 500;
}

.login-tab.is-active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    border-radius: 1px;
    background: #1668dc;
}

.login-tab:focus-visible {
    outline: 2px solid rgba(22, 104, 220, 0.45);
    outline-offset: 3px;
    border-radius: 2px;
}

/* 表单区 */
.login-pane .login-form {
    display: block;
}

/* 输入框：40px 高、3px 小圆角、1px 浅灰描边（覆盖全局胶囊 input 与主题输入框覆盖） */
#loginPage .login-input {
    display: block;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 40px;
    color: #1f2329;
    background: #ffffff;
    border: 1px solid #d9dde3;
    border-radius: 3px;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

#loginPage .login-input::placeholder {
    color: #a9aeb8;
}

#loginPage .login-input:hover {
    border-color: #b8c0cc;
}

#loginPage .login-input:focus {
    border-color: #1668dc;
    box-shadow: 0 0 0 3px rgba(22, 104, 220, 0.10);
}

.login-form .login-input + .login-input,
.login-form .sms-code-row {
    margin-top: 16px;
}

/* 自动登录 + 忘记密码 */
.login-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    font-size: 13px;
}

.login-remember {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #4e5969;
    cursor: pointer;
    user-select: none;
}

#loginPage .login-remember input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    padding: 0;
    border-radius: 2px;
    accent-color: #1668dc;
    cursor: pointer;
    flex: 0 0 auto;
}

.login-forgot {
    color: #1668dc;
    text-decoration: none;
    white-space: nowrap;
}

.login-forgot:hover {
    color: #0e5bc4;
    text-decoration: underline;
}

/* 主按钮：实心蓝、40px 高、3px 小圆角 */
#loginPage .btn-login {
    display: block;
    width: 100%;
    margin-top: 22px;
    padding: 0 16px;
    height: 40px;
    border: none;
    border-radius: 3px;
    background: #1668dc;
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 40px;
    letter-spacing: 0.02em;
    text-align: center;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.18s ease;
}

#loginPage .btn-login:hover {
    background: #0e5bc4;
    transform: none;
    filter: none;
}

#loginPage .btn-login:active {
    background: #0b4da8;
    transform: none;
}

#loginPage .btn-login:disabled,
#loginPage .btn-login[disabled] {
    background: #a9c7f5;
    color: #ffffff;
    cursor: not-allowed;
    opacity: 1;
    box-shadow: none;
}

#loginPage .btn-login:focus-visible {
    outline: 2px solid rgba(22, 104, 220, 0.45);
    outline-offset: 2px;
}

/* 错误提示条（JS 会 innerText 写入并移除 .hidden） */
#loginPage #loginError.alert-error {
    display: block;
    width: 100%;
    margin: 0 0 16px;
    padding: 9px 12px;
    border-radius: 3px;
    font-size: 13px;
    line-height: 1.5;
    color: #d93026;
    background: #fef2f2;
    border: 1px solid #f8d4d2;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* ---------- 短信登录（前端完整，接口未就绪时由 SMS_ENABLED 降级） ---------- */
/* 提示区：默认中性灰，成功绿，失败红 */
.sms-hint {
    margin: 0 0 16px;
    padding: 9px 12px;
    border-radius: 3px;
    font-size: 13px;
    line-height: 1.5;
    color: #4e5969;
    background: #f7f8fa;
    border: 1px solid #e5e6eb;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.sms-hint.is-success {
    color: #1f9d55;
    background: #eefaf3;
    border-color: #c6eeda;
}

.sms-hint.is-error {
    color: #d93026;
    background: #fef2f2;
    border-color: #f8d4d2;
}

/* 未绑定引导：就地切换的子视图说明与返回链接 */
.sms-bind-tip {
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.6;
    color: #4e5969;
}

.sms-bind-back {
    margin: 14px 0 0;
    text-align: center;
    font-size: 13px;
    line-height: 1.5;
}

.sms-bind-back a {
    color: #1668dc;
    text-decoration: none;
}

.sms-bind-back a:hover {
    color: #0e5bc4;
    text-decoration: underline;
}

.sms-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sms-code-row .login-input {
    flex: 1 1 auto;
    min-width: 0;
    margin-top: 0;
}

#loginPage .sms-send {
    flex: 0 0 auto;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #1668dc;
    border-radius: 3px;
    background: #ffffff;
    color: #1668dc;
    font-family: inherit;
    font-size: 13px;
    line-height: 38px;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

#loginPage .sms-send:hover:not(:disabled) {
    background: #f2f7ff;
}

#loginPage .sms-send:disabled {
    color: #a9aeb8;
    border-color: #e5e6eb;
    background: #f7f8fa;
    cursor: not-allowed;
}

#loginPage .sms-send:focus-visible {
    outline: 2px solid rgba(22, 104, 220, 0.45);
    outline-offset: 2px;
}

/* ---------- 页面底部版权行 ---------- */
.login-copyright {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 12px;
    z-index: 1;
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: #a9aeb8;
    text-align: center;
    pointer-events: none;
}

/* ---------- 响应式：≤900px 单卡居中，左栏隐藏 ---------- */
@media (max-width: 900px) {
    #loginPage.login-page {
        padding: 24px 0 48px;
    }

    .login-shell {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        gap: 0;
        max-width: 380px;
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        justify-self: center;
        max-width: 100%;
    }

    .login-deco-a {
        top: -60px;
        left: -120px;
    }

    .login-deco-c {
        right: 6%;
        top: 8%;
    }
}

/* ---------- 响应式：≤480px 收紧内边距，保证 375px 无横向滚动 ---------- */
@media (max-width: 480px) {
    .login-panel {
        padding: 24px 22px 22px;
    }

    .login-tabs {
        gap: 22px;
        margin-bottom: 20px;
    }

    .login-tab {
        font-size: 14px;
    }

    .login-copyright {
        font-size: 11px;
        bottom: 8px;
    }
}

/* ---------- 尊重系统「减少动态效果」偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
    #loginPage *,
    #loginPage *::before,
    #loginPage *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* 告警表格适配 */
#alertConfigsBody td {
    vertical-align: middle;
}
#alertConfigsBody .btn-sm {
    margin: 2px;
}
#thresholdInputContainer input,
#thresholdInputContainer select {
    width: 100%;
}
#comparisonContainer select {
    width: 100%;
}

/* ---------- 半透明毛玻璃：卡片与侧边栏轻微透出背景装饰 ----------
   用 body 前缀提高特异性，确保覆盖各断点里的同名规则。
   不透明度取 0.72–0.78：既能让背景装饰隐约透出，又不至于压低文字对比度。
   backdrop-filter 让装饰的动效透过卡片时化为柔和光晕，而不是清晰的色块在动。 */
body .stat-card,
body .device-card,
body .glass-card,
body .table-card,
body .detail-card,
body .empty-card {
    background: rgba(255, 255, 255, 0.40);
    -webkit-backdrop-filter: blur(8px) saturate(1.18);
    backdrop-filter: blur(8px) saturate(1.18);
}

/* 侧边栏用 #navbar.sidebar 选择器，必须带上 ID 才能压过基础规则的 (
   ID 选择器优先级高于 body .sidebar ) */
body #navbar.sidebar {
    background: rgba(255, 255, 255, 0.34);
    -webkit-backdrop-filter: blur(8px) saturate(1.18);
    backdrop-filter: blur(8px) saturate(1.18);
}

body.dark-theme #navbar.sidebar {
    background: rgba(17, 26, 43, 0.52);
}

body.dark-theme .stat-card,
body.dark-theme .device-card,
body.dark-theme .glass-card,
body.dark-theme .table-card,
body.dark-theme .detail-card,
body.dark-theme .empty-card {
    background: rgba(20, 28, 46, 0.55);
}

/* 不支持 backdrop-filter 的浏览器退回近乎不透明的底，避免文字压在装饰上难读 */
@supports not (backdrop-filter: blur(1px)) {
    body .stat-card,
    body .device-card,
    body .glass-card,
    body .table-card,
    body .detail-card,
    body .empty-card {
        background: rgba(255, 255, 255, 0.96);
    }
    body #navbar.sidebar {
        background: rgba(255, 255, 255, 0.96);
    }
    body.dark-theme .stat-card,
    body.dark-theme .device-card,
    body.dark-theme .glass-card,
    body.dark-theme .table-card,
    body.dark-theme .detail-card,
    body.dark-theme .empty-card {
        background: rgba(20, 28, 46, 0.96);
    }
    body.dark-theme #navbar.sidebar {
        background: rgba(17, 26, 43, 0.96);
    }
}

/* ==========================================================================
   控制台动态背景（与登录页同源）
   --------------------------------------------------------------------------
   造型与 @keyframes decoDriftA/B/C 复用登录页那一套（keyframes 是全局的，
   这里只是引用，不修改登录页任何规则），但：
     1. 透明度取登录页的 40–50%，尺寸略小 —— 背景上压着一屏卡片，不能抢注意力；
     2. 用 position: absolute 而不是 fixed —— 只铺在 .main-area（右侧内容区）内，
        既不会盖住白底侧边栏，也不会在滚动时跟着视口乱跑。
   裁剪容器是 .main-area（见上方 position: relative + overflow: hidden），
   .topbar / .content 已提到 z-index: 1，装饰层固定 z-index: 0。
   ========================================================================== */
.console-deco {
    position: absolute;
    z-index: 0;
    pointer-events: none;
    border-radius: 50%;
}

.console-deco-a {
    width: 260px;
    height: 260px;
    top: -78px;
    left: -70px;
    background: radial-gradient(closest-side, rgba(170, 205, 255, .26) 0%, rgba(170, 205, 255, .12) 55%, rgba(170, 205, 255, 0) 100%);
    animation: decoDriftA 28s ease-in-out infinite;
    will-change: transform;
}

.console-deco-b {
    width: 150px;
    height: 150px;
    right: 4%;
    bottom: 6%;
    border-radius: 26px;
    transform: rotate(18deg);
    background: radial-gradient(closest-side, rgba(170, 205, 255, .22) 0%, rgba(170, 205, 255, .10) 55%, rgba(170, 205, 255, 0) 100%);
    animation: decoDriftB 23s ease-in-out infinite;
    will-change: transform;
}

.console-deco-c {
    width: 96px;
    height: 96px;
    right: 22%;
    top: 9%;
    border-radius: 22px;
    transform: rotate(-12deg);
    background: radial-gradient(closest-side, rgba(190, 218, 255, .24) 0%, rgba(190, 218, 255, .10) 55%, rgba(190, 218, 255, 0) 100%);
    animation: decoDriftC 19s ease-in-out infinite;
    animation-delay: -7s;
    will-change: transform;
}

/* 深色主题：同一组晕光换成低亮度深蓝，透明度比浅色低一档，避免深底上发灰 */
body.dark-theme .console-deco-a {
    background: radial-gradient(closest-side, rgba(90, 140, 220, .22) 0%, rgba(90, 140, 220, .09) 55%, rgba(90, 140, 220, 0) 100%);
}

body.dark-theme .console-deco-b {
    background: radial-gradient(closest-side, rgba(90, 140, 220, .17) 0%, rgba(90, 140, 220, .07) 55%, rgba(90, 140, 220, 0) 100%);
}

body.dark-theme .console-deco-c {
    background: radial-gradient(closest-side, rgba(120, 170, 240, .19) 0%, rgba(120, 170, 240, .08) 55%, rgba(120, 170, 240, 0) 100%);
}

/* ==========================================================================
   卡片扩展区：当天 24h 曲线 / 近 7 日曲线 / 电压·烟雾指标行
   --------------------------------------------------------------------------
   默认 display: none —— <1280px（手机、平板、窄窗口）完全不渲染。
   数据只在 ≥1280px 时才向 /hourly、/daily 拉取（见 script.js 的 loadCardHistory）。
   两张曲线都是纯手写 SVG（viewBox 100×40 + preserveAspectRatio="none"），
   不引入任何图表库：卡片上会同时存在 N 份，ECharts 实例成本过高。
   ========================================================================== */
.device-chart,
.device-metrics {
    display: none;
}

/* 卡片主体与三栏包裹层：<1280px 一律 display: contents ——
   不生成盒子、不参与布局，子元素直接落进 .device-card 的纵向 flex 流，
   等于完全没有包裹层，因此手机 / 平板的像素表现与改造前一致。
   ≥1280px 的媒体查询里再把它们变回 grid + 块级三栏。
   （用 display: contents 而不是 JS 判断重排：同一份 DOM，纯 CSS 切换布局） */
.device-body,
.device-col {
    display: contents;
}

.device-chart-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.chart-hint {
    color: var(--ink-4);
    font-size: 11px;
    font-weight: 500;
}

.device-chart-body {
    position: relative;
    height: 68px;
}

.chart-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.chart-grid-line {
    stroke: var(--line-strong);
    stroke-width: 1;
    stroke-dasharray: 3 5;
    vector-effect: non-scaling-stroke;
}

.chart-line {
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    /* viewBox 被非等比拉伸，用 non-scaling-stroke 保证线宽恒定 */
    vector-effect: non-scaling-stroke;
}

.chart-line.chart-line-hourly {
    stroke: #1668dc;
}

.chart-line.chart-line-daily {
    stroke: #0e9f6e;
}

body.dark-theme .chart-line.chart-line-hourly {
    stroke: #6aa9ff;
}

body.dark-theme .chart-line.chart-line-daily {
    stroke: #4ade9b;
}

.chart-area {
    stroke: none;
}

/* 数据不足 / 请求失败时的占位：直接盖住绘图区，绝不画一条假的水平直线 */
.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink-4);
    font-size: 11.5px;
}

.device-chart:not(.is-empty) .chart-empty {
    display: none;
}

.device-chart.is-empty .chart-axis {
    visibility: hidden;
}

.chart-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    color: var(--ink-4);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 1280px) {
    /* ---------- 横向长卡片：4 条轨道 + 卡片跨 2 条 → 恒为「一行 2 张」 ----------
       实测（含竖向滚动条占用的 10px）：
       1440：1150 可用宽 → 轨道 274 → 卡片 566
       1920：1630 可用宽 → 轨道 394 → 卡片 806（更宽，不空旷）
       这里用固定 4 条轨道而不是 auto-fill(minmax(280px,1fr))：auto-fill 在 1920
       会排出 5 条轨道，卡片跨 2 条后每行右侧会多出一条空轨道，出现缺口。 */
    .device-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .device-card {
        grid-column: span 2;
        padding: 14px 18px 10px;
    }

    .device-card .device-header {
        margin-bottom: 8px;
        padding-bottom: 8px;
    }

    /* 三栏卡片里头部略收紧一档，把高度预算留给内容区 */
    .device-card .device-icon {
        flex: 0 0 36px;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 15px;
    }

    /* ---------- 左中右三栏：同一份 DOM，纯 CSS 切换（<1280px 是 display: contents） ---------- */
    .device-body {
        display: grid;
        grid-template-columns: 1.2fr 1fr 1fr;
        align-items: stretch;
        column-gap: 14px;
        /* 撑满卡片剩余高度：某些设备没有指标行（如不支持电压/烟雾）时，
           若不撑开，底部信息行会悬在中间，卡片下半截空着 */
        flex: 1 1 auto;
    }

    .device-col {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    /* 栏间竖分隔线：1px 细线，贯穿整栏高度（grid 行高 = 最高一栏） */
    .device-col + .device-col {
        padding-left: 14px;
        border-left: 1px solid var(--line);
    }

    /* ---------- 左栏：温度 / 湿度 1×2 + 实时曲线 + 指标行 ---------- */
    .device-col-a .device-data {
        gap: 8px;
        margin-bottom: 8px;
    }

    .device-col-a .data-item {
        padding: 7px 10px;
    }

    .device-col-a .data-label {
        margin-bottom: 2px;
    }

    .device-col-a .data-value {
        font-size: 19px;
    }

    .device-col-a .device-spark {
        margin: 0 0 6px;
    }

    .device-col-a .spark-svg {
        height: 28px;
    }

    .device-chart {
        display: block;
        margin: 0;
    }

    .device-chart-body {
        height: 68px;
    }

    /* 指标行贴在左栏底部（父级是 flex column，靠 margin-top: auto 压到底） */
    .device-metrics {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 5px 6px;
        margin-top: auto;
        margin-bottom: 0;
        padding-top: 6px;
        border-top: 1px solid var(--line);
    }

    /* 三个指标全部不显示（设备既没有能力、也从没上报过）时，整块不留空边框 */
    .device-metrics.is-empty {
        display: none;
    }

    /* ---------- 底部信息行：横跨整卡，一行放下「运行 / 通道 / 时间 / 详细」 ---------- */
    .device-card .device-details {
        margin-top: 8px;
        padding-top: 8px;
    }

    /* 覆盖「≥1280 隐藏底部胶囊」的旧规则：胶囊改为在三栏卡片底部一行展示 */
    .device-card .device-details .detail-item {
        display: inline-flex;
    }

    .device-card .device-lastseen {
        display: inline-flex;
    }

    /* 状态徽章是传感器状态的口径重复展示（副标题胶囊已在 <700px 呈现），
       三栏卡片里不再单占一行，避免把卡片顶高 */
    .device-badges {
        display: none;
    }

    .metric {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        max-width: 100%;
        padding: 3px 8px;
        overflow: hidden;
        border-radius: 999px;
        background: var(--surface-2);
        color: var(--ink-3);
        font-size: 11px;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .metric.is-off {
        display: none;
    }

    .metric i {
        color: var(--ink-4);
        font-size: 10px;
    }

    /* 指标数值默认中性灰：正常状态不喧哗，异常（无电 / 报警中）才上色 */
    .metric b {
        color: var(--ink-2);
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }

    .metric b.warn {
        color: var(--warn);
    }

    .metric b.error {
        color: var(--danger);
    }

    /* 状态着色时整颗胶囊一起变色，安全信息要能一眼扫到 */
    .metric.is-alert {
        background: var(--danger-soft);
    }

    .metric.is-alert i {
        color: var(--danger);
    }

    .metric.is-warn {
        background: var(--warn-soft);
    }

    .metric.is-warn i {
        color: var(--warn);
    }
}

/* 超宽屏：轨道本身随可用宽度变宽 → 跨 2 条的卡片自然更宽（1920 约 811px），
   三栏可以再宽松一档，曲线加高到 76px，长卡片上的折线不至于太挤。
   注意：这里不能再改 .device-grid 的列数，否则「一行 2 张」会被破坏。 */
@media (min-width: 1680px) {
    .device-body {
        column-gap: 20px;
    }

    .device-col + .device-col {
        padding-left: 20px;
    }

    .device-chart-body {
        height: 76px;
    }

    /* 左栏更宽后指标行会收到一行内，实时曲线略加高，保持三栏高度与卡片总高协调 */
    .device-col-a .spark-svg {
        height: 36px;
    }
}

/* 尊重系统「减少动态效果」偏好：装饰块停在初始位置 */
@media (prefers-reduced-motion: reduce) {
    .console-deco-a,
    .console-deco-b,
    .console-deco-c {
        animation: none !important;
    }
}

/* 宽屏三栏卡片：底部信息行始终贴着卡片底边。
   不同设备支持的指标数不同（有电压/无电压），.device-body 高度会差一截，
   不贴底的话，内容少的卡片下半截会空出一块，半透明下尤其明显。 */
@media (min-width: 1280px) {
    .device-card .device-details {
        margin-top: auto;
    }
}

/* ==========================================================================
   首页仪表盘（#homeView）
   --------------------------------------------------------------------------
   视觉语言与设备列表完全一致：浅色底 + 半透明白卡（毛玻璃由文件上方的
   body .glass-card 规则统一提供，这里不重复声明背景）+ 16px 圆角 + 发丝边框，
   不加重阴影。统计卡直接复用 .stat-card / .stat-icon，只补充栅格与区块间距。

   栅格：
     <700px        单列堆叠
     700–1279px    两列（AI 分析卡横跨整行）
     ≥1280px       三列（AI 卡横跨整行，报警记录占两列、通知通道占一列）

   所有网格子项都带 min-width: 0，长文本一律换行，保证手机上不出现横向滚动。
   ========================================================================== */

#homeView {
    display: block;
    padding-bottom: 4px;
}

/* ---------- 欢迎区 ---------- */
.home-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin: 4px 0 18px;
}

.home-hero-main {
    min-width: 0;
}

.home-hero-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0;
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
}

/* 问候语与用户名之间不加 flex gap：逗号后紧贴名字才自然 */
#homeUserName {
    color: var(--ink);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.home-hero-role {
    margin-left: 8px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-accent);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.home-hero-desc {
    margin-top: 6px;
    color: var(--ink-3);
    font-size: 13px;
    line-height: 1.5;
}

.home-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--card-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .40);
    -webkit-backdrop-filter: blur(8px) saturate(1.18);
    backdrop-filter: blur(8px) saturate(1.18);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
}

.home-hero-badge i {
    color: var(--ok);
    font-size: 12px;
}

body.dark-theme .home-hero-badge {
    background: rgba(20, 28, 46, .55);
}

@supports not (backdrop-filter: blur(1px)) {
    .home-hero-badge {
        background: rgba(255, 255, 255, .96);
    }

    body.dark-theme .home-hero-badge {
        background: rgba(20, 28, 46, .96);
    }
}

/* ---------- 主体栅格 ---------- */
.home-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    align-items: start;
}

.home-analysis,
.home-alerts,
.home-channels {
    min-width: 0;
}

/* ---------- AI 数据分析卡 ---------- */
.home-analysis {
    position: relative;
    overflow: hidden;
    padding: 22px 24px 20px;
}

/* 顶部 3px 细条：颜色跟随 riskLevel，是整张卡最先被注意到的信号 */
.analysis-band {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--line-strong);
}

.analysis-band.is-normal {
    background: linear-gradient(90deg, #34d399, #10b981);
}

.analysis-band.is-attention {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.analysis-band.is-warning {
    background: linear-gradient(90deg, #f87171, #dc2626);
}

.analysis-band.is-muted {
    background: var(--line-strong);
}

.analysis-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.analysis-head-main {
    min-width: 0;
}

.analysis-date {
    margin-left: 8px;
    color: var(--ink-4);
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.analysis-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.risk-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.risk-chip i {
    font-size: 11px;
}

.risk-chip.is-normal {
    background: var(--ok-soft);
    color: var(--ok);
}

.risk-chip.is-attention {
    background: var(--warn-soft);
    color: var(--warn);
}

.risk-chip.is-warning {
    background: var(--danger-soft);
    color: var(--danger);
}

.risk-chip.is-muted {
    background: var(--surface-3);
    color: var(--ink-4);
}

/* 摘要：整张卡的第一句结论，字号略大于正文 */
.analysis-summary {
    margin-bottom: 14px;
    color: var(--ink);
    font-size: 15.5px;
    font-weight: 500;
    line-height: 1.6;
}

/* 逐设备结论：条目式排版，左侧色条指示 verdict */
.analysis-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.analysis-item {
    position: relative;
    padding: 12px 14px 12px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.analysis-item::before {
    content: '';
    position: absolute;
    top: 11px;
    bottom: 11px;
    left: 0;
    width: 3px;
    border-radius: 3px;
    background: var(--line-strong);
}

.analysis-item.is-ok::before {
    background: #10b981;
}

.analysis-item.is-warn::before {
    background: #f59e0b;
}

.analysis-item.is-off::before {
    background: var(--ink-4);
}

.analysis-item-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.analysis-item-place {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.analysis-item-place i {
    color: var(--ink-4);
    font-size: 11px;
}

.analysis-verdict {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.analysis-verdict.is-ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.analysis-verdict.is-warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.analysis-peak {
    color: var(--ink-4);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.analysis-item-headline {
    margin-bottom: 4px;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.analysis-item-detail {
    color: var(--ink-2);
    font-size: 12.5px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

/* 扩展指标补充说明（供电 / 烟雾 / 信号 / 掉线等非温度结论）。
   定位是「补充证据」：字号略小于 detail、颜色更淡、图标中性灰，
   刻意不用红/橙色，避免看起来像系统告警——是否异常交给后端文案表达。
   文本可能很长（80–120 字，极端情况几百字），必须允许换行且不截断。 */
.analysis-item-metrics {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    color: var(--ink-3);
    font-size: 12px;
    line-height: 1.65;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* 图标对齐首行文字基线：行高 1.65 * 12px ≈ 19.8px，图标 11px，偏移 4px 视觉居中 */
.analysis-item-metrics-icon {
    flex: 0 0 auto;
    margin-top: 4px;
    color: var(--ink-4);
    font-size: 11px;
    line-height: 1;
}

/* min-width: 0 让 flex 子项可以收缩，长串英文/数字才会换行而不是撑破卡片 */
.analysis-item-metrics-text {
    flex: 1 1 auto;
    min-width: 0;
}

/* 深色主题：--ink-3 / --ink-4 在深底上已提亮，这里只把图标再抬一档保证可辨识 */
body.dark-theme .analysis-item-metrics-icon {
    color: var(--ink-3);
}

/* ---------- 逐设备逐小时明细（默认收起，点「展开逐小时」才出现） ---------- */

/* 设备类型小标签：室内 / 室外，弱于判定标签，只做归类提示 */
.analysis-kind {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

/* 当日温度范围：推到条目右侧，扫描时第一眼就能看到区间 */
.analysis-range {
    margin-left: auto;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* 条目底部操作行：左侧峰值 / 最大波动，右侧展开按钮 */
.analysis-item-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 9px;
}

.analysis-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 4px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--ink-3);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.analysis-toggle:hover {
    background: var(--surface-3);
    color: var(--ink);
}

.analysis-toggle:focus-visible {
    outline: 2px solid var(--brand-accent);
    outline-offset: 2px;
}

.analysis-toggle i {
    font-size: 10px;
    transition: transform .18s ease;
}

.analysis-toggle.is-open i {
    transform: rotate(180deg);
}

/* 明细面板：收起态挂 hidden 属性，这里显式压掉，避免被下面的 display 覆盖 */
.analysis-hours {
    /* 温差配色：正=暖 / 负=冷；深色主题在下文提亮，否则深底上看不清 */
    --hour-up: #b45309;
    --hour-down: #1d4ed8;
    --hour-dev-up-bg: rgba(245, 158, 11, .10);
    --hour-dev-down-bg: rgba(59, 130, 246, .10);
    --hour-dev-up-bar: #f59e0b;
    --hour-dev-down-bar: #3b82f6;
    margin-top: 10px;
}

.analysis-hours[hidden] {
    display: none;
}

.analysis-hours-hint {
    margin-bottom: 6px;
    color: var(--ink-4);
    font-size: 11.5px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

/* 横向滚动容器：<700px 时表格可横滑，但页面本身绝不溢出 */
.analysis-hours-scroll {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}

.analysis-hours-table {
    width: 100%;
    min-width: 240px;
    border-collapse: collapse;
    /* 固定列宽：四列在宽屏上不会被拉伸成两三百像素的空旷格子，
       窄屏下也按比例收缩，配合 min-width 保证不会被压扁 */
    table-layout: fixed;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.analysis-hours-table th:nth-child(1),
.analysis-hours-table td:nth-child(1) {
    width: 18%;
}

.analysis-hours-table th:nth-child(2),
.analysis-hours-table td:nth-child(2) {
    width: 26%;
}

.analysis-hours-table th:nth-child(3),
.analysis-hours-table td:nth-child(3) {
    width: 26%;
}

.analysis-hours-table th:nth-child(4),
.analysis-hours-table td:nth-child(4) {
    width: 30%;
}

.analysis-hours-table th,
.analysis-hours-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--line);
    /* 全局 th/td 规则（设备列表表格）会给所有 th 铺 surface-2 底色、
       给首/末列加 10px 圆角；这里显式压平，否则时间列会变成一条灰带 */
    background: transparent;
    border-radius: 0;
    font-size: 12px;
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
}

.analysis-hours-table thead th {
    /* 表头用比表体深一档的底色 + 更实的下边线，24 行时滚动扫读不会迷行 */
    background: var(--surface-3);
    border-bottom: 1px solid var(--line-strong);
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
}

/* 时间列是行表头（th scope=row）：左对齐、弱化，与数值列区分开 */
.analysis-hours-table tbody th {
    color: var(--ink-3);
    text-align: left;
    font-size: 11.5px;
}

.analysis-hours-table tbody td {
    color: var(--ink-2);
}

.analysis-hours-table tbody tr:last-child th,
.analysis-hours-table tbody tr:last-child td {
    border-bottom: none;
}

.analysis-hours-table tbody tr:hover th,
.analysis-hours-table tbody tr:hover td {
    background: var(--surface-3);
}

.analysis-hours-table tbody td.analysis-hour-temp {
    color: var(--ink);
    font-weight: 600;
}

.analysis-hours-table tbody td.analysis-hour-base {
    color: var(--ink-3);
}

/* 温差：正暖负冷，绝对值 ≥2℃ 加粗 */
.analysis-hour-diff.is-up {
    color: var(--hour-up);
}

.analysis-hour-diff.is-down {
    color: var(--hour-down);
}

.analysis-hour-diff.is-flat {
    color: var(--ink-4);
}

.analysis-hour-diff.is-strong {
    font-weight: 700;
}

/* 与 7 日均值偏差 ≥2℃：浅底色 + 左侧细色条，一眼扫出偏离时段
   选择器带上 .analysis-hours-table tbody，确保压过上面的行 hover 底色，
   否则鼠标划过时偏离标记会被 hover 底色盖住。 */
.analysis-hours-table tbody .analysis-hour-row.is-deviated-up th,
.analysis-hours-table tbody .analysis-hour-row.is-deviated-up td {
    background: var(--hour-dev-up-bg);
}

.analysis-hours-table tbody .analysis-hour-row.is-deviated-down th,
.analysis-hours-table tbody .analysis-hour-row.is-deviated-down td {
    background: var(--hour-dev-down-bg);
}

.analysis-hour-row.is-deviated-up .analysis-hour-time {
    box-shadow: inset 2px 0 0 var(--hour-dev-up-bar);
}

.analysis-hour-row.is-deviated-down .analysis-hour-time {
    box-shadow: inset 2px 0 0 var(--hour-dev-down-bar);
}

/* 缺测小时：整行淡化，温度列显示 — */
.analysis-hour-row.is-missing {
    opacity: .55;
}

/* 深色主题：语义色必须提亮，否则深底上反差不足 */
body.dark-theme .analysis-hours {
    --hour-up: #fbbf6b;
    --hour-down: #93c5fd;
    --hour-dev-up-bg: rgba(251, 191, 107, .10);
    --hour-dev-down-bg: rgba(147, 197, 253, .10);
    --hour-dev-up-bar: #fbbf6b;
    --hour-dev-down-bar: #93c5fd;
}

/* 交叉验证：用品牌淡色底区分「模型的旁证推理」与「逐设备结论」 */
.analysis-cross {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--brand-soft);
}

.analysis-cross-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    color: var(--brand-accent);
    font-size: 12px;
    font-weight: 600;
}

.analysis-cross-text {
    color: var(--ink-2);
    font-size: 12.5px;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

/* 建议 */
.analysis-suggest {
    margin-top: 12px;
}

.analysis-suggest-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 600;
}

.analysis-suggest-label i {
    color: var(--warn);
    font-size: 11px;
}

.analysis-suggest-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin: 0;
    padding: 0;
}

.analysis-suggest-list li {
    position: relative;
    padding-left: 16px;
    color: var(--ink-2);
    font-size: 12.5px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.analysis-suggest-list li::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--brand-accent);
}

/* 页脚元信息：模型 / 生成时间，弱化到几乎不抢注意力 */
.analysis-meta {
    margin-top: 12px;
    color: var(--ink-4);
    font-size: 11.5px;
    line-height: 1.5;
}

/* 分析卡内的失败提示（重新分析失败时出现） */
.home-inline-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 12.5px;
    line-height: 1.6;
}

.home-inline-error i {
    margin-top: 2px;
    font-size: 12px;
}

/* ---------- 空态 / 加载态 ---------- */
.home-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    text-align: center;
}

.home-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--surface-3);
    color: var(--ink-4);
    font-size: 15px;
}

.home-empty-title {
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
}

.home-empty-desc {
    max-width: 320px;
    color: var(--ink-4);
    font-size: 12px;
    line-height: 1.6;
}

/* 分析卡的空态/错误态用横向「图标 + 文字」条，比居中空态更省纵向空间 */
.analysis-empty {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.analysis-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand-accent);
    font-size: 15px;
}

.analysis-empty-icon.is-warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.analysis-empty-main {
    min-width: 0;
}

.analysis-empty-title {
    margin-bottom: 4px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
}

.analysis-empty-desc {
    color: var(--ink-3);
    font-size: 12.5px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

/* ---------- 报警记录 / 通知通道 面板 ---------- */
.home-panel {
    display: flex;
    flex-direction: column;
    padding: 18px 20px 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.panel-hint {
    color: var(--ink-4);
    font-size: 11.5px;
    white-space: nowrap;
}

.alert-list {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 2px;
    border-bottom: 1px solid var(--line);
}

.alert-item:last-child {
    border-bottom: none;
    padding-bottom: 2px;
}

.alert-item-dot {
    flex: 0 0 7px;
    width: 7px;
    height: 7px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--ink-4);
}

.alert-item.is-ok .alert-item-dot {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .14);
}

.alert-item.is-warn .alert-item-dot {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .14);
}

.alert-item.is-error .alert-item-dot {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(217, 45, 32, .12);
}

.alert-item-main {
    flex: 1 1 auto;
    min-width: 0;
}

.alert-item-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.45;
}

.alert-item-type {
    color: var(--ink);
}

.alert-item-value {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.alert-item-cond {
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.alert-item-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
    color: var(--ink-3);
    font-size: 11.5px;
    line-height: 1.5;
}

.alert-item-place {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.alert-item-place i {
    color: var(--ink-4);
    font-size: 10px;
}

.alert-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-3);
    font-size: 11px;
    white-space: nowrap;
}

.alert-chip i {
    font-size: 9.5px;
}

.alert-status {
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-4);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.alert-status.is-ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.alert-status.is-warn {
    background: var(--warn-soft);
    color: var(--warn);
}

.alert-status.is-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert-item-time {
    flex: 0 0 auto;
    padding-top: 1px;
    color: var(--ink-4);
    font-size: 11.5px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ---------- 通知通道 ---------- */
.channel-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    min-width: 0;
}

.channel-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line-strong);
}

.channel-item.is-on .channel-dot {
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, .14);
}

.channel-item.is-partial .channel-dot {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .14);
}

.channel-main {
    flex: 1 1 auto;
    min-width: 0;
}

.channel-name {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

.channel-name i {
    color: var(--ink-4);
    font-size: 11px;
}

.channel-desc {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: var(--ink-3);
    font-size: 11.5px;
    line-height: 1.5;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.channel-state {
    flex: 0 0 auto;
    color: var(--ink-4);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.channel-item.is-on .channel-state {
    color: var(--ok);
}

.channel-item.is-partial .channel-state {
    color: var(--warn);
}

/* ---------- 响应式：单列 → 两列 → 三列 ---------- */
@media (min-width: 700px) {
    .home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* AI 分析卡横跨整行 */
    .home-analysis {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1280px) {
    .home-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* AI 卡整行；报警记录占两列，通知通道占一列 */
    .home-alerts {
        grid-column: span 2;
    }
}

@media (max-width: 699.98px) {
    .home-hero {
        margin-bottom: 14px;
    }

    .home-hero-title {
        font-size: 18px;
    }

    .home-hero-badge {
        height: 30px;
        padding: 0 11px;
        font-size: 12px;
    }

    .home-analysis {
        padding: 18px 16px 16px;
    }

    /* 窄屏下按钮跟随标题换行，右对齐更整齐 */
    .analysis-head {
        align-items: flex-start;
    }

    .analysis-head-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .analysis-summary {
        font-size: 15px;
    }

    /* 窄屏：温度范围不再右推（会把设备名挤成一列窄字），跟着 head 自然换行 */
    .analysis-range {
        margin-left: 0;
    }

    /* 扩展指标说明：窄屏只压间距与字号，仍完整换行显示，不做任何截断 */
    .analysis-item-metrics {
        margin-top: 5px;
        font-size: 11.5px;
    }

    .analysis-item-metrics-icon {
        margin-top: 3px;
    }

    /* 逐小时表格：压紧内边距 + 缩小字号，390px 下四列也能完整读，
       真放不下时由 .analysis-hours-scroll 横向滚动兜底 */
    .analysis-hours-table {
        font-size: 11.5px;
        min-width: 224px;
    }

    .analysis-hours-table th,
    .analysis-hours-table td {
        padding: 4px 7px;
    }

    .analysis-hours-hint {
        font-size: 11px;
    }

    .home-panel {
        padding: 16px 16px 14px;
    }

    /* 手机上时间另起一行，避免和地点/渠道挤在一行被压成一列窄字 */
    .alert-item {
        flex-wrap: wrap;
    }

    .alert-item-main {
        flex: 1 1 calc(100% - 18px);
    }

    .alert-item-time {
        margin-left: 17px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .analysis-item,
    .channel-item,
    .home-hero-badge {
        transition: none;
    }
}
