/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
       background: #f4f6f9; color: #1a1d23; line-height: 1.6; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 1rem; }

/* ── Header ── */
.site-header { background: #1e3a5f; color: #fff; padding: 0; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 20px;
               display: flex; align-items: center; justify-content: space-between; height: 56px; }
.site-title { color: #fff; font-size: 1.1rem; font-weight: 700; }
.site-nav { display: flex; align-items: center; gap: 16px; }
.site-nav a { color: #cbd5e1; font-size: .9rem; }
.site-nav a:hover { color: #fff; }

/* ── Main ── */
.site-main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.site-footer { text-align: center; padding: 20px; color: #94a3b8; font-size: .8rem; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .95rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── Page title bar ── */
.page-title-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title-bar h1 { font-size: 1.4rem; font-weight: 700; color: #1e3a5f; }

/* ── Stepper ── */
.stepper { display: flex; align-items: center; justify-content: center; gap: 0; margin-bottom: 28px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 80px; }
.step-num { width: 36px; height: 36px; border-radius: 50%; background: #e2e8f0; color: #94a3b8;
            display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.step-label { font-size: .75rem; color: #94a3b8; font-weight: 500; text-align: center; }
.step.active .step-num { background: #2563eb; color: #fff; }
.step.active .step-label { color: #2563eb; font-weight: 700; }
.step.done .step-num { background: #16a34a; color: #fff; }
.step.done .step-label { color: #16a34a; font-weight: 600; }
.step-line { flex: 1; height: 2px; background: #e2e8f0; min-width: 40px; max-width: 80px; }

/* ── Document layout ── */
.doc-layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .doc-layout { grid-template-columns: 1fr; } }

/* ── Preview pane ── */
.doc-preview-pane { background: #fff; border-radius: 12px; padding: 16px;
                    box-shadow: 0 1px 4px rgba(0,0,0,.1); position: sticky; top: 76px; }
.preview-label { font-size: .75rem; color: #64748b; font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; }
.preview-img { width: 100%; border: 1px solid #e2e8f0; border-radius: 4px; display: block; }
.preview-placeholder { width: 100%; aspect-ratio: 3/4; background: #f1f5f9; border-radius: 4px;
                       display: flex; align-items: center; justify-content: center; color: #94a3b8; text-align: center; font-size: .85rem; }
.preview-actions { margin-top: 12px; }

/* ── Form pane ── */
.form-pane { display: flex; flex-direction: column; gap: 20px; }

/* ── Form sections ── */
.form-section { background: #fff; border-radius: 12px; padding: 20px;
                box-shadow: 0 1px 4px rgba(0,0,0,.08); border: 2px solid transparent; }
.active-section { border-color: #2563eb; }
.disabled-section { border-color: #e2e8f0; opacity: .8; position: relative; overflow: hidden; }
.readonly-section { border-color: #e2e8f0; }
.disabled-overlay { background: rgba(241,245,249,.85); position: absolute; inset: 0; z-index: 5;
                    display: flex; align-items: center; justify-content: center;
                    font-size: .9rem; color: #64748b; border-radius: 10px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: .8rem; font-weight: 700; }
.transferor-badge { background: #dbeafe; color: #1d4ed8; }
.transferee-badge { background: #d1fae5; color: #065f46; }
.muted { opacity: .5; }

/* ── Fields ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .85rem; font-weight: 600; color: #374151; }
.field input, .field select, .field textarea {
  padding: 10px 14px; border: 1.5px solid #d1d5db; border-radius: 8px;
  font-size: 1rem; background: #fff; transition: border-color .15s;
}
.field input:focus, .field select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.field input:disabled { background: #f8fafc; color: #94a3b8; cursor: not-allowed; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }
.required { color: #ef4444; }
.hint { font-size: .78rem; color: #94a3b8; margin-top: 2px; }

/* ── Read-only value ── */
.value-box { padding: 10px 14px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 8px;
             font-size: .95rem; min-height: 42px; }

/* ── Radio group ── */
.radio-group { display: flex; gap: 20px; flex-wrap: wrap; padding: 8px 0; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: .95rem; cursor: pointer; font-weight: 600; }
.radio-label input[type="radio"] { width: 18px; height: 18px; accent-color: #2563eb; cursor: pointer; }

/* ── Animal table ── */
.animal-table-wrap { overflow-x: auto; }
.animal-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.animal-table th { background: #f1f5f9; padding: 8px 10px; text-align: left; font-weight: 600;
                   border: 1px solid #e2e8f0; font-size: .8rem; color: #374151; }
.animal-table td { border: 1px solid #e2e8f0; padding: 4px; }
.animal-table td input { border: none; padding: 6px 8px; width: 100%; background: transparent;
                         font-size: .88rem; min-width: 60px; box-sizing: border-box; }
.animal-table td input:focus { outline: 1px solid #2563eb; border-radius: 4px; }
/* 날짜 입력: 모바일/아이패드에서 캘린더 아이콘과 레이아웃 정합 */
.animal-table td input[type="date"] {
  min-width: 110px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2px;
}
.readonly-table td { padding: 6px 10px; font-size: .88rem; }

/* ── Signature pad ── */
.signature-container { border: 2px dashed #94a3b8; border-radius: 8px; overflow: hidden; background: #fff; }
.signature-canvas { display: block; width: 100%; cursor: crosshair; touch-action: none; }
.signature-actions { padding: 6px 8px; background: #f8fafc; border-top: 1px solid #e2e8f0; }
.signature-preview-box { padding: 10px 14px; background: #dcfce7; border: 1.5px solid #bbf7d0;
                          border-radius: 8px; color: #166534; font-size: .9rem; }

/* ── Buttons ── */
.btn-primary { background: #2563eb; color: #fff; border: none; border-radius: 8px;
               padding: 12px 24px; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-secondary { background: #f1f5f9; color: #374151; border: 1.5px solid #d1d5db; border-radius: 8px;
                 padding: 10px 18px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-outline-sm { border: 1.5px solid #d1d5db; background: transparent; color: #374151; padding: 5px 12px;
                  border-radius: 6px; font-size: .82rem; font-weight: 600; cursor: pointer; display: inline-block; }
.btn-outline-sm:hover { background: #f1f5f9; text-decoration: none; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn-full { width: 100%; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ── Records table ── */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.search-input { flex: 1; min-width: 200px; padding: 10px 14px; border: 1.5px solid #d1d5db;
                border-radius: 8px; font-size: .95rem; }
.search-select { padding: 10px 14px; border: 1.5px solid #d1d5db; border-radius: 8px; background: #fff; }
.records-table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.records-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.records-table th { background: #f1f5f9; padding: 10px 12px; text-align: left; font-weight: 700;
                    border-bottom: 2px solid #e2e8f0; color: #374151; white-space: nowrap; }
.records-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.records-table tr:hover td { background: #f8fafc; }
.action-cell { white-space: nowrap; display: flex; gap: 6px; }
.type-badge { background: #eff6ff; color: #1d4ed8; padding: 2px 8px; border-radius: 12px; font-size: .78rem; font-weight: 700; }
.status-badge { padding: 3px 10px; border-radius: 12px; font-size: .78rem; font-weight: 600; }
.status-draft_transferor { background: #fef3c7; color: #92400e; }
.status-draft_transferee { background: #dbeafe; color: #1d4ed8; }
.status-completed { background: #dcfce7; color: #166534; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: #64748b; }
.empty-state p { font-size: 1rem; margin-bottom: 16px; }

/* ── Completion banner ── */
.completion-banner { background: #dcfce7; border: 1.5px solid #bbf7d0; border-radius: 10px;
                     padding: 14px 18px; color: #166534; font-weight: 600; display: flex;
                     align-items: center; flex-wrap: wrap; gap: 8px; }

/* ── Settings ── */
.settings-page { max-width: 560px; }
.settings-card { background: #fff; border-radius: 12px; padding: 28px;
                 box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.settings-card h2 { font-size: 1.1rem; margin-bottom: 6px; color: #1e3a5f; }

/* ── Auth ── */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.auth-card { background: #fff; border-radius: 12px; padding: 32px; box-shadow: 0 4px 20px rgba(0,0,0,.1);
             width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 1.2rem; margin-bottom: 20px; color: #1e3a5f; text-align: center; }
.auth-back { text-align: center; margin-top: 16px; font-size: .85rem; }

/* ── Mobile tweaks ── */
@media (max-width: 600px) {
  .site-main { padding: 16px 12px 40px; }
  .stepper { gap: 0; }
  .step-line { min-width: 20px; }
  .records-table { font-size: .78rem; }
  .records-table th, .records-table td { padding: 7px 8px; }
}

/* ── 케이스 폼 그리드 ── */
.case-form-grid { display: flex; flex-direction: column; gap: 16px; }

/* ── 케이스 디테일 그리드 ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-label { font-size: .78rem; font-weight: 700; color: #64748b; display: block; margin-bottom: 3px; }

/* ── 액션 카드 ── */
.case-action-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 4px; }
.action-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px;
               background: #fff; border-radius: 12px; border: 2px solid #e2e8f0;
               box-shadow: 0 1px 4px rgba(0,0,0,.06); text-decoration: none; color: inherit;
               transition: border-color .15s, box-shadow .15s; }
.action-card:hover { border-color: #93c5fd; box-shadow: 0 2px 8px rgba(37,99,235,.1); text-decoration: none; }
.action-card.done { border-color: #bbf7d0; background: #f0fdf4; }
.action-card.agreed { border-color: #93c5fd; background: #eff6ff; }
.ac-icon { font-size: 1.8rem; line-height: 1; }
.ac-body { flex: 1; }
.ac-title { font-weight: 700; font-size: .95rem; color: #1e3a5f; }
.ac-status { font-size: .78rem; margin-top: 3px; font-weight: 600; }
.ac-status.done { color: #16a34a; }
.ac-status.agreed { color: #2563eb; }
.ac-status.pending { color: #94a3b8; }
.ac-arrow { font-size: 1.4rem; color: #94a3b8; }

/* ── 케이스 상태 배지 ── */
.status-badge.status-draft { background: #fef3c7; color: #92400e; }
.status-badge.status-report_done { background: #dbeafe; color: #1d4ed8; }

/* ── 계약서 스크롤 ── */
.contract-scroll-body { height: 420px; overflow-y: auto; padding: 20px 24px; font-size: .88rem; line-height: 1.75; }
.contract-para { margin-bottom: 16px; }
.contract-clause-title { font-weight: 700; color: #1e3a5f; margin-bottom: 4px; }
.contract-clause-body { color: #374151; white-space: pre-wrap; }
/* 모바일: 내부 스크롤 해제 → 페이지 스크롤로 전환 */
@media (max-width: 900px) {
  .contract-scroll-body {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    overflow-x: hidden !important;
    font-size: .95rem;
    line-height: 1.7;
    padding: 16px 16px 8px;
  }
  .scroll-hint-bar { display: none !important; }
}

/* ── 완료 페이지 ── */
.complete-download-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 700px; margin: 0 auto; }
@media (max-width: 640px) { .complete-download-grid { grid-template-columns: 1fr; } }
.complete-card { background: #fff; border-radius: 14px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.08);
                 border: 2px solid #e2e8f0; display: flex; flex-direction: column; }
.cc-icon { font-size: 2rem; margin-bottom: 10px; }
.cc-title { font-size: 1.05rem; font-weight: 700; color: #1e3a5f; margin-bottom: 4px; }
.cc-desc { font-size: .85rem; color: #64748b; }

/* ── 케이스 5단계 상태 배지 ── */
.status-badge.status-draft_basic      { background: #f1f5f9; color: #475569; }
.status-badge.status-report_generated { background: #dbeafe; color: #1d4ed8; }
.status-badge.status-contract_pending { background: #fef3c7; color: #92400e; }
.status-badge.status-contract_agreed  { background: #d1fae5; color: #065f46; }
.status-badge.status-completed        { background: #dcfce7; color: #166534; }

/* ── 계약서 2단 레이아웃 ── */
.contract-page-layout { display: grid; grid-template-columns: 1fr 400px; gap: 24px; align-items: start; }
.contract-main-col {}
.contract-side-col {}
@media (max-width: 960px) {
  .contract-page-layout { grid-template-columns: 1fr; }
  .contract-main-col  { order: 1; }
  .contract-side-col  { order: 2; }
}

/* ── 당사자 라벨 ── */
.party-role-label { font-size: .75rem; font-weight: 700; color: #64748b; margin-bottom: 2px; }

/* ── 동물 정보 행 (6컬럼: 학명 Morph 성별 해칭일 수량 부모정보) ── */
.animal-info-row {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  font-size: .85rem;
  margin-bottom: 4px;
  padding: 6px 10px;
  background: #f8fafc;
  border-radius: 6px;
  align-items: center;
}
/* 학명: flex 44 비율로 최대 공간 확보 */
.animal-sn {
  flex: 44;
  min-width: 0;
  font-weight: 600;
  font-size: .88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 수량 */
.animal-qty {
  flex: 0 0 auto;
  font-size: .82rem;
  white-space: nowrap;
}
/* 부모정보: 마지막 컬럼 18% 비율 */
.animal-parent-info {
  flex: 18;
  min-width: 0;
  font-size: .76rem;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
/* 태그 공통 */
.animal-tag {
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #374151;
  font-size: .78rem;
  white-space: nowrap;
}
.animal-tag.morph-tag { background: #ede9fe; color: #5b21b6; }
.animal-tag.muted-tag { background: #f1f5f9; color: #64748b; }

/* 모바일: 가로 스크롤 허용 */
@media (max-width: 600px) {
  .animal-info-row { overflow-x: auto; gap: 5px; padding: 6px 8px; }
  .animal-sn       { min-width: 130px; }
  .animal-parent-info { min-width: 80px; }
}

/* ── 동물 행 삭제 버튼 ── */
.del-col { width: 28px; text-align: center; padding: 2px !important; }
.del-row-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.del-row-btn:hover { color: #ef4444; background: #fee2e2; }

/* ── 주소 입력 + 검색 버튼 행 ── */
.address-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.address-input-row input {
  flex: 1;
  min-width: 0;
}
.addr-btn {
  flex-shrink: 0;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .address-input-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .addr-btn { width: 100%; text-align: center; }
}

/* ── 계약서 스크롤 힌트 ── */
.scroll-hint-bar { text-align: center; padding: 8px; background: #fef3c7; color: #92400e; font-size: .82rem; font-weight: 600; border-top: 1px solid #fde68a; }

/* ── 동의 체크박스 블록 ── */
.consent-block { background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; }
.consent-label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.consent-checkbox { width: 18px; height: 18px; accent-color: #2563eb; flex-shrink: 0; margin-top: 2px; }
.consent-checkbox:disabled { accent-color: #94a3b8; cursor: not-allowed; }
.consent-text { font-size: .88rem; line-height: 1.6; color: #374151; }
.consent-text strong { color: #991b1b; }
.consent-hint { font-size: .77rem; color: #94a3b8; margin-top: 5px; padding-left: 28px; font-style: italic; }

/* ── 관리자 조항 편집 ── */
.clause-edit-block { padding: 10px 4px; }
.clause-edit-header { display: flex; align-items: center; gap: 10px; }
.clause-num-badge { background: #ede9fe; color: #5b21b6; font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 20px; flex-shrink: 0; }

/* ══════════════════════════════════════════════════
   모바일 반응형 확장 (768px 이하)
   ══════════════════════════════════════════════════ */

/* ── 동물 테이블 → 카드형 변환 (768px 이하) ── */
@media (max-width: 768px) {
  .animal-table.responsive-cards { display: block; border-collapse: separate; }
  .animal-table.responsive-cards thead { display: none; }
  .animal-table.responsive-cards tbody { display: block; }
  .animal-table.responsive-cards tr.animal-row {
    display: block;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 14px;
    background: #fff;
    overflow: hidden;
  }
  .animal-table.responsive-cards td {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 8px 12px;
  }
  .animal-table.responsive-cards td:last-child { border-bottom: none; }
  .animal-table.responsive-cards td::before {
    content: attr(data-label);
    min-width: 72px;
    font-size: .75rem;
    font-weight: 700;
    color: #64748b;
    flex-shrink: 0;
  }
  .animal-table.responsive-cards td input {
    flex: 1;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    padding: 9px 10px;
    font-size: .9rem;
    min-width: 0;
    background: #fff;
  }
  .animal-table.responsive-cards td select {
    flex: 1;
    border: 1.5px solid #d1d5db !important;
    border-radius: 6px;
    padding: 9px 10px !important;
    font-size: .9rem;
    background: #fff;
  }
  .animal-table.responsive-cards td input:focus,
  .animal-table.responsive-cards td select:focus {
    outline: none;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 2px rgba(37,99,235,.1);
  }
}

/* ── 터치 친화적 최소 높이 (768px 이하) ── */
@media (max-width: 768px) {
  .btn-primary, .btn-secondary { min-height: 44px; font-size: .95rem; }
  .field input, .field select, .field textarea { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .radio-label { min-height: 36px; }
  .consent-checkbox { width: 22px; height: 22px; }
}

/* ── 서명 패드 모바일 높이 ── */
@media (max-width: 768px) {
  .signature-canvas { height: 180px !important; min-height: 180px; }
}

/* ── 모바일 sticky 액션 바 ── */
.mobile-sticky-bar {
  display: none;
}
@media (max-width: 768px) {
  .mobile-sticky-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 12px 16px;
    z-index: 60;
    box-shadow: 0 -3px 12px rgba(0,0,0,.1);
  }
  .mobile-sticky-bar .btn-primary,
  .mobile-sticky-bar .btn-secondary { flex: 1; text-align: center; display: flex; align-items: center; justify-content: center; }
}

/* ── 계약서 페이지 모바일 조정 ── */
@media (max-width: 768px) {
  .contract-scroll-body { height: 260px; }
  .contract-page-layout { gap: 16px; }
  .site-main { padding-bottom: 80px; }
}

/* ── 스테퍼 모바일 ── */
@media (max-width: 480px) {
  .step-label { display: none; }
  .step-line { min-width: 12px; max-width: 24px; }
  .step { min-width: 36px; }
}

/* ══════════════════════════════════════════════
   계약서 화면 신규 클래스
══════════════════════════════════════════════ */
.contract-version-label { font-size: .8rem; color: #64748b; align-self: center; }

/* 계약서 문서 헤더 */
.contract-doc-header {
  background: #1e3a5f;
  color: #fff;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 1.05rem;
}
.contract-doc-version { font-size: .75rem; font-weight: 400; opacity: .7; margin-left: 8px; }

/* 당사자 정보 2열 그리드 */
.contract-parties-grid {
  padding: 14px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.contract-party-sub { font-size: .82rem; color: #64748b; }

/* 동물 정보 래퍼 */
.contract-animals-wrap { padding: 12px 20px; border-bottom: 1px solid #e2e8f0; }
.contract-animals-label { font-size: .78rem; font-weight: 700; color: #374151; margin-bottom: 6px; }

/* 데스크톱 동물 행 / 모바일 동물 카드 전환 */
.desktop-animal-row { display: flex; }
.mobile-animal-card { display: none; }

.mobile-animal-sn   { font-size: .9rem; font-weight: 700; color: #1e3a5f; margin-bottom: 4px; }
.mobile-animal-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 3px; }
.mobile-animal-parent { font-size: .78rem; color: #64748b; }

/* 동의 완료 카드 */
.contract-agreed-card {
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.contract-agreed-title { font-weight: 700; color: #166534; margin-bottom: 5px; }
.contract-agreed-date  { font-size: .82rem; color: #374151; }
.contract-agreed-meta  { font-size: .79rem; color: #64748b; margin-top: 5px; }

/* 동의 후 액션 버튼 스택 */
.contract-action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 모바일 서명 패드 높이 */
.contract-sig-canvas-mobile { height: 100px; }

@media (max-width: 900px) {
  /* 당사자 정보: 1열 */
  .contract-parties-grid { grid-template-columns: 1fr; gap: 10px; padding: 12px 16px; }
  .contract-animals-wrap { padding: 10px 14px; }
  .contract-doc-header   { padding: 12px 16px; font-size: 1rem; }

  /* 동물: 카드 표시, 행 숨김 */
  .desktop-animal-row { display: none !important; }
  .mobile-animal-card {
    display: block;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .mobile-animal-card:last-child { margin-bottom: 0; }

  /* 서명 패드 높이 증가 */
  .contract-sig-canvas-mobile { height: 180px; }

  /* completion-banner compact */
  .completion-banner-compact {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }
  .completion-banner-compact span { flex: 1 1 100%; }
  .completion-banner-compact .btn-primary,
  .completion-banner-compact .btn-secondary {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* 계약서 조항 가독성 */
  .contract-para { margin-bottom: 18px; }
  .contract-clause-title { font-size: 1rem; }
  .contract-clause-body  { font-size: .93rem; line-height: 1.7; }

  /* 동의/서명 영역 overflow 방지 */
  .contract-side-col { overflow-x: hidden; }
  .contract-action-stack .btn-primary,
  .contract-action-stack .btn-secondary { min-height: 44px; }
}

/* ══════════════════════════════════════════════
   삭제 버튼 (danger)
══════════════════════════════════════════════ */
.btn-danger {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: .88rem;
  transition: background .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-danger:hover { background: #dc2626; color: #fff; text-decoration: none; }
.btn-danger.btn-sm { padding: 5px 12px; font-size: .82rem; border-radius: 6px; }

.btn-danger-outline {
  background: none;
  color: #ef4444;
  border: 1.5px solid #ef4444;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-danger-outline:hover { background: #ef4444; color: #fff; }

/* ══════════════════════════════════════════════
   케이스 목록 반응형: 데스크톱 테이블 / 모바일 카드 전환
══════════════════════════════════════════════ */
.desktop-only-table { display: block; }
.mobile-only-cards  { display: none;  }

@media (max-width: 900px) {
  .desktop-only-table { display: none !important; }
  .mobile-only-cards  { display: flex; flex-direction: column; gap: 12px; }
}

/* ── 케이스 카드 ── */
.case-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border: 1px solid #e2e8f0;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 카드 상단: 배지 + 날짜 */
.case-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.case-card-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.case-card-date   { font-size: .75rem; color: #94a3b8; white-space: nowrap; flex-shrink: 0; }

/* 카드 본문 */
.case-card-body { display: flex; flex-direction: column; gap: 6px; }

.case-card-parties {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .92rem;
  font-weight: 600;
  color: #1e3a5f;
}
.case-party-name {
  max-width: 38%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.case-party-arrow { color: #94a3b8; font-size: .85rem; flex-shrink: 0; }

.case-card-doc-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
}
.doc-done    { color: #16a34a; font-weight: 600; }
.doc-agreed  { color: #2563eb; font-weight: 600; }
.doc-pending { color: #94a3b8; }
.doc-sep     { color: #cbd5e1; }

/* 카드 하단 액션 버튼 */
.case-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}
.case-card-btn {
  flex: 1;
  min-width: 64px;
  text-align: center;
  justify-content: center;
}
.case-card-actions form { flex: 1; display: flex; }
.case-card-actions form .btn-danger { width: 100%; justify-content: center; }

/* ══════════════════════════════════════════════
   모바일 햄버거 메뉴
══════════════════════════════════════════════ */
/* 햄버거 버튼 — 모바일에서만 표시 */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  flex-shrink: 0;
}
.nav-toggle .bar {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-toggle.open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open .bar:nth-child(2) { opacity: 0; }
.nav-toggle.open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 모바일 메뉴 패널 */
.mobile-nav-panel {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  background: #1e3a5f;
  z-index: 200;
  flex-direction: column;
  padding: 8px 0 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s, opacity .2s;
}
.mobile-nav-panel.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.mobile-nav-panel a {
  display: block;
  color: #e2e8f0;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  min-height: 44px;
  line-height: 1;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}
.mobile-nav-panel a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.mobile-nav-panel a:last-child { border-bottom: none; }

/* 모바일 메뉴 오버레이 */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0,0,0,.3);
  z-index: 199;
}
.mobile-nav-overlay.open { display: block; }

/* ── 모바일에서 활성화 (≤900px) ── */
@media (max-width: 900px) {
  #site-nav-desktop { display: none !important; }
  .nav-toggle { display: flex; }
  .mobile-nav-panel { display: flex; }
}

/* ══════════════════════════════════════════════
   모바일 신고서 미리보기 아코디언
══════════════════════════════════════════════ */
/* 모바일 토글 헤더 — 기본 숨김, 모바일에서 표시 */
.preview-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0 4px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.preview-toggle-icon {
  font-size: .8rem;
  color: #2563eb;
  font-weight: 600;
  white-space: nowrap;
}

/* 미리보기 본문 — 모바일에서 접힘/펼침 */
.preview-body {
  overflow: hidden;
  transition: max-height .3s ease, opacity .25s;
}

@media (max-width: 900px) {
  /* sticky 해제 + 전체 폭 */
  .doc-preview-pane {
    position: static !important;
    width: 100%;
    padding: 12px 14px;
  }
  /* 토글 헤더 표시 */
  .preview-mobile-toggle {
    display: flex;
  }
  /* 미리보기 본문 기본 접힘 */
  .preview-body {
    max-height: 0;
    opacity: 0;
  }
  /* 펼침 상태 */
  .preview-body.open {
    max-height: 1200px;
    opacity: 1;
  }
  /* 데스크톱 preview-label은 모바일 토글 안에 있으므로 숨김 */
  .doc-preview-pane > .preview-label { display: none; }
}
