/* Partners Page Styles — mia partners.html에서 추출 */
/* CSS 클래스 변경 금지 */

.partners-layout {
  flex: 1;
  overflow: hidden;
  display: flex;
  height: 100%;
}

.partner-left-panel {
  width: 300px;
  min-width: 300px;
  background: #fff;
  border-right: 1px solid var(--tint);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.partner-search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--tint);
  display: flex;
  gap: 6px;
  align-items: center;
}

.partner-search-wrap input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--tint);
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--brand);
  outline: none;
  background: var(--background) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%239CA1B4' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 10px center;
}

.partner-search-wrap input:focus { border-color: #3B82F6; }

.grade-tabs {
  display: flex;
  border-bottom: 1px solid var(--tint);
  padding: 0 12px;
}

.grade-tab {
  flex: 1;
  padding: 8px 0;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.grade-tab:hover { color: var(--brand); }
.grade-tab.active { color: #3B82F6; border-bottom-color: #3B82F6; }

.ptr-list { flex: 1; overflow-y: auto; }

.ptr-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.ptr-item:hover { background: var(--bg-light); }

/* ── 인라인 style 대체 클래스 (규칙 17 준수) ── */

/* 상세주소 full-width */
.info-item-full { grid-column: 1 / -1; }

/* 메모 textarea */
.ptr-memo-textarea {
  width: 100%;
  background: var(--background);
  border-color: transparent;
  resize: none;
  padding: 8px;
  font-size: 0.8125rem;
  line-height: 1.5;
  min-height: 80px;
  border-radius: 6px;
  outline: none;
  color: var(--brand);
}

/* 거래이력 테이블 카드 */
.ptr-history-card { padding: 0; overflow: hidden; }

/* 거래이력 테이블 */
.ptr-history-table {
  width: 100%;
  border-collapse: collapse;
}
.ptr-history-table thead tr { background: var(--bg-light); }
.ptr-history-table thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--tertiary);
  text-transform: uppercase;
}
.ptr-history-table thead th.th-right { text-align: right; }
.ptr-history-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--tint);
  font-size: 0.8125rem;
  color: var(--brand);
}
.ptr-history-table tbody tr:last-child td { border-bottom: none; }
.ptr-history-date { color: var(--brand); }
.ptr-history-num  { color: var(--brand); }
.ptr-history-amount { text-align: right; color: var(--brand); }

/* 거래처 등급(파트너 타입) 배지 색상 — mia 명세서 기준 */
.grade-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.6875rem; font-weight: 700; }
.grade-badge-customer  { background: rgba(59,130,246,0.1);  color: #1E40AF; }
.grade-badge-supplier  { background: rgba(249,115,22,0.1);  color: #C2410C; }
.grade-badge-both      { background: rgba(139,92,246,0.1);  color: #5B21B6; }
.grade-badge-default   { background: var(--bg-light);       color: var(--tertiary); }

/* 도어 등급 A~D */
.door-level-A { background: rgba(34,197,94,0.1);  color: #15803D; padding: 1px 7px; border-radius: 4px; font-size: 0.6875rem; font-weight: 700; }
.door-level-B { background: rgba(59,130,246,0.1);  color: #1E40AF; padding: 1px 7px; border-radius: 4px; font-size: 0.6875rem; font-weight: 700; }
.door-level-C { background: rgba(249,115,22,0.1);  color: #C2410C; padding: 1px 7px; border-radius: 4px; font-size: 0.6875rem; font-weight: 700; }
.door-level-D { background: rgba(239,68,68,0.1);   color: #B91C1C; padding: 1px 7px; border-radius: 4px; font-size: 0.6875rem; font-weight: 700; }

/* 미수금 위험 배지 */
.ptr-overdue-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(239,68,68,0.1);
  color: #DC2626;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  animation: pulse-overdue 1.5s infinite;
}
@keyframes pulse-overdue {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
.ptr-item.active { background: rgba(59,130,246,0.06); border-left-color: #3B82F6; }
.ptr-item .ptr-row { display: flex; justify-content: space-between; align-items: center; }
.ptr-item .ptr-name { font-size: 0.875rem; font-weight: 600; color: var(--brand); }
.ptr-item .ptr-biz { font-size: 0.75rem; color: var(--light); margin-top: 1px; }
.ptr-item .ptr-sub { font-size: 0.6875rem; color: var(--light); }

.grade-badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.3px; }
.grade-a { background: rgba(59,130,246,0.1); color: #2563EB; }
.grade-b { background: rgba(245,158,11,0.1); color: #D97706; }
.grade-c { background: rgba(156,163,175,0.15); color: #6B7280; }
.grade-d { background: rgba(239,68,68,0.1); color: #DC2626; }

.ptr-add-btn {
  width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--tint);
  background: var(--brand); color: white; font-size: 0.875rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.2s; text-decoration: none;
}
.ptr-add-btn:hover { background: #3B82F6; }

.partner-right-panel {
  flex: 1; min-width: 0; background: var(--background);
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
}
.partner-right-panel > turbo-frame {
  display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}
.partner-right-panel > turbo-frame > [data-controller="detail-tab"] {
  display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden;
}

.ptr-detail-tabs {
  display: flex; background: #fff; border-bottom: 1px solid var(--tint); padding: 0 20px;
}

.ptr-detail-tab {
  padding: 10px 16px; font-size: 0.8125rem; font-weight: 600; color: var(--tertiary);
  cursor: pointer; border-bottom: 2px solid transparent; background: none;
  border-top: none; border-left: none; border-right: none; transition: all 0.2s;
}
.ptr-detail-tab:hover { color: var(--brand); }
.ptr-detail-tab.active { color: #3B82F6; border-bottom-color: #3B82F6; }

.ptr-detail-body { flex: 1; overflow-y: auto; padding: 20px; }

.ptr-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.ptr-detail-header .ptr-detail-name { font-size: 1.25rem; font-weight: 700; color: var(--brand); }
.ptr-detail-header .edit-btn {
  margin-left: auto; padding: 6px 14px; font-size: 0.75rem; font-weight: 600;
  color: var(--tertiary); background: #fff; border: 1px solid var(--tint);
  border-radius: 6px; cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.ptr-detail-header .edit-btn:hover { border-color: #3B82F6; color: #3B82F6; }

.ptr-info-card { background: #fff; border-radius: 8px; border: 1px solid var(--tint); padding: 20px; margin-bottom: 16px; }
.ptr-info-card .card-title { font-size: 0.75rem; font-weight: 700; color: var(--tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.ptr-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.ptr-info-grid .info-item label { display: block; font-size: 0.6875rem; font-weight: 600; color: var(--light); margin-bottom: 3px; }
.ptr-info-grid .info-item span { font-size: 0.8125rem; color: var(--brand); font-weight: 500; }

.ptr-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ptr-stat-item { text-align: center; padding: 14px 8px; background: var(--background); border-radius: 6px; }
.ptr-stat-item .stat-label { font-size: 0.6875rem; color: var(--light); margin-bottom: 6px; }
.ptr-stat-item .stat-value { font-size: 0.9375rem; font-weight: 700; color: var(--brand); }
.ptr-stat-item .stat-value.warn { color: #D97706; }

.ptr-memo textarea {
  width: 100%; min-height: 80px; padding: 12px; border: 1px solid var(--tint);
  border-radius: 6px; font-size: 0.8125rem; color: var(--brand); resize: vertical;
  outline: none; font-family: inherit;
}
.ptr-memo textarea:focus { border-color: #3B82F6; }

.ptr-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.ptr-actions .btn-save {
  padding: 8px 24px; background: #3B82F6; color: #fff; border: none; border-radius: 6px;
  font-size: 0.8125rem; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
}
.ptr-actions .btn-save:hover { opacity: 0.85; }
.ptr-actions .btn-delete {
  padding: 8px 24px; background: #fff; color: #EF4444; border: 1px solid #FCA5A5;
  border-radius: 6px; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; text-decoration: none;
}
.ptr-actions .btn-delete:hover { background: #FEF2F2; border-color: #EF4444; }

.register-form-card { background: #fff; border-radius: 8px; border: 1px solid var(--tint); padding: 20px; margin-bottom: 16px; }
.register-form-card .card-title { font-size: 0.75rem; font-weight: 700; color: var(--tertiary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.register-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.register-form-grid .form-group { display: flex; flex-direction: column; gap: 4px; }
.register-form-grid .form-group.full { grid-column: 1 / -1; }
.register-form-grid .form-group label { font-size: 0.6875rem; font-weight: 600; color: var(--light); }
.register-form-grid .form-group label .required { color: #EF4444; margin-left: 2px; }
.register-form-grid .form-group input,
.register-form-grid .form-group select,
.register-form-grid .form-group textarea {
  padding: 8px 10px; border: 1px solid var(--tint); border-radius: 6px;
  font-size: 0.8125rem; color: var(--brand); outline: none; font-family: inherit;
  background: #fff; transition: border-color 0.2s;
}
.register-form-grid .form-group input:focus,
.register-form-grid .form-group select:focus,
.register-form-grid .form-group textarea:focus { border-color: #3B82F6; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); }
.register-form-grid .form-group textarea { resize: vertical; min-height: 70px; }

.outstanding-warn { color: #EF4444 !important; font-weight: 700 !important; }
.outstanding-danger-badge {
  display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 0.625rem;
  font-weight: 700; background: rgba(239,68,68,0.12); color: #DC2626;
  margin-left: 6px; letter-spacing: 0.3px; animation: pulse-badge 1.5s ease-in-out infinite;
}
@keyframes pulse-badge { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.ptr-empty { padding: 24px; text-align: center; color: var(--light); font-size: 0.8125rem; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; background: var(--brand); color: white; border-radius: 8px;
  font-size: 0.8125rem; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 200; animation: toast-in 0.3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── 등급 설정 모달 (규칙 17 준수 — inline style 없음) ── */

/* 등급 카드 헤더 (타이틀 + 설정 버튼 row) */
.ptr-grade-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.ptr-grade-card-header .card-title { margin-bottom: 0; }

.ptr-grade-edit-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: white;
  color: var(--tertiary);
  border: 1px solid var(--tint);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.ptr-grade-edit-btn:hover { border-color: #3B82F6; color: #3B82F6; }

/* Native <dialog> modal */
.ptr-grade-modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  max-width: 480px;
  width: 90%;
}
.ptr-grade-modal::backdrop { background: rgba(0,0,0,0.4); }

.ptr-grade-modal-inner { padding: 24px; }

.ptr-grade-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.ptr-grade-modal-title { font-size: 1rem; font-weight: 700; color: var(--brand); }
.ptr-grade-modal-close {
  background: none;
  border: none;
  font-size: 1.375rem;
  cursor: pointer;
  color: var(--light);
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}
.ptr-grade-modal-close:hover { color: var(--brand); }

.ptr-grade-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.ptr-grade-form-item { display: flex; flex-direction: column; gap: 4px; }
.ptr-grade-form-item-full { grid-column: 1 / -1; }
.ptr-grade-form-item label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--light);
}
.ptr-grade-form-item select {
  padding: 8px 10px;
  border: 1px solid var(--tint);
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--brand);
  outline: none;
  background: #fff;
  cursor: pointer;
}
.ptr-grade-form-item select:focus { border-color: #3B82F6; }

.ptr-grade-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.ptr-grade-cancel-btn {
  padding: 8px 20px;
  background: white;
  color: var(--tertiary);
  border: 1px solid var(--tint);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s;
}
.ptr-grade-cancel-btn:hover { border-color: var(--brand); }
.ptr-grade-save-btn {
  padding: 8px 20px;
  background: #3B82F6;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.ptr-grade-save-btn:hover { opacity: 0.85; }

/* ── 거래이력 그룹 뷰 (WEB-19) ── */
.ptr-history-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--tint);
  margin-bottom: 8px;
}
.ptr-history-type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}
.ptr-history-type-so   { background: rgba(34,197,94,0.12);  color: #15803D; }
.ptr-history-type-qt   { background: rgba(59,130,246,0.12); color: #1D4ED8; }
.ptr-history-type-cl   { background: rgba(239,68,68,0.12);  color: #B91C1C; }
.ptr-history-type-sh   { background: rgba(124,58,237,0.12); color: #6D28D9; }
.ptr-history-type-po   { background: rgba(245,158,11,0.12); color: #B45309; }
.ptr-history-group-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--light);
  font-weight: 600;
}

/* --- 폼 유틸리티 (Rule 17: 인라인 style 대체) --- */
.ptr-form-errors {
  color: #EF4444;
  font-size: 0.8125rem;
  margin-bottom: 16px;
}
.ptr-form-section-title {
  margin-top: 20px;
}
.ptr-form-textarea {
  min-height: 70px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--tint, #CDD0D9);
  border-radius: 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
}
