/* ==========================================
   보험 CRM - 메인 스타일시트 v3
   ========================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #fff;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --text-main: #1e293b;
  --text-sub: #64748b;
  --text-light: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --header-h: 64px;
  --transition: .2s ease;
}

html { font-size: 15px; }
body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
}

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px;
  height: var(--header-h);
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo i { color: #60a5fa; font-size: 1.3rem; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .93rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
.nav-item.active { background: rgba(96,165,250,.15); color: #60a5fa; }
.nav-item i { width: 18px; text-align: center; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; flex-direction: column; gap: 10px;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  color: var(--sidebar-text); font-size: .85rem;
  overflow: hidden;
}
.user-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info i { font-size: 1.2rem; flex-shrink: 0; }
.btn-logout {
  width: 100%; padding: 8px 12px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; color: #94a3b8;
  font-size: .82rem; font-weight: 600;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 7px;
  font-family: 'Noto Sans KR', sans-serif;
  transition: background .2s, color .2s;
}
.btn-logout:hover { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.3); }

/* ── 메인 래퍼 ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── 상단 헤더 ── */
.top-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.page-title { font-size: 1.2rem; font-weight: 700; color: var(--text-main); }
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: var(--text-sub); padding: 6px;
}

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600;
  border: none; cursor: pointer;
  text-decoration: none; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-ghost { background: transparent; color: var(--text-sub); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text-main); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-sub); padding: 4px 8px; font-size: .9rem; }

/* ── 통계 바 ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding: 20px 28px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.purple { background: #ede9fe; color: var(--purple); }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-main); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-sub); margin-top: 4px; }

/* ── 관리자 보기 토글 버튼 ── */
.view-toggle-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border: 1.5px solid #e2e8f0;
  border-radius: 8px; background: #f8fafc;
  font-size: .8rem; font-weight: 600; color: #64748b;
  cursor: pointer; font-family: 'Noto Sans KR', sans-serif;
  transition: all .15s;
}
.view-toggle-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.view-toggle-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ── 검색바 ── */
.search-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px 16px;
}
.search-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 16px;
  transition: border-color var(--transition);
}
.search-input-wrap:focus-within { border-color: var(--primary); }
.search-input-wrap i { color: var(--text-light); }
.search-input-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: .93rem; color: var(--text-main);
  font-family: 'Noto Sans KR', sans-serif;
}
.filter-group { display: flex; gap: 8px; }
.filter-select {
  padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .88rem;
  color: var(--text-main); background: var(--card-bg);
  cursor: pointer; outline: none; font-family: 'Noto Sans KR', sans-serif;
  transition: border-color var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ── 콘텐츠 영역 ── */
.content-area { padding: 0 28px 32px; }

/* ── 고객 그리드 ── */
.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.customer-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  text-decoration: none;
  display: block;
  color: inherit;
}
.customer-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.card-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--primary); font-weight: 700;
}
.card-actions { display: flex; gap: 4px; }
.card-action-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-sub); font-size: .8rem;
  transition: all var(--transition);
}
.card-action-btn:hover.edit { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.card-action-btn:hover.delete { border-color: var(--danger); color: var(--danger); background: #fee2e2; }

.card-name { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.card-info { font-size: .82rem; color: var(--text-sub); display: flex; flex-direction: column; gap: 4px; }
.card-info span { display: flex; align-items: center; gap: 6px; }
.card-info i { width: 14px; color: var(--text-light); }
.card-footer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  background: var(--primary-light); color: var(--primary);
  padding: 2px 8px; border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.tag.green { background: #d1fae5; color: var(--success); }
.tag.orange { background: #fef3c7; color: #d97706; }
.tag.purple { background: #ede9fe; color: var(--purple); }
.tag.gray { background: #f1f5f9; color: var(--text-sub); }

.doc-count { font-size: .78rem; color: var(--text-light); display: flex; align-items: center; gap: 4px; }

/* ── 상태 배지 ── */
.status-badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: .78rem; font-weight: 600;
}
.status-잠재고객 { background: #f1f5f9; color: var(--text-sub); }
.status-상담중 { background: #fef3c7; color: #d97706; }
.status-계약완료 { background: #d1fae5; color: var(--success); }
.status-유지관리 { background: #dbeafe; color: var(--primary); }

/* ── 로딩 / 빈 상태 ── */
.loading-spinner {
  text-align: center; padding: 60px; color: var(--text-sub); font-size: 1rem;
}
.loading-spinner i { margin-right: 8px; color: var(--primary); }
.empty-state {
  text-align: center; padding: 80px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.empty-state i { font-size: 3rem; color: var(--text-light); }
.empty-state p { color: var(--text-sub); font-size: 1rem; }
.empty-state.small { padding: 40px 20px; }
.empty-state.small i { font-size: 2rem; }

/* ── 페이지네이션 ── */
.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 28px;
}
.page-btn {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--card-bg);
  cursor: pointer; font-size: .88rem; color: var(--text-sub);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active {
  border-color: var(--primary); color: var(--primary); background: var(--primary-light);
}
.page-btn.active { font-weight: 700; }

/* ══════════════════════
   고객 등록 폼 (단일 카드)
   ══════════════════════ */
.form-single {
  max-width: 720px;
  margin: 0 auto;
}

/* 프로필 + 이름/상태 가로 배치 */
.profile-and-basic {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 4px;
}

/* 프로필 사진 업로드 블록 (등록 폼 내) */
.profile-upload-preview {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.profile-upload-preview:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.profile-upload-preview.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}
.profile-upload-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  font-size: 3rem;
  color: var(--primary);
}
.profile-upload-preview img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.profile-upload-overlay {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  color: #fff;
  font-size: .72rem; font-weight: 600;
  pointer-events: none;
}
.profile-upload-overlay i { font-size: 1.2rem; }
.profile-upload-preview:hover .profile-upload-overlay { opacity: 1; }

.profile-upload-actions {
  display: flex; gap: 6px;
  margin-top: 8px;
  justify-content: center;
}
.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* 파일 뷰어 모달 다운로드 버튼: 모바일에서 텍스트 숨기고 아이콘만 표시 */
@media (max-width: 600px) {
  .btn-label-desktop { display: none !important; }
  #pdfDownloadBtn { padding: 6px 10px !important; min-width: 34px; }
  .modal-box.full { max-width: 100%; margin: 6px; border-radius: 12px; }
  .modal-header { padding: 10px 12px !important; gap: 6px !important; }
  .modal-header h2 { font-size: .82rem !important; }
}
.profile-upload-hint {
  font-size: .75rem;
  color: var(--text-light);
  line-height: 1.6;
  text-align: center;
  margin-top: 4px;
}

/* 구분선 */
.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

/* ── 카드 ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  font-size: .95rem; font-weight: 700;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  display: flex; align-items: center; gap: 8px;
}
.card-header i { color: var(--primary); }
.card-body { padding: 20px; }
.mt-16 { margin-top: 16px; }

/* ── PDF(파일) 업로드 ── */
.pdf-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  padding: 28px 16px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}
.pdf-upload-zone:hover { border-color: #2563eb; background: #eff6ff; }
.pdf-upload-content { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pdf-upload-content i { font-size: 2.2rem; color: #2563eb; }
.pdf-upload-content p { font-size: .9rem; font-weight: 600; color: var(--text-main); }
.pdf-upload-content span { font-size: .8rem; color: var(--text-sub); }

.pdf-file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.pdf-file-item {
  display: flex; align-items: center; gap: 10px;
  background: #f8fafc; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  transition: border-color var(--transition);
}
.pdf-file-item:hover { border-color: var(--primary); }
.pdf-file-item i { flex-shrink: 0; }
.pdf-file-info { flex: 1; min-width: 0; }
.pdf-file-name {
  font-size: .85rem; font-weight: 600;
  color: var(--text-main); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.pdf-file-size { font-size: .75rem; color: var(--text-sub); margin-top: 1px; }
.pdf-file-remove {
  flex-shrink: 0; background: none; border: none;
  cursor: pointer; color: var(--text-sub); font-size: .85rem;
  padding: 3px; transition: color var(--transition);
}
.pdf-file-remove:hover { color: var(--danger); }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 14px; }
.form-row.two-col > .form-group { flex: 1; }
.form-label {
  display: block; font-size: .85rem; font-weight: 600;
  color: var(--text-sub); margin-bottom: 6px;
}
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-input, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem; color: var(--text-main);
  font-family: 'Noto Sans KR', sans-serif;
  background: #fff;
  transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border);
}

/* ══════════════════════
   고객 상세
   ══════════════════════ */
.detail-header-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.detail-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; color: var(--primary);
  flex-shrink: 0;
}
.detail-summary { flex: 1; }
.detail-name-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.detail-name-row h2 { font-size: 1.4rem; font-weight: 700; }
.detail-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  font-size: .85rem; color: var(--text-sub);
}
.detail-meta span { display: flex; align-items: center; gap: 5px; }
.detail-meta i { color: var(--text-light); }
.detail-tags { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.detail-date { text-align: right; flex-shrink: 0; }
.detail-date span { font-size: .8rem; color: var(--text-sub); display: block; }
.detail-date strong { font-size: .95rem; color: var(--text-main); }

/* ── 탭 ── */
.tab-menu {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 20px;
  border: none; background: transparent;
  font-size: .88rem; font-weight: 600;
  color: var(--text-sub); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  font-family: 'Noto Sans KR', sans-serif;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge {
  background: var(--primary); color: #fff;
  padding: 1px 7px; border-radius: 20px; font-size: .72rem;
}

/* ── 정보 그리드 ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.info-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.info-card.full-width { grid-column: 1 / -1; }
.info-label {
  font-size: .78rem; font-weight: 600;
  color: var(--text-sub); display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.info-label i { color: var(--primary); }
.info-value { font-size: .9rem; color: var(--text-main); font-weight: 500; }

/* ── 메모 카드 ── */
.memo-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 200px;
  box-shadow: var(--shadow-sm);
}
.memo-content {
  font-size: .9rem; line-height: 1.8; color: var(--text-main);
  white-space: pre-wrap;
}

/* ── 문서 그리드 ── */
.docs-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.doc-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; gap: 10px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.doc-card:hover { border-color: #ef4444; box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-card-icon { font-size: 2.2rem; color: #ef4444; }
.doc-card-name {
  font-size: .88rem; font-weight: 600; color: var(--text-main);
  overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-height: 1.4;
}
.doc-card-type { font-size: .75rem; color: var(--text-sub); }
.doc-card-meta { font-size: .75rem; color: var(--text-light); }
.doc-delete-btn {
  position: absolute; top: 10px; right: 10px;
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-sub); font-size: .75rem;
  opacity: 0; transition: opacity var(--transition), color var(--transition);
}
.doc-card:hover .doc-delete-btn { opacity: 1; }
.doc-delete-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ══════════════════════
   모달
   ══════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  display: flex; flex-direction: column;
  max-height: 90vh;
}
.modal-box.small { max-width: 420px; }
.modal-box.wide { max-width: 760px; }
.modal-box.full { max-width: 1000px; }
.modal-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0 !important;
  gap: 8px !important;
  min-width: 0 !important;
  overflow: hidden !important;
}
.modal-header h2 {
  font-size: .88rem !important;
  font-weight: 700;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex: 1 1 0% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  white-space: nowrap !important;
}
.modal-header h2 i {
  color: var(--primary);
  flex-shrink: 0 !important;
  width: 16px;
}
.modal-header h2 span {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  display: block !important;
  min-width: 0 !important;
}
.modal-actions {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;  /* 버튼 영역 절대 축소 안 됨 */
  white-space: nowrap !important;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: var(--text-sub);
  padding: 6px 8px !important;
  border-radius: 6px; transition: background var(--transition);
  flex-shrink: 0 !important;
  line-height: 1;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* PDF 뷰어 */
.pdf-viewer-wrap { padding: 0; flex: 1; min-height: 600px; }
.pdf-viewer { width: 100%; height: 100%; min-height: 600px; border: none; }

/* 통계 모달 */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.stats-grid h3 { font-size: .95rem; font-weight: 700; margin-bottom: 16px; color: var(--text-main); }
.stats-chart-wrap { display: flex; flex-direction: column; align-items: center; }
.stats-list-wrap {}
.stats-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--bg); margin-bottom: 8px;
  font-size: .9rem;
}
.stats-item-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.stats-dot { width: 10px; height: 10px; border-radius: 50%; }
.stats-item-val { font-weight: 700; color: var(--text-main); }

/* 삭제 확인 */
.delete-name-confirm {
  margin-top: 12px; font-weight: 700; font-size: 1rem;
  color: var(--danger); text-align: center;
}
.text-danger { color: var(--danger) !important; }

/* ── 토스트 알림 ── */
.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: #1e293b; color: #fff;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 9999;
  display: flex; align-items: center; gap: 10px;
  animation: slideUp .3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #3b82f6; }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ══════════════════════
   대시보드 패널
   ══════════════════════ */
.dashboard-panels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0 28px 20px;
}
.dash-panel-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-left: 4px solid transparent;
}
.dash-panel-card.urgent  { border-left-color: #ef4444; }
.dash-panel-card.birthday { border-left-color: #ec4899; }
.dash-panel-card.expiry   { border-left-color: #f59e0b; }
.dash-panel-card.week     { border-left-color: #3b82f6; }
.dash-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.dash-panel-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.dash-panel-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.dash-panel-sub {
  font-size: .78rem;
  color: var(--text-sub);
  margin-top: 2px;
}
.dash-panel-link {
  margin-left: auto;
  font-size: .78rem;
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.dash-panel-link:hover { text-decoration: underline; }
.dash-panel-list { padding: 8px 12px 10px; }
.dash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.dash-item:hover { background: var(--bg); }
.dash-item-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dash-item-body { flex: 1; min-width: 0; }
.dash-item-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-item-sub {
  font-size: .76rem;
  color: var(--text-sub);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-badge {
  font-size: .72rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
  flex-shrink: 0;
  white-space: nowrap;
}
.today-badge   { background: #10b981; color: #fff; }
.birthday-badge { background: #fce7f3; color: #ec4899; }
.urgent-badge  { background: #fee2e2; color: #ef4444; }
.expiry-badge  { background: #fffbeb; color: #f59e0b; }
.week-badge    { background: #dbeafe; color: var(--primary); }
.dash-more-link {
  text-align: center;
  padding: 6px;
  font-size: .78rem;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}
.dash-more-link:hover { text-decoration: underline; }

/* ══════════════════════
   반응형
   ══════════════════════ */
@media (max-width: 1200px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  /* 사이드바 숨김 */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: flex !important; }

  /* 헤더 */
  .top-header { padding: 0 12px; gap: 8px; }
  .page-title { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
  .header-left { gap: 8px; min-width: 0; }
  .header-right { gap: 6px; flex-shrink: 0; }
  /* 버튼 텍스트 숨기고 아이콘만 */
  .header-right .btn { padding: 8px 10px; }
  .header-right .btn span,
  .header-right .btn-text { display: none; }

  /* 그리드/검색 */
  .stats-bar { grid-template-columns: repeat(2, 1fr); padding: 16px; }
  .dashboard-panels { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .search-bar { flex-direction: column; padding: 0 16px 12px; }
  .filter-group { width: 100%; }
  .filter-select { flex: 1; }
  .content-area { padding: 0 12px 24px; }

  /* 고객 상세 헤더 */
  .detail-header-card {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
    gap: 12px;
  }
  .detail-avatar { width: 80px; height: 80px; font-size: 2.6rem; }
  .detail-name-row { justify-content: center; }
  .detail-meta { justify-content: center; flex-direction: column; gap: 8px; align-items: center; }
  .detail-tags { justify-content: center; }
  .detail-date { text-align: center; }
  .info-grid { grid-template-columns: 1fr; }
  .info-card.full-width { grid-column: 1; }

  /* 탭 */
  .tab-menu { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 10px 14px; font-size: .82rem; white-space: nowrap; }
}
@media (max-width: 480px) {
  .stats-bar { grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .stat-card { padding: 12px 14px; }
  .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
  .stat-value { font-size: 1.3rem; }
  .customer-grid { grid-template-columns: 1fr; }
  .profile-and-basic { flex-direction: column; align-items: center; }
  .profile-and-basic > div:last-child { width: 100%; }

  /* 헤더 버튼 아이콘만 표시 */
  .header-right .btn { padding: 7px 9px; min-width: 34px; justify-content: center; }
  .page-title { max-width: 90px; font-size: .9rem; }

  /* 상세 페이지 헤더 버튼 아이콘만 */
  .btn-ghost i, .btn-primary i, .btn-danger i { margin: 0; }
}

/* 사이드바 오버레이 */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 190;
}
.sidebar-overlay.show { display: block; }

/* ══════════════════════
   프로필 사진 업로드 (등록 폼)
   ══════════════════════ */
.profile-upload-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile-upload-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.profile-upload-preview:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}
.profile-upload-preview.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}

.profile-upload-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 2.8rem;
  color: var(--primary);
}

.profile-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* 호버 오버레이 */
.profile-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  pointer-events: none;
}
.profile-upload-overlay i { font-size: 1.3rem; }
.profile-upload-preview:hover .profile-upload-overlay { opacity: 1; }

.profile-upload-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.profile-upload-hint {
  font-size: .78rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* 고객 카드 아바타 - 사진 있을 때 */
.card-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.card-avatar {
  overflow: hidden; /* 사진이 원형 밖으로 나가지 않도록 */
}

/* 상세 페이지 아바타 - 사진 있을 때 */
.detail-avatar {
  overflow: hidden;
}
.detail-avatar.has-photo {
  background: transparent;
  border: 3px solid var(--border);
}
.detail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ══════════════════════════════════════
   보험 계약 카드 & 모달 스타일
   ══════════════════════════════════════ */
.insurance-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: .84rem;
  color: var(--text-sub);
  font-weight: 500;
}
.insurance-summary b { color: var(--primary); }

.insurance-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: box-shadow .15s;
}
.insurance-card:hover { box-shadow: var(--shadow); }

.ins-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.ins-icon-wrap {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: #eff6ff;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: .95rem;
  flex-shrink: 0;
}
.ins-info { flex: 1; min-width: 0; }
.ins-name {
  font-weight: 700;
  font-size: .92rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ins-company { font-size: .78rem; color: var(--text-sub); margin-top: 2px; }
.ins-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.ins-status {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.ins-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .78rem;
  color: var(--text-sub);
}
.ins-details span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ins-memo {
  margin-top: 8px;
  font-size: .80rem;
  color: var(--text-sub);
  background: var(--bg);
  padding: 6px 10px;
  border-radius: 7px;
  line-height: 1.5;
}
.ins-expiry-soon {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  background: #fff7ed;
  color: #f97316;
  border: 1px solid #fed7aa;
}
.ins-expiry-done {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #94a3b8;
}

/* ── 카드 액션 버튼 (수정 / 삭제) ── */
.timeline-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  transition: background .15s, transform .1s;
  background: #eff6ff;
  color: #2563eb;
}
.icon-btn:hover {
  background: #dbeafe;
  transform: scale(1.08);
}
.icon-btn:active {
  transform: scale(.95);
}
.icon-btn.danger {
  background: #fff1f2;
  color: #ef4444;
}
.icon-btn.danger:hover {
  background: #fee2e2;
  transform: scale(1.08);
}

/* 면책·감액 뱃지 (카드 내) */
.ins-period-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.ins-exclusion-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  background: #fee2e2;
  color: #ef4444;
  border: 1px solid #fca5a5;
}
.ins-exclusion-badge.done {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
  text-decoration: line-through;
}
.ins-reduction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  background: #fffbeb;
  color: #f59e0b;
  border: 1px solid #fcd34d;
}
.ins-reduction-badge.done {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
  text-decoration: line-through;
}
.ins-car-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  background: #eff6ff;
  color: #3b82f6;
  border: 1px solid #bfdbfe;
}
/* 90일 이내 만기 임박 — 주황/빨간 강조 */
.ins-car-badge.soon {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fca5a5;
  animation: pulse-badge .8s ease-in-out infinite alternate;
}
/* 만기 완료 */
.ins-car-badge.done {
  background: #f1f5f9;
  color: #94a3b8;
  border-color: #e2e8f0;
  text-decoration: line-through;
}
@keyframes pulse-badge {
  from { opacity: 1; }
  to   { opacity: .65; }
}

/* ══════════════════════════════════════
   만기일 선택 카드 (계약일+만기일+프리셋 통합)
   ══════════════════════════════════════ */
.end-date-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 14px 10px;
  margin-bottom: 12px;
}
/* 년만기/세만기 탭 */
.end-type-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.end-type-tab {
  padding: 5px 16px;
  border-radius: 20px;
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: #6b7280;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.end-type-tab.active {
  background: #1e40af;
  color: #fff;
  border-color: #1e40af;
}
.end-type-tab:not(.active):hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}
/* 프리셋 버튼 행 */
.end-date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.end-preset-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.end-preset-btn:hover {
  border-color: #3b82f6;
  color: #3b82f6;
  background: #eff6ff;
}
.end-preset-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
/* 직접 입력 버튼 */
.end-preset-direct-btn {
  background: #f0fdf4 !important;
  border-color: #86efac !important;
  color: #15803d !important;
}
.end-preset-direct-btn:hover {
  background: #dcfce7 !important;
  border-color: #4ade80 !important;
}
/* 종신 버튼 */
.end-preset-life-btn {
  background: #faf5ff !important;
  border-color: #d8b4fe !important;
  color: #7c3aed !important;
}
.end-preset-life-btn:hover {
  background: #f3e8ff !important;
  border-color: #a855f7 !important;
}
.end-preset-life-btn.active {
  background: #7c3aed !important;
  color: #fff !important;
  border-color: #7c3aed !important;
}

/* ══════════════════════════════════════
   보험 모달 내 섹션 스타일
   ══════════════════════════════════════ */
.ins-section-title {
  font-size: .84rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.ins-section-title:first-child { margin-top: 0; }

.ins-notice-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .80rem;
  line-height: 1.6;
  margin-bottom: 12px;
}
.ins-notice-box.orange {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #92400e;
}
.ins-notice-box.blue {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}
.ins-notice-box i { margin-top: 2px; flex-shrink: 0; }

.ins-period-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 4px;
}
@media (max-width: 600px) {
  .ins-period-grid { grid-template-columns: 1fr; }
}

.ins-period-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .15s;
}
.ins-period-card:has(input:checked) {
  border-color: #f97316;
}
.ins-period-card:has(#insReductionCheck:checked) {
  border-color: #f59e0b;
}

.ins-period-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ins-toggle-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: .88rem;
  user-select: none;
}
.ins-toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.ins-period-status {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: .78rem;
  font-weight: 600;
  background: #f8fafc;
  color: var(--text-sub);
  line-height: 1.5;
}
.ins-period-status.active { background: #fee2e2; color: #b91c1c; }
.ins-period-status.done   { background: #f0fdf4; color: #166534; }
.ins-period-status.info   { background: #eff6ff; color: #2563eb; }

/* ── 자동차보험 만기일 모드 선택 ── */
.car-expiry-mode-wrap {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.car-mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.car-mode-btn input[type="radio"] { display: none; }
.car-mode-btn.active {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #2563eb;
}
.car-mode-btn:hover:not(.active) {
  border-color: #94a3b8;
  background: #f8fafc;
}
.car-expiry-mode-tag {
  font-size: .72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 2px;
}
.car-expiry-mode-tag.auto-tag   { background: #dbeafe; color: #2563eb; }
.car-expiry-mode-tag.manual-tag { background: #fef3c7; color: #b45309; }

/* 모달 wide */
.modal-box.wide {
  width: min(680px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
}

/* ══════════════════════════════════════
   면책·감액 기간 새 UI (card2 방식)
   ══════════════════════════════════════ */

/* 카드 컨테이너 */
.ins-period-card2 {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color .2s;
}
.ins-period-card2.active-excl { border-color: #ef4444; }
.ins-period-card2.active-red  { border-color: #f59e0b; }

/* 토글 행 */
.ins-period-toggle-row {
  padding: 13px 16px;
  background: var(--bg);
}
.ins-toggle-label2 {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.ins-toggle-label2 strong {
  display: block;
  font-size: .9rem;
  color: var(--text);
}
.ins-toggle-label2 small {
  display: block;
  font-size: .75rem;
  color: var(--text-sub);
  margin-top: 1px;
}

/* 토글 스위치 */
.ins-toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.ins-toggle-switch input { opacity: 0; width: 0; height: 0; }
.ins-toggle-slider {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: .25s;
  cursor: pointer;
}
.ins-toggle-slider:before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.ins-toggle-switch input:checked + .ins-toggle-slider { background: var(--primary); }
.ins-toggle-switch input:checked + .ins-toggle-slider:before { transform: translateX(18px); }

/* 아이콘 */
.ins-toggle-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.ins-toggle-icon.red    { background: #fee2e2; color: #ef4444; }
.ins-toggle-icon.yellow { background: #fffbeb; color: #f59e0b; }

/* 바디 (펼쳐지는 영역) */
#exclusionBody, #reductionBody {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}

/* 일수 설정 행 */
.ins-days-row {
  padding-top: 14px;
}
.ins-days-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}
.ins-preset-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.ins-preset-btn:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.ins-preset-btn.active { border-color: var(--primary); color: #fff; background: var(--primary); }

.ins-days-direct { display: flex; flex-direction: column; gap: 4px; }
.ins-days-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ins-days-input {
  width: 110px !important;
  text-align: center;
  font-size: .95rem;
  font-weight: 700;
}
.ins-days-unit {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-sub);
}

/* 감액 비율 행 */
.ins-rate-row {
  padding: 10px 0 4px;
  border-top: 1px dashed var(--border);
  margin-top: 10px;
}
.ins-rate-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 8px;
}

/* 결과(종료일) 행 */
.ins-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  flex-wrap: wrap;
}
.ins-result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}
.ins-result-label {
  font-size: .74rem;
  color: var(--text-sub);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ins-result-value {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
}
.ins-result-date {
  font-size: .86rem !important;
  font-weight: 600 !important;
  padding: 6px 8px !important;
}
.ins-result-arrow {
  color: var(--text-sub);
  font-size: .9rem;
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .ins-result-row { flex-direction: column; }
  .ins-result-arrow { transform: rotate(90deg); }
  .ins-days-input { width: 90px !important; }
}

/* ══════════════════════════════════════
   상담이력 타임라인 카드
   ══════════════════════════════════════ */
.timeline-item {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.timeline-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 14px;
}
.timeline-card {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.timeline-header-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.timeline-type {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 4px;
}
.timeline-date {
  font-size: .76rem;
  color: var(--text-light);
}
.timeline-result {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.timeline-content {
  font-size: .86rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 6px;
  word-break: break-word;
}
.timeline-next {
  font-size: .78rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}
.timeline-memo {
  font-size: .78rem;
  color: var(--text-sub);
  background: var(--bg);
  padding: 5px 10px;
  border-radius: 6px;
  margin-top: 6px;
}
.timeline-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   일정 카드
   ══════════════════════════════════════ */
.schedule-item {
  display: flex;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: opacity .2s;
}
.schedule-item.past { opacity: .65; }
.schedule-item.today { border-color: #3b82f6; background: #eff6ff10; }

.sched-left { flex-shrink: 0; }
.sched-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem;
}
.sched-body { flex: 1; min-width: 0; }
.sched-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.sched-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.sched-title {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}
.sched-auto-badge {
  font-size: .70rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.sched-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.sched-actions {
  display: flex;
  gap: 5px;
}
.sched-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .76rem;
  color: var(--text-sub);
}
.sched-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sched-memo {
  font-size: .78rem;
  color: var(--text-sub);
  background: var(--bg);
  padding: 5px 10px;
  border-radius: 6px;
  margin-top: 6px;
  word-break: break-word;
}

/* D-day 뱃지 */
.d-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.d-badge.today   { background: #fef9c3; color: #ca8a04; border: 1px solid #fde68a; }
.d-badge.upcoming{ background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.d-badge.past    { background: #f1f5f9; color: #94a3b8; border: 1px solid #e2e8f0; }

/* 작은 icon-btn (일정 카드용) */
.icon-btn.sm {
  width: 28px;
  height: 28px;
  font-size: .78rem;
  border-radius: 7px;
}

/* settings.html - 연결 테스트 결과 */
.ocr-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: .88rem;
  line-height: 1.6;
}
.ocr-status.analyzing {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}
.ocr-status.success {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #15803d;
}
.ocr-status.error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #be123c;
}
.ai-analyze-box {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.ai-analyze-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: .95rem;
  font-weight: 700;
  color: #1e40af;
}
.ai-analyze-header i {
  margin-right: 6px;
  color: #6366f1;
}
.ai-key-ok {
  font-size: .78rem;
  font-weight: 600;
  color: #16a34a;
  background: #dcfce7;
  border: 1px solid #86efac;
  padding: 2px 10px;
  border-radius: 20px;
}
.ai-key-missing {
  font-size: .78rem;
  font-weight: 600;
  color: #b45309;
  background: #fef9c3;
  border: 1px solid #fde68a;
  padding: 2px 10px;
  border-radius: 20px;
}
.ai-key-missing a {
  color: #2563eb;
  text-decoration: underline;
}
.ai-analyze-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ai-upload-label {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px dashed #93c5fd;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  background: #fff;
  transition: all .2s;
  text-align: center;
  font-size: .85rem;
  color: #64748b;
}
.ai-upload-label:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #2563eb;
}
.ai-upload-label.has-file {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #15803d;
}
.ai-upload-label i {
  font-size: 1.5rem;
  color: #3b82f6;
}
.ai-upload-label.has-file i {
  color: #22c55e;
}
.ai-upload-label small {
  color: #94a3b8;
  font-size: .75rem;
}
.ai-pdf-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .85rem;
  color: #c2410c;
}
.ai-pdf-badge i {
  font-size: 1.2rem;
  color: #ef4444;
}
/* AI 분석 상태 메시지 */
#aiAnalyzeStatus {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
}
.ai-status-analyzing {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .88rem;
  color: #1d4ed8;
}
.ai-status-analyzing i {
  font-size: 1rem;
  color: #3b82f6;
}
.ai-status-success {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .88rem;
  color: #15803d;
  margin-bottom: 10px;
}
.ai-status-success i {
  font-size: 1rem;
  color: #22c55e;
}
.ai-status-error {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .88rem;
  color: #be123c;
}
.ai-status-error i {
  font-size: 1rem;
  color: #ef4444;
}
/* AI 결과 테이블 */
.ai-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.ai-result-table tr:not(:last-child) td {
  border-bottom: 1px solid #f1f5f9;
}
.ai-result-key {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 7px 12px;
  width: 90px;
  white-space: nowrap;
}
.ai-result-val {
  background: #fff;
  color: #1e293b;
  padding: 7px 14px;
}
