/* ============================================================
   서식 공통 — 모바일 화면 대응 + 인쇄 최적화
   (화면에서는 폰 폭에 맞추고, 인쇄할 때는 A4 원본 그대로)
   ============================================================ */

/* 표 가로 스크롤 래퍼 — _forms.js 가 모든 table 을 이걸로 감쌈 */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 상단 도구막대 (인쇄 버튼) */
#fbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: #fff; border-bottom: 1px solid #dde2e7;
  padding: 9px 12px; margin: -14px -14px 12px;
  font-family: -apple-system, BlinkMacSystemFont, "맑은 고딕", "Malgun Gothic", sans-serif;
}
#fbar button {
  font-family: inherit; font-size: 14px; font-weight: 600; padding: 10px 15px;
  border-radius: 8px; border: 1px solid #1f5f8b; background: #1f5f8b; color: #fff; cursor: pointer;
}
#fbar button.sec { background: #fff; color: #1f5f8b; }
#fbar .st { font-size: 12.5px; color: #666; }
#fbar .st b { color: #1c6b2f; }

/* 저장 안내 토스트 */
#ftoast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: rgba(20,20,20,.9); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13.5px; z-index: 999; opacity: 0; transition: opacity .25s; pointer-events: none;
  font-family: -apple-system, BlinkMacSystemFont, "맑은 고딕", sans-serif;
}
#ftoast.on { opacity: 1; }

/* ---------- 폰·태블릿 화면 ---------- */
@media screen and (max-width: 820px) {
  body { padding: 14px 14px 30px !important; font-size: 13px !important; }
  .sheet, .post { max-width: 100% !important; padding: 12px !important; border-radius: 8px; }

  /* 표는 최소 폭을 지켜 좌우로 밀어 보게 한다 (칸이 뭉개지는 것보다 낫다) */
  .tw > table { min-width: 660px; }
  .tw.wide > table { min-width: 900px; }

  /* 입력칸을 손가락으로 누를 수 있는 크기로 */
  input[type=text], input[type=number] {
    font-size: 15px !important; padding: 7px 4px !important;
    min-height: 34px; background: #fbfcfd;
  }
  textarea { font-size: 14px !important; min-height: 90px; }
  input[type=checkbox] { width: 20px; height: 20px; }

  h1 { font-size: 17pt !important; }
  .imgbox { height: 150px !important; }
}

/* 아주 좁은 화면 */
@media screen and (max-width: 420px) {
  #fbar { padding: 8px 10px; margin: -14px -14px 10px; }
  #fbar button { flex: 1; padding: 11px 8px; font-size: 13.5px; }
  #fbar .st { width: 100%; }
}

/* ---------- 인쇄 : 화면용 장치를 전부 걷어내고 A4 원본으로 ---------- */
@media print {
  #fbar, #ftoast, .noprint { display: none !important; }
  .tw { overflow: visible !important; }
  .tw > table { min-width: 0 !important; }
  body { padding: 0 !important; background: #fff !important; }
  .sheet, .post { max-width: none !important; padding: 0 !important; box-shadow: none !important; }
  /* 표가 페이지 경계에서 잘리지 않게 */
  tr, .spot, .slot { page-break-inside: avoid; }
  thead { display: table-header-group; }
}
