/* ================================================================
   v3.5 弹窗规范：定位基准为右侧内容区，不覆盖左侧菜单
   1) 内容类弹窗：内容区内全屏，四边各留 10px
   2) 取消小尺寸例外：列表 / 表格 / 表单 / 正文 / 明细一律内容区全屏
   3) 纯确认框：内容区内水平垂直居中，小尺寸
   ================================================================ */

/* 弹窗根节点已在 .main-area 内；遮罩改为按内容区计算尺寸（JS 写入 left/top/width/height） */
#modal-root { position: static; }

.modal-mask {
  position: fixed;
  inset: auto;
  padding: 0;
  overflow: hidden;
  background: rgba(17, 24, 39, .42);
  backdrop-filter: blur(1px);
}

/* 内容类：遮罩铺满内容区，弹窗铺满遮罩 */
.modal-mask.mask-content {
  align-items: stretch;
  justify-content: flex-start;
}

/* 确认类：遮罩铺满内容区，弹窗在其中上下左右居中 */
.modal-mask.mask-confirm {
  align-items: center;
  justify-content: center;
}

.modal.full {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: none;
}

.modal.full > .modal-head,
.modal.full > .modal-foot {
  flex: 0 0 auto;
}

/* 中部独立滚动，标题栏与操作栏固定；内容不超屏时不出滚动条 */
.modal.full > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* 默认规范 / 引用明细等列表在窄内容区也不横向溢出 */
.modal.full .table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.modal.full .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.modal.full .sw-input {
  min-height: 220px;
}

/* 纯确认框 */
.modal.confirm {
  width: min(440px, 70%);
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  animation: none;
}

.modal.confirm > .modal-body {
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal.confirm > .modal-foot {
  flex: 0 0 auto;
}

/* 窄屏：仍然四边 10px，不溢出、不出横向滚动条 */
@media (max-width: 760px) {
  .modal.full .form-grid { grid-template-columns: 1fr; }
}

/* 窄屏侧栏为抽屉时，菜单必须仍可点，层级高于遮罩 */
@media (max-width: 1080px) {
  .sidebar.open { z-index: 130; }
}
