/* 대성기업 ERP 휴대폰·폴더블 공통 화면 보정 (2026-10-11)
   원칙: 내용을 숨기지 않는다. 넘치는 표는 가로로 밀어서 모두 볼 수 있게 한다. */

/* 노치·홈바 영역 피하기(앱 실행 시) */
html.m-app body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); }

/* 메인 이동 버튼 */
#m-home {
  position: fixed; z-index: 99999; left: calc(12px + env(safe-area-inset-left)); bottom: calc(14px + env(safe-area-inset-bottom));
  width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 118, 110, .9); color: #fff !important; font-size: 22px; text-decoration: none;
  box-shadow: 0 6px 18px rgba(8, 33, 59, .3); -webkit-tap-highlight-color: transparent;
}
@media print { #m-home { display: none !important; } }

/* 1024px 미만(일반폰·폴더블 펼침·소형 태블릿) */
@media screen and (max-width: 1023px) {
  /* 기존 공통 CSS의 overflow-x:hidden 때문에 넓은 표 오른쪽이 잘려 안 보이던 문제 해소 */
  html, body { overflow-x: auto !important; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  /* 표를 감싼 영역은 손가락으로 가로 스크롤 */
  .table-wrap, .grid-wrap, .list, .wrap, .sheet, .panel, .tbl-wrap, .table-container, .scroll {
    max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  /* 모달이 화면 밖으로 나가지 않게 */
  .modal .box, .modal-content, .modal-box, .modal-dialog, .modal > div {
    max-width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px); overflow: auto; box-sizing: border-box;
  }
  img, canvas, video { max-width: 100%; height: auto; }
}

/* 터치 기기: 입력칸 글자 16px(아이폰 자동확대 방지)·버튼 누르기 쉬운 크기 */
@media screen and (max-width: 1023px) {
  html.m-touch input:not([type=checkbox]):not([type=radio]), html.m-touch select, html.m-touch textarea { font-size: 16px !important; }
  html.m-touch button, html.m-touch .btn, html.m-touch .tab { min-height: 36px; }
}

/* [메뉴접기] 휴대폰 대시보드 메뉴 ☰ 접기 (되돌리기: 이 블록과 mobile.js [메뉴접기] 블록 삭제) */
#m-menu-btn { display: none; }
@media screen and (max-width: 560px) {
  html.m-has-fold .home-side { position: sticky; top: 0; z-index: 50; display: flex !important; flex-wrap: wrap; align-items: center; padding: 8px 12px !important; box-shadow: 0 2px 10px rgba(30,64,125,.08); }
  html.m-has-fold #m-menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-right: 6px; border: 1px solid #e7ecf2; border-radius: 10px; background: #fff; color: #0f766e; font-size: 20px; cursor: pointer; }
  html.m-has-fold .home-brand { padding: 0 !important; display: inline-block; width: auto !important; flex: 0 1 auto !important; text-align: left !important; }
  html.m-has-fold .home-side { flex-direction: row !important; justify-content: flex-start !important; text-align: left !important; }
  html.m-has-fold .home-side:not(.m-open) { flex-wrap: nowrap !important; }
  html.m-has-fold .home-side > :not(#m-menu-btn):not(.home-brand) { display: none !important; }
  html.m-has-fold .home-side.m-open { max-height: 100dvh; overflow-y: auto; }
  html.m-has-fold .home-side.m-open > :not(#m-menu-btn):not(.home-brand):not(.home-section):not(.home-spacer):not(.home-tree) { display: flex !important; width: 100% !important; }
  html.m-has-fold .home-side.m-open > .home-tree:not(#m-menu-btn) { display: block !important; width: 100% !important; flex: 0 0 100% !important; }
  html.m-has-fold .home-side.m-open .home-subnav { padding: 0 0 6px 30px !important; }
  html.m-has-fold .home-side.m-open .home-nav-sub { width: 100% !important; text-align: left; white-space: nowrap; }
  html.m-has-fold .home-side.m-open .home-nav { width: 100% !important; padding: 11px 10px !important; font-size: 14px; }
  html.m-has-fold .home-side.m-open .home-nav-sub { font-size: 13px; padding: 9px 8px; }
}

/* 일반폰(600px 미만): 여백 축소로 한 화면에 더 많이 */
@media screen and (max-width: 599px) {
  body > .page, body > .container, body > .app-container { padding: 10px !important; }
  main { padding: 10px !important; }
}

/* 폴더블 펼침·소형 태블릿(600~1023px): 2열 배치 유지로 더 많은 내용 */
@media screen and (min-width: 600px) and (max-width: 1023px) {
  .cards, .stat-grid, .menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .home-stats { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  main { padding: 14px !important; }
}
