/* 위클리 정산 — 주간 정산 PDF 리포트. 평소엔 숨겨두고 인쇄(다른 이름으로 저장 > PDF) 시에만 보여준다. */
#hg-weekly-print-root {
  display: none;
}

@media print {
  body > *:not(#hg-weekly-print-root) { display: none !important; }
  #hg-weekly-print-root { display: block !important; }
  @page { size: portrait; margin: 9mm; }
}

#hg-weekly-print-root {
  font-family: var(--hg-font);
  color: var(--hg-text1);
  padding: 12px;
}
/* 브라우저 인쇄 대화상자의 "배경 그래픽" 옵션이 꺼져 있어도 배경색(컬러 바/범례 점 등)이 항상 인쇄되도록 강제 */
#hg-weekly-print-root, #hg-weekly-print-root * {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  color-adjust: exact;
}
.hg-pdf-title { font-size: 18px; font-weight: 600; margin-bottom: 3px; }
.hg-pdf-subtitle { font-size: 10px; color: var(--hg-text3); margin-bottom: 12px; }

/* 일별 지출 + 한주 대시보드 — 4칸씩 2줄 (대시보드ㅣ월ㅣ화ㅣ수 / 목ㅣ금ㅣ토ㅣ일) */
.hg-pdf-day-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.hg-pdf-day-box { min-width: 0; border: 0.5px solid var(--hg-border); border-radius: 8px; padding: 16px; }

/* 한주 대시보드 박스 — 패딩(카드 여백)은 늘리는 대신, 내부 요소 간 여백은 좁혀서 카드 크기 자체는 유지 */
.hg-pdf-dash-box { font-size: 9px; }
.hg-pdf-dash-cat { margin-bottom: 4px; padding-bottom: 4px; border-bottom: 0.5px dashed var(--hg-border); }
.hg-pdf-dash-cat:last-of-type { border-bottom: none; }
.hg-pdf-dash-cat-name { display: flex; align-items: center; gap: 5px; font-weight: 600; font-size: 10px; margin-bottom: 2px; }
.hg-pdf-dash-metrics-labels, .hg-pdf-dash-metrics-values { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.hg-pdf-dash-metrics-labels { color: var(--hg-text3); }
.hg-pdf-dash-metrics-values { color: var(--hg-text1); font-weight: 500; }
.hg-pdf-dash-cat-simple { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; padding-bottom: 4px; border-bottom: 0.5px dashed var(--hg-border); font-size: 10px; font-weight: 600; }
.hg-pdf-dash-simple-val { margin-left: auto; font-weight: 500; color: var(--hg-text1); font-size: 9px; }
.hg-pdf-dash-check-title { font-size: 10px; font-weight: 600; margin: 4px 0 2px; }
.hg-pdf-dash-check-item { display: flex; align-items: center; gap: 5px; padding: 1px 0; }
.hg-pdf-dash-check-done { text-decoration: line-through; color: var(--hg-text4); }
.hg-pdf-dash-check-amt { margin-left: auto; color: var(--hg-text3); }
.hg-pdf-day-head { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.hg-pdf-day-total { font-size: 13px; font-weight: 600; color: var(--hg-accent); margin-bottom: 3px; }
.hg-pdf-day-rows { font-size: 10px; }
.hg-pdf-day-row { padding: 2px 0; border-bottom: 0.5px dashed var(--hg-border); }
.hg-pdf-day-row-top { display: flex; align-items: center; gap: 4px; }
.hg-pdf-bar { width: 3px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.hg-pdf-day-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hg-pdf-day-row-amt { flex-shrink: 0; font-weight: 500; }
.hg-pdf-day-empty { font-size: 10px; color: var(--hg-text4); text-align: center; padding: 8px 0; }

/* 가치 판단 배지(쓸스/안쓰/중립) — daily-logs 정산과 동일한 색 */
.hg-pdf-badge { font-size: 8px; font-weight: 500; padding: 1px 5px; border-radius: 6px; white-space: nowrap; flex-shrink: 0; }
.hg-pdf-badge-good { border: 0.5px solid var(--hg-accent); background: rgba(46,124,246,0.08); color: var(--hg-accent); }
.hg-pdf-badge-bad { border: 0.5px solid var(--hg-danger); background: #FEF2F2; color: var(--hg-danger); }
.hg-pdf-badge-neu { border: 0.5px solid var(--hg-border); background: var(--hg-bg); color: var(--hg-text3); }

/* 리뷰 */
.hg-pdf-review { border: 0.5px solid var(--hg-border); border-radius: 8px; padding: 10px 14px; margin-bottom: 0; font-size: 11px; }
.hg-pdf-review > div { margin-bottom: 6px; }
.hg-pdf-review > div:last-child { margin-bottom: 0; }
.hg-pdf-review p { margin: 3px 0 0; white-space: pre-wrap; color: var(--hg-text2); }

/* 카테고리 블록(도넛 + 평가) */
.hg-pdf-cat-block { margin-bottom: 12px; page-break-inside: avoid; }
.hg-pdf-cat-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
/* 일별 7칸과 동일한 7열 그리드 — 도넛은 일·월 2칸, 상세표는 화~토 5칸 폭에 맞춘다 */
.hg-pdf-cat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: start; }
.hg-pdf-cat-donut { grid-column: span 2; text-align: center; }
.hg-pdf-cat-remain { font-size: 10px; color: var(--hg-text3); margin-top: 2px; }
/* 원형 밑 범례 — 어떤 색이 어떤 소분류인지 명확히 보이도록 사각 스와치로 표시 */
.hg-pdf-legend { margin-top: 8px; text-align: left; }
.hg-pdf-legend-row { display: flex; align-items: center; gap: 6px; font-size: 9.5px; padding: 2px 0; }
.hg-pdf-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.hg-pdf-legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--hg-text2); font-weight: 500; }
.hg-pdf-legend-pct { color: var(--hg-text3); flex-shrink: 0; }
.hg-pdf-legend-val { color: var(--hg-text1); font-weight: 500; flex-shrink: 0; min-width: 48px; text-align: right; }
/* 카드 여백은 위 일별 지출 카드(16px)와 통일하고, 그만큼 내부 요소 간격을 좁혀서 카드 크기는 유지 */
.hg-pdf-cat-eval { grid-column: span 5; min-width: 0; border: 0.5px solid var(--hg-border); border-radius: 8px; padding: 16px; }
/* 상세 카테고리 표(왼쪽) ㅣ 이번주 지출 평가(오른쪽) 좌우 배치 — 구분선은 상세표 높이만큼만 (border는 요소 자체 높이를 따라가므로 stretch하지 않아야 함) */
.hg-pdf-cat-eval-split { display: flex; align-items: flex-start; }
.hg-pdf-cat-eval-detail { flex-shrink: 0; padding-right: 30px; border-right: 1px solid var(--hg-border); }
.hg-pdf-cat-eval-text { flex: 1; min-width: 0; padding-left: 30px; }
.hg-pdf-cat-eval-title { font-size: 11px; font-weight: 600; margin-bottom: 3px; }
.hg-pdf-cat-eval ul { margin: 0; padding-left: 16px; font-size: 10.5px; line-height: 1.5; }

/* 카테고리 상세 표(항목/주 예산/주 지출/잔액) — 이름 열을 1fr로 늘리지 않고 내용에 맞게 좁혀서
   이름과 숫자 사이에 큰 빈틈이 생기지 않도록 한다. 표 자체도 카드 폭까지 억지로 늘리지 않는다. */
.hg-pdf-detail-table { width: fit-content; max-width: 100%; }
.hg-pdf-detail-head, .hg-pdf-detail-row { display: grid; grid-template-columns: 86px 54px 54px 54px; gap: 10px; font-size: 10px; padding: 1px 0; align-items: center; }
.hg-pdf-detail-head { color: var(--hg-text3); font-weight: 500; padding-bottom: 3px; margin-bottom: 1px; border-bottom: 0.5px dashed var(--hg-border); }
.hg-pdf-detail-head span:not(:first-child), .hg-pdf-detail-row span { text-align: right; }
.hg-pdf-detail-name { display: flex; align-items: center; gap: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
