html, body {
    /* 全局字体栈：中文优先走系统中文字体，避免中文被回退到仅含符号的字体导致乱码（浅/深色模式均适用） */
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC",
                 Inter, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Ensure account management panels are spaced consistently from other content */
.hmi-account-section {
    /* Match other panels: 16px vertical spacing, no extra horizontal offset (main provides padding) */
    margin: 16px 0;
}

@media (max-width: 860px) {
    .hmi-account-section {
        margin: 12px 0;
    }
}

/* Visual border for the account list area to separate it from surrounding content */
.hmi-account-table {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.02);
}

.hmi-account-table .hmi-panel-header {
    margin: 0 0 12px 0;
}

/* Make the inner table use full width inside the bordered box and keep scrolling behavior */
.hmi-account-table .hmi-table-wrap {
    overflow: auto;
}

/* Make light-theme render the same visual effect as dark mode for the account list */
html[data-theme="light"] .hmi-account-table {
    /* stronger contrast in light theme so the border is visible against white backgrounds */
    background: rgba(255,255,255,0.92) !important;
    border-color: rgba(16,24,40,0.08) !important;
    box-shadow: 0 6px 18px rgba(16,24,40,0.04);
}

/* Make the header divider inside the account table visible (both themes) */
.hmi-account-table .hmi-panel-header {
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 0.25px solid rgba(255,255,255,0.06);
}

/* Light theme: use darker divider so it is visible on white background */
html[data-theme="light"] .hmi-account-table .hmi-panel-header {
    border-bottom-color: rgba(16,24,40,0.08) !important;
}

/* Row dividers inside account list: use cell borders for consistent rendering */
.hmi-account-table .hmi-table {
    border-collapse: collapse;
}

/* Divider between the table header and the first data row */
.hmi-account-table .hmi-table thead th {
    border-bottom: 0.25px solid rgba(255,255,255,0.12);
}

html[data-theme="light"] .hmi-account-table .hmi-table thead th {
    border-bottom-color: rgba(16,24,40,0.12) !important;
}

.hmi-account-table .hmi-table tbody td {
    border-bottom: 0.25px solid rgba(255,255,255,0.08);
    box-shadow: inset 0 -0.25px 0 rgba(255,255,255,0.08);
}

.hmi-account-table .hmi-table tbody tr:last-child td {
    border-bottom: none;
    box-shadow: none;
}

/* Light theme: make the horizontal lines visible on white backgrounds */
html[data-theme="light"] .hmi-account-table .hmi-table tbody td {
    border-bottom-color: rgba(16,24,40,0.10) !important;
    box-shadow: inset 0 -0.25px 0 rgba(16,24,40,0.10) !important;
}

html[data-theme="light"] .hmi-account-table .hmi-table tbody tr:last-child td {
    box-shadow: none !important;
}

/* subtle hover to aid row affordance */
.hmi-account-table .hmi-table tbody tr:hover {
    background: rgba(var(--hmi-accent-rgb),0.02);
}

/* Removed custom icon font (not needed since inline SVGs are used). */

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA9NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA7MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N7MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "发生错误，请稍后重试。"
    }

.components-reconnect-modal,
.components-reconnect-modal p,
.components-reconnect-modal h1,
.components-reconnect-modal h2,
.components-reconnect-modal h3,
.components-reconnect-modal h4,
.components-reconnect-modal h5,
.components-reconnect-modal h6,
.components-reconnect-modal span,
.components-reconnect-modal div {
    color: #000;
}

/* Make the localized 'Rejoin failed' message render black in dark theme for visibility
   while keeping the default color in light theme. */
.reconnect-failed-black {
    color: inherit;
}

/* Stronger override for reconnect text inside the reconnect modal to beat inline or theme styles */
html[data-theme="dark"] .components-reconnect-modal .reconnect-failed-black,
html[data-theme="dark"] .reconnect-failed-black {
    color: #1f2937 !important;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

html, body {
    margin: 0;
    min-height: 100%;
    background: #0f1320;
    color: #e8ecff;
}

:root {
    --hmi-sidebar-width: 220px;
    --hmi-sidebar-collapsed-width: 100px;
    --hmi-sidebar-gap: 20px; /* extra gap between sidebar and content */
    --hmi-text-primary: #e8ecff;
    --hmi-text-secondary: #9ca3af;
    --hmi-text-muted: #9aa3b6;
    --hmi-status-on: #67e29a;
    --hmi-status-off: #4b5563;
    /* 深色主题下的边框与主色变量（Reports/LogTrendChart SVG 线条和 spinner 消费） */
    --hmi-border: rgba(255, 255, 255, 0.08);
    --hmi-primary: #4c7dff;
    /* 色调 token：以 RGB 三元组提供色板，便于 rgba() 按透明度复用，值与原字面量一致（零视觉漂移） */
    --hmi-accent-rgb: 76, 125, 255;       /* 主蓝 #4c7dff */
    --hmi-accent2-rgb: 127, 93, 255;      /* 辅紫 #7f5dff */
    --hmi-surface-rgb: 31, 36, 55;        /* 面板表面 #1f2437 */
    --hmi-sidebar-rgb: 15, 19, 31;        /* 侧栏表面 #0f131f */
    /* 按钮渐变（主/危险）+ 按钮主色默认值（深色侧缺失时兜底） */
    --accent: #4c7dff;
    --accent-2: #7f5dff;
    --hmi-grad-primary: linear-gradient(90deg, #4c7dff, #7f5dff);
    --hmi-grad-danger: linear-gradient(90deg, #ff7a7a, #ffb199);
    /* 状态色板（值用字面 hex 定义，被下方各规则以 var() 消费） */
    --hmi-green: #34d399;
    --hmi-green-rgb: 52, 211, 153;
    --hmi-red: #f87171;
    --hmi-red-rgb: 248, 113, 113;
    --hmi-amber: #f59e0b;
    --hmi-amber-rgb: 245, 158, 11;
    --hmi-yellow: #facc15;
    --hmi-cyan: #22d3ee;
    --hmi-cyan-rgb: 34, 211, 238;
    --hmi-blue: #4c7dff;
    --hmi-orange: #fb923c;
    --hmi-purple: #9a7dff;
    /* 玻璃与渐变语义 token：统一模糊与表面半透明，避免各处即兴数值 */
    --hmi-glass-blur: 10px;
    --hmi-surface-panel: rgba(var(--hmi-surface-rgb), 0.88);
    --hmi-surface-tab: rgba(var(--hmi-surface-rgb), 0.60);
    --hmi-grad-blue: linear-gradient(135deg, #4c7dff, #7d8cff);
    --hmi-grad-green: linear-gradient(135deg, #2dbf8a, #53d17d);
    --hmi-grad-orange: linear-gradient(135deg, #ff9a52, #ff6f61);
    --hmi-grad-yellow: linear-gradient(135deg, #ffd24d, #ffb84d);
    --hmi-grad-red: linear-gradient(135deg, #ff5f6d, #ff7b7b);
    --hmi-grad-purple: linear-gradient(135deg, #9c7bff, #6e74ff);
}

a {
    color: inherit;
}

.hmi-shell {
    min-height: 100vh;
    display: flex;
    background: radial-gradient(circle at top, #1d2236 0%, #121624 55%, #0f1320 100%);
    color: #e8ecff;
    /* 中文字体优先，避免浅色模式下字体回退到符号字形产生乱码（▼▲ 等不可读字符） */
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC",
                 Inter, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    box-sizing: border-box;
    /* reserve space for the fixed sidebar plus a small visual gap so panels don't touch */
    padding-left: calc(var(--hmi-sidebar-width) + var(--hmi-sidebar-gap));
}

html[data-sidebar-collapsed="true"] .hmi-shell {
    padding-left: calc(var(--hmi-sidebar-collapsed-width) + var(--hmi-sidebar-gap));
}

.hmi-sidebar {
    width: var(--hmi-sidebar-width);
    height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    padding: 18px 14px;
    background: rgba(var(--hmi-sidebar-rgb), 0.82);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
    z-index: 20;
}

/* 侧栏采用单段固定头 + 滚动导航布局：
   ┌─────────────────────┐
   │ .hmi-brand          │  flex:0 固定（吸顶，含品牌名 + 折叠按钮）
   ├─────────────────────┤  ← 顶部渐变遮挡，视觉衔接
   │ .hmi-nav            │  flex:1 独立滚动（唯一滚动区）
   └─────────────────────┘
   这样用户在滚动中间导航列表时，顶部品牌/折叠按钮不会跟随滚动。 */

/* 吸顶区：顶部折叠按钮行在品牌区上方，二者均固定顶部（position:sticky 兜底）。
   实际这里 header 在 .hmi-sidebar（overflow:hidden）内部是兄弟节点，
   不需要 sticky 也不会滚动；sticky 仅作安全兜底。 */

/* 顶部折叠按钮行：在品牌区上方，展开时按钮靠右，折叠时按钮居中。
   背景完全透明。 */
.hmi-sidebar-tools {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 2px 0 16px;
    background: transparent;
}

.hmi-brand {
    flex: 0 0 auto;
    position: sticky;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 0 14px;
    background: transparent;
    position: relative;
}

/* 中间导航区：唯一滚动容器。min-height:0 是 flex 子项能正确触发 overflow 的关键
   （Firefox / Safari 默认 min-height = content，会把整个 sidebar 撑爆）。 */
.hmi-nav {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-auto-rows: min-content;
    align-content: start;
    gap: 8px;
    margin: 8px 0 0;
    padding: 8px 4px 14px;
    margin-inline: -4px;
    padding-inline: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    /* 与全局一致统一到 thin 细条，避免 scrollbar-gutter 参与宽度计算导致比主滚动条更细 */
    scrollbar-width: thin;
}

/* 导航栏底部固定空行：位于滚动区之外，flex 不收缩、恒占一行，不随导航列表滚动 */
.hmi-nav-spacer {
    flex: 0 0 auto;
    height: 40px;
    flex-shrink: 0;
}

/* 全局滚动条统一样式：微窄 + 深浅主题配色
   注意：::-webkit-scrollbar 是整个滚动条"容器"（gutter 区域），
   在 Windows Chromium 下其默认背景会落回系统深色主题色，必须显式声明容器颜色。
   我们给容器直接写入与页面一致的背景色，而不是靠 transparent 透出，以此覆盖浏览器原生默认值。 */
* { scrollbar-width: thin; scrollbar-color: #262C3E rgba(20, 26, 42, 0.98); }
*::-webkit-scrollbar { width: 3px; height: 3px; background: rgba(20, 26, 42, 0.98); }
*::-webkit-scrollbar-track { background: rgba(20, 26, 42, 0.98); }
*::-webkit-scrollbar-thumb { background: #262C3E; border-radius: 2px; }
*::-webkit-scrollbar-thumb:hover { background: #323A52; }
*::-webkit-scrollbar-corner { background: rgba(20, 26, 42, 0.98); }

/* 深色主题（默认）：显式覆盖 html / body 根元素，确保页面主滚动条配色一致 */
html, body { scrollbar-color: #262C3E rgba(20, 26, 42, 0.98); }
html::-webkit-scrollbar, body::-webkit-scrollbar { width: 3px; height: 3px; background: rgba(20, 26, 42, 0.98); }
html::-webkit-scrollbar-track, body::-webkit-scrollbar-track { background: rgba(20, 26, 42, 0.98); }
html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb { background: #262C3E; border-radius: 2px; }
html::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover { background: #323A52; }
html::-webkit-scrollbar-corner, body::-webkit-scrollbar-corner { background: rgba(20, 26, 42, 0.98); }

/* 浅色主题：显式把 ::-webkit-scrollbar 容器 + track 写成与浅色页面背景一致的颜色，
   彻底避免 Windows Chromium 将其回退为系统深色轨道带。
   浅色 body 背景为 #eef3fb。 */
html[data-theme=light], html[data-theme=light] body,
html[data-theme=light] * { scrollbar-color: #c9d4e9 #eef3fb; }
html[data-theme=light]::-webkit-scrollbar, html[data-theme=light] body::-webkit-scrollbar,
html[data-theme=light] *::-webkit-scrollbar { width: 3px; height: 3px; background: #eef3fb; }
html[data-theme=light]::-webkit-scrollbar-track, html[data-theme=light] body::-webkit-scrollbar-track,
html[data-theme=light] *::-webkit-scrollbar-track { background: #eef3fb; }
html[data-theme=light]::-webkit-scrollbar-thumb, html[data-theme=light] body::-webkit-scrollbar-thumb,
html[data-theme=light] *::-webkit-scrollbar-thumb { background: #c9d4e9; border-radius: 2px; }
html[data-theme=light]::-webkit-scrollbar-thumb:hover, html[data-theme=light] body::-webkit-scrollbar-thumb:hover,
html[data-theme=light] *::-webkit-scrollbar-thumb:hover { background: #b3c2de; }
html[data-theme=light]::-webkit-scrollbar-corner, html[data-theme=light] body::-webkit-scrollbar-corner,
html[data-theme=light] *::-webkit-scrollbar-corner { background: #eef3fb; }


html[data-sidebar-collapsed="true"] .hmi-sidebar {
    width: 84px;
    padding-inline: 10px;
}

/* 收起态：折叠按钮行居中；品牌文字/图标隐藏，仅按钮仍居中显示 */
html[data-sidebar-collapsed="true"] .hmi-sidebar-tools {
    width: 100%;
    justify-content: center;
}

html[data-sidebar-collapsed="true"] .hmi-brand {
    width: 100%;
    justify-content: center;
}

.hmi-brand-text {
    display: flex;
    flex-direction: column;
}

.hmi-brand-mark {
    width: 60px;
    height: 50px;
    border-radius: 14px;
    background: var(--hmi-grad-primary);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.5px;
    color: #fff;
    box-shadow: 0 10px 24px rgba(var(--hmi-accent-rgb), 0.28);
}

.hmi-brand-text strong {
    display: block;
    font-size: 1.15rem;
}

.hmi-brand-text span {
    display: block;
    margin-top: 2px;
    font-size: 0.9rem;
    color: #8f96b8;
}

html[data-sidebar-collapsed="true"] .hmi-brand-text,
html[data-sidebar-collapsed="true"] .hmi-nav-text {
    display: none;
}

html[data-sidebar-collapsed="false"] .hmi-brand-text,
html[data-sidebar-collapsed="false"] .hmi-nav-text,
html[data-sidebar-collapsed="false"] .hmi-theme-button {
    display: block;
}

.hmi-sidebar-toggle {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #4c7dff;
    cursor: pointer;
    flex: 0 0 auto;
    font-size: 1.45rem;
    transition: background 0.16s ease, box-shadow 0.16s ease, color 0.12s ease;
}

.hmi-sidebar-toggle .icon-expanded {
    display: none;
}

html[data-sidebar-collapsed="true"] .hmi-sidebar-toggle .icon-collapsed {
    display: inline;
}

html[data-sidebar-collapsed="true"] .hmi-sidebar-toggle .icon-expanded {
    display: none;
}

html[data-sidebar-collapsed="false"] .hmi-sidebar-toggle .icon-collapsed {
    display: none;
}

html[data-sidebar-collapsed="false"] .hmi-sidebar-toggle .icon-expanded {
    display: inline;
}

/* 展开态：折叠按钮往左靠一点（右侧留出空隙）；折叠态按钮居中，不受影响 */
html[data-sidebar-collapsed="false"] .hmi-sidebar-toggle {
    margin-right: 10px;
}

.hmi-sidebar-toggle:hover {
    background: rgba(var(--hmi-accent-rgb), 0.26);
    box-shadow: 0 8px 20px rgba(var(--hmi-accent-rgb), 0.10);
}

.hmi-sidebar-toggle:focus-visible {
    outline: 2px solid #4c7dff;
    outline-offset: 2px;
    box-shadow: 0 8px 26px rgba(var(--hmi-accent-rgb),0.14);
}

/* .hmi-nav 主样式（滚动容器、flex 占比等）已在 .hmi-sidebar 三段式布局中定义。
   这里不再重复，仅保留内部 NavLink 条目样式。 */

.hmi-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 14px;
    border-radius: 12px;
    text-decoration: none;
    color: #a9afcb;
    font-size: 1rem;
    background: transparent;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.hmi-nav-icon {
    width: 20px;
    text-align: center;
    color: #7ea1ff;
    flex: 0 0 auto;
}

/* icon-font class removed — using inline SVGs instead */

.hmi-nav-svg {
    width: 26px;
    height: 26px;
    display: block;
    stroke: none;
}

/* Make username in the topbar user chip more prominent */
.hmi-user-meta strong {
    font-size: 1.5rem; /* larger */
    font-weight: 600;
    line-height: 1;
    display: block;
}

.hmi-user-meta span {
    font-size: 0.8rem;
    color: #9aa4c7;
}

/* ConfirmDialog / Modal styles (fresh, theme-aware) */
:root {
    --accent: #4c7dff; /* primary accent */
    --accent-2: #7f5dff;
    --modal-bg: rgba(255, 255, 255, 0.06);
    --modal-text: #e8ecff;
    --modal-border: rgba(255,255,255,0.06);
    --backdrop: rgba(8, 12, 20, 0.45);
}

.hmi-modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--backdrop);
    backdrop-filter: blur(14px) saturate(1.18);
    display: grid;
    place-items: center;
    z-index: 2000;
    padding: 20px;
    animation: hmi-fade-in 160ms ease;
}

.hmi-modal {
    width: min(560px, 100%);
    margin: auto;
    background: rgba(18, 22, 36, 0.42);
    backdrop-filter: blur(18px) saturate(1.25);
    color: var(--modal-text);
    border-radius: 12px;
    box-shadow:
        0 22px 50px rgba(2, 6, 23, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255,255,255,0.14);
    overflow: hidden;
    transform: translateY(6px) scale(0.995);
    animation: hmi-pop-in 180ms cubic-bezier(.2,.9,.28,1) forwards;
}

.hmi-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.06);
}

.hmi-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--modal-text);
}

.hmi-modal-body {
    padding: 16px 20px;
    color: var(--modal-text, rgba(232,236,255,0.95));
    font-size: 0.98rem;
    background: rgba(255,255,255,0.02);
}

.hmi-modal-footer {
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}

.hmi-button {
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    border: 0;
    min-width: 76px;
    transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.hmi-button-muted {
    background: transparent;
    color: rgba(150,170,200,0.95);
    border: 1px solid rgba(255,255,255,0.04);
}

.hmi-button-primary {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    color: white;
    box-shadow: 0 8px 20px rgba(var(--hmi-accent-rgb),0.14);
}

.hmi-button-danger {
    background: var(--hmi-grad-danger);
    color: white;
}

.hmi-button:hover { transform: translateY(-2px); }

/* 按下反馈：回弹到原位并轻微收缩，配合阴影压沉，感知"已按下" */
.hmi-button:active {
    transform: translateY(0) scale(0.97);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.20);
}

.hmi-button:focus {
    outline: 3px solid rgba(var(--hmi-accent-rgb),0.12);
    outline-offset: 2px;
}

@keyframes hmi-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes hmi-pop-in { to { transform: translateY(0) scale(1) } }

/* Light theme overrides */
html[data-theme="light"] {
    --accent: #3b82f6;
    --accent-2: #60a5fa;
    --modal-bg: rgba(255, 255, 255, 0.72);
    --modal-text: #0f1724;
    --modal-border: rgba(16,24,40,0.06);
    --backdrop: rgba(240, 244, 255, 0.7);
    /* 文本 token：与深色侧的 :root --hmi-text-* 对齐，确保任何使用
       var(--hmi-text-primary/secondary/muted) 的组件在切主题时立刻变色。
       取值与 UI Style Guideline 一致。 */
    --hmi-text-primary: #172034;
    --hmi-text-secondary: #5b6782;
    --hmi-text-muted: #5b667c;
    /* 浅色主题下的边框/主色变量 */
    --hmi-border: rgba(15, 23, 42, 0.08);
    --hmi-primary: #4c7dff;
    /* 表面 token 浅色侧：白色系 */
    --hmi-surface-rgb: 255, 255, 255;
    --hmi-sidebar-rgb: 255, 255, 255;
}

/* Use a semi-transparent "glass" modal in light theme to keep the fresh translucent look */
html[data-theme="light"] .hmi-modal {
    background: var(--modal-bg);
    backdrop-filter: blur(18px) saturate(1.25);
    color: var(--modal-text);
    border-color: rgba(16,24,40,0.10);
    box-shadow:
        0 18px 40px rgba(16,24,40,0.08),
        inset 0 1px 0 rgba(255,255,255,0.5);
}

html[data-theme="dark"] .hmi-modal {
    background: rgba(18, 22, 36, 0.42);
    backdrop-filter: blur(18px) saturate(1.25);
    border-color: rgba(255,255,255,0.14);
}

/* Improve contrast for modal body text in light theme */
html[data-theme="light"] .hmi-modal-body {
    color: #172034; /* stronger dark text */
}

html[data-theme="light"] .hmi-modal-header,
html[data-theme="light"] .hmi-modal-footer {
    background: rgba(255,255,255,0.12);
}

html[data-theme="light"] .hmi-button-muted {
    color: #55607a;
    border-color: rgba(16,24,40,0.06);
}


.hmi-nav-svg path,
.hmi-nav-svg rect,
.hmi-nav-svg circle {
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.hmi-nav-item:hover .hmi-nav-svg path,
.hmi-nav-item:hover .hmi-nav-svg rect,
.hmi-nav-item:hover .hmi-nav-svg circle {
    transform: translateY(-2px);
    opacity: 1;
}

/* Make all nav SVG shapes follow the text color so icons stay consistent */
.hmi-nav-svg {
    color: inherit;
}

.hmi-nav-svg path,
.hmi-nav-svg rect,
.hmi-nav-svg circle {
    fill: currentColor !important;
}

.hmi-nav-text {
    white-space: nowrap;
}

html[data-sidebar-collapsed="true"] .hmi-nav-item {
    justify-content: center;
    padding: 13px 14px;
}

html[data-sidebar-collapsed="false"] .hmi-nav-item {
    justify-content: flex-start;
}

html[data-sidebar-collapsed="true"] .hmi-nav-icon {
    margin: 0;
}

.hmi-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    transform: scale(1.04);
}

.hmi-nav-item.active {
    background: rgba(255, 255, 255, 0.06);
    color: #4c7dff; /* selected color (blue) */
    transform: scale(1.04);
}

/* Ensure selected nav item stays blue across theme-specific overrides */
html .hmi-nav-item.active,
html[data-theme="light"] .hmi-nav-item.active {
    color: #4c7dff !important;
}

/* Force-fill SVG shapes and text inside active nav item to the selected blue */
.hmi-nav-item.active .hmi-nav-svg path,
.hmi-nav-item.active .hmi-nav-svg rect,
.hmi-nav-item.active .hmi-nav-svg circle,
.hmi-nav-item.active .hmi-nav-text {
    color: #4c7dff !important;
    fill: #4c7dff !important;
}

.hmi-nav-item:active {
    transform: scale(0.98);
}

.hmi-main {
    flex: 1;
    width: 100%;
    margin-left: 0;
    padding: 82px 22px 22px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

html[data-sidebar-collapsed="true"] .hmi-main {
    width: 100%;
    margin-left: 0;
}

/* Small visual gap so the content panels don't touch the sidebar edge */
.hmi-main > * {
    margin-left: 0;
}

.hmi-shell-content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

.hmi-footer {
    margin-top: auto;
    padding: 18px 0 4px;
    text-align: center;
    font-size: 0.78rem;
    color: #8f96b8;
    letter-spacing: 0.2px;
}

html[data-theme="light"] .hmi-footer {
    color: #64748b;
}

.hmi-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.hmi-page-meta {
    display: flex;
    flex-direction: column;
}

.hmi-page-title {
    margin: 0; /* 作为 h1 渲染时清除浏览器默认外边距 */
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.hmi-page-subtitle {
    margin-top: 4px;
    font-size: 0.85rem;
    color: #8f96b8;
}

.hmi-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 18px;
    right: 22px;
    z-index: 1000;
}

.hmi-topbar-actions .hmi-user-chip {
    margin-left: 6px;
}
/* 顶栏待办/预警徽标 */
.hmi-alert-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-left: 4px;
    border: 1px solid var(--hmi-border, rgba(255, 255, 255, 0.12));
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--hmi-text-secondary, #9aa4b2);
    cursor: pointer;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.hmi-alert-badge:hover {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.4);
    color: var(--hmi-red);
}
.hmi-alert-icon {
    width: 18px;
    height: 18px;
}
.hmi-alert-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--hmi-red);
    box-shadow: 0 0 0 2px var(--hmi-sidebar-bg, #141a26);
    animation: hmi-pulse 1.6s infinite;
}
.hmi-alert-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 17px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--hmi-sidebar-bg, #141a26);
}
@keyframes hmi-pulse {
    0% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.55); }
    70% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
}

/* Shell user chip layout: avatar left, details center, logout right */
.hmi-topbar-actions .hmi-user-chip {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;
    white-space: nowrap;
}

.hmi-topbar-actions .hmi-user-avatar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 24px;
    height: auto;
}

.hmi-topbar-actions .hmi-user-summary {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    gap: 12px;
    white-space: nowrap;
}

.hmi-topbar-actions .hmi-user-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    align-self: center;
}

.hmi-topbar-actions .hmi-logout-button {
    margin-left: auto;
    flex: 0 0 auto;
    align-self: center;
}

.hmi-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(72, 211, 114, 0.14);
    color: #9ef0b6;
    font-size: 0.8rem;
    font-weight: 600;
}

.hmi-pill,
.hmi-theme-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hmi-theme-button {
    display: inline-flex;
}

.hmi-pill-soft {
    background: rgba(255, 255, 255, 0.06);
    color: #d4d9ee;
}

.hmi-cards,
.hmi-grid {
    display: grid;
    gap: 16px;
}

.hmi-cards {
    /* 自适应：卡片一次铺得下就整行排满（5 张也能一行），空间不足再均匀换行，避免第二排只剩 1 张的孤卡 */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

.hmi-grid.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hmi-grid.split-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 网格项允许收缩到容器宽度（默认 min-width:auto 会被内容撑宽，造成两行宽度不一、右侧留白） */
.hmi-grid.two-col > .hmi-panel,
.hmi-grid.split-wide > .hmi-panel {
    min-width: 0;
}

/* 所有区块容器统一底部间距，与上下区块保持一致 */
.hmi-cards,
.hmi-grid,
section.hmi-panel {
    margin-bottom: 16px;
}

.hmi-panel,
.hmi-stat-card {
    background: var(--hmi-surface-panel);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(var(--hmi-glass-blur));
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

/* hover 反馈：统计卡轻浮升；面板仅加深/提亮光影与描边（用 transform 会让大内容表格抖动，这里不位移） */
.hmi-stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 22px 40px rgba(0, 0, 0, 0.28);
}

.hmi-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 34px rgba(0, 0, 0, 0.22);
}

@media (prefers-reduced-motion: reduce) {
    .hmi-stat-card:hover { transform: none; }
}

/* =====================================================================
 * A2 / A3 新增 UI 类：严格复用现有 HMI 视觉基准，不改变任何已有类。
 *   - 面板圆角 18px / 遮罩背景 rgba(7,10,20,0.72) / 字体色 --hmi-text-*
 *   - 按钮圆角 10px，primary 沿用蓝紫渐变 #4c7dff -> #7f5dff
 *   - tag / badge 颜色：绿 #10b981 / 紫 #8b5cf6 / 红 #ef4444 并加半透明底
 *   - 分隔线统一 rgba(255,255,255,0.06)，字段输入透明 focus 渐变下划线
 * （新增类全部作用域限定在 .hmi-shell / section.hmi-panel 内，不影响其他模块）
 * ===================================================================== */

.hmi-tabbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 18px;
    background: var(--hmi-surface-tab);
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(var(--hmi-glass-blur));
    box-shadow: 0 14px 26px rgba(0, 0, 0, 0.14);
}

.hmi-tab {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--hmi-text-secondary, #9ca3af);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.hmi-tab:hover {
    transform: translateY(-1px);
    color: var(--hmi-text-primary, #e8ecff);
    border-color: rgba(var(--hmi-accent-rgb), 0.30);
    background: rgba(var(--hmi-accent-rgb), 0.08);
}

.hmi-tab.active {
    background: var(--hmi-grad-primary);
    color: #fff;
    font-weight: 700;
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 10px 22px rgba(var(--hmi-accent-rgb), 0.32);
}

/* 顶部工具栏：搜索框 + 主按钮，与账户管理页面 hmi-account-button 风格一致 */
.hmi-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.hmi-toolbar input.hmi-login-field-input,
.hmi-toolbar select.hmi-login-field-input {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.hmi-toolbar select.hmi-login-field-input {
    color: #e8ecff;
    padding-right: 32px;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    background-color: rgba(36, 42, 68, 0.92);
    border-color: rgba(255, 255, 255, 0.14);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23e8ecff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    cursor: pointer;
    font-weight: 500;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}
.hmi-toolbar select.hmi-login-field-input option {
    background-color: #20253d;
    color: #e8ecff;
}

.hmi-toolbar input.hmi-login-field-input:focus,
.hmi-toolbar select.hmi-login-field-input:focus {
    border-color: rgba(var(--hmi-accent-rgb), 0.5);
    box-shadow: 0 0 0 3px rgba(var(--hmi-accent-rgb), 0.14);
    background: rgba(255, 255, 255, 0.05);
}
.hmi-toolbar select.hmi-login-field-input:focus {
    background-color: rgba(36, 42, 68, 0.96);
}

/* 模态弹窗：遮罩 + 面板，完全复刻 hmi-panel 的玻璃感 */
.hmi-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 20, 0.72);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 50;
}

.hmi-modal {
    width: 100%;
    max-width: 680px;
    max-height: 86vh;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: rgba(31, 36, 55, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.38);
    color: var(--hmi-text-primary, #e8ecff);
    overflow: hidden;
}

.hmi-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hmi-modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.hmi-modal-close {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--hmi-text-secondary, #9ca3af);
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.hmi-modal-close:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ff8e8e;
    transform: translateY(-1px);
}

.hmi-modal-body {
    padding: 14px 6px 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

.hmi-modal-body .hmi-login-field-set {
    padding: 2px 0;
}

.hmi-modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
}

/* A2 Devices 页面新增：点位快照表格（继承 hmi-table，只补 sticky 与单元格 padding 微调） */
.hmi-snapshot-table thead th {
    font-weight: 700;
    color: var(--hmi-text-secondary, #9ca3af);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hmi-snapshot-table tbody tr:hover td {
    background: rgba(var(--hmi-accent-rgb), 0.06);
}

/* A3 点位标签 accent 色补两个（保持与 .accent-*.hmi-icon 渐变家族一致） */
.hmi-tag.accent-green {
    background: rgba(45, 191, 138, 0.14);
    color: #63e6ab;
}

.hmi-tag.accent-purple {
    background: rgba(156, 123, 255, 0.16);
    color: #c5b1ff;
}

/* 明亮模式下的新增组件配色覆写（与现有 html[data-theme="light"] .hmi-panel / .hmi-tag 风格对齐） */
html[data-theme="light"] .hmi-tabbar {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .hmi-tab {
    color: var(--hmi-text-secondary, #5b6782);
    border-color: rgba(15, 23, 42, 0.08);
    background: rgba(15, 23, 42, 0.02);
}

html[data-theme="light"] .hmi-tab:hover {
    border-color: rgba(var(--hmi-accent-rgb), 0.35);
    color: var(--hmi-text-primary, #172034);
    background: rgba(var(--hmi-accent-rgb), 0.06);
}

html[data-theme="light"] .hmi-tab.active {
    background: linear-gradient(90deg, #4c7dff, #7f5dff);
    color: #fff;
    font-weight: 700;
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 20px rgba(76, 125, 255, 0.16);
}

html[data-theme="light"] .hmi-toolbar input.hmi-login-field-input,
html[data-theme="light"] .hmi-toolbar select.hmi-login-field-input {
    background: rgba(15, 23, 42, 0.02);
    border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .hmi-toolbar select.hmi-login-field-input {
    background-color: #ffffff;
    color: #172034;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23172034' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    box-shadow: none;
}
html[data-theme="light"] .hmi-toolbar select.hmi-login-field-input option {
    background-color: #ffffff;
    color: #172034;
}

html[data-theme="light"] .hmi-toolbar input.hmi-login-field-input:focus,
html[data-theme="light"] .hmi-toolbar select.hmi-login-field-input:focus {
    border-color: rgba(var(--hmi-accent-rgb), 0.50);
    background: #fff;
}

html[data-theme="light"] .hmi-modal {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(15, 23, 42, 0.08);
    color: var(--hmi-text-primary, #172034);
    box-shadow: 0 26px 50px rgba(15, 23, 42, 0.18);
}

html[data-theme="light"] .hmi-modal-header,
html[data-theme="light"] .hmi-modal-footer {
    border-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .hmi-modal-footer {
    background: rgba(15, 23, 42, 0.02);
}

html[data-theme="light"] .hmi-snapshot-table thead th {
    color: var(--hmi-text-secondary, #5b6782);
    border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .hmi-tag.accent-green {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

html[data-theme="light"] .hmi-tag.accent-purple {
    background: rgba(124, 58, 237, 0.12);
    color: #7c3aed;
}

.hmi-stat-card {
    padding: 18px;
    min-height: 132px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hmi-stat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #aab0ce;
    font-size: 0.82rem;
}

.hmi-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-weight: 700;
}

.hmi-stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.hmi-stat-foot {
    color: #95a0bf;
    font-size: 0.8rem;
}

.accent-blue .hmi-icon { background: var(--hmi-grad-blue); }
.accent-green .hmi-icon { background: var(--hmi-grad-green); }
.accent-orange .hmi-icon { background: var(--hmi-grad-orange); }
.accent-yellow .hmi-icon { background: var(--hmi-grad-yellow); }
.accent-red .hmi-icon { background: var(--hmi-grad-red); }
.accent-purple .hmi-icon { background: var(--hmi-grad-purple); }

.hmi-panel {
    padding: 18px;
}

.hmi-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hmi-panel-header h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.hmi-tag {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.72rem;
    color: #aeb4d0;
}

.hmi-tag.danger {
    background: rgba(255, 89, 89, 0.12);
    color: #ff8e8e;
}

.hmi-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(180px, 0.7fr);
    gap: 16px;
    align-items: stretch;
}

.hmi-chart-box {
    min-height: 240px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(var(--hmi-accent-rgb), 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 14px;
}

.hmi-chart-title {
    font-size: 0.84rem;
    color: #b7bdd8;
    margin-bottom: 14px;
}

.hmi-chart-placeholder {
    height: calc(100% - 30px);
    display: flex;
    align-items: end;
    gap: 12px;
    padding: 10px 6px 4px;
}

.hmi-bar {
    flex: 1;
    border-radius: 12px 12px 4px 4px;
    background: linear-gradient(180deg, rgba(94, 140, 255, 0.95), rgba(94, 140, 255, 0.25));
    box-shadow: 0 10px 20px rgba(72, 109, 255, 0.16);
}

.hmi-kpi-list,
.hmi-status-list,
.hmi-alarm-list,
.hmi-report-grid,
.hmi-config-grid {
    display: grid;
    gap: 10px;
}

.hmi-kpi-item,
.hmi-status-item,
.hmi-alarm-item,
.hmi-report-item,
.hmi-config-item {
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hmi-kpi-item span,
.hmi-report-item span,
.hmi-config-item span {
    display: block;
    color: #98a0bf;
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.hmi-kpi-item strong,
.hmi-report-item strong,
.hmi-config-item strong {
    font-size: 1.15rem;
}

.hmi-status-item,
.hmi-alarm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* 近期报警：文字左对齐、自动换行；徽章固定在左侧不收缩 */
.hmi-alarm-item .hmi-badge {
    flex: 0 0 auto;
    align-self: flex-start;
}
.hmi-alarm-item > div:last-child {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}
.hmi-alarm-item > div:last-child strong {
    display: block;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.hmi-status-item.ok .hmi-status-value { color: #67e29a; }
.hmi-status-item.warn .hmi-status-value { color: #ffc15a; }
.hmi-status-item.alarm .hmi-status-value { color: #ff7b7b; }

.hmi-table-wrap {
    overflow: auto;
}

.hmi-table {
    width: 100%;
    border-collapse: collapse;
}

.hmi-table th,
.hmi-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.82rem;
}

.hmi-table th {
    color: #96a0c0;
    font-weight: 600;
}

/* 浅色模式：所有表格表头统一使用 #F2F3F4 背景（深色模式保持现状不变） */
html[data-theme="light"] .hmi-table th,
html[data-theme="light"] .hmi-snapshot-table thead th,
html[data-theme="light"] .hmi-account-table .hmi-table thead th {
    background: #F2F3F4;
}

.hmi-table td {
    color: #edf0ff;
}

/* 表格行 hover 反馈：统一作用于所有 .hmi-table，行背景平滑提亮 */
.hmi-table tbody tr { transition: background 0.18s ease; }
.hmi-table tbody tr:hover td { background: rgba(255, 255, 255, 0.05); }

.devices-module-grid {
    align-items: start;
}

.devices-metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.devices-connection-card {
    background: linear-gradient(180deg, rgba(var(--hmi-accent-rgb), 0.12), rgba(255, 255, 255, 0.04));
}

.devices-status-grid,
.devices-command-grid {
    display: grid;
    gap: 10px;
}

.devices-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.devices-command-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.devices-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.devices-action-grid .hmi-button {
    width: 100%;
    min-height: 48px;
}

@media (max-width: 980px) {
    .devices-metric-grid,
    .devices-status-grid,
    .devices-command-grid,
    .devices-action-grid {
        grid-template-columns: 1fr;
    }
}

.hmi-log-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 12px;
    align-items: end;
}

.hmi-log-setting {
    display: grid;
    gap: 8px;
}

.hmi-log-setting span {
    color: #98a0bf;
    font-size: 0.78rem;
}

.hmi-log-number {
    width: 100%;
    max-width: 180px;
    padding: 10px 32px 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background-color: rgba(36, 42, 68, 0.92);
    color: #e8ecff;
    font-weight: 500;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23e8ecff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}
.hmi-log-number option {
    background-color: #20253d;
    color: #e8ecff;
}

.hmi-log-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.hmi-log-summary {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #b8c1df;
    font-size: 0.84rem;
    line-height: 1.6;
}

.hmi-log-table-wrap {
    overflow: auto;
    max-height: 62vh;
}

/* 日志表自动列宽布局：前两列按内容自适应，内容列占满剩余宽度 */
.hmi-log-panel .hmi-table {
    width: 100%;
}

/* 内容列宽度设为 100%：在自动布局下占满剩余宽度，超长文本换行/截断 */
.hmi-log-panel .hmi-table th:nth-child(3),
.hmi-log-panel .hmi-table td:nth-child(3) {
    width: 100%;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* 表头吸顶：滚动日志内容时，时间/类型/内容表头保持固定（与 hmi-snapshot-table 表头同款对比度） */
.hmi-log-panel .hmi-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(38, 44, 62, 0.98);
    color: #ccd4e8;
}
html[data-theme="light"] .hmi-log-panel .hmi-table thead th {
    background: #F2F3F4;
    color: #2f3b4f;
}

.hmi-log-preview,
.hmi-log-empty {
    margin-top: 10px;
    color: #d8def5;
    font-size: 0.88rem;
    line-height: 1.6;
}

.hmi-log-empty {
    color: #9da6c7;
}

.hmi-log-number:focus {
    outline: 2px solid rgba(var(--hmi-accent-rgb), 0.25);
    outline-offset: 2px;
}

@media (max-width: 1200px) {
    .hmi-log-toolbar {
        grid-template-columns: 1fr;
    }

    .hmi-log-actions {
        justify-content: flex-start;
    }
}

html[data-theme="light"] .hmi-log-number {
    background-color: #ffffff;
    color: #172034;
    border-color: rgba(16,24,40,0.10);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23172034' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    box-shadow: none;
}
html[data-theme="light"] .hmi-log-number option {
    background-color: #ffffff;
    color: #172034;
}

html[data-theme="light"] .hmi-log-summary,
html[data-theme="light"] .hmi-log-preview {
    background: rgba(255, 255, 255, 0.9);
    color: #172034;
    border-color: rgba(16,24,40,0.08);
}

html[data-theme="light"] .hmi-log-empty {
    color: #5c6782;
}

.hmi-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.74rem;
    background: rgba(255, 255, 255, 0.06);
    color: #d7defa;
}

.hmi-badge.good { background: rgba(103, 226, 154, 0.16); color: #85efac; }  /* 运行日志：绿色（正常状态） */
.hmi-badge.info { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }  /* 操作日志：蓝色（用户操作） */
.hmi-badge.warn { background: rgba(255, 193, 90, 0.18); color: #ffd27a; }  /* 警告日志：黄色（可恢复的警告） */
.hmi-badge.alarm { background: rgba(255, 89, 89, 0.18); color: #ff9090; }  /* 报警日志：红色（需立即处理） */

.hmi-bar-row {
    height: 220px;
    display: flex;
    align-items: end;
    gap: 12px;
    padding: 10px 6px 4px;
}

.hmi-switch-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.hmi-switch-card {
    border-radius: 14px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hmi-switch-card strong {
    display: block;
    margin-bottom: 6px;
}

.hmi-switch-card span {
    color: #98a0bf;
    font-size: 0.78rem;
}

.bar-1 { height: 32%; }
.bar-2 { height: 56%; }
.bar-3 { height: 44%; }
.bar-4 { height: 72%; }
.bar-5 { height: 58%; }
.bar-6 { height: 84%; }
.bar-7 { height: 66%; }

@media (max-width: 1200px) {
    .hmi-cards {
        /* 中等宽度收窄最小列宽，保证 5 张卡仍能尽量一行排下 */
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
    }

    /* 用 minmax(0,1fr) 而非 1fr：避免单列被内容固有最小宽度撑宽，导致各行宽度不一致、右侧留白 */
    .hmi-grid.two-col,
    .hmi-grid.split-wide,
    .hmi-overview {
        grid-template-columns: minmax(0, 1fr);
    }

    .hmi-switch-row {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 860px) {
    .hmi-shell {
        flex-direction: column;
        padding-left: 0;
    }

    .hmi-sidebar {
        width: 100%;
        height: auto;
        position: static;
        inset: auto;
        overflow: visible;
    }

    /* 移动端：还原为流式布局：全部展开，不吸顶，也不需要背景渐变遮挡 */
    .hmi-sidebar-tools,
    .hmi-brand {
        position: static !important;
        flex: 0 0 auto;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .hmi-nav {
        overflow: visible;
        min-height: auto;
        flex: 0 0 auto;
    }

    .hmi-main {
        width: 100%;
        margin-left: 0;
        padding: 14px;
    }

    html[data-sidebar-collapsed="true"] .hmi-main {
        width: 100%;
        margin-left: 0;
    }

    .hmi-cards {
        grid-template-columns: 1fr;
    }

    .hmi-topbar {
        flex-direction: column;
        align-items: start;
        gap: 12px;
    }

    .hmi-topbar-actions {
        position: static;
        z-index: auto;
    }
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.hmi-theme-switch {
    display: inline-flex;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    gap: 4px;
}

.hmi-theme-button {
    border: 0;
    background: transparent;
    color: #aab0ce;
    font-size: 0.95rem;
    font-weight: 600;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    cursor: pointer;
}

.hmi-theme-button.active,
html[data-theme="light"] .hmi-theme-button[data-theme="light"],
html[data-theme="dark"] .hmi-theme-button[data-theme="dark"] {
    background: rgba(var(--hmi-accent-rgb), 0.22);
    color: #ffffff;
}

/* Top-right user chip layout */
.hmi-topbar-actions .hmi-user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.hmi-topbar-actions .hmi-user-avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 32px;
    height: auto;
    align-self: center;
}

.hmi-avatar-svg {
    width: 20px;
    height: 20px;
    display: block;
    color: #fff;
}

/* Make avatar SVG paths follow currentColor so we can theme them */
.hmi-user-chip .hmi-avatar-svg {
    color: #4c7dff; /* blue foreground for both admin and user avatars */
}
.hmi-user-chip .hmi-avatar-svg path {
    fill: currentColor !important;
}

.hmi-topbar-actions .hmi-user-meta {
    grid-area: meta;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    line-height: 1.05;
}

.hmi-user-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    margin: 0;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
}

.hmi-user-status.online {
    background: rgba(103, 226, 154, 0.16);
    color: #85efaf;
}

.hmi-user-status.offline {
    background: rgba(255, 193, 90, 0.18);
    color: #ffd27a;
}

.hmi-topbar-actions .hmi-user-meta strong {
    font-size: 1.2rem;
    line-height: 1;
}

.hmi-topbar-actions .hmi-user-meta span {
    font-size: 0.64rem;
    line-height: 1;
}

.hmi-topbar-actions .hmi-logout-button {
    margin-left: auto;
    align-self: center;
}

/* Styled logout button: pill with subtle hover/focus effects */
.hmi-topbar-actions .hmi-logout-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: inherit;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, color 0.14s ease;
    box-shadow: none;
    align-self: center;
}

.hmi-topbar-actions .hmi-logout-button::before {
    content: none;
}

.hmi-logout-icon {
    width: 15px;
    height: 15px;
    display: block;
    flex: 0 0 auto;
    color: currentColor;
}

.hmi-logout-icon path {
    fill: currentColor;
}

.hmi-topbar-actions .hmi-logout-button:hover {
    transform: translateY(-2px);
    background: linear-gradient(90deg, rgba(var(--hmi-accent-rgb),0.12), rgba(var(--hmi-accent2-rgb),0.06));
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(var(--hmi-accent-rgb),0.12);
}

.hmi-topbar-actions .hmi-logout-button:active {
    transform: translateY(0) scale(0.98);
}

.hmi-topbar-actions .hmi-logout-button:focus-visible {
    outline: 2px solid rgba(var(--hmi-accent-rgb),0.22);
    outline-offset: 2px;
}

/* Light theme variant */
html[data-theme="light"] .hmi-topbar-actions .hmi-logout-button {
    border-color: rgba(16,24,40,0.08);
    background: rgba(16,24,40,0.04);
    color: #172034;
}

html[data-theme="light"] .hmi-topbar-actions .hmi-logout-button:hover {
    background: rgba(var(--hmi-accent-rgb),0.12);
    color: #fff;
}

.hmi-theme-button:focus-visible {
    outline: 2px solid #4c7dff;
    outline-offset: 2px;
}

html[data-theme="light"] {
    color-scheme: light;
    --hmi-text-primary: #172034;
    --hmi-text-secondary: #5b6782;
    --hmi-text-muted: #5b667c;
    --hmi-status-on: #18794e;
    --hmi-status-off: #9ca3af;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] body {
    background: #eef3fb;
    color: #172034;
}

html[data-theme="light"] .hmi-shell {
    background: radial-gradient(circle at top, #ffffff 0%, #edf2fb 55%, #e5ebf6 100%);
    color: #172034;
}

html[data-theme="light"] .hmi-sidebar {
    background: rgba(255, 255, 255, 0.78);
    border-right-color: rgba(16, 24, 40, 0.08);
}

/* 浅色主题：顶部折叠按钮行与品牌区背景保持透明 */
html[data-theme="light"] .hmi-sidebar-tools,
html[data-theme="light"] .hmi-brand {
    background: transparent;
}

/* Make the sidebar toggle visually distinct in light mode so it doesn't blend
   into the sidebar background. Use a subtle darker tint and stronger icon color. */
html[data-theme="light"] .hmi-sidebar-toggle {
    background: rgba(16, 24, 40, 0.06);
    color: #4c7dff; /* blue foreground for toggle in light theme */
}

html[data-theme="light"] .hmi-sidebar-toggle:hover {
    background: rgba(16, 24, 40, 0.16);
    box-shadow: 0 6px 18px rgba(var(--hmi-accent-rgb),0.08);
}

html[data-theme="light"] .hmi-sidebar-toggle:focus-visible {
    outline: 2px solid #4c7dff;
    outline-offset: 2px;
    box-shadow: 0 8px 26px rgba(var(--hmi-accent-rgb),0.12);
}

html[data-theme="light"] .hmi-brand-text span,
html[data-theme="light"] .hmi-footer-sub,
html[data-theme="light"] .hmi-page-subtitle,
html[data-theme="light"] .hmi-page-meta,
html[data-theme="light"] .hmi-stat-head,
html[data-theme="light"] .hmi-stat-foot,
html[data-theme="light"] .hmi-kpi-item span,
html[data-theme="light"] .hmi-config-item span,
html[data-theme="light"] .hmi-report-item span,
html[data-theme="light"] .hmi-table th,
html[data-theme="light"] .hmi-badge,
html[data-theme="light"] .hmi-status-item,
html[data-theme="light"] .hmi-nav-item {
    color: #5b6782;
}

html[data-theme="light"] .hmi-user-status {
    background: rgba(16, 24, 40, 0.06);
    color: #172034;
}

html[data-theme="light"] .hmi-user-status.online {
    background: rgba(103, 226, 154, 0.16);
    color: #18794e;
}

html[data-theme="light"] .hmi-user-status.offline {
    background: rgba(255, 193, 90, 0.18);
    color: #9a6700;
}

html[data-theme="light"] .hmi-nav-item:hover,
html[data-theme="light"] .hmi-nav-item.active {
    background: rgba(var(--hmi-accent-rgb), 0.10);
    color: #172034;
}

html[data-theme="light"] .hmi-pill-soft,
html[data-theme="light"] .hmi-kpi-item,
html[data-theme="light"] .hmi-status-item,
html[data-theme="light"] .hmi-alarm-item,
html[data-theme="light"] .hmi-report-item,
html[data-theme="light"] .hmi-config-item,
html[data-theme="light"] .hmi-chart-box {
    background: rgba(255, 255, 255, 0.76);
    border-color: rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-panel,
html[data-theme="light"] .hmi-stat-card {
    background: rgba(var(--hmi-surface-rgb), 0.85);
    border-color: rgba(16, 24, 40, 0.08);
    box-shadow: 0 16px 30px rgba(16, 24, 40, 0.08);
}

/* 浅色主题 hover 反馈：浅阴影，保持卡片层级清晰 */
html[data-theme="light"] .hmi-stat-card:hover {
    border-color: rgba(16, 24, 40, 0.16);
    box-shadow: 0 22px 40px rgba(16, 24, 40, 0.12);
}

html[data-theme="light"] .hmi-panel:hover {
    border-color: rgba(16, 24, 40, 0.14);
    box-shadow: 0 18px 34px rgba(16, 24, 40, 0.10);
}

html[data-theme="light"] .hmi-theme-switch {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-theme-button {
    color: #4b5874;
}

html[data-theme="light"] .hmi-theme-button[data-theme="light"] {
    color: #ffffff;
}

html[data-theme="light"] .hmi-table td,
html[data-theme="light"] .hmi-page-title,
html[data-theme="light"] .hmi-panel-header h2,
html[data-theme="light"] .hmi-brand-text strong,
html[data-theme="light"] .hmi-footer-title,
html[data-theme="light"] .hmi-stat-value,
html[data-theme="light"] .hmi-kpi-item strong,
html[data-theme="light"] .hmi-report-item strong,
html[data-theme="light"] .hmi-config-item strong {
    color: #172034;
}

html[data-theme="light"] .hmi-tag,
html[data-theme="light"] .hmi-pill-soft,
html[data-theme="light"] .hmi-badge {
    background: rgba(16, 24, 40, 0.06);
}

/* 浅色表格行 hover：淡蓝提亮，与既有模块 hover 风格一致 */
html[data-theme="light"] .hmi-table tbody tr:hover td {
    background: rgba(var(--hmi-accent-rgb), 0.05);
}

/* 浅色模式下日志徽章颜色 */
html[data-theme="light"] .hmi-badge.good { background: rgba(34, 197, 94, 0.12); color: #16a34a; }  /* 运行日志：深绿色 */
html[data-theme="light"] .hmi-badge.info { background: rgba(59, 130, 246, 0.12); color: #2563eb; }  /* 操作日志：深蓝色 */
html[data-theme="light"] .hmi-badge.warn { background: rgba(245, 158, 11, 0.12); color: #d97706; }  /* 警告日志：深黄色 */
html[data-theme="light"] .hmi-badge.alarm { background: rgba(239, 68, 68, 0.12); color: #dc2626; }  /* 报警日志：深红色 */

html[data-theme="light"] .hmi-pill {
    background: rgba(72, 211, 114, 0.14);
    color: #18794e;
}

/* Authentication / login screen */
.hmi-auth-loading,
.hmi-login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.hmi-auth-loading-card,
.hmi-login-panel {
    width: min(1120px, 100%);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(18, 22, 36, 0.82);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
}

.hmi-auth-loading-card {
    max-width: 420px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.hmi-auth-loading-card strong,
.hmi-auth-loading-card span {
    display: block;
}

.hmi-auth-loading-card span {
    margin-top: 4px;
    color: #98a0bf;
    font-size: 0.84rem;
}

.hmi-auth-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.12);
    border-top-color: #4c7dff;
    animation: hmi-spin 0.8s linear infinite;
}

.hmi-login-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
    overflow: hidden;
}

.hmi-login-hero {
    padding: 34px;
    background: radial-gradient(circle at top, rgba(var(--hmi-accent-rgb), 0.25), rgba(18, 22, 36, 0.1));
}

.hmi-login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.hmi-login-mark {
    width: 70px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #4c7dff, #7f5dff);
    box-shadow: 0 14px 30px rgba(var(--hmi-accent-rgb), 0.28);
}

.hmi-login-brand strong {
    display: block;
    font-size: 1.15rem;
}

.hmi-login-brand span {
    display: block;
    margin-top: 3px;
    color: #9ea6c8;
    font-size: 0.84rem;
}

.hmi-login-hero h1 {
    margin: 0 0 10px;
    font-size: 2.2rem;
}

.hmi-login-hero p {
    margin: 0 0 24px;
    color: #b7bdd8;
    max-width: 42ch;
    line-height: 1.7;
}

.hmi-login-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hmi-login-badges span {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #dfe5ff;
    font-size: 0.8rem;
}

.hmi-login-card {
    padding: 30px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.hmi-login-message {
    min-height: 24px;
    margin-bottom: 14px;
    font-size: 0.88rem;
    color: #9ea6c8;
}

.hmi-login-message.success { color: #7ee1a0; }
.hmi-login-message.error { color: #ff9090; }

.hmi-login-form {
    display: grid;
    gap: 14px;
}

.hmi-login-form label {
    display: grid;
    gap: 8px;
}

.hmi-login-field-set {
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
}

.hmi-login-field-row {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 14px;
}

.hmi-login-field-row + .hmi-login-field-row {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hmi-login-field-label {
    color: #c4cade;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.hmi-login-field-input {
    width: 100%;
    border: 0;
    background: transparent;
    color: #edf0ff;
    outline: none;
    min-width: 0;
    padding: 0;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.hmi-login-input {
    width: 100%;
    border: 0;
    background: transparent;
    color: #edf0ff;
    outline: none;
    min-width: 0;
    padding: 0;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.hmi-login-field-input::placeholder {
    color: #8f96b8;
}

.hmi-login-input::placeholder {
    color: #8f96b8;
}

.hmi-login-field-input:focus {
    border: 0;
    box-shadow: none;
}

.hmi-login-input:focus {
    border: 0;
    box-shadow: none;
}

.hmi-login-field-input:-webkit-autofill,
.hmi-login-field-input:-webkit-autofill:hover,
.hmi-login-field-input:-webkit-autofill:focus,
.hmi-login-input:-webkit-autofill,
.hmi-login-input:-webkit-autofill:hover,
.hmi-login-input:-webkit-autofill:focus {
    -webkit-text-fill-color: inherit;
    transition: background-color 9999s ease-in-out 0s;
    box-shadow: 0 0 0 1000px transparent inset;
    caret-color: #4c7dff;
}

/* Actions (login / register / reset) */
.hmi-login-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: center;
    margin-top: 8px;
}

.hmi-login-submit {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: transparent;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
}

.hmi-login-submit.primary {
    background: linear-gradient(90deg, #3567ef, #6a48ee);
    color: #fff;
    border-color: transparent;
}

.hmi-login-submit.secondary {
    background: rgba(255,255,255,0.04);
    color: inherit;
}

.hmi-login-note {
    margin-top: 8px;
    font-size: 0.82rem;
    color: #98a0bf;
    line-height: 1.5;
}

.hmi-login-note.success {
    color: #7ee1a0;
}

.hmi-login-note.error {
    color: #ff9090;
}

.hmi-account-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.18fr);
    gap: 16px;
    align-items: start;
}

.hmi-account-form,
.hmi-account-table {
    display: grid;
    gap: 12px;
}

.hmi-account-select {
    /* unified dark token: visible solid panel + arrow, consistent with other selects */
    background-color: rgba(36, 42, 68, 0.92) !important;
    color: #e8ecff !important;
    border: 1px solid rgba(255, 255, 255, 0.14);
    outline: none;
    width: 100%;
    min-width: 0;
    padding: 8px 32px 8px 10px;
    border-radius: 10px;
    font-weight: 500;
    -moz-appearance: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23e8ecff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 10px 6px !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

/* Hide native dropdown arrow in various engines */
.hmi-account-select::-ms-expand { display: none; }
.hmi-account-select::-webkit-inner-spin-button { display: none; }
.hmi-account-select::-webkit-search-decoration { display: none; }

/* dark theme: popup options use the unified dark panel color for max readability */
html[data-theme="dark"] .hmi-account-select option {
    background-color: #20253d;
    color: #e8ecff;
}

/* Ensure native option rows don't inherit the arrow image or repeat it */
.hmi-account-select option,
select.hmi-account-select option {
    background-image: none !important;
    background-repeat: no-repeat !important;
    background-size: auto !important;
}

/* Add subtle border and padding for select to increase contrast and hit target */
.hmi-account-select:focus {
    outline: 2px solid rgba(var(--hmi-accent-rgb),0.18);
    outline-offset: 2px;
}

.hmi-account-actions,
.hmi-account-row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hmi-account-button {
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    padding: 8px 12px;
    background: rgba(255,255,255,0.04);
    color: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.hmi-account-button.primary {
    background: linear-gradient(90deg, #3567ef, #6a48ee);
    color: #fff;
    border-color: transparent;
}

.hmi-account-button.secondary {
    background: rgba(255,255,255,0.04);
}

.hmi-account-button.ghost {
    background: transparent;
}

.hmi-account-button.danger {
    color: #ff8e8e;
    border-color: rgba(255, 89, 89, 0.18);
}

.hmi-account-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(var(--hmi-accent-rgb), 0.10);
}

.hmi-account-table .hmi-table tr.editing td {
    background: rgba(var(--hmi-accent-rgb), 0.08);
}

.hmi-role-select {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.hmi-role-card {
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    color: #edf0ff;
    text-align: left;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.hmi-role-card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.hmi-role-card span {
    display: block;
    color: #98a0bf;
    font-size: 0.78rem;
    line-height: 1.4;
}

.hmi-role-card:hover {
    transform: translateY(-1px);
    border-color: rgba(var(--hmi-accent-rgb), 0.34);
    box-shadow: 0 10px 22px rgba(var(--hmi-accent-rgb), 0.10);
}

.hmi-role-card.active {
    background: linear-gradient(135deg, rgba(var(--hmi-accent-rgb), 0.22), rgba(var(--hmi-accent2-rgb), 0.14));
    border-color: rgba(var(--hmi-accent-rgb), 0.52);
    box-shadow: 0 12px 28px rgba(var(--hmi-accent-rgb), 0.18);
    color: #ffffff;
    transform: translateY(-1px) scale(1.01);
}

.hmi-role-card.active span {
    color: rgba(255, 255, 255, 0.78);
}

.hmi-role-card:focus-visible {
    outline: 2px solid #4c7dff;
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .hmi-login-actions {
        grid-template-columns: 1fr;
    }
}

.hmi-login-link {
    border: 0;
    background: transparent;
    padding: 0;
    color: #4c7dff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.hmi-login-link:hover {
    text-decoration: underline;
}

.hmi-password-field {
    display: contents;
}

.hmi-password-input {
    caret-color: #4c7dff;
}

.hmi-password-input:focus {
    outline: none;
}


.hmi-password-actions {
    position: static;
    transform: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.hmi-password-visibility {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #98a0bf;
    cursor: pointer;
    padding: 0;
    flex: 0 0 auto;
}

.hmi-password-visibility:hover {
    color: #4c7dff;
    background: rgba(var(--hmi-accent-rgb), 0.10);
}

.hmi-password-eye {
    width: 16px;
    height: 16px;
    display: block;
}

.hmi-login-field-row input::-ms-reveal,
.hmi-login-field-row input::-ms-clear {
    display: none;
}

.hmi-remember-row {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    white-space: nowrap;
}

.hmi-remember-row input {
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 auto;
}

.hmi-remember-row span {
    line-height: 1;
}

.hmi-login-link {
    border: 0;
    background: transparent;
    padding: 0;
    color: #4c7dff;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .hmi-password-actions {
        gap: 6px;
    }

    .hmi-login-link {
        font-size: 0.78rem;
    }

    .hmi-account-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .hmi-login-panel {
        grid-template-columns: 1fr;
    }

    .hmi-login-card {
        border-left: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }
}

@media (max-width: 640px) {
    .hmi-login-page,
    .hmi-auth-loading {
        padding: 12px;
    }

    .hmi-login-hero,
    .hmi-login-card {
        padding: 20px;
    }

    .hmi-role-select,
    .hmi-login-actions {
        grid-template-columns: 1fr;
    }

    .hmi-user-chip {
        width: auto;
        justify-content: flex-start;
        border-radius: 16px;
    }
}

/* Login page theme adaptation */
.hmi-login-page {
    background: radial-gradient(circle at top, #1d2236 0%, #121624 55%, #0f1320 100%);
    color: #e8ecff;
}

html[data-theme="light"] .hmi-login-page {
    background: radial-gradient(circle at top, #ffffff 0%, #edf2fb 55%, #e5ebf6 100%);
    color: #172034;
}

html[data-theme="light"] .hmi-auth-loading-card,
html[data-theme="light"] .hmi-login-panel {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(16, 24, 40, 0.08);
    box-shadow: 0 24px 60px rgba(16, 24, 40, 0.10);
}

html[data-theme="light"] .hmi-login-hero {
    background: radial-gradient(circle at top, rgba(var(--hmi-accent-rgb), 0.12), rgba(255, 255, 255, 0.12));
}

html[data-theme="light"] .hmi-login-card {
    background: rgba(255, 255, 255, 0.78);
    border-left-color: rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-login-field-set {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(16, 24, 40, 0.18);
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-login-field-row + .hmi-login-field-row {
    border-top-color: rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-login-brand span,
html[data-theme="light"] .hmi-login-hero p,
html[data-theme="light"] .hmi-login-message,
html[data-theme="light"] .hmi-login-note,
html[data-theme="light"] .hmi-login-field-label,
html[data-theme="light"] .hmi-login-form label > span,
html[data-theme="light"] .hmi-remember-row,
html[data-theme="light"] .hmi-role-card span,
html[data-theme="light"] .hmi-user-meta span,
html[data-theme="light"] .hmi-auth-loading-card span {
    color: #5b6782;
}

html[data-theme="light"] .hmi-login-brand strong,
html[data-theme="light"] .hmi-login-hero h1,
html[data-theme="light"] .hmi-role-card strong,
html[data-theme="light"] .hmi-user-meta strong,
html[data-theme="light"] .hmi-auth-loading-card strong {
    color: #172034;
}

html[data-theme="light"] .hmi-login-badges span,
html[data-theme="light"] .hmi-logout-button,
html[data-theme="light"] .hmi-login-submit.secondary,
html[data-theme="light"] .hmi-account-button.secondary,
html[data-theme="light"] .hmi-account-button.ghost {
    background: rgba(16, 24, 40, 0.06);
    color: #172034;
    border-color: rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-login-field-input {
    background: transparent;
    color: #172034;
    border-color: rgba(16, 24, 40, 0.16);
}

html[data-theme="light"] .hmi-login-field-input::placeholder {
    color: #9aa4bf;
}

html[data-theme="light"] .hmi-login-link {
    color: #4c7dff;
}

/* Light theme: make account select readable (white background, dark text, darker arrow) */
html[data-theme="light"] .hmi-account-select {
    background-color: #ffffff !important;
    color: #172034 !important;
    border-color: rgba(16, 24, 40, 0.10) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23172034' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 10px 6px !important;
    box-shadow: none !important;
}

html[data-theme="light"] .hmi-account-select option {
    background-color: #ffffff;
    color: #172034;
}

html[data-theme="light"] .hmi-password-visibility {
    color: #74809a;
}

html[data-theme="light"] .hmi-password-visibility:hover {
    background: rgba(var(--hmi-accent-rgb), 0.08);
}

html[data-theme="light"] .hmi-login-submit.secondary,
html[data-theme="light"] .hmi-role-card {
    background: rgba(16, 24, 40, 0.04);
    color: #172034;
    border-color: rgba(16, 24, 40, 0.08);
}

html[data-theme="light"] .hmi-role-card.active,
html[data-theme="light"] .hmi-login-submit.primary {
    background: linear-gradient(135deg, rgba(var(--hmi-accent-rgb), 0.18), rgba(var(--hmi-accent2-rgb), 0.10));
    border-color: rgba(var(--hmi-accent-rgb), 0.44);
    box-shadow: 0 12px 24px rgba(var(--hmi-accent-rgb), 0.12);
    color: #172034;
}

/* =========================================================
   MES MVP 新增样式（严格符合 UI Style Guideline 2.0）
   ========================================================= */

/* ---------- Tab 切换条 ---------- */
.hmi-tabbar {
    display: inline-flex;
    gap: 6px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    flex-wrap: wrap;
    width: 100%;
    box-sizing: border-box;
}
.hmi-tab {
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #9ca3af;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.14s ease;
    user-select: none;
}
.hmi-tab:hover { transform: translateY(-1px); color: #e8ecff; background: rgba(255, 255, 255, 0.04); }
.hmi-tab.active {
    background: linear-gradient(90deg, #4c7dff, #7f5dff);
    color: #fff;
    font-weight: 700;
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 8px 18px rgba(var(--hmi-accent-rgb), 0.32);
}
html[data-theme="light"] .hmi-tabbar {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.08);
}
html[data-theme="light"] .hmi-tab { color: #5b6782; }
html[data-theme="light"] .hmi-tab:hover { transform: translateY(-1px); color: #172034; background: rgba(15, 23, 42, 0.04); }
html[data-theme="light"] .hmi-tab.active {
    background: linear-gradient(90deg, #4c7dff, #7f5dff);
    color: #fff;
    font-weight: 700;
    border-color: transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 18px rgba(76, 125, 255, 0.16);
}

/* ---------- Toolbar 工具栏行 ---------- */
.hmi-toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------- 通用按钮 ---------- */
.hmi-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #e8ecff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    line-height: 1.4;
}
.hmi-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(var(--hmi-accent-rgb), 0.10); }
.hmi-btn.primary {
    /* 白字在浅色/深色主题均需 ≥4.5:1 对比度：渐变整体加深但仍保持蓝紫品牌色 */
    background: linear-gradient(90deg, #3567ef, #6a48ee);
    color: #fff;
    border-color: transparent;
}
.hmi-btn.ghost {
    background: rgba(255, 255, 255, 0.02);
}
.hmi-btn.danger {
    border-color: rgba(255, 89, 89, 0.18);
    color: #ff8e8e;
}
html[data-theme="light"] .hmi-btn {
    background: rgba(15, 23, 42, 0.02);
    border-color: rgba(15, 23, 42, 0.08);
    color: #172034;
}
html[data-theme="light"] .hmi-btn.primary { color: #fff; }
html[data-theme="light"] .hmi-btn.ghost { background: rgba(15, 23, 42, 0.02); }
html[data-theme="light"] .hmi-btn.primary {
    background: linear-gradient(90deg, #4c7dff, #7f5dff);
    box-shadow: 0 6px 16px rgba(76, 125, 255, 0.18);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
html[data-theme="light"] .hmi-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(76, 125, 255, 0.24);
    filter: brightness(1.03);
}
html[data-theme="light"] .hmi-btn.primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 125, 255, 0.30);
}

/* ---------- 通用输入 ---------- */
input.hmi-input, select.hmi-input, textarea.hmi-input {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: #e8ecff;
    font-size: 13px;
    outline: none;
    transition: border-color 0.14s ease, box-shadow 0.14s ease;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
}
input.hmi-input::placeholder, textarea.hmi-input::placeholder { color: #6b7193; }
input.hmi-input:focus, select.hmi-input:focus, textarea.hmi-input:focus {
    border-color: rgba(var(--hmi-accent-rgb), 0.50);
    box-shadow: 0 0 0 3px rgba(var(--hmi-accent-rgb), 0.14);
}
html[data-theme="light"] input.hmi-input,
html[data-theme="light"] select.hmi-input,
html[data-theme="light"] textarea.hmi-input {
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.08);
    color: #172034;
}
html[data-theme="light"] input.hmi-input::placeholder,
html[data-theme="light"] textarea.hmi-input::placeholder { color: #9aa4bf; }
select.hmi-input { appearance: none; -webkit-appearance: none; -moz-appearance: none;
    /* 深色下增强背景与边框，让下拉框边界清晰、与面板明显区分，避免控件"消融"在深色界面 */
    background-color: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23f4f6ff' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    padding-right: 32px;
    cursor: pointer;
}
/* 深色模式：下拉弹出面板显式指定深色背景 + 浅色文字，避免在原生/EdgeWebView2 里出现深色文字叠深色底的不可读情况 */
html[data-theme="dark"] select.hmi-input option {
    background-color: #20253d;
    color: #e8ecff;
}
html[data-theme="light"] select.hmi-input {
    /* 深色箭头：必须显式补全 background-repeat/position/size，
       否则浅色规则里 background:#fff 简写会把它们重置为 repeat/auto，
       导致下拉箭头被重复平铺成一排排黑色锯齿乱码 */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23172034' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
}
html[data-theme="light"] select.hmi-input option {
    background-color: #ffffff;
    color: #172034;
}

/* ---------- 表单行 ---------- */
.hmi-form-row { display: flex; flex-direction: column; gap: 6px; }
.hmi-form-row label { font-size: 12px; color: #aab0ce; font-weight: 500; }
html[data-theme="light"] .hmi-form-row label { color: var(--hmi-text-muted); }
.hmi-form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
@media (max-width: 640px) {
    .hmi-form-grid-2 { grid-template-columns: 1fr; }
}

/* ---------- 操作列按钮 ---------- */
.hmi-ops-cell {
    display: flex;
    gap: 10px;
    align-items: center;
    white-space: nowrap;
    min-width: 0;
}
.hmi-linkbtn {
    background: none;
    border: none;
    padding: 0;
    color: #7f95ff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    flex: 0 0 auto;
}
.hmi-linkbtn:hover { text-decoration: underline; }
.hmi-linkbtn.danger { color: #ff8e8e; }
/* 浅色主题：默认文字色 #7f95ff 在浅底上对比度不足（≈2.5:1），加深以提升可读性 */
html[data-theme="light"] .hmi-linkbtn { color: #3b5bdb; }
html[data-theme="light"] .hmi-linkbtn.danger { color: #c53030; }

/* ---------- 表格容器 + hmi-snapshot-table ---------- */
.hmi-log-table-wrap {
    overflow: auto;
    max-height: 62vh;
    width: 100%;
}
.hmi-snapshot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    color: #e8ecff;
}
.hmi-snapshot-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(38, 44, 62, 0.98);
}
.hmi-snapshot-table thead th {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: #ccd4e8;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}
.hmi-snapshot-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: top;
}
.hmi-snapshot-table tbody tr:hover {
    background: rgba(var(--hmi-accent-rgb), 0.06);
}
.hmi-snapshot-table code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(var(--hmi-accent2-rgb), 0.12);
    color: #c5b1ff;
}
html[data-theme="light"] .hmi-snapshot-table { color: #172034; }
html[data-theme="light"] .hmi-snapshot-table thead { background: #F2F3F4; }
html[data-theme="light"] .hmi-snapshot-table thead th {
    border-bottom-color: rgba(15, 23, 42, 0.12);
    color: #2f3b4f;
}
html[data-theme="light"] .hmi-snapshot-table tbody td {
    border-bottom-color: rgba(15, 23, 42, 0.06);
}
html[data-theme="light"] .hmi-snapshot-table tbody tr:hover { background: rgba(var(--hmi-accent-rgb), 0.05); }
html[data-theme="light"] .hmi-snapshot-table code {
    background: rgba(124, 58, 237, 0.08);
    color: #7c3aed;
}

/* ---------- Tag 扩展色 ---------- */
.hmi-tag.expand-tag,
.hmi-tag.warning {
    background: rgba(245, 158, 11, 0.14);
    color: #fcd34d;
}
html[data-theme="light"] .hmi-tag.expand-tag,
html[data-theme="light"] .hmi-tag.warning {
    background: rgba(217, 119, 6, 0.10);
    color: #b45309;
}
.hmi-tag.good {
    background: rgba(16, 185, 129, 0.14);
    color: #10b981;
}
html[data-theme="light"] .hmi-tag.good {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

/* ---------- Modal 遮罩 ---------- */
.hmi-modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(7, 10, 20, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: hmi-modal-fade 0.16s ease;
}
@keyframes hmi-modal-fade { from { opacity: 0; } to { opacity: 1; } }

.hmi-modal {
    width: 100%;
    max-width: 680px;
    background: rgba(31, 36, 55, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    animation: hmi-modal-pop 0.26s cubic-bezier(0.3, 1.4, 0.4, 1);
}
@keyframes hmi-modal-pop {
    from { transform: translateY(12px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
html[data-theme="light"] .hmi-modal {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
}
.hmi-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
html[data-theme="light"] .hmi-modal-header { border-bottom-color: rgba(15, 23, 42, 0.08); }
.hmi-modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; color: #e8ecff; }
html[data-theme="light"] .hmi-modal-header h3 { color: #172034; }
.hmi-modal-close {
    background: none; border: none; color: #9ca3af; font-size: 22px;
    line-height: 1; cursor: pointer; padding: 0;
    width: 28px; height: 28px; border-radius: 8px;
    transition: all 0.14s ease;
}
.hmi-modal-close:hover { background: rgba(255, 255, 255, 0.06); color: #e8ecff; }
html[data-theme="light"] .hmi-modal-close:hover { background: rgba(15, 23, 42, 0.06); color: #172034; }

.hmi-modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}
.hmi-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
html[data-theme="light"] .hmi-modal-footer { border-top-color: rgba(15, 23, 42, 0.08); }

/* ---------- 四列栅格 ---------- */
.hmi-grid.four-col { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1200px) {
    .hmi-grid.four-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .hmi-grid.four-col { grid-template-columns: 1fr; }
}

/* 上下文卡片背景变量 */
.hmi-panel-bg2 { background: rgba(255, 255, 255, 0.03); }
html[data-theme="light"] .hmi-panel-bg2 { background: rgba(15, 23, 42, 0.03); }

/* =====================================================================
 * 深打磨批次：工具栏响应式 / tab 按下反馈 / 空态统一 / 移动端卡片间距
 * ===================================================================== */

/* 统一空态：虚线软框 + 居中弱色文案，供各页面复用 */
.hmi-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    margin: 12px 0;
    padding: 24px;
    text-align: center;
    color: #9da6c7;
    font-size: 0.88rem;
    line-height: 1.6;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.015);
}
html[data-theme="light"] .hmi-empty {
    color: #5c6782;
    border-color: rgba(16, 24, 40, 0.14);
    background: rgba(16, 24, 40, 0.012);
}

/* 表格单元格内的紧凑空态：去掉大留白与虚线框，纯居中弱色文案 */
.hmi-table .hmi-empty {
    min-height: auto;
    margin: 0;
    padding: 24px 8px;
    border: 0;
    background: transparent;
}

/* tab 按下反馈 */
.hmi-tab:active { transform: scale(0.96); }

/* 工具栏响应式：窄屏时输入/选择器占满一行，避免挤压 */
@media (max-width: 640px) {
    .hmi-toolbar { gap: 8px; }
    .hmi-toolbar input.hmi-login-field-input,
    .hmi-toolbar select.hmi-login-field-input {
        flex: 1 1 100%;
        padding: 10px 12px;
    }
}

/* 移动端卡片间距：收紧网格间隙与底部留白 */
@media (max-width: 640px) {
    .hmi-cards,
    .hmi-grid {
        gap: 12px;
    }
    .hmi-cards,
    .hmi-grid,
    section.hmi-panel {
        margin-bottom: 12px;
    }
}

/* =====================================================================
 * UICraft P1 无障碍加固
 * ===================================================================== */

/* 跳到主内容：默认置于屏外，获得焦点时显示 */
.hmi-skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    z-index: 101;
    padding: 10px 16px;
    border-radius: 10px;
    background: linear-gradient(90deg, #4c7dff, #7f5dff);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    box-shadow: 0 8px 22px rgba(var(--hmi-accent-rgb), 0.35);
}
.hmi-skip-link:focus {
    left: 12px;
    outline: 2px solid #9ab6ff;
    outline-offset: 2px;
}

/* 统一键盘焦点环基线：作用域限定业务壳内，键盘用户可见、鼠标不打扰 */
.hmi-shell :focus-visible {
    outline: 2px solid #4c7dff;
    outline-offset: 2px;
}
html[data-theme="light"] .hmi-shell :focus-visible {
    outline-color: #3b82f6;
}

/* =====================================================================
 * UI 统一批次：主题 token 补全 + 一致动效 + reduced-motion + 移动端修正
 * ===================================================================== */

/* 补全 --hmi-panel-bg 主题 token（此前未定义，导致浅色模式下面板/表头残留深色底，出现深底深字不可读）
   与 :root/.light 既有 surface token 语义保持一致，供 inline 背景引用统一取用。 */
:root {
    --hmi-panel-bg: #1e2433;
}
html[data-theme="light"] {
    --hmi-panel-bg: #ffffff;
}

/* 通用加载态：居中 spinner + 文案，供各页面表格/区块复用（与 .hmi-empty 并列的“加载”三态之一） */
.hmi-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 120px;
    margin: 12px 0;
    padding: 24px;
    color: #9da6c7;
    font-size: 0.88rem;
}
.hmi-loading .hmi-spinner,
.hmi-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.14);
    border-top-color: #4c7dff;
    animation: hmi-spin 0.7s linear infinite;
}
html[data-theme="light"] .hmi-loading { color: #5c6782; }
html[data-theme="light"] .hmi-spinner,
html[data-theme="light"] .hmi-loading .hmi-spinner {
    border-color: rgba(16, 24, 40, 0.14);
    border-top-color: #4c7dff;
}
@keyframes hmi-spin { to { transform: rotate(360deg); } }

/* 面板/统计卡/工具栏统一入场：轻微上浮并淡入，节奏克制 */
.hmi-panel,
.hmi-stat-card,
.hmi-tabbar {
    animation: hmi-enter 260ms ease-out both;
}
@keyframes hmi-enter {
    /* 仅淡入，不含 transform 位移：
       若在 keyframe 里设置 transform 并以 fill-mode 保留，动画会占用 transform 属性，
       优先级高于 :hover 的 translateY，导致卡片悬浮抬升失效。故这里只动画 opacity。 */
    from { opacity: 0; }
    to { opacity: 1; }
}

/* prefers-reduced-motion：系统性关闭非关键位移动画，保障动晕/无障碍用户 */
@media (prefers-reduced-motion: reduce) {
    .hmi-panel, .hmi-stat-card, .hmi-tabbar,
    .hmi-modal, .hmi-modal-backdrop {
        animation: none !important;
        transition: none !important;
    }
    .hmi-alert-dot,
    .hmi-spinner,
    .hmi-auth-spinner {
        animation: none !important;
    }
    .hmi-stat-card, .hmi-panel, .hmi-button,
    .hmi-nav-item, .hmi-nav-svg path, .hmi-nav-svg rect, .hmi-nav-svg circle,
    .hmi-sidebar-toggle, .hmi-logout-button {
        transform: none !important;
    }
}

