/* =============================================
   자산 인사이트 (Insights) — 임원용 대시보드
   ============================================= */

.ix-main {
  padding: var(--sp-3);
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* ── 월 범위 Scope (dual-handle range slider) ── */
.ix-scope__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}
.ix-scope__label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: var(--snow);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.ix-range-slider {
  position: relative;
  height: 50px;
  margin: 0 9px; /* thumb 너비 절반만큼 inset → tick 정렬용 */
}

.ix-range-track {
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--mist);
  border-radius: 3px;
}
.ix-range-fill {
  position: absolute;
  top: 14px;
  height: 6px;
  background: linear-gradient(90deg, var(--green-dark), var(--green));
  border-radius: 3px;
  transition: left 80ms linear, width 80ms linear;
}

/* 두 개의 range input을 트랙 위에 겹쳐 배치. 트랙 영역은 click 비활성, thumb만 활성. */
.ix-range-input {
  position: absolute;
  top: 8px;
  left: -9px;
  right: -9px;
  width: calc(100% + 18px);
  height: 18px;
  background: transparent;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  z-index: 2;
}
.ix-range-input--max { z-index: 3; }

.ix-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: all;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--green-dark);
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--t-fast);
}
.ix-range-input::-webkit-slider-thumb:hover { transform: scale(1.1); }
.ix-range-input::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }

.ix-range-input::-moz-range-thumb {
  pointer-events: all;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--green-dark);
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.ix-range-input::-moz-range-track { background: transparent; border: 0; }

/* 12개 월 tick — JS가 each tick의 left를 i/11*100% 로 설정 */
.ix-range-ticks {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 14px;
}
.ix-range-ticks > span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--silver);
  white-space: nowrap;
}
.ix-range-ticks > span.in-scope {
  color: var(--green-dark);
  font-weight: 700;
}

/* ── 공통 섹션 ─────────────────────────── */
.ix-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: var(--sp-3);
}

.ix-section__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.ix-section__title small {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--silver);
}

/* ── US-2 + US-4: 카테고리 분포 막대 (필터 역할) ── */
.ix-cat-bars-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.ix-cat-bars-head__right {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}
.ix-filter__hint {
  font-size: 11px;
  color: var(--silver);
  white-space: nowrap;
}
.ix-cat-clear {
  font-family: var(--font-base);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--slate);
  cursor: pointer;
  transition: background var(--t-fast);
}
.ix-cat-clear:hover { background: var(--snow); }

/* 카테고리 분포 — 세로 막대 차트 컨테이너 */
.ix-cat-bars {
  display: flex;
  align-items: stretch;
  gap: 3px;
  overflow-x: auto;
  height: 220px;
  padding: 4px 2px;
}

/* 한 막대 = 한 카테고리. 전체가 클릭 가능한 button. 컬럼 레이아웃. */
.ix-cat-bar {
  flex: 0 0 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-base);
  cursor: pointer;
  text-align: center;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.ix-cat-bar:hover {
  background: var(--snow);
  border-color: var(--border);
}
.ix-cat-bar.active {
  background: rgba(155, 202, 60, 0.12);
  border-color: var(--green);
}
.ix-cat-bar.active .ix-cat-bar__label {
  color: var(--green-dark);
  font-weight: 700;
}
.ix-cat-bar.active .ix-cat-bar__fill {
  background: linear-gradient(180deg, var(--green), var(--green-dark));
}

/* 상단: 건수 + % */
.ix-cat-bar__count {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 3px;
  min-height: 14px;
  white-space: nowrap;
}
.ix-cat-bar__count small {
  font-size: 9px;
  font-weight: 500;
  color: var(--silver);
}

/* 막대 트랙 (세로) */
.ix-cat-bar__track {
  flex: 1;
  width: 24px;
  background: var(--mist);
  border-radius: 4px 4px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.ix-cat-bar__fill {
  display: block;
  width: 100%;
  background: linear-gradient(180deg, var(--slate), var(--silver));
  border-radius: 4px 4px 0 0;
  transition: height var(--t-normal), background var(--t-normal);
  min-height: 2px;
}

/* 하단: 카테고리 라벨 (작은 폰트, 2줄까지 줄바꿈) */
.ix-cat-bar__label {
  font-size: 10px;
  color: var(--slate);
  font-weight: 500;
  line-height: 1.15;
  word-break: keep-all;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  height: 24px;
  width: 100%;
  text-align: center;
}

.ix-empty {
  padding: var(--sp-4);
  text-align: center;
  color: var(--silver);
  font-size: 13px;
}

/* ── US-1: KPI ─────────────────────────── */
.ix-kpi-grid {
  display: grid;
  grid-template-columns: 0.7fr 1fr 1fr;
  gap: var(--sp-2);
}

.ix-kpi {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--snow);
}
.ix-kpi--global   { border-left: 4px solid var(--cluster-d-bar); }
.ix-kpi--domestic { border-left: 4px solid var(--green); }

.ix-kpi__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate);
  letter-spacing: 0.02em;
}
.ix-kpi__target {
  margin-left: auto;
  font-size: 10px;
  font-weight: 500;
  color: var(--silver);
  background: var(--mist);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

.ix-kpi__big {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.05;
}

.ix-kpi__bar {
  position: relative;
  height: 10px;
  background: var(--mist);
  border-radius: 5px;
  overflow: visible;
}
.ix-kpi__bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 5px;
  transition: width var(--t-normal);
}
.ix-kpi__bar-fill--global   { background: var(--cluster-d-bar); }
.ix-kpi__bar-fill--domestic { background: var(--green); }

/* 가이드라인 표시 — 막대 위에 짧은 검정 바 */
.ix-kpi__bar-target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--ink);
  border-radius: 1px;
  transform: translateX(-50%);
}
.ix-kpi__bar-target::after {
  content: '';
  position: absolute;
  top: -2px; left: 50%;
  width: 6px; height: 6px;
  background: var(--ink);
  border-radius: 50%;
  transform: translateX(-50%);
}

.ix-kpi__delta {
  display: inline-block;
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--mist);
  color: var(--slate);
}
.ix-kpi__delta.ix-delta--up   { background: rgba(231, 76, 60, 0.15);   color: var(--error); }
.ix-kpi__delta.ix-delta--down { background: rgba(243, 156, 18, 0.18);  color: var(--warning); }
.ix-kpi__delta.ix-delta--flat { background: rgba(46, 204, 113, 0.15);  color: var(--success); }

.ix-kpi__hint {
  font-size: 10.5px;
  color: var(--silver);
}

/* ── US-3: 월별 밸런스 Heatmap ─────────── */
.ix-heatmap-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
}
@media (max-width: 1100px) {
  .ix-heatmap-row { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 600px) {
  .ix-heatmap-row { grid-template-columns: repeat(4, 1fr); }
}

.ix-heatmap-cell {
  position: relative;
  border-radius: var(--radius-sm);
  padding: 8px 7px 6px;
  min-height: 88px;
  background: var(--white);
  color: var(--ink);
  border: 1px solid rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  cursor: default;
}
.ix-heatmap-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

/* 마케팅 없음: 빨강 + 흰 텍스트 */
.ix-heatmap-cell--empty {
  background: var(--error);
  color: var(--white);
  border-color: var(--error);
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.ix-heatmap-cell__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.ix-heatmap-cell__month {
  font-size: 13px;
  font-weight: 700;
}
.ix-heatmap-cell__count {
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
  color: var(--ink);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  text-shadow: none;
}
.ix-heatmap-cell--empty .ix-heatmap-cell__count {
  background: rgba(255, 255, 255, 0.30);
  color: var(--white);
}

.ix-heatmap-cell__big {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.ix-heatmap-cell__big small {
  font-size: 11px;
  font-weight: 600;
  margin-left: 2px;
  opacity: 0.85;
}
.ix-heatmap-cell--empty .ix-heatmap-cell__big { font-size: 22px; }

.ix-heatmap-cell__foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.ix-heatmap-cell__foot--center {
  justify-content: center;
  font-weight: 700;
}

/* 범례 — 그라디언트 바 + 자산 없음 표시 */
.ix-heatmap-legend {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border);
  font-size: 11px;
  color: var(--slate);
  flex-wrap: wrap;
}
.ix-heatmap-legend__label { font-weight: 600; }
.ix-heatmap-legend__gradient {
  width: 220px;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgb(155, 202, 60)   0%,    /* 국내 초과 */
    rgb(255, 255, 255) 50%,    /* 정상 */
    rgb(52, 152, 219)  100%    /* 글로벌 초과 */
  );
  border: 1px solid var(--border);
}
.ix-heatmap-legend__scale {
  font-size: 10px;
  color: var(--silver);
  margin-left: -8px;
}
.ix-heatmap-legend__scale--mid { margin-left: 0; }
.ix-heatmap-legend__scale--end { margin-left: 0; }

.ix-heatmap-legend__empty {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: var(--sp-3);
}
.ix-heatmap-legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--mist);
  border: 1px solid var(--silver);
}
.ix-heatmap-legend__swatch--empty {
  background: var(--error);
  border-color: var(--error);
}

/* 컬러 dot — 글/국 표시용 */
.ix-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.ix-dot--global   { background: var(--cluster-d-bar); }
.ix-dot--domestic { background: var(--green); }
