/* 强制 hidden 属性生效，防止 author display: flex/block 覆盖 UA [hidden] 规则 */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: light;
  --device-preview-width: 138px;
  --bg: #f4f7fc;
  --bg-2: #ebf0fb;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --panel-muted: #f2f5fb;
  --border: rgba(66, 83, 120, 0.14);
  --border-strong: rgba(66, 83, 120, 0.22);
  --text: #172033;
  --muted: #6a7388;
  --accent: #125ae4; /* 统一品牌主色调 */
  --accent-2: #0c43b3;
  --success: #0c8a5a;
  --warning: #a16800;
  --danger: #cc3f5d;
  --shadow: 0 24px 54px rgba(42, 67, 115, 0.12);
  --phone-frame: #121720;
  --phone-shell: #1d2431;
  --phone-screen: #f5f7fc;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09111f;
  --bg-2: #0f1a2d;
  --panel: rgba(16, 24, 39, 0.9);
  --panel-strong: #111827;
  --panel-muted: #0f1726;
  --border: rgba(118, 142, 191, 0.18);
  --border-strong: rgba(118, 142, 191, 0.32);
  --text: #eef4ff;
  --muted: #97a5bc;
  --accent: #2e6ff2; /* 统一品牌主色调 暗色模式 */
  --accent-2: #4e86f5;
  --success: #6cf0b8;
  --warning: #ffd36e;
  --danger: #ff839c;
  --shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  --phone-frame: #080b11;
  --phone-shell: #161b24;
  --phone-screen: #dce4f3;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(18, 90, 228, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(53, 177, 141, 0.12), transparent 26%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
}

.toast.error {
  border-color: rgba(204, 63, 93, 0.22);
  color: var(--danger);
}

.toast.success {
  border-color: rgba(12, 138, 90, 0.22);
  color: var(--success);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
}

.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-sidebar="collapsed"] .dashboard-shell {
  grid-template-columns: 0px minmax(0, 1fr);
}

.sidenav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 0;
  border-right: 1px solid var(--border);
  background: rgba(245, 247, 252, 0.82);
  backdrop-filter: blur(18px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

body[data-sidebar="collapsed"] .sidenav {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

body[data-theme="dark"] .sidenav {
  background: rgba(8, 14, 25, 0.82);
}

body[data-theme="dark"] .brand-logo img {
  filter: brightness(0) invert(1);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 65px; /* Exactly match topbar height (64px + 1px border) */
  padding: 0 24px;
  border-bottom: 1px solid transparent;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-logo img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.brand-block h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-title h2,
.content-card-title h2,
.side-card-title h2,
.device-name {
  margin: 0;
}

.brand-text,
.panel-note,
.topbar-title p,
.device-error {
  margin: 8px 0 0;
  color: var(--muted);
}

.side-card,
.content-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.side-card {
  padding: 18px 24px;
  margin: 16px 24px 0;
}


.side-card-title,
.content-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.content-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 24px;
  height: 65px; /* Align with brand block */
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(20px);
}

body[data-theme="dark"] .topbar {
  background: rgba(6, 12, 22, 0.7);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(83, 105, 231, 0.08);
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.icon-btn {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  width: clamp(220px, 28vw, 320px);
  padding: 0 14px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
}

.search-box input {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  outline: none;
}

.workspace {
  padding: 16px 24px;
  display: grid;
  gap: 24px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(18, 90, 228, 0.12);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

.subtle-badge {
  background: var(--panel-muted);
  color: var(--muted);
}

.content-card {
  padding: 20px;
}

.content-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.header-titles {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-select {
  height: 38px;
  padding: 0 36px 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.header-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 90, 228, 0.12);
}

.device-drawer-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.device-drawer-summary::-webkit-details-marker {
  display: none;
}

.device-drawer-summary::after {
  content: "展开";
  font-size: 12px;
  color: var(--muted);
}

.device-drawer[open] .device-drawer-summary::after {
  content: "收起";
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 280px));
  gap: 14px;
  justify-content: start;
  align-items: start;
}

.device-tile {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 9px;
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.04);
  min-width: 0;
  height: 100%;
}

.device-tile.is-selected {
  border-color: rgba(83, 105, 231, 0.36);
  box-shadow: 0 12px 36px rgba(83, 105, 231, 0.12);
}

.device-tile-head,
.device-title-group {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.device-title-group {
  justify-content: flex-start;
  min-width: 0;
  flex: 1;
  align-items: center;
}

.device-title-group > div:last-child {
  min-width: 0;
}

.device-tile-head {
  min-height: 58px;
}

.device-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: var(--device-preview-width);
  max-width: var(--device-preview-width);
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(18, 90, 228, 0.05), rgba(18, 90, 228, 0.015));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
  position: relative;
  cursor: pointer;
  text-align: center;
}

.device-name {
  width: 100%;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 0;
  text-align: center;
}

.device-name-input-inline {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  outline: none;
  padding: 0;
}

.rename-btn.is-editing .rename-icon {
  opacity: 1;
}

.rename-icon {
  position: absolute;
  right: 10px;
  font-size: 14px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.rename-btn {
  appearance: none;
}

.rename-btn:hover .rename-icon,
.rename-btn:focus-visible .rename-icon {
  opacity: 1;
}

.device-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  color: var(--accent);
  background: rgba(83, 105, 231, 0.1);
}

.device-status-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 6px;
  justify-content: flex-end;
}

.device-status-text {
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.device-status-text.status-running { color: var(--success); }
.device-status-text.status-stopped,
.device-status-text.status-missing { color: var(--muted); }
.device-status-text.status-provisioning { color: var(--warning); }
.device-status-text.status-error { color: var(--danger); }

.device-status-indicator {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  outline: none;
}

.device-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(18, 90, 228, 0.4);
  box-shadow: 0 0 0 6px rgba(18, 90, 228, 0.08);
}

.tooltip-content {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  max-width: 240px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-strong);
  border: 1px solid rgba(204, 63, 93, 0.2);
  box-shadow: var(--shadow);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.2s ease;
}

.device-status-indicator:hover .tooltip-content,
.device-status-indicator:focus-visible .tooltip-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.device-status-dot.status-running {
  background: var(--success);
  box-shadow: 0 0 0 6px rgba(12, 138, 90, 0.12);
}

.device-status-dot.status-stopped,
.device-status-dot.status-missing,
.device-status-dot.status-provisioning {
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(255, 209, 91, 0.16);
}

.device-status-dot.status-error {
  background: var(--danger);
  box-shadow: 0 0 0 6px rgba(204, 63, 93, 0.12);
}

.phone-preview {
  padding: 0;
  background: transparent;
  border: 0;
  text-align: left;
  justify-self: center;
  width: min(100%, var(--device-preview-width));
  cursor: pointer;
}

.phone-preview:hover .phone-frame {
  transform: translateY(-1px);
}

.phone-frame {
  padding: 6px;
  border-radius: 22px;
  background: linear-gradient(180deg, var(--phone-shell), var(--phone-frame));
  transition: transform 0.15s ease;
}

.phone-notch {
  width: 34%;
  height: 8px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.phone-screen {
  aspect-ratio: 9 / 18.5;
  overflow: hidden;
  position: relative;
  border-radius: 16px;
  background: var(--phone-screen);
}

.device-preview-image,
#control-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.device-preview-image {
  display: block;
  object-fit: cover;
  object-position: top center;
}

.phone-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  color: var(--muted);
  background: var(--panel-muted);
  text-align: center;
}

.placeholder-icon {
  font-size: 24px;
  opacity: 0.5;
}

.placeholder-text {
  font-size: 11px;
}

.device-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.device-metrics div {
  padding: 8px;
  border-radius: 12px;
  background: var(--panel-muted);
  border: 1px solid var(--border);
  min-height: 74px;
}

.device-metrics dt {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.device-metrics dd {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  word-break: break-all;
  line-height: 1.35;
}

.device-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 6px;
  align-items: center;
}

.apk-upload-btn > span.action-btn {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: normal;
}

.apk-upload-btn > span.action-btn:hover {
  background: var(--panel-strong);
  border-color: var(--border-strong);
}

.delete-btn {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
  padding: 0;
  width: 36px;
}

.delete-btn:hover {
  background: rgba(204, 63, 93, 0.08);
}

.action-btn {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0;
  border-radius: 12px;
  font-size: 12px;
}

.device-drawer {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-muted);
  padding: 8px 10px;
  min-height: 34px;
}

.device-drawer-summary {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.device-drawer[open] .device-metrics {
  margin-top: 10px;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.stack-form label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.stack-form input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.apk-upload-btn > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.ghost-btn {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}

.danger-btn {
  color: var(--danger);
  background: rgba(204, 63, 93, 0.08);
  border-color: rgba(204, 63, 93, 0.18);
}

.compact-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
}

.full-width-btn {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.form-helper {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.apk-upload-btn > span:hover {
  transform: translateY(-1px);
}

.apk-upload-btn {
  position: relative;
  overflow: hidden;
  display: flex;
}

.apk-upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

.apk-upload-btn > span {
  background: rgba(83, 105, 231, 0.08);
  border-color: rgba(83, 105, 231, 0.14);
  color: var(--accent);
  width: 100%;
  height: 36px;
}

.status-grid {
  display: grid;
  gap: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--panel-muted);
  border: 1px solid var(--border);
}

.status-item strong {
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok {
  color: var(--success);
  background: rgba(12, 138, 90, 0.1);
}

.status-pill.warn {
  color: var(--warning);
  background: rgba(255, 209, 91, 0.14);
}



/* ── Sidebar Toggle ─────────────────────────────── */
.sidebar-toggle-btn-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-toggle-btn-inline:hover {
  background: var(--panel-muted);
  color: var(--text);
}

body[data-sidebar="collapsed"] .sidebar-toggle-btn-inline {
  display: none;
}

.sidebar-expand-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
}

.sidebar-expand-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

body[data-sidebar="collapsed"] .sidebar-expand-btn {
  display: inline-flex;
}

/* ── Sidenav User Block ──────────────────────────── */
.sidenav-spacer {
  flex: 1;
}

/* ── Mobile City Bar（顶部横向城市筛选，仅手机端显示）── */
.mobile-city-bar {
  display: none;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 8px;
  padding: 0 4px 8px;
  flex-shrink: 0;
}

.mobile-city-bar::-webkit-scrollbar {
  display: none;
}

.mobile-city-bar .city-btn {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  width: auto;
  background: var(--panel-strong);
}

.mobile-city-bar .city-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mobile-city-bar .city-count {
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.7;
}
.city-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.city-btn {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
}

.city-btn:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.city-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.city-btn .city-count {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.75;
  background: rgba(255,255,255,0.2);
  padding: 1px 6px;
  border-radius: 20px;
}

.sidenav-user-block {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidenav-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.sidenav-user-icon {
  font-size: 22px;
  color: var(--muted);
  flex-shrink: 0;
}

.sidenav-username {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidenav-user-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidenav-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  width: 100%;
  text-align: left;
}

.sidenav-action-btn:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.sidenav-action-btn .material-symbols-outlined {
  font-size: 18px;
  flex-shrink: 0;
}
}

/* ── System Monitor Panel ──────────────────────── */
.monitor-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.monitor-placeholder {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}

.monitor-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.monitor-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.monitor-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.monitor-label .material-symbols-outlined {
  font-size: 16px;
}

.monitor-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.monitor-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.monitor-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
  min-width: 2px;
}

.monitor-bar-fill.level-ok {
  background: var(--success);
}

.monitor-bar-fill.level-warn {
  background: var(--warning);
}

.monitor-bar-fill.level-danger {
  background: var(--danger);
}

.monitor-text-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.monitor-text-row:first-child {
  border-top: none;
}

.monitor-text-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.monitor-text-label .material-symbols-outlined {
  font-size: 16px;
}

.monitor-text-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.monitor-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
  margin-top: 4px;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(12, 138, 90, 0.4); }
  50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(12, 138, 90, 0); }
}

.monitor-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

/* Health Popover */
.health-dropdown-wrap {
  position: relative;
}

.health-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  padding: 16px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  transform-origin: top right;
  animation: pop-in 0.15s ease-out;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.popover-header h3 {
  margin: 0;
  font-size: 15px;
}

/* Device Modal — 勿对未打开的 dialog 设 display:flex，会覆盖 UA 的 display:none，移动端关闭后整页下方可能仍铺一层黑底 */
.device-modal {
  /* 桌面：框略缩小，随屏适配；云机竖屏 540×975（键盘区不易叠字）+ ~48px scrcpy 侧栏 */
  --dm-max-h: min(86vh, 840px);
  width: min(88vw, calc((var(--dm-max-h) - 44px) * (540 / 975) + 48px));
  max-height: var(--dm-max-h);
  padding: 0;
  border: none;
  border-radius: 16px;
  margin: auto;
  background: #000;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.device-modal[open] {
  display: flex;
  flex-direction: column;
}

.device-modal:not([open]) {
  display: none !important;
}

.device-modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.confirm-modal {
  width: min(92vw, 440px);
  padding: 0;
  border: 0;
  border-radius: 28px;
  background: transparent;
}

.confirm-modal::backdrop {
  background: rgba(7, 12, 24, 0.36);
  backdrop-filter: blur(8px);
}

.confirm-card {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 26px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  box-shadow: 0 28px 64px rgba(15, 23, 42, 0.18);
}

.confirm-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.confirm-message {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}

.confirm-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.confirm-checkbox input {
  width: 16px;
  height: 16px;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  height: 44px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-strong);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.modal-title-group h2 {
  margin: 0;
  font-size: 14px;
}

.modal-body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  height: calc(var(--dm-max-h, min(86vh, 840px)) - 44px);
  max-height: calc(var(--dm-max-h, min(86vh, 840px)) - 44px);
  background: #000;
  border-radius: 0;
  overflow: hidden;
}

.control-frame-shell {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--phone-frame);
  border-radius: 0 0 24px 24px;
  position: relative;
}

.modal-thumb-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 0 0 24px 24px;
  transition: opacity 0.4s ease;
}

.modal-thumb-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
}

.modal-thumb-spinner {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.7);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#control-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.close-btn {
  width: 34px;
  height: 34px;
}

.disabled-link {
  opacity: 0.5;
  pointer-events: none;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 36px 24px;
  border-radius: 20px;
  border: 1px dashed var(--border-strong);
  background: var(--panel-muted);
  text-align: center;
  color: var(--muted);
}

.empty-state[hidden] {
  display: none;
}

.empty-logo {
  width: 56px;
  height: auto;
  opacity: 0.18;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(18, 90, 228, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(53, 177, 141, 0.12), transparent 30%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-card {
  width: min(100%, 420px);
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card-large {
  width: min(100%, 920px);
  padding: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 420px);
  gap: 28px;
  align-items: stretch;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.login-brand-large {
  margin-bottom: 20px;
  align-items: center;
  gap: 20px;
}

.login-brand img {
  width: 64px;
  height: auto;
  object-fit: contain;
}

.login-brand-large img {
  width: 108px;
}

.login-brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.login-brand-large h1 {
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.login-brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-brand-large p {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 500;
}

.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 12px 8px 12px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form-large {
  align-self: center;
  gap: 16px;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(16px);
}

body[data-theme="dark"] .login-form-large {
  background: rgba(17, 24, 39, 0.58);
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-form-large input {
  height: 58px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
  font-size: 16px;
}

.login-form-large input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(18, 90, 228, 0.12);
}

.login-submit-btn {
  min-height: 52px;
  font-size: 15px;
  font-weight: 700;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 1220px) {
  .dashboard-shell {
    grid-template-columns: 304px minmax(0, 1fr);
  }

  body[data-sidebar="collapsed"] .dashboard-shell {
    grid-template-columns: 0px minmax(0, 1fr);
  }

  .topbar {
    padding: 12px 16px;
    height: auto;
    min-height: 52px;
  }

  .workspace {
    padding: 16px;
  }

  .login-card-large {
    grid-template-columns: 1fr;
    width: min(100%, 480px);
  }

  .login-hero {
    display: none;
  }
}

@media (max-width: 860px) {
  .dashboard-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  body[data-sidebar="collapsed"] .dashboard-shell {
    grid-template-columns: 0px minmax(0, 1fr);
  }

  .topbar {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 14px;
  }

  .topbar-title h2 {
    font-size: 17px;
  }

  .topbar-actions {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .search-box {
    min-width: 0;
    flex: 1;
  }

  .header-actions {
    width: 100%;
  }

  .header-select {
    width: 100%;
  }

  .device-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .device-metrics {
    grid-template-columns: 1fr;
  }

  .side-card {
    margin: 10px 14px;
    padding: 12px 14px;
  }
}

/* ── 手机端（<=600px）完整适配 ──────────────────── */
@media (max-width: 600px) {
  /* 单列布局 */
  .dashboard-shell {
    grid-template-columns: 1fr !important;
  }

  body[data-sidebar="collapsed"] .dashboard-shell {
    grid-template-columns: 1fr !important;
  }

  /* 侧边栏变抽屉 */
  .sidenav {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    height: 100vh !important;
    width: 280px !important;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 32px rgba(0,0,0,0.22);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body[data-sidebar="open"] .sidenav {
    transform: translateX(0) !important;
  }

  body[data-sidebar="collapsed"] .sidenav {
    transform: translateX(-100%) !important;
  }

  /* 遮罩 */
  body[data-sidebar="open"]::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 299;
    background: rgba(0,0,0,0.45);
  }

  .sidebar-expand-btn {
    display: inline-flex !important;
  }

  .sidebar-toggle-btn-inline {
    display: none !important;
  }

  /* topbar */
  .topbar {
    gap: 8px;
    padding: 10px 12px;
    flex-wrap: nowrap;
  }

  .topbar-title {
    gap: 8px;
    flex: 1;
    min-width: 0;
  }

  .topbar-title h2 {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-icon {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    flex-shrink: 0;
  }

  .topbar-actions {
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: nowrap;
  }

  .topbar-actions .ghost-btn span:not(.material-symbols-outlined) {
    display: none;
  }

  .ghost-btn {
    min-height: 36px;
    padding: 0 10px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  /* workspace */
  .workspace {
    padding: 10px;
  }

  .content-card {
    padding: 12px;
    border-radius: 16px;
  }

  .content-card-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }

  .content-card-title h2 {
    font-size: 15px;
  }

  .header-actions {
    width: 100%;
  }

  .header-select {
    width: 100%;
  }

  .hero-badge {
    padding: 4px 8px;
    font-size: 12px;
  }

  /* 城市筛选双列网格 */
  .mobile-city-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    overflow-x: visible;
    padding: 0 0 8px;
  }

  .mobile-city-bar .city-btn {
    flex-shrink: unset;
    text-align: center;
    padding: 8px 4px;
    font-size: 13px;
    justify-content: center;
  }

  .mobile-city-bar .city-count {
    display: none;
  }

  /* 隐藏侧边栏展开按钮（与搜索框重合） */
  .sidebar-expand-btn {
    display: none !important;
  }

  /* 设备卡片单列居中，名称在上手机在下 */
  .device-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  .device-tile {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 14px 12px;
    border-radius: 14px;
    gap: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  /* 名称行（图标+名称+绿点）在上，手机图在下 */
  /* 名称行：图标最左，名称框居中(手机等宽)，绿点最右 */
  .device-tile-head {
    order: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: auto;
    width: 100%;
    margin-bottom: 10px;
    position: static;
  }

  .device-title-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  /* 设备图标左固定 */
  .device-icon {
    display: flex;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .device-icon .material-symbols-outlined {
    font-size: 14px;
  }

  /* 名称框与手机框等宽，居中 */
  .device-identity {
    width: var(--device-preview-width);
    max-width: var(--device-preview-width);
    min-width: var(--device-preview-width);
    flex: 0 0 var(--device-preview-width);
    justify-content: center;
    margin: 0 auto;
  }

  .device-name {
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 绿点右固定 */
  .device-status-wrap {
    position: static;
    flex-shrink: 0;
    margin: 0;
  }
  /* 手机图在名称行下方，居中 */
  .phone-preview {
    order: 1;
    justify-self: center;
    margin: 0 auto;
  }

  /* 手机端 topbar 只显示搜索框、刷新、退出 */
  .topbar-icon {
    display: none;
  }

  .topbar-title {
    display: none;
  }

  .health-dropdown-wrap {
    display: none !important;
  }

  #theme-toggle-btn {
    display: none !important;
  }

  #admin-link {
    display: none !important;
  }

  #current-user-badge {
    display: none !important;
  }

  .device-drawer {
    order: 1;
    width: 100%;
  }

  .device-actions {
    order: 2;
    width: 100%;
    grid-template-columns: 1fr 1fr 32px;
    gap: 4px;
  }

  .action-btn {
    height: 32px;
    font-size: 12px;
    border-radius: 10px;
  }

  .action-btn span:not(.material-symbols-outlined) {
    display: none;
  }

  .delete-btn {
    width: 32px;
  }

  /* 侧边栏内部 */
  .brand-block {
    height: auto;
    padding: 14px 16px;
    gap: 10px;
  }

  .brand-block h1 {
    font-size: 20px;
  }

  .brand-logo img {
    height: 28px;
  }

  .side-card {
    margin: 8px 12px;
    padding: 12px;
    border-radius: 14px;
  }

  .side-card-title h2 {
    font-size: 13px;
  }

  /* 城市筛选纵向列表 */
  .city-nav {
    flex-direction: column;
    gap: 2px;
  }

  .city-btn {
    width: 100%;
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    font-size: 13px;
  }

  /* 表单 */
  .stack-form input {
    height: 42px;
    border-radius: 12px;
  }

  .primary-btn {
    min-height: 40px;
    border-radius: 12px;
    font-size: 14px;
  }

  .confirm-card {
    padding: 20px;
    border-radius: 20px;
    width: calc(100vw - 32px);
  }

  /* 登录页 */
  .login-shell {
    padding: 20px 16px;
    padding-top: 12vh;
    align-items: flex-start;
  }

  .login-card-large {
    width: 100%;
    padding: 24px 20px;
    border-radius: 24px;
    grid-template-columns: 1fr;
  }

  .login-hero {
    display: none;
  }

  .login-brand-large {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
  }

  .login-brand-large img {
    width: 42px;
    height: 42px;
  }

  .login-brand-large h1 {
    font-size: 22px;
  }

  .login-brand-large p {
    font-size: 13px;
    margin: 0;
  }

  /* modal 全屏，宽度锁定屏幕宽让 scrcpy fit-to-screen 正确计算 */
  .device-modal[open] {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  .device-modal[open] .modal-body {
    height: calc(100dvh - 44px);
    max-height: calc(100dvh - 44px);
    overflow: hidden;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
  }

  /* control-frame-shell 保持 540:975 比例，自动居中，不拉伸 */
  .device-modal[open] .control-frame-shell {
    border-radius: 0;
    flex: none;
    width: min(100vw, calc((100dvh - 44px) * 540 / 975));
    height: calc(100dvh - 44px);
    max-width: 100vw;
    overflow: hidden;
  }

  /* iframe 完整显示 */
  #control-frame {
    width: 100%;
    height: 100%;
    border: 0;
    overflow: hidden;
  }
}

/* User management */
.user-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 10px;
  background: var(--panel-muted);
  border-radius: 20px;
  white-space: nowrap;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel-muted);
  font-size: 13px;
}

.user-item-name {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-item-role {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

.user-item-role.admin {
  background: var(--accent);
  color: #fff;
}

.user-item-role.user {
  background: var(--border);
  color: var(--text);
}

.tiny-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 16px;
}

.tiny-btn .material-symbols-outlined {
  font-size: 16px;
}
