:root {
  --bg: #eef3fa;
  --surface: #ffffff;
  --ink: #0f1e3d;
  --muted: #6b7b95;
  --line: #dde6f3;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8f0ff;
  --cyan: #38bdf8;
  --navy: #0b1730;
  --danger: #e5484d;
  --warn: #f59e0b;
  --shadow: 0 10px 30px rgba(15, 30, 61, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- 登录 */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #081226;
  overflow: hidden;
  z-index: 80;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(37, 99, 235, 0.42), transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(56, 189, 248, 0.24), transparent 46%),
    linear-gradient(150deg, #081226 0%, #0c1c3a 55%, #0a1529 100%);
}

.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

.login-card {
  position: relative;
  width: 400px;
  max-width: calc(100vw - 40px);
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  padding: 38px 34px 26px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.45);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

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

.brand-mark, .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
  flex: none;
}

.brand h1 { font-size: 20px; margin: 0; letter-spacing: 0.5px; }
.brand p { margin: 3px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }

.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafd;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.form-error {
  min-height: 20px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--danger);
}

.login-note {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
  color: #8b98ad;
}

/* ---------------------------------------------------------------- 按钮 */
.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, 0.26); }
.btn.primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn.ghost { background: #fff; border-color: var(--line); color: #3c4b66; }
.btn.ghost:hover { border-color: #b9cbe8; color: var(--primary); background: #f7faff; }
.btn.danger { background: #fff; border-color: #f3cfd1; color: var(--danger); }
.btn.danger:hover { background: #fff5f5; border-color: var(--danger); }
.btn.block { width: 100%; height: 46px; font-size: 14px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------- 顶栏 */
.app { min-height: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 72px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.logo { display: flex; align-items: center; gap: 12px; }
.logo .logo-mark { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
.logo b { display: block; font-size: 16px; letter-spacing: 0.4px; }
.logo span { display: block; font-size: 10px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.stats { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
.stat { padding: 0 14px; text-align: center; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10px; color: var(--muted); }

.search {
  width: 230px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafe;
  font-size: 13px;
  outline: none;
  transition: all 0.18s;
}
.search:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* ---------------------------------------------------------------- 内容区 */
.content { padding: 24px 28px 48px; max-width: 1800px; margin: 0 auto; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}
.section-head h2 { margin: 0; font-size: 20px; letter-spacing: 0.3px; }
.section-head p { margin: 5px 0 0; font-size: 12px; color: var(--muted); }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.legend b { color: var(--ink); }
.legend-sep { width: 1px; height: 12px; background: var(--line); margin: 0 6px; }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--offline);
  flex: none;
}
.dot.online { background: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14); }
.dot.offline { background: #a9b6c9; }

/* ---------------------------------------------------------------- 设备卡片 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(15, 30, 61, 0.04);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: cardIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.grid.no-anim .card { animation: none; }
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(15, 30, 61, 0.12);
  border-color: #c8d9f2;
}

.card-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.thumb-placeholder {
  color: #506a97;
  font-size: 12px;
  letter-spacing: 0.08em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.thumb-placeholder::before {
  content: "";
  width: 34px;
  height: 24px;
  border: 2px solid #38527f;
  border-radius: 4px;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 20px;
  background: rgba(8, 18, 38, 0.72);
  backdrop-filter: blur(4px);
  color: #cfe0ff;
  font-size: 11px;
  font-weight: 600;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}
.badge.offline { color: #9fb0c8; }
.badge.offline::before { background: #7c8da8; box-shadow: none; }

.rec-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 20px;
  background: rgba(37, 99, 235, 0.88);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rec-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
}

.time-pill {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(8, 18, 38, 0.68);
  color: #cfe0ff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.card-body { padding: 13px 15px 14px; }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.card-title h3 {
  margin: 0;
  min-width: 0;
  flex: 0 1 auto;
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.name-btn {
  margin-left: auto;
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.75;
}
.name-btn:hover { color: var(--primary); background: var(--primary-soft); opacity: 1; }
.del-btn { margin-left: 0; }
.del-btn:hover { color: #c93333; background: #fdecec; opacity: 1; }
.blocked-panel {
  margin-top: 18px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.blocked-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.blocked-head h2 { margin: 0; font-size: 13.5px; }
.blocked-head span { color: var(--muted); font-size: 11px; }
.blocked-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
}
.blocked-row .blocked-host { font-weight: 600; }
.blocked-row .blocked-time { color: var(--muted); font-size: 11.5px; }
.blocked-row .btn { margin-left: auto; }
.note-chip {
  flex: none;
  max-width: 110px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.card-foot b { color: var(--ink); font-variant-numeric: tabular-nums; }

.empty {
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-icon {
  width: 64px;
  height: 46px;
  margin: 0 auto 18px;
  border: 2px solid #c3d3ea;
  border-radius: 6px;
  position: relative;
}
.empty-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  width: 24px;
  height: 6px;
  border-radius: 3px;
  background: #c3d3ea;
}
.empty h3 { margin: 0 0 8px; color: var(--ink); font-size: 16px; }
.empty p { margin: 0; font-size: 13px; }

/* ---------------------------------------------------------------- 详情 */
.detail {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: detailIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes detailIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 68px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.detail-title { min-width: 0; flex: 1; }
.detail-title h2 {
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}
.detail-actions { display: flex; align-items: center; gap: 10px; }

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #3c4b66;
  cursor: pointer;
  user-select: none;
}
.switch input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

.note-editor { display: flex; align-items: center; gap: 6px; }
.note-editor input {
  width: 160px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  outline: none;
}
.note-editor input:focus { border-color: var(--primary); }

.detail-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.viewer {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 18px 22px;
}

.viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--navy);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35);
}
.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
.viewer-stage:fullscreen img,
.viewer-stage.fs-fallback img { cursor: zoom-in; }
.viewer-stage:fullscreen img.zoomed,
.viewer-stage.fs-fallback img.zoomed { cursor: grab; }
.viewer-stage.dragging img { cursor: grabbing; }

.viewer-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #7f93b5;
  text-align: center;
}
.viewer-empty h3 { margin: 0 0 6px; font-size: 15px; color: #a9bcd8; }
.viewer-empty p { margin: 0; font-size: 12px; }

.viewer-time {
  position: absolute;
  left: 14px;
  top: 14px;
  padding: 5px 11px;
  border-radius: 8px;
  background: rgba(8, 18, 38, 0.72);
  backdrop-filter: blur(6px);
  color: #dbe9ff;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.viewer-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
}
.live-state {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}
.live-state #d-window {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a9b6c9;
  flex: none;
}
.live-dot.live {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  animation: livePulse 1.6s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.viewer-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.live-meta {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 录像回放 */
.viewer-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 10px;
  flex: none;
}
.vtab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.vtab:hover { background: var(--primary-soft); color: var(--ink); }
.vtab.active {
  background: var(--primary);
  color: #fff;
}
.vtab-note {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
}

.record-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding-top: 12px;
}
.record-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex: none;
}
.record-date { display: flex; align-items: center; gap: 6px; }
.record-date input[type="date"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafd;
  font-size: 13px;
  outline: none;
  color: var(--ink);
}
.record-date input[type="date"]:focus { border-color: var(--primary); }
.record-summary { font-size: 12px; color: var(--muted); }

.record-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.record-stage video {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.record-stage .viewer-empty { color: #7f93b5; }
.record-stage .viewer-empty h3 { color: #a9bcd8; }
.record-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7f93b5;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 5;
}
.record-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  margin-right: 10px;
  animation: recSpin 0.9s linear infinite;
}
@keyframes recSpin { to { transform: rotate(360deg); } }

.record-timeline-wrap {
  flex: none;
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 10px;
}
.record-timeline {
  position: relative;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg,
      rgba(15, 30, 61, 0.05) 0 1px, transparent 1px 10%);
  cursor: crosshair;
}
.rec-seg {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  opacity: 0.85;
  border: 1px solid rgba(29, 78, 216, 0.4);
}
.rec-seg:hover, .rec-seg.active { opacity: 1; }
.rec-seg.active {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary);
}
.record-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.record-footer {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.rec-now { color: var(--ink); font-weight: 600; }

.viewer.rec-mode .viewer-stage,
.viewer.rec-mode .viewer-bar { display: none; }

/* ---------------------------------------------------------------- 全屏 */
.viewer-hint, .viewer-fsbar { display: none; }.viewer-stage::backdrop { background: #000; }
.viewer-stage:fullscreen,
.viewer-stage.fs-fallback {
  border-radius: 0;
  background: #000;
}
.viewer-stage.fs-fallback {
  position: fixed;
  inset: 0;
  z-index: 95;
}
.viewer-stage:fullscreen .viewer-hint,
.viewer-stage.fs-fallback .viewer-hint {
  display: block;
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 3;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #cfe0ff;
  font-size: 11.5px;
  white-space: nowrap;
  pointer-events: none;
}
.viewer-stage:fullscreen .viewer-fsbar,
.viewer-stage.fs-fallback .viewer-fsbar {
  display: flex;
  gap: 8px;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
}
.viewer-stage:fullscreen .viewer-fsbar .btn,
.viewer-stage.fs-fallback .viewer-fsbar .btn {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  color: #e8f1ff;
}
.viewer-stage:fullscreen .viewer-fsbar .btn:hover,
.viewer-stage.fs-fallback .viewer-fsbar .btn:hover {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
}
.viewer-stage:fullscreen .viewer-time,
.viewer-stage.fs-fallback .viewer-time { top: 16px; left: 16px; }

/* ---------------------------------------------------------------- 设备列表 */
.device-panel {
  width: 300px;
  flex: none;
  background: #fff;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.device-panel-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.device-panel-head h3 { margin: 0; font-size: 14px; }
.device-panel-head span { font-size: 11.5px; color: var(--muted); }

.device-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.device-item:hover { border-color: #b9cbe8; background: #f5f9ff; }
.device-item.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.device-item .dot { flex: none; }
.device-item-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.device-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-item-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-item-tag {
  flex: none;
  padding: 2px 7px;
  border: 1px solid #c9dcff;
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-size: 10px;
}
.device-list::-webkit-scrollbar { width: 8px; }
.device-list::-webkit-scrollbar-thumb { background: #cdd9ea; border-radius: 4px; }
.device-list::-webkit-scrollbar-track { background: transparent; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  z-index: 100;
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(8, 18, 38, 0.92);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  animation: rise 0.2s ease;
}

/* ---------------------------------------------------------------- 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(8, 18, 38, 0.55);
  backdrop-filter: blur(3px);
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative;
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 24px 26px 20px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 30px 70px rgba(8, 18, 38, 0.35);
  animation: rise 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; letter-spacing: 0.3px; }
.modal-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: #f2f6fd; color: var(--ink); }
.modal-sub {
  margin: 6px 0 20px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.modal-card .field { margin-bottom: 14px; }
.modal-card .field input { height: 42px; }
.modal-card .form-error { min-height: 18px; margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* ---------------------------------------------------------------- 响应式 */
@media (max-width: 1100px) {
  .stats { display: none; }
  .search { width: 180px; }
}

@media (max-width: 860px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .content { padding: 18px 16px 40px; }
  .search { width: 140px; }
  .detail-body { flex-direction: column; }
  .viewer { padding: 12px; }
  .viewer-stage { min-height: 240px; }
  .device-panel { width: auto; height: 40%; border-left: 0; border-top: 1px solid var(--line); }
  .device-list { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
  .device-item { width: 220px; flex: none; }
  .detail-head { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 10px; }
  .detail-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
}
