/* monitor-dashboard — 深色现代 SaaS 大盘样式 */
:root {
  --bg: #0b0f1a;
  --bg-2: #0e1424;
  --panel: #141a2c;
  --panel-2: #1a2238;
  --border: #223055;
  --text: #e6edf7;
  --muted: #7d8db1;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --green: #2ecc71;
  --yellow: #f5a623;
  --red: #ef4e4e;
  --cyan: #22d3ee;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .35);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(79, 140, 255, .08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(124, 92, 255, .06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }

/* ---------- 布局骨架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 12px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 14px rgba(79, 140, 255, .35);
}
.brand .t { font-weight: 700; font-size: 14px; letter-spacing: .3px; }
.brand .s { font-size: 11px; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
  color: var(--muted); font-weight: 500; transition: all .15s;
  border: 1px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(79, 140, 255, .16), rgba(124, 92, 255, .10));
  color: var(--text); border-color: rgba(79, 140, 255, .35);
}
.nav-item .ico { width: 18px; text-align: center; }
.sidebar .spacer { flex: 1; }
.nav-item.logout { color: var(--red); margin-top: 8px; }

/* ---------- 主区 ---------- */
.main { flex: 1; padding: 20px 24px 40px; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.offline { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.dot.error { background: var(--red); box-shadow: 0 0 8px var(--red); }
.topbar .meta { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; gap: 14px; align-items: center; }

/* ---------- 卡片 ---------- */
.grid { display: grid; gap: 16px; }
/* grid/flex 子项允许收缩(否则内部 min-width 的内容会把列撑破, 表格横向滚动失效) */
.grid > .panel, .cols > .panel { min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.scene { display: none; }
.scene.active { display: block; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.panel h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel h3::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--accent); }
.chart { width: 100%; height: 260px; }

/* 指标卡 */
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi .ring-wrap { display: flex; align-items: center; gap: 14px; }
.kpi .val { font-size: 26px; font-weight: 800; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .lbl { color: var(--muted); font-size: 12px; }
.kpi .sub { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 8px 10px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--panel); font-size: 12px;
}
.tbl td { padding: 7px 10px; border-bottom: 1px solid rgba(34, 48, 85, .5); }
.tbl tr:hover td { background: rgba(79, 140, 255, .05); }
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; }
.tbl tr.clickable { cursor: pointer; }
.mono { font-family: "JetBrains Mono", "Consolas", monospace; font-size: 12px; }
.pill { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.green { background: rgba(46, 204, 113, .15); color: var(--green); }
.pill.yellow { background: rgba(245, 166, 35, .15); color: var(--yellow); }
.pill.red { background: rgba(239, 78, 78, .15); color: var(--red); }

/* 场景描述条 */
.scene-desc { color: var(--muted); font-size: 12px; margin: -8px 0 14px; }

/* 选择器 */
select.picker {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; outline: none;
  max-width: 380px; margin-bottom: 14px;
}
select.picker:focus { border-color: var(--accent); }

/* 两栏 */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(1000px 500px at 20% 0%, rgba(79, 140, 255, .10), transparent 55%),
    radial-gradient(800px 500px at 90% 100%, rgba(124, 92, 255, .10), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 36px 32px; box-shadow: var(--shadow);
}
.login-card .logo {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 24px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(79, 140, 255, .4);
}
.login-card h1 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 11px 14px; border-radius: 9px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  font-size: 14px; outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.btn {
  width: 100%; padding: 12px; border: none; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 15px; font-weight: 700; letter-spacing: 2px;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.err { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 10px; text-align: center; }
.login-hint { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }
.login-hint code { background: var(--bg-2); padding: 2px 7px; border-radius: 5px; border: 1px solid var(--border); }

/* ---------- 账户管理 / 表单 / 模态框 ---------- */
/* 主机信息: IO/网络实时数值卡片 */
.io-kpi {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 14px; border-radius: 8px; background: rgba(79, 140, 255, .08);
  border: 1px solid rgba(79, 140, 255, .18); min-width: 110px;
}
.io-kpi b { font-size: 16px; color: #22d3ee; font-weight: 600; }
.io-kpi .io-label { font-size: 11px; color: var(--muted); }
.io-kpi:nth-child(2) b { color: #ff7ad9; }
.io-kpi:nth-child(3) b { color: #2ecc71; }
.io-kpi:nth-child(4) b { color: #f5a623; }
.adduser-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.adduser-form input, .modal input {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; outline: none;
}
.adduser-form input:focus, .modal input:focus { border-color: var(--accent); }
.btn.small { width: auto; padding: 9px 18px; font-size: 13px; letter-spacing: 1px; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--accent); filter: none; }
.btn.danger { background: linear-gradient(135deg, #ef4e4e, #c0392b); }
.btn.mini { width: auto; padding: 5px 10px; font-size: 12px; letter-spacing: 0; border-radius: 7px; }
.views-chk { display: inline-flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12px; align-items: center; }
.views-chk.big { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.views-chk label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.views-chk input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.view-pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px;
  background: rgba(79, 140, 255, .12); color: #9db9ff; border: 1px solid rgba(79, 140, 255, .3); margin: 1px; }
.action-group { display: flex; gap: 6px; justify-content: flex-end; }
.op-btn { padding: 5px 10px; border-radius: 7px; font-size: 12px; cursor: pointer; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); transition: all .15s; }
.op-btn:hover { border-color: var(--accent); color: var(--accent); }
.op-btn.danger:hover { border-color: var(--red); color: var(--red); }
.op-btn:disabled { opacity: .35; cursor: not-allowed; }
.modal-mask { position: fixed; inset: 0; background: rgba(5, 8, 16, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; }
.modal { width: min(400px, calc(100vw - 28px)); background: var(--panel); border: 1px solid var(--border); border-radius: 14px;  padding: 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.modal h3 { margin-bottom: 16px; font-size: 16px; }
.term-modal { width: 92%; max-width: 1200px; position: relative; }
/* 模态框缩放柄(右下角 SE, 20260824g): 拖拽任意调整整个终端窗口大小 */
.term-modal-resize {
  position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; z-index: 50;
  cursor: nwse-resize; touch-action: none; border-bottom-right-radius: 14px;
  background: linear-gradient(135deg, transparent 50%, rgba(79, 140, 255, .45) 50%);
}
.term-modal-resize:hover { background: linear-gradient(135deg, transparent 50%, rgba(79, 140, 255, .75) 50%); }
/* 模态框级样式面板(透明度/颜色, 20260824h) */
.term-modal-settings {
  position: absolute; top: 44px; right: 8px; z-index: 60; width: 230px; padding: 10px 12px;
  background: rgba(16, 22, 42, .98); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); font-size: 12px;
}
.term-modal-settings .ts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.term-modal-settings label { color: #9db9ff; width: 52px; flex: none; }
.term-modal-settings input[type=range] { flex: 1; min-width: 0; accent-color: #4f8cff; }
.term-modal-settings .ts-val { width: 42px; text-align: right; color: #7d8db1; }
.term-modal-settings input[type=color] { width: 32px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.term-modal-settings .ts-sws { display: flex; gap: 4px; flex-wrap: wrap; }
.term-modal-settings .term-swatch {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .25);
  cursor: pointer; display: inline-block;
}
.term-modal-settings .term-swatch:hover { border-color: #4f8cff; }
.term-modal-settings .term-swatch.on { outline: 2px solid #4f8cff; outline-offset: 1px; }
.term-modal-settings .ts-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.term-modal h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.term-tools { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.term-tools .btn { padding: 3px 10px; font-size: 12px; }
/* 终端多标签页(Ubuntu gnome-terminal 风格) */
.term-tabs { display: flex; gap: 4px; margin-bottom: 8px; overflow-x: auto; flex-wrap: nowrap; }
.term-tab {
  padding: 5px 12px; border-radius: 6px 6px 0 0; background: rgba(79, 140, 255, .10);
  color: #9db9ff; cursor: pointer; font-size: 13px; display: flex; align-items: center;
  gap: 8px; white-space: nowrap; user-select: none;
}
.term-tab:hover { background: rgba(79, 140, 255, .18); }
.term-tab.active { background: rgba(79, 140, 255, .28); color: #fff; }
.term-tab-x { color: #7d8db1; font-weight: 700; padding: 0 2px; }
.term-tab-x:hover { color: #ef4e4e; }
.term-tab-add {
  padding: 5px 12px; border-radius: 6px 6px 0 0; background: rgba(79, 140, 255, .06);
  color: #7d8db1; cursor: pointer; font-size: 13px; white-space: nowrap; user-select: none;
}
.term-tab-add:hover { color: #4f8cff; background: rgba(79, 140, 255, .15); }
/* 窗口内标签栏(每窗口多终端标签, 20260824 移植 temp 多标签模型) */
.term-win-tabs {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 4px 6px 0; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap;
  background: rgba(10, 14, 26, .92); border-bottom: 1px solid rgba(34, 48, 85, .55);
}
.term-win-tabs .term-tab, .term-win-tabs .term-tab-add {
  padding: 3px 10px; font-size: 12px; border-radius: 6px 6px 0 0;
}
/* 窗口内终端面板(每个标签一个, 绝对定位铺满窗口 body) */
.term-pane { position: absolute; inset: 0; }
/* 终端桌面(浮动窗口容器) */
#termDesktop {
  position: relative; height: 520px; overflow: hidden; border-radius: 8px;
  border: 1px solid rgba(34, 48, 85, .6); background: rgba(8, 11, 21, .65);
}
/* 终端浮动窗口(可拖拽/缩放/设置透明度与颜色) */
.term-win {
  position: absolute; z-index: 1; min-width: 280px; min-height: 180px;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--border); border-radius: 8px;
  background: rgba(13, 18, 32, 1); box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
/* 窗口全域禁浏览器手势接管: 双指捏合缩放/平移/长按拖拽全部由 JS 处理
   (否则触屏双指会被判定为页面缩放而 pointercancel, 20260824b 实测) */
.term-win, .term-win * { touch-action: none; }
.term-win.active {
  z-index: 10; border-color: #4f8cff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 1px rgba(79, 140, 255, .35);
}
.term-win-bar {
  display: flex; align-items: center; gap: 2px; padding: 3px 6px; cursor: move;
  background: linear-gradient(180deg, rgba(30, 40, 72, .96), rgba(22, 30, 56, .96));
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.term-win-bar:active { cursor: grabbing; }
/* 拖拽/缩放中: 半透明浮起 + 阴影加深 + 高亮边框(拖拽效果 20260822f) */
.term-win.dragging, .term-win.resizing {
  opacity: .85;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .7), 0 0 0 1px rgba(79, 140, 255, .55);
}
/* 松手落定动画: 只在松手后短暂启用(拖拽中禁用 transition 保跟手) */
.term-win.drop-anim {
  transition: left .12s ease-out, top .12s ease-out,
              width .12s ease-out, height .12s ease-out, opacity .15s ease;
}
.term-win-title {
  flex: 1; min-width: 0; font-size: 12px; color: #9db9ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.term-win-btn {
  border: 0; background: transparent; color: #7d8db1; font-size: 11px; line-height: 1.3;
  cursor: pointer; padding: 3px 5px; border-radius: 4px; white-space: nowrap;
}
.term-win-btn:hover { background: rgba(79, 140, 255, .22); color: #fff; }
.term-win-btn.danger:hover { background: rgba(239, 78, 78, .28); color: #ffb3b3; }
.term-win-body { flex: 1; min-height: 0; position: relative; background: rgba(13, 18, 32, 1); }
/* 透明度: 盖掉 xterm 自带不透明背景, 露出窗口底色(文字仍不透明) */
.term-win-body .xterm { background: transparent !important; }
.term-win-body .xterm-viewport { background-color: transparent !important; }
/* 8 方向缩放柄(四边 + 四角, 右下角为可见角柄): 任意方向拉伸/收缩 */
.term-win-resize, .term-win-resize-n, .term-win-resize-s, .term-win-resize-e,
.term-win-resize-w, .term-win-resize-ne, .term-win-resize-nw, .term-win-resize-sw {
  position: absolute; z-index: 20; touch-action: none;
}
.term-win-resize {           /* SE 可见角柄(三角形) */
  right: 0; bottom: 0; width: 18px; height: 18px;
  cursor: nwse-resize; border-bottom-right-radius: 8px;
  background: linear-gradient(135deg, transparent 50%, rgba(79, 140, 255, .55) 50%);
}
.term-win-resize-n { top: 0; left: 14px; right: 14px; height: 6px; cursor: ns-resize; }
.term-win-resize-s { bottom: 0; left: 14px; right: 14px; height: 6px; cursor: ns-resize; }
.term-win-resize-e { right: 0; top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
.term-win-resize-w { left: 0; top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
.term-win-resize-ne { top: 0; right: 0; width: 14px; height: 14px; cursor: nesw-resize; }
.term-win-resize-nw { top: 0; left: 0; width: 14px; height: 14px; cursor: nwse-resize; }
.term-win-resize-sw { bottom: 0; left: 0; width: 14px; height: 14px; cursor: nesw-resize; }
/* 窗口设置面板(透明度/颜色) */
.term-settings {
  position: absolute; top: 32px; right: 8px; z-index: 30; width: 230px; padding: 10px 12px;
  background: rgba(16, 22, 42, .98); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); font-size: 12px;
}
.term-settings .ts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.term-settings label { color: #9db9ff; width: 52px; flex: none; }
.term-settings input[type=range] { flex: 1; min-width: 0; accent-color: #4f8cff; }
.term-settings .ts-val { width: 42px; text-align: right; color: #7d8db1; }
.term-settings input[type=color] { width: 32px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
.term-settings .ts-sws { display: flex; gap: 4px; flex-wrap: wrap; }
.term-settings .ts-sw {
  width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .25);
  cursor: pointer; display: inline-block;
}
.term-settings .ts-sw:hover { border-color: #4f8cff; }
.term-settings .ts-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.term-settings .ts-actions .term-win-btn { font-size: 12px; padding: 3px 10px; color: #9db9ff; }
/* 全屏 */
#termModal:fullscreen { display: grid; place-items: stretch; background: #05080f; padding: 12px; overflow: hidden; }
#termModal:fullscreen .term-modal { width: 100%; max-width: none; height: 100%; display: flex; flex-direction: column; }
#termModal:fullscreen .term-modal h3 { flex-wrap: nowrap; }
#termModal:fullscreen #termDesktop { flex: 1; height: auto; }
#termModal.term-full-fallback {
  position: fixed; inset: 0; z-index: 200; border-radius: 0; place-items: stretch;
  background: #05080f; padding: 12px; overflow: hidden;
}
#termModal.term-full-fallback .term-modal { width: 100%; max-width: none; height: 100%; display: flex; flex-direction: column; }
#termModal.term-full-fallback #termDesktop { flex: 1; height: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.tag-self { color: var(--yellow); font-size: 11px; margin-left: 4px; }

/* ========== 响应式适配(手机/平板; 桌面 >1024px 布局不受影响) ========== */

/* 汉堡按钮: 默认隐藏, 手机显示 */
.menu-btn {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 9px; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); font-size: 16px; cursor: pointer; line-height: 1;
}
.menu-btn:hover { border-color: var(--accent); }

/* 抽屉遮罩: 默认隐藏; 抽屉打开时锁定 body 滚动 */
.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(5, 8, 16, .55); z-index: 110; }
body.drawer-open { overflow: hidden; }

/* 导航角标: adb 在线设备数(0 台时隐藏) */
.nav-badge {
  margin-left: auto; min-width: 18px; padding: 1px 6px; border-radius: 999px;
  background: rgba(46, 204, 113, .18); color: var(--green);
  font-size: 11px; font-weight: 700; text-align: center;
}
.nav-badge.zero { background: rgba(125, 141, 177, .18); color: var(--muted); }
/* 右上角浮动提示(adb 设备接入/断开等即时事件) */
.toast-layer {
  position: fixed; top: 16px; right: 16px; z-index: 4000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 340px; padding: 10px 14px; border-radius: 10px;
  background: rgba(16, 22, 40, .96); border: 1px solid rgba(79, 140, 255, .35);
  color: var(--text); font-size: 13px; line-height: 1.5;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  animation: toast-in .18s ease-out;
}
.toast.ok { border-color: rgba(46, 204, 113, .55); }
.toast.warn { border-color: rgba(245, 166, 35, .55); }
.toast.err { border-color: rgba(239, 78, 78, .55); }
.toast .t { font-weight: 700; margin-bottom: 2px; }
.toast .d { color: var(--muted); font-size: 12px; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }


/* ---------- 平板(≤1024px): 侧边栏收窄为 64px 图标栏 ---------- */
@media (max-width: 1024px) {
  .sidebar { width: 64px; padding: 20px 8px; }
  .sidebar .brand { justify-content: center; padding: 4px 0 18px; }
  .sidebar .brand > div:last-child { display: none; }
  .nav-item { justify-content: center; padding: 12px 4px; gap: 0; }
  .nav-item .ico { width: auto; font-size: 17px; }
  .nav-item .nav-label { display: none; }
  .main { padding: 16px 18px 32px; }
  .cards-row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .topbar .meta { gap: 10px; }
}

/* ---------- 手机(≤768px): 汉堡抽屉 + 全宽控件 + 宽表格横向滚动 ---------- */
@media (max-width: 768px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 120;
    width: 220px; height: 100vh; overflow-y: auto;
    transform: translateX(-100%); transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  .sidebar-mask.show { display: block; }
  .sidebar .brand { justify-content: flex-start; }
  .sidebar .brand > div:last-child { display: block; }
  .nav-item { justify-content: flex-start; padding: 11px 12px; gap: 10px; }
  .nav-item .ico { width: 18px; font-size: 15px; }
  .nav-item .nav-label { display: inline; }
  .main { padding: 12px 12px 28px; }
  .topbar { gap: 10px; margin-bottom: 14px; }
  .topbar h1 { font-size: 16px; }
  .topbar-ctrl { width: 100%; order: 8; }
  .topbar .meta { margin-left: 0; width: 100%; order: 9; flex-wrap: wrap; gap: 8px; }
  .status-pill { font-size: 11px; padding: 4px 10px; }
  .chart { height: 220px; }
  .cards-row { grid-template-columns: 1fr; gap: 12px; }
  .panel { padding: 13px; }
  .scene-desc { margin: -4px 0 12px; flex-wrap: wrap; }
  select.picker { width: 100%; max-width: none; }
  /* 表单控件: 覆盖内联 width 使其满宽 */
  .adduser-form input, .adduser-form select { width: 100% !important; }
  .adduser-form .views-chk { width: 100%; }
  #hlType, #hlSort, #alEvent, #alUser, #alIp { width: 100% !important; }
  /* 宽表格 → 在已有 overflow 容器内横向滚动(sticky 表头仍生效) */
  .tbl { font-size: 12px; }
  .tbl:not(.kv) { min-width: 720px; }
  #threadTable, #threadTable2 { min-width: 480px; }
  #accessTable { min-width: 900px; }
  .tbl th, .tbl td { padding: 6px 8px; }
  .action-group { flex-wrap: wrap; }
  .modal { padding: 18px; }
  .term-modal h3 { flex-wrap: wrap; gap: 6px; }
  #termDesktop { height: 56vh; min-height: 300px; }
  .term-win { min-width: 200px; min-height: 140px; }
  .term-win-btn { font-size: 12px; padding: 4px 6px; }
}

/* 矮屏(横屏手机/小笔记本): 模态框可滚动, 避免内容溢出视口 */
@media (max-height: 620px) {
  .modal-mask { place-items: start center; overflow-y: auto; padding: 12px 0; }
  #termDesktop { height: 48vh; min-height: 260px; }
}

/* ---------- 设备实时画面(scrcpy 镜像) ---------- */
.ds-tag { font-size: 11px; color: var(--muted); background: rgba(34,48,85,.5);
          border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px;
          font-weight: 400; letter-spacing: .5px; }
.ds-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ds-bar select.picker { width: 230px; padding: 7px 10px; }
.ds-state { font-size: 12px; color: var(--muted); letter-spacing: .5px; }
.ds-state.on { color: #2ecc71; }
.ds-state.err { color: #ef4e4e; }
.ds-err { font-size: 12px; color: #ef4e4e; background: rgba(239,78,78,.08);
          border: 1px solid rgba(239,78,78,.35); border-radius: 8px;
          padding: 8px 12px; margin-top: 8px; line-height: 1.6; }
#dsVideo { display: block; object-fit: contain; }
@media (max-width: 768px) {
  .ds-bar select.picker { width: 100%; }
  .ds-bar .btn { flex: 1; }
}
