/* ══════════════════════════════════════════════════════════════════════
   비용 절감 탭 (#svPanel) — 재무 화면 톤(finance.css 변수) 그대로 사용.
   finance.css 뒤에 로드해야 --ink/--line/--surface-2 등 변수를 쓸 수 있다.
   ══════════════════════════════════════════════════════════════════════ */

#svPanel { font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 14px; }
#svPanel .num { font-variant-numeric: tabular-nums; }
#svPanel .r { text-align: right; }

#svPanel .sv-content { padding: 18px 22px 60px; display: flex; flex-direction: column; gap: 16px; }
/* ⚠ display:flex 가 HTML [hidden](display:none)을 이겨서, 데이터가 오기 전에 빈 카드가 그대로 보였다.
   명시적으로 되돌린다 — 로딩 중엔 아무것도 안 보이는 게 맞다. */
#svPanel .sv-content[hidden] { display: none; }
@media (max-width: 639px) { #svPanel .sv-content { padding-left: 16px; padding-right: 16px; } }

#svPanel .fin-msg { margin: 18px 22px; padding: 14px 16px; background: var(--surface-2, #F4F5F7);
  border-radius: 10px; color: var(--ink2, #4A5159); font-size: 13px; line-height: 1.6; }

/* ── 요약 카드 ── */
#svPanel .sv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
#svPanel .sv-kpi { background: #fff; border-radius: var(--r, 14px); box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06)); padding: 16px 18px; }
#svPanel .sv-kpi .k { font-size: 12px; color: var(--muted, #79818B); font-weight: 600; }
#svPanel .sv-kpi .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--ink, #1A1D21);
  margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
#svPanel .sv-kpi .v.pos { color: #1F8A4C; }
#svPanel .sv-kpi .v.neg { color: #C0392B; }
#svPanel .sv-kpi .meta { font-size: 11.5px; color: var(--muted, #79818B); line-height: 1.5; }

/* ── 섹션 카드 ── */
#svPanel .sv-card { background: #fff; border-radius: var(--r, 14px); box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.06)); overflow: hidden; }
#svPanel .sv-card > .hd { padding: 14px 18px 12px; border-bottom: 1px solid var(--line, #E7E9EC);
  font-size: 14px; font-weight: 700; color: var(--ink, #1A1D21); letter-spacing: -.01em;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
#svPanel .sv-card > .hd .cap { font-size: 11.5px; font-weight: 500; color: var(--muted, #79818B); }
#svPanel .sv-card > .bd { padding: 0; }
#svPanel .sv-desc { padding: 12px 18px; font-size: 12.5px; line-height: 1.7; color: var(--ink2, #4A5159);
  background: var(--surface-2, #F8F9FA); border-bottom: 1px solid var(--line, #E7E9EC); }
#svPanel .sv-desc b { color: var(--ink, #1A1D21); font-weight: 700; }
#svPanel .sv-note-bar { padding: 11px 18px; font-size: 12px; line-height: 1.7; color: var(--muted, #79818B);
  border-top: 1px solid var(--line, #E7E9EC); }
#svPanel .sv-note-bar b { color: var(--ink2, #4A5159); font-weight: 700; }

/* ── 표 ── */
#svPanel .sv-scroll { overflow-x: auto; }
#svPanel .sv-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#svPanel .sv-tbl th, #svPanel .sv-tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line, #E7E9EC); white-space: nowrap; }
#svPanel .sv-tbl thead th { background: var(--surface-2, #F8F9FA); color: var(--muted, #79818B);
  font-size: 11.5px; font-weight: 700; text-align: left; position: sticky; top: 0; z-index: 2; }
#svPanel .sv-tbl thead th.r { text-align: right; }
#svPanel .sv-tbl thead th .sub { display: block; font-size: 10px; font-weight: 500; opacity: .8; margin-top: 1px; }
#svPanel .sv-tbl td.num { font-variant-numeric: tabular-nums; color: var(--ink2, #4A5159); }
#svPanel .sv-tbl td.num.strong { color: var(--ink, #1A1D21); font-weight: 700; }
#svPanel .sv-tbl td.num.pos { color: #1F8A4C; }
#svPanel .sv-tbl td.num.neg { color: #C0392B; }
#svPanel .sv-tbl td .sub { display: block; font-size: 10px; color: var(--muted, #79818B); font-weight: 500; }
#svPanel .sv-tbl tbody tr:hover td { background: #FAFBFC; }
#svPanel .sv-tbl tr.tot td { background: var(--surface-2, #F8F9FA); font-weight: 700; border-top: 1.5px solid var(--line, #E7E9EC); }
#svPanel .sv-tbl tr.tot:hover td { background: var(--surface-2, #F8F9FA); }
/* 첫 칸 고정 — 가로 스크롤에서 월이 따라온다 */
#svPanel .sv-tbl td.stick, #svPanel .sv-tbl th.stick { position: sticky; left: 0; z-index: 3;
  background: #fff; font-weight: 700; color: var(--ink, #1A1D21); border-right: 1px solid var(--line, #E7E9EC); }
#svPanel .sv-tbl thead th.stick { background: var(--surface-2, #F8F9FA); z-index: 4; }
#svPanel .sv-tbl tr.tot td.stick { background: var(--surface-2, #F8F9FA); }

/* 시나리오 표에서 현재 수준 줄 */
#svPanel .sv-tbl tr.here td { background: #F3F7F4; }
#svPanel .sv-tbl tr.here:hover td { background: #EEF4F0; }
#svPanel .sv-tbl tr.here td .tag { display: inline-block; margin-left: 7px; padding: 2px 7px; border-radius: 999px;
  background: #E7F4EC; color: #1F8A4C; font-size: 10.5px; font-weight: 700; }

/* ── 흐름 태그 ── */
#svPanel .sv-tbl td.tags { white-space: normal; min-width: 190px; }
#svPanel .tg { display: inline-block; margin: 1px 4px 1px 0; padding: 2px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; background: var(--surface-2, #F1F3F5); color: var(--muted, #79818B); }
#svPanel .tg.up { background: #E7F4EC; color: #1F8A4C; }
#svPanel .tg.down { background: #FBEAE7; color: #C0392B; }
#svPanel .tg.hi { background: #E8F1F5; color: #3E6B8A; }
#svPanel .tg.lo { background: #F1F3F5; color: #79818B; }
#svPanel .tg.warn { background: #FBF1E0; color: #B7791F; }

/* ── 라벨별 세부 표 ── */
#svPanel .sv-tbl .zero { color: #C3C8CD; }
#svPanel .sv-grp { font-size: 11px; color: var(--muted, #79818B); font-weight: 600; }
#svPanel .sv-chip { display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; background: var(--surface-2, #F1F3F5); color: var(--muted, #79818B); }
#svPanel .sv-break td.stick, #svPanel .sv-break th.stick { min-width: 150px; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; }
#svPanel .sv-break tr.sv-unl td { background: #FDF6EC; }
#svPanel .sv-break tr.sv-unl:hover td { background: #FBF0E0; }
#svPanel .sv-break tr.sv-unl td.stick { background: #FDF6EC; color: #B7791F; }
#svPanel .sv-warn { color: #B7791F; }
/* 스파이크 셀 — 그 항목에서 유독 튄 달. 볼드+앰버+옅은 배경으로 눈에 걸리게. */
#svPanel .sv-tbl td.sv-spike { color: #B7791F; font-weight: 800; background: #FDF3E3; }
#svPanel .sv-tbl tbody tr:hover td.sv-spike { background: #FAEBD3; }
#svPanel .sv-spike-legend { color: #B7791F; font-weight: 800; }

/* ── 셀 클릭 → 거래 내역 드릴다운 ── */
#svPanel td.sv-clickable { cursor: pointer; }
#svPanel td.sv-clickable:hover { background: #EEF3EF; }
#svPanel td.sv-clickable:focus-visible { outline: 2px solid #6E8472; outline-offset: -2px; }
#svPanel td.sv-open { background: #E7EFE9 !important; box-shadow: inset 0 -2px 0 #6E8472; }
/* 월별 요약 표 — 행 전체가 클릭 대상(그 달 금액 큰 순 10건) */
#svPanel tr[data-txm] { cursor: pointer; }
#svPanel tr[data-txm]:hover > td { background: #EEF3EF; }
#svPanel tr[data-txm]:focus-visible { outline: 2px solid #6E8472; outline-offset: -2px; }
#svPanel tr.sv-open-row > td { background: #E7EFE9 !important; }
#svPanel tr.sv-open-row > td.stick { box-shadow: inset 3px 0 0 #6E8472; }
#svPanel table.sv-tx td.sv-tx-lb { color: var(--ink2, #4A5159); font-weight: 600; }
#svPanel .sv-tx-sh { font-weight: 500; color: var(--muted, #79818B); }

#svPanel tr.sv-drill > td { padding: 0; background: #FAFBFC; border-bottom: 1px solid var(--line, #E7E9EC); }
#svPanel .sv-drill-hd { display: flex; align-items: center; gap: 9px; padding: 10px 16px;
  font-size: 12.5px; font-weight: 700; color: var(--ink, #1A1D21);
  border-bottom: 1px solid var(--line, #E7E9EC); background: #F1F4F2; }
#svPanel .sv-drill-cap { font-size: 11px; font-weight: 500; color: var(--muted, #79818B); }
#svPanel .sv-drill-x { margin-left: auto; border: none; background: transparent; cursor: pointer;
  color: var(--muted, #79818B); font-size: 13px; line-height: 1; padding: 3px 5px; border-radius: 5px; }
#svPanel .sv-drill-x:hover { background: rgba(0,0,0,.06); color: var(--ink, #1A1D21); }
#svPanel table.sv-tx { width: 100%; border-collapse: collapse; font-size: 12px; }
#svPanel table.sv-tx th, #svPanel table.sv-tx td { padding: 8px 16px; border-bottom: 1px solid #EEF0F2; white-space: nowrap; }
#svPanel table.sv-tx thead th { background: transparent; color: var(--muted, #79818B);
  font-size: 11px; font-weight: 700; text-align: left; position: static; }
#svPanel table.sv-tx thead th.r { text-align: right; }
#svPanel table.sv-tx td.sv-tx-d { color: var(--muted, #79818B); font-variant-numeric: tabular-nums; width: 66px; }
/* 적요는 길 수 있어 이 칸만 줄바꿈 허용 */
#svPanel table.sv-tx td.sv-tx-ds { white-space: normal; color: var(--ink2, #4A5159); min-width: 260px; }
#svPanel table.sv-tx tbody tr:hover td { background: #F4F6F5; }
#svPanel table.sv-tx tr.tot td { background: #F1F4F2; font-weight: 700; border-bottom: none; }
#svPanel table.sv-tx tr.tot:hover td { background: #F1F4F2; }
#svPanel .sv-empty { padding: 26px 18px; text-align: center; color: var(--muted, #79818B); font-size: 12.5px; }

/* ── 계산식 툴팁 (body 직속 — 표 overflow에 안 잘린다) ── */
.sv-calc-tip { position: fixed; z-index: 9999; max-width: 340px; padding: 10px 12px;
  background: #23282D; color: #fff; border-radius: 9px; box-shadow: 0 6px 20px rgba(0,0,0,.22);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", Roboto, sans-serif;
  pointer-events: none; }
.sv-calc-tip[hidden] { display: none; }
.sv-calc-tip .ct-t { font-size: 11px; font-weight: 700; color: #9AA3AB; letter-spacing: .02em; margin-bottom: 5px; }
/* 식이 길면 \n 으로 줄을 나눈다(JS가 넣은 개행을 그대로 살린다) */
.sv-calc-tip .ct-e { font-size: 12.5px; font-weight: 600; line-height: 1.55; font-variant-numeric: tabular-nums;
  word-break: keep-all; white-space: pre-line; }
.sv-calc-tip .ct-r { font-size: 13px; font-weight: 800; color: #8FD4A8; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sv-calc-tip .ct-d { font-size: 11.5px; line-height: 1.6; color: #C3CAD1; margin-top: 7px;
  padding-top: 7px; border-top: 1px solid rgba(255,255,255,.14); }
/* 계산식이 붙은 셀·헤더 — 점선 밑줄로 "설명이 있다"는 걸 알린다 */
#svPanel [data-calc] { cursor: help; }
#svPanel td[data-calc] { text-decoration: underline dotted rgba(0,0,0,.22); text-underline-offset: 3px; }
#svPanel th[data-calc] { text-decoration: underline dotted rgba(0,0,0,.3); text-underline-offset: 3px; }

/* ── 눈에 띄는 것 ── */
#svPanel .sv-note { padding: 13px 18px; border-bottom: 1px solid var(--line, #E7E9EC); }
#svPanel .sv-note:last-child { border-bottom: none; }
#svPanel .sv-note .t { font-size: 13px; font-weight: 700; color: var(--ink, #1A1D21); margin-bottom: 4px; }
#svPanel .sv-note .d { font-size: 12.5px; line-height: 1.7; color: var(--ink2, #4A5159); }
