/* 고객 관리(v1.7): 고객사·연락처 목록 필터, 상세 레이아웃, 타임라인, 메모, 중복 정리, CSV 가져오기 */

.card-pad { padding-left: var(--space-4); padding-right: var(--space-4); }
.card-flush > .card-header.card-pad { padding-top: var(--space-4); margin-bottom: var(--space-3); }
.card-flush > p.card-pad:last-child { padding-bottom: var(--space-4); }
.card-header h2 svg, .card > h2 svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--color-text-muted); }

/* 목록 필터(단계·담당자·업종·정렬) */
.filter-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; padding: var(--space-3) var(--space-4); }
.filter-row .field { margin: 0; min-width: 140px; }
.filter-row .field label { font-size: var(--text-xs); color: var(--color-text-muted); }
.card-table th.num, .card-table td.num { text-align: right; }

/* 단계 이름 바꾸기(관리자) */
.stage-editor { margin-bottom: var(--space-4); }
.stage-grid { display: grid; grid-template-columns: max-content 1fr 1fr; gap: var(--space-2) var(--space-3); align-items: center; margin: var(--space-3) 0; }

/* 상세: 왼쪽(기본 정보·명함) + 오른쪽(연락처·발송·메모·타임라인) */
.customer-layout { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: var(--space-4); align-items: start; margin-top: var(--space-4); }
.customer-side { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.customer-side > .card + .card, .customer-layout .detail-main > .card + .card { margin-top: 0; }
.review-layout .customer-side { min-width: 0; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 var(--space-1); }
.card-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-3); }
.card-thumbs figure { margin: 0; }
.card-thumbs figcaption { margin-top: var(--space-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-thumb { width: 100%; aspect-ratio: 1.6; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--color-border); background: var(--color-surface-sunken); }
.hidden-contacts { display: flex; gap: var(--space-2); align-items: center; padding-top: var(--space-2); padding-bottom: var(--space-3); margin: 0; }
.hidden-contacts svg, .dup-panel svg { width: 16px; height: 16px; }
.account-fixed { display: flex; gap: var(--space-2); align-items: center; font-weight: var(--weight-semibold); margin-top: 0; }
.account-fixed svg { width: 18px; height: 18px; color: var(--color-text-muted); }
.form-grid .span-2 { grid-column: 1 / -1; }
.req { color: var(--color-danger); }

/* 소속 이력 */
.affiliation-list { list-style: none; margin: 0; padding: 0; }
.affiliation-list li { padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
.affiliation-list li:last-child { border-bottom: 0; }
.affiliation-list li:not(.is-current) strong { font-weight: var(--weight-medium, 500); }

/* 타임라인 */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 4px; bottom: 4px; width: 2px; background: var(--color-border); }
.timeline-item { position: relative; display: flex; gap: var(--space-3); padding: var(--space-2) 0; }
.timeline-dot { flex: none; position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-surface); border: 2px solid var(--color-border); color: var(--color-text-muted); }
.timeline-dot svg { width: 16px; height: 16px; }
.timeline-item[data-kind="brochure_viewed"] .timeline-dot, .timeline-item[data-kind="brochure_downloaded"] .timeline-dot { border-color: var(--color-success, #1a7f37); color: var(--color-success, #1a7f37); }
.timeline-item[data-kind="brochure_sent"] .timeline-dot, .timeline-item[data-kind="card_saved"] .timeline-dot { border-color: var(--color-primary); color: var(--color-primary); }
.timeline-body { min-width: 0; padding-top: 4px; overflow-wrap: anywhere; }
.timeline-title { font-weight: var(--weight-medium, 500); }

/* 메모 */
.note-form { margin-bottom: var(--space-3); }
.note-form .form-actions { margin-top: var(--space-2); }
.note-list { list-style: none; margin: 0; padding: 0; }
.note-item { position: relative; padding: var(--space-3) var(--space-8) var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.note-item:last-child { border-bottom: 0; }
.note-item .btn { position: absolute; top: var(--space-2); right: 0; }

/* 중복 정리 */
.dup-group + .dup-group { margin-top: var(--space-4); }
.dup-group fieldset { border: 0; margin: 0; padding: 0; }
.dup-list { list-style: none; margin: 0; padding: 0; }
.dup-list li { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
.dup-list li:last-child { border-bottom: 0; }
.dup-list .choice { display: flex; gap: var(--space-2); align-items: flex-start; flex: 1 1 260px; min-width: 0; }
.dup-list .choice input { margin-top: 4px; }
.merge-explain { justify-content: flex-start !important; }

/* CSV 가져오기 */
.import-table tr.is-error td { background: var(--color-danger-soft, #fdecec); }
.import-table tr.is-duplicate td { background: var(--color-warning-soft, #fff7e0); }

@media (max-width: 900px) {
  .customer-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .filter-row { padding: var(--space-3); }
  .filter-row .field { flex: 1 1 45%; min-width: 0; }
  .filter-row .select { width: 100%; }
  .stage-grid { grid-template-columns: 1fr; }
  .stage-grid > .label { display: none; }
  .card-table td.num { text-align: left; }
  .page-header .btn-row, .page-header-actions { flex-wrap: wrap; }
}

/* 화면 다듬기: 접힘 제목 아이콘 크기, 카드 첫 제목 위 여백, 직함 칸이 글자 단위로 줄바꿈되지 않게 */
.stage-editor summary svg { width: 18px; height: 18px; vertical-align: -3px; }
.customer-layout .card > h2:first-child, .customer-side .card > h2:first-child, .detail-main .card > h2:first-child { margin-top: 0; }
.detail-main .card .kv + h3, .detail-main .card .kv + .point-list, .customer-side .card .kv + h3 { margin-top: var(--space-4); }
.card-table td.cell-title { min-width: 9em; }
@media (max-width: 640px) { .card-table td.cell-title { min-width: 0; } }
