/* ═══════════════════════════════════════════════════════════════════════════
   UI DATAGRID — 전역 테이블 그리드 공통 스타일
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── 🎯 SINGLE SOURCE OF TRUTH — 모든 그리드 디자인 토큰 ─────────────────── */
:root {
  --grid-row-h: 32px;
  --grid-header-h: var(--panel-head-height, 40px);
  /* 그리드 헤더는 패널헤드 토큰을 그대로 사용 → 시각 통일 */
  --grid-font: 12px;
  --grid-font-weight: 400;
  --grid-cell-px: 10px;

  --grid-header-bg: #f6f7fa; /* 사이드바(#e0e4ed) 톤을 거의 흰색까지 옅게 */
  --grid-header-color: #1f2937;
  --grid-row-odd: #ffffff;
  --grid-row-even: #fafbfc;
  --grid-row-hover: #f4f6fa;       /* 옅은 슬레이트 호버 */
  --grid-row-active: #e8edf5;      /* 호버보다 한 톤 살짝 진함 */

  --grid-border-h: #e9ecef;
  --grid-border-v: #e9ecef;
  --grid-border-header: #e9ecef;
  --grid-text: #1f2937;

  /* 라디우스 통일 토큰 */
  --r-xs: 3px;
  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 10px;

  /* 모드 컬러 — 보기/수정/신규 공통 토큰 */
  /* 무채색 베이스 + 미세한 색조 — 구분은 확실히 */
  --mode-view-bg:    #eef2f6;   /* 중성 회색 */
  --mode-view-fg:    #475569;

  --mode-edit-bg:    #ede9dc;   /* 따뜻한 베이지 톤 (수정) */
  --mode-edit-fg:    #6b5e3c;

  --mode-create-bg:    #dde7eb; /* 차가운 블루그레이 톤 (신규) */
  --mode-create-fg:    #3b556a;
}

/* ─── 공용 컨텍스트 메뉴 ─────────────────────────────────────────── */
.core-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--grid-border-header);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 4px 0;
  min-width: 160px;
  font-size: var(--grid-font);
}
.core-ctx-item {
  padding: 6px 14px;
  cursor: pointer;
  color: var(--grid-text);
}
.core-ctx-item:hover { background: #f3f4f6; }
.core-ctx-item.has-sub {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.core-ctx-arrow { color: #94a3b8; font-size: 11px; }
.core-ctx-submenu { margin-left: 2px; }

/* ─── 공용 우측 상세 드로어 ──────────────────────────────────────── */
.detail-drawer {
  /* work-page 안에 absolute로 들어가 페이지 영역과 정확히 일치 */
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 90%;
  background: #fff;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--radius-ui, 8px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
  z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: drawerSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.detail-drawer[hidden] { display: none; }
@keyframes drawerSlideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
/* 드로어는 .panel + .panel-head + .panel-body를 그대로 사용 */

/* ─── CSV 업로드 모달 ─────────────────────────────────────────── */
.csv-upload-modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.csv-upload-modal[hidden] { display: none; }
.csv-upload-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.csv-upload-panel {
  position: relative;
  width: 640px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  background: #fff;
  border-radius: var(--radius-ui, 8px);
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.24);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.csv-upload-body {
  display: flex; flex-direction: column;
  gap: 14px;
  padding: 16px 18px;
  overflow-y: auto;
}
.csv-schema-info {
  background: #f8fafc;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: var(--grid-font);
  display: flex; flex-direction: column; gap: 4px;
}
.csv-schema-row { display: flex; gap: 8px; }
.csv-schema-label { color: #64748b; min-width: 70px; }
.csv-schema-vals { color: var(--grid-text); }

.csv-drop {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  border: 2px dashed var(--grid-border-header);
  border-radius: var(--r-md);
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.csv-drop:hover, .csv-drop.is-drag { background: #f1f5f9; border-color: #94a3b8; }
.csv-drop-text { font-size: var(--grid-font); font-weight: 500; color: var(--grid-text); }
.csv-drop-hint { font-size: var(--grid-font); color: #94a3b8; }

.csv-sample-btn {
  align-self: flex-start;
  background: none; border: none;
  color: #475569; font-size: var(--grid-font);
  cursor: pointer; text-decoration: underline;
  padding: 0;
}

.csv-preview-info { font-size: var(--grid-font); color: #475569; }
.csv-preview-table-wrap {
  max-height: 240px; overflow: auto;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
}
.csv-col-skip { color: #cbd5e1 !important; }

.csv-result {
  border-top: 1px solid var(--grid-border-h);
  padding-top: 10px;
  font-size: var(--grid-font);
}
.csv-result-summary { display: flex; gap: 12px; margin-bottom: 6px; }
.csv-result-ok { color: #16a34a; font-weight: 600; }
.csv-result-fail { color: #dc2626; font-weight: 600; }
.csv-result-note { color: #2563eb; font-weight: 600; }

/* 행별 결과 뱃지 */
.csv-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: help;
}
.csv-badge--ok   { background: #ecfdf5; color: #059669; border: 1px solid #d1fae5; }
.csv-badge--warn { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.csv-badge--err  { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* 행별 기타차량 체크박스 */
.csv-other-check {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  user-select: none;
}
.csv-other-check input[type="checkbox"] {
  width: 12px;
  height: 12px;
  margin: 0;
  cursor: pointer;
}
.csv-row--warn td { background: #fffbeb !important; }
.csv-row--error td { background: #fef2f2 !important; }

/* 변환 표시 — 원본 → 보정값 */
.csv-cell-changed {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  font-size: 10px;
}
.csv-cell-changed__from { color: #94a3b8; text-decoration: line-through; }
.csv-cell-changed__to { color: #059669; font-weight: 500; font-size: 11px; }

/* 사유 컬럼 */
.csv-reason {
  font-size: 11px;
  white-space: normal;
  display: inline-block;
  text-align: left;
  line-height: 1.4;
}
.csv-reason--ok   { color: #94a3b8; }
.csv-reason--warn { color: #d97706; }
.csv-reason--err  { color: #dc2626; }

/* 자산전체 — 차량 종류 필터 바 */
.asset-type-filter {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--grid-border-h, #e9ecef);
  background: #fff;
  flex: 0 0 auto;
}
.asset-type-filter button {
  padding: 5px 14px;
  border: 1px solid var(--grid-border-h, #e9ecef);
  border-radius: var(--r-sm);
  background: #fff;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.asset-type-filter button:hover {
  background: #f6f7fa;
}
.asset-type-filter button.is-active {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}

/* 기타차량 뱃지 (그리드 행) */
.asset-other-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  background: #fef3c7;
  color: #92400e;
  font-size: 9px;
  font-weight: 500;
  vertical-align: 1px;
}

/* 추천 칩 */
.csv-sug-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.csv-sug-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border: 1px solid #c7d7ec;
  border-radius: var(--r-sm);
  background: #f0f6ff;
  color: #2563eb;
  font-size: 10px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.csv-sug-chip:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* 인라인 편집 가능 셀 — 셀 내부 div 형태 */
.csv-cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
}
.csv-cell-value.pls-cell--editable {
  display: inline-block;
  min-width: 40px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: text;
  outline: none;
}
.csv-cell-value.pls-cell--editable:hover {
  background: #fff7e6;
}
.csv-cell-value.pls-cell--editable:focus {
  background: #fffbeb;
  box-shadow: inset 0 0 0 2px #f59e0b;
}
.csv-cell-sugs {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
}
.csv-result-notes {
  margin-top: 6px;
  background: #f8fafc;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: var(--grid-font);
  color: #475569;
  max-height: 140px; overflow-y: auto;
}
.csv-result-notes summary { cursor: pointer; font-weight: 600; color: #2563eb; }
.csv-result-notes div { padding: 2px 0; }
.csv-result-errors {
  max-height: 120px; overflow-y: auto;
  background: #fef2f2;
  border-radius: var(--r-sm);
  padding: 6px 10px;
  color: #991b1b;
  font-size: var(--grid-font);
}

.csv-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding-top: 4px;
}
.csv-actions-left { display: flex; gap: 6px; }
.csv-actions .inline-button.is-active {
  background: #fff7ed; border-color: #fdba74; color: #c2410c;
}
.csv-actions .inline-button {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--grid-border-h);
  background: #fff;
  color: var(--grid-text);
  font-size: var(--grid-font);
  cursor: pointer;
}
.csv-actions .inline-button.btn-tone-save {
  background: #0f172a; color: #fff; border-color: #0f172a;
}
.csv-actions .inline-button:hover { background: #f1f5f9; }
.csv-actions .inline-button.btn-tone-save:hover { background: #1e293b; }

/* ─── 수납관리 — 납부 칩/입력 ────────────────────────────────────── */
.bill-payments {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px;
}
.bill-pay-chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 6px;
  background: #e2e8f0; color: #334155;
  border-radius: var(--r-xs);
  font-size: var(--grid-font);
  font-variant-numeric: tabular-nums;
}
.bill-pay-chip .bill-pay-del {
  background: none; border: none;
  color: #64748b; cursor: pointer;
  padding: 0 2px; font-size: 13px; line-height: 1;
}
.bill-pay-chip .bill-pay-del:hover { color: #dc2626; }

.bill-pay-add {
  height: 18px; padding: 0 8px;
  background: #fff; border: 1px dashed var(--grid-border-header);
  border-radius: var(--r-xs);
  color: #64748b; cursor: pointer;
  font-size: var(--grid-font);
}
.bill-pay-add:hover { background: #f1f5f9; color: #0f172a; }

/* 회차 한 줄 토글 버튼 */
.bill-toggle {
  padding: 2px 10px;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-xs);
  background: #fff;
  font-size: 11px;
  color: #475569;
  cursor: pointer;
}
.bill-toggle:hover { background: #f1f5f9; border-color: #94a3b8; }
.bill-detail-row td { padding: 8px 12px !important; }

.bill-pay-form {
  display: inline-flex; align-items: center; gap: 4px;
}
.bill-pay-form input,
.bill-pay-form select {
  height: 22px; padding: 0 6px;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-xs);
  font-size: var(--grid-font);
  background: #fff;
  outline: none;
}
.bill-pay-form input[name="date"] { width: 120px; }
.bill-pay-form select[name="method"] { width: 90px; }
.bill-pay-form input[name="amount"] { width: 100px; text-align: right; }
.bill-pay-form input[name="note"] { width: 100px; }
.bill-pay-form input:focus,
.bill-pay-form select:focus { border-color: #475569; box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.06); }

/* 납부 내역 표 (회차 셀 안에 inline 테이블) */
.bill-pay-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 4px;
  font-size: var(--grid-font);
  background: #fafbfc;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-xs);
  overflow: hidden;
}
.bill-pay-table th {
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 400;
  color: #64748b;
  background: #f1f3f5;
  border-bottom: 1px solid var(--grid-border-h);
  text-align: left;
}
.bill-pay-table th.num { text-align: right; }
.bill-pay-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--grid-border-h);
  white-space: nowrap;
}
.bill-pay-table td.num { text-align: right; }
.bill-pay-table tr:last-child td { border-bottom: none; }
.bill-pay-table .bill-pay-del {
  border: none; background: none; cursor: pointer;
  color: #94a3b8; font-size: 13px; padding: 0 4px;
}
.bill-pay-table .bill-pay-del:hover { color: #dc2626; }
.bill-pay-save, .bill-pay-cancel {
  height: 20px; padding: 0 8px;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-xs);
  font-size: var(--grid-font);
  cursor: pointer;
}
.bill-pay-save { background: #0f172a; color: #fff; border-color: #0f172a; }
.bill-pay-cancel { background: #fff; color: #64748b; }

/* 상태 뱃지 */
.bill-status {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: var(--grid-font); font-weight: 600;
}
.bill-status--unpaid  { background: #f1f5f9; color: #64748b; }
.bill-status--partial { background: #fef3c7; color: #92400e; }
.bill-status--paid    { background: #dcfce7; color: #166534; }
.bill-status--overdue { background: #fee2e2; color: #991b1b; }

/* ─── 일괄업로드 페이지 — 카드 그리드 ─────────────────────────── */
.upload-page-body { padding: 24px; }
.upload-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.upload-card {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 8px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.upload-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.upload-card:active { transform: translateY(1px); }
.upload-card-icon {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: #475569;
  border-radius: var(--r-sm);
  margin-bottom: 4px;
}
.upload-card-title {
  font-size: 14px; font-weight: 600; color: #0f172a;
}
.upload-card-desc {
  font-size: var(--grid-font); color: #475569;
  line-height: 1.5;
}
.upload-card-meta {
  font-size: var(--grid-font); color: #94a3b8;
  margin-top: 4px;
}

/* ─── 일괄업로드 워크스페이스 ─────────────────────────────────── */
.up-entity-tabs {
  display: flex; gap: 6px;
}
.up-entity-tab {
  flex: 1;
  height: 30px;
  background: #fff;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  font-size: var(--grid-font);
  color: #475569;
  cursor: pointer;
  transition: all 0.12s;
}
.up-entity-tab:hover { background: #f8fafc; border-color: #94a3b8; }
.up-entity-tab.is-active {
  background: #0f172a; color: #fff; border-color: #0f172a;
  font-weight: 600;
}

.up-schema-box {
  background: #f8fafc;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: var(--grid-font);
  display: flex; flex-direction: column; gap: 4px;
  color: var(--grid-text);
}
.up-schema-row { display: flex; gap: 8px; }
.up-schema-label { color: #64748b; min-width: 36px; flex-shrink: 0; }

.up-link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px;
  background: none; border: none; padding: 0;
  color: #475569; font-size: var(--grid-font);
  line-height: 1;
  cursor: pointer;
  text-align: left;
}
.up-link-btn svg { display: block; flex-shrink: 0; }
.up-link-btn span { text-decoration: underline; line-height: 1; }
.up-link-btn:hover { color: #0f172a; }
.up-confirm-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
}
.up-schema-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.up-source-tabs {
  display: flex; gap: 6px;
  margin-bottom: 10px;
}
.up-source-tab {
  flex: 1; height: 42px;
  background: #fff;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  font-size: var(--grid-font);
  color: #475569;
  cursor: pointer;
}
.up-source-tab:hover { background: #f8fafc; }
.up-source-tab.is-active {
  background: #0f172a; color: #fff;
  border-color: #0f172a; font-weight: 600;
}
.up-source-pane {
  display: flex; flex-direction: column;
  gap: 8px;
}
.up-source-pane[hidden] { display: none; }
.up-sheet-hint {
  font-size: var(--grid-font);
  color: #64748b;
  margin: 0;
}
.up-sheet-hint b { color: #0f172a; }
/* 파일 드롭존은 자기 컨텐츠만큼 */
#upPaneFile .up-drop { min-height: 100px; padding: 12px; }

/* 우측 작업 패널 — 업로드 시작 버튼은 항상 하단 고정 */
#upWorkBody { display: flex; flex-direction: column; }
#upWorkBody > .form-section:last-child { margin-top: auto; }

.up-drop {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  min-height: 100px;
  padding: 16px;
  border: 2px dashed var(--grid-border-header);
  border-radius: var(--r-md);
  background: #f8fafc;
  color: #64748b;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.up-drop:hover, .up-drop.is-drag { background: #f1f5f9; border-color: #94a3b8; }
.up-drop-text { font-size: var(--grid-font); color: var(--grid-text); }

.up-confirm-btn {
  width: 100%;
  height: 42px;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: var(--grid-font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s;
}
.up-confirm-btn:hover:not(:disabled) { background: #1e293b; }
.up-confirm-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

.up-option-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  font-size: 11px;
  color: var(--text-main, #1f2937);
  cursor: pointer;
  user-select: none;
}
.up-option-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}
.up-actions-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.up-actions-row .up-confirm-btn { flex: 1; }
.up-reset-btn {
  padding: 0 18px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--grid-border-h, #e9ecef);
  background: #fff;
  color: var(--text-main, #1f2937);
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.up-reset-btn:hover {
  background: #f6f7fa;
  border-color: #adb5bd;
}

.up-result-summary { display: flex; gap: 12px; font-size: var(--grid-font); }
.up-result-ok { color: #16a34a; font-weight: 600; }
.up-result-fail { color: #dc2626; font-weight: 600; }
.up-result-note { color: #2563eb; font-weight: 600; }
.up-result-errors {
  margin-top: 6px;
  max-height: 120px; overflow-y: auto;
  background: #fef2f2;
  border-radius: var(--r-sm);
  padding: 6px 10px;
  color: #991b1b;
  font-size: var(--grid-font);
}
.up-result-notes {
  margin-top: 6px;
  background: #f8fafc;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  font-size: var(--grid-font);
  color: #475569;
  max-height: 140px; overflow-y: auto;
}
.up-result-notes summary { cursor: pointer; font-weight: 600; color: #2563eb; }
.up-result-notes div { padding: 2px 0; }

/* ─── 공용 커스텀 셀렉트 ─────────────────────────────────────── */
.cs-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.cs-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: #f2f3f7;
  font-size: var(--grid-font);
  color: var(--grid-text);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.cs-trigger:hover { background: #eaecf2; }
.cs-trigger.is-open {
  background: #fff;
  border-color: var(--form-focus-border, #2b3a52);
  box-shadow: 0 0 0 3px rgba(43, 58, 82, 0.1);
}
.cs-label {
  flex: 1 1 auto;
  text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cs-label.is-placeholder { color: #94a3b8; }
.cs-arrow {
  flex-shrink: 0;
  margin-left: 8px;
  color: #64748b;
  transition: transform 0.18s;
}
.cs-trigger.is-open .cs-arrow { transform: rotate(180deg); }

.cs-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}
.cs-option {
  padding: 8px 14px;
  font-size: var(--grid-font);
  color: var(--grid-text);
  cursor: pointer;
  user-select: none;
}
.cs-option:hover { background: #f1f5f9; }
.cs-option.is-selected {
  background: #f8fafc;
  font-weight: 600;
  color: #0f172a;
}
.cs-option.is-disabled {
  color: #cbd5e1;
  cursor: not-allowed;
}

/* ─── 모드 뱃지 (보기/수정/신규 공통 시각 규격) ─────────────────────── */
.mode-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--r-xs);
  font-size: var(--grid-font);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-right: 6px;
}
.mode-badge--view   { background: var(--mode-view-bg);   color: var(--mode-view-fg); }
.mode-badge--edit   { background: var(--mode-edit-bg);   color: var(--mode-edit-fg); }
.mode-badge--create { background: var(--mode-create-bg); color: var(--mode-create-fg); }

/* 모드 컬러는 입력칸 자체에 반영 — 패널 색은 건드리지 않음 */
/* 수정 — 따뜻한 베이지 톤 */
.mode--edit .field input,
.mode--edit .field select,
.mode--edit .field textarea {
  border-color: #d6cfb8;
  background: #fdfcf7;
}
.mode--edit .field input:hover,
.mode--edit .field select:hover,
.mode--edit .field textarea:hover { border-color: #a89f7e; }
.mode--edit .field input:focus,
.mode--edit .field select:focus,
.mode--edit .field textarea:focus {
  border-color: #6b5e3c;
  box-shadow: 0 0 0 3px rgba(107, 94, 60, 0.16);
  background: #fff;
}

/* 신규 — 차가운 블루그레이 톤 */
.mode--create .field input,
.mode--create .field select,
.mode--create .field textarea {
  border-color: #b9c8d2;
  background: #f8fbfd;
}
.mode--create .field input:hover,
.mode--create .field select:hover,
.mode--create .field textarea:hover { border-color: #7d97a6; }
.mode--create .field input:focus,
.mode--create .field select:focus,
.mode--create .field textarea:focus {
  border-color: #3b556a;
  box-shadow: 0 0 0 3px rgba(59, 85, 106, 0.16);
  background: #fff;
}

.dd-section { margin-bottom: 20px; }
.dd-section:last-child { margin-bottom: 0; }
.dd-section__title {
  font-size: var(--grid-font);
  font-weight: 600;
  color: #64748b;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dd-section__title svg {
  width: 12px; height: 12px;
  color: #94a3b8;
}
.dd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.dd-grid--full { grid-template-columns: 1fr; }
.dd-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 3px 0; }
.dd-row__label { font-size: var(--grid-font); color: #6b7280; flex-shrink: 0; }
.dd-row__value { font-size: var(--grid-font); color: var(--grid-text); text-align: right; font-variant-numeric: tabular-nums; }
.dd-row__value--empty { color: #d1d5db; }

.dd-cost-table { width: 100%; border-collapse: collapse; font-size: var(--grid-font); }
.dd-cost-table th, .dd-cost-table td { padding: 5px 8px; border-bottom: 1px solid #f3f4f6; text-align: left; }
.dd-cost-table th { font-size: var(--grid-font); font-weight: 600; color: #6b7280; background: #f9fafb; }
.dd-cost-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dd-cost-table tfoot td { font-weight: 600; border-top: 1px solid var(--grid-border-header); border-bottom: none; }

/* 드로어 인라인 편집 */
.dd-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.dd-edit-row { display: flex; flex-direction: column; gap: 3px; }
.dd-edit-row label { font-size: var(--grid-font); color: #6b7280; }
.dd-edit-row input,
.dd-edit-row select,
.dd-edit-row textarea {
  font-size: var(--grid-font);
  color: var(--grid-text);
  padding: 5px 8px;
  border: 1px solid var(--grid-border-h);
  border-radius: var(--r-xs);
  background: #fff;
  outline: none;
  font-family: inherit;
}
.dd-edit-row input:focus,
.dd-edit-row select:focus,
.dd-edit-row textarea:focus {
  border-color: #64748b;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.06);
}

/* 모드 차이는 헤드 미세 톤으로만 — 무채색 유지 */
.detail-drawer--edit .detail-drawer__head,
.detail-drawer--create .detail-drawer__head {
  background: #f1f5f9;
}

/* ─── 그리드 패널 ─────────────────────────────────────────────────────────── */

.pls-grid-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: none;
  border-radius: var(--radius-ui, 8px);
  background: var(--new-bg-panel, #fff);
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.12), 0 4px 8px 3px rgba(60, 64, 67, 0.08);
}


.pls-grid-scroll {
  flex: 1 1 0;
  min-width: 0;
  overflow: auto;
  position: relative;
}

/* 헤더 ↔ 본문 경계: sticky pseudo-element 로 헤더 바로 아래에 그림자 띠 */
.pls-grid-scroll::before {
  content: '';
  position: sticky;
  display: block;
  top: var(--grid-header-h, 40px);
  width: 100%;
  height: 1px;
  margin-bottom: -1px;
  z-index: 11;
  pointer-events: none;
  background: transparent;
  box-shadow: 0 6px 8px -3px rgba(15, 23, 42, 0.22);
}

/* 본문이 비어있으면 스크롤 자체를 숨김 */
.pls-grid-scroll:has(tbody:empty) {
  overflow: hidden;
}
.panel-body:has(> .manage-idle-hint:only-child) {
  overflow: hidden !important;
}

/* idle 상태 큰 신규 버튼 — 모든 list_detail 페이지 공통 */
.manage-idle-hint.idle-create {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  min-height: 200px;
}
.idle-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 18px 44px;
  border: 1px solid var(--border-main, #dadce0);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  font-weight: 400;
  color: var(--new-text-main, #333);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.idle-create-btn svg { width: 22px; height: 22px; }
.idle-create-btn:hover {
  background: var(--grid-header-bg, #f6f7fa);
  border-color: #adb5bd;
}
.idle-create-hint {
  font-size: 11px;
  color: var(--text-muted, #94a3b8);
}

/* ─── 테이블 (엑셀형 — 컬럼은 max-content, 가로 스크롤) ───────────────────── */

.pls-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-size: var(--font-size-sub);
  white-space: nowrap;
}

.pls-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.pls-table thead tr {
  background: var(--new-bg-panel-head, #f0f4f9);
}

/* ─── 헤더 셀 (th) ───────────────────────────────────────────────────────── */

.pls-th {
  position: relative;
  padding: 0 var(--grid-cell-px);
  height: var(--grid-header-h);
  font-size: var(--panel-head-font, 12px);
  font-weight: 350; /* Pretendard 가변 폰트 — 셀 300보다 한 단계 위 */
  color: var(--new-text-main, var(--grid-header-color));
  white-space: nowrap;
  user-select: none;
  border-bottom: 1px solid var(--grid-border-h);
  border-right: 1px solid var(--grid-border-v);
  letter-spacing: -0.03em;
  text-align: center;
  background: var(--grid-header-bg);
}

/* 마지막 컬럼도 격자선 유지 — 엑셀 시트 느낌 */

/* 첫/끝 셀 여백만 패널 헤더와 정렬 (정렬은 기본 center 유지) */
.pls-table th:first-child,
.pls-table td:first-child { padding-left: var(--panel-head-px) !important; }
.pls-table th:last-child,
.pls-table td:last-child { padding-right: var(--panel-head-px) !important; }

.pls-th--sticky {
  position: sticky;
  left: 0;
  z-index: 11;
  background: var(--grid-header-bg);
  border-right: 1px solid var(--grid-border-h);
}

.pls-th__label { white-space: nowrap; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.pls-th__sort { font-size: 9px; color: #3b82f6; flex-shrink: 0; }

/* ─── 데이터 행 (tr) ──────────────────────────────────────────────────────── */

.pls-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pls-row:nth-child(even) td { background: var(--grid-row-even); }
.pls-row:nth-child(odd) td { background: var(--grid-row-odd); }
.pls-row:hover td { background: var(--grid-row-hover); }
.pls-row.is-active td {
  background: var(--grid-row-active);
}

/* ─── 데이터 셀 (td) ─────────────────────────────────────────────────────── */

.pls-cell {
  padding: 0 var(--grid-cell-px);
  height: var(--grid-row-h);
  line-height: var(--grid-row-h);
  vertical-align: middle;
  font-size: var(--panel-head-font, 12px);
  font-weight: var(--font-weight-base, 300);
  color: var(--grid-text);
  white-space: nowrap;
  letter-spacing: -0.03em;
  text-align: center;
  border-bottom: 1px solid var(--grid-border-h);
  border-right: 1px solid var(--grid-border-v);
}

/* 마지막 셀도 격자 유지 */
.pls-row.is-active .pls-cell { border-bottom-color: rgba(0, 0, 0, 0.06); }

.pls-cell--sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
}

.pls-cell--num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: 'Pretendard', monospace;
}

.pls-cell--dim { color: #64748b; }

.pls-cell[style*="max-width"] {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── 정렬 유틸 ───────────────────────────────────────────────────────────── */

.pls--center { text-align: center; }
.pls--right { text-align: right; }

/* ─── 행 액션 버튼 ──────────────────────────────────────────────────────── */

.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.row-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--height-xs);
  height: var(--height-xs);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #80868b;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.row-action-btn:hover {
  background: #f1f3f4;
  color: #1f1f1f;
}

.row-action-btn svg,
.row-action-btn path,
.row-action-btn circle,
.row-action-btn line {
  pointer-events: none;
}

.row-action-btn--danger:hover {
  background: #fce8e6;
  color: #d93025;
}

/* ─── 상태 배지 ───────────────────────────────────────────────────────────── */

.pls-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--badge-min-width);
  height: var(--badge-height);
  padding: 0 var(--badge-padding-x);
  margin: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--badge-radius);
  font-size: var(--badge-font-size);
  font-weight: var(--font-weight-strong);
  line-height: 1;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

.pls-badge--ok { background: #dcfce7; color: #166534; }
.pls-badge--warn { background: #fef3c7; color: #92400e; }
.pls-badge--off { background: #f1f5f9; color: #64748b; }

/* ─── 빈 목록 ─────────────────────────────────────────────────────────────── */

.pls-table .list-empty {
  padding: var(--height-2xl) var(--space-4);
  text-align: center;
  font-size: var(--font-size-base);
  color: #94a3b8;
}

/* ─── 색상 배지 (호환) ────────────────────────────────────────────────────── */

.color-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 var(--space-1); border-radius: var(--list-badge-radius, var(--radius-ui, 8px)); font-size: var(--font-size-xs); font-weight: var(--font-weight-heavy); line-height: 1; border: 1px solid rgba(0,0,0,0.08); }
.color-badge--on-dark { color: #fff; }
.color-badge--on-light { color: #333; }
.color-badge--empty { background: transparent; border: 1px dashed #cbd5e1; color: #94a3b8; }

/* ─── 헤더 필터 (filterable / searchable) ────────────────────────────────── */

.pls-th--sortable,
.pls-th--filterable { cursor: pointer; }
.pls-th--filterable:hover { background: #e2e8f0; color: #1e293b; }
.pls-th--filterable.is-filtering { background: #e2e8f0; color: #1e293b; }

.pls-th--has-filter { background: #e2e8f0; }
.pls-th--has-filter .pls-th__label { color: #1e293b; font-weight: var(--font-weight-heavy); }
.pls-th--has-filter::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 4px;
  right: 4px;
  height: 2px;
  background: #475569;
  border-radius: 1px;
}

.pls-filter-dd {
  position: fixed;
  z-index: 1000;
  min-width: 140px;
  max-width: 220px;
  max-height: 240px;
  overflow-y: auto;
  padding: 2px 0;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-ui, 8px);
  background: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
}

.pls-filter-dd[hidden] { display: none; }

.pls-filter-dd label {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-1);
  height: var(--height-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-base);
  color: #1e293b;
  cursor: pointer;
  letter-spacing: -0.03em;
}

.pls-filter-dd label:hover { background: #f1f5f9; }
.pls-filter-dd input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  min-height: 0;
  padding: 0;
}

.pls-fdd__section { padding: 2px 0; }
.pls-fdd__section + .pls-fdd__section { border-top: 1px solid #e2e8f0; }
.pls-fdd__title { padding: 2px 6px 1px; font-size: 9px; font-weight: var(--font-weight-heavy); color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; }

.pls-fdd__sort-row { display: flex; gap: 3px; padding: 3px 6px; border-bottom: 1px solid #e2e8f0; }
.pls-fdd__sort-btn { flex: 1; height: 22px; border: 1px solid #e2e8f0; border-radius: var(--radius-xs); background: #fff; font-size: var(--font-size-xs); color: #64748b; cursor: pointer; letter-spacing: -0.02em; }
.pls-fdd__sort-btn:hover { background: #f1f5f9; color: #1e293b; }
.pls-fdd__sort-btn.is-active { background: #eef2ff; border-color: #a5b4fc; color: #4338ca; font-weight: var(--font-weight-heavy); }

.pls-fdd__count { margin-left: auto; font-size: 9px; color: #94a3b8; font-variant-numeric: tabular-nums; flex-shrink: 0; }

.pls-fdd__actions { display: flex; gap: 3px; padding: 3px 6px; border-top: 1px solid #e2e8f0; position: sticky; bottom: 0; background: #fff; }
.pls-fdd__action-btn { flex: 1; height: 22px; border: 1px solid #e2e8f0; border-radius: var(--radius-xs); background: #fff; font-size: var(--font-size-xs); font-weight: var(--font-weight-heavy); cursor: pointer; letter-spacing: -0.02em; }
.pls-fdd__action-btn--reset { color: #64748b; }
.pls-fdd__action-btn--reset:hover { background: #f1f5f9; }
.pls-fdd__action-btn--apply { background: #1e293b; border-color: #1e293b; color: #fff; }
.pls-fdd__action-btn--apply:hover { background: #0f172a; }

.pls-fdd__search-wrap { padding: 6px; display: flex; align-items: center; gap: 6px; }

.pls-fdd__match-count {
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-heavy);
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.pls-fdd__match-count:empty { display: none; }

.pls-fdd__match-count--zero { color: #94a3b8; }
.pls-fdd__search { width: 100%; height: var(--height-xs); padding: 0 6px; border: 1px solid #cbd5e1; border-radius: var(--radius-xs); background: #fff; font-size: var(--font-size-xs); color: #1e293b; outline: none; letter-spacing: -0.02em; }
.pls-fdd__search:focus { border-color: #94a3b8; box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.06); }

.pls-filter-dd label.is-checked { background: #f1f5f9; }
.pls-filter-dd label.is-checked .pls-fdd__count { color: #475569; }
