/* 계약서 초안 작성기 (contract-builder.html)
   policy-finance.css · export-docs.css(경고 상자·기관 서식 상자 등)를 함께 쓴다. */

.cb-section-builder { padding-top: 50px; }
.cb-section-clauses { background: #faf8f2; border-top: 1px solid #eee7d3; border-bottom: 1px solid #eee7d3; }
.cb-section-forms { padding-top: 10px; }
.cb-noprint {}

/* 자리표시 [ ] */
mark.cb-ph { background: #fff1c2; color: #6b4e00; padding: 0 3px; border-radius: 3px; font-family: inherit; }

/* 개인정보 안내 */
.cb-privacy { display: flex; gap: 12px; align-items: flex-start; max-width: 980px; margin: 12px auto 0; padding: 12px 18px; background: #eef4ee; border: 1px solid #c6dcc6; border-radius: 10px; font-size: .93rem; line-height: 1.7; color: #2f4a2f; }
.cb-privacy > i { color: #2e7d32; margin-top: 4px; flex: none; }
.cb-privacy p { margin: 0; }
.cb-privacy strong { color: #1f4d22; }

/* 단계 표시 */
.cb-steps { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cb-step { font-family: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid #d9cfb4; border-radius: 999px; background: #fff; color: var(--primary-color); font-size: .88rem; font-weight: 700; }
.cb-step span { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: #eef2f8; font-size: .75rem; }
.cb-step:hover { border-color: var(--secondary-color); }
.cb-step.is-active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.cb-step.is-active span { background: var(--secondary-color); color: var(--primary-color); }
.cb-step.is-done span { background: var(--secondary-color); color: var(--primary-color); }
.cb-step.has-err { border-color: #c62828; }
.cb-step:focus-visible { outline: 3px solid var(--secondary-color); outline-offset: 2px; }

/* 입력 + 점검 2단 */
.cb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 26px; margin-top: 22px; align-items: start; }
.cb-form { min-width: 0; }
.cb-card { margin: 0; padding: 22px 24px; background: #fff; border: 1px solid #e5e5e5; border-top: 4px solid var(--secondary-color); border-radius: 12px; min-width: 0; }
.cb-card[hidden] { display: none; }
.cb-card legend { float: left; width: 100%; padding: 0; margin: 0 0 14px; font-size: 1.15rem; font-weight: 700; color: var(--primary-color); display: flex; align-items: center; gap: 8px; }
.cb-card legend + * { clear: both; }
.cb-card-n { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-color); color: #fff; font-size: .85rem; }
.cb-field { margin: 0 0 14px; min-width: 0; }
.cb-field[hidden], .cb-check[hidden], [data-show][hidden] { display: none !important; }
.cb-label { display: block; margin: 0 0 5px; font-size: .88rem; font-weight: 700; color: #333; }
.cb-label small, .cb-sub small { font-weight: 400; color: #888; margin-left: 4px; }
.cb-form input[type="text"], .cb-form input[type="number"], .cb-form input[type="date"], .cb-form select {
    width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #cfd4db; border-radius: 8px; background: #fff; font-family: inherit; font-size: 1rem; color: #222; min-height: 44px;
}
.cb-form input:focus, .cb-form select:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(212, 168, 83, .35); }
.cb-form input[aria-invalid="true"] { border-color: #c62828; background: #fff6f5; }
.cb-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.cb-party { margin-top: 6px; padding: 14px 16px 2px; background: #f7f8fa; border-radius: 10px; }
.cb-party + .cb-party { margin-top: 12px; }
.cb-sub { margin: 0 0 10px; font-weight: 700; color: var(--primary-color); padding-left: 8px; border-left: 3px solid var(--secondary-color); }
.cb-hint { margin: 6px 0 12px; font-size: .84rem; line-height: 1.6; color: #666; }
.cb-hint i { color: var(--secondary-color); margin-right: 3px; }
.cb-indent { margin-left: 30px; }

.cb-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.cb-choice-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cb-choice label, .cb-check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid #e3e3e3; border-radius: 8px; cursor: pointer; background: #fff; }
.cb-choice label:hover, .cb-check:hover { border-color: var(--secondary-color); }
.cb-choice label:has(input:checked), .cb-check:has(input:checked) { border-color: var(--primary-color); background: #f4f6fa; }
.cb-choice input, .cb-check input { flex: none; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary-color); }
.cb-choice span, .cb-check span { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; line-height: 1.5; color: #333; }
.cb-choice small, .cb-check small { font-size: .8rem; color: #777; }
.cb-check { margin: 0 0 10px; }
.cb-check-key { border-color: #e3b5ae; background: #fff7f5; }
.cb-check-key:has(input:checked) { border-color: #c0392b; background: #fff7f5; }
.cb-alert { margin: 0 0 12px; padding: 10px 14px; background: #fdecea; border: 1px solid #f2b8b0; border-radius: 8px; color: #8f2318; font-size: .9rem; line-height: 1.6; }
.cb-alert[hidden] { display: none; }

/* 수출서류 작성기에서 넘겨받은 값 안내 */
.cb-handoff { max-width: 980px; margin: 18px auto 0; padding: 10px 14px; background: #eef4ee; border: 1px solid #c6dcc6; border-radius: 8px; color: #2f4a2f; font-size: .9rem; line-height: 1.6; }
.cb-handoff i { margin-right: 4px; color: #2e7d32; }

/* 품목 */
.cb-items { display: grid; gap: 10px; }
.cb-item { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, 1.1fr) 40px; gap: 8px; align-items: end; padding: 12px; background: #f7f8fa; border-radius: 10px; }
.cb-item .cb-field { margin: 0; }
.cb-item .cb-label { font-size: .78rem; }
.cb-item-del { font-family: inherit; cursor: pointer; width: 40px; height: 44px; border: 1px solid #e0c1bc; background: #fff; color: #a12a1b; border-radius: 8px; }
.cb-item-del:hover { background: #fdecea; }
.cb-item-del:disabled { opacity: .35; cursor: default; }
.cb-item-amt { grid-column: 1 / -1; margin: 0; font-size: .82rem; color: #666; text-align: right; }
.cb-add { margin-top: 10px; font-family: inherit; cursor: pointer; }
.cb-total { margin: 14px 0 0; padding: 10px 14px; background: #f4f6fa; border-radius: 8px; font-size: .95rem; }
.cb-total strong { color: var(--primary-color); font-size: 1.1rem; }
.cb-total small { color: #888; }

.cb-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.cb-nav .pf-btn { font-family: inherit; cursor: pointer; }
.cb-nav .pf-btn:disabled { opacity: .4; cursor: default; }
.cb-nav-pos { font-size: .9rem; color: #777; }
.cb-next { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.cb-next:hover { color: var(--primary-color); background: #fff; }
/* 휴대폰은 누른 뒤에도 hover가 남아 '다음' 글자가 배경색과 같아지거나 '이전'이 채워진 채 남으므로 hover 모양을 끈다 */
@media (hover: none) {
    .cb-nav .pf-btn:hover { background: #fff; color: var(--primary-color); }
    .cb-nav .cb-next:hover { background: var(--primary-color); color: #fff; }
}
.cb-nav .pf-btn:disabled:hover { background: #fff; color: var(--primary-color); }

/* 점검 사이드 */
.cb-side { position: sticky; top: 90px; padding: 18px 18px 16px; background: #fff; border: 1px solid #e3dccb; border-radius: 12px; max-height: calc(100vh - 110px); overflow: auto; }
.cb-side-t { margin: 0 0 10px; font-weight: 700; color: var(--primary-color); }
.cb-side-t i { color: var(--secondary-color); margin-right: 4px; }
.cb-sum { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 0 0 12px; padding: 10px 12px; background: #f7f8fa; border-radius: 8px; font-size: .84rem; }
.cb-sum dt { color: #888; }
.cb-sum dd { margin: 0; color: #222; font-weight: 700; overflow-wrap: anywhere; }
.cb-warns { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cb-warns li { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; font-size: .84rem; line-height: 1.55; }
.cb-warns li i { margin-top: 3px; flex: none; }
.cb-w-error { background: #fdecea; color: #8f2318; border: 1px solid #f2b8b0; }
.cb-w-warn { background: #fff4dc; color: #5c4a1c; border: 1px solid #ead095; }
.cb-w-info { background: #eef2f8; color: #2a3b55; border: 1px solid #d3dcea; }
.cb-w-ok { background: #eef4ee; color: #2f4a2f; border: 1px solid #c6dcc6; }
.cb-warns button { font-family: inherit; cursor: pointer; border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; font-size: inherit; font-weight: 700; }
.cb-side-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.cb-side-btns a { justify-content: center; text-align: center; padding: 10px 8px; font-size: .88rem; }

/* 추천 조항 */
.cb-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; vertical-align: 1px; white-space: nowrap; }
.cb-badge-chk { background: #fdecea; color: #a5281b; }
.cb-badge-opt { background: #eef2f8; color: var(--primary-color); }
.cb-badge-key { background: #c0392b; color: #fff; }
.cb-clauses { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.cb-cl { background: #fff; border: 1px solid #e3dccb; border-left: 4px solid var(--secondary-color); border-radius: 10px; padding: 16px 18px; min-width: 0; }
.cb-cl.is-chk { border-left-color: #c0392b; }
.cb-cl-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 6px; font-size: 1.02rem; color: var(--primary-color); }
.cb-cl-n { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--primary-color); color: #fff; font-size: .78rem; }
.cb-cl-h em { font-style: normal; font-weight: 500; font-size: .85rem; color: #888; }
.cb-cl-why { margin: 0 0 10px; font-size: .86rem; line-height: 1.6; color: #555; }
.cb-cl-why i { color: var(--secondary-color); margin-right: 3px; }
.cb-cl-txt { position: relative; margin: 0 0 8px; padding: 10px 12px; background: #fbfaf6; border: 1px solid #ece4cc; border-radius: 6px; }
.cb-cl-txt p { margin: 0; font-size: .88rem; line-height: 1.65; color: #222; white-space: pre-line; overflow-wrap: anywhere; }
.cb-cl-txt p[lang="en"] { font-family: Georgia, 'Times New Roman', serif; }
.cb-cl-lang { display: block; margin-bottom: 4px; font-size: .72rem; font-weight: 700; color: #998; }
.cb-cl-txt .ed-copy { top: 6px; right: 8px; }
.cb-cl-note { margin: 6px 0 0; padding: 8px 10px; background: #fff6f5; border: 1px dashed #e3b5ae; border-radius: 6px; font-size: .82rem; line-height: 1.6; color: #6b2a22; }
.cb-cl-note i { margin-right: 3px; }
.cb-items-t { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: .84rem; }
.cb-items-t th, .cb-items-t td { border: 1px solid #ddd; padding: 4px 6px; text-align: left; }
.cb-items-t td.num, .cb-items-t th.num { text-align: right; white-space: nowrap; }
.cb-items-t tfoot td { font-weight: 700; }

/* 동의·생성 */
.cb-consent { max-width: 860px; margin: 26px auto 0; padding: 20px 22px; background: #fffaf0; border: 2px solid var(--secondary-color); border-radius: 12px; }
.cb-consent-t { margin: 0 0 12px; font-weight: 700; color: var(--primary-color); }
.cb-consent-t i { color: var(--secondary-color); margin-right: 4px; }
.cb-consent-t small { font-weight: 400; color: #888; }
.cb-consent-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 6px; }
.cb-consent-btns .btn { font-family: inherit; cursor: pointer; border: 0; }
.cb-consent-btns .btn:disabled { opacity: .45; cursor: not-allowed; }
.cb-gen-msg { margin: 0; font-size: .88rem; color: #8f2318; }

/* 초안 미리보기 */
.cb-out { margin-top: 26px; }
.cb-out[hidden] { display: none; }
.cb-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cb-tools .pf-btn { font-family: inherit; cursor: pointer; }
.cb-tools .pf-btn.is-done { background: var(--primary-color); color: #fff; }
.cb-tools-note { flex-basis: 100%; margin: 4px 0 0; font-size: .82rem; color: #777; }
.cb-langbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin: 0 0 12px; padding: 12px 14px; background: #f7f8fa; border: 1px solid #e1e4e8; border-radius: 8px; }
.cb-langbar-t { flex-basis: 100%; font-size: .85rem; font-weight: 700; color: #333; }
.cb-lang-btn { flex: 1 1 0; min-width: 0; padding: 8px 10px; font: inherit; font-size: .92rem; font-weight: 700; color: #333; background: #fff; border: 1.5px solid #cfd4db; border-radius: 6px; cursor: pointer; line-height: 1.3; }
.cb-lang-btn small { display: block; font-size: .74rem; font-weight: 400; color: #888; }
.cb-lang-btn.is-on { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }
.cb-lang-btn.is-on small { color: rgba(255, 255, 255, .85); }
.cb-langbar-note { flex-basis: 100%; margin: 2px 0 0; font-size: .8rem; color: #777; }
.cb-hangul { flex-basis: 100%; margin: 0; padding: 6px 10px; font-size: .84rem; color: #8a4b00; background: #fff6e0; border: 1px solid #f0c36d; border-radius: 6px; }
.cb-hangul[hidden] { display: none; }
.cb-doc {
    position: relative; margin-top: 14px; padding: 34px 40px; background-color: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 4px 18px rgba(0, 0, 0, .06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='240'%3E%3Ctext x='50%25' y='50%25' fill='%23c0392b' fill-opacity='0.07' font-family='sans-serif' font-size='38' font-weight='700' text-anchor='middle' transform='rotate(-28 180 120)'%3E초안 DRAFT%3C/text%3E%3C/svg%3E");
    font-size: .95rem; line-height: 1.7; color: #1a1a1a;
}
.cb-doc[lang="en"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='240'%3E%3Ctext x='50%25' y='50%25' fill='%23c0392b' fill-opacity='0.07' font-family='sans-serif' font-size='38' font-weight='700' text-anchor='middle' transform='rotate(-28 180 120)'%3EDRAFT%3C/text%3E%3C/svg%3E"); }
.cb-doc-warn { margin: 0 0 22px; padding: 12px 14px; border: 2px solid #c0392b; border-radius: 6px; background: #fff7f5; font-size: .86rem; line-height: 1.65; color: #5a1f18; }
.cb-doc-warn strong { color: #a12a1b; }
.cb-doc-warn-end { margin: 26px 0 0; }
.cb-doc-stamp { display: inline-block; margin-bottom: 6px; padding: 2px 10px; border: 2px solid #c0392b; color: #c0392b; font-weight: 700; letter-spacing: .08em; font-size: .8rem; border-radius: 4px; }
.cb-doc h4 { margin: 0 0 4px; text-align: center; font-size: 1.35rem; letter-spacing: .04em; color: #111; font-family: Georgia, 'Times New Roman', serif; }
.cb-doc-sub { margin: 0 0 18px; text-align: center; font-size: .85rem; color: #666; }
.cb-doc h5 { margin: 18px 0 6px; font-size: 1rem; color: #111; }
.cb-doc h5 .cb-badge { margin-left: 6px; }
.cb-doc p { margin: 0 0 8px; white-space: pre-line; }
.cb-doc p[lang="en"] { font-family: Georgia, 'Times New Roman', serif; }
.cb-doc .cb-ko { padding: 6px 10px; background: #f7f8fa; border-left: 3px solid #cfd4db; font-size: .9rem; color: #333; }
.cb-doc .cb-ko-k { display: block; font-size: .72rem; font-weight: 700; color: #888; }
.cb-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 26px; }
.cb-sign div { padding-top: 40px; border-top: 0; }
.cb-sign p { margin: 0; font-size: .88rem; white-space: normal; }
.cb-sign .cb-sign-line { border-top: 1px solid #333; padding-top: 4px; margin-top: 8px; }

/* 인쇄 전용 요소(화면에서는 숨김) */
.cb-print-wm, .cb-print-foot { display: none; }

/* ── 반응형 ── */
@media (max-width: 1100px) {
    .cb-layout { grid-template-columns: 1fr; }
    .cb-side { position: static; max-height: none; }
    .cb-clauses { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .cb-section-builder { padding-top: 30px; }
    .cb-privacy { padding: 12px 14px; font-size: .9rem; }
    .cb-steps { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: 6px; margin-left: -4px; margin-right: -4px; scrollbar-width: thin; }
    .cb-step { white-space: nowrap; padding: 7px 12px; font-size: .84rem; }
    .cb-card { padding: 18px 14px; }
    .cb-grid2 { grid-template-columns: 1fr; }
    .cb-choice, .cb-choice-3 { grid-template-columns: 1fr; }
    .cb-choice-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cb-party { padding: 12px 12px 2px; }
    .cb-indent { margin-left: 0; }
    .cb-item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .cb-item .cb-f-desc { grid-column: 1 / -1; }
    .cb-item-del { width: 100%; grid-column: 1 / -1; height: 36px; }
    .cb-nav { margin-bottom: 6px; }
    .cb-side { padding: 16px 14px; }
    .cb-cl { padding: 14px 12px; }
    .cb-cl-txt .ed-copy { position: static; margin-top: 8px; }
    .cb-consent { padding: 16px 14px; }
    .cb-consent-btns .btn { width: 100%; }
    .cb-tools .pf-btn { flex: 1 1 calc(50% - 8px); justify-content: center; }
    .cb-doc { padding: 20px 14px; font-size: .9rem; }
    .cb-doc h4 { font-size: 1.12rem; }
    .cb-sign { grid-template-columns: 1fr; }
    .cb-items-wrap { overflow-x: auto; }
}

/* ── 인쇄(PDF 저장): 초안만 출력 ── */
@media print {
    @page { margin: 16mm 14mm 20mm; }
    body > *:not(#draft):not(.cb-print-wm):not(.cb-print-foot) { display: none !important; }
    #draft { padding: 0 !important; }
    #draft .cb-noprint, #draft .ed-warn-full { display: none !important; }
    .cb-out { margin: 0; }
    .cb-doc { border: 0; box-shadow: none; padding: 0; background-image: none; font-size: 10.5pt; }
    .cb-doc h5 { break-after: avoid; }
    .cb-doc p { orphans: 3; widows: 3; }
    .cb-sign { break-inside: avoid; }
    .cb-print-wm { display: block; position: fixed; top: 42%; left: 0; right: 0; text-align: center; font-size: 80pt; font-weight: 700; color: rgba(192, 57, 43, .08); transform: rotate(-28deg); z-index: 0; pointer-events: none; }
    .cb-print-foot { display: block; position: fixed; left: 0; right: 0; bottom: 0; margin: 0; text-align: center; font-size: 8pt; color: #a12a1b; border-top: 1px solid #ccc; padding-top: 3px; background: #fff; }
    mark.cb-ph { background: #fff1c2 !important; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
