:root {
  --bg: #f1f5f9;
  --content-bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-secondary: #334155;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.08);
  --sidenav-width: 252px;
  --sidenav-bg: #0f172a;
  --sidenav-border: rgba(255, 255, 255, 0.08);
  --sidenav-text: rgba(255, 255, 255, 0.78);
  --sidenav-text-active: #ffffff;
  --topbar-bg: #ffffff;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
}
* { box-sizing: border-box; }

/* ========== 后台整体骨架 ========== */
.admin-body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

html[data-admin-theme="dark"] body.admin-body {
  background: #070b14;
  color: var(--text);
  --bg: #0b1120;
  --content-bg: #070b14;
  --card: rgba(15, 23, 42, 0.86);
  --border: rgba(56, 189, 248, 0.2);
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --muted: #64748b;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-admin-theme="light"] body.admin-body {
  background: #f1f5f9;
  color: var(--text);
}

.admin-shell {
  min-height: 100vh;
}

.admin-sidenav {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  width: var(--sidenav-width);
  max-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--sidenav-bg);
  color: var(--sidenav-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidenav-border);
}

.admin-sidenav__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 0.8rem 1rem 0.9rem;
  color: var(--sidenav-text-active);
  border-bottom: 1px solid var(--sidenav-border);
}

.admin-sidenav__brand-mark {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  /*background: #ffffff;*/
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.22);
}

.admin-sidenav__brand-mark img {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
}

.admin-sidenav__brand-copy {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
}

.admin-sidenav__brand-title {
  display: block;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

.admin-sidenav__brand-subtitle {
  display: block;
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.admin-sidenav__brand-text {
  min-width: 0;
  line-height: 1.35;
}

.admin-sidenav__theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.admin-sidenav__theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-sidenav__theme-toggle:focus-visible {
  outline: 2px solid var(--accent, #38bdf8);
  outline-offset: 2px;
}

.admin-sidenav__theme-icon {
  display: none;
  width: 1.25rem;
  height: 1.25rem;
}

.admin-sidenav__theme-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

html[data-admin-theme="dark"] .admin-sidenav__theme-icon--sun {
  display: block;
}

html[data-admin-theme="light"] .admin-sidenav__theme-icon--moon {
  display: block;
}

html[data-admin-theme="light"] .admin-sidenav__theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.admin-sidenav__nav {
  flex: 1;
  padding: 1rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.admin-sidenav__link {
  display: flex;
  align-items: center;
  gap: 0.78rem;
  padding: 0.82rem 0.92rem;
  margin: 0;
  border-radius: 14px;
  color: var(--sidenav-text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.admin-sidenav__link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--sidenav-text-active);
  border-color: rgba(255, 255, 255, 0.05);
  transform: translateX(1px);
}

.admin-sidenav__link.is-active {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.28), rgba(29, 78, 216, 0.2));
  color: var(--sidenav-text-active);
  border-color: rgba(96, 165, 250, 0.22);
  box-shadow: inset 0 1px 0 rgba(191, 219, 254, 0.12), 0 12px 24px rgba(2, 6, 23, 0.22);
}

.admin-sidenav__link-icon {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  color: rgba(191, 219, 254, 0.86);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-sidenav__link-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.admin-sidenav__link-text {
  min-width: 0;
}

.admin-sidenav__debug {
  flex-shrink: 0;
  padding: 0.35rem 0 0.65rem;
  border-top: 1px solid var(--sidenav-border);
  margin-top: 0.25rem;
}

.admin-sidenav__debug-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidenav-text);
  opacity: 0.45;
  padding: 0.45rem 1.35rem 0.25rem;
}

.admin-sidenav__nav--debug {
  padding-top: 0;
}

.admin-sidenav__link--debug {
  font-size: 0.8125rem;
  opacity: 0.92;
}

.admin-sidenav__user {
  margin-top: auto;
  padding: 1.1rem 1.35rem 1.35rem;
  border-top: 1px solid var(--sidenav-border);
  font-size: 0.8125rem;
}

.admin-sidenav__user-label {
  color: var(--sidenav-text);
  opacity: 0.75;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-sidenav__user-name {
  color: var(--sidenav-text-active);
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.2rem;
}

.admin-sidenav__user-role {
  color: var(--sidenav-text);
  font-size: 0.8125rem;
}

.admin-sidenav__logout {
  margin-top: 0.9rem;
  width: 100%;
}

.admin-main {
  margin-left: var(--sidenav-width);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
}

html[data-admin-theme="dark"] .admin-main {
  background: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(56, 189, 248, 0.12), transparent 55%),
    linear-gradient(180deg, #0a101f 0%, #070b14 40%, #060912 100%);
}

/* 侧栏、顶栏与智慧总览中心大屏一致（青蓝强调、深 slate 底） */
html[data-admin-theme="dark"] body.admin-body .admin-sidenav {
  background: linear-gradient(180deg, #0c1222 0%, #070b14 100%);
  border-right: 1px solid rgba(56, 189, 248, 0.12);
}

html[data-admin-theme="dark"] body.admin-body .admin-sidenav__brand {
  color: #ffffff;
}

html[data-admin-theme="dark"] body.admin-body .admin-sidenav__link {
  color: rgba(255, 255, 255, 0.78);
}

html[data-admin-theme="dark"] body.admin-body .admin-sidenav__link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-admin-theme="dark"] body.admin-body .admin-sidenav__link.is-active {
  color: #ffffff;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.28), rgba(29, 78, 216, 0.2));
  border-color: rgba(96, 165, 250, 0.22);
}

html[data-admin-theme="dark"] body.admin-body .admin-sidenav__user-label,
html[data-admin-theme="dark"] body.admin-body .admin-sidenav__user-role {
  color: rgba(255, 255, 255, 0.72);
}

html[data-admin-theme="dark"] body.admin-body .admin-sidenav__user-name {
  color: #ffffff;
}

html[data-admin-theme="dark"] body.admin-body .admin-topbar {
  border-bottom-color: rgba(56, 189, 248, 0.18);
  background: rgba(7, 11, 20, 0.85);
  backdrop-filter: blur(8px);
  box-shadow: none;
}

html[data-admin-theme="dark"] body.admin-body .admin-topbar__title {
  color: #e2e8f0;
  text-shadow: 0 0 24px rgba(56, 189, 248, 0.25);
}

html[data-admin-theme="dark"] body.admin-body .admin-topbar__subtitle {
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .admin-topbar__subtitle strong {
  color: #7dd3fc;
}

/* 浅色主题：侧栏保持深色，顶栏恢复日间样式 */
html[data-admin-theme="light"] .admin-sidenav {
  background: linear-gradient(180deg, #0c1222 0%, #070b14 100%);
  color: rgba(255, 255, 255, 0.78);
  border-right-color: rgba(56, 189, 248, 0.12);
}

html[data-admin-theme="light"] .admin-sidenav__brand {
  color: #ffffff;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-admin-theme="light"] .admin-sidenav__link {
  color: rgba(255, 255, 255, 0.78);
}

html[data-admin-theme="light"] .admin-sidenav__link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-admin-theme="light"] .admin-sidenav__link.is-active {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.28), rgba(29, 78, 216, 0.2));
  color: #ffffff;
  border-color: rgba(96, 165, 250, 0.22);
}

html[data-admin-theme="light"] .admin-sidenav__user-label,
html[data-admin-theme="light"] .admin-sidenav__user-role {
  color: rgba(255, 255, 255, 0.72);
}

html[data-admin-theme="light"] .admin-sidenav__user-name {
  color: #ffffff;
}

html[data-admin-theme="light"] .admin-topbar {
  background: #ffffff;
  border-bottom-color: #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  backdrop-filter: none;
}

html[data-admin-theme="light"] .admin-topbar__title {
  color: #0f172a;
  text-shadow: none;
}

html[data-admin-theme="light"] .admin-topbar__subtitle {
  color: #64748b;
}

html[data-admin-theme="light"] .admin-topbar__subtitle strong {
  color: #2563eb;
}

.admin-topbar {
  flex-shrink: 0;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: 1.2rem 1.75rem 1.15rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.admin-topbar__titles {
  min-width: 0;
  flex: 1;
}

.admin-topbar__title {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.3;
}

.admin-topbar__subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  max-width: 52rem;
}

.admin-topbar__subtitle:empty {
  display: none;
}

.admin-topbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.admin-content {
  flex: 1;
  padding: 1.5rem 1.75rem 2.5rem;
  width: 100%;
  /*max-width: 1920px;*/
  margin: 0 auto;
}

/* 顶栏右侧：筛选 / 搜索占位 */
.admin-toolbar-placeholder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.admin-toolbar-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.admin-input {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-size: 0.875rem;
  background: #fff;
  color: var(--text);
}

.admin-input--search {
  min-width: 11rem;
  max-width: 16rem;
}

.admin-input:disabled {
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
}

.admin-code {
  font-size: 0.84em;
  padding: 0.12rem 0.35rem;
  background: #f1f5f9;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* 主内容区卡片（后台通用） */
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 1.35rem 1.5rem;
  max-width: 56rem;
}

.admin-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  /*margin-bottom: 0.85rem;*/
}

.admin-card__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
}

.admin-card__lead {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.admin-muted {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.admin-muted a {
  color: var(--accent);
  text-decoration: none;
}

.admin-muted a:hover {
  text-decoration: underline;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn--secondary {
  background: #fff;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: #f8fafc;
}

.btn:disabled, .btn--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* 仅写 .btn 的链接（如设备卡片）默认主色 */
a.btn:not(.btn--secondary):not(.btn--primary) {
  background: var(--accent);
  color: #fff !important;
  border-color: var(--accent);
}
a.btn:not(.btn--secondary):not(.btn--primary):hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* 标签 / 徽章 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px dashed var(--border);
  color: var(--muted);
  background: #f8fafc;
}

.tag--muted {
  opacity: 0.9;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--info {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge--success {
  background: #d1fae5;
  color: var(--success);
}

.badge--warning {
  background: #fef3c7;
  color: var(--warning);
}

.badge--danger {
  background: #fee2e2;
  color: var(--danger);
}

/* 兼容旧 .wrap（遗留 HTML 壳） */
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

@media (max-width: 900px) {
  .admin-shell {
    display: flex;
    flex-direction: column;
  }
  .admin-sidenav {
    position: static;
    top: auto;
    left: auto;
    bottom: auto;
    z-index: auto;
    width: 100%;
    max-height: none;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  .admin-main {
    margin-left: 0;
  }
  .admin-sidenav__brand {
    flex: 1;
    min-width: 140px;
    border-bottom: none;
    border-right: 1px solid var(--sidenav-border);
    padding: 1rem 1rem;
  }
  .admin-sidenav__nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 2;
    padding: 0.5rem 0.35rem;
    gap: 0.25rem;
  }
  .admin-sidenav__link {
    margin: 0;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 0.55rem 0.85rem;
  }
  .admin-sidenav__link.is-active {
    border-left: none;
    border-bottom-color: var(--accent);
  }

  html[data-admin-theme="dark"] body.admin-body .admin-sidenav__link.is-active {
    border-bottom-color: #60a5fa;
  }

  html[data-admin-theme="light"] .admin-sidenav__link.is-active {
    border-bottom-color: #60a5fa;
  }
  .admin-sidenav__user {
    width: 100%;
    margin-top: 0;
    border-top: 1px solid var(--sidenav-border);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    align-items: baseline;
  }
  .admin-sidenav__user-label {
    width: 100%;
    margin-bottom: 0;
  }
  .admin-content {
    padding: 1.1rem 1rem 2rem;
  }
  .admin-topbar {
    padding: 1rem 1rem;
  }
}

@media (min-width: 1920px) {
  .admin-content {
    /*padding-left: 2rem;*/
    /*padding-right: 2rem;*/
  }
}
header.page-hd {
  margin-bottom: 1.5rem;
}
header.page-hd h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
header.page-hd p.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
header.page-hd p.nav-extra {
  margin: 0.55rem 0 0;
  font-size: 0.9rem;
}
header.page-hd p.nav-extra a {
  color: var(--accent);
  text-decoration: none;
}
header.page-hd p.nav-extra a:hover { text-decoration: underline; color: var(--accent-hover); }
a.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
a.back:hover { text-decoration: underline; color: var(--accent-hover); }
.card-grid {
  display: grid;
  gap: 1rem;
}
@media (min-width: 640px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}
.device-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.device-card .title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.device-card .display-name {
  font-weight: 600;
  font-size: 1.05rem;
}
.device-card .bid {
  font-size: 0.75rem;
  color: var(--muted);
  word-break: break-all;
}
.device-card .bid-all {
  font-size: 0.68rem;
  opacity: 0.85;
  margin-top: 0.2rem;
}
.device-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.25rem 0.5rem;
  font-size: 0.875rem;
}
.device-card dt {
  color: var(--muted);
  margin: 0;
}
.device-card dd {
  margin: 0;
  word-break: break-word;
}
.device-card .btn {
  margin-top: 0.25rem;
  align-self: flex-start;
}
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.25rem;
}
.section > h2 {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.section .sub,
p.sub {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}
.section .sub:last-child {
  margin-bottom: 0;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1rem;
}
.summary-grid .kv label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.15rem;
}
.summary-grid .kv span {
  font-size: 0.95rem;
  word-break: break-word;
}
.htl-meta {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.htl-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.htl-range-btn {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  padding: 0.38rem 0.72rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}
.htl-range-btn:hover { background: #eef2f6; }
.htl-range-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.htl-track {
  margin-top: 0.25rem;
}
.htl-bar-wrap {
  position: relative;
  padding: 10px 0 4px;
  overflow: visible;
}
#htl-zoom-area {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
#htl-zoom-area.htl-panning {
  cursor: grabbing;
}
body.htl-no-select {
  user-select: none !important;
  -webkit-user-select: none !important;
}
.htl-bar {
  position: relative;
  height: 46px;
  background: linear-gradient(180deg, #dce3ec 0%, #eef2f6 100%);
  border-radius: 8px;
  overflow: visible;
  border: 1px solid #b8c4d4;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.65);
}
.htl-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 3px;
  box-sizing: border-box;
  border-right: 1px solid rgba(255,255,255,0.4);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  cursor: crosshair;
  transform-origin: center bottom;
  border-radius: 0;
}
.htl-seg:hover {
  transform: translateY(-7px) scaleY(1.18);
  z-index: 20;
  filter: brightness(1.12) saturate(1.1);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.28);
  border-radius: 5px 5px 0 0;
}
.htl-seg-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.96);
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  pointer-events: none;
}
.htl-seg--narrow .htl-seg-inner {
  display: none;
}
.htl-tooltip {
  position: fixed;
  z-index: 300;
  background: rgba(15, 23, 42, 0.96);
  color: #f1f5f9;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  max-width: 340px;
  min-width: 220px;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.08);
}
.htl-tt-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}
.htl-tt-k { color: #94a3b8; }
.htl-ticks {
  position: relative;
  height: 1.65rem;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.htl-tick {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}
.htl-tick--first {
  transform: translateX(0);
}
.htl-tick--last {
  transform: translateX(-100%);
}
.htl-tick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  margin-left: -0.5px;
  width: 1px;
  height: 6px;
  background: #94a3b8;
}
.htl-tick--first::before {
  left: 0;
  margin-left: 0;
}
.htl-tick--last::before {
  left: 100%;
  margin-left: -1px;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
table.data th, table.data td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: top;
}
table.data th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.75rem;
}
table.data tr:nth-child(even) td { background: #fafbfc; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}
.section-hd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.section-hd h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.ai-btn {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #f8fafc, #eef2f6);
  color: var(--text);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.ai-btn:hover:not(:disabled) {
  background: #e2e8f0;
}
.ai-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.ai-result-card {
  margin-bottom: 0.85rem;
  padding: 0.95rem 1.05rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.ai-result-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}
.ai-result-card .ai-block {
  margin-bottom: 0.6rem;
}
.ai-result-card .ai-block:last-child {
  margin-bottom: 0;
}
.ai-result-card ul {
  margin: 0.25rem 0 0 1.1rem;
  padding: 0;
}
.ai-error {
  color: #b91c1c;
  margin: 0;
}
.ai-loading {
  color: var(--muted);
  margin: 0;
}
.ai-muted {
  color: var(--muted);
  margin: 0.25rem 0 0;
  font-size: 0.85em;
}

/* ========== 控制台卡片 / 表单：与智慧总览 dash-panel、dash-kpi-card 统一 ========== */

html[data-admin-theme="dark"] body.admin-body .btn--secondary {
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
  border-color: rgba(51, 65, 85, 0.95);
}

html[data-admin-theme="dark"] body.admin-body .btn--secondary:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.92);
  border-color: rgba(56, 189, 248, 0.35);
  color: #f1f5f9;
}

/* 面板：与 dash-panel 相同的渐变底与内高光 */
html[data-admin-theme="dark"] body.admin-body .admin-card,
html[data-admin-theme="dark"] body.admin-body .panel-like,
html[data-admin-theme="dark"] body.admin-body .rep-card,
html[data-admin-theme="dark"] body.admin-body .emp-card,
html[data-admin-theme="dark"] body.admin-body .ins-card,
html[data-admin-theme="dark"] body.admin-body .ins-filter,
html[data-admin-theme="dark"] body.admin-body .ins-ai-panel,
html[data-admin-theme="dark"] body.admin-body .section,
html[data-admin-theme="dark"] body.admin-body .device-card,
html[data-admin-theme="dark"] body.admin-body .debug-nav {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.88) 0%, rgba(15, 23, 42, 0.72) 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* KPI：与 dash-kpi-card 一致 */
html[data-admin-theme="dark"] body.admin-body .rep-kpi-card,
html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card,
html[data-admin-theme="dark"] body.admin-body .ins-kpi {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.92) 0%, rgba(15, 23, 42, 0.72) 100%);
  border: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.5), 0 8px 32px rgba(0, 0, 0, 0.35);
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card__label,
html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card__label,
html[data-admin-theme="dark"] body.admin-body .ins-kpi__label {
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card__value,
html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card__value,
html[data-admin-theme="dark"] body.admin-body .ins-kpi__value {
  color: #f1f5f9;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card__suffix,
html[data-admin-theme="dark"] body.admin-body .rep-kpi-card__hint,
html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card__hint {
  color: #64748b;
}

html[data-admin-theme="dark"] body.admin-body .ins-kpi__value--text {
  color: #cbd5e1;
  text-shadow: none;
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card--focus .rep-kpi-card__value {
  color: #38bdf8;
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card--warn {
  border-color: rgba(251, 191, 36, 0.45);
  background: linear-gradient(145deg, rgba(120, 53, 15, 0.4) 0%, rgba(15, 23, 42, 0.9) 100%);
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card--low {
  border-color: rgba(248, 113, 113, 0.45);
  background: linear-gradient(145deg, rgba(127, 29, 29, 0.38) 0%, rgba(15, 23, 42, 0.9) 100%);
}

html[data-admin-theme="dark"] body.admin-body .rep-kpi-card--anomaly {
  border-color: rgba(167, 139, 250, 0.45);
  background: linear-gradient(145deg, rgba(76, 29, 149, 0.38) 0%, rgba(15, 23, 42, 0.9) 100%);
}

html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card--pending {
  border-color: rgba(248, 113, 113, 0.5);
  background: linear-gradient(145deg, rgba(127, 29, 29, 0.35) 0%, rgba(15, 23, 42, 0.9) 100%);
}

html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card--resolved {
  border-color: rgba(52, 211, 153, 0.4);
  background: linear-gradient(145deg, rgba(6, 78, 59, 0.4) 0%, rgba(15, 23, 42, 0.9) 100%);
}

html[data-admin-theme="dark"] body.admin-body .alerts-kpi-card--priority {
  border-color: rgba(56, 189, 248, 0.45);
  background: linear-gradient(145deg, rgba(30, 58, 138, 0.45) 0%, rgba(15, 23, 42, 0.88) 100%);
}

html[data-admin-theme="dark"] body.admin-body .admin-code {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

html[data-admin-theme="dark"] body.admin-body .admin-input {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(51, 65, 85, 0.9);
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body select.admin-input,
html[data-admin-theme="dark"] body.admin-body select.ins-input {
  color-scheme: dark;
  background-color: #0f172a;
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body select.admin-input option,
html[data-admin-theme="dark"] body.admin-body select.admin-input optgroup,
html[data-admin-theme="dark"] body.admin-body select.ins-input option,
html[data-admin-theme="dark"] body.admin-body select.ins-input optgroup {
  background: #0f172a;
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .admin-input:disabled {
  background: rgba(30, 41, 59, 0.65);
  color: #64748b;
}

html[data-admin-theme="dark"] body.admin-body .admin-input:focus {
  outline: 2px solid rgba(56, 189, 248, 0.35);
  outline-offset: 1px;
}

html[data-admin-theme="dark"] body.admin-body .admin-card__title {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .admin-card__lead {
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .alerts-state--warning {
  background: rgba(120, 53, 15, 0.35);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fcd34d;
}

html[data-admin-theme="dark"] body.admin-body .alerts-state--error {
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

html[data-admin-theme="dark"] body.admin-body .emp-global-err {
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

html[data-admin-theme="dark"] body.admin-body .alerts-select,
html[data-admin-theme="dark"] body.admin-body .alerts-input {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(51, 65, 85, 0.9);
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .alerts-input:focus,
html[data-admin-theme="dark"] body.admin-body .alerts-select:focus {
  outline: 2px solid rgba(56, 189, 248, 0.35);
  outline-offset: 1px;
}

html[data-admin-theme="dark"] body.admin-body .alerts-table thead th {
  background: rgba(30, 41, 59, 0.95);
  color: #94a3b8;
  border-bottom-color: rgba(56, 189, 248, 0.15);
}

html[data-admin-theme="dark"] body.admin-body .alerts-table tbody tr:hover td {
  background: rgba(56, 189, 248, 0.06);
}

html[data-admin-theme="dark"] body.admin-body .alerts-list-title {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__backdrop {
  background: rgba(7, 11, 20, 0.72);
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__card {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(15, 23, 42, 0.78) 100%);
  border: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__head {
  border-bottom-color: rgba(56, 189, 248, 0.15);
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__head h3 {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__body {
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__close {
  background: rgba(30, 41, 59, 0.9);
  color: #cbd5e1;
  border: 1px solid rgba(51, 65, 85, 0.8);
}

html[data-admin-theme="dark"] body.admin-body .alerts-modal__close:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(56, 189, 248, 0.35);
}

html[data-admin-theme="dark"] body.admin-body .alerts-live-banner {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

html[data-admin-theme="dark"] body.admin-body .rep-metric {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(56, 189, 248, 0.12);
}

html[data-admin-theme="dark"] body.admin-body .rep-badge {
  background: rgba(30, 41, 59, 0.85);
  color: #cbd5e1;
}

html[data-admin-theme="dark"] body.admin-body .rep-aside-btn:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(56, 189, 248, 0.25);
  color: #f1f5f9;
}

html[data-admin-theme="dark"] body.admin-body .rep-empty {
  background: rgba(30, 41, 59, 0.45);
  border-color: rgba(56, 189, 248, 0.2);
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .ins-input {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(51, 65, 85, 0.9);
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .ins-tabs__nav {
  border-bottom-color: rgba(56, 189, 248, 0.15);
}

html[data-admin-theme="dark"] body.admin-body .ins-tabs__btn:hover {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .ins-tabs__btn.is-active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
}

html[data-admin-theme="dark"] body.admin-body .ins-card__title {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .ins-table th {
  color: #94a3b8;
  border-bottom-color: rgba(56, 189, 248, 0.2);
}

html[data-admin-theme="dark"] body.admin-body .ins-table td {
  border-bottom-color: rgba(51, 65, 85, 0.55);
  color: #cbd5e1;
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-panel {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(139, 92, 246, 0.12);
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-card {
  background: rgba(49, 46, 129, 0.35);
  border-color: rgba(165, 180, 252, 0.35);
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-card__title {
  color: #c4b5fd;
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-card__body {
  color: #cbd5e1;
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-summary {
  background: rgba(49, 46, 129, 0.28);
  border-color: rgba(167, 139, 250, 0.35);
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-summary__text {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-state--error {
  background: rgba(127, 29, 29, 0.35);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-state--empty {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(56, 189, 248, 0.12);
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .ins-ai-badge {
  background: rgba(91, 33, 182, 0.45);
  color: #e9d5ff;
}

html[data-admin-theme="dark"] body.admin-body .ins-debug-panel {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(56, 189, 248, 0.18);
}

html[data-admin-theme="dark"] body.admin-body .emp-metric {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(56, 189, 248, 0.12);
}

html[data-admin-theme="dark"] body.admin-body .emp-app-track {
  background: rgba(30, 41, 59, 0.9);
}

html[data-admin-theme="dark"] body.admin-body .emp-alert-item {
  background: rgba(30, 41, 59, 0.65);
  border-color: rgba(56, 189, 248, 0.12);
}

html[data-admin-theme="dark"] body.admin-body .emp-sev--critical {
  background: rgba(127, 29, 29, 0.55);
  color: #fecaca;
}

html[data-admin-theme="dark"] body.admin-body .emp-sev--high {
  background: rgba(154, 52, 18, 0.45);
  color: #ffedd5;
}

html[data-admin-theme="dark"] body.admin-body .emp-sev--medium {
  background: rgba(113, 63, 18, 0.45);
  color: #fef9c3;
}

html[data-admin-theme="dark"] body.admin-body .emp-sev--low {
  background: rgba(49, 46, 129, 0.45);
  color: #e0e7ff;
}

html[data-admin-theme="dark"] body.admin-body table.data th {
  background: rgba(30, 41, 59, 0.95);
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body table.data tr:nth-child(even) td {
  background: rgba(15, 23, 42, 0.35);
}

html[data-admin-theme="dark"] body.admin-body .ai-btn {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.9));
  color: #e2e8f0;
  border-color: rgba(56, 189, 248, 0.2);
}

html[data-admin-theme="dark"] body.admin-body .ai-btn:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(56, 189, 248, 0.3);
}

html[data-admin-theme="dark"] body.admin-body .ai-result-card {
  background: rgba(30, 41, 59, 0.55);
  border-color: rgba(56, 189, 248, 0.15);
  color: #cbd5e1;
}

html[data-admin-theme="dark"] body.admin-body .section > h2 {
  color: #e2e8f0;
}

html[data-admin-theme="dark"] body.admin-body .tag {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(56, 189, 248, 0.15);
  color: #94a3b8;
}

html[data-admin-theme="dark"] body.admin-body .badge--info {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

/* ========== 全局请求 Loading（fetch 包装，见 base.js） ========== */
.hd-global-loading {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.hd-global-loading[hidden] {
  display: none !important;
}

.hd-global-loading:not([hidden]) {
  pointer-events: auto;
}

.hd-global-loading__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}

html[data-admin-theme="dark"] .hd-global-loading__backdrop {
  background: rgba(7, 11, 20, 0.55);
}

.hd-global-loading__panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 1.35rem 1.75rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.hd-global-loading__spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: hd-global-spin 0.7s linear infinite;
}

@keyframes hd-global-spin {
  to {
    transform: rotate(360deg);
  }
}

body.hd-global-loading--active {
  cursor: wait;
}

/* 无权限提示（fetch 403 时顶部 Toast） */
.hd-forbidden-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 450;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid rgba(220, 38, 38, 0.35);
  box-shadow: var(--shadow-card);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hd-forbidden-toast[hidden] {
  display: none !important;
}

.hd-forbidden-toast__text {
  flex: 1;
  min-width: 0;
}

.hd-forbidden-toast__close {
  flex-shrink: 0;
  margin: -0.2rem -0.25rem 0 0;
  padding: 0.15rem 0.45rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}

.hd-forbidden-toast__close:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.access-denied-card {
  max-width: 440px;
  margin: 2rem auto;
  padding: 1.75rem 1.5rem;
  text-align: center;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.access-denied-card__icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 3rem;
}

.access-denied-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  color: var(--text);
}

.access-denied-card__msg {
  margin: 0 0 1.35rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.access-denied-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}
