/* ════════════════════════════════════════════════════════════════
   비용 관리 뷰 (Cost View) — 전용 스타일
   · index.html 인라인 <style>에서 분리(데스크탑+모바일 @media 전부).
   · :root 디자인 토큰(--surface/--line/--brand 등)은 index.html이 정의 —
     여기서는 var() 참조만 한다.
   · JS는 static/js/cost.js (window.CostView)
   ════════════════════════════════════════════════════════════════ */
/* ════════ 비용 관리 뷰 ════════ */
/* 뷰 전환 — 비용 관리 활성 시 대시보드 섹션·배너/빈상태 숨김(#costView만 표시).
   SPA 섹션 show/hide 방식: 퍼포먼스 채널 복귀 시 클래스 제거로 원래 대시보드 무손상 복원. */
.container.view-cost > .section:not(#costView),
.container.view-cost > #bannerSlot,
.container.view-cost > #emptySlot { display: none; }

.cost-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; box-shadow: 0 1px 2px rgba(16, 24, 32, .04);
}
.cost-form { display: grid; gap: 14px; }
.cost-form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.cost-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cost-field-grow { flex: 1 1 220px; }
.cost-field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.cost-input {
  height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); font-size: 14px; color: var(--text); font-family: inherit;
}
.cost-input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
select.cost-input { padding-right: 8px; }
/* 카테고리 칩 — 한 줄(좁으면 줄바꿈), 선택은 세이지 브랜드 */
.cost-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cost-chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; line-height: 1;
}
.cost-chip:hover { background: var(--surface-3); }
.cost-chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
/* 칩 아래 보조 안내 한 줄 — 작고 muted, 거슬리지 않게 */
.cost-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.4; }
/* 기간 일할 분배 토글 + 범위 */
.cost-split-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; padding-bottom: 9px; }
.cost-split-toggle input { accent-color: var(--brand); width: 16px; height: 16px; cursor: pointer; }
.cost-split-range { display: inline-flex; align-items: center; gap: 6px; }
.cost-split-range[hidden] { display: none; }
.cost-split-tilde { color: var(--muted); }
.cost-actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.cost-actions .btn { width: auto; padding: 10px 16px; font-size: 14px; }
.cost-btn-ghost { background: var(--surface); border: 1px solid var(--line-strong); color: var(--text-2); border-radius: 10px; cursor: pointer; font-family: inherit; font-weight: 600; }
.cost-btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.cost-btn-ghost:disabled { opacity: .5; cursor: default; }
.cost-edit-cap { color: var(--chart-line-ink); }
/* scope 토글(퍼포먼스/시스템/전체) — 작게. unit-btn과 분리(전역 단위 토글 핸들러 오염 방지) */
.cost-scope { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.cost-scope-btn { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; line-height: 1; }
.cost-scope-btn.is-active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 2px rgba(16, 24, 32, .08); }
/* 내역 필터 */
.cost-filter { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.cost-filter .cost-input { height: 34px; font-size: 13px; }
.cost-filter-vendor { width: 180px; }
/* 내역 테이블 — 기존 카드/세이지 톤 일관, 모바일 가로 스크롤(.table-scroll 재사용) */
.cost-grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 860px; }
.cost-grid thead th {
  background: var(--thead-bg); color: var(--text-2); font-weight: 600; text-align: left;
  padding: 9px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.cost-grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; color: var(--text); background: var(--surface); }
.cost-grid tbody tr:nth-child(even) td { background: var(--surface-3); }
.cost-grid td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.cost-grid td.memo { white-space: normal; min-width: 160px; max-width: 340px; color: var(--text-2); }
.cost-grid td.cost-empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.cost-cat-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--sage-tint); color: var(--brand-ink); font-size: 12px; font-weight: 600; }
.cost-cat-badge.is-system { background: var(--surface-2); color: var(--muted); }
.cost-act-btn { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text-2); font-family: inherit; font-weight: 600; }
.cost-act-btn:hover { background: var(--surface-3); }
.cost-act-btn.danger { color: var(--neg); border-color: #F0CFCF; }
.cost-act-btn.danger:hover { background: var(--neg-bg); }
.cost-act-btn + .cost-act-btn { margin-left: 6px; }
.cost-more-wrap { display: flex; justify-content: center; margin-top: 12px; }
.cost-more-wrap .btn { width: auto; padding: 9px 22px; font-size: 13px; }
.cost-list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
/* ── 비용 관리 날짜 선택 — 기간 설정과 동일 Cally 캘린더(트리거 알약 + 팝오버) ──
   네이티브 input[type=date]는 값 보관용으로 유지(cost-native-only — 기존 JS가 .value를
   그대로 읽고 씀). Cally 정상 시 숨기고 트리거가 표시 담당, 로드 실패(.no-cally) 시 노출. */
.cost-cal { position: relative; display: inline-flex; min-width: 0; }
.cost-native-only { display: none; }
.no-cally .cost-native-only { display: inline-block; }
.no-cally .cost-cal { display: none; }
/* 폼/필터 트리거 높이를 주변 인풋과 정렬 */
.cost-form .cal-trigger { min-height: 38px; padding: 8px 12px; }
.cost-filter .cal-trigger { min-height: 34px; padding: 6px 12px; font-size: 12.5px; }

/* 모바일 — 폼 세로 스택, 필터 줄바꿈, 테이블은 .table-scroll 가로 스크롤 */
@media (max-width: 639px) {
  .cost-cal { flex: 1 1 100%; }
  .cost-cal .cal-trigger { width: 100%; min-height: 44px; justify-content: space-between; box-sizing: border-box; }
  .cost-form-row { flex-direction: column; align-items: stretch; }
  .cost-field, .cost-field-grow { width: 100%; }
  .cost-split-range { width: 100%; }
  .cost-split-range .cost-input { flex: 1 1 0; min-width: 0; }
  .cost-actions { margin-left: 0; width: 100%; }
  .cost-actions .btn { flex: 1 1 0; }
  .cost-filter .cost-field { flex: 1 1 46%; }
  .cost-filter-vendor { width: 100%; }
}
