/* =====================================================================
   设备控制中心 · 三栏工作台 + 右侧功能面板（v9）
   左：无障碍阅读器 + 投屏（常驻，不受标签切换影响）
   中：屏幕控制/一键解锁/功能区/日志 窄列
   右：功能面板（AI分析/注入中心/应用列表… 内嵌显示），原 ADB 控制区隐藏
   ===================================================================== */
@media (min-width: 1024px) {

  /* ---------- 主区：左(树+投屏) / 中(功能卡) / 右(功能面板) ---------- */
  .home-tab-split {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding: 6px 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
  }
  .home-tab-left {
    flex: 0 0 auto !important;
    width: 34% !important;
    max-width: 36% !important;
    height: auto !important;
    padding: 0 !important;
  }
  .home-tab-right {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: auto !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  .home-tab-left > .ctrl-body {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
    padding: 0 !important;
  }
  .home-tab-left > .ctrl-body > .ctrl-screen-area {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    overflow: visible !important;
  }

  /* 左内：界面树 + 投屏 并排等分 */
  .home-tab-left > .ctrl-body > .ctrl-screen-area > div {
    width: 100% !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }
  .home-tab-left > .ctrl-body > .ctrl-screen-area .reader-style-bar {
    padding: 4px 8px !important;
    gap: 6px !important;
    height: auto !important;
    min-height: 0 !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .home-tab-left > .ctrl-body > .ctrl-screen-area .reader-style-bar * { font-size: 11px !important; }
  .home-tab-left > .ctrl-body > .ctrl-screen-area > div > div:not(.reader-style-bar) {
    display: flex !important;
    flex-direction: row !important;
    gap: 6px !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  .home-tab-left > .ctrl-body > .ctrl-screen-area > div > div:not(.reader-style-bar) > div {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    max-height: calc(100vh - 260px) !important;
  }

  /* ---------- 中栏：功能卡（窄） ---------- */
  .home-tab-right > .ctrl-sidebar-panel {
    flex: 0 0 205px !important;
    width: 205px !important;
    min-width: 205px !important;
    max-width: 205px !important;
    height: auto !important;
    padding: 0 !important;
    border-left: none !important;
    overflow: visible !important;
  }
  .home-tab-right > .ctrl-sidebar-panel .sidebar-two-col {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
    height: auto !important;
  }
  .home-tab-right > .ctrl-sidebar-panel .sidebar-col { width: 100% !important; height: auto !important; gap: 6px !important; }
  .home-tab-right > .ctrl-sidebar-panel .sidebar-card {
    width: 100% !important;
    height: auto !important;
    padding: 6px 6px !important;
    box-sizing: border-box !important;
  }
  .home-tab-right > .ctrl-sidebar-panel button {
    font-size: 11px !important;
    padding: 5px 3px !important;
    line-height: 1.2 !important;
    min-height: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .home-tab-right > .ctrl-sidebar-panel input,
  .home-tab-right > .ctrl-sidebar-panel select {
    font-size: 11px !important;
    padding: 4px !important;
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ---------- 原 ADB 控制区：隐藏 ---------- */
  .home-tab-right > div:last-child,
  .home-tab-right .trojan-main-area,
  .home-tab-right .trojan-control-panel {
    display: none !important;
  }

  /* ---------- 右侧功能面板 ---------- */
  #wk-panel {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: calc(100vh - 215px);
    min-height: 420px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    overflow: hidden;
    background: #161616;
  }
  #wk-panel[hidden] { display: none !important; }
  .wk-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-size: 12px;
    color: #cfd8e3;
    background: rgba(255, 255, 255, .02);
    flex: 0 0 auto;
  }
  .wk-panel-title { font-weight: 600; letter-spacing: .5px; }
  .wk-panel-actions { display: flex; align-items: center; gap: 6px; }
  .wk-panel-btn {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .10);
    color: #9aa7b8;
    border-radius: 6px;
    font-size: 11px;
    padding: 3px 8px;
    cursor: pointer;
  }
  .wk-panel-btn:hover { color: #e6eefc; border-color: rgba(255, 255, 255, .25); }
  .wk-panel-body { flex: 1 1 auto; min-height: 0; position: relative; }
  .wk-panel-frame { width: 100%; height: 100%; border: 0; background: #101010; display: block; }
  .wk-panel-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
    color: #5f6b7a;
    font-size: 13px;
    text-align: center;
    padding: 20px;
  }
  .wk-panel-empty b { color: #8fa2b8; font-weight: 600; }

  /* ---------- 顶栏压缩 ---------- */
  .ctrl-header { padding: 4px 8px !important; min-height: 0 !important; }
  .ctrl-header-brand { font-size: 14px !important; }
  .ctrl-tabs { height: auto !important; padding: 2px 6px !important; gap: 4px !important; }
  .ctrl-tab { padding: 4px 10px !important; font-size: 12px !important; height: 28px !important; }
  .ctrl-tab.wk-tab-open { color: #4da3ff !important; border-color: #4da3ff !important; }
  .home-tab-topbar {
    padding: 4px 8px !important;
    gap: 6px !important;
    height: auto !important;
    min-height: 32px !important;
    flex-wrap: wrap !important;
  }
  .home-tab-topbar .topbar-label { font-size: 11px !important; }
  .home-tab-topbar .topbar-val   { font-size: 12px !important; }
  .home-tab-topbar-pwd { height: auto !important; }
}

/* ---------- 内嵌面板模式（iframe 内）---------- */
html.wk-embed .ctrl-header { display: none !important; }
html.wk-embed .home-tab-split { display: none !important; }
html.wk-embed body { background: #141414 !important; }
html.wk-embed .ctrl-tab-content { height: 100vh !important; overflow: auto !important; }
html.wk-embed .ctrl-tab-panel { margin: 0 !important; }

/* ---------- 窄屏兜底 ---------- */
@media (max-width: 1023px) {
  .home-tab-split {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  .home-tab-left { width: 100% !important; max-width: none !important; }
  .home-tab-right { flex-wrap: wrap !important; width: 100% !important; }
  .home-tab-right > .ctrl-sidebar-panel { flex: 0 0 100% !important; width: 100% !important; max-width: none !important; }
  #wk-panel { width: 100% !important; height: 70vh !important; }
}

/* =====================================================================
   v10 紧凑模式：一屏放下，三栏各自内部滚动（1280x720 也不整页滚）
   ===================================================================== */
@media (min-width: 1024px) {
  /* 顶部再压一轮：把纵向空间让给内容 */
  .ctrl-header { padding: 2px 8px !important; }
  .ctrl-header-left { gap: 6px !important; }
  .ctrl-tabs { padding: 0 6px !important; gap: 3px !important; margin-top: 2px !important; }
  .ctrl-tab { padding: 3px 8px !important; font-size: 11px !important; height: 24px !important; line-height: 18px !important; }
  .home-tab-topbar { padding: 2px 8px !important; min-height: 26px !important; gap: 4px !important; }
  .home-tab-topbar .topbar-label { font-size: 10px !important; }
  .home-tab-topbar .topbar-val { font-size: 11px !important; }
  .home-tab-split { padding: 4px 6px !important; gap: 6px !important; }

  /* 左：30% 宽，超高则内部滚动 */
  .home-tab-left {
    width: 30% !important;
    max-width: 32% !important;
    max-height: calc(100vh - 158px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  .home-tab-left > .ctrl-body { max-height: none !important; }
  .home-tab-left > .ctrl-body > .ctrl-screen-area > div > div:not(.reader-style-bar) > div {
    max-height: calc(100vh - 290px) !important;
  }

  /* 中：185 宽，内部滚动 */
  .home-tab-right > .ctrl-sidebar-panel {
    flex: 0 0 185px !important;
    width: 185px !important;
    min-width: 185px !important;
    max-width: 185px !important;
    max-height: calc(100vh - 158px) !important;
    overflow-y: auto !important;
  }
  .home-tab-right > .ctrl-sidebar-panel button { padding: 4px 3px !important; font-size: 10.5px !important; }

  /* 右：功能面板撑满可视高度，内部滚动 */
  #wk-panel {
    height: calc(100vh - 158px) !important;
    min-height: 340px !important;
  }
  .home-tab-right { max-height: calc(100vh - 158px) !important; }

  /* 列表/表格类页面在面板里更紧凑 */
  .wk-panel-frame { display: block; }
}

/* =====================================================================
   v11 微调：顶栏再省一行，左栏回宽一点（投屏别被挤小）
   ===================================================================== */
@media (min-width: 1024px) {
  /* 时间行与顶栏信息重复，隐藏，省 17px */
  .ctrl-time-row { display: none !important; }

  .home-tab-left {
    width: 34% !important;
    max-width: 36% !important;
    max-height: calc(100vh - 138px) !important;
  }
  .home-tab-left > .ctrl-body > .ctrl-screen-area > div > div:not(.reader-style-bar) > div {
    max-height: calc(100vh - 268px) !important;
  }

  .home-tab-right { max-height: calc(100vh - 138px) !important; }

  .home-tab-right > .ctrl-sidebar-panel {
    flex: 0 0 172px !important;
    width: 172px !important;
    min-width: 172px !important;
    max-width: 172px !important;
    max-height: calc(100vh - 138px) !important;
  }
  .home-tab-right > .ctrl-sidebar-panel button {
    font-size: 10px !important;
    padding: 4px 2px !important;
  }

  #wk-panel {
    height: calc(100vh - 138px) !important;
    min-height: 340px !important;
  }
}

/* v12 收尾：彻底消掉整页滚动条（再让 14px）+ 顶栏再压一格 */
@media (min-width: 1024px) {
  .ctrl-tabs { padding: 0 !important; margin: 0 !important; }
  .ctrl-tab { height: 22px !important; line-height: 16px !important; padding: 2px 8px !important; }
  .home-tab-split { padding: 2px 6px !important; }

  .home-tab-left { max-height: calc(100vh - 152px) !important; }
  .home-tab-right { max-height: calc(100vh - 152px) !important; }
  .home-tab-right > .ctrl-sidebar-panel { max-height: calc(100vh - 152px) !important; }
  #wk-panel { height: calc(100vh - 152px) !important; }
  .home-tab-left > .ctrl-body > .ctrl-screen-area > div > div:not(.reader-style-bar) > div {
    max-height: calc(100vh - 282px) !important;
  }
}

/* =====================================================================
   v13 左侧留白回收：.home-tab-split 原本 margin-left:64px，白扔一条宽度
   去掉后整排左移 64px，右侧功能面板直接多出 64px
   ===================================================================== */
@media (min-width: 1024px) {
  .home-tab-split {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 2px 4px !important;
    box-sizing: border-box !important;
  }
  /* 头部同样对齐到最左，避免上下错位 */
  .ctrl-header {
    margin-left: 0 !important;
    padding-left: 8px !important;
  }
  .home-tab-topbar {
    margin-left: 0 !important;
    padding-left: 8px !important;
  }
}

/* =====================================================================
   键盘记录面板（右侧）—— 参考浅色卡片列表
   ===================================================================== */
.wk-keylog {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f3f4f6;
}
.wk-kl-bar {
  font-size: 12px;
  color: #6b7280;
  padding: 2px 2px 4px;
}
.wk-kl-item {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.wk-kl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.wk-kl-app {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}
.wk-kl-time {
  font-size: 11px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}
.wk-kl-pkg {
  font-size: 11px;
  color: #6b7280;
  word-break: break-all;
  margin-bottom: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.wk-kl-txt {
  font-size: 14px;
  color: #111827;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.wk-kl-tip {
  margin: auto;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.8;
}
.wk-kl-tip span { font-size: 12px; color: #9ca3af; }

.wk-kl-type {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  color: #2563eb;
  background: #e0ecff;
  border-radius: 4px;
  vertical-align: 1px;
}

/* 顶栏屏幕状态徽章 */
.wk-screen-badge .topbar-label { color: #8892a6 !important; }
.wk-screen-badge .wk-screen-val { font-variant-numeric: tabular-nums; }

/* ===== 设备列表：屏幕状态徽章 ===== */
.wk-scr {
  display: inline-block;
  margin: 0 6px 0 8px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, .06);
  white-space: nowrap;
}

/* ===== 设备列表：安装日期筛选 ===== */
.wk-date-wrap { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }
.wk-date-label { font-size: 12px; color: #8892a6; white-space: nowrap; }
.wk-date-input {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #cfd8e3;
  border-radius: 6px;
  font-size: 12px;
  padding: 4px 8px;
  color-scheme: dark;
}
.wk-date-input::-webkit-calendar-picker-indicator { filter: invert(.8); cursor: pointer; }
.wk-date-clear {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .12);
  color: #8892a6;
  border-radius: 6px;
  font-size: 11px;
  padding: 3px 7px;
  cursor: pointer;
}
.wk-date-clear:hover { color: #e6eefc; border-color: rgba(255, 255, 255, .3); }

/* ===== 自建日历面板 ===== */
.wk-date-wrap { position: relative; display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; }
.wk-date-label { font-size: 12px; color: #8892a6; white-space: nowrap; }
.wk-date-btn {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  color: #cfd8e3;
  border-radius: 6px;
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
  min-width: 96px;
  text-align: left;
}
.wk-date-btn:hover { border-color: rgba(255,255,255,.3); }
.wk-date-btn.active { color: #4da3ff; border-color: #4da3ff; }
.wk-date-clear {
  background: transparent; border: 1px solid rgba(255,255,255,.12);
  color: #8892a6; border-radius: 6px; font-size: 11px; padding: 3px 7px; cursor: pointer;
}
.wk-date-clear:hover { color: #e6eefc; border-color: rgba(255,255,255,.3); }

.wk-cal {
  position: absolute;
  top: 34px; left: 0;
  z-index: 9999;
  width: 248px;
  background: #1b2330;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  padding: 8px;
  color: #cfd8e3;
  font-size: 12px;
}
.wk-cal[hidden] { display: none !important; }
.wk-cal-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 8px; }
.wk-cal-title { font-weight: 600; font-size: 13px; }
.wk-cal-nav {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: #cfd8e3; border-radius: 6px; width: 24px; height: 24px; cursor: pointer; line-height: 1;
}
.wk-cal-nav:hover { background: rgba(255,255,255,.12); }
.wk-cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; color: #7d8aa0; font-size: 11px; padding-bottom: 4px; }
.wk-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.wk-cal-empty { height: 28px; }
.wk-cal-day {
  height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; cursor: pointer; color: #cfd8e3;
}
.wk-cal-day:hover { background: rgba(77,163,255,.18); }
.wk-cal-day.today { color: #4da3ff; font-weight: 700; }
.wk-cal-day.sel { background: #4da3ff; color: #fff; font-weight: 700; }
.wk-cal-foot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 6px; }
.wk-cal-foot button {
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: #cfd8e3; border-radius: 6px; font-size: 11px; padding: 4px 9px; cursor: pointer;
}
.wk-cal-foot button:hover { background: rgba(255,255,255,.12); }

/* 日期筛选隐藏（用 class，避免内联 style 被 React 覆盖抖动） */
.wk-hidden { display: none !important; }

/* 注入数量徽章 */
.wk-inj {
  display: inline-block;
  margin: 0 6px;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #c084fc;
  background: rgba(168, 85, 247, .16);
  border: 1px solid rgba(168, 85, 247, .35);
  white-space: nowrap;
  cursor: help;
}
.wk-inj-zero {
  color: #6b7280 !important;
  background: rgba(255, 255, 255, .04) !important;
  border-color: rgba(255, 255, 255, .08) !important;
}

/* 支付/银行类应用徽章 */
.wk-pay {
  display: inline-block;
  margin: 0 6px;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  background: rgba(52, 211, 153, .14);
  border: 1px solid rgba(52, 211, 153, .32);
  white-space: nowrap;
  cursor: help;
}

/* 顶栏「自动允许」开关 */
.wk-aa-btn {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #8892a6;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-width: 72px;
  white-space: nowrap;
}
.wk-aa-btn:hover { border-color: rgba(255, 255, 255, .3); }
.wk-aa-btn:disabled { opacity: .6; cursor: default; }
