/* 문서 선택과 같은 문서의 보기 전환을 구분한다. 기존 화면의 글자/색 토큰을 사용한다. */
#view-estimate #estModeBar.est-workspace {
  display: flex;
  position: relative;
  flex-wrap: wrap !important;
  align-items: center;
  gap: 6px !important;
  padding: 8px 12px !important;
  margin-bottom: 10px;
  border: 1px solid var(--doc-border);
  border-radius: 16px;
  background: linear-gradient(135deg, #f8faff, #fff 65%);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
  min-width: 0;
}
.est-workspace-document { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.est-workspace-document-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.est-workspace-document-title strong { font-size: var(--fs-title); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.est-workspace-document-title .version-list-chip { flex-shrink: 0; }
.est-docswitch-trigger { display: inline-flex; align-items: center; gap: 6px; min-width: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-main); text-align: left; }
.est-docswitch-trigger:hover, .est-docswitch-trigger[aria-expanded="true"] { background: #eff6ff; }
.est-docswitch-caret { flex-shrink: 0; color: var(--accent); }
.est-workspace-views { position: relative; min-width: 0; }
.est-workspace-view-heading { display: flex; align-items: baseline; margin: 0; }
.est-workspace-view-heading strong { font-size: var(--fs-base); }
.est-workspace-note { color: var(--text-sub); font-size: var(--fs-base); line-height: 1.6; margin: 8px 0 0; }
#view-estimate #estModeBar.est-workspace #estModeHint { display: block !important; }
.est-workspace-mode-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px; border-radius: 12px; background: #eef2f8; }
.est-workspace-templates summary { width: fit-content; min-height: 44px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: var(--fs-base); color: var(--text-sub); font-weight: 600; }
.est-workspace-templates summary:hover { color: var(--accent); background: #eff6ff; }
.est-workspace-templates summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#view-estimate #estModeBar.est-workspace button {
  min-height: 44px;
  min-width: 44px;
  font-size: var(--fs-base) !important;
  padding: 8px 10px !important;
  line-height: 1.4;
  cursor: pointer;
  touch-action: manipulation;
  white-space: normal;
}
#view-estimate #estModeBar.est-workspace .est-mode-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}
#view-estimate #estModeBar.est-workspace .est-mode-btn[aria-pressed="true"] { background: var(--accent) !important; color: var(--card-bg) !important; border-color: var(--accent); box-shadow: 0 2px 6px #2563eb26; }
#view-estimate #estModeBar.est-workspace .est-mode-btn[aria-pressed="false"] { background: transparent !important; color: var(--text-sub) !important; }
#view-estimate #estModeBar.est-workspace .est-mode-btn[aria-pressed="false"]:hover { background: var(--card-bg) !important; color: var(--accent) !important; }
.est-workspace-link { border: 1px solid var(--doc-border); border-radius: 8px; background: var(--card-bg); color: var(--accent); font-weight: 600; }
.est-workspace-link:hover { background: var(--bg-main); }
.est-workspace-states { display: grid; gap: 6px; }
.est-workspace-status { margin-inline-start: auto; max-width: 10em; font-size: var(--fs-meta); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.est-workspace-status:empty { display: none; }
.est-workspace-state { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-left: 3px solid #bfdbfe; border-radius: 4px 10px 10px 4px; background: #eff6ff; }
.est-workspace-state > div { min-width: 0; overflow-wrap: anywhere; }
.est-workspace-state strong { font-size: var(--fs-base); color: #1e40af; }
.est-workspace-state p { color: var(--text-sub); font-size: var(--fs-meta); line-height: 1.6; margin: 4px 0 0; }
.est-workspace-state button { flex-shrink: 0; }
#view-estimate #estModeBar.est-workspace .est-workspace-templates { position: relative; margin-inline-start: auto; }
.est-workspace-templates summary { list-style: none; white-space: nowrap; }
.est-workspace-templates summary::-webkit-details-marker { display: none; }
.est-menu-panel {
  position: absolute; z-index: 62; inset-inline-end: 0; top: 100%;
  width: min(22rem, calc(100vw - 48px)); max-height: min(65dvh, 34rem);
  overflow: auto; overscroll-behavior: contain; padding: 14px;
  background: var(--card-bg); border: 1px solid var(--doc-border); border-radius: 12px; box-shadow: var(--shadow-md);
}
.est-menu-panel > * + * { margin-top: 8px; }
.est-menu-buttons, .est-workspace-actions, .est-workspace-project { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.est-workspace-project { font-size: var(--fs-meta); overflow-wrap: anywhere; }
.est-workspace-project .pcs-name, .est-document-info legend { font-weight: 700; }
.est-document-info { min-width: 0; }
.est-menu-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; }
.est-menu-fields label { min-width: 0; color: var(--text-sub); font-size: var(--fs-meta); }
.est-menu-fields input, .est-summary-rate input {
  box-sizing: border-box; min-width: 0; max-width: 100%; border: 1px solid var(--doc-border); border-radius: 6px;
  background: var(--card-bg); color: var(--text-main); font-size: 16px;
}
.est-menu-fields input { display: block; width: 100%; padding: 6px; }
.est-summary-rate label { display: inline-flex; align-items: center; gap: 2px; }
.est-summary-rate input { width: 3em; text-align: center; }
/* 진한 요약 띠 위 흰 입력칸이 «총 공급가액»보다 먼저 눈에 띄었다(2026-11-25) — 띠 색에 묻히는 반투명 칸으로.
   폰은 16px(아이폰 확대 방지) 그대로, 잠금·승인 미리보기의 disabled 는 더 옅게. */
.est-summary-rate input {
  background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); color: #fff; font-weight: 800;
  padding: 1px 2px; line-height: 1.3;
}
.est-summary-rate input:focus { outline: none; border-color: #93c5fd; background: rgba(255, 255, 255, .16); }
.est-summary-rate input:disabled { border-color: transparent; background: transparent; color: rgba(255, 255, 255, .75); }
.est-workspace-status .pcs-save-pending { color: #b45309; }
.est-workspace-status .pcs-save-bad { color: #b91c1c; font-weight: 700; }
#view-estimate #estModeBar.est-workspace #estTplSaveBtn::before,
#view-estimate #estModeBar.est-workspace #estTplLoadBtn::before { content: none; }
#estListView .est-document-heading { flex-wrap: wrap; gap: 12px; }
#estListView .est-document-heading h3 { font-size: var(--fs-title) !important; margin: 0; }
#estListView .est-document-heading > div { flex-wrap: wrap; gap: 8px !important; }
#estListView .est-document-note { font-size: var(--fs-base); color: var(--text-sub); line-height: 1.6; margin: 0 0 16px; }
#estListView .est-document-row { flex-wrap: wrap; gap: 8px !important; }
#estListView .est-document-open { border: 0; background: transparent; color: inherit; text-align: left; font: inherit; padding: 4px; }
#estListView .est-document-open > span { display: block; white-space: normal !important; overflow-wrap: anywhere; }
#estListView .est-document-open > span:first-child { font-size: var(--fs-base) !important; }
#estListView .est-document-open > span:last-child { font-size: var(--fs-meta) !important; line-height: 1.5; }
#estListView .est-document-heading button,
#estListView .est-document-row button { min-height: 44px; min-width: 44px; font-size: var(--fs-base) !important; cursor: pointer; touch-action: manipulation; }
#view-estimate #estModeBar.est-workspace button:focus-visible,
#estListView .est-document-heading button:focus-visible,
#estListView .est-document-row button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#estListView .est-document-row button:disabled { cursor: default; }
@media (max-width: 768px) {
  #view-estimate #estModeBar.est-workspace { padding: 16px !important; }
  #view-estimate #estModeBar.est-workspace .est-workspace-state { flex-direction: column; align-items: stretch; }
  #view-estimate #estModeBar.est-workspace .est-workspace-document { flex-wrap: wrap; }
  #estListView .est-document-heading { flex-direction: column; align-items: stretch !important; }
  #estListView .est-document-open { flex-basis: calc(100% - 42px) !important; }
}

@media (min-width: 769px) {
  #view-estimate:not(.doc-entry) .est-workspace-document { flex: 0 1 auto; min-width: 0; max-width: 40%; }
  #view-estimate:not(.doc-entry) .est-workspace-views { flex: none; }
  #view-estimate:not(.doc-entry) #estQuoteLinkChip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  #view-estimate:not(.doc-entry) .est-docswitch-hint { display: none; }
  #projectContextStrip:has(~ #view-estimate.active:not(.doc-entry)) { display: none; }
  /* 상태 설명은 폰처럼 ⓘ 로 접는다 — 칩 이름은 늘 보이고 문장만 눌러서 편다(_mobileHelp) */
  @layer base { body:not(.pdf-exporting) .est-workspace-state .mobile-help-toggle[hidden] { display: inline-flex !important; } }
  body:not(.pdf-exporting) .est-workspace-state .mobile-help-toggle[hidden] { align-items: center; justify-content: center; border: 0; background: transparent; color: var(--accent); }
  body:not(.pdf-exporting) .est-workspace-state .mobile-help-copy:not(.mobile-help-open) { display: none; }
  body:not(.pdf-exporting) .est-workspace-state .mobile-help-copy.mobile-help-open { display: block; padding-bottom: 8px; }
  /* 숫자 요약: 머리글(설명 말풍선 포함)은 두고 띠만 낮춘다 */
  #view-estimate .doc-table-wrap.est-summary-wrap th,
  #view-estimate .doc-table-wrap.est-summary-wrap td { padding-top: 4px; padding-bottom: 4px; }
  #view-estimate #summarySupply { font-size: var(--fs-title); }
}

/* 넓은 화면(문서 바 한 줄)에서는 «견적과 +○○원» 칩의 숫자가 잘리지 않게 이름 칸 상한을 푼다(2026-11-25) */
@media (min-width: 1280px) {
  #view-estimate:not(.doc-entry) .est-workspace-document { max-width: none; }
  #view-estimate:not(.doc-entry) #estQuoteLinkChip { overflow: visible; text-overflow: clip; max-width: none; flex-shrink: 0; }
}
@media screen and (min-width: 1280px) {
  #view-estimate:not(.doc-entry) #estModeBar.est-workspace { flex-wrap: nowrap !important; }
  #view-estimate:not(.doc-entry) .est-workspace-actions { flex-wrap: nowrap; }
  #view-estimate:not(.doc-entry) #estModeBar .est-workspace-templates { margin-inline-start: 0; }
  #estWorkspaceStatus:empty + .est-workspace-actions { margin-inline-start: auto; }
}
#view-estimate:not(.doc-entry) { position: relative; }
#view-estimate #estTabInfo[hidden] { display: none !important; margin: 0; }
@media screen {
  body:not(.pdf-exporting) #view-estimate:not(.doc-entry) > #guide-estimate { display: none !important; }
  body:not(.pdf-exporting) #view-estimate:not(.doc-entry) > #guide-estimate.est-guide-open {
    display: block !important; position: absolute; inset-inline-end: 0; z-index: 62;
    width: min(24rem, 100%); max-height: 65dvh; overflow: auto; box-shadow: var(--shadow-md);
  }
  #guide-estimate.est-guide-open .mobile-help-copy { display: block !important; }
  @layer base { body:not(.pdf-exporting) #guide-estimate.est-guide-open .mobile-help-toggle[hidden] { display: none !important; } }
}
@media (max-width: 768px) {
  #view-estimate:not(.doc-entry) .est-workspace-document,
  #view-estimate:not(.doc-entry) .est-workspace-views { flex-basis: 100%; min-width: 0; }
  #view-estimate:not(.doc-entry) .est-workspace-actions { display: contents; }
  #view-estimate:not(.doc-entry) .est-workspace-status { margin-inline-start: 0; }
  #view-estimate:not(.doc-entry) #estModeBar .est-workspace-templates { position: static; }
  #view-estimate:not(.doc-entry) .est-menu-panel { width: min(22rem, 100%); }
}
#estModeBar .est-phone-exports { display: none; }
@media screen and (max-width: 768px) {
  #estModeBar .est-workspace-actions .est-export-button { display: none; }
  #estModeBar .est-phone-exports { display: flex; }
}

/* 인쇄는 세로 병합 구분 열과 모든 항목을 사용한다. */
@media screen {
  #estimateTable .c-group { display: none !important; }
  #estimateTable .est-group-name-m {
    display: block !important; flex: 0 1 auto; width: 12em; min-width: 0;
  }
  #estimateTable .est-div-sub { margin-inline-start: auto; }
  #estimateTable .est-fold-count, #estimateTable .est-div-sub { white-space: nowrap; font-size: var(--fs-meta); }
  #estimateTable .est-group-toggle, #estimateTable .est-strip-delete {
    flex: none; min-width: 32px; min-height: 32px; color: var(--text-sub); cursor: pointer;
  }
  #estimateTable .est-strip-delete { font-size: var(--fs-meta); }
  /* ▾ 글리프가 13px 회색이면 점처럼 보인다 — 구분 이름과 같은 인디고·한 단계 크게(2026-11-25 실화면) */
  #estimateTable .est-group-toggle { color: var(--accent); font-size: var(--fs-title); font-weight: 900; line-height: 1; }
  #estimateTable .est-group-toggle:focus-visible, #estimateTable .est-strip-delete:focus-visible {
    outline: 2px solid var(--accent); outline-offset: -2px;
  }
  /* 769~900px 표 복원 규칙과 폰의 table-row !important보다 구체적으로 지정한다. */
  body:not(.pdf-exporting) #estimateTable tbody tr.est-row-collapsed { display: none !important; }
}
@media screen and (max-width: 768px) {
  #estimateTable .est-div-strip > .flex { flex-wrap: wrap; }
  #estimateTable .est-div-strip .est-group-name-m { width: 7em; }
  /* 공용 표 버튼은 36px로 줄어든다. 구분 머리행에는 폰 조작 기준을 유지한다. */
  #estimateTable .est-div-strip :is(.est-group-toggle, .est-strip-delete) {
    min-width: 44px !important; min-height: 44px !important; font-size: var(--fs-base);
  }
}
/* 360폰: 소계가 8자리(«소계 ₩19,320,000»)면 «✕ 구분»이 약 10px 모자라 다음 줄로 꺾였다(2026-11-25) — 이름 칸만 7em→6em */
@media screen and (max-width: 374px) {
  #estimateTable .est-div-strip .est-group-name-m { width: 6em; }
}
@media print {
  #estimateTable .est-group-name-m { display: none !important; }
}
/* 이름표 «이 문서의 보기»는 화면에서만 감춘다(세 버튼 묶음의 aria 이름이라 지우지 않는다) */
#view-estimate #estModeBar.est-workspace .est-workspace-view-heading {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* 내수표의 담당자·날짜는 기존 문서 머리에서 편집한다. */
body.est-mode-internal #view-estimate .est-pct-toggle,
body.est-mode-naesu #view-estimate .est-pct-toggle,
body.est-mode-naesu #view-estimate .est-document-info { display: none; }

/* ── 💵 발주·지급 정산 (estimate-internal.js _buildInternalFooter) ── */
#view-estimate #estInternalFooter.est-int-card {
  margin-bottom: 24px;
  border: 1px solid var(--doc-border);
  border-radius: 16px;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
#estInternalFooter .est-int-row-hidden { display: none !important; }
.est-int-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 10px 20px; background: #1e293b; color: #fff; }
.est-int-head strong { font-size: var(--fs-base); font-weight: 800; }
.est-int-head span { font-size: var(--fs-meta); color: #cbd5e1; }
/* 숨은 칸의 폭은 보이는 칸이 나눠 갖고, 긴 금액이 안 들어가면 칸 단위로 줄을 바꾼다. */
.est-int-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px 0; }
.est-int-cell { flex: 1 1 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 12px; border-radius: 12px; border: 1px solid #eef2f7; background: #f8fafc; }
.est-int-label { font-size: 13px; font-weight: 700; color: #334155; line-height: 1.4; white-space: nowrap; }
.est-int-note { display: none; }
.est-int-value { font-size: 17px; font-weight: 800; color: #1e293b; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.est-int-secondary .est-int-value { font-size: var(--fs-body); }
.est-int-input { flex: 1 1 auto; width: 8ch; min-width: 0; padding: 0; border: 0; border-bottom: 2px solid #fcd34d; background: transparent; outline: none; text-align: right; font-size: 17px; font-weight: 800; color: #78350f; font-variant-numeric: tabular-nums; }
.est-int-input:focus-visible { border-bottom-color: #d97706; }
.est-int-blue { background: #eff6ff; border-color: #dbeafe; } .est-int-blue .est-int-label { color: #1e40af; } .est-int-blue .est-int-value { color: #1d4ed8; }
.est-int-amber { background: #fffbeb; border-color: #fde68a; } .est-int-amber .est-int-label { color: #92400e; } .est-int-amber .est-int-value { color: #b45309; }
.est-int-green { background: #ecfdf5; border-color: #a7f3d0; } .est-int-green .est-int-label { color: #065f46; } .est-int-green .est-int-value { color: #047857; }
.est-int-indigo { background: #eef2ff; border-color: #e0e7ff; } .est-int-indigo .est-int-label { color: #3730a3; } .est-int-indigo .est-int-value { color: #4338ca; }
.est-int-rose { background: #fff1f2; border-color: #ffe4e6; } .est-int-rose .est-int-label { color: #9f1239; } .est-int-rose .est-int-value { color: #be123c; }
.est-int-rate { display: grid; grid-template-columns: auto minmax(24px, 1fr) auto auto; align-items: center; gap: 4px 12px; margin: 8px 14px 10px; padding: 6px 12px; border-radius: 12px; border: 1px solid #eef2f7; background: #f8fafc; }
.est-int-bar { position: relative; height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.est-int-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #10b981; transition: width .2s; }
.est-int-rate-text { font-size: var(--fs-title); font-weight: 800; color: #1e293b; white-space: nowrap; text-align: right; }
.est-int-rate-text.est-int-pending { color: #b45309; }
.est-int-paid-detail { font-size: var(--fs-meta); color: #64748b; line-height: 1.5; }
@media (max-width: 768px) {
  .est-int-head { padding: 10px 14px; }
  .est-int-grid { gap: 6px; padding: 8px 10px 0; }
  .est-int-cell { flex-basis: calc(50% - 3px); min-width: 0; flex-direction: column; align-items: stretch; gap: 0; padding: 5px 10px; }
  .est-int-rate { margin: 6px 10px 8px; }
  .est-int-input { width: 100%; }
  .est-int-rate { grid-template-columns: auto minmax(0, 1fr) auto; }
  .est-int-paid-detail { grid-column: 1 / -1; }
}

/* ── 📱 폰 원가계획 요약 바: 6칸 한 줄 → 3·2·1 격자(금액이 «30,500,…»으로 잘리던 것) ──
   id·.doc-table-wrap 조상은 그대로(두 보기가 이 래퍼를 기준으로 끼워 넣고 숨긴다). 라벨은 칸의 data-label. */
@media (max-width: 768px) {
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full { display: grid !important; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full colgroup,
  #view-estimate .doc-table-wrap.est-summary-wrap th:not(.est-summary-rate) { display: none !important; }
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full :is(thead, tbody),
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full tr:first-child { display: contents !important; }
  #view-estimate .doc-table-wrap.est-summary-wrap .est-summary-rate { grid-row: 2; grid-column: span 3; color: white; background: #1e293b; }
  #view-estimate .doc-table-wrap.est-summary-wrap tbody tr:first-child td { grid-row: 1; }
  #view-estimate .doc-table-wrap.est-summary-wrap tbody tr:first-child :is(#summaryAdmin, #summaryProfit) { grid-row: 3; }
  #view-estimate .doc-table-wrap.est-summary-wrap :is(#summaryAdmin, #summaryProfit)::before { content: none; }
  #view-estimate .doc-table-wrap.est-summary-wrap tbody tr:first-child #summarySupply { grid-row: 4; }
  #view-estimate .doc-table-wrap.est-summary-wrap #summaryPctRow:not(.hidden) { display: grid !important; grid-column: 1 / -1; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full td {
    display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    grid-column: span 2; padding: 8px 4px !important; white-space: normal; overflow: visible; text-overflow: clip;
    font-size: var(--fs-base) !important; font-variant-numeric: tabular-nums;
  }
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full td:nth-child(4),
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full td:nth-child(5) { grid-column: span 3; }
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full td:nth-child(6) { grid-column: 1 / -1; border-top: 1px solid #e2e8f0; }
  #view-estimate .doc-table-wrap.est-summary-wrap table.w-full td::before {
    content: attr(data-label); font-size: var(--fs-badge); font-weight: 700; color: #64748b;
  }
  #view-estimate #summarySupply { font-size: 20px !important; }
}

/* 발주·지급 표 머리(_syncTableHead) — 좁은 «지급» 칸이 «지|급»으로 꺾이고, 폰에선 «수주·발주…»로 잘리던 것 */
body.est-mode-internal #estimateTable thead th.c-del { white-space: nowrap; padding-left: 2px; padding-right: 2px; }
/* 좁은 머리글 «No»·«일/회차»·«단위»가 좌우 여백 8px 때문에 두 줄로 꺾이던 것(2026-10-21) — 산출·견적 표 공통 */
#estimateTable thead th.c-no, #estimateTable thead th.c-days, #estimateTable thead th.c-unit, #estimateTable thead th.c-unit2,
.quote-table thead th.c-qty, .quote-table thead th.c-days, .quote-table thead th.c-unit, .quote-table thead th.c-unit2 { padding-left: 2px; padding-right: 2px; }
#estimateTable thead th.c-unit2, #quoteEditTable thead th.c-unit2, .naesu-table thead th.c-unit2 {
  white-space: normal !important; /* 모바일 내수표 머리글의 nowrap !important 재정의 */
  word-break: keep-all;
  line-height: 1.15;
}
/* 태블릿 폭(769~900)에선 산출 표가 약 750px 에 14칸이라 «No»·«구분(비목)»·«등급/규격»·«수량»이 꺾였다 — 머리글만 한 단계 작게 */
@media (min-width: 769px) and (max-width: 900px) {
  #estimateTable thead th, .quote-table thead th { font-size: var(--fs-meta); padding-left: 3px; padding-right: 3px; }
}
@media (max-width: 768px) {
  body.est-mode-internal #estimateTable thead th.c-price,
  body.est-mode-internal #estimateTable thead th.c-amt { white-space: normal; text-overflow: clip; line-height: 1.25; }
}

/* 내수표 지급액 칸: 거절된 입력(저장 안 됨)은 칸에 그대로 두고 빨갛게 — estimate-naesu.js cellInput */
#view-estimate input.nae-invalid { outline: 2px solid #dc2626; outline-offset: -2px; background: #fef2f2 !important; }

/* 내수표 지급액 칸의 «단위 확인» 단추 — 기본 단추 글자로 튀던 것 */
#view-estimate .nae-unit-btn {
  display: inline-flex; align-items: center; margin-top: 4px; min-height: 28px; padding: 2px 10px;
  border: 1px solid #fcd34d; border-radius: 999px; background: #fffbeb; color: #92400e;
  font-size: var(--fs-badge); font-weight: 700; white-space: nowrap; cursor: pointer;
}
#view-estimate .nae-unit-btn:hover { background: #fef3c7; }
#view-estimate .nae-unit-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  #view-estimate #estModeBar.est-workspace .est-mode-btn,
  #estListView .est-document-row { transition: none !important; }
}
@media print { #view-estimate #estModeBar.est-workspace { display: none !important; } }

/* 견적·산출 버전 목록: 폭 기준은 각 목록의 렌더 시점 offsetWidth다. */
.version-list-row { display:grid; grid-template-columns:22px minmax(0,1fr) auto 44px; align-items:center; gap:2px 8px; padding:4px 10px; border-bottom:1px solid #f1f5f9; }
.version-list-number { color:#94a3b8; font-size:var(--fs-badge); font-weight:800; text-align:right; }
.version-list-name { min-width:0; padding:0; border:0; background:transparent; text-align:left; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#1e293b; font-size:var(--fs-base); font-weight:600; cursor:pointer; }
.version-list-name[aria-current] { color:#1d4ed8; font-weight:800; }
.version-list-meta { grid-row:2; grid-column:1/-1; display:flex; flex-wrap:wrap; align-items:baseline; gap:8px; min-width:0; color:#64748b; font-size:var(--fs-meta); padding-bottom:4px; }
.version-list-date, .version-list-count, .version-list-amount { white-space:nowrap; }
.version-list-details { flex-basis:100%; overflow-wrap:anywhere; }
.version-list-count, .version-list-amount { text-align:right; font-variant-numeric:tabular-nums; }
.version-list-amount { margin-left:auto; color:#334155; font-weight:700; }
.version-list-difference { margin-left:6px; color:#64748b; font-size:var(--fs-badge); font-weight:400; }
.version-list-chips { display:flex; gap:4px; align-items:center; }
.version-list-chip { border-radius:7px; padding:2px 6px; font-size:var(--fs-badge); font-weight:700; white-space:nowrap; }
.version-status-pending_pm { background:#fef3c7; color:#92400e; }
.version-status-pending_admin, .version-status-pending { background:#dbeafe; color:#1e40af; }
.version-status-superseded, .version-status-draft { background:#e2e8f0; color:#475569; }
.version-status-approved { background:#dcfce7; color:#166534; }
.version-status-rejected { background:#fee2e2; color:#991b1b; }
.version-list-latest { background:#eef2ff; color:#4338ca; }
.version-list-more { width:44px; min-height:44px; border:0; border-radius:8px; background:transparent; color:#64748b; font-size:var(--fs-title); font-weight:800; cursor:pointer; }
.version-list-more:hover, .version-list-more[aria-expanded="true"] { background:#eef2ff; color:#4338ca; }
.version-list-row button:focus-visible, .version-list-menu-item:focus-visible { outline:2px solid #2563eb; outline-offset:-2px; }
.version-list-wide { display:grid; grid-template-columns:32px minmax(0,1fr) 82px 36px max-content max-content 54px; column-gap:8px; }
.version-list-wide .version-list-row { grid-column:1/-1; grid-template-columns:subgrid; min-height:52px; }
.version-list-wide .version-list-meta { display:contents; }
.version-list-wide .version-list-details { grid-row:2; grid-column:2/-1; padding-bottom:4px; }
.version-list-wide .version-list-amount { margin:0; }
.version-list-difference:empty { display:none; }
.version-list-wide .version-list-difference { display:inline-block; min-width:7.5em; text-align:right; }
.version-list-wide .version-list-chips { justify-content:flex-end; }
/* 기존 산출 카드의 버튼 줄바꿈 규칙보다 구체적으로 한 줄 격자를 유지한다. */
#estListView .est-document-row.version-list-row { gap:2px 8px !important; }
#estListView .version-list-row .version-list-name { min-width:0; min-height:44px; }
.version-list-menu { position:fixed; z-index:10000; min-width:164px; max-width:calc(100vw - 16px); max-height:calc(100vh - 16px); overflow:auto; padding:4px; border:1px solid #e2e8f0; border-radius:12px; background:#fff; box-shadow:0 8px 24px #0f172a26; }
.version-list-menu[hidden] { display:none; }
.version-list-menu-item { display:block; width:100%; min-height:44px; padding:8px 12px; border:0; border-radius:8px; background:transparent; text-align:left; color:#334155; font-size:var(--fs-base); cursor:pointer; }
.version-list-menu-item:hover { background:#eff6ff; color:#1d4ed8; }
.version-list-menu-item:disabled { opacity:.6; cursor:default; }
.version-list-menu-note { display:block; padding:6px 12px; color:#64748b; font-size:var(--fs-meta); overflow-wrap:anywhere; }

/* ── 문서 전환 드롭다운(est-exp-views.js _estToggleDocSwitcher) — 줄 모양은 위 버전 목록 그대로 ── */
.est-docswitch { position: fixed; z-index: 9000; display: flex; flex-direction: column; width: min(460px, calc(100vw - 16px)); overflow: hidden; border: 1px solid var(--doc-border); border-radius: 12px; background: var(--card-bg); box-shadow: 0 8px 24px #0f172a26; color: var(--text-main); }
.est-docswitch-backdrop { display: none; }
.est-docswitch-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; font-size: var(--fs-base); }
.est-docswitch-close { display: none; min-height: 44px; min-width: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--text-sub); font-size: var(--fs-base); cursor: pointer; }
.est-docswitch-search { flex-shrink: 0; margin: 0 12px 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--doc-border); border-radius: 8px; font-size: var(--fs-base); }
.est-docswitch-warn { flex-shrink: 0; margin-left: 12px; margin-right: 12px; }
.est-docswitch-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; border-top: 1px solid var(--doc-border); }
.est-docswitch-list[aria-busy="true"] { opacity: .6; }
.est-docswitch .version-list-name { min-height: 44px; }
.est-docswitch-empty { margin: 0; padding: 16px; text-align: center; color: var(--text-sub); font-size: var(--fs-base); }
.est-docswitch-foot { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--doc-border); }
.est-docswitch-foot button { min-height: 44px; padding: 8px 12px; font-size: var(--fs-base); cursor: pointer; touch-action: manipulation; }
.est-docswitch button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 768px) {
  .est-docswitch { left: 0; right: 0; bottom: 0; width: auto; max-height: 80vh; max-height: 80dvh; border-width: 1px 0 0; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .est-docswitch-backdrop { display: block; position: fixed; inset: 0; z-index: 8999; background: #0f172a66; }
  .est-docswitch-close { display: block; }
  .est-docswitch-search { font-size: 16px; }
}

/* 문서 전환 창의 아래 동작은 같은 무게로 — 지급 확인은 자주 쓰는 동작이 아니다 */
.est-docswitch-foot { align-items: stretch; }
.est-docswitch-foot > button { margin: 0 !important; background: #fff !important; color: var(--text-main) !important; border: 1px solid var(--doc-border) !important; box-shadow: none !important; }

/* 문서 전환은 눌러 보지 않아도 버튼으로 보이게 */
.est-docswitch-trigger { border: 1px solid var(--doc-border) !important; background: #fff; padding: 6px 10px; min-height: 44px; }
.est-docswitch-hint { flex-shrink: 0; font-size: var(--fs-meta); color: var(--accent); font-weight: 600; }
@media (max-width: 768px) { .est-docswitch-hint { display: none; } .est-docswitch-trigger { flex: 1 1 auto; } }

/* 문서 줄 — 문서가 둘 이상일 때 문서 바 맨 아래 */
.est-doc-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--doc-border); padding-top: 10px; margin-top: 2px; }
.est-doc-row::-webkit-scrollbar { display: none; }
.est-doc-row-item { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; max-width: 240px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-sub); font-size: var(--fs-meta); cursor: pointer; }
.est-doc-row-item:hover { background: #f1f5f9; color: var(--text-main); }
.est-doc-row-item[aria-current="true"] { background: #eff6ff; border-color: #bfdbfe; color: var(--accent); font-weight: 700; cursor: default; }
.est-doc-row-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.est-doc-row-state { flex-shrink: 0; font-weight: 500; opacity: .8; }
.est-doc-row-state.ok { color: #047857; font-weight: 700; opacity: 1; }
.est-doc-row-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 768px) { .est-doc-row { width: 100%; } .est-doc-row-item { min-height: 44px; } }

/* 견적서·지출결의 문서 위 막대 */
.doc-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; margin-bottom: 12px; padding: 8px 12px; border: 1px solid var(--doc-border); border-radius: 12px; background: var(--card-bg); }
.doc-bar .est-doc-row { flex: 1 1 320px; min-width: 0; border-top: 0; padding-top: 0; margin-top: 0; }
.doc-bar-actions { display: flex; flex-shrink: 0; gap: 8px; }
.doc-bar-actions button { min-height: 40px; padding: 0 12px; font-size: var(--fs-meta); }
@media (max-width: 768px) { .doc-bar .est-doc-row { flex-basis: 100%; } .doc-bar-actions button { min-height: 44px; } }

.nae-basis-switch { display: inline-flex; padding: 2px; border: 1px solid #cbd5e1; border-radius: 10px; background: #f1f5f9; }
.nae-basis-switch button { min-height: 44px; padding: 0 12px; border-radius: 8px; color: #475569; font-size: var(--fs-base); font-weight: 700; }
.nae-basis-switch button[aria-pressed="true"] { background: #1e293b; color: #fff; }
.naesu-table thead th.nae-basis-heading { white-space: normal !important; word-break: keep-all; }

/* 산출 표 숫자 칸 여백 — 단가 입력칸이 칸 여백 8px×2 + 입력 여백 5px·12px(.text-right-input)로 33px를 먹어
   1024px 에서 «450,000»까지 잘렸다(2026-11-25 실측). 견적 표(quote-workflow.css «#quoteEditTable .input-no-border»)와 같은 3px. */
@media screen and (min-width: 769px) {
  #estimateTable .input-no-border { padding-left: 3px; padding-right: 3px; }
  #estimateTable tbody :is(td.c-no, td.c-cat, td.c-lvl, td.c-qty, td.c-unit, td.c-days, td.c-unit2, td.c-price, td.c-amt) { padding-left: 4px; padding-right: 4px; }
}
/* 769~1279px(사이드바 펼친 노트북·태블릿 가로)는 표가 약 750px — 비어 있기 쉬운 산출근거를 줄여 단가 8자리·«장비/렌탈»·«NO» 머리글·이름을 살린다.
   1280px 이상·인쇄는 index.html colgroup 비율 그대로(합계 94% 유지, c-group 6% 는 인쇄 전용). */
@media screen and (min-width: 769px) and (max-width: 1279px) {
  body:not(.est-mode-internal) #estimateTable col.c-no { width: 4%; }
  body:not(.est-mode-internal) #estimateTable col.c-cat { width: 10%; }
  body:not(.est-mode-internal) #estimateTable col.c-role { width: 16%; }
  body:not(.est-mode-internal) #estimateTable col.c-lvl { width: 6%; }
  body:not(.est-mode-internal) #estimateTable col.c-qty { width: 6%; }
  body:not(.est-mode-internal) #estimateTable :is(col.c-unit, col.c-unit2) { width: 5%; }
  body:not(.est-mode-internal) #estimateTable :is(col.c-price, col.c-amt) { width: 12%; }
  body:not(.est-mode-internal) #estimateTable col.c-note { width: 6%; }
}
/* 폰(≤768) 산출 표 — 2026-11-25 사장님 «한 화면 + 금액 우선». 입력칸은 16px(아이폰 확대 방지)이라 % 폭이면
   단가 7자리가 잘렸다. 표는 table-layout:fixed — 숫자 칸은 px 로 고정하고 역할 이름 칸이 남는 폭을 갖는다
   (390폰 약 86px·360폰 약 56px, 긴 이름은 끝이 잘리고 누르면 전체가 보인다). 발주·지급(est-mode-internal)은 별도 규칙 그대로. */
@media screen and (max-width: 768px) {
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-no { width: 24px !important; }
  body:not(.est-mode-internal) #estimateTable thead th.c-no { padding-left: 1px !important; padding-right: 1px !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-role { width: auto !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-qty { width: 32px !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-days { width: 34px !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-price { width: 88px !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-amt { width: 86px !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-del { width: 26px !important; }
  body:not(.est-mode-internal) #estimateTable thead th.c-days { white-space: normal; line-height: 1.15; }
  /* 공용 표 버튼 최소 36px 이 26px 칸을 넘어 ✕ 가 반쯤 잘렸다 — 칸을 채우게(누르는 면적 약 26×55px) */
  body:not(.est-mode-internal) #estimateTable tbody td.c-del button { min-width: 0 !important; width: 100%; padding-left: 0; padding-right: 0; }
}
/* 360폰처럼 375px 미만 — 이름 칸이 56px 라 «총괄 PD»도 잘렸다. 금액(86px)은 그대로 두고 ✕·수량만 줄여 이름에 약 6px 를 돌려주고 머리글은 두 줄로. */
@media screen and (max-width: 374px) {
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-qty { width: 30px !important; }
  body:not(.est-mode-internal) #estimateTable :is(col, thead th, tbody td).c-del { width: 22px !important; }
  body:not(.est-mode-internal) #estimateTable thead th.c-role { white-space: normal !important; text-overflow: clip !important; line-height: 1.15; }
}
/* 발주·지급 보기(est-mode-internal) 칸 폭 — 2026-11-25 실측: 800px 에서 단가 7자리, 폰 390 에서 단가(수주·발주 두 입력칸)
   6자리·발주금액 7자리가 잘렸다. 원가계획과 같은 «한 화면 + 금액 우선»: 폰은 숫자 칸 px 고정, 역할 칸이 남는 폭.
   style.css 폰 블록(역할 27%·지급 11% !important)보다 구체적으로 둔다. */
@media screen and (min-width: 769px) and (max-width: 1279px) {
  body.est-mode-internal #estimateTable col.c-role { width: 15%; }
  body.est-mode-internal #estimateTable :is(col.c-price, col.c-amt) { width: 12%; }
  body.est-mode-internal #estimateTable col.c-note { width: 8%; }
}
@media screen and (max-width: 768px) {
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-no { width: 24px !important; }
  body.est-mode-internal #estimateTable thead th.c-no { padding-left: 1px !important; padding-right: 1px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-role { width: auto !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-qty { width: 32px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-days { width: 34px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-price { width: 90px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-amt { width: 90px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-del { width: 40px !important; }
  body.est-mode-internal #estimateTable thead :is(th.c-days, th.c-price, th.c-amt, th.c-del) { white-space: normal; line-height: 1.15; }
  /* 발주금액 입력칸은 굵기 900 이라 7자리 최대 86px — 칸 90px·여백 2px(실측 «3,000,000»). 지급 칸 ✕·💸(최소 36px)는 칸을 채우게 */
  body.est-mode-internal #estimateTable tbody td.c-amt { padding-left: 2px !important; padding-right: 2px !important; }
  body.est-mode-internal #estimateTable tbody td.c-del button { min-width: 0 !important; width: 100%; padding-left: 0; padding-right: 0; }
}
@media screen and (max-width: 374px) {
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-qty { width: 30px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-days { width: 32px !important; }
  body.est-mode-internal #estimateTable :is(col, thead th, tbody td).c-del { width: 38px !important; }
  body.est-mode-internal #estimateTable thead th.c-role { white-space: normal !important; text-overflow: clip !important; line-height: 1.15; }
}

.est-po-vendor { display: block; white-space: normal; font-size: var(--fs-meta); }
#estimateTable .est-po-vendor input { display: block; box-sizing: border-box; width: 100%; min-width: 0; border: 1px solid var(--doc-border); border-radius: 4px; padding: 2px; }
.est-po-mobile { display: none; }
@media screen and (max-width: 768px) {
  .est-po-mobile { display: block; }
  #estimateTable tbody td.c-role .est-po-mobile input { font-size: 16px !important; }
}
.po-dialog { color: #0f172a; font-size: var(--fs-base); }
.po-dialog .os-modal-header { background: #fff; color: #0f172a; border-bottom: 1px solid #e2e8f0; padding: 16px 20px; }
.po-dialog .os-modal-header h3 { font-size: 17px; overflow-wrap: anywhere; }
.po-dialog .os-modal-header small { color: #64748b; font-size: 13px; font-weight: 600; }
.po-dialog .os-modal-close { color: #64748b; }
.po-dialog .po-body { padding: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; }
.po-vendor-list { border-right: 1px solid #e2e8f0; padding: 10px; }
.po-card { display: block; width: 100%; box-sizing: border-box; text-align: left; white-space: normal; overflow-wrap: anywhere; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; padding: 10px 12px; margin-bottom: 8px; font: inherit; color: inherit; }
.po-card[aria-pressed="true"] { border-color: #2563eb; background: #eff6ff; }
.po-card b, .po-card small, .po-summary b, .po-summary small { display: block; }
.po-card small, .po-summary small { color: #475569; }
.po-chip { display: inline-block; margin: 3px 4px 0 0; padding: 1px 7px; border-radius: 999px; font-size: var(--fs-meta); font-weight: 700; }
.po-connected { background: #ecfdf5; color: #047857; }
.po-unmatched { background: #fffbeb; color: #b45309; }
.po-number { background: #eef2ff; color: #3730a3; }
.po-chip[hidden] { display: none; }
.po-unassigned { border-style: dashed; color: #475569; }
.po-fields { min-width: 0; padding: 14px 18px; overflow-wrap: anywhere; }
.po-summary { display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; }
.po-summary > :last-child { text-align: right; }
.po-fields label { display: block; margin-top: 10px; font-size: var(--fs-meta); font-weight: 700; color: #475569; }
.po-fields input, .po-fields textarea { display: block; box-sizing: border-box; width: 100%; min-width: 0; margin-top: 4px; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; color: #0f172a; background: #fff; line-height: 1.45; font-family: inherit; font-size: var(--fs-base); font-weight: 400; }
.po-notice { margin: 10px 0 0; border: 1px solid #fcd34d; border-radius: 8px; background: #fffbeb; color: #92400e; padding: 8px 10px; font-size: var(--fs-meta); }
.po-dialog .os-modal-footer { padding: 12px 20px; }
.po-action { border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; padding: 9px 16px; font: inherit; font-weight: 700; }
.po-primary { border-color: #2563eb; background: #2563eb; color: #fff; }
.po-action:disabled { opacity: .55; }
@media screen and (max-width: 768px) {
  .po-dialog .po-body { display: block; padding: 0 !important; }
  .po-vendor-list { border-right: 0; border-bottom: 1px solid #e2e8f0; }
  .po-fields input, .po-fields textarea { font-size: 16px; }
  .po-card, .po-action, .po-dialog .os-modal-close { min-height: 44px; min-width: 44px; }
}
