/* 견적서·세금계산서 위젯 — 배치·상태만. 입력·버튼 기본 모양은 auto-tool.css .lt-widget */
.iv-block { min-width: 0; margin-bottom: 32px; }
.iv-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 문서 종류 */
.document-type-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-width: 520px; }
.lt-widget .type-option { flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 10px 14px; text-align: left; }
.lt-widget .type-option.active { border-color: var(--brand); outline: 1px solid var(--brand); }
.type-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.type-option.active .type-name { color: var(--brand); }
.type-desc { font-size: 13px; font-weight: 400; color: var(--ink3); }

/* 공급자 | 고객 */
.iv-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lt-widget .form-input { width: 100%; }

/* 품목 */
.add-item-form { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 2fr) auto; gap: 8px; margin-bottom: 12px; }
.items-table-container { position: relative; max-width: 100%; overflow-x: auto; } /* relative: 머리글 안 숨김 글자(absolute)가 스크롤 상자 밖으로 나가 쪽 폭을 늘리지 않게 */
.items-table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.items-table th { padding: 8px; text-align: left; font-size: 14px; font-weight: 700; color: var(--ink2); background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.items-table td { padding: 6px 8px; color: var(--ink); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.items-table :is(th, td):nth-child(n+2):nth-child(-n+4) { text-align: right; white-space: nowrap; }
.items-table :is(th, td):last-child { width: 1%; text-align: right; }
.items-table td.items-empty { padding: 24px 8px; text-align: center; color: var(--ink3); }
.lt-widget .btn-delete { min-height: 36px; padding: 0 10px; font-size: 14px; color: var(--danger); }

/* 합계 */
.calculation-summary { max-width: 440px; border-top: 3px double var(--ink); border-bottom: 3px double var(--ink); font-variant-numeric: tabular-nums; }
.summary-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; color: var(--ink2); border-bottom: 1px solid var(--line); }
.summary-row span:last-child { color: var(--ink); }
.summary-row.hidden { display: none; }
.summary-row.total-row { border-bottom: 0; font-weight: 700; }
.summary-row.total-row span:last-child { font-size: 22px; color: var(--brand); }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.lt-widget .btn-primary { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }
.lt-widget .btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }

/* 미리보기 창: 스크립트가 style.display='block' 으로 연다 */
.modal { display: none; position: fixed; inset: 0; z-index: 1000; overflow-y: auto; padding: 24px 16px; background: var(--surface); }
.modal-content { max-width: 800px; margin: 0 auto; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-control); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.lt-widget .modal-header h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 24px 16px; overflow-x: auto; }

.preview-document { color: var(--ink); font-variant-numeric: tabular-nums; }
.document-header { margin-bottom: 24px; text-align: center; }
.lt-widget .document-title { margin: 0 0 4px; font-size: 26px; font-weight: 700; color: var(--ink); letter-spacing: 4px; }
.lt-widget .document-number { margin: 0; font-size: 14px; color: var(--ink3); }
.document-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-bottom: 24px; }
.document-info .info-section h4 { margin: 0 0 8px; padding-bottom: 4px; font-size: 15px; font-weight: 700; color: var(--ink); border-bottom: 2px solid var(--ink); }
.lt-widget .document-info p { margin: 0 0 4px; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.lt-widget .items-heading { margin: 0 0 8px; }
.items-list, .summary-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.items-list th { padding: 6px 8px; text-align: left; font-weight: 700; background: var(--surface); border-bottom: 1px solid var(--line-strong); }
.items-list td { padding: 6px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.items-list .c { text-align: center; }
.items-list .r { text-align: right; white-space: nowrap; }
.summary-table { max-width: 360px; margin: 16px 0 0 auto; border-top: 3px double var(--ink); border-bottom: 3px double var(--ink); }
.summary-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.summary-table td:last-child { text-align: right; white-space: nowrap; }
.summary-table .total-row td { border-bottom: 0; }
.document-footer { margin-top: 32px; padding-top: 16px; text-align: center; border-top: 1px solid var(--line); }
.lt-widget .document-footer p { margin: 0 0 4px; font-size: 14px; color: var(--ink2); }
.lt-widget .document-issued { font-size: 13px; color: var(--ink3); }

@media (max-width: 719px) {
  .iv-parties { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .add-item-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .add-item-form #item-name, .add-item-form button { grid-column: 1 / -1; }
  .lt-widget .btn-delete { min-height: 44px; }
  .action-buttons button { flex: 1 1 0; }
  .document-info { grid-template-columns: minmax(0, 1fr); }
  .modal { padding: 0; }
  .modal-content { border: 0; border-radius: 0; min-height: 100%; }
}

/* 인쇄: 미리보기 문서만 */
@media print {
  body * { visibility: hidden; }
  .preview-document, .preview-document * { visibility: visible; }
  .modal { position: absolute; inset: 0 auto auto 0; width: 100%; padding: 0; overflow: visible; background: transparent; }
  .modal-content { max-width: none; border: 0; }
  .preview-document { position: absolute; left: 0; top: 0; width: 100%; }
}
