/* ============================================================
   Factory Manager - 한국형 ERP 디자인 토큰
   ============================================================ */

:root {
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.04), 0 1px 3px 0 rgb(0 0 0 / 0.06);
  --shadow-hover: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.04);
}

/* 설계 프로젝트 상세대장: 조회 레이블·값·편집 필드의 역할을 즉시 식별 */
.fm-project-detail dt,
.fm-project-detail article .text-xs.text-slate-500,
.fm-project-detail article span.block.text-xs.text-slate-500 {
  color: rgb(71 85 105);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1rem;
  letter-spacing: 0.015em;
}
.dark .fm-project-detail dt,
.dark .fm-project-detail article .text-xs.text-slate-500,
.dark .fm-project-detail article span.block.text-xs.text-slate-500 {
  color: rgb(148 163 184);
}
.fm-project-detail dd {
  color: rgb(15 23 42);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5rem;
}
.dark .fm-project-detail dd { color: rgb(241 245 249); }
.fm-project-detail label {
  color: rgb(51 65 85);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.dark .fm-project-detail label { color: rgb(203 213 225); }
.fm-project-detail label > input,
.fm-project-detail label > textarea {
  margin-top: 0.375rem;
  border-color: rgb(148 163 184);
  background: rgb(248 250 252);
  color: rgb(15 23 42);
  font-size: 0.875rem;
  font-weight: 500;
}
.fm-project-detail label > input:focus,
.fm-project-detail label > textarea:focus {
  border-color: rgb(37 99 235);
  background: rgb(255 255 255);
}
.dark .fm-project-detail label > input,
.dark .fm-project-detail label > textarea {
  border-color: rgb(71 85 105);
  background: rgb(15 23 42);
  color: rgb(241 245 249);
}
.dark .fm-project-detail label > input:focus,
.dark .fm-project-detail label > textarea:focus {
  border-color: rgb(96 165 250);
  background: rgb(2 6 23);
}

html.dark {
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / 0.3), 0 1px 3px 0 rgb(0 0 0 / 0.2);
  --shadow-hover: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

* {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'tnum';
}

/* ─── 숫자 균등폭 (회계/금액 표시) ─── */
.tabular-nums { font-feature-settings: 'tnum' 1; font-variant-numeric: tabular-nums; }

/* ─── 스크롤바 ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.6); }
.dark ::-webkit-scrollbar-thumb { background: rgba(71, 85, 105, 0.5); }
.dark ::-webkit-scrollbar-thumb:hover { background: rgba(71, 85, 105, 0.8); }

/* ─── KPI 카드 hover ─── */
.kpi-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: var(--shadow-card);
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* ─── 차트 컨테이너 ─── */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}
.chart-container-sm {
  position: relative;
  width: 100%;
  height: 220px;
}

/* ─── 페이지 전환 부드럽게 ─── */
[x-cloak] { display: none !important; }

/* ─── 데이터 테이블 행 호버 ─── */
.data-row {
  transition: background-color 0.15s ease;
}
.data-row:hover {
  background-color: rgb(248 250 252);
}
.dark .data-row:hover {
  background-color: rgb(15 23 42);
}

/* ─── 사이드바 nav 활성 표시 좌측 보더 ─── */
.nav-item-active {
  position: relative;
}
.nav-item-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: rgb(37 99 235);
  border-radius: 0 2px 2px 0;
}
.dark .nav-item-active::before {
  background: rgb(59 130 246);
}

/* ─── 그라데이션 배경 (헤더 강조용) ─── */
.bg-gradient-mesh {
  background:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.06) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.06) 0px, transparent 50%);
}
.dark .bg-gradient-mesh {
  background:
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
}

/* ─── 진행률 바 애니메이션 ─── */
@keyframes progress-fill {
  from { width: 0; }
  to { width: var(--progress); }
}
.progress-bar {
  animation: progress-fill 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ─── 스켈레톤 로딩 (옵션) ─── */
@keyframes pulse {
  50% { opacity: 0.5; }
}
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: pulse 1.5s ease-in-out infinite;
}
.dark .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
}

/* ─── 알림 점 펄스 ─── */
@keyframes ping-pulse {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}
.notification-dot {
  position: relative;
}
.notification-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgb(239 68 68);
  animation: ping-pulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* ─── 모바일 반응형 (UX-6) ─── */
@media (max-width: 768px) {
  .chart-container { height: 240px; }
  .chart-container-sm { height: 180px; }
}

/* 모바일에서 사이드바를 오버레이로 (작은 화면) */
@media (max-width: 1023px) {
  .fm-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 256px !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }
  .fm-sidebar.fm-sidebar-open {
    transform: translateX(0);
  }
  .fm-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
  }
  .dark .fm-sidebar-backdrop { background: rgba(0, 0, 0, 0.6); }
}

/* 모바일에서 테이블을 카드처럼 (옵션) */
@media (max-width: 640px) {
  .fm-mobile-stack-cells td,
  .fm-mobile-stack-cells th {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem;
  }
  .fm-mobile-hide-md { display: none !important; }
}

/* 다이얼로그 모바일 풀스크린 */
@media (max-width: 640px) {
  .fm-dialog-mobile-full > div[class*="max-w-"] {
    max-width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
}

/* ─── 모바일/태블릿 우선 플랫폼 (대장님 명령) ─── */
@media (max-width: 1024px) {
  /* 모든 폼 요소 44px 보장 (iOS Safari 자동 줌 방지 위해 16px font) */
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="date"], input[type="tel"],
  input[type="search"], select, textarea {
    min-height: 44px !important;
    font-size: 16px !important;
  }
  /* 모든 버튼 44px (iOS HIG) */
  button, [role="button"], a.btn, .fm-touch-target {
    min-height: 44px;
  }
  /* 다이얼로그 풀스크린 모드 (모바일/태블릿) */
  [x-show*="open"][class*="fixed inset-0"] > div[class*="max-w-"] {
    max-width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  /* sticky footer 다이얼로그 (모바일에서 풀스크린 시 footer 항상 보이게) */
  [x-show*="open"] > div[class*="max-w-"] > div:last-child {
    position: sticky;
    bottom: 0;
    background: inherit;
    border-top: 1px solid rgba(148,163,184,0.2);
    box-shadow: 0 -4px 8px rgba(0,0,0,0.05);
  }
  /* 페이지 콘텐츠 하단 여백 (사파리 홈 인디케이터) */
  main { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 768px) {
  /* 액션 버튼 (저장/전송 등 주요 CTA) 더 큰 터치 영역 */
  button[type="submit"],
  .fm-cta-mobile {
    min-height: 48px;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    font-size: 0.95rem;
  }
  /* 테이블 셀 좌우 스와이프 hint */
  .overflow-x-auto::-webkit-scrollbar { height: 4px; }
  /* 모달 footer 항상 하단 고정 (긴 폼) */
  [x-show*="open"] > div > div:last-child {
    position: sticky;
    bottom: 0;
    background: inherit;
  }
}

/* 모바일 카드 list 패턴 — 페이지에서 x-show로 분기 사용 */
.fm-mobile-card {
  background: white;
  border: 1px solid rgb(226 232 240);
  border-radius: 0.75rem;
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.dark .fm-mobile-card {
  background: rgb(15 23 42);
  border-color: rgb(30 41 59);
}
.fm-mobile-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.8125rem;
}
.fm-mobile-card-row:not(:last-child) {
  border-bottom: 1px dashed rgb(226 232 240);
}
.dark .fm-mobile-card-row:not(:last-child) {
  border-bottom-color: rgb(30 41 59);
}
.fm-mobile-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgb(100 116 139);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.dark .fm-mobile-card-label { color: rgb(148 163 184); }

/* ─── 인쇄 레이아웃 (UX-7) ─── */
@media print {
  /* 비주얼/네비 요소 모두 숨김 */
  aside, header, footer, .fm-sidebar, .fm-sidebar-backdrop,
  button, .fm-no-print, [class*="fixed"],
  .fm-tip-icon, [data-lucide]:not(.fm-print-show) {
    display: none !important;
  }
  /* 본문은 흰 배경 */
  body, html, .dark body, .dark html {
    background: white !important;
    color: black !important;
    font-size: 10pt;
  }
  main, section, .max-h-\[500px\], .max-h-\[600px\], .overflow-y-auto, .overflow-x-auto {
    max-height: none !important;
    overflow: visible !important;
  }
  /* 카드 보더 강조 */
  .kpi-card, .bg-white, .bg-slate-900, .bg-slate-50, .bg-slate-800\/40 {
    background: white !important;
    color: black !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  /* 테이블 인쇄 친화적 */
  table { border-collapse: collapse !important; width: 100% !important; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  th, td { border: 1px solid #94a3b8 !important; padding: 4px 6px !important; }
  th {
    background: #e2e8f0 !important;
    color: black !important;
    font-weight: bold !important;
  }
  /* 차트는 인쇄에서 숨김 (이미지 캡처는 스크린샷으로) */
  .chart-container, canvas { display: none !important; }
  /* 인쇄 시 빈 페이지 방지 */
  section { page-break-before: auto; }
  h1 { font-size: 16pt !important; margin: 0 0 8pt 0 !important; }
  h3 { font-size: 12pt !important; margin: 8pt 0 4pt 0 !important; }
  /* 인쇄 헤더 (페이지 상단) */
  .fm-print-header { display: block !important; margin-bottom: 12pt; padding-bottom: 6pt; border-bottom: 2px solid black; }
  /* URL 노출 안 함 */
  a[href]::after { content: '' !important; }
}
.fm-print-header { display: none; }

/* ─── 타임존 배지 (UX-7) ─── */
.fm-tz-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.1);
  color: rgb(37 99 235);
  font-weight: 600;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.02em;
}
.dark .fm-tz-badge {
  background: rgba(59, 130, 246, 0.15);
  color: rgb(96 165 250);
}

/* ─── 빈 상태 (Empty State, UX-2) ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  min-height: 320px;
}
.empty-state-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(168,85,247,0.08) 100%);
  border: 2px dashed rgba(148, 163, 184, 0.4);
}
.dark .empty-state-icon {
  background: linear-gradient(135deg, rgba(59,130,246,0.12) 0%, rgba(168,85,247,0.12) 100%);
  border-color: rgba(71, 85, 105, 0.6);
}
.empty-state-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.empty-state-message {
  font-size: 0.875rem;
  color: rgb(100 116 139);
  margin-bottom: 1.5rem;
  max-width: 28rem;
  line-height: 1.6;
}
.dark .empty-state-message { color: rgb(148 163 184); }
.empty-state-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  background: rgb(248 250 252);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: rgb(71 85 105);
  text-align: left;
}
.dark .empty-state-steps { background: rgb(15 23 42 / 0.5); color: rgb(203 213 225); }
.empty-state-steps li { display: flex; gap: 0.5rem; }
.empty-state-steps b { color: rgb(37 99 235); }
.dark .empty-state-steps b { color: rgb(96 165 250); }

/* ─── 도움말 툴팁 (UX-4) ─── */
.fm-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.fm-tip-icon {
  width: 14px; height: 14px;
  color: rgb(148 163 184);
  cursor: help;
  transition: color 0.15s;
}
.fm-tip:hover .fm-tip-icon { color: rgb(59 130 246); }
.fm-tip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgb(15 23 42);
  color: rgb(241 245 249);
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 50;
}
.fm-tip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgb(15 23 42);
}
.fm-tip:hover .fm-tip-content { opacity: 1; }
.fm-tip-content b { color: rgb(125 211 252); font-weight: 600; }
.fm-tip-content code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
}

/* ─── 종합 리포트 인쇄 (ADD-11) ─── */
.fm-report-print { box-sizing: border-box; }
@media print {
  body.report-print-active > * { display: none !important; }
  body.report-print-active .fm-report-print {
    display: block !important;
    position: static !important;
    background: white !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100% !important;
    font-size: 10pt;
  }
  body.report-print-active .fm-report-print * { visibility: visible !important; }
  body.report-print-active .fm-report-print h1 { font-size: 18pt !important; }
  body.report-print-active .fm-report-print h2 { font-size: 12pt !important; margin: 14pt 0 6pt 0 !important; page-break-after: avoid; }
  body.report-print-active .fm-report-print table { page-break-inside: avoid; }
  body.report-print-active .fm-report-print thead { display: table-header-group; }
  @page { margin: 14mm; size: A4; }
}

/* ─── 작업지시서 인쇄 (ADD-3) ─── */
.fm-wo-print {
  display: none;
}
body.wo-print-active .fm-wo-print {
  display: block !important;
}
@media print {
  /* 작업지시서 인쇄 모드: 모든 본문 숨기고 지시서만 표시 */
  body.wo-print-active > * { display: none !important; }
  body.wo-print-active .fm-wo-print {
    display: block !important;
    position: static !important;
    background: white !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 10pt;
  }
  body.wo-print-active .fm-wo-print * {
    visibility: visible !important;
  }
  /* 80mm 감열지 모드 */
  body.wo-print-thermal .fm-wo-print {
    width: 72mm;
    font-size: 9pt;
    line-height: 1.35;
  }
  body.wo-print-thermal .fm-wo-print .fm-wo-letter-only { display: none !important; }
  body.wo-print-thermal .fm-wo-print h1 { font-size: 12pt !important; }
  body.wo-print-thermal .fm-wo-print h2 { font-size: 10pt !important; }
  body.wo-print-thermal .fm-wo-print table { font-size: 8pt; }
  /* A4 모드 (사무실용) */
  body.wo-print-active:not(.wo-print-thermal) .fm-wo-print { width: 100%; }
  body.wo-print-active:not(.wo-print-thermal) .fm-wo-print .fm-wo-thermal-only { display: none !important; }
  /* 페이지 설정 — A4 기본 */
  @page { size: A4; margin: 14mm; }
  body.wo-print-thermal { @page: thermal; }
  @page thermal { size: 80mm auto; margin: 4mm; }
}
.fm-wo-print { box-sizing: border-box; }
.fm-wo-print .wo-stage-row { page-break-inside: avoid; }
.fm-wo-sign-box {
  display: inline-block;
  border-bottom: 1px solid #475569;
  min-width: 80px;
  height: 28px;
  vertical-align: bottom;
}

/* 서식 입력기(Rich Editor) — 2026-08-02.
   contenteditable 에는 placeholder 속성이 없어 :empty 로 만든다.
   ⚠ 비어 있어도 브라우저가 <br> 을 남기는 경우가 있어 :empty 만으로는 부족하다 —
     그래서 richSync 가 빈 내용을 감지하면 innerHTML 을 비워 :empty 가 성립하게 한다. */
.fm-rich:empty::before { content: attr(data-ph); color: #94a3b8; pointer-events: none; }
.fm-rich ul { list-style: disc; padding-left: 1.25rem; margin: 0.25rem 0; }
.fm-rich ol { list-style: decimal; padding-left: 1.25rem; margin: 0.25rem 0; }
.fm-rich li { margin: 0.1rem 0; }
.fm-rich b, .fm-rich strong { font-weight: 700; }
/* 저장된 회의록 표시용 — 입력기와 같은 서식으로 보여야 "쓴 대로 보인다" */
.fm-rich-view ul { list-style: disc; padding-left: 1.1rem; }
.fm-rich-view ol { list-style: decimal; padding-left: 1.1rem; }
.fm-rich-view b, .fm-rich-view strong { font-weight: 700; }

/* ─────────────────────────────────────────────────────────────
   시스템 탭 바 — 알약(pill) 스타일 (2026-08-19, 대장님 지시)
   탭 18개가 밑줄 스타일로 3줄 wrap 되면 줄바꿈 지점에서 경계가 사라져
   "어디까지가 한 탭인지" 를 못 읽는다. 버튼 18개를 각각 고치지 않고
   컨테이너 한 클래스로 자식 button 을 일괄 제어한다(향후 탭 추가 시 자동 적용).
   ⚠ 순수 표현(presentation)만 바꾼다 — 업종·권한 로직에는 손대지 않는다.
   ───────────────────────────────────────────────────────────── */
.fm-systab > button {
  border-bottom-width: 0 !important;
  border-radius: 0.5rem;
  padding: 0.45rem 0.8rem;
  line-height: 1.25rem;
  white-space: nowrap;
  /* 이모지와 글자가 붙어 보이던 문제 — 이모지 뒤 여백을 문자 단위로 준다 */
  word-spacing: 0.15em;
}
.fm-systab > button:hover { background: rgb(255 255 255 / .75); }
.dark .fm-systab > button:hover { background: rgb(30 41 59 / .75); }
/* 활성 탭 — 밑줄 대신 채움. Alpine 이 붙이는 border-blue-600 를 그대로 신호로 쓴다 */
.fm-systab > button.border-blue-600 {
  background: #fff;
  box-shadow: 0 1px 2px rgb(15 23 42 / .08), 0 0 0 1px rgb(37 99 235 / .35);
  font-weight: 700;
}
.dark .fm-systab > button.border-blue-600 {
  background: rgb(15 23 42);
  box-shadow: 0 1px 2px rgb(0 0 0 / .4), 0 0 0 1px rgb(96 165 250 / .45);
}

/* 사이트×설계단계 매트릭스 — 셀 밀도 정돈 */
.fm-spmatrix td, .fm-spmatrix th { vertical-align: middle; }
.fm-spmatrix input[type="number"] { -moz-appearance: textfield; }
.fm-spmatrix input[type="number"]::-webkit-outer-spin-button,
.fm-spmatrix input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ─────────────────────────────────────────────────────────────
   랩탑 가독성 — 전역 폰트 스케일 (2026-08-19, 대장님 「랩탑에서 전체 화면폰트가 작음」)

   왜 작았나 — 두 가지가 겹쳤다:
     ① Tailwind 는 rem 기반이고 `html` 이 브라우저 기본 16px 이라, 화면이 커져도
        글자는 그대로다. 랩탑(1280~1680px)은 정보 밀도가 높은데 기준이 모바일과 같았다.
     ② 화면 곳곳이 `text-[10px]`·`text-[11px]` 같은 **px 고정**을 쓴다.
        이건 rem 확대의 혜택을 아예 못 받아, 배지·힌트·표 보조문구가 특히 작게 남는다.

   그래서 **둘 다** 손본다 — rem 기준을 올리고, px 고정에는 하한을 준다.
   ⚠ 순수 표현이라 업종·권한 로직과 무관하다(전 비즈모델이 같은 개선을 받는다).
   ⚠ 모바일(<1024px)은 건드리지 않는다 — 거기선 지금 크기가 맞고, 키우면 줄바꿈이 터진다.
   ───────────────────────────────────────────────────────────── */

/* 랩탑 — 13~16인치 구간. +6.25%(16→17px) */
@media (min-width: 1024px) and (max-width: 1679px) {
  html { font-size: 17px; }
}
/* 큰 데스크탑 — +12.5%(16→18px) */
@media (min-width: 1680px) {
  html { font-size: 18px; }
}

/* px 고정 텍스트 하한 — rem 확대가 닿지 않는 자리 */
@media (min-width: 1024px) {
  .text-\[9px\]  { font-size: 10.5px !important; }
  .text-\[10px\] { font-size: 11.5px !important; }
  .text-\[11px\] { font-size: 12.5px !important; }
  .text-\[12px\] { font-size: 13.5px !important; }
  /* 코드·해시 등 등폭 보조문구도 같이 */
  .font-mono.text-\[10px\], .font-mono.text-\[11px\] { letter-spacing: -0.01em; }
}

/* html 기준을 올리면 고정 px 로 잡힌 사이드바·헤더가 상대적으로 좁아 보인다 — 함께 보정 */
@media (min-width: 1024px) {
  /* 표 셀 세로 여백이 글자 크기를 못 따라가 답답해 보이던 것 완화 */
  table.fm-spmatrix td, table.fm-spmatrix th { padding-top: .55rem; padding-bottom: .55rem; }
}

/* ─────────────────────────────────────────────────────────────
   본문 좌우 흔들림 차단 (2026-08-19, 대장님 「스마트폰에서 화면의 바디부분이 좌우로
   움직이는 문제 — 특정 섹션의 내부컨텐츠가 아니라 전체바디의 좌우스크롤문제」)

   실측 — 데스크톱 뷰포트 390px·320px 로 전 화면을 훑었을 때 `scrollWidth == clientWidth`
   였다(오른쪽 넘침 0건). 사이드바는 `position: fixed` + `transform` 이라 레이아웃에
   영향을 주지 않는다. 즉 **넘치는 요소 때문이 아니다.**

   그럼 왜 움직이나 — 실기기의 **터치 오버스크롤**이다. iOS Safari·Android Chrome 은
   내용이 넘치지 않아도 손가락으로 밀면 좌우로 고무줄처럼 끌린다(그리고 그 제스처가
   브라우저의 뒤로가기 스와이프와 뒤섞인다). 데스크톱 마우스로는 재현되지 않아
   **뷰포트를 줄여 보는 것만으로는 못 잡는 자리**다.

   ⚠ `overflow-x: hidden` 이 아니라 **`clip`** 을 쓴다 — `hidden` 은 스크롤 컨테이너를
     만들어 이 앱이 여러 곳에서 쓰는 `position: sticky`(헤더·표 첫 열)를 죽인다.
     `clip` 은 컨테이너를 만들지 않아 sticky 가 살아남는다. 미지원 브라우저를 위해
     `hidden` 을 먼저 선언하고 `clip` 으로 덮는다(지원하면 뒤엣것이 이긴다).
   ⚠ 세로 오버스크롤은 건드리지 않는다 — pull-to-refresh 를 막으면 사용자가 당황한다.
   ───────────────────────────────────────────────────────────── */
html, body {
  overflow-x: hidden;          /* 폴백 */
  overflow-x: clip;            /* sticky 를 죽이지 않는 차단 */
  overscroll-behavior-x: none; /* 좌우 고무줄·스와이프 내비 차단 */
  max-width: 100%;
}
/* 넓은 표는 자기 컨테이너 안에서만 가로로 움직여야 한다(본문이 아니라) */
.overflow-x-auto { overscroll-behavior-x: contain; }

/* ─────────────────────────────────────────────────────────────
   다이얼로그 3단 껍데기 (2026-08-19, 대장님 「다른 다이얼로그도 동일적용!」)

   왜 3단인가 — 겉모양이 아니라 **행동**의 문제다:
     · 제목이 스크롤에 딸려 사라지면 사용자는 자기가 무엇을 편집 중인지 잊는다
     · [저장] 이 본문 끝에 있으면 긴 폼에서 **버튼을 찾으러** 끝까지 내려가야 한다
   헤더는 맥락을, 푸터는 행동을 붙잡아 둔다. 둘 다 스크롤 밖에 있어야 한다.

   마크업은 역할만 밝히고(`fm-dlg-head/body/foot`) 배치는 여기서 정한다 —
   다이얼로그마다 Tailwind 조합이 제각각이라 클래스를 일일이 맞추면 또 갈린다.
   ⚠ `min-height: 0` 이 없으면 flex 자식이 내용만큼 늘어나 **본문이 스크롤되지 않는다**
     (flex item 의 기본 min-height 는 auto 다 — 이 한 줄이 빠지면 3단이 무너진다).
   ───────────────────────────────────────────────────────────── */
.fm-dlg {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fm-dlg > .fm-dlg-head,
.fm-dlg > .fm-dlg-foot { flex: 0 0 auto; }
.fm-dlg > .fm-dlg-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
/* 본문 표시가 없는 다이얼로그(확인창 등)는 컨테이너 자체가 스크롤되게 — 넘침만은 막는다 */
.fm-dlg:not(:has(> .fm-dlg-body)) { overflow-y: auto; }

/* 거래대금 안의 외주계약은 바깥 본문과 분리된 스크롤 뷰포트다. */
[data-project-outsourcing-list] {
  height: min(42vh, 32rem);
  height: min(42dvh, 32rem);
  min-height: 0;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
  scroll-padding-bottom: 1rem;
}
[data-project-outsourcing-list] > article:last-child { margin-bottom: 1px; }
