:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff; /* 카드/표/입력창 등 "면" 배경 — 페이지 배경(--bg)과 구분해서 다크모드에서 따로 톤을 준다 */
  --text: #1e293b;
  --muted: #64748b;
  --danger: #dc2626;
  /* 상태 배지/진행 카드용 강조색 — 진행중/취소는 --primary/--danger를 그대로 쓰고, 나머지 상태만
     별도 색을 둔다(등록/발주서 요청 등 여러 화면의 상태 배지·카드가 공통으로 참조한다). */
  --st-done: #16a34a;
  --st-hold: #d97706;
  --st-partial: #0891b2;
  --st-ordered: #6d28d9;
  /* select/checkbox/스크롤바/달력 아이콘처럼 우리가 색을 직접 못 정하는 브라우저 기본 UI 부품에게
     "지금 이 페이지는 밝은/어두운 배경이다"를 알려준다 — 이게 없으면 위 button/input/select color
     리셋으로 글자색만 밝게 바뀌고 부품 자체의 배경은 계속 브라우저 기본(밝은색)으로 남아,
     예를 들어 목록 "페이지당" select처럼 배경 없이 글자색만 쓰는 곳에서 밝은 배경에 밝은 글자가
     겹쳐 안 보이는 문제가 생긴다. */
  color-scheme: light;
}

/* ---------- 다크모드 ----------
   기본은 시스템(OS/브라우저) 설정을 따르고(prefers-color-scheme), 사이드바의 다크모드 버튼으로
   직접 선택하면 그 값을 localStorage에 저장해 시스템 설정과 무관하게 항상 그 모양으로 연다
   (적용 스크립트: views/partials/layout.ejs 상단의 인라인 스크립트 + public/js/theme-toggle.js).
   견적서 등 인쇄 서식은 화면 테마와 무관하게 항상 흰 종이여야 하므로, 아래 @media print에서
   이 변수들을 다시 밝은 값으로 고정한다. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #6d9bf3;
    --primary-dark: #8fb3f7;
    --border: #3d4d66;
    --bg: #0f1520;
    --surface: #171f2b;
    --text: #e5e9f0;
    --muted: #93a0b4;
    --danger: #f37478;
    --st-done: #4ecb7e;
    --st-hold: #f0ad4e;
    --st-partial: #34c2d6;
    --st-ordered: #b394f5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #6d9bf3;
  --primary-dark: #8fb3f7;
  --border: #3d4d66;
  --bg: #0f1520;
  --surface: #171f2b;
  --text: #e5e9f0;
  --muted: #93a0b4;
  --danger: #f37478;
  --st-done: #4ecb7e;
  --st-hold: #f0ad4e;
  --st-partial: #34c2d6;
  --st-ordered: #b394f5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* 브라우저 기본 스타일은 버튼/입력창/선택창/텍스트영역의 글자색을 body의 color를 물려받지 않고
   시스템 색(대개 검정에 가까움)으로 따로 고정해버린다 — 라이트모드에서는 우연히 잘 보였지만,
   다크모드에서는 어두운 배경 위에 어두운 글자가 그대로 남아 "글자가 안 보이는" 원인이 된다.
   폼 컨트롤 전체에 이 리셋을 걸어두면 아래 .btn-primary/.danger 등 개별 규칙이 그대로 덮어써
   먼저 정한 색을 계속 쓸 수 있다(이 규칙이 그것들보다 먼저 나오므로 우선순위 문제 없음). */
button, input, select, textarea { font: inherit; color: inherit; }
/* select는 배경도 브라우저 기본값(대개 흰색 계열)을 따로 갖고 있어서, 위 color:inherit로 글자만
   밝아지면 "밝은 배경 + 밝은 글자"가 겹쳐 오히려 안 보이게 된다(예: 목록 하단 "페이지당" select).
   화면 어디에 있든 항상 우리 테마의 면 색을 쓰도록 기본값으로 깔아둔다 — 특정 화면에서 이미
   background를 따로 지정한 곳은 그 값이 그대로 우선한다(구체성이 더 높거나 나중에 나오므로). */
select { background: var(--surface); }
body {
  margin: 0;
  /* "NanumGothic"을 맨 앞에 둔 이유: PDF 생성(lib/pdf.js)이 도커 컨테이너 안의 리눅스 크로미움으로
     이 페이지를 그대로 찍어내는데, 처음엔 이름 없는 sans-serif로 밀려 fonts-noto-cjk가 잡혔었다 —
     그런데 이 폰트가 여러 굵기/지역을 한 파일에 묶은 형태(.ttc, OpenType Collection)라, 크로미움이
     PDF 인쇄 시 "진짜 글자(텍스트)"가 아니라 윤곽선(그림)으로 찍어버려 화면엔 멀쩡해도 PDF에서 글자
     선택/복사가 안 되는 문제가 있었다(Noto Sans KR로 이름만 지정해도 결국 같은 파일이라 안 고쳐짐).
     Dockerfile에 새로 넣은 fonts-nanum(낱개 TTF라 이 문제가 없음)을 1순위로 써서 해결한다 — 이 폰트가
     없는 맥/윈도우 브라우저에서는 그냥 건너뛰고 기존 폰트를 그대로 쓰므로 화면 UI 모양엔 영향 없다. */
  font-family: "NanumGothic", "Nanum Gothic", "Noto Sans KR", "Noto Sans CJK KR", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- 좌측 사이드바 네비게이션 ---- */
body.app { display: flex; align-items: flex-start; min-height: 100vh; }
.sidebar {
  flex: 0 0 220px; width: 220px; align-self: stretch;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 50;
}
.sidebar-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; font-size: 18px; color: var(--text); white-space: nowrap; }
.mainnav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.navlabel {
  display: flex; align-items: center; width: 100%; gap: 8px;
  padding: 9px 12px; border: none; background: none; border-radius: 6px;
  font: inherit; font-weight: 500; color: var(--text); text-align: left; cursor: pointer;
}
.navlabel:hover { background: var(--bg); }
/* 사용설명서: 드롭다운 없이 바로 여는 단일 링크라 <a>로 만들되, 버튼형 메뉴 항목들과 똑같이 보이게 한다 */
a.navlink { text-decoration: none; margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 13px; }
a.navlink:hover { text-decoration: none; }
/* 접힘/펼침 표시 화살표 — 열리면 위를 향하도록 회전 */
.nav-caret {
  width: 6px; height: 6px; margin-left: auto; flex: none;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .15s ease;
}
.navitem.open > .navlabel .nav-caret { transform: rotate(-135deg); }
.dropdown { display: none; padding: 2px 0 6px 12px; }
.navitem.open > .dropdown { display: block; }
.dropdown a { display: block; padding: 7px 12px; border-radius: 6px; color: var(--muted); font-size: 14px; }
.dropdown a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
/* 영업관리/입출관리/생산 하위 메뉴: 문서 종류별로 옅은 구분선을 긋고, 조회/작성/요청 글자색을
   옅게 구분한다(배경은 안 칠하고 글자색만 — 상태 배지에 쓰는 색을 그대로 재사용해 화면 전체와
   톤을 맞춘다 — 조회=--st-partial 청록, 작성=--st-done 초록, 요청=--st-ordered 보라). */
.dropdown a.nav-group-sep { margin-top: 6px; padding-top: 9px; border-top: 1px solid var(--border); }
.dropdown a.nav-link-view { color: var(--st-partial); }
.dropdown a.nav-link-new { color: var(--st-done); }
.dropdown a.nav-link-request { color: var(--st-ordered); }
.dropdown a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-weight: 600; }
.sidebar-user {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted);
}

.container { flex: 1; min-width: 0; padding: 24px 32px 64px; }

/* 스마트폰 화면 상단 고정 바(햄버거 + 브랜드명 + 현재 화면 제목) — 데스크톱에서는 숨긴다 */
.mobile-topbar { display: none; }
.mobile-nav-toggle {
  width: 36px; height: 36px; flex: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; padding: 0;
}
.mobile-nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
.sidebar-backdrop { display: none; }

/* 햄버거 메뉴(누르면 열리고, 바깥을 누르거나 메뉴 항목을 고르면 자동으로 닫히는 좌측 서랍)는
   900px 이하(태블릿+스마트폰 공통)에서 항상 쓴다 — 사이드바가 position:fixed로 화면에 고정돼
   본문이 좌우로 스크롤돼도(아래 스마트폰 전용 규칙) 메뉴 버튼은 항상 같은 자리에 남는다. */
@media (max-width: 900px) {
  body.app { flex-direction: column; }
  .mobile-topbar {
    display: flex; align-items: center; gap: 10px;
    position: fixed; top: 0; left: 0; right: 0; z-index: 90; height: 56px;
    padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .mobile-topbar-brand {
    flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 16px; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .mobile-topbar-title {
    flex: 0 1 auto; min-width: 0; max-width: 50%; margin-left: auto;
    font-weight: 600; font-size: 15px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 91;
    width: 240px; max-width: 80vw; height: 100vh; flex: none;
    border-right: 1px solid var(--border); border-bottom: none;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 2px 0 16px rgba(0,0,0,.15);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4);
    z-index: 89; opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }
  .container { padding: 72px 16px 64px; }
}

/* 본문(.container) 자체의 폭은 태블릿과 스마트폰이 다르다 — 태블릿(768~900px)은 화면 폭에
   맞춰 줄어들고(아래 태블릿 전용 규칙), 스마트폰(767px 이하)은 PC와 같은 폭을 유지한 채
   좌우로 스크롤한다(아래 "스마트폰: PC와 동일한 폭 + 좌우 스크롤" 규칙). */
@media (min-width: 768px) and (max-width: 900px) {
  .container { width: 100%; }
}
.page-title { font-size: 22px; margin: 0 0 16px; text-align: center; }
.section-title { font-size: 17px; margin: 28px 0 10px; text-align: center; }

/* 매출현황 "매출 추이 비교" 그래프 영역 */
.sales-trend-section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.sales-trend-section .section-title { margin: 0 0 10px; text-align: left; }
.sales-trend-years { margin-bottom: 14px; flex-wrap: wrap; }
.trend-years-label { color: var(--muted); font-size: 13px; align-self: center; }
.trend-year-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: normal; }
.trend-metric-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.trend-metric-tab {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}
.trend-metric-tab:hover { border-color: var(--primary); color: var(--primary); }
.trend-metric-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.sales-trend-chart-wrap { position: relative; height: 260px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.card-grid.small .card-value { font-size: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; }
.card-value.warn { color: var(--danger); }

.dashboard table.grid th, .dashboard table.grid td { text-align: center; }

/* 대시보드는 스크롤 없이 모니터 화면 전체를 채운다 */
body.app-dashboard { height: 100vh; overflow: hidden; }
body.app-dashboard .container { max-width: none; height: 100vh; display: flex; flex-direction: column; padding: 20px 24px; overflow: hidden; }
body.app-dashboard .dashboard { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* 900px 이하에서는 위 padding:20px 24px 대신 고정된 상단 바(56px)만큼 위 여백을 더 줘야
   "진행 현황" 제목이 그 바에 가리지 않는다. 선택자 구체성이 같은 규칙끼리는 나중에 나온 쪽이
   이기므로, 이 규칙을 위 body.app-dashboard .container 규칙보다 뒤에 둬야 실제로 적용된다
   (앞서 900px 미디어 쿼리 블록 안에 넣었을 때는 파일 순서상 이 규칙보다 앞이라 무시됐었다). */
@media (max-width: 900px) {
  body.app-dashboard .container { padding: 72px 16px 64px; }
}

/* 등록 > 기본설정 (화면설정 / 메일 메시지 관리를 한 화면에 모아둔 페이지) */
/* 원래 720px이었는데, 메일 메시지/주소록처럼 표(이메일·전화번호 등 긴 값)가 들어간 섹션이 생기면서
   칸이 좁아 줄바꿈이 잦았다 — 표 칼럼이 줄바꿈 없이 한 줄에 들어갈 만큼 넉넉하게 넓힌다. */
.settings-page { display: flex; flex-direction: column; gap: 20px; max-width: 1100px; margin: 0 auto; }
/* 등록 > 기본설정 상단 탭(화면 설정/메일 설정/캘린더 설정, public/js/settings-tabs.js가 전환을 붙인다).
   한 번에 한 탭 패널만 보이므로 패널 자체가 .settings-page 카드 간격을 그대로 이어받는다. */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); max-width: 1100px; margin-left: auto; margin-right: auto; }
.settings-tab-btn {
  padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
}
.settings-tab-btn:hover { color: var(--text); }
.settings-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.settings-tab-panel { display: flex; flex-direction: column; gap: 20px; }
.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.settings-section h2.section-title { text-align: left; margin: 0 0 4px; }
.settings-section .modal-desc { text-align: left; margin: 0 0 14px; }
/* 화면 테마처럼 설명글 없이 "제목(+설명 팝업 버튼)"과 조작 스위치를 한 줄에 나란히 놓는 헤더 */
.settings-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.settings-section-head h2.section-title { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
/* 사유 보기(.reason-info-btn)와 똑같은 동그란 "ⓘ" 버튼 스타일을 여기서도 그대로 쓴다(설명 팝업 열기) */
.info-btn, .reason-info-btn {
  flex: none; width: 18px; height: 18px; line-height: 16px; padding: 0;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.info-btn:hover, .reason-info-btn:hover { background: var(--bg); color: var(--text); }
.settings-check-list { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px 24px; margin-bottom: 14px; }
/* 캘린더 연동의 iCal URL 칸처럼, .simple-form 밖에서 쓰는 일반 입력칸에도 같은 테두리/배경을 준다 */
.settings-section input[type="url"], .settings-section input[type="text"] {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 14px; background: var(--surface);
}
label.dash-prefs-check {
  display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--text);
}
/* 메일 서명/명함의 현재 등록된 이미지 미리보기 + 삭제 체크박스 한 줄 */
.mail-sig-current { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.mail-sig-current img { max-height: 70px; max-width: 220px; border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: var(--surface); }

/* 등록 > 기본설정의 "다크모드" 토글 스위치 (public/js/theme-toggle.js가 동작을 붙인다) */
.theme-toggle-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.theme-toggle-switch input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0; /* 화면엔 안 보이지만 키보드/스크린리더로는 계속 접근 가능 */
}
.theme-toggle-track {
  position: relative; flex: none; width: 44px; height: 24px; border-radius: 999px;
  background: var(--border); transition: background .15s ease;
}
.theme-toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s ease;
}
.theme-toggle-switch input:checked ~ .theme-toggle-track { background: var(--primary); }
.theme-toggle-switch input:checked ~ .theme-toggle-track .theme-toggle-thumb { transform: translateX(20px); }
.theme-toggle-switch input:focus-visible ~ .theme-toggle-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-toggle-label { font-size: 14px; color: var(--text); }

/* 주문서/발주서 작성·수정 화면 및 상세 화면의 첨부파일(파일/이미지) 영역 */
.attach-section { margin-top: 14px; }
.attach-section .attach-hint { margin: 4px 0 8px; }
.attach-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attach-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 13px;
}
.attach-row a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { color: var(--muted); white-space: nowrap; }
.attach-del-btn { color: var(--danger); white-space: nowrap; }
.attach-print-box { margin: -10px 0 16px; padding: 10px 0 0; }

/* 첨부파일 목록 순번 체크박스로 여러 건 선택해 한번에 삭제하는 툴바 */
.attach-bulk-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; font-size: 13px; }
.attach-select-all-label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.attach-bulk-count { color: var(--muted); }
.attach-bulk-delete { color: var(--danger); }

/* BOM 조회 화면: 첨부파일 이름을 누르면(링크가 아니라 버튼) 뷰어가 뜬다. 다운로드는 별도 링크로 오른쪽에 둔다. */
.attach-row .attach-view-trigger {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
}
.attach-row > a.link-btn { flex: 0 0 auto; }

/* 첨부파일 뷰어 모달 (이미지/PDF/엑셀/텍스트 미리보기) */
.modal-inner.attach-viewer-inner { width: min(2200px, 96vw); max-height: 92vh; overflow: hidden; }
.attach-viewer-title { font-size: 15px; word-break: break-all; flex: 1; min-width: 0; }
.attach-viewer-body { flex: 1; overflow: auto; min-height: 120px; display: flex; flex-direction: column; }
/* 첨부파일 여러 건을 열었을 때 팝업을 닫지 않고 이전/다음 파일로 넘어가는 버튼 (방향키 ←/→로도 이동) - 이미지 아래 가운데 배치 */
.attach-viewer-nav { display: flex; align-items: center; justify-content: center; gap: 10px; flex: none; }
.attach-viewer-prev, .attach-viewer-next {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px; width: 28px; height: 28px;
  font-size: 16px; line-height: 1; cursor: pointer; color: var(--text);
}
.attach-viewer-prev:hover, .attach-viewer-next:hover { background: var(--bg); }
.attach-viewer-pos { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 40px; text-align: center; }
.attach-image-view { max-width: 100%; max-height: 74vh; margin: 0 auto; display: block; }
.attach-pdf-view { width: 100%; height: 74vh; border: 0; }
.attach-text-view {
  white-space: pre-wrap; word-break: break-all; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: 12px; font-size: 13px; max-height: 74vh; overflow: auto;
}
.attach-xlsx-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.attach-xlsx-tab {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px 6px 0 0; padding: 6px 12px;
  font-size: 13px; cursor: pointer; color: var(--muted);
}
.attach-xlsx-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.attach-xlsx-table-wrap { overflow: auto; max-height: 68vh; border: 1px solid var(--border); border-radius: 6px; }
table.attach-xlsx-table { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.attach-xlsx-table td, table.attach-xlsx-table th { border: 1px solid var(--border); padding: 4px 8px; }
/* 엑셀처럼 맨 위(열 문자 A,B,C…)/맨 왼쪽(행 번호 1,2,3…) 머리글 칸 — 표를 스크롤해도 계속 보이도록
   .attach-xlsx-table-wrap(overflow: auto) 기준으로 고정한다. 모서리 칸은 두 방향 다 고정이라 z-index를 더 높인다. */
table.attach-xlsx-table th.attach-xlsx-colhead,
table.attach-xlsx-table th.attach-xlsx-rowhead,
table.attach-xlsx-table th.attach-xlsx-corner {
  background: var(--bg); color: var(--muted); font-weight: 600; text-align: center;
}
table.attach-xlsx-table th.attach-xlsx-colhead, table.attach-xlsx-table th.attach-xlsx-corner {
  position: sticky; top: 0; z-index: 2;
}
table.attach-xlsx-table th.attach-xlsx-rowhead, table.attach-xlsx-table th.attach-xlsx-corner {
  position: sticky; left: 0; z-index: 2;
}
table.attach-xlsx-table th.attach-xlsx-corner { z-index: 3; }
.attach-print-box > b { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }

/* 엑셀 자료검색 화면: 파일별 검색결과 묶음 */
.excel-search-group {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  margin-bottom: 14px; overflow: hidden;
}
.excel-search-group-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); background: var(--bg); font-size: 13px;
}
.excel-search-group-head b { word-break: break-all; }
.excel-search-table-wrap { overflow-x: auto; max-height: 360px; overflow-y: auto; }
table.excel-search-table { width: 100%; font-size: 13px; }
table.excel-search-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
table.excel-search-table mark { background: color-mix(in srgb, var(--primary) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }

/* 엑셀 자료검색 화면: 폴더 탭 바 */
.excel-folder-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.excel-folder-tab {
  display: inline-block; border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 14px; font-size: 13px; color: var(--text); text-decoration: none; white-space: nowrap;
}
.excel-folder-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.excel-folder-new-form { display: flex; gap: 6px; margin-left: auto; }
.excel-folder-new-form input {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 5px 10px; font-size: 13px; width: 140px;
}
.excel-folder-new-form button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 5px 10px; font-size: 13px; cursor: pointer;
}
.excel-folder-delete-form { display: inline-block; }
.excel-move-select { font-size: 12px; padding: 3px 6px; flex: 0 0 auto; max-width: 140px; }
.excel-select-hint { margin: -8px 0 14px; font-size: 12px; }
.excel-select-hint #excelSelectCount { color: var(--primary); font-weight: 600; }
.excel-list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.excel-list-head .section-title { margin: 0; }
.excel-list-toolbar { display: flex; align-items: center; gap: 12px; font-size: 13px; margin-bottom: 10px; }
.excel-list-toolbar select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 8px; font-size: 13px;
}
.excel-list-toolbar button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 4px 10px; font-size: 13px; cursor: pointer;
}
.excel-list-toolbar button:disabled { opacity: .5; cursor: default; }
.attach-row .excel-file-select { flex: none; }

/* 위쪽은 진행 현황이 가로 전체를 차지하고, 아래쪽에 최근 작업 문서 / 재고 현황 / BOM 목록 중
   로그인 계정이 켜둔 항목만 위에서부터 쌓인다(화면설정에서 여러 개를 켜면 세로로 나란히 쌓임).
   아무것도 켜지 않았다면 아래쪽 없이 진행 현황이 화면 전체를 차지한다. 각 박스는 화면에 고정된
   크기이며, 넘치는 내용은 확대(⤢) 버튼을 눌러 팝업에서 스크롤로 본다. */
.dash-grid { display: flex; flex-direction: column; gap: 16px; flex: 1; min-height: 0; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; min-height: 0; }
/* 진행 현황이 주가 되는 화면이라 세로 공간을 더 많이 갖는다(3:2) — 화면설정에서 추가 항목을
   여러 개 켜도 아래쪽 칸이 서로 균등하게(.dash-col-side .dash-box, flex:1) 나눠 갖는다. */
.dash-col-po { flex: 3; min-height: 0; }
.dash-col-side { flex: 2; min-height: 0; }
.dash-col-po .dash-box-po { flex: 1; }
.dash-col-side .dash-box { flex: 1; }
.dash-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; min-width: 0; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.dash-box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none; flex-wrap: wrap; }
.dash-box-head .section-title { margin: 0; text-align: left; white-space: nowrap; }
.dash-box-more { font-size: 13px; font-weight: 400; }
/* 발주 진행 현황 통계칩을 제목 오른쪽, 헤더 안에서 가운데 정렬로 표시 */
.dash-box-head .flow-filter { flex: 1 1 auto; justify-content: center; margin: 0; gap: 4px; min-width: 0; }
.dash-box-head .filter-chip { padding: 3px 8px; font-size: 11px; gap: 3px; white-space: nowrap; }
.dash-box-expand {
  flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  padding: 3px 9px; font-size: 15px; line-height: 1.4; cursor: pointer; color: var(--muted);
}
.dash-box-expand:hover { background: var(--bg); color: var(--text); }
.dash-box-body { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin-top: 10px; }

/* 보류·취소 사유 보기 버튼과 팝업: 카드에는 사유를 바로 보여주지 않고 클릭 시에만 확인
   (버튼 자체 스타일은 .info-btn, .reason-info-btn 규칙 — 화면 테마 설명 버튼과 공용) */
.reason-modal-inner { width: 420px; max-width: 90vw; }
.reason-modal-title { margin: 0 0 10px; font-size: 16px; }
.reason-modal-text { margin: 0 0 8px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.reason-modal-meta { margin: 0; font-size: 12px; }

/* 보류·취소 사유 입력 팝업: 상태 선택 시 카드 안이 아니라 팝업에서 사유를 입력받는다 */
.reason-input-modal-inner { width: 420px; max-width: 90vw; }
.reason-input-modal-title { margin: 0 0 10px; font-size: 16px; }
.reason-input-field { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px; font-size: 14px; background: var(--surface); }
.reason-input-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* 확대 팝업: 박스 내용을 그대로 옮겨와 큰 화면에서 스크롤로 전체를 본다 */
.modal-inner.dash-box-modal-inner { width: min(3300px, 92vw); max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; }
.dash-box-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex: none; }
.dash-box-modal-title { margin: 0; font-size: 18px; }
.dash-box-modal-body { flex: 1; min-height: 0; overflow-y: auto; }
.dash-box-modal-body .dash-box-body { overflow: visible; flex: none; margin-top: 0; }

/* 대시보드의 이 압축 레이아웃(카드 색상/전체폭 카드 등)도 진짜 태블릿 폭(768~900px)에만 적용한다.
   스마트폰(767px 이하)은 아래 "스마트폰: PC와 동일한 폭 + 좌우 스크롤" 규칙을 대신 쓴다. */
@media (min-width: 768px) and (max-width: 900px) {
  body.app-dashboard, body.app-dashboard .container { height: auto; overflow: visible; }
  .dash-grid { flex-direction: column; }
  .dash-box { min-height: 320px; }
  /* 이 폭에서는 화면 설정에서 추가 항목을 켜두었어도 진행 현황만 보이게 한다 (공간이 좁아서) */
  .dash-toolbar { display: none; }
  .dash-col-side { display: none; }
  .dash-box-po { min-height: 70vh; }

  /* 주문/발주 카드도 세부 정보(진행 흐름도, 일정, 상태변경)는 걷어내고
     거래처명·상태·문서번호만 크게 보이는 카드로 단순화한다.
     자세한 내용/상태 변경은 문서번호를 눌러 상세 화면에서 한다. */
  .dash-box-po .flow-filter { justify-content: flex-start; }
  .pipeline-list { gap: 14px; }
  .pipeline {
    flex-direction: column; align-items: stretch; gap: 8px;
    background: var(--primary); border-color: var(--primary);
    border-radius: 16px; padding: 20px 22px; color: #fff;
  }
  .pipeline.is-completed { background: var(--st-done); border-color: var(--st-done); }
  .pipeline.is-hold { background: var(--st-hold); border-color: var(--st-hold); }
  .pipeline.is-cancelled { background: var(--muted); border-color: var(--muted); opacity: 1; }
  .pipeline.is-partial_inbound, .pipeline.is-partial_outbound { background: var(--st-partial); border-color: var(--st-partial); }
  .pipeline.is-ordered { background: var(--st-ordered); border-color: var(--st-ordered); }
  .pipeline-head { flex: none; width: 100%; gap: 6px; }
  .pipeline-client { color: #fff; font-size: 16px; }
  .pipeline-meta { color: rgba(255, 255, 255, .85); }
  .pipeline-meta a, .pipeline-meta .link-btn { color: #fff; text-decoration: underline; }
  .status-badge,
  .status-badge.is-completed, .status-badge.is-hold, .status-badge.is-cancelled,
  .status-badge.is-partial_inbound, .status-badge.is-partial_outbound, .status-badge.is-ordered {
    background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .5); color: #fff;
  }
  .reason-info-btn { background: rgba(255, 255, 255, .15); border-color: rgba(255, 255, 255, .5); color: #fff; }
  /* 진행 흐름도(주문~완료)는 카드 아래 전체 폭에 그대로 두고, 아래 768px 미만(스마트폰) 규칙이
     없는 한 기본(desktop) 규칙대로 6단계가 폭에 맞춰 줄어들며 스크롤 없이 한 번에 보인다 —
     갤럭시탭 등 진짜 태블릿 폭(약 768~900px)에서는 이 화면 폭으로도 충분히 다 보인다. */
  .pipeline-flow { width: 100%; margin-top: 4px; }
  /* 상태 변경 폼도 카드 아래 전체 폭으로 다시 보여준다(가로로 배치해 셀렉트가 좁아지지 않게) */
  .pipeline-side { flex: none; width: 100%; align-items: stretch; margin-top: 4px; }
  .pipeline-side .status-form { flex-direction: row; align-items: center; }
  .pipeline-side .status-form select { flex: 1; width: auto; }
}

/* ---- 스마트폰(768px 미만, 태블릿 표준 분기점 768px 기준 — 갤럭시 폴드 포함): 메뉴는 위 900px
   규칙대로 똑같이 햄버거로 자동 숨김되지만, 본문(.container)은 화면 폭에 맞춰 압축/줄바꿈하는 대신
   PC 화면과 동일한 폭 그대로 보여주고 좌우로 스크롤(스와이프)해서 보게 한다. 진행 흐름도/표/폼 등을
   화면마다 따로 좁게 맞추다 글자가 잘리는 문제를 근본적으로 없애기 위한 방식이다 — 768~900px
   (갤럭시탭 등 진짜 태블릿)은 본문도 화면 폭에 맞춰 줄어드는 압축 레이아웃(카드 색상 등)을 쓴다. */
@media (max-width: 767px) {
  /* .container가 폭을 줄이지 않도록(기본은 min-width:0으로 줄어드는 게 허용돼 있었다) 최소 폭을
     PC 화면 수준으로 못박아, 사이드바(220px)+본문이 화면보다 넓어지며 자연히 좌우 스크롤이 생기게 한다. */
  .container { min-width: 1200px; }
  /* 대시보드 화면은 desktop에서 body 자체에 overflow:hidden을 걸어 세로 스크롤 없이 내부 박스만
     스크롤하게 만들어져 있는데(모니터 화면 전체를 채우는 디자인), 그대로 두면 좌우 스크롤도 막혀버려
     여기서 가로만 다시 열어준다(세로는 desktop과 동일하게 내부 박스 스크롤만 쓴다). */
  body.app-dashboard { overflow-x: auto; overflow-y: hidden; }
}

/* ---- 좁은 스마트폰 화면(갤럭시 S23 등, 웹 기준 폭 약 360~412px) 공용 보정 ----
   본문 표(목록)·문서 서식 자체를 좁히던 규칙은 여기서 걷어냈다(스마트폰도 이제 PC와 동일한 폭을
   쓰고 페이지 전체를 좌우로 스크롤하므로, 표만 따로 줄일 필요가 없다). 표의 자체 스크롤은 아래
   "모달 팝업 안의 표" 규칙에만 남아, 모달(화면 폭(vw)에 맞춰 따로 줄어드는 팝업) 안에서만 쓰인다. */
@media (max-width: 480px) {
  /* 인쇄 서식(견적서/주문서/발주서/BOM 등)의 표 머리글이 좁은 화면에서 줄바꿈되지 않게 */
  .doc-meta th { width: auto; white-space: nowrap; }
  /* 모달 팝업 안쪽 여백도 줄여 좁은 화면에서 내용이 더 넓게 보이게 한다 */
  .modal-inner { padding: 14px; }
  /* 자동완성 목록(거래처/품목 검색 등)이 항상 260px 폭을 고집하면, 입력칸이 화면 오른쪽 가까이 있을 때
     그 너비만큼 화면 밖으로 넘쳐 전체 페이지가 옆으로 밀릴 수 있어 화면 폭에 맞춰 줄어들게 한다 */
  .ac-list { min-width: 0; width: max(70vw, 200px); max-width: 92vw; }
}
/* 모달 팝업은 화면 폭(vw)에 맞춰 따로 줄어드는 독립된 상자라(본문 페이지처럼 좌우로 스크롤하지
   않는다), 그 안의 표는 화면 크기와 무관하게 항상 자체적으로 좌우 스크롤을 갖는다.
   예전에는 표(<table>) 자체를 display:block으로 바꾸면서 thead/tbody까지 각각 독립된 table로
   강제해, 헤더 칸과 내용 칸 너비를 브라우저가 서로 따로 계산해버렸다 — 그 결과 ① 헤더와 값의
   칸이 안 맞고, ② 실제 칸 너비가 필요한 만큼만 좁게 잡혀 표 오른쪽에 빈 여백(오른쪽 테두리까지
   빈 칸처럼 보이는 공백)이 남는 두 가지 문제가 같이 생겼다. 지금은 표 자체는 그대로 두고
   .items-table-scroll로 감싸는 바깥 div에만 가로 스크롤을 줘서(품목등록 목록과 같은 방식),
   표 하나가 그대로 유지되어 칸도 항상 맞고 좌우 여백도 생기지 않는다. */
.modal-inner .items-table-scroll { max-width: 100%; -webkit-overflow-scrolling: touch; }
/* 이미 자체 가로/세로 스크롤 통을 갖고 있는 표(불러오기 팝업의 품목 목록)도 가로 스크롤을 허용 */
.src-items-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 발주 건별 진행 흐름도 (견적 → 주문 → 발주 → 입고 → 생산 → 출고 → 완료) */
.flow-filter { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 13px; color: var(--text);
}
.filter-chip:hover { background: var(--bg); text-decoration: none; }
.filter-chip .chip-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-chip.active .chip-count { color: #fff; }

.pipeline-list { display: flex; flex-direction: column; gap: 10px; }
.pipeline {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; text-align: left;
}
/* 완료·취소 건은 눈에 덜 띄게 (목록에서도 아래로 정렬된다) */
.pipeline.is-completed { border-color: color-mix(in srgb, var(--st-done) 35%, transparent); background: color-mix(in srgb, var(--st-done) 6%, var(--surface)); }
.pipeline.is-cancelled { background: var(--bg); opacity: .75; }
.pipeline.is-hold { border-color: color-mix(in srgb, var(--st-hold) 35%, transparent); background: color-mix(in srgb, var(--st-hold) 6%, var(--surface)); }
.pipeline.is-partial_inbound, .pipeline.is-partial_outbound { border-color: color-mix(in srgb, var(--st-partial) 35%, transparent); background: color-mix(in srgb, var(--st-partial) 6%, var(--surface)); }
.pipeline.is-ordered { border-color: color-mix(in srgb, var(--st-ordered) 35%, transparent); background: color-mix(in srgb, var(--st-ordered) 6%, var(--surface)); }

.pipeline-head { flex: 0 0 165px; min-width: 145px; display: flex; flex-direction: column; gap: 4px; }
/* 사업자명이 길어도 줄바뀜으로 취소 배지/ⓘ 아이콘이 다음 줄로 밀리지 않도록, 이름 쪽만 말줄임표로 자른다 */
.pipeline-title { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; }
.pipeline-client {
  font-weight: 600; font-size: 14px; min-width: 0; flex: 1 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pipeline-title .status-badge, .pipeline-title .reason-info-btn { flex: none; }
.pipeline-meta { font-size: 12px; color: var(--muted); }
.pipeline-meta .link-btn { font-size: inherit; }
.pipeline-meta .link-btn:hover { text-decoration: underline; }
.status-badge {
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; white-space: nowrap;
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  color: var(--primary);
}
.status-badge.is-completed { background: color-mix(in srgb, var(--st-done) 16%, transparent); border-color: color-mix(in srgb, var(--st-done) 45%, transparent); color: var(--st-done); }
.status-badge.is-hold { background: color-mix(in srgb, var(--st-hold) 16%, transparent); border-color: color-mix(in srgb, var(--st-hold) 45%, transparent); color: var(--st-hold); }
.status-badge.is-cancelled { background: color-mix(in srgb, var(--danger) 16%, transparent); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.status-badge.is-partial_inbound, .status-badge.is-partial_outbound { background: color-mix(in srgb, var(--st-partial) 16%, transparent); border-color: color-mix(in srgb, var(--st-partial) 45%, transparent); color: var(--st-partial); }
/* 발주서 전용 상태: 발주대기(is-pending)는 기본 .status-badge 색을 그대로 쓰고, 발주완료(is-ordered)만
   "실제로 공급처에 발주를 넣었다"는 걸 눈에 띄게 구분하기 위해 별도 색을 준다. */
.status-badge.is-ordered { background: color-mix(in srgb, var(--st-ordered) 16%, transparent); border-color: color-mix(in srgb, var(--st-ordered) 45%, transparent); color: var(--st-ordered); }

.pipeline-side { flex: 0 0 95px; min-width: 80px; display: flex; flex-direction: column; gap: 6px; }
.status-form { display: flex; gap: 6px; align-items: center; }
.status-form select { flex: 0 0 90px; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; background: var(--surface); }
.status-form .status-reason { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; background: var(--surface); }
.status-form button { padding: 6px 12px; font-size: 13px; }

/* nav의 "발주서 요청" 옆 미확인 건수 배지 */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger, #d64545);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

/* 발주 진행 현황 카드: 저장 버튼 없이 선택 시 자동 저장되므로 선택 박스를 오른쪽 정렬로 표시 */
.pipeline-side .status-form { flex-direction: column; align-items: flex-end; }
.pipeline-side .status-form select { flex: none; width: 80px; padding: 8px 10px; font-size: 14px; }
.pipeline-side .status-form .status-reason { flex: none; width: 100%; }
.status-reason-text { margin: 0; font-size: 12px; color: var(--text); line-height: 1.5; }
.status-reason-text b { color: var(--muted); margin-right: 4px; }

/* 발주서 상세 화면의 상태 변경 패널 */
.po-status-panel {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; margin-bottom: 14px;
}
.po-status-current { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.po-status-panel .status-form { margin-left: auto; flex: 0 1 340px; }
/* 7단계가 스크롤 없이 한 번에 다 보이도록 남는 폭만큼 자연스럽게 넓어진다(줄어들지만 스크롤은 생기지 않는다) */
.pipeline-flow {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px;
  overflow: hidden;
}
.flow-step {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 2px; background: var(--bg);
}
.flow-step[data-instances] { cursor: pointer; }
/* 단계 제목(주문/발주/입고/생산/출고/완료): 박스 폭 전체를 차지해야 말줄임(ellipsis)이 정확히 계산되고
   가운데 정렬도 유지된다 (부모가 align-items:center면 글자 수만큼만 폭을 차지해 계산이 어긋난다) */
.flow-label {
  display: block; width: 100%; box-sizing: border-box; text-align: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* "주문" 단계 제목 아래: 주문명을 작게 표시 */
.flow-step-name {
  display: block; width: 100%; box-sizing: border-box; text-align: center;
  font-size: 10px; color: var(--muted); opacity: .85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* "생산" 단계는 주문명을 별도 줄이 아니라 진행률 바와 같은 줄, 막대 왼쪽에 붙여 보여준다 */
.flow-step-progress .flow-step-name {
  display: block; width: auto; flex: 0 1 auto; max-width: 50%; text-align: left;
}
/* "발주"/"입고" 단계 제목 아래: 발주·미발주 / 입고완료·부분입고·미입고 건수 — 박스가 좁아도
   잘리지 않도록(말줄임 대신) 줄바꿈을 허용한다 */
.flow-step-counts {
  display: block; width: 100%; box-sizing: border-box; text-align: center;
  font-size: 10px; color: var(--muted); opacity: .85; line-height: 1.3;
  white-space: normal; word-break: keep-all;
}
/* 위 건수들 중 문서 건수(발주(N) 배지 등)와 다른 기준(자재/품목 줄 수)이라 서로 달라 보일 수 있는
   숫자 옆에 붙는 작은 ⓘ 버튼 — .info-btn/.reason-info-btn과 같은 모양이되, 이 글자 크기(10px)에
   맞춰 더 작게 줄였다. 마우스 오버 title이 아니라 눌러서(모바일 포함) 바로 이유를 확인할 수 있다. */
.count-info-btn {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 13px; height: 13px; line-height: 1; padding: 0; margin-left: 3px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: 9px; cursor: pointer; opacity: 1;
}
.count-info-btn:hover { background: var(--bg); color: var(--text); }
.flow-step.is-current .count-info-btn { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .5); color: #fff; }
.flow-step.is-done .count-info-btn { border-color: color-mix(in srgb, var(--primary) 45%, transparent); color: var(--primary); }
/* 생산(production_inbound) 단계: 품목 진행률 평균을 막대로 바로 보여준다 —
   50% 미만 빨강(지연 경고) / 50~99% 주황(진행 중) / 100% 초록(완료)으로 색을 다르게 표시 */
.flow-step-progress { display: flex; align-items: center; gap: 4px; width: 100%; padding: 0 4px; }
.flow-step-progress-track { flex: 1; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.flow-step-progress-fill { height: 100%; border-radius: 2px; background: var(--primary); }
.flow-step-progress-fill.is-low { background: var(--danger); }
.flow-step-progress-fill.is-mid { background: var(--st-hold); }
.flow-step-progress-fill.is-complete { background: var(--st-done); }
.flow-step-progress-pct { font-size: 9px; color: var(--muted); flex: none; }
.flow-step.is-current .flow-step-progress-track { background: rgba(255,255,255,.3); }
.flow-step.is-current .flow-step-progress-pct { color: #fff; opacity: .85; }
.flow-step.is-done { background: color-mix(in srgb, var(--primary) 12%, transparent); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.flow-step.is-done .flow-label, .flow-step.is-done .flow-step-name, .flow-step.is-done .flow-step-counts { color: var(--primary); }
.flow-step.is-current { background: var(--primary); border-color: var(--primary); }
.flow-step.is-current .flow-label, .flow-step.is-current .flow-step-name, .flow-step.is-current .flow-step-counts { color: #fff; }
.flow-step.is-todo { opacity: .55; }
/* 지나쳤지만 문서가 없는 단계 — 점선으로 건너뛴 것을 표시 */
.flow-step.is-skipped { opacity: .55; border-style: dashed; }
.flow-arrow { flex: 0 0 auto; color: var(--border); font-size: 16px; line-height: 1; padding: 0 1px; }

/* 진행 단계 배지를 클릭하면 뜨는, 그 단계에 연결된 문서·품목 트리 드롭다운 (js/flow-dropdown.js) */
.flow-dropdown {
  position: fixed; z-index: 1000; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
  padding: 4px 0; width: max-content; min-width: 260px; max-width: min(460px, 94vw); max-height: 340px; overflow-y: auto;
  font-size: 12px; line-height: 1.5;
}
.flow-dropdown.hidden { display: none; }
.flow-dropdown-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-weight: 700; padding: 7px 12px 8px; border-bottom: 1px solid var(--border);
}
/* "출고 조회"처럼, 문서가 있든 없든 그 유형의 조회(목록) 화면으로 바로 가는 버튼 */
.flow-dropdown-goto-btn {
  flex: none; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--primary); background: var(--surface); cursor: pointer;
}
.flow-dropdown-goto-btn:hover { background: var(--bg); border-color: var(--primary); }
/* 품목 열(코드/품명/규격/수량/현재고) — 헤더와 각 품목 행이 같은 grid-template-columns를 써서
   글자 길이와 상관없이 열이 서로 정확히 맞춰진다 */
.flow-item-grid {
  display: grid; grid-template-columns: 52px minmax(0, 1.3fr) minmax(0, 1fr) 38px 48px;
  column-gap: 8px; align-items: baseline;
}
/* "주문" 단계 품목 목록에 한해 BOM보기 버튼을 넣을 열이 하나 더 붙는다 */
.flow-item-grid.has-bom { grid-template-columns: 52px minmax(0, 1.3fr) minmax(0, 1fr) 38px 48px 56px; }
/* "생산" 단계 품목 목록에 한해 진행률 −/+ 조정 칸이 하나 더 붙는다 */
.flow-item-grid.has-progress { grid-template-columns: 52px minmax(0, 1.3fr) minmax(0, 1fr) 38px 48px 80px; }
.flow-item-grid .fi-code, .flow-item-grid .fi-name, .flow-item-grid .fi-spec {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flow-item-grid .fi-qty, .flow-item-grid .fi-stock { text-align: right; white-space: nowrap; }
.flow-item-grid .fi-bom { white-space: nowrap; }
.flow-item-grid .fi-bom .flow-bom-view-btn { font-size: 11px; }
/* 품목별 생산 진행률 −/+ 빠른 조정 (js/flow-dropdown.js) */
.flow-item-grid .fi-progress { display: flex; align-items: center; justify-content: flex-end; gap: 3px; white-space: nowrap; }
.flow-dropdown-header .fi-progress { justify-content: center; }
.fi-progress-btn {
  flex: none; width: 16px; height: 16px; line-height: 1; padding: 0;
  border: 1px solid var(--border); border-radius: 3px; background: var(--surface);
  color: var(--muted); font-size: 11px; font-weight: 700; cursor: pointer;
}
.fi-progress-btn:hover { color: var(--primary); border-color: var(--primary); }
.fi-progress-btn:disabled { opacity: .5; cursor: default; }
.fi-progress-val { min-width: 30px; text-align: right; }
/* "발주" 팝업 문서 목록 아래에 붙는 미발주 자재 목록(품목코드/품목명/규격만) */
.flow-dropdown-divider { border-top: 1px solid var(--border); margin-top: 4px; }
.flow-material-grid { display: grid; grid-template-columns: 60px minmax(0, 1.3fr) minmax(0, 1fr); column-gap: 8px; align-items: baseline; }
.flow-material-grid .fi-code, .flow-material-grid .fi-name, .flow-material-grid .fi-spec {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flow-dropdown-header.flow-material-grid {
  font-size: 10px; font-weight: 700; color: var(--muted);
  padding: 6px 12px; border-bottom: 1px dashed var(--border);
}
.flow-item-row.flow-material-grid { padding: 4px 12px; font-size: 11px; color: var(--muted); }
/* 트리 1단계: 문서(주문서/발주서 등) 노드 — 클릭해서 펼치고 접는다 */
.flow-tree-head {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; cursor: pointer;
}
.flow-tree-head:hover { background: var(--bg); }
.flow-tree-toggle { flex: none; width: 10px; color: var(--muted); font-size: 10px; }
.flow-tree-label {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600;
}
.flow-tree-link {
  flex: none; font-size: 11px; color: var(--primary); text-decoration: none;
  padding: 2px 6px; border-radius: 4px;
  /* "보기"가 <a>에서 팝업을 여는 <button>으로 바뀌어도(js/flow-dropdown.js) 같은 모양을 유지 */
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.flow-tree-link:hover { background: var(--surface); text-decoration: underline; }
/* 트리 2단계: 문서명(발주명 등) 바로 아래, 그 문서의 품목 목록 — 열 이름 안내 + 품목 행 순서로 나온다 */
.flow-tree-children { padding-left: 22px; }
.flow-tree-children.hidden { display: none; }
/* 품목 목록 위에 붙는 열 이름 안내 (품목코드 · 품목명 · 규격 · 수량 · 현재고) —
   같은 컨테이너(.flow-tree-children) 안의 품목 행과 좌우 여백을 맞춰 열을 정렬한다 */
.flow-tree-children .flow-dropdown-header {
  font-size: 10px; font-weight: 700; color: var(--muted);
  padding: 4px 12px 6px 0; margin-bottom: 2px; border-bottom: 1px dashed var(--border);
}
.flow-tree-children .flow-item-row {
  padding: 3px 12px 3px 0; font-size: 11px; color: var(--muted);
}
/* "부분입고" 목록에서 이미 다 받은 자재 줄 — BOM 자재명세서의 부족 표시와 같은 옅은 분홍 배경 */
.flow-item-row.is-fulfilled { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 14px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 9px 10px; text-align: left; }
table.grid thead th { background: var(--bg); font-weight: 600; color: var(--muted); font-size: 13px; text-align: center; }
/* 헤더를 클릭해 정렬하는 목록(품목등록 등) — 파란 링크가 아니라 헤더 글자색 그대로, 밑줄만 hover로 표시 */
.sort-link { color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
.sort-link:hover { text-decoration: underline; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--text) 4%, var(--surface)); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.right { text-align: right; }
table.grid .warn { color: var(--danger); font-weight: 700; }
/* BOM 조회 자재 목록: 필요수량이 현재고보다 많은 줄 전체를 배경색으로 표시(진행 현황 BOM보기 팝업 등) */
table.grid tbody tr.row-short, table.grid tbody tr.row-short:hover { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
/* BOM 조회 자재 목록: 발주관리가 "미사용"인 자재 줄은 옅은 초록 배경으로 구분 */
table.grid tbody tr.row-unused, table.grid tbody tr.row-unused:hover { background: color-mix(in srgb, var(--st-done) 20%, var(--surface)); }
/* 재고현황: 불량/수리중(A/S) 수량이 있는 품목 줄은 옅은 주황 배경으로 구분 */
table.grid tbody tr.row-as-stock, table.grid tbody tr.row-as-stock:hover { background: color-mix(in srgb, var(--st-hold) 7%, var(--surface)); }

/* 재고현황 제목 오른쪽 끝에 위 줄 색상 설명을 붙여둔다 */
.page-title-wrap { position: relative; }
.row-color-legend {
  position: absolute; right: 0; top: 6px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.row-color-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.row-color-swatch.row-as-stock { background: color-mix(in srgb, var(--st-hold) 35%, var(--surface)); }
/* 인쇄 양식 품목 테이블: 칸이 좁아 글자가 한 자씩 세로로 줄바꿈되지 않도록(비고 칸은 내용은 줄바꿈 허용하되, 헤더 글자 "비고"는 줄바꿈되어 줄 높이가 늘어나지 않도록 고정) */
.doc-items td:not(:last-child), .doc-items th:not(:last-child) { white-space: nowrap; }
.doc-items th:last-child { white-space: nowrap; }
/* 규격 칸 너비를 절반으로 줄이고 넘치는 글자는 말줄임표로 처리 */
.doc-items td:nth-child(4), .doc-items th:nth-child(4) { max-width: 15ch; overflow: hidden; text-overflow: ellipsis; }
/* 품목코드 칸 너비 10% 축소, 비고 칸 너비 10% 확대 */
.doc-items td:nth-child(2), .doc-items th:nth-child(2) { width: 8.5%; }
.doc-items td:last-child, .doc-items th:last-child { width: 6.4%; }
/* 순번(#) 칸 가운데 정렬 */
.doc-items td:first-child { text-align: center; }
/* BOM 자재 목록: 마지막 칸에 "현재고"가 추가되면서 "비고"(9번째 칸)가 더 이상 마지막 칸이 아니게 됐다 —
   위 규칙(마지막 칸이 아니면 줄바꿈 금지)에 걸리지 않게 비고 칸만 다시 줄바꿈을 허용한다. */
.bom-items td:nth-child(9), .bom-items th:nth-child(9) { white-space: normal; }
/* 주문서/발주서/출고/구매입고/생산입고 조회(인쇄) 화면의 품목 목록(견적서·BOM 제외 — 칸 구성이 다름):
   품목명·규격이 길면 표 전체가 화면 오른쪽으로 밀려나던 것을, 두 칸 너비를 고정하고 한 줄까지만
   보여준 뒤 넘치는 글자는 말줄임표(...)로 숨겨서 표 너비가 항상 같게 유지된다. */
.doc-items:not(.quote-items):not(.bom-items) td:nth-child(3),
.doc-items:not(.quote-items):not(.bom-items) th:nth-child(3) {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 18%;
}
.doc-items:not(.quote-items):not(.bom-items) td:nth-child(4),
.doc-items:not(.quote-items):not(.bom-items) th:nth-child(4) {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: none; width: 12%;
}
/* 목록 글자 크기를 조금 줄인다 */
.doc-items:not(.quote-items):not(.bom-items) th,
.doc-items:not(.quote-items):not(.bom-items) td { font-size: 13px; }
/* 표 외곽선이 --border(아주 옅은 회색)라 눈에 잘 안 띄던 것을, 품목 표는 좀 더 또렷한 색으로 강조 */
/* .doc-items는 화면(BOM 조회 등)과 인쇄 서식(doc-sheet, 항상 흰 종이) 양쪽에서 같이 쓰여
   테마 변수에 맞추면 인쇄 서식 쪽에서 대비가 어긋날 수 있어, 두 상황 모두 무난한 고정 회색을 쓴다. */
table.grid.doc-items { border-color: #94a3b8; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 품목등록 목록: 규격 칸 너비 130px, 품목구분/재고관리/단위 칸 가운데 정렬 */
.spec-col { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 품목코드는 잘려서(...) 안 보이는 일이 없도록 줄바꿈 없이 항상 전체를 보여준다 */
.code-col { white-space: nowrap; }
/* 구매경로 칸 너비 50% 축소 (규격 칸 130px의 절반) — 넘치면 말줄임표, 전체 내용은 title 툴팁으로 */
.route-col { max-width: 65px; overflow: hidden; text-overflow: ellipsis; }
/* BOM 작성/수정 자재 목록: <colgroup>로 정한 칸 너비를 그대로 지키도록 고정 레이아웃.
   참고용 칸(구매처~담당자 연락처)은 한 글자씩 세로로 줄바꿈되지 않게 한 줄 + 말줄임으로 보여주고,
   구매경로는 좁은 칸에 말줄임 — 전체 내용은 title 툴팁(마우스 오버)으로 확인한다. */
table.grid.bom-edit-table { table-layout: fixed; width: 100%; }
.bom-edit-table th { white-space: normal; word-break: keep-all; }
.bom-edit-table td input, .bom-edit-table td select { width: 100%; min-width: 0; box-sizing: border-box; }
.bom-edit-table td.f-purchase-client, .bom-edit-table td.f-in-price, .bom-edit-table td.f-purchase-route,
.bom-edit-table td.f-sales-manager, .bom-edit-table td.f-sales-manager-phone {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bom-edit-table td.f-purchase-route { cursor: help; }
/* 품목등록 목록 전체: 어느 칸도 줄바꿈되지 않게 하고, 폭이 화면을 넘으면 표 영역만 가로 스크롤 */
.items-table-scroll { overflow-x: auto; }
.items-table-scroll table.grid td, .items-table-scroll table.grid th { white-space: nowrap; }
table.grid td.col-center, table.grid th.col-center { text-align: center; }
/* 비활성화된 품목: 목록에서 흐리게 표시 + 이름 옆에 "비활성" 배지 */
tr.row-inactive { opacity: .55; }
.badge-inactive {
  display: inline-block; font-size: 11px; font-weight: 700; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}

/* 체크박스+문구를 한 줄로(예: 필터바의 "비활성 보기"). .simple-form 안에서는 더 구체적인
   규칙(위쪽)이 폰트색 등을 마저 정해준다. */
.checkbox-inline { display: flex; flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; font-size: 13px; }

/* 대시보드 재고 현황: 품목코드/현재고 칸은 줄바꿈되지 않도록 */
.stock-table th:first-child, .stock-table td:first-child,
.stock-table th:last-child, .stock-table td:last-child { white-space: nowrap; }

/* 재고현황 화면: 모든 칸이 줄바꿈 없이 한 줄로 고정된다. 품목코드/품목명/규격처럼 길어질 수 있는
   칸(마지막 두 칸인 재고수정 입력폼·이력 버튼 제외)은 넘치는 글자를 "..."으로 숨기고, title
   속성으로 넣어둔 전체 텍스트가 마우스를 올리면 브라우저 기본 툴팁으로 그대로 보인다. */
.stock-status-table th, .stock-status-table td { white-space: nowrap; }
.stock-status-table td:not(:nth-last-child(-n+2)) {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.stock-status-table td:not(:nth-last-child(-n+2)) .link-btn {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom;
}

/* 대시보드 A/S 진행현황: "출고" 버튼은 표 안에 들어가므로 기본 버튼보다 작게, 테두리는 기본(1px)의 2배 */
.as-flow-table .btn-secondary { display: inline-block; padding: 4px 10px; font-size: 13px; text-decoration: none; border-width: 2px; }
/* 대시보드 A/S 진행현황: 상태 칸의 드롭다운 폼은 기본이 block(flex)이라 td.col-center의
   text-align만으로는 안 가운데로 오므로, inline-flex로 바꿔 가운데 정렬되게 한다 */
.as-flow-table .status-form { display: inline-flex; }

/* 검색 버튼처럼 라벨 텍스트가 없는 항목도, 라벨(텍스트+입력칸)을 가진 항목들의 "입력칸 높이"에 맞춰
   아래쪽으로 정렬한다(center로 두면 라벨 전체 높이의 가운데에 맞춰져 입력칸보다 버튼이 위로 뜬다). */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--border); padding: 12px; border-radius: 8px; }
.filter-bar label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
/* "검색" 버튼과 "+ 작성" 링크는 한 덩어리로 묶어, 필터 칸들이 줄바꿈될 때도 이 둘만 따로 떨어져
   다음 줄로 넘어가지 않고 항상 같은 줄에 붙어 있게 한다(줄바꿈이 필요하면 이 덩어리째로 넘어간다) */
.filter-bar-actions { display: flex; gap: 10px; flex: none; margin-left: auto; }
/* .filter-bar label보다 구체적으로 지정해서, 체크박스+문구 라벨(.checkbox-inline)만은 세로로
   쌓이지 않고 체크박스와 글자가 같은 줄에서 높이가 맞도록 가로로 배치한다 */
.filter-bar label.checkbox-inline { flex-direction: row; align-items: center; gap: 6px; }
.filter-bar .date-range { display: flex; flex-direction: row; align-items: center; gap: 6px; }
/* 날짜 입력칸은 브라우저 기본 폭(약 155px)이 필요 이상으로 넓어 다른 필터 칸들이 줄바꿈되기
   쉬웠다 — "YYYY-MM-DD"만 온전히 보이면 되는 만큼만 줄인다. 스마트폰 브라우저는 type=date를
   자체 위젯으로 그려 옆의 일반 텍스트 입력칸(예: 거래처 검색)보다 세로로 더 크게 나오므로,
   높이도 함께 다른 입력칸과 같도록 고정한다. */
.filter-bar .date-range input[type="date"] { width: 130px; height: 34px; }
.filter-bar input, .filter-bar select, .simple-form input, .simple-form select, .simple-form textarea,
.doc-form input, .doc-form select, .doc-form textarea {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 14px; font-family: inherit;
  background: var(--surface);
}
.filter-bar button, button, .btn-primary, .btn-secondary {
  border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; margin-left: auto; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { color: var(--text); }
.danger { color: var(--danger); border-color: var(--danger); }
/* 작성 페이지 "선택 삭제": 선택된 행이 없으면 회색(비활성), 선택되면 분홍으로 강조 */
#deleteSelectedBtn:disabled {
  color: var(--muted); border-color: var(--border); background: var(--bg);
  cursor: not-allowed; opacity: 1;
}
#deleteSelectedBtn:not(:disabled) {
  color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}
#deleteSelectedBtn:not(:disabled):hover { background: color-mix(in srgb, var(--danger) 18%, var(--surface)); }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

/* 거래처/품목/담당자/회사정보 등록·수정 폼: 페이지 가운데에 2열로 배치해 가독성을 높인다 */
.simple-form {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 24px;
  max-width: 760px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; align-items: start;
}
/* 메일 주소록 등록 폼: 기본 2열 대신 구분/업체/이름/이메일/전화번호 5칸 + "추가" 버튼까지 한 줄로 —
   기본 폼의 760px 폭 제한도 풀어야 칸마다 줄바꿈 없이 들어갈 만큼 넉넉해진다. 버튼 칸은 입력칸들처럼
   늘어나지 않고 내용(글자) 폭만큼만 차지하게 auto로 두고, 라벨(위)+입력칸(아래)인 다른 칸들과 달리
   라벨이 없어 밑으로 붙지 않으니 align-self:end로 입력칸 아랫줄에 맞춘다. */
.simple-form.maddr-form { grid-template-columns: repeat(5, 1fr) auto; max-width: none; }
.simple-form.maddr-form .maddr-add-btn { align-self: end; white-space: nowrap; }
.simple-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
/* 사용자번호 등 중복 확인 결과를 입력칸 바로 아래에 작게 표시 */
.field-check-msg { font-size: 12px; min-height: 14px; }
.field-check-msg.ok { color: var(--st-done); }
.field-check-msg.error { color: var(--danger); }
.simple-form .field-block { display: flex; flex-direction: column; gap: 5px; }
.simple-form .field-label { font-size: 13px; color: var(--muted); }
/* 거래처 등록의 사업자등록증/통장사본: 현재 첨부된 파일명 + 크기 + 삭제 체크박스를 한 줄로 */
.simple-form .attach-current { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 2px; font-size: 13px; color: var(--text); }
.simple-form .attach-current .checkbox-inline { margin-left: auto; }
/* 입고단가/출고단가 라벨 옆에 "부가세 포함" 체크박스를 나란히: 입력칸은 체크박스와 폭을 나눠쓰지 않고 온전히 차지 */
.simple-form .field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.simple-form .field-label-row .checkbox-inline { flex: none; }
.simple-form .price-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.simple-form .price-row input[type="number"] { flex: 1; min-width: 0; }
/* 거래처 주소: 입력칸 옆에 "우편번호 검색" 버튼을 나란히 — 버튼은 글자 폭만, 입력칸이 남는 폭 전부 */
.simple-form .address-search-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.simple-form .address-search-row input { flex: 1; min-width: 0; }
.simple-form .address-search-row button { flex: none; white-space: nowrap; }
.simple-form .inline-fields { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.simple-form .inline-fields select { flex: 1; min-width: 0; }
.simple-form .field-section-title {
  font-size: 14px; font-weight: 700; color: var(--text); margin: 8px 0 -4px;
  padding-top: 16px; border-top: 1px solid var(--border);
}
.simple-form .field-section-title .muted { font-weight: 400; }
.simple-form label.checkbox-inline { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); white-space: nowrap; }
/* 주소·비고처럼 넓게 봐야 하는 항목과 저장/취소 버튼 줄은 2열을 모두 차지한다 */
.simple-form .span-2, .simple-form .form-actions { grid-column: 1 / -1; }
/* 구매처+구매경로, 단위+재고수량+입고단가+출고단가처럼 여러 항목을 한 줄에 나란히 배치할 때 쓰는 하위 그리드.
   전체 폭(2열)을 차지하면서 내부에서 다시 2~4칸으로 나눈다. */
.simple-form .sub-row { grid-column: 1 / -1; display: grid; gap: 16px 24px; align-items: start; }
.simple-form .sub-row > * { min-width: 0; } /* 그리드 칸이 입력값 길이 때문에 카드 밖으로 밀려나지 않도록 */
.simple-form .sub-row.cols-2 { grid-template-columns: 1fr 1fr; }
.simple-form .sub-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.simple-form .sub-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
/* 단위+재고수량+입고단가+출고단가 줄: 단위는 최소한으로 줄이고, 그만큼을 입고/출고단가에 몰아줘서
   12자리 숫자까지 온전히 보이게 한다. */
.simple-form .sub-row.qty-price-row { grid-template-columns: 0.6fr 1fr 2.1fr 2.1fr; }
/* 이 1열 줄바꿈은 본문 페이지의 폼(거래처/품목 등록)에는 더 이상 쓰지 않는다(스마트폰도 이제
   PC와 같은 폭을 쓰고 페이지를 좌우로 스크롤한다). 다만 이 폼이 모달 팝업(예: 목록의 "수정" 팝업)
   안에 들어갈 때는 그 팝업 자체가 화면 폭(vw)에 맞춰 따로 줄어드는 상자라, 좁은 화면에서는 여전히
   1열로 바꿔줘야 한다. */
@media (max-width: 640px) {
  .modal-inner .simple-form { grid-template-columns: 1fr; }
  .modal-inner .simple-form .sub-row.cols-2, .modal-inner .simple-form .sub-row.cols-3,
  .modal-inner .simple-form .sub-row.cols-4, .modal-inner .simple-form .sub-row.qty-price-row { grid-template-columns: 1fr; }
}

.doc-form .form-row { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; align-items: flex-end; position: relative; }
.doc-form .form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
/* 원가 계산 설명 문구: 입력칸들과 같은 줄에서 폭을 다투며 어색하게 줄바꿈되지 않도록,
   .form-row 밖으로 빼서 항상 그 아래에 한 줄 전체 너비로 표시한다 (BOM 작성의 소요일~영업비 칸 등) */
.doc-form .form-row-hint { margin: -6px 0 14px; }
.doc-form .form-row label.grow { flex: 1; min-width: 240px; position: relative; }
.doc-form .form-row label.client-field { flex: 0 0 260px; min-width: 200px; position: relative; }
/* 출고 작성의 "발주번호" 칸: 입력칸 옆에 "주문서 문서번호/거래처 발주번호 중 선택해서 채우기" 콤보를 붙여둔다 */
.po-no-row { display: flex; gap: 6px; }
.po-no-row input { flex: 1; min-width: 0; }
.po-no-source-select { flex: 0 0 auto; max-width: 220px; font-size: 12px; color: var(--muted); }
.client-info {
  display: flex; flex-wrap: wrap; align-items: stretch;
  background: var(--bg); border: 2px solid var(--primary); border-radius: 8px;
  overflow: hidden; font-size: 14px; color: var(--muted); flex-basis: 100%;
}
.client-info .ci-item {
  flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 4px;
  padding: 10px 16px; border-right: 1px solid var(--border);
}
.client-info .ci-item:last-child { border-right: none; }
.client-info .ci-item b { color: var(--muted); font-size: 12px; font-weight: 600; }
.client-info .ci-item span { color: var(--text); font-size: 14px; }
/* 거래처 미선택 상태 — 헤더는 그대로 보이되 강조를 낮춘다 */
.client-info.is-empty { border-color: var(--border); }
.client-info.is-empty .ci-item span { color: var(--muted); }
.form-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.form-actions-inline { margin-left: auto; display: flex; gap: 10px; }
.item-table input { width: 100%; border: 1px solid transparent; background: transparent; padding: 5px 6px; }
.item-table input:focus { border-color: var(--primary); background: var(--surface); }
/* BOM 작성 자재 목록의 "발주관리" 선택칸 */
.item-table .f-purchase-manage { width: 100%; border: 1px solid var(--border); border-radius: 4px; padding: 4px; font-size: 13px; background: var(--surface); }
.item-table .num-input { text-align: right; }
.simple-form input.num-input { text-align: right; }
/* BOM 작성화면: 소요일/소요시간/시간당 인건비/인원 입력칸 */
.labor-input { text-align: right; }
.item-table td { position: relative; vertical-align: middle; }
/* 공용 table.grid는 둥근 모서리를 위해 overflow:hidden인데, 품목/자재 입력 표에서는 그 때문에
   자재코드·자재명·규격 칸의 자동 검색 목록(.ac-list, 칸 아래로 펼쳐짐)이 표 밖으로 나가는 부분이 잘려
   마지막 몇 행에서는 검색 결과가 아예 안 보였다(BOM 수정 등). 입력 표만 잘리지 않게 풀어준다. */
table.grid.item-table { overflow: visible; }
table.grid.item-table th { text-align: center; }

/* 생산입고 작성화면: 품목별 생산 진행률(0~100%) 입력 + 막대바 — 칸 안에서 입력칸/막대 모두 가운데 정렬 */
.progress-cell { min-width: 120px; text-align: center; }
.progress-input-row { display: flex; align-items: center; justify-content: center; gap: 2px; }
/* 다른 품목 입력칸(연하고 포커스 때만 보이는 테두리)과 달리, 0~100/5단위 제한이 있는 진행률 칸은
   항상 굵은 테두리로 눈에 띄게 표시한다 */
.progress-input-row .f-progress {
  /* 세 자리(100)가 잘리지 않도록 넉넉하게. −/+ 버튼이 생겨 브라우저 기본 스피너 화살표는 감춘다(중복) */
  width: 46px; flex: none; text-align: center; padding: 4px 2px;
  border: 2px solid var(--border); background: var(--surface); border-radius: 4px;
  -moz-appearance: textfield;
}
.progress-input-row .f-progress::-webkit-outer-spin-button,
.progress-input-row .f-progress::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.progress-input-row .f-progress:focus { border-color: var(--primary); }
.progress-pct { color: var(--muted); font-size: 12px; }
/* 숫자를 직접 타이핑하지 않아도 눌러서 5씩 조정할 수 있는 버튼 */
.progress-step-btn {
  flex: none; width: 20px; height: 20px; line-height: 1; padding: 0;
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg);
  color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer;
}
.progress-step-btn:hover { background: var(--surface); color: var(--primary); border-color: var(--primary); }
.progress-bar-track {
  margin-top: 4px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden;
  cursor: pointer; /* 클릭한 위치의 %로 바로 값을 맞출 수 있다 */
}
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .15s ease; }
.progress-bar-fill.is-complete { background: var(--st-done); }
.ac-cell { position: relative; }
/* 메일 발송 팝업의 받는사람/참조 칸: 모달 라벨(flex column) 안에서도 입력창이 폭 전체를 채우게 한다 */
.mail-ac-cell { display: block; width: 100%; }
.mail-ac-cell input { width: 100%; box-sizing: border-box; }
.ac-list { position: absolute; top: 100%; left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 20px rgba(0,0,0,.1); min-width: 260px; max-height: 240px; overflow-y: auto; z-index: 40; }
.ac-item { padding: 8px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--bg); }
.toolbar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }
label.block { display: flex; flex-direction: column; gap: 5px; margin: 14px 0; font-size: 13px; color: var(--muted); }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
/* 팝업 배경(.modal)이 반투명 어두운 오버레이라, 다크모드에서는 팝업 상자(.modal-inner)의 면 색이
   그 오버레이 너머로 비치는 뒤 화면과 명도가 비슷해져 테두리가 흐릿해 보였다 — 테두리선과
   그림자를 또렷하게 줘서 팝업 경계가 라이트/다크 모두에서 분명히 보이게 한다. */
.modal-inner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 22px;
  width: 480px; max-width: 92vw; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.modal-inner label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
/* "문서 불러오기" 팝업의 검색 입력칸처럼, .simple-form/.filter-bar/.doc-form 같은 감싸는 폼 클래스
   없이 팝업 안에 바로 놓인 입력칸/선택칸은 테두리 규칙을 못 받아 브라우저 기본 모양(다크모드에서
   거의 안 보임)으로 남아 있었다 — 팝업 안 어디에 있든 기본으로 또렷한 테두리를 갖게 한다
   (이미 자기만의 스타일이 있는 입력칸은 그 값이 그대로 우선 적용된다). */
.modal-inner input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .modal-inner select, .modal-inner textarea {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 14px; background: var(--surface);
}
/* 메일 발송 팝업: 기본 너비(480px)의 1.5배. 메시지 입력칸은 기본 높이(rows=4일 때 66px)의 2.5배.
   textarea는 rows만으로는 줄간격+여백 때문에 정확한 배수가 안 나와 height를 직접 지정한다. */
.send-mail-modal-inner { width: 720px; max-width: 94vw; max-height: 94vh; }
.send-mail-modal-inner #smMessage { height: 320px; }
/* 메일 발송 진행률 바(추정치) — 아래 생산 진행률용 .progress-bar-track과 모양은 같지만, 값을
   직접 입력하는 게 아니라 상태만 보여주는 용도라 cursor:pointer 등 조작 힌트는 빼고 새로 둔다. */
.send-mail-progress { display: flex; align-items: center; gap: 8px; margin-top: -4px; margin-bottom: 4px; }
.send-mail-progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.send-mail-progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: 3px; transition: width .2s ease; }
.send-mail-progress-fill.is-complete { background: var(--st-done); }
.send-mail-progress-pct { flex: none; font-size: 12px; color: var(--muted); min-width: 32px; text-align: right; }
/* 목록에서 특정 칸을 클릭해 수정 팝업을 띄우는 화면 공용 (품목등록/거래처등록 등) */
.item-edit-cell, .client-edit-cell { cursor: pointer; }
.item-edit-cell:hover, .client-edit-cell:hover { text-decoration: underline; color: var(--primary); }
.edit-modal-inner { width: min(800px, 94vw); max-height: 90vh; }
.edit-modal-inner .simple-form { max-width: none; margin: 0; border: none; padding: 0; }
/* 메일 템플릿 추가/수정/보기 팝업: 기본 너비(480px)의 2배 — 메시지 textarea가 넓어야 줄바꿈 없이 읽기 편하다. */
.mail-template-modal-inner { width: min(960px, 96vw); }
.mail-template-modal-inner .simple-form { max-width: none; margin: 0; border: none; padding: 0; }
/* 대시보드 "진행 현황"에서 BOM보기를 누르면 뜨는 팝업 — BOM 조회 화면(자재표+원가+첨부파일)을 그대로 담는다.
   자재 목록에 발주관리·필요수량·현재고까지 12개 칸이 있어 900px로는 가로 스크롤이 생기던 것을,
   팝업을 넓히고(최대 1180px) 자재명 칸은 줄바꿈을 허용해 폭에 맞춰 표가 항상 안에 들어오게 한다.
   overflow-x:hidden은 그래도 아주 좁은 화면에서 모달 박스 자체에 가로 스크롤바가 생기는 걸 막는다
   (표 자체의 스크롤은 위 ".modal-inner table.grid" 규칙이 화면 크기와 무관하게 따로 처리한다). */
.bom-view-modal-inner { width: min(1180px, 96vw); max-height: 90vh; overflow-x: hidden; }
.bom-view-modal-inner .doc-sheet { border: none; padding: 0; margin: 0; box-shadow: none; }
.bom-view-modal-inner .bom-items td:nth-child(3), .bom-view-modal-inner .bom-items th:nth-child(3) {
  white-space: normal; word-break: keep-all; overflow-wrap: anywhere;
}
/* 대시보드 "진행 현황"에서 문서번호/각 단계의 "보기"를 누르면 뜨는 팝업 — 주문서/발주서/거래명세서 등
   조회(인쇄) 화면을 그대로 담는다. 견적서/거래명세서는 서식 폭이 넓어 BOM 팝업보다 조금 더 크게 잡는다. */
.doc-view-modal-inner { width: min(1000px, 96vw); max-height: 92vh; }
.doc-view-modal-inner .doc-sheet, .doc-view-modal-inner .quote-sheet { border: none; padding: 0; margin: 0; box-shadow: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.modal-head h3 { margin: 0; }
/* 팝업 제목 오른쪽에 "[문서유형] 조회 이동" 버튼과 닫기(×)를 같이 묶어둔다 */
.modal-head-actions { display: flex; align-items: center; gap: 8px; }
.modal-close-x {
  background: none; border: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px;
}
.modal-close-x:hover { color: var(--text); }
.src-results { border-top: 1px solid var(--border); padding-top: 8px; max-height: 260px; overflow-y: auto; }
.src-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }

/* 문서 불러오기 모달: 기간/거래처/품목 검색 + 문서 선택 + 품목 체크박스 선택 2단계 UI */
.load-source-modal-inner { width: 1240px; max-width: 96vw; max-height: 92vh; }
.src-search-panel { display: flex; flex-direction: column; gap: 10px; width: 50%; min-width: 320px; }
.src-search-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.src-search-row label { flex: 1 1 140px; min-width: 120px; }
.src-search-row .date-range { display: flex; align-items: center; gap: 6px; }
.src-search-row .date-range input { flex: 1; min-width: 0; }
.src-search-row input, .src-search-row select { font-size: 16px; padding: 8px 10px; }
.src-search-submit-row { justify-content: flex-end; }
.src-search-submit-row button { flex: 0 0 auto; height: 34px; }
.src-items-panel { display: flex; flex-direction: column; gap: 8px; }
.src-items-head { display: flex; justify-content: space-between; align-items: center; }
.src-items-table-wrap { border-top: 1px solid var(--border); padding-top: 8px; max-height: 640px; overflow-y: auto; }
table.src-items-table { width: 100%; font-size: 13px; }
table.src-items-table thead th { position: sticky; top: 0; z-index: 1; }
table.src-items-table tbody tr:hover { background: var(--bg); }
/* 발주서에서 주문서 불러오기: BOM 완제품 헤더행/자재행 구분 표시 */
table.src-items-table tr.src-bom-header td { background: var(--bg); font-weight: 600; border-top: 2px solid var(--border); }
table.src-items-table tr.src-bom-material td { font-size: 12px; }
/* 자재별 "기존 발주서와 연동" 후보 목록 — 자재 행 바로 아래 펼쳐지는 칸 */
table.src-items-table tr.src-link-picker td { background: var(--bg); padding: 8px 10px; }
table.src-items-table .link-po-btn { font-size: 12px; white-space: nowrap; }
/* 이미 연동된 발주서 태그 — 잘못 연동했을 때 옆의 "해제"로 되돌릴 수 있다 */
.linked-po-list { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px; }
.linked-po-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 4px 1px 8px;
}
.linked-po-tag .unlink-po-btn { font-size: 11px; }
table.src-items-table tr.src-bom-material td:nth-child(2) { color: var(--muted); }
/* 검색/닫기 버튼과 겹치지 않도록 적용·닫기 버튼을 모달 맨 아래 한 줄에 나란히 배치 */
.modal-bottom-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.modal-bottom-actions button { flex: 0 0 auto; }

.toolbar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
/* 거래명세서 인쇄 툴바의 "인쇄 세로 크기" 직접 조절 칸 */
.doc-print-size-field { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.doc-print-size-field input { width: 70px; }
/* 견적서/발주서 등 문서 조회 화면(.doc-sheet/.quote-sheet)도 다른 화면과 마찬가지로 다크모드를
   따른다 — "실제 인쇄될 종이 미리보기"라 항상 밝게 고정해뒀던 적이 있었는데, 화면에서까지 흰
   배경을 고집하면 다크모드로 다른 화면을 다 보다가 문서 조회만 눈부신 흰 화면으로 튀는 게 오히려
   불편하다는 피드백으로 되돌렸다. 실제 인쇄/PDF 결과만 아래 @media print에서 항상 밝게 고정된다
   (거기는 종이에 실제로 인쇄되는 값이라 테마와 무관해야 하므로 그대로 유지). */
.doc-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.doc-title { text-align: center; margin: 0 0 20px; font-size: 24px; letter-spacing: 4px; }
.doc-title:has(+ .copy-label) { margin-bottom: 6px; }
.doc-meta { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.doc-meta th, .doc-meta td { border: 1px solid var(--border); padding: 8px 10px; font-size: 14px; }
.doc-meta th { background: var(--bg); width: 12%; text-align: left; }
.doc-meta td.num, .doc-meta th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 거래명세서 전용 "발주일/발주번호/발주담당" 줄: 값이 비어있을 때가 많아 다른 doc-meta 줄과 같은
   12%/균등폭으로 두면 빈 칸만 넓게 남아 보인다 — 라벨/값 모두 가운데 정렬하고, 칸 너비도 균등 배분
   대신 내용 길이에 맞춰 줄어들게(th는 width:1%로 "필요한 만큼만" 힌트를 줘 auto 레이아웃이 늘리지 않게) 한다. */
.po-ref-meta th, .po-ref-meta td { text-align: center; }
.po-ref-meta th { width: 1%; white-space: nowrap; }
/* 값 칸 너비 배분: 발주담당(이름+연락처로 길어서 원래 가장 넓게 남던 칸) 20%p 줄이고,
   발주일·발주번호(원래 좁게 남던 칸)는 각 10%p씩 넓힌다. */
.po-ref-meta td:nth-child(2) { width: 25%; }
.po-ref-meta td:nth-child(4) { width: 25%; }
.po-ref-meta td:nth-child(6) { width: 50%; }
.doc-note { margin-top: 16px; font-size: 14px; background: var(--bg); border: 1px solid var(--border); padding: 12px; border-radius: 8px; white-space: pre-wrap; }
/* BOM 조회 자재 목록 위: 줄 배경색이 뜻하는 바를 설명하는 범례(부족/미사용) */
.bom-color-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.bom-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.bom-legend-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); }
.bom-legend-swatch.is-short { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.bom-legend-swatch.is-unused { background: color-mix(in srgb, var(--st-done) 20%, var(--surface)); }

/* 품목 리스트 아래 수량/공급가액/부가세/합계 + 인수자 서명란 한 줄 요약 (다섯 항목 양쪽 맞춤, 구분 칸막이, 줄바꿈 없이 한 줄 고정) */
.delivery-summary-line {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-between; gap: 10px 0;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; margin-top: 12px; font-size: 13px;
  white-space: nowrap;
}
.delivery-summary-line > span { padding: 0 14px; }
.delivery-summary-line > span:first-child { padding-left: 0; }
.delivery-summary-line > span:last-child { padding-right: 0; }
.delivery-summary-line > span:not(:last-child) { border-right: 1px solid var(--border); }
.delivery-summary-line b { color: var(--muted); margin-right: 4px; }
.delivery-summary-line .receiver-sign { display: flex; align-items: center; gap: 5px; white-space: nowrap; min-width: 14em; justify-content: space-between; }
.delivery-summary-line .receiver-sign .sign-value { text-align: right; }

/* 거래명세서 두 장(공급받는자/공급자 보관용) 인쇄용 라벨 및 절취선 */
.copy-label { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 14px; letter-spacing: 2px; }
.cut-line {
  display: flex; align-items: center; gap: 8px; margin: 28px 0; color: var(--muted); font-size: 12px;
  break-inside: avoid;
}
.cut-line::before, .cut-line::after { content: ''; flex: 1; border-top: 1px dashed var(--border); }

/* 거래명세서 품목이 11줄 이상이면 두 장을 절취선 대신 페이지 나눔으로 분리 */
.page-break { border-top: 2px dashed var(--border); margin: 24px 0; }

/* 모든 인쇄 문서: 품목 리스트 바로 위 합계 금액(한글/숫자) 표시 */
.total-amount-line {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; margin-bottom: 12px; font-size: 14px;
}
.total-amount-korean { text-align: left; font-weight: 600; }
.total-amount-number { text-align: right; font-weight: 700; white-space: nowrap; }

/* 견적서 전용 인쇄 양식 (첨부 PDF 양식 참고) */
.quote-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 28px; }
.quote-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.quote-logo { height: 32px; width: auto; object-fit: contain; }
.quote-title { margin: 0; font-size: 26px; letter-spacing: 6px; }
.quote-info-grid { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.quote-info-col { flex: 1; }
/* 공급받는자 관련 정보(좌)와 공급자 정보(우)를 가운데서 뚜렷하게 분리 */
.quote-info-col + .quote-info-col { border-left: 2px solid var(--text); }
.qi-row { display: flex; border-bottom: 1px solid var(--border); font-size: 13px; }
.qi-row:last-child { border-bottom: none; }
.qi-label { flex: 0 0 84px; background: var(--bg); color: var(--muted); font-weight: 600; padding: 7px 10px; }
.qi-value { flex: 1; padding: 7px 10px; word-break: break-all; }
.qi-value.is-empty { color: var(--muted); }
/* 견적서 "수신" 칸: 담당자명+연락처는 거래처명 다음 줄로 내려가고(위 doc-print.ejs에서 <br>로 분리),
   그 둘 사이는 어중간하게 줄바꿈되지 않고 항상 한 줄에 붙어 보이게 한다 */
.qi-contact { display: inline-block; white-space: nowrap; }
/* 견적서 대표 칸: 직인(도장) 이미지가 칸 높이에 맞춰 줄어들지 않고 칸 밖으로 넘치도록 절대 배치 */
.qi-ceo { position: relative; padding-right: 56px; }
.qi-ceo .seal { color: var(--muted); }
.qi-ceo .stamp {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  height: 46px; width: auto; max-width: 46px; object-fit: contain; opacity: .9; pointer-events: none;
}
.quote-amount-banner {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; margin-bottom: 16px; font-size: 15px; font-weight: 700;
}
.quote-amount-banner .quote-amount-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.quote-amount-banner .quote-amount-value { font-size: 20px; color: var(--primary); }
.quote-extra-box {
  margin-top: 14px; font-size: 13px; background: var(--bg); border-radius: 8px; padding: 10px 14px;
}
.quote-extra-box .qe-row { display: flex; gap: 6px; padding: 2px 0; }
.quote-extra-box .qe-row b { color: var(--muted); flex: 0 0 auto; }

/* 견적서 품목표: 칸 너비를 %로 지정(합계 100%)해서 고정 레이아웃에서 남는 공간 재분배로 값이 틀어지지 않게 함 */
table.grid.quote-items { table-layout: fixed; }
table.grid.quote-items th:nth-child(1), table.grid.quote-items td:nth-child(1) { width: 3.6%; }
table.grid.quote-items th:nth-child(2), table.grid.quote-items td:nth-child(2) { width: 36.72%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid.quote-items th:nth-child(3), table.grid.quote-items td:nth-child(3) { width: 20.97%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid.quote-items th:nth-child(4), table.grid.quote-items td:nth-child(4) { width: 12%; }
table.grid.quote-items th:nth-child(5), table.grid.quote-items td:nth-child(5) { width: 6.6%; }
table.grid.quote-items th:nth-child(6), table.grid.quote-items td:nth-child(6) { width: 20.11%; }
/* NO 칸 가운데 정렬, 수량/단가 칸 오른쪽 정렬 */
table.grid.quote-items td:nth-child(1) { text-align: center; }
table.grid.quote-items td:nth-child(4), table.grid.quote-items td:nth-child(5) { text-align: right; }

/* 인쇄 시에만 입력하는 추가정보 팝업 */
.quote-extra-field { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.quote-extra-field input { flex: 1; border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 13px; background: var(--surface); }
.quote-extra-field .qe-remove { flex: none; color: var(--danger); border-color: var(--danger); padding: 5px 9px; }

/* 공급자 / 공급받는자 정보 (견적서·발주서 등 인쇄 양식) */
.party-box { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.party { flex: 1 1 320px; border-collapse: collapse; }
.party caption {
  caption-side: top; text-align: left; font-size: 13px; font-weight: 700;
  color: var(--muted); padding-bottom: 5px;
}
.party th, .party td { border: 1px solid var(--border); padding: 6px 9px; font-size: 13px; }
.party th { background: var(--bg); width: 74px; text-align: left; color: var(--muted); font-weight: 600; white-space: nowrap; }
.party td { word-break: break-all; }
/* 대표자 칸 위에 도장을 겹쳐 찍는다 — 셀 높이를 늘리지 않도록 절대 배치 */
.party td.ceo-cell { position: relative; }
.party .seal { color: var(--muted); margin-left: 3px; }
.party .stamp {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 55px; width: auto; max-width: 55px; object-fit: contain;
  opacity: .9; pointer-events: none;
}

/* 회사정보 - 도장 업로드 */
.stamp-upload { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.stamp-preview {
  flex: none; width: 96px; height: 96px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); text-align: center; padding: 6px;
}
.stamp-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.stamp-upload-fields { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 6px; }
.stamp-upload-fields .muted { line-height: 1.5; margin: 0; }

.inline-form { display: flex; gap: 6px; align-items: center; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, var(--bg)), var(--bg)); }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 340px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-box h1 { font-size: 18px; text-align: center; margin: 0 0 20px; }
.login-box form { display: flex; flex-direction: column; gap: 10px; }
.login-box label { font-size: 13px; color: var(--muted); }
.login-box input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; margin-top: 4px; background: var(--surface); }
.login-box .login-remember-check { display: flex; align-items: center; gap: 6px; margin-top: -2px; cursor: pointer; }
.login-box .login-remember-check input { width: auto; margin-top: 0; }
.login-box button { margin-top: 8px; background: var(--primary); color: #fff; border: none; padding: 10px; border-radius: 6px; font-size: 15px; cursor: pointer; }
.login-box .error { color: var(--danger); font-size: 13px; }
.login-box .hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.alert-success { background: color-mix(in srgb, var(--st-done) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--st-done) 40%, transparent); color: var(--st-done); }
.alert-error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }

.bulk-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  padding: 9px 14px; border-radius: 8px; margin-bottom: 10px;
}
.bulk-toolbar .bulk-count { font-size: 13px; color: var(--muted); font-weight: 600; margin-right: 4px; }
.bulk-toolbar .bulk-delete { color: var(--danger); border-color: var(--danger); }
table.grid .bulk-exclude:first-child { width: 34px; text-align: center; }
/* 조회 목록의 보기/수정/인쇄(삭제) 액션 링크 사이 간격을 20px로 고정 */
table.grid td.bulk-exclude:last-child { white-space: nowrap; }
table.grid td.bulk-exclude:last-child > * + * { margin-left: 16px; }

.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pagination-info { font-size: 13px; color: var(--muted); }
.pagination-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-pages .page-link {
  display: inline-block; min-width: 30px; text-align: center; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 13px;
}
.pagination-pages .page-link:hover { background: var(--bg); text-decoration: none; }
.pagination-pages .page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination-pages .page-link.disabled { color: var(--border); pointer-events: none; }
.pagination-size select { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px; background: var(--surface); }

.seq-col { color: var(--muted); width: 48px; }
table.grid td.seq-col, table.grid th.seq-col { text-align: center; }

/* 별도 순번 칸/체크박스 없이, 순번이 적힌 원형 배지를 클릭하면 그대로 선택된다.
   실제 체크박스는 화면에서만 숨기고(opacity:0) 배지 위에 겹쳐서 클릭을 그대로 받게 한다 -
   bulk-actions.js는 이 checkbox의 checked 상태를 그대로 보고 동작하므로 로직 변경이 필요 없다.
   이 칸에 display:flex를 주면 표 셀(table-cell) 레이아웃에서 벗어나 헤더의 전체선택
   체크박스 칸과 너비가 서로 달라져(각자 다른 기준으로 너비가 계산됨) 두 줄이 어긋나 보인다.
   그래서 table-cell을 유지한 채 text-align/vertical-align으로만 가운데 정렬한다 —
   배지(.seq-checkbox-badge)가 inline-flex라 text-align도 그대로 먹는다. */
.seq-checkbox-cell { text-align: center; vertical-align: middle; white-space: nowrap; }
.seq-checkbox-badge { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; cursor: pointer; }
.seq-checkbox-badge input[type="checkbox"] {
  position: absolute; inset: 0; margin: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.seq-num-faint {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); opacity: .7; font-size: 11px; flex: none;
  pointer-events: none; /* 클릭은 겹쳐진 체크박스가 받는다 */
}
.seq-checkbox-badge input[type="checkbox"]:checked + .seq-num-faint {
  background: var(--primary); border-color: var(--primary); color: #fff; opacity: 1;
}

/* 원가현황: 완제품코드를 클릭하면(링크 이동 대신) 그 행을 선택해 원가 합계에 반영한다 */
.cost-code-cell { cursor: pointer; }
.cost-code-cell:hover { text-decoration: underline; color: var(--primary); }

.import-bar { justify-content: space-between; }
.import-bar .import-left { display: flex; align-items: center; gap: 10px; }
.import-bar .import-right { display: flex; align-items: center; gap: 14px; }
.import-left .import-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.import-left input[type="file"] {
  height: 36px; box-sizing: border-box; padding: 0 8px 0 0;
  display: inline-flex; align-items: center; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; background: var(--surface);
}
.import-left input[type="file"]::file-selector-button {
  height: 36px; margin-right: 8px; padding: 0 12px; box-sizing: border-box;
  border: none; border-right: 1px solid var(--border); border-radius: 6px 0 0 6px;
  background: var(--bg); color: var(--text); font-size: 13px; font-family: inherit; cursor: pointer;
}
.import-left button[type="submit"] { height: 36px; box-sizing: border-box; }

/* 품목 등록 - 구매처 자동완성 */
.client-picker { position: relative; }
.client-search-input { width: 100%; }
.client-picker-actions { margin-top: 4px; }
.ac-item.ac-empty { color: var(--muted); cursor: default; }
.ac-item.ac-empty:hover { background: none; }

/* 품목 등록 - 부가세 자동계산 힌트 */
.price-calc-hint { font-size: 12px; color: var(--muted); min-height: 16px; }

/* 엑셀 업로드 - 구매처 매칭 팝업 */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: 10px; padding: 22px; width: 100%; max-width: 560px;
  max-height: 82vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-box h3 { margin: 0 0 8px; font-size: 17px; }
.modal-desc { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.modal-body { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.unmatched-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.unmatched-name { font-size: 13px; margin-bottom: 6px; }
.unmatched-select { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
/* 재고 변경 이력 팝업: 열이 많아 기본 480px보다 훨씬 넓게 잡고, 내용이 길면 세로 스크롤 */
.stock-history-modal-inner { width: 1100px; max-width: 96vw; max-height: 80vh; }
/* 이력 표는 모달이 넓어진 만큼 칸 내용이 줄바꿈되지 않고 한 줄로 보인다.
   그래도 넘칠 만큼 긴 내용(내용 칸 등)이 있으면 표만 가로 스크롤된다. */
.stock-history-body { overflow-y: auto; overflow-x: auto; max-height: 55vh; }
.stock-history-body table.grid { white-space: nowrap; }

@media print {
  /* 화면이 다크모드여도 견적서/발주서 등 인쇄 서식은 항상 흰 종이에 검은 글씨로 나와야 하므로,
     테마 변수를 인쇄 시에는 무조건 밝은(기본) 값으로 고정한다.
     다크모드 값을 정하는 ":root[data-theme="dark"]"(47행)와 ":root:not([data-theme="light"])"(31행,
     @media (prefers-color-scheme: dark))는 둘 다 이 아래 평범한 ":root"보다 선택자 명시도가 높아(속성
     선택자 포함) 인쇄 중에도 그대로 이겨버렸다 — 실제 다크모드로 PDF를 뽑으면 이 배너 등 --bg를 쓰는
     요소가 검게 나오던 원인. !important로 명시도와 무관하게 항상 이 값이 이기도록 고정한다. */
  :root {
    --primary: #2563eb !important; --primary-dark: #1d4ed8 !important; --border: #e2e8f0 !important;
    --bg: #ffffff !important; --surface: #ffffff !important; --text: #000000 !important; --muted: #64748b !important;
    --danger: #dc2626 !important; --st-done: #16a34a !important; --st-hold: #d97706 !important;
    --st-partial: #0891b2 !important; --st-ordered: #6d28d9 !important; color-scheme: light !important;
  }
  /* 용지 여백을 0으로 두면 크롬 계열 브라우저가 기본 인쇄 머리글(인쇄 일시·제목)/
     바닥글(URL·페이지 번호)을 표시할 공간이 없어져 자동으로 생략된다.
     대신 내용이 종이 끝에 붙지 않도록 .container에 여백을 넣어 가운데에 배치한다. */
  @page { margin: 0; }
  .sidebar, .mobile-topbar, .sidebar-backdrop, .no-print, .filter-bar, .modal { display: none !important; }
  body.app { display: block; }
  .container { padding: 15mm; max-width: none; }
  /* 브라우저가 인쇄 시 이미지를 흐리게 처리하지 않도록 */
  .party .stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; opacity: 1; }
  /* 인쇄/PDF에서만 대표자 도장을 1.5배 키운다(화면 조회는 기존 크기 그대로) —
     견적서(.qi-ceo)는 46px→69px, 그 외 문서(.party)는 55px→82.5px. */
  .qi-ceo .stamp { height: 69px; max-width: 69px; }
  .party .stamp { height: 82.5px; max-width: 82.5px; }
  /* 인쇄/PDF(발주서 등, 견적서·BOM 제외)에서만 화면보다 글자를 조금 작게 — 화면 조회는 원래 크기 그대로 둔다.
     PDF 생성(lib/pdf.js)도 이 print 미디어를 그대로 적용해서 만들기 때문에 여기 적용하면 PDF에도 반영된다. */
  .doc-sheet { border: none; padding: 0; font-size: 14px; }
  .doc-meta th, .doc-meta td { font-size: 12px; }
  .party th, .party td { font-size: 10px; }
  .doc-items:not(.quote-items):not(.bom-items) th,
  .doc-items:not(.quote-items):not(.bom-items) td { font-size: 10px; }
  /* 규격은 넓혀서 잘 보이게, 수량은 "10,000"처럼 5자리까지만 보이면 되니 좁혀서 그만큼 규격 쪽에 넘겨준다 */
  .doc-items:not(.quote-items):not(.bom-items) td:nth-child(4),
  .doc-items:not(.quote-items):not(.bom-items) th:nth-child(4) { width: 20%; }
  .doc-items:not(.quote-items):not(.bom-items) td:nth-child(5),
  .doc-items:not(.quote-items):not(.bom-items) th:nth-child(5) { width: 6%; }
  /* 납품일자는 26/08/21(YY/MM/DD, views/partials/doc-sheet-body.ejs에서 짧게 표시)만큼만 보이면 되니
     좁히고, 줄어든 만큼 품목명 쪽 너비를 넓힌다. */
  .doc-items:not(.quote-items):not(.bom-items) .col-delivery { width: 8%; }
  .doc-items:not(.quote-items):not(.bom-items) td:nth-child(3),
  .doc-items:not(.quote-items):not(.bom-items) th:nth-child(3) { width: 24%; }
  .quote-sheet { border: none; padding: 0; }
  .quote-amount-banner { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; }

  /* 인쇄/PDF에서만: 품목 표에 칸을 나누는 세로선을 추가한다(화면 조회는 가로줄만 유지) —
     마지막 칸은 표 자체의 오른쪽 테두리와 겹치므로 세로선을 넣지 않는다. */
  .doc-items th, .doc-items td { border-right: 1px solid var(--border); }
  .doc-items th:last-child, .doc-items td:last-child { border-right: none; }
  /* border-collapse:collapse인 표에 border-radius+overflow:hidden을 같이 주면(화면에서 모서리를
     둥글게 하려고 쓴 것) 브라우저가 표 자체의 바깥 테두리를 아예 그리지 않는 경우가 있다(화면에서는
     티가 잘 안 나지만 인쇄에서 그대로 드러난다) — 인쇄에서는 모서리를 각지게 하고 클리핑을 없애
     바깥 테두리가 확실히 그려지게 한다. */
  table.grid.doc-items { border-radius: 0; overflow: visible; }

  /* 인쇄/PDF에서만: 문서에 쓰이는 모든 선(표 테두리·칸 구분선·박스 테두리) 굵기 — 화면 조회는 기존
     굵기 그대로 유지된다. 기존 1px/2px에서 한 단계 더 굵게(1.4px/2.4px) 올렸다(색은 계속 검은색 유지). */
  .doc-meta th, .doc-meta td,
  .party th, .party td,
  .doc-note, .total-amount-line, .delivery-summary-line, .quote-info-grid {
    border-width: 1.4px;
  }
  table.grid { border-width: 1.4px; }
  table.grid th, table.grid td { border-bottom-width: 1.4px; }
  .delivery-summary-line > span:not(:last-child) { border-right-width: 1.4px; }
  .qi-row { border-bottom-width: 1.4px; }
  .cut-line::before, .cut-line::after { border-top-width: 1.4px; }
  .quote-info-col + .quote-info-col { border-left-width: 2.4px; }

  /* 인쇄/PDF에서만: 글자를 한 단계 더 진하게(굵게) — 화면 조회는 기존 굵기 그대로 유지된다.
     .doc-sheet에 걸어두면 안의 모든 글자에 상속되고, <b>/<strong>로 이미 굵게 표시하던 부분은
     그보다 더 굵게(보통 700) 그대로 유지된다. */
  .doc-sheet, .quote-sheet { font-weight: 500; }

  /* 인쇄/PDF에서만: 위 선들을 옅은 회색(--border)이 아니라 검은색으로 — 화면 조회는 그대로 유지 */
  .doc-meta th, .doc-meta td,
  .party th, .party td,
  .doc-note, .total-amount-line, .delivery-summary-line, .quote-info-grid,
  .qi-row, .cut-line::before, .cut-line::after,
  table.grid.doc-items,
  table.grid.doc-items th, table.grid.doc-items td {
    border-color: #000;
  }
  .delivery-summary-line > span:not(:last-child) { border-right-color: #000; }
  .quote-info-col + .quote-info-col { border-left-color: #000; }

  /* justify-content:center로 위아래 가운데 정렬을 시도했으나 실제 인쇄 결과에는 반영되지
     않는 것으로 확인되어(transform과 마찬가지) 되돌렸다. 종이 위쪽에 붙여서 찍는다. */
  .doc-sheet-2up-wrap { display: block; }

  /* 거래명세서: 공급받는자용/공급자용 두 장이 한 페이지에 들어가도록 축소.
     "발주일/발주번호/발주담당" 박스가 늘어난 만큼, 머릿글(제목~담당자 정보)과 꼬리글(합계~비고) 쪽
     여백을 한 단계씩 더 줄여 두 장 + 절취선이 A4 한 장 안에 다시 들어오게 맞춘다.
     ---
     실제 진짜 인쇄 파이프라인(Chrome 헤드리스로 이 화면을 그대로 PDF로 찍어서 확인)으로 따로
     검증해보니, 기존 값(이전 버전)은 두 장을 합친 높이가 A4 한 장보다 아주 살짝(용지 몇 mm)
     더 길어서 — `.doc-sheet-copy`에 걸려있는 break-inside:avoid 때문에 공급자용 카피 전체가
     통째로 다음 페이지로 밀려나 있었다(그래서 첫 페이지엔 "공급받는자용 + 아래쪽 빈 여백"만
     보이고, 둘째 페이지에 공급자용이 따로 찍히고 있었다 — 화면에 "여백"으로 보였던 건 사실
     "다음 페이지로 넘어간 자재"의 흔적이었다). 그래서 세로 값을 늘리는(전 시도) 대신 오히려
     한 단계 더 줄여 한 페이지 안에 여유 있게 들어오게 한 뒤(headless Chrome으로 PDF를 직접
     찍어 1페이지로 나오는 것을 확인), 그 여유분 안에서 다시 최대한 채워 넣은 값이다 — 살짝
     여백을 남겨 둔 건 품목명 등 실제 데이터가 길어져도 다시 2페이지로 밀리지 않게 하기 위한
     안전 여유분이다. */
  /* 13.5px 기본값 — 나머지 값도 전부 같은 비율(13.5/13.2)로 함께 맞췄다. */
  .doc-sheet-copy {
    font-size: 13.5px; line-height: 1.547; transform-origin: top left;
  }
  .doc-sheet-copy .doc-title { font-size: 22.1px; margin-bottom: 3.8px; }
  .doc-sheet-copy .copy-label { margin-bottom: 5.2px; font-size: 13.5px; }
  .doc-sheet-copy .doc-meta th, .doc-sheet-copy .doc-meta td { padding: 5.1px 8.2px; font-size: 13.5px; }
  .doc-sheet-copy .doc-meta { margin-bottom: 7.2px; }
  .doc-sheet-copy .party-box { margin-bottom: 7.2px; }
  .doc-sheet-copy .party th, .doc-sheet-copy .party td { padding: 3.8px 6.1px; font-size: 12.5px; }
  .doc-sheet-copy .party th { width: 52px; }
  .doc-sheet-copy .party caption { font-size: 12.5px; padding-bottom: 3.8px; }
  .doc-sheet-copy .party .stamp { height: 43px; max-width: 43px; }
  .doc-sheet-copy .total-amount-line { padding: 6.5px 12.3px; margin-bottom: 7.2px; font-size: 14.5px; }
  .doc-sheet-copy .doc-items { font-size: 13.5px; }
  /* 위쪽의 .doc-items:not(.quote-items):not(.bom-items) th,td 글자 크기 규칙(:not() 두 개라 명시도가 더 높음)에
     묻혀 실제로는 10px로 찍히던 것을, 명시도를 그만큼 높여 의도한 크기가 그대로 적용되게 한다 */
  .doc-sheet-copy .doc-items:not(.quote-items):not(.bom-items) th,
  .doc-sheet-copy .doc-items:not(.quote-items):not(.bom-items) td { padding: 2.9px 6.1px; font-size: 13.5px; line-height: 1.851; }
  .doc-sheet-copy .delivery-summary-line { padding: 6.5px 12.3px; margin-top: 5.1px; font-size: 13.5px; }
  .doc-sheet-copy .doc-note { margin-top: 5.1px; padding: 6.5px 8.2px; font-size: 13.5px; }
  .doc-sheet-copy, .cut-line { break-inside: avoid; }
  /* 절취선 바로 위/아래 여백 */
  .cut-line { margin: 7.8mm 0; }
  /* 페이지 위아래 바깥 여백도 한 단계 줄인다(좌우는 그대로) */
  .container { padding-top: 10mm; padding-bottom: 10mm; }

  /* 거래명세서 품목 11줄 이상: 공급받는자용/공급자용을 절취선 없이 각각 별도 페이지로 인쇄 */
  .page-break { border: none; margin: 0; page-break-after: always; break-after: page; }
}

/* 캘린더(TimeTree 등 iCal 연동) — 로그인이 필요한 외부 서비스라 화면 안에 그대로 띄울(iframe)
   수 없어서, 서버가 iCal 구독 주소를 읽어와 만든 달력을 직접 그린다(views/calendar.ejs 참고). */
.cal-setup-alert { margin-bottom: 14px; }
.calendar-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav-btn { padding: 6px 12px; font-size: 13px; }
.cal-month-label { margin: 0; min-width: 110px; text-align: center; font-size: 17px; }
.cal-toolbar-actions { display: flex; gap: 8px; }

.cal-grid { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 24px; background: var(--surface); }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-week-head { background: var(--bg); border-bottom: 1px solid var(--border); }
.cal-day-head {
  padding: 8px 0; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted);
}
.cal-day {
  min-height: 92px; padding: 6px; border-right: 1px solid var(--border); border-top: 1px solid var(--border);
  overflow: hidden; background: var(--surface);
}
.cal-week .cal-day:last-child { border-right: none; }
.cal-week:first-of-type .cal-day { border-top: none; }
.cal-day.out { background: var(--bg); color: var(--muted); }
.cal-day.today { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.cal-day-num { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.cal-day.today .cal-day-num { color: var(--primary); }
.cal-event {
  font-size: 11px; line-height: 1.4; padding: 1px 4px; margin-bottom: 2px; border-radius: 4px;
  background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary-dark);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-event-more { font-size: 11px; color: var(--muted); padding-left: 4px; }

.cal-upcoming .section-title { margin-bottom: 8px; }
.cal-upcoming-list { list-style: none; margin: 0; padding: 0; }
.cal-upcoming-item {
  display: flex; align-items: baseline; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.cal-upcoming-date { flex: 0 0 130px; font-weight: 700; color: var(--primary-dark); }
.cal-upcoming-title { flex: 1; }
.cal-upcoming-loc { font-size: 12px; }
