:root {
  --bg: #070b10;
  --bg-elevated: #0c1219;
  --bg-card: #111820;
  --bg-hover: #182230;
  --border: rgba(120, 160, 190, 0.14);
  --border-strong: rgba(120, 160, 190, 0.28);
  --text: #eef3f8;
  --muted: #8fa3b8;
  --accent: #2fd6b5;
  --accent-dim: rgba(47, 214, 181, 0.14);
  --accent-glow: rgba(47, 214, 181, 0.35);
  --danger: #ff5c6a;
  --warning: #f0a83a;
  --font: "Noto Sans SC", system-ui, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.28);
  --ease: 180ms ease;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 140, 165, 0.35) rgba(8, 12, 18, 0.4);
}
/* 全局暗色滚动条：避免系统默认白条在深色界面上晃眼 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 140, 165, 0.35) rgba(8, 12, 18, 0.35);
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-track {
  background: rgba(8, 12, 18, 0.55);
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: rgba(110, 140, 165, 0.32);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(47, 214, 181, 0.42);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}
.data-query-table-wrap {
  scrollbar-color: rgba(110, 140, 165, 0.38) rgba(8, 12, 18, 0.5);
}
.data-query-table-wrap::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
.data-query-table-wrap::-webkit-scrollbar-track {
  background: rgba(8, 12, 18, 0.65);
}
.data-query-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(110, 140, 165, 0.3);
}
/* 未完成身份验证时强制隐藏业务区（防脚本加载前闪屏、防绕过 hidden） */
body.auth-locked #appLayout,
body.auth-locked #monitorModal,
body:not(.authenticated) #appLayout,
body:not(.authenticated) #monitorModal {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.auth-locked .login-gate,
body:not(.authenticated) .login-gate {
  display: flex !important;
}
.hidden { display: none !important; }
.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 480px at 18% 12%, rgba(47, 214, 181, 0.16), transparent 58%),
    radial-gradient(700px 420px at 88% 78%, rgba(56, 120, 180, 0.18), transparent 55%),
    linear-gradient(165deg, #06090e 0%, #0b121a 48%, #081018 100%);
}
.login-gate::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 72%);
  pointer-events: none;
  opacity: 0.45;
}
.login-box {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  padding: 2.25rem 2rem 1.75rem;
  background: rgba(14, 20, 28, 0.82);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-soft), 0 0 0 1px rgba(47, 214, 181, 0.06) inset;
  backdrop-filter: blur(14px);
  animation: loginRise 420ms ease both;
}
@keyframes loginRise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.brand-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.1rem;
}
.brand-logo {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(47, 214, 181, 0.18));
}
.brand-logo--sidebar {
  width: auto;
  height: 28px;
  max-width: 72px;
  margin: 0;
  flex-shrink: 0;
  filter: none;
}
.login-brand-name {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  margin: 0 0 0.35rem 0.28em;
  color: var(--text);
}
.login-footer {
  text-align: center;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}
.login-footer .login-hint {
  margin-top: 0;
  margin-bottom: 0.45rem;
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  margin: 0;
  line-height: 1.5;
}
.login-box > p { color: var(--muted); font-size: 0.88rem; margin-bottom: 0.85rem; text-align: center; line-height: 1.5; }
.login-role-hint { font-size: 0.78rem !important; margin-top: -0.35rem !important; opacity: 0.85; }
.login-box label { display: block; font-size: 0.78rem; color: var(--muted); margin: 0.65rem 0 0.3rem; }
.login-box input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(7, 11, 16, 0.75);
  color: var(--text);
  margin-bottom: 0.2rem;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.login-box input:focus {
  outline: none;
  border-color: rgba(47, 214, 181, 0.55);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.login-box button[type="submit"] {
  width: 100%;
  margin-top: 1.15rem;
  padding: 0.7rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #3ee0c0 0%, #22c3a4 100%);
  color: #04140f;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: transform var(--ease), box-shadow var(--ease), filter var(--ease);
  box-shadow: 0 8px 22px rgba(47, 214, 181, 0.22);
}
.login-box button[type="submit"]:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 28px rgba(47, 214, 181, 0.3);
}
.login-box button[type="submit"]:active { transform: translateY(1px); }
.login-err { color: var(--danger); font-size: 0.85rem; margin-top: 0.75rem; min-height: 1.2em; text-align: center; }
.login-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: 0.75rem;
  line-height: 1.4;
  text-align: center;
  opacity: 0.92;
}
.login-hint-dash { opacity: 0.45; letter-spacing: 0.05em; color: var(--muted); }
.sidebar-foot {
  padding: 0.65rem 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.btn-logout {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}
.btn-logout:hover { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }
.layout { display: flex; min-height: 100vh; background: var(--bg); }
.sidebar {
  width: 228px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(47, 214, 181, 0.06) 0%, transparent 22%),
    var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 0.85rem 0 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  transition: width var(--ease);
}
.btn-sidebar-toggle {
  flex-shrink: 0;
  width: 1.7rem;
  height: 1.7rem;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}
.btn-sidebar-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
  transition: transform var(--ease);
}
.btn-sidebar-toggle:hover {
  color: var(--accent);
  border-color: rgba(47, 214, 181, 0.45);
  background: var(--accent-dim);
}
.sidebar.is-collapsed {
  width: 72px;
}
.sidebar.is-collapsed .brand {
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.2rem 0.45rem 0.7rem;
  align-items: center;
}
.sidebar.is-collapsed .brand-text { display: none; }
.sidebar.is-collapsed .btn-sidebar-toggle { margin-left: 0; }
.sidebar.is-collapsed .btn-sidebar-toggle svg { transform: rotate(180deg); }
.sidebar.is-collapsed .nav-group-label {
  justify-content: center;
  padding: 0.35rem 0.2rem 0.25rem;
  font-size: 0;
  letter-spacing: 0;
  gap: 0;
}
.sidebar.is-collapsed .nav-group-label::before {
  content: "";
  width: 1.1rem;
  height: 1px;
  background: var(--border);
}
.sidebar.is-collapsed .nav-group-label::after { display: none; }
.sidebar.is-collapsed #sidebarNav.sidebar-nav { padding: 0.1rem 0.4rem 0.45rem; }
.sidebar.is-collapsed .sidebar-nav button {
  justify-content: center;
  padding: 0.5rem;
  gap: 0;
}
.sidebar.is-collapsed .sidebar-nav button .nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sidebar.is-collapsed .sidebar-nav button.active {
  box-shadow: inset 0 0 0 1px rgba(47, 214, 181, 0.35);
  background: rgba(47, 214, 181, 0.16);
}
.sidebar.is-collapsed .ws-status #wsLabel,
.sidebar.is-collapsed .ws-status .build-version { display: none; }
.sidebar.is-collapsed .ws-status { justify-content: center; }
.sidebar.is-collapsed .btn-logout {
  font-size: 0;
  padding: 0.55rem;
  line-height: 0;
  position: relative;
}
.sidebar.is-collapsed .btn-logout::before {
  content: "⎋";
  font-size: 0.95rem;
  line-height: 1;
  color: inherit;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.25rem 0.95rem 0.8rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.4rem;
  text-align: left;
  flex-shrink: 0;
}
.brand-text { min-width: 0; flex: 1; }
.brand p { font-size: 0.68rem; color: var(--muted); margin-top: 0.12rem; line-height: 1.3; }
.brand-name {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin: 0 0 0 0.12em;
  color: var(--text);
  line-height: 1.2;
}
.brand-tagline { display: none; }
/* 勿用 id="nav"：天地图 tianditu4.0.css 含 #nav{background:#F9F9F9} 会污染侧栏 */
#sidebarNav.sidebar-nav {
  background: transparent;
  border: none;
  width: auto;
  padding: 0.1rem 0.55rem 0.45rem;
  font-weight: inherit;
  text-align: left;
  list-style: none;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 163, 184, 0.35) transparent;
}
#sidebarNav.sidebar-nav::-webkit-scrollbar { width: 5px; }
#sidebarNav.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
#sidebarNav.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(143, 163, 184, 0.28);
  border-radius: 999px;
}
#sidebarNav.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(47, 214, 181, 0.45);
}
.nav-group { margin-bottom: 0.5rem; }
.nav-group:last-child { margin-bottom: 0.15rem; }
.nav-group-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.55rem 0.3rem;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: none;
  color: rgba(143, 163, 184, 0.78);
  font-weight: 600;
}
.nav-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}
.sidebar-nav button {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.48rem 0.6rem;
  margin: 0 0 0.1rem;
  border: none;
  border-radius: 9px;
  background-color: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  position: relative;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}
.sidebar-nav button .nav-ico {
  width: 1.35rem;
  height: 1.35rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
}
.sidebar-nav button .nav-ico svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-nav button .nav-label { flex: 1; min-width: 0; }
.sidebar-nav button:hover {
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.045);
}
.sidebar-nav button:hover .nav-ico {
  background: rgba(47, 214, 181, 0.1);
  color: var(--accent);
}
.sidebar-nav button.active {
  color: #f4fffb;
  background: linear-gradient(90deg, rgba(47, 214, 181, 0.2), rgba(47, 214, 181, 0.07));
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav button.active .nav-ico {
  background: rgba(47, 214, 181, 0.22);
  color: var(--accent);
}
.sidebar-nav button:focus-visible {
  outline: 2px solid rgba(47, 214, 181, 0.55);
  outline-offset: 1px;
}
.main {
  flex: 1;
  padding: 1.6rem 2rem 2.25rem;
  overflow: auto;
  min-width: 0;
  background:
    radial-gradient(1000px 420px at 100% -10%, rgba(47, 214, 181, 0.07), transparent 55%),
    var(--bg);
}
.main > .page-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}
.main > .page-desc {
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 1.35rem;
  max-width: 62rem;
  line-height: 1.55;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.page-desc { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.ah-device-metrics { margin-bottom: 1.25rem; }
.ah-device-metrics:last-child { margin-bottom: 0; }
.ah-device-metrics-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.ah-metric-grid { gap: 0.75rem; }
.ah-metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
}
.ah-metric-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.ah-metric-val {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0.25rem 0;
}
.ah-metric-ref { margin: 0.35rem 0 0; line-height: 1.35; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.03), transparent 42%), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  transition: border-color var(--ease), transform var(--ease);
}
.grid.g4 > .card {
  position: relative;
  overflow: hidden;
  padding-top: 1.1rem;
}
.grid.g4 > .card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent 85%);
  opacity: 0.85;
}
.card h3 { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.45rem; font-weight: 500; letter-spacing: 0.04em; }
.stat {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.section { font-size: 0.95rem; color: var(--text); margin-bottom: 0.75rem; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-weight: 500; }
tr:hover td { background: var(--bg-hover); }
.badge { padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; }
.b-running { background: #0d3d32; color: var(--accent); }
.b-offline { background: #2a2a2a; color: var(--muted); }
.b-critical { background: #3d1515; color: var(--danger); }
.b-warning { background: #3d3010; color: var(--warning); }
.b-muted { background: #1e2430; color: var(--muted); }
.device-provision-banner .provision-kv {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }
input:not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  margin-bottom: 0.75rem;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  vertical-align: middle;
}
label.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text);
}
label.checkbox-inline input[type="checkbox"] {
  flex-shrink: 0;
}
td.actions { min-width: 11rem; vertical-align: top; }
td.actions .sel-group { width: 100%; max-width: 10rem; margin-bottom: 0.4rem; }
td.actions .btn { width: auto; display: inline-block; margin: 0 0.35rem 0.35rem 0; padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.bind-code-banner code { font-size: 1.15rem; letter-spacing: 0.12em; color: var(--accent); }

.card .btn-hist-query {
  width: auto;
  display: inline-block;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}
.config-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}
.config-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.config-item:last-child { border-bottom: none; }
.config-item--off { opacity: 0.55; }
.config-item code { color: var(--accent); font-size: 0.78rem; }
.config-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
.config-actions .btn-ghost { padding: 0.2rem 0.45rem; font-size: 0.75rem; width: auto; }
.config-add { margin-top: 0.5rem; }
.config-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 0.4rem;
  align-items: center;
}
.config-add-row--metric {
  grid-template-columns: 1fr minmax(4rem, 5rem) minmax(7rem, 1fr) auto;
}
.metric-key-preview {
  font-size: 0.78rem;
  color: var(--muted, #8aa);
  white-space: nowrap;
}
.metric-key-preview code {
  color: var(--accent, #3dd6c6);
  font-size: 0.82em;
}
.config-add-row .btn-inline {
  width: auto;
  padding: 0.45rem 0.65rem;
  font-size: 0.8rem;
  white-space: nowrap;
}
@media (max-width: 900px) {
  .config-add-row { grid-template-columns: 1fr 1fr; }
}
/* 分组管理 */
.group-panel { margin-bottom: 0.25rem; }
.group-panel input[type="file"].fw-file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}
.fw-file-label {
  display: block;
  margin-bottom: 0.35rem;
}
.fw-file-btn {
  display: inline-block;
  width: auto;
  cursor: pointer;
}
.fw-file-name {
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
  word-break: break-all;
}
.fw-ota-hint {
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}
.fw-batch-preview {
  font-size: 0.8rem;
  margin: 0.5rem 0;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  line-height: 1.45;
}
.fw-batch-summary { margin: 0 0 0.4rem; color: var(--text); }
.fw-batch-summary strong { color: var(--accent); }
.fw-batch-list {
  margin: 0;
  padding: 0 0 0 1.1rem;
  max-height: 140px;
  overflow-y: auto;
}
.fw-batch-list li { margin-bottom: 0.25rem; }
.fw-batch-list code { font-size: 0.78rem; color: var(--accent); }
.fw-batch-empty { margin: 0; color: var(--muted); }
.group-panel label {
  margin-top: 0.35rem;
}
.group-panel input:not([type="file"]) {
  margin-bottom: 0.5rem;
}
/* 分组创建行：grid 固定行高，避免全局 input margin 导致按钮偏下 */
.group-create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.group-panel .group-create-row .group-create-input,
.group-panel .group-create-row .btn-inline {
  margin: 0;
  height: 2.125rem;
  box-sizing: border-box;
  font-size: 0.875rem;
}
.group-panel .group-create-row .group-create-input {
  width: 100%;
  min-width: 0;
  padding: 0 0.65rem;
  line-height: normal;
}
.group-panel .group-create-row .btn-inline {
  width: auto;
  padding: 0 0.75rem;
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
}
.group-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 240px;
  overflow-y: auto;
}
.group-list::-webkit-scrollbar { width: 6px; }
.group-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.group-empty {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}
.group-empty__icon {
  font-size: 1.25rem;
  opacity: 0.7;
}
.group-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem 0.55rem 0.75rem;
  background: linear-gradient(135deg, rgba(0, 212, 170, 0.06) 0%, transparent 55%), var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.group-card:hover {
  border-color: rgba(0, 212, 170, 0.45);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
.group-card__main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}
.group-card__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(0, 212, 170, 0.12);
  border: 1px solid rgba(0, 212, 170, 0.25);
  position: relative;
}
.group-card__icon::after {
  content: "";
  position: absolute;
  inset: 9px 8px 11px 8px;
  border: 2px solid var(--accent);
  border-radius: 2px;
  opacity: 0.85;
}
.group-card__text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.group-card__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-card__badge {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 500;
}
.group-card__badge--empty {
  color: var(--muted);
  font-weight: 400;
}
.group-card__del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.group-card__del:hover {
  color: var(--danger);
  background: rgba(255, 71, 87, 0.12);
  border-color: rgba(255, 71, 87, 0.35);
}
.btn { padding: 0.5rem 1rem; border: none; border-radius: 6px; font-family: inherit; cursor: pointer; background: var(--accent); color: #0a0e14; font-weight: 500; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.msg { padding: 0.75rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.875rem; }
.msg-ok { background: #0d3d32; color: var(--accent); border: 1px solid #00a888; }
.msg-err { background: #3d1515; color: #ffb4b4; border: 1px solid var(--danger); }
.msg-warn {
  background: rgba(245, 166, 35, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 166, 35, 0.45);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
}
.chart { height: 300px; width: 100%; overflow: hidden; position: relative; }
.chart--below-toolbar { margin-top: 0.75rem; }
.chart--section { margin-top: 0.5rem; }
.mt { margin-top: 1rem; }
.flex { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
/* 筛选工具栏：去掉 select 底部外边距，按钮与下拉框底边对齐 */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
}
.filter-field {
  display: flex;
  flex-direction: column;
}
.filter-field > label {
  margin-bottom: 0.35rem;
  min-height: 1.2em;
  line-height: 1.2;
}
.filter-toolbar .filter-field select {
  margin-bottom: 0;
  width: auto;
  min-width: 9rem;
}
.filter-field--action {
  padding-top: calc(0.8rem * 1.2 + 0.35rem);
}
.filter-field--action .btn {
  width: auto;
  white-space: nowrap;
}

.device-list-toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.device-list-toolbar .section {
  margin: 0;
  white-space: nowrap;
}
.device-search-input {
  width: 100%;
  max-width: 18rem;
  justify-self: center;
  margin-bottom: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
}
.bind-scan-input {
  font-size: 1.15rem !important;
  letter-spacing: 0.08em;
  font-weight: 600;
  border-color: rgba(47, 214, 181, 0.45) !important;
  background: rgba(47, 214, 181, 0.06) !important;
}
.device-search-meta {
  font-size: 0.78rem;
  white-space: nowrap;
  text-align: right;
}
.device-list-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.data-query-filter-grid {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  gap: 0.5rem 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}
@media (max-width: 720px) {
  .data-query-filter-grid {
    grid-template-columns: 1fr;
  }
}
.data-query-filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.data-query-auto {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}
.data-query-field-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  max-height: 140px;
  overflow: auto;
  padding-right: 0.25rem;
}
.data-query-field-section + .data-query-field-section {
  margin-top: 0.75rem;
}
.data-query-field-group-title {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}
.data-query-field-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.data-query-table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}
.data-query-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 1rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: rgba(255, 71, 87, 0.12); }
.data-query-delete-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.data-query-delete-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.data-query-col-check { width: 2rem; text-align: center; }
.data-query-col-check input { cursor: pointer; }
  font-size: 0.82rem;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.data-query-page-size select {
  width: auto;
  min-width: 4rem;
  margin: 0;
  padding: 0.25rem 0.4rem;
}
.empty-hint {
  padding: 1.5rem 0;
  text-align: center;
}

.ws-status {
  padding: 0;
  font-size: 0.7rem;
  color: var(--muted);
  border-top: none;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
}
.ws-status .build-version {
  width: 100%;
  margin-top: 0.15rem;
}
.build-version { margin-top: 0.35rem; font-size: 0.65rem; color: var(--muted); opacity: 0.75; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.35rem; }
.status-dot.on { background: var(--accent); }
.status-dot.off { background: var(--danger); }
.feed { max-height: 160px; overflow-y: auto; font-size: 0.75rem; font-family: monospace; color: var(--muted); }
.feed li { list-style: none; padding: 0.2rem 0; border-bottom: 1px solid var(--border); }
.hidden { display: none !important; }

.monitor-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
}
@media (max-width: 1100px) {
  .monitor-layout { grid-template-columns: 1fr; }
}
.monitor-map-card {
  position: relative;
  overflow: hidden;
}
.monitor-map {
  height: 420px;
  width: 100%;
  border-radius: 8px;
  background: #0d1219;
  position: relative;
  overflow: hidden;
}
.monitor-map .tdt-container,
.monitor-map .tdt-map {
  width: 100% !important;
  height: 100% !important;
}
.map-placeholder {
  padding: 2rem; color: var(--muted); font-size: 0.875rem; text-align: center;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
}
.monitor-alerts-card { max-height: 520px; display: flex; flex-direction: column; }
.alert-live-list {
  list-style: none; overflow-y: auto; flex: 1; max-height: 440px; margin: 0; padding: 0;
}
.alert-live-item {
  padding: 0.65rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem;
  display: grid; gap: 0.25rem;
}
.alert-live-item--critical { border-left: 3px solid var(--danger); padding-left: 0.5rem; }
.alert-live-item--warning { border-left: 3px solid var(--warning); padding-left: 0.5rem; }
.alert-live-item time { font-size: 0.7rem; color: var(--muted); }
.btn-ack-sm { padding: 0.2rem 0.5rem; font-size: 0.75rem; width: auto; }
.chart-sm { height: 220px; }
.feed-type { color: var(--accent); margin-right: 0.35rem; }
.page-desc a { color: var(--accent); }
.alert-toast-stack {
  position: fixed; top: 1rem; right: 1rem; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px;
}
.alert-toast {
  padding: 0.75rem 1rem; border-radius: 8px; background: var(--bg-card);
  border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0; transform: translateX(20px); transition: opacity 0.3s, transform 0.3s;
  font-size: 0.8rem; display: grid; gap: 0.2rem;
}
.alert-toast.show { opacity: 1; transform: translateX(0); }
.alert-toast--critical { border-color: var(--danger); }
.alert-toast--warning { border-color: var(--warning); }
.monitor-modal {
  position: fixed; inset: 0; z-index: 8000; display: flex; align-items: center; justify-content: center;
}
.monitor-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.monitor-modal-box {
  position: relative; width: min(480px, 92vw); max-height: 80vh; overflow: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem;
}
.monitor-modal-box header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.monitor-dl { display: grid; grid-template-columns: 100px 1fr; gap: 0.35rem 0.75rem; font-size: 0.85rem; }
.monitor-dl dt { color: var(--muted); }

select.sel-multi {
  min-height: 7rem;
  margin-bottom: 0;
}
.table-compact { font-size: 0.8rem; }
.table-compact th, .table-compact td { padding: 0.35rem 0.5rem; }
.comm-status-table .comm-json-cell { max-width: 280px; vertical-align: top; }
.comm-json-fold { margin: 0; }
.comm-json-preview { cursor: pointer; list-style: none; }
.comm-json-preview::-webkit-details-marker { display: none; }
.comm-json-preview code {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.72rem;
  color: var(--muted, #8b9cb3);
}
.comm-json-pre {
  margin: 0.35rem 0 0;
  padding: 0.5rem;
  max-height: 220px;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.35;
  background: #0f172a;
  border: 1px solid var(--border, #243044);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 数据分析 · 设备效能列表：分页 + 分组折叠 */
.eff-devices-fold { margin-top: 0.75rem; border-top: 1px solid var(--border, #243044); padding-top: 0.5rem; }
.eff-devices-fold-summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #e8edf5);
  list-style: none;
  user-select: none;
}
.eff-devices-fold-summary::-webkit-details-marker { display: none; }
.eff-devices-fold-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  color: var(--accent, #00d4aa);
}
.eff-devices-fold[open] > .eff-devices-fold-summary::before { transform: rotate(90deg); }
.eff-device-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}
.eff-device-toolbar-field select { width: auto; min-width: 4rem; margin: 0 0.25rem; }
.eff-device-toolbar-check { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.eff-device-pager-info { flex: 1 1 auto; min-width: 8rem; }
.eff-device-pager { display: flex; gap: 0.35rem; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.eff-device-list { display: flex; flex-direction: column; gap: 0.5rem; }
.eff-device-group {
  border: 1px solid var(--border, #243044);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.35);
  overflow: hidden;
}
.eff-device-group-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.eff-device-group-hd::-webkit-details-marker { display: none; }
.eff-device-group-hd::before {
  content: "▸";
  margin-right: 0.35rem;
  color: var(--accent, #00d4aa);
  transition: transform 0.15s ease;
}
.eff-device-group[open] > .eff-device-group-hd::before { transform: rotate(90deg); }
.eff-device-group-title { font-weight: 600; }
.eff-device-group-body {
  max-height: 280px;
  overflow: auto;
  border-top: 1px solid var(--border, #243044);
}
.eff-device-group-body .table-compact { margin: 0; }
.eff-device-flat { max-height: 360px; overflow: auto; }
tr.row-fail td { background: rgba(255, 107, 107, 0.06); }
.audit-detail { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 固件升级进度（弹窗） */
.fw-upgrade-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.fw-upgrade-label { color: var(--accent); font-weight: 500; }
.fw-upgrade-pct { margin-left: auto; font-weight: 600; color: var(--text); }
.fw-progress {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.fw-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #008866, var(--accent));
  box-shadow: 0 0 8px rgba(0, 212, 170, 0.45);
  transition: width 0.45s ease;
}
.fw-progress-bar.is-installing {
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.45);
}
.fw-progress-bar.is-success {
  background: linear-gradient(90deg, #059669, #34d399);
}

.fw-pick-card { width: min(440px, 92vw); }
.fw-pick-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: min(320px, 50vh);
  overflow-y: auto;
  margin: 0.75rem 0 1rem;
  padding: 2px;
}
.fw-pick-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.fw-pick-item:hover {
  border-color: rgba(0, 212, 170, 0.45);
  background: rgba(0, 212, 170, 0.06);
}
.fw-pick-item.is-selected {
  border-color: var(--accent);
  background: rgba(0, 212, 170, 0.12);
  box-shadow: 0 0 0 1px rgba(0, 212, 170, 0.25);
}
.fw-pick-item input[type="radio"] {
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.fw-pick-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}
.fw-pick-ver {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}
.fw-pick-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.fw-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.fw-modal-card {
  width: min(420px, 92vw);
  padding: 1.5rem 1.75rem;
  border-radius: 10px;
  background: var(--panel, #151c28);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.fw-modal-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: var(--text);
}
.fw-modal-card .fw-modal-sub {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.fw-modal-progress { margin: 1rem 0 0.5rem; }
.fw-modal-progress .fw-progress { height: 10px; }
.fw-modal-foot {
  margin-top: 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.fw-success-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: rgba(0, 212, 170, 0.15);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: 1.75rem;
  line-height: 48px;
  text-align: center;
}
.fw-modal-card.fw-success-card { text-align: center; }
.fw-modal-card.fw-success-card .fw-modal-foot { justify-content: center; }

@media print {
  body.print-analytics .sidebar,
  body.print-analytics .login-gate,
  body.print-analytics #loginGate,
  body.print-analytics .btn,
  body.print-analytics .filter-toolbar,
  body.print-analytics .btn-sidebar-toggle {
    display: none !important;
  }
  body.print-analytics .layout,
  body.print-analytics .main {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #111 !important;
  }
  body.print-analytics .card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}

/* 管理端窄屏：侧栏可收纳 + 主区全宽 */
@media (max-width: 860px) {
  .layout {
    flex-direction: row;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    height: 100vh;
    width: min(280px, 86vw);
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }
  .sidebar.is-collapsed {
    transform: translateX(calc(-100% + 3.25rem));
    width: min(280px, 86vw);
  }
  .main {
    margin-left: 3.25rem;
    width: calc(100% - 3.25rem);
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
  .grid.g2,
  .grid-2,
  .grid.g4 {
    grid-template-columns: 1fr !important;
  }
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
}
