/* V2 layout shell on top of classic-style.css (Dock yellow/black) */
:root {
  --sidebar-w: 0px;
  --drawer-w: 360px;
  --top-h: auto;
  --kpi-h: auto;
  --surface: rgba(11, 21, 36, 0.86);
  --surface-2: rgba(15, 27, 45, 0.78);
  --line: rgba(148, 163, 184, 0.13);
  --blue: #38bdf8;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #fb7185;
  --log-bg: rgba(4, 10, 19, 0.92);
  --radius: 16px;
}

body.v2-classic { overflow: hidden; }

.app-v2 {
  width: min(1480px, calc(100vw - 24px));
  margin: 8px auto 12px;
  position: relative;
  z-index: 1;
  /* 固定高度（而非 min-height）才能让 flex 链收住 .table-wrap 的高度并出现内部滚动条；
     用 min-height 会让内容把容器撑高、被 body overflow:hidden 裁掉且无法滚动 */
  height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
}

.app-v2 .topbar {
  margin-bottom: 0;
  flex-shrink: 0;
  min-height: 70px;
  padding: 10px 18px;
  border-radius: 18px;
}
.app-v2 .brand { gap: 12px; min-width: 250px; }
.app-v2 .brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  font-size: 1.05rem;
}
.app-v2 h1 { margin-bottom: 4px; font-size: clamp(1.35rem, 1.7vw, 1.7rem); }
.app-v2 .brand p { font-size: 0.72rem; letter-spacing: 0.07em; }

.nav-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(5, 12, 22, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.nav-tabs button {
  height: 32px;
  border: none;
  border-radius: 9px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}
.nav-tabs button.active {
  color: #03111c;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(240, 255, 0, 0.15);
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
  flex-shrink: 0; /* 不被 shell 挤压，保持 KPI 卡完整高度 */
}
.kpi-row .card.metric {
  min-height: 58px;
  padding: 8px 12px;
  border-radius: 12px;
}
.kpi-row .card.metric label,
.kpi-row .card.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.kpi-row .card.metric strong {
  font-family: var(--mono);
  font-size: 1.45rem;
  letter-spacing: 0;
}
.kpi-row .card.metric strong.ok { color: #7ef0c3; }
.kpi-row .card.metric strong.warn { color: var(--gold); }
.kpi-row .card.metric strong.bad { color: var(--red); }

.operation-progress {
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(9, 19, 32, 0.95), rgba(5, 12, 22, 0.9));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
}
.operation-progress.idle {
  opacity: 0.82;
}
.operation-progress.is-running {
  border-color: rgba(240, 255, 0, 0.48);
  box-shadow: 0 0 0 1px rgba(240, 255, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.24);
}
.operation-progress.is-done {
  border-color: rgba(126, 240, 195, 0.42);
  box-shadow: 0 0 0 1px rgba(126, 240, 195, 0.08), 0 12px 32px rgba(0, 0, 0, 0.24);
}
.operation-progress.is-failed {
  border-color: rgba(251, 113, 133, 0.55);
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.1), 0 12px 32px rgba(0, 0, 0, 0.24);
}
.operation-progress.is-waiting {
  border-color: rgba(148, 163, 184, 0.34);
}
.operation-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.operation-progress-kicker {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}
.operation-progress-head strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}
.operation-progress-state {
  min-width: 92px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  padding: 5px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.operation-progress-state.running {
  border-color: rgba(240, 255, 0, 0.45);
  color: var(--brand);
  background: rgba(240, 255, 0, 0.08);
}
.operation-progress-state.done {
  border-color: rgba(126, 240, 195, 0.42);
  color: #7ef0c3;
  background: rgba(16, 185, 129, 0.08);
}
.operation-progress-state.failed {
  border-color: rgba(251, 113, 133, 0.45);
  color: #fecaca;
  background: rgba(251, 113, 133, 0.08);
}
.operation-progress-state.waiting {
  border-color: rgba(148, 163, 184, 0.32);
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.08);
}
.operation-progress-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.operation-step {
  position: relative;
  min-height: 34px;
  padding: 6px 8px 5px 28px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 9px;
  background: rgba(4, 10, 19, 0.52);
  overflow: hidden;
}
.operation-step::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.42);
  background: rgba(7, 15, 28, 0.95);
}
.operation-step-title {
  display: block;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}
.operation-step-status {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}
.operation-step-detail {
  display: none;
  margin-top: 4px;
  color: rgba(203, 213, 225, 0.72);
  font-size: 10px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.operation-step.done {
  border-color: rgba(126, 240, 195, 0.3);
  background: rgba(16, 185, 129, 0.08);
}
.operation-step.done::before {
  border-color: #7ef0c3;
  background: #7ef0c3;
  box-shadow: 0 0 14px rgba(126, 240, 195, 0.3);
}
.operation-step.done .operation-step-status::before {
  content: "✓ ";
}
.operation-step.active {
  border-color: rgba(240, 255, 0, 0.48);
  background: rgba(240, 255, 0, 0.08);
}
.operation-step.active::before {
  border-color: var(--brand);
  box-shadow: 0 0 0 5px rgba(240, 255, 0, 0.08), 0 0 18px rgba(240, 255, 0, 0.35);
}
.operation-step.active .operation-step-status {
  color: var(--brand);
}
.operation-step.active .operation-step-status::before {
  content: "● ";
}
.operation-step.failed {
  border-color: rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.08);
}
.operation-step.failed::before {
  border-color: #fb7185;
  background: #fb7185;
  box-shadow: 0 0 14px rgba(251, 113, 133, 0.28);
}
.operation-step.failed .operation-step-status {
  color: #fecaca;
}
.operation-step.failed .operation-step-status::before {
  content: "✗ ";
}
.operation-step.waiting {
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(148, 163, 184, 0.06);
}
.operation-step.waiting::before {
  border-color: #94a3b8;
  background: rgba(148, 163, 184, 0.3);
}
.operation-step.waiting .operation-step-status {
  color: #cbd5e1;
}
.operation-progress-message {
  display: none;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
  flex: 1;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: visible;
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.9), rgba(7, 14, 26, 0.85));
  box-shadow: var(--shadow);
}
.shell.drawer-open { grid-template-columns: 1fr var(--drawer-w); }

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(7, 15, 28, 0.55);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border-radius: 20px 0 0 20px;
}
.shell > .sidebar { display: none !important; }
.shell > .sidebar-overlay { display: none !important; }
.sidebar-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.sidebar-head h2 {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.quick-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.device-list { overflow: auto; padding: 10px; flex: 1; }
.device-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: rgba(4, 10, 19, 0.45);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.device-item:hover { border-color: rgba(240, 255, 0, 0.22); }
.device-item.active {
  border-color: rgba(240, 255, 0, 0.45);
  background: rgba(240, 255, 0, 0.08);
}
.device-item.offline { opacity: 0.72; }
.device-item h3 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.device-item .meta { margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.device-item .mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.device-item .mini-stats span {
  background: rgba(15, 27, 45, 0.78);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 10px;
  text-align: center;
}
.device-item .mini-stats strong {
  display: block;
  font: 700 13px/1.2 var(--mono);
  color: var(--text);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
  border-radius: 14px 0 14px 14px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 15, 28, 0.45);
  overflow: visible;
  position: relative;
  z-index: 30;
}
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); }
.toolbar .context { width: 100%; font-size: 11px; color: var(--muted); }
.search { min-width: 220px; flex: 1; max-width: 320px; }
.ttl-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 15, 28, 0.74);
}
.ttl-group input { width: 52px; height: 30px; padding: 0 8px; }

.view { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: visible; }
.view.active { display: flex; }

.mini-device-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 15, 28, 0.35);
  overflow-x: auto;
  min-height: 44px;
}
.mini-device-nav:empty { display: none; }
.mini-device-nav button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 27, 45, 0.72);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.mini-device-nav button.active {
  color: #03111c;
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.mini-device-nav button .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
}
.mini-device-nav button.offline .dot { background: var(--red); }
.mini-device-nav .mini-count {
  color: inherit;
  opacity: 0.72;
  font-family: var(--mono);
}

.device-grid {
  overflow: auto;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.device-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(4, 10, 19, 0.42);
  box-shadow: var(--shadow);
}
.device-card.disabled-card { opacity: 0.55; }
.device-card h3 { font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.device-card .meta { color: var(--muted); font-size: 10px; margin: 6px 0 8px; line-height: 1.45; }
.device-card .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}
.device-card .stats div {
  background: rgba(15, 27, 45, 0.78);
  border-radius: 8px;
  padding: 6px;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}
.device-card .stats strong {
  display: block;
  font: 700 14px/1.2 var(--mono);
  color: var(--text);
  margin-top: 4px;
}
.device-card .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.device-card .actions .btn { flex: 0 0 auto; }
.device-card .actions .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.table-wrap { flex: 1; min-height: 0; overflow: auto; padding: 0 10px 10px; }
.table-wrap table { min-width: 1100px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.table-wrap th:nth-child(2), .table-wrap td:nth-child(2) { width: 72px; }
.table-wrap th:nth-child(12), .table-wrap td:nth-child(12) { width: 280px; }
.c-money { text-align: right; color: var(--gold); font-weight: 700; }
/* 余额列(第10列)表头与右对齐的金额单元格对齐 */
.table-wrap th:nth-child(10) { text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; }
.table-wrap .ok, .kpi-row strong.ok { color: var(--green); font-weight: 700; }
.table-wrap .warn, .kpi-row strong.warn { color: var(--gold); font-weight: 700; }
.table-wrap .bad, .kpi-row strong.bad { color: var(--red); font-weight: 700; }
tr.running td { background: rgba(16, 185, 129, 0.06); }
tr.starting td { background: rgba(245, 158, 11, 0.07); }
tr.leftover td { background: rgba(251, 113, 133, 0.08); }
tr.selected td { background: rgba(240, 255, 0, 0.08); }
.table-wrap tbody tr[data-account] { cursor: pointer; }
.table-wrap tbody tr.row-selected td { background: rgba(240, 255, 0, 0.14); }
.table-wrap tbody tr.row-selected:hover td { background: rgba(240, 255, 0, 0.18); }
.table-wrap td[data-stop],
.table-wrap input[type="checkbox"] { cursor: crosshair; }
.table-wrap.drag-selecting,
.table-wrap.drag-selecting * {
  user-select: none;
  cursor: crosshair !important;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 27, 45, 0.78);
  font-size: 11px;
  font-weight: 700;
}
.pill.ok { color: #8df0c6; border-color: rgba(16, 185, 129, 0.22); }
.pill.bad { color: #fda4af; border-color: rgba(251, 113, 133, 0.28); }

.drawer {
  border-left: 1px solid var(--line);
  background: rgba(7, 15, 28, 0.72);
  display: none;
  flex-direction: column;
  min-height: 0;
}
.shell.drawer-open .drawer { display: flex; }
.drawer-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.drawer-head h2 { margin: 0; font-size: 15px; }
.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}
.drawer-tabs button {
  height: 30px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0 12px;
}
.drawer-tabs button.active {
  color: #03111c;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.drawer-body { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.kv {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px 12px;
  margin-bottom: 14px;
}
.kv span { color: var(--muted); font-size: 12px; }
.kv strong { font-weight: 700; }
pre.log-view {
  background: var(--log-bg);
  color: #dbeafe;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 280px;
  max-height: 420px;
  overflow: auto;
  font: 12px/1.5 var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.bottom-panel {
  border-top: 1px solid var(--line);
  background: rgba(7, 15, 28, 0.55);
  height: 118px;
  min-height: 32px;
  display: flex;
  flex-direction: column;
  transition: height 0.2s;
}
.bottom-panel.collapsed { height: 32px; }
.bottom-panel.collapsed #logContent { display: none; }
.bottom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
#logContent {
  flex: 1;
  overflow: auto;
  padding: 10px 14px;
  font: 12px/1.45 var(--mono);
  color: #cbd5e1;
  white-space: pre-wrap;
}

.error-banner {
  margin: 10px 16px 0;
  padding: 10px 12px;
  border: 1px solid rgba(251, 113, 133, 0.35);
  border-radius: 12px;
  background: rgba(251, 113, 133, 0.08);
  color: #fecaca;
  font-size: 12px;
  display: none;
}
.error-banner.show { display: block; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 16, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
  width: min(520px, 100%);
  border-radius: 20px;
  border: 1px solid rgba(240, 255, 0, 0.16);
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.96), rgba(7, 14, 26, 0.94));
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h2 { margin: 0 0 14px; font-size: 1.05rem; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.modal select, .modal textarea, .modal input { width: 100%; }
.modal .btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.confirm-list {
  max-height: 220px;
  overflow: auto;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(4, 10, 19, 0.45);
}

button.sm, .btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }
button.warn, .btn-warn {
  color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
}
button.danger, .btn-danger {
  color: var(--red);
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.35);
}
button.primary, button.success, button.ghost, button.warn, button.danger {
  height: 34px;
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 700;
}
button.primary {
  color: #03111c;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: none;
  box-shadow: 0 10px 28px rgba(240, 255, 0, 0.18);
}
button.ghost {
  color: var(--text);
  background: rgba(15, 27, 45, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.11);
}
button.success {
  color: #8df0c6;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 40;
}
.shell.mobile-sidebar-open .sidebar-overlay { display: block; }
.nav-toggle { display: none; }

/* Base controls (V2 shell on classic tokens) */
.toolbar button:not(.btn),
.drawer-body button:not(.btn),
.modal .btns button:not(.btn) {
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.11);
  background: rgba(15, 27, 45, 0.78);
  color: var(--text);
  font-weight: 700;
  transition: border-color 0.15s, transform 0.15s;
}
.toolbar button:not(.btn):hover { border-color: rgba(240, 255, 0, 0.22); }
.toolbar input[type="text"],
.toolbar input[type="number"],
.toolbar select,
.modal select,
.modal textarea,
.modal input {
  height: 34px;
  border: 1px solid rgba(148, 163, 184, 0.13);
  border-radius: 12px;
  background: rgba(7, 15, 28, 0.74);
  color: var(--text);
  padding: 0 12px;
}
.modal textarea.textarea { min-height: 96px; padding: 10px 12px; resize: vertical; height: auto; }
.toolbar input:focus, .toolbar select:focus, .modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none;
  border-color: rgba(240, 255, 0, 0.35);
  box-shadow: 0 0 0 3px rgba(240, 255, 0, 0.08);
}

.toolbar-accounts { align-items: flex-start; }
.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  margin-bottom: 2px;
}
.toolbar-filters .search { flex: 1; min-width: 200px; max-width: 360px; }
.filter-select { min-width: 140px; max-width: 180px; }
.toolbar-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 15, 28, 0.45);
}
.toolbar-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-right: 2px;
}
.toolbar-more { position: relative; z-index: 40; align-self: center; }
.toolbar-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(240, 255, 0, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.98), rgba(7, 14, 26, 0.96));
  box-shadow: var(--shadow);
}
.toolbar-more-menu.toolbar-more-menu-fixed {
  position: fixed;
  top: auto;
  left: auto;
}
.toolbar-more-menu .btn { width: 100%; justify-content: center; }
.toolbar-filters .input.search {
  cursor: text;
}

/* Custom dropdown (replaces native select popup clipped by layout) */
.custom-select { position: relative; display: inline-block; }
.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0);
}
.custom-select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 148px;
}
/* 账号筛选行：设备/状态下拉触发器与 38px 搜索框等高，避免同排控件高低不齐
   特异性需高于 .btn.sm(30px)，故链上 .btn.sm 三类 */
.toolbar-filters .custom-select-trigger.btn.sm { height: 34px; }
.toolbar-filters .filter-select { height: 34px; }
.custom-select-caret { color: var(--brand); font-size: 10px; line-height: 1; }
.custom-select-menu,
.toolbar-more-menu {
  position: fixed;
  z-index: 9999;
  max-height: min(320px, 50vh);
  overflow: auto;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(240, 255, 0, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.98), rgba(7, 14, 26, 0.96));
  box-shadow: var(--shadow);
}
.custom-select-menu.hidden,
.toolbar-more-menu.hidden { display: none !important; }
.custom-select-menu.open,
.toolbar-more-menu.open { display: flex !important; }
.custom-select-option {
  min-height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  width: 100%;
}
.custom-select-option:hover,
.custom-select-option.active {
  background: rgba(240, 255, 0, 0.12);
  color: var(--brand);
}
.modal .custom-select { width: 100%; }
.modal .custom-select-trigger { width: 100%; min-width: 0; }

/* Unified .btn variants inside classic shell */
.btn.sm { height: 28px; padding: 0 9px; font-size: 11px; }
.btn.btn-primary {
  color: #03111c;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: none;
  box-shadow: 0 8px 20px rgba(240, 255, 0, 0.15);
}
.btn.btn-ghost {
  color: var(--text);
  background: rgba(15, 27, 45, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.11);
}
.btn.btn-danger {
  color: var(--red);
  background: rgba(251, 113, 133, 0.12);
  border: 1px solid rgba(251, 113, 133, 0.35);
}
.btn.btn-warn {
  color: var(--gold);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.btn.btn-primary:hover,
.btn.btn-ghost:hover,
.btn.btn-danger:hover,
.btn.btn-warn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.ttl-label { font-size: 11px; color: var(--muted); }
.ttl-input { width: 52px !important; height: 30px !important; padding: 0 8px !important; }
.sidebar-empty { color: var(--muted); font-size: 12px; padding: 8px; margin: 0; }
.flex-gap-8 { display: flex; gap: 8px; flex-wrap: wrap; }
.mt-8 { margin-top: 8px; }
.drawer-body .btn,
.modal .btns .btn { min-width: 88px; }
.drawer-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 12px; }
.device-card { box-shadow: none; }
.device-card:hover { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22); }
tr.running:hover td { background: rgba(16, 185, 129, 0.1); }
tr.starting:hover td { background: rgba(245, 158, 11, 0.1); }
tr.leftover:hover td { background: rgba(251, 113, 133, 0.12); }
tr.selected:hover td { background: rgba(240, 255, 0, 0.12); }

.confirm-code-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 8px;
}
.confirm-code-tools.hidden { display: none; }
.confirm-code-tools code {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(240, 255, 0, 0.2);
  background: rgba(240, 255, 0, 0.08);
  color: var(--brand);
  font: 800 12px/1.2 var(--mono);
  user-select: all;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(240, 255, 0, 0.2);
  background: rgba(10, 20, 35, 0.96);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.error { border-color: rgba(251, 113, 133, 0.35); color: #fecaca; }

body.is-busy { cursor: progress; }
body.is-busy .status-pill::after {
  content: " · 执行中";
  color: var(--gold);
}

/* 顶部不确定进度条：操作进行中持续左右滑动，给用户明确的「正在执行」信号 */
#busyBar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 10000;
  background: rgba(240, 255, 0, 0.12);
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#busyBar.active { opacity: 1; }
#busyBar span {
  position: absolute;
  top: 0;
  height: 100%;
  width: 35%;
  background: linear-gradient(90deg, transparent, var(--brand), var(--brand-2), transparent);
  box-shadow: 0 0 8px rgba(240, 255, 0, 0.55);
  animation: busy-slide 1.1s ease-in-out infinite;
}
@keyframes busy-slide {
  0% { left: -35%; }
  100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  #busyBar span { animation: none; width: 100%; left: 0; opacity: 0.6; }
}

/* 状态徽章圆点跟随语义色（在线绿/离线红），不再恒为琥珀色 */
.pill .dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  box-shadow: none;
}
.pill { font-size: 11px; }
.device-item .pill, .device-card .pill { font-size: 10px; }

/* 空状态 / 错误状态统一块 */
.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  grid-column: 1 / -1;
}
.state-block p { margin: 0; font-size: 13px; line-height: 1.6; }
.state-block.error { color: #fda4af; }
.state-block.error::before { content: "⚠"; font-size: 26px; line-height: 1; }
.state-block.empty::before { content: "○"; font-size: 24px; line-height: 1; opacity: 0.6; }
tr.empty-row td { padding: 0; background: transparent; }
tr.empty-row:hover td { background: transparent; }

/* 连接失败时 KPI 置灰，区分「真的为 0」和「拿不到数据」 */
.kpi-row.kpi-stale .card.metric { opacity: 0.55; }

/* 启动中状态徽章用进行中色（琥珀），区别于失败红 */
.state-chip.pending {
  border-color: rgba(245, 158, 11, 0.28);
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.08);
}

/* 确认弹窗的后果提示与确认码错误 */
.confirm-hint { color: var(--gold); font-size: 12px; }
.confirm-error {
  margin: 6px 0 0;
  color: #fda4af;
  font-size: 12px;
  min-height: 0;
  display: none;
}
.confirm-error.show { display: block; }

/* 快捷筛选选中态 */
.quick-filters .btn.active {
  color: #03111c;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-color: transparent;
}

/* 键盘焦点可见性 */
.btn:focus-visible,
.nav-tabs button:focus-visible,
.device-item:focus-visible,
.drawer-tabs button:focus-visible,
.table-wrap tbody tr:focus-visible,
input[type="checkbox"]:focus-visible,
.custom-select-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.device-item:focus-visible { border-color: rgba(240, 255, 0, 0.5); }
.table-wrap tbody tr:focus-visible { outline-offset: -2px; }

/* 读屏专用：视觉隐藏但保留在无障碍树中（用于日志镜像 live region） */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* 顶栏刷新时间（非 live region，不打扰读屏） */
.global-time { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 3px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  background: rgba(5, 12, 22, 0.58);
}
.lang-switch button {
  height: 24px;
  min-width: 38px;
  border: 0;
  border-radius: 7px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.lang-switch button.active {
  color: #03111c;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.lang-switch button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
/* 选择启动设备弹窗的说明文字 */
.modal-info { color: var(--muted); font-size: 12px; margin: 0 0 12px; line-height: 1.5; }

/* 备注列加宽，尽量显示完整备注；超长仍省略号 + title 全文 */
.table-wrap td:nth-child(12) { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }

/* 离线/禁用设备卡按钮：禁用态去色，主色按钮不再看起来可点 */
.device-card .actions .btn:disabled { filter: grayscale(0.7); }

@media (max-width: 1200px) {
  /* 解除桌面端的「应用壳固定视口」，让整页可以纵向滚动 */
  body.v2-classic { overflow: auto; }
  .app-v2 { height: auto; min-height: 0; }
  .shell { min-height: 0; }
  .main, .view, .table-wrap, .device-grid, .device-list { overflow: visible; }
  .table-wrap { overflow-x: auto; }

  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .operation-progress-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operation-progress-message { white-space: normal; }
  .shell { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: var(--shadow);
    border-radius: 0;
    background: rgba(7, 15, 28, 0.98);
  }
  .shell.mobile-sidebar-open .sidebar { transform: translateX(0); }
  .drawer {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 60;
    width: min(var(--drawer-w), 100vw);
    display: none !important;
    background: rgba(7, 15, 28, 0.98);
  }
  .shell.drawer-open .drawer { display: flex !important; }
  .nav-toggle { display: inline-flex !important; }
}

@media (max-width: 980px) {
  /* 工具栏按钮全宽后，竖向分隔线和空状态文字会变成多余空行，隐藏掉 */
  .toolbar .sep { display: none; }
  .toolbar .context:empty { display: none; }
  /* 触控目标放大到约 40px，复选框热区撑到 44px */
  .btn.sm, button.sm { min-height: 40px; }
  .nav-tabs button { height: 40px; }
  .table-wrap td:first-child,
  .table-wrap th:first-child { padding: 10px; }
  .table-wrap input[type="checkbox"] {
    width: 22px;
    height: 22px;
  }
  .device-card .actions .btn { flex: 1 1 auto; }
  .operation-progress-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .operation-progress-state {
    min-width: 0;
  }
  .operation-progress-steps { grid-template-columns: 1fr; }
  .operation-step-detail { white-space: normal; }
}
