/* ============================================================
   v2 print (카드 T1) — 인쇄 6종 : 일보 · 노무대장 · 자금청구서(개별/통합) · 주간보고 · 사진 대지 · 장비 가동집계

   ① 셸 인쇄 (@media print)  — 앱 화면을 그대로 Ctrl+P 할 때: 사이드바·상단바·탭바·모달 숨김, 본문만 흐름으로.
   ② 문서 스킨 (최상위 규칙)   — 옛 print 함수들이 window.open 새 창에 쓰는 자체 style 태그 HTML 위에 덧씌우는 공통 규칙.
        새 창 문서에는 <html data-theme>이 없으므로 :root:not([data-theme]) 로 앱 화면과 분리한다.
        인라인 style="" 이 셀마다 박혀 있어서 !important 로만 덮을 수 있다.
        js/ui/print-skin.js 의 uiPrintSkinCss()가 이 파일 전체를 문자열로 돌려주고, 인쇄 HTML 쪽에서 style 태그 안에 넣는다.
   색은 인쇄 전용 --print-* 변수만 쓴다 (화면 토큰은 다크에서 값이 바뀌므로 종이에는 쓰지 않는다).
   ============================================================ */
:root {
  --print-paper: #ffffff;
  --print-ink:   #111111;
  --print-mute:  #555555;
  --print-line:  #333333;   /* 표 선 0.5pt */
  --print-head:  #f3f3f3;   /* 머리행·라벨 칸 */
}

@page { margin: 12mm; }     /* size 는 각 문서가 정한다 (노무대장·장비집계 = A4 가로, 나머지 = A4 세로) */

/* ── ② 문서 스킨 ─────────────────────────────────────── */
:root:not([data-theme]) body {
  margin: 0 !important; padding: 0 !important;
  background: var(--print-paper) !important;
  color: var(--print-ink) !important;
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif !important;
  font-size: 10.5pt;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
:root:not([data-theme]) body > div[style*="padding:24px"] { padding: 0 !important; }   /* 자금청구서 바깥 래퍼 */

/* 표 — 선 0.5pt · 본문 10pt */
:root:not([data-theme]) body table { border-collapse: collapse; }
:root:not([data-theme]) body :is(td, th) {
  border: .5pt solid var(--print-line) !important;
  padding: 3px 6px !important;
  font-size: 10pt !important;
  line-height: 1.4;
  vertical-align: middle;
}
:root:not([data-theme]) body th,
:root:not([data-theme]) body td[style*="background:#f5f5f5"] {
  background: var(--print-head) !important;
  color: var(--print-ink) !important;
  font-weight: 700;
}
/* 바깥 테두리가 굵게 지정된 표(본표) */
:root:not([data-theme]) body table[style*="border:1.2px"],
:root:not([data-theme]) body table[style*="border:1.5px"] { border: 1pt solid var(--print-line) !important; }
/* 합계행 — 굵게 + 위쪽 선 1pt */
:root:not([data-theme]) body tr[style*="font-weight:700"] > td {
  border-top: 1pt solid var(--print-line) !important;
  background: var(--print-head) !important;
  font-weight: 700;
}
/* 열이 많은 표(노무대장 공제 포함 15열) — 열 폭이 th width 합 + 칸 여백으로 넘쳐 '직종/소속' 칸이 한 글자 폭으로 찌그러지던 것을 막는다 */
:root:not([data-theme]) body table:has(> thead > tr > th:nth-child(12)) :is(td, th) {
  padding: 3px 2px !important;
  font-size: 9pt !important;
}
/* 결재란(작성·검토·승인) — 서명 칸은 높이를 지킨다 */
:root:not([data-theme]) body td[style*="height:44px"],
:root:not([data-theme]) body td[style*="height:40px"],
:root:not([data-theme]) body td[style*="height:34px"] { padding: 0 !important; }

/* 보조 글자(회색) 통일 */
:root:not([data-theme]) body [style*="color:#666"],
:root:not([data-theme]) body [style*="color:#555"],
:root:not([data-theme]) body [style*="color:#888"],
:root:not([data-theme]) body [style*="color:#444"],
:root:not([data-theme]) body [style*="color:#333"] { color: var(--print-mute) !important; }

/* 사진 대지 칸 */
:root:not([data-theme]) body div[style*="break-inside:avoid"] { border: .5pt solid var(--print-line) !important; }
:root:not([data-theme]) body img { max-width: 100%; }

/* 쪽 나눔 — 행·사진 칸은 쪼개지 않고, 머리행은 쪽마다 반복 */
:root:not([data-theme]) body tr { page-break-inside: avoid; break-inside: avoid; }
:root:not([data-theme]) body thead { display: table-header-group; }
:root:not([data-theme]) body tfoot { display: table-footer-group; }
:root:not([data-theme]) body :is(h1, h2, h3) { page-break-after: avoid; break-after: avoid; }

/* ── ① 셸 인쇄 ──────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .m-header, .tabbar, .fab, .toast, .modal-bg, .guest-bar,
  #uiStatusHost, #uiSidebar, #uiTabbar, .section-jump, .month-picker, .btn, .pc-only { display: none !important; }
  .app { display: block !important; }
  .app-main, .app-content { padding: 0 !important; min-width: 0; }

  /* 다크 테마 화면을 인쇄할 때는 js/ui/print-skin.js 가 beforeprint 에서 data-theme 을 light 로 잠깐 바꾼다 */
  body { background: var(--print-paper) !important; color: var(--print-ink) !important; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
}
