/* ── App Shell：Launcher + 独立 App 全屏模式 ──
 *
 * 约定：
 * - body.mode-launcher  主页九宫格
 * - body.mode-appt      约单系统（唯一保留 .layout）
 * - body.mode-<appId>   其它独立 App（自动隐藏 .layout）
 *
 * 新增 shell 类独立 App 时：
 * 1. registry 里 id 填 appId → setBodyMode 会加 mode-<appId>
 * 2. HTML 根节点用 class="app-page"，id 自定
 * 3. open() 里 cancel hidden；close() 设回 hidden
 * 4. 不需要再往本文件追加 body.mode-xxx .layout 白名单
 */

body:not(.mode-launcher) .app-launcher { display: none; }

/* 除约单外：任何 mode-* 都隐藏约单 .layout（含 launcher / 装机 / 掌上运维…） */
body.mode-launcher .layout,
body[class*="mode-"]:not(.mode-appt) .layout {
  display: none !important;
}

/* 带 [hidden] 的壳一律不显示（压过桌面端全局 display:block） */
.app-page[hidden] {
  display: none !important;
}

/* 独立 shell App（非约单 / 非 launcher）：body 锁滚动，壳全屏滚动 */
body[class*="mode-"]:not(.mode-appt):not(.mode-launcher):not(.mode-knowledge):not(.mode-memo):not(.mode-worklog) {
  overflow: hidden !important;
  height: 100% !important;
}
body[class*="mode-"]:not(.mode-appt):not(.mode-launcher) .app-page:not([hidden]) {
  display: block !important;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--clr-muted, #f8fafc);
  box-sizing: border-box;
}

/* 装机看板：flex 列 + 内部结构滚动 */
body.mode-installBoard #install-board-app {
  display: flex !important;
  flex-direction: column;
}
body.mode-installBoard #ib-board-home,
body.mode-installBoard #ib-worker-page {
  flex: 0 0 auto;
  width: 100%;
  min-height: min-content;
}

/* 知识库/备忘录/工作日志：modal 变全屏页（它们不用 .app-page） */
body.mode-knowledge #kg-mask,
body.mode-memo #notes-mask,
body.mode-worklog #work-report-mask {
  background: var(--bg, var(--clr-muted)); padding: 0; align-items: stretch;
}
body.mode-knowledge #kg-mask > .modal-dialog,
body.mode-memo #notes-mask > .modal-dialog,
body.mode-worklog #work-report-mask > .modal {
  width: 100%; max-width: 100%; max-height: 100vh; max-height: 100dvh;
  border-radius: 0; box-shadow: none; height: 100%;
}
body.mode-knowledge #kg-mask .modal-head,
body.mode-memo #notes-mask .modal-head,
body.mode-worklog #work-report-mask .modal-head {
  padding-top: 14px; padding-left: 56px;
}
body.mode-knowledge #kg-mask .modal-close,
body.mode-memo #notes-mask .modal-close,
body.mode-worklog #work-report-mask .modal-close,
body.mode-knowledge #kg-tree-mask .modal-close,
body.mode-knowledge #kg-detail-mask .modal-close {
  display: none;
}
body.mode-knowledge #kg-tree-mask,
body.mode-knowledge #kg-detail-mask,
body.mode-knowledge #kg-edit-mask,
body.mode-memo #note-edit-mask {
  background: var(--bg, var(--clr-muted)); padding: 0; align-items: stretch;
}
body.mode-knowledge #kg-tree-mask > .modal-dialog,
body.mode-knowledge #kg-detail-mask > .modal-dialog,
body.mode-knowledge #kg-edit-mask > .modal-dialog,
body.mode-memo #note-edit-mask > .modal-dialog {
  width: 100%; max-width: 100%; max-height: 100vh; max-height: 100dvh;
  border-radius: 0; box-shadow: none; height: 100%;
}
@media (min-width: 960px) {
  body.mode-knowledge #kg-mask > .modal-dialog,
  body.mode-memo #notes-mask > .modal-dialog,
  body.mode-knowledge #kg-tree-mask > .modal-dialog,
  body.mode-knowledge #kg-detail-mask > .modal-dialog,
  body.mode-knowledge #kg-edit-mask > .modal-dialog,
  body.mode-memo #note-edit-mask > .modal-dialog,
  body.mode-worklog #work-report-mask > .modal {
    max-width: 800px; margin: 0 auto; border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow-lg); height: auto; max-height: calc(100vh - 60px); margin-top: 30px;
  }
}

/* 返回 Launcher 按钮 */
.back-to-launcher {
  width: 100%; box-sizing: border-box;
  background: transparent; border: none; border-radius: 8px;
  padding: 7px 12px; font-size: 13px; color: var(--clr-muted-fg);
  cursor: pointer; display: flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s;
  margin-bottom: 4px;
}
.back-to-launcher:hover { background: var(--bg-hover, hsl(var(--accent))); color: var(--clr-fg); }

/* 独立 App 挂在 body 上时：固定左上角（约单 layout 已隐藏） */
body[class*="mode-"]:not(.mode-appt):not(.mode-launcher) > .back-to-launcher {
  position: fixed; top: 12px; left: 12px; z-index: 8500;
  width: auto; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border: 1px solid var(--clr-border); border-radius: 999px;
  padding: 6px 16px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
  margin-bottom: 0;
}
@media (max-width: 959px) {
  .back-to-launcher {
    position: fixed; top: 12px; left: 12px; z-index: 8500;
    width: auto; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
    border: 1px solid var(--clr-border); border-radius: 999px;
    padding: 6px 16px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-bottom: 0;
  }
  .back-to-launcher:hover { background: var(--clr-card); }
}

/* 掌上运维：左侧装维 Tab + 右侧工区 */
.zsyw-multi-page {
  padding: 0 !important;
  background: #f1f5f9 !important;
}
.zsyw-layout {
  display: flex;
  height: 100%;
  min-height: 100dvh;
}
.zsyw-side {
  width: 260px;
  flex: 0 0 260px;
  border-right: 1px solid #e2e8f0;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.zsyw-side-head {
  padding: 48px 12px 10px;
  border-bottom: 1px solid #f1f5f9;
  flex: 0 0 auto;
}
.zsyw-tabs {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 12px;
  -webkit-overflow-scrolling: touch;
}
.zsyw-side-foot {
  padding: 10px;
  border-top: 1px solid #f1f5f9;
  flex: 0 0 auto;
}
.zsyw-tab-branch {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  padding: 10px 8px 4px;
  letter-spacing: .04em;
}
.zsyw-tab {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  margin-bottom: 2px;
}
.zsyw-tab:hover { background: #f8fafc; }
.zsyw-tab.active {
  background: #eff6ff;
  border-color: #bfdbfe;
}
.zsyw-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 5px; flex: 0 0 auto;
}
.zsyw-tab-body { min-width: 0; flex: 1; }
.zsyw-tab-name {
  display: block; font-size: 13px; font-weight: 600; color: #0f172a;
}
.zsyw-tab-sub {
  display: block; font-size: 11px; color: #94a3b8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.zsyw-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.zsyw-main-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.zsyw-main-work {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.zsyw-work-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 48px 16px 12px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.zsyw-orders-list {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 24px;
}
.zsyw-need-login {
  text-align: center;
  padding: 40px 16px;
  background: #fff;
  border-radius: 10px;
  border: 1px dashed #cbd5e1;
}
.zsyw-need-login p { margin: 0 0 8px; }
.zsyw-need-login .btn { margin-top: 12px; }
@media (max-width: 720px) {
  .zsyw-layout { flex-direction: column; }
  .zsyw-side {
    width: 100%; flex: 0 0 auto;
    max-height: 38vh;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }
  .zsyw-side-head { padding-top: 48px; }
}
