/*
 * M9 정산·결제 화면 스타일 — 전 규칙 .kx-settle 로 스코프 격리(전역 재정의 방지).
 * design.md §1 토큰(색·radius·spacing)만 사용. 선 SVG/텍스트만 — 이모지 장식 없음.
 */

.kx-settle {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: var(--gutter);
}

/* 헤더 */
.kx-settle__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.kx-settle__title {
  margin: 0;
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  font-weight: var(--fw-bold);
  color: var(--color-neutral-900);
}
.kx-settle__subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--color-neutral-500);
}
.kx-settle__head-actions {
  display: flex;
  gap: 8px;
}

/* 공지 배너 */
.kx-settle__notice {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-050);
  border: 1px solid var(--color-primary-100);
  color: var(--color-primary-700);
  font-size: 13px;
}
.kx-settle__notice--error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--color-error);
}

/* KPI 밴드 */
.kx-settle__kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kx-settle__kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: var(--border-card);
  border-radius: var(--radius-lg);
  background: var(--color-white);
}
.kx-settle__kpi-sub {
  font-size: var(--fs-caption);
  color: var(--color-neutral-500);
}
.kx-settle__kpi--info {
  border-left: 4px solid var(--color-primary-600);
}
.kx-settle__kpi--ok {
  border-left: 4px solid var(--color-success);
}
.kx-settle__kpi--error {
  border-left: 4px solid var(--color-error);
}
.kx-settle__kpi--muted {
  border-left: 4px solid var(--color-neutral-200);
}

/* 상태 분포 */
.kx-settle__dist-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: center;
}
.kx-settle__legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.kx-settle__legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.kx-settle__legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.kx-settle__legend-name {
  color: var(--color-neutral-700);
  min-width: 60px;
}
.kx-settle__legend-val {
  color: var(--color-neutral-500);
  margin-left: auto;
}
.kx-settle__paynote {
  margin: 12px 0 0;
  font-size: var(--fs-caption);
  color: var(--color-neutral-500);
}

/* 목록 */
.kx-settle__list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.kx-settle__row {
  cursor: pointer;
}
.kx-settle__row:hover {
  background: var(--color-primary-050);
}
.kx-settle__link {
  border: none;
  background: none;
  color: var(--color-primary-600);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.kx-settle__link:hover {
  text-decoration: underline;
}
.kx-settle__pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
}
.kx-settle__pageinfo {
  font-size: 13px;
  color: var(--color-neutral-500);
}

/* 상태 pill */
.kx-settle__pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  line-height: 18px;
}
.kx-settle__pill--muted {
  background: var(--color-neutral-100);
  color: var(--color-neutral-500);
}
.kx-settle__pill--info {
  background: var(--color-primary-050);
  color: var(--color-primary-700);
}
.kx-settle__pill--ok {
  background: #ecfdf3;
  color: var(--color-success);
}
.kx-settle__pill--error {
  background: #fef3f2;
  color: var(--color-error);
}

/* 상세 모달 */
.kx-settle__overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
  overflow-y: auto;
}
.kx-settle__modal {
  width: 100%;
  max-width: 720px;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.2);
}
.kx-settle__modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: var(--border-card);
}
.kx-settle__modal-head h2 {
  margin: 0;
  font-size: var(--fs-h3);
}
.kx-settle__close {
  border: none;
  background: none;
  font-size: var(--fs-h3);
  color: var(--color-neutral-500);
  cursor: pointer;
}
.kx-settle__modal-body {
  padding: 20px;
  display: grid;
  gap: 16px;
}
.kx-settle__meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.kx-settle__meta > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kx-settle__meta-k {
  font-size: var(--fs-caption);
  color: var(--color-neutral-500);
}
.kx-settle__meta-v {
  font-size: var(--fs-body);
  color: var(--color-neutral-900);
  font-weight: var(--fw-semibold);
}

.kx-settle__lines {
  width: 100%;
}
.kx-settle__lines tfoot td {
  font-size: 13px;
  color: var(--color-neutral-700);
}
.kx-settle__total-row td {
  font-weight: var(--fw-bold);
  color: var(--color-neutral-900);
  border-top: 1px solid var(--color-neutral-200);
}
.kx-settle__cat {
  display: inline-block;
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  color: var(--color-primary-700);
  background: var(--color-primary-050);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  margin-right: 4px;
}

.kx-settle__pay-hist h3 {
  margin: 0 0 8px;
  font-size: var(--fs-body);
}
.kx-settle__pay-hist ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.kx-settle__pay-hist li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-neutral-700);
  padding: 6px 10px;
  background: var(--color-neutral-050);
  border-radius: var(--radius-sm);
}
.kx-settle__pay-method {
  font-size: var(--fs-micro);
  color: var(--color-neutral-500);
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-sm);
  padding: 0 6px;
}
.kx-settle__pay-memo {
  color: var(--color-neutral-500);
}
.kx-settle__pay-date {
  margin-left: auto;
  color: var(--color-neutral-500);
}

.kx-settle__actions {
  display: grid;
  gap: 12px;
  border-top: var(--border-card);
  padding-top: 16px;
}
.kx-settle__pay-inputs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.kx-settle .kx-input {
  padding: 8px 10px;
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-neutral-900);
}
.kx-settle .kx-input:focus {
  outline: none;
  border-color: var(--color-primary-600);
}
.kx-settle__form-error {
  margin: 0;
  font-size: var(--fs-caption);
  color: var(--color-error);
}
.kx-settle__muted {
  font-size: var(--fs-caption);
  color: var(--color-neutral-500);
  text-align: left;
}

/* F084 정산 유형 태그(임대 / 옥션 수수료 구분) */
.kx-settle__cattag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: var(--fs-micro);
  font-weight: var(--fw-semibold);
  vertical-align: middle;
  white-space: nowrap;
}
.kx-settle__cattag--rental {
  background: var(--color-neutral-100, #f2f4f7);
  color: var(--color-neutral-600, #475467);
}
.kx-settle__cattag--auction_fee {
  background: var(--color-primary-surface, #eef2ff);
  color: var(--color-primary-600, #2f42fc);
}

/* ── W9: F085 환불·취소 + F083 세금계산서 + 정산 리포트 ───────────────────────── */
.kx-settle__tax {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-neutral-200, #e4e7ec);
  display: grid;
  gap: 8px;
}
.kx-settle__tax h3 {
  margin: 0;
  font-size: 13px;
  font-weight: var(--fw-semibold);
}
.kx-settle__tax-doc {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--color-neutral-200, #e4e7ec);
  border-radius: 8px;
  background: var(--color-neutral-50, #f9fafb);
}
.kx-settle__tax-row {
  display: flex;
  gap: 10px;
  font-size: var(--fs-caption);
}
.kx-settle__tax-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 4px;
  font-size: var(--fs-caption);
}
.kx-settle__cancel {
  margin-top: 12px;
}
.kx-settle__cancel-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--color-error-border, #fda29b);
  border-radius: 8px;
  background: var(--color-error-surface, #fffbfa);
}
.kx-settle__cancel-box h4 {
  margin: 0;
  font-size: 13px;
  font-weight: var(--fw-semibold);
}
.kx-settle__refund {
  display: grid;
  gap: 4px;
}
.kx-settle__refund-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--fs-caption);
}
.kx-settle__refund-row--em {
  padding-top: 4px;
  border-top: 1px dashed var(--color-neutral-300, #d0d5dd);
  font-size: 13px;
}
.kx-settle__refund-row--em strong {
  color: var(--color-primary-600, #2f42fc);
}
.kx-settle__cancel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.kx-settle__report {
  margin-top: 16px;
}
.kx-settle__report-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.kx-settle__report-actions {
  display: flex;
  gap: 8px;
}
.kx-settle__report-body {
  display: grid;
  gap: 16px;
}
.kx-settle__report-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
}
.kx-settle__report-group h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: var(--fw-semibold);
}

/* ── 반응형 (공백없는 반응형 스윕 #39) — KPI/분포 좁은 폭 붕괴 방지 ── */
@media (max-width: 900px) {
  .kx-settle__kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 560px) {
  .kx-settle__kpis {
    grid-template-columns: 1fr;
  }
  .kx-settle__dist-body {
    grid-template-columns: 1fr;
  }
}
