/* ============= Economy Modal (ecm- prefixed) ============= */

/* 공통 */
#ecm-modal {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 4000;
}
#ecm-modal.hidden { display: none; }

#ecm-modal .ecm-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.45); }

#ecm-modal .ecm-card {
  position: relative; background: #fff; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  width: min(92vw, 640px); height: 80vh;
  display: flex; flex-direction: column; overflow: hidden;
}

/* 헤더: 중앙 제목 + 우측 닫기 */
#ecm-modal .ecm-header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 50px; padding: 0 12px; background: #333d4b; color: #fff;
  position: sticky; top: 0; z-index: 1;
}
#ecm-modal .ecm-title {
  grid-column: 2; margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: .2px; text-align: center;
}
#ecm-modal .ecm-close {
  grid-column: 3; justify-self: end;
  width: 36px; height: 36px; border: 0; border-radius: 8px;
  background: transparent; color: #fff; font-size: 1.35rem; line-height: 36px; cursor: pointer;
}
#ecm-modal .ecm-close:hover { background: rgba(255,255,255,.12); }

/* 본문 */
#ecm-modal .ecm-body {
  flex: 1; min-height: 0; overflow: auto;
  padding: 14px 16px 18px; color: #222; background: #fff;
  text-align: left;             /* 상속 중앙정렬 방지 */
  box-sizing: border-box;
}

/* 섹션 타이틀 */
#ecm-modal .ecm-section-title {
  font-size: .95rem; font-weight: 700; margin: 10px 0 8px; color: #111;
}

/* ================= 지수(두 줄 레이아웃) ================= */
#ecm-modal .ecm-index-wrap { margin-bottom: 14px; }

#ecm-modal .ecm-index-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
  width: 100%;
}

#ecm-modal .ecm-index-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid #eee; border-radius: 10px; background: #fafafa;
  width: 100%; box-sizing: border-box;
}

#ecm-modal .ecm-flag {
  width: 22px; height: 14px; flex-shrink: 0;
  display: block; border-radius: 2px; object-fit: cover;
}

#ecm-modal .ecm-index-text {
  display: flex; flex-direction: column; flex: 1; min-width: 0; /* ← 반쪽만 쓰이는 문제 방지 */
}

/* 1줄차: 이름 + 현재가(우측) */
#ecm-modal .ecm-row1 {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
#ecm-modal .ecm-name {
  font-size: .92rem; color: #333;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#ecm-modal .ecm-value {
  font-size: .95rem; font-weight: 700; color: #111;
  font-variant-numeric: tabular-nums;
}

/* 2줄차: 변화량 + 변화율(작게, 우측 정렬) */
#ecm-modal .ecm-row2 {
  display: flex; justify-content: flex-end; gap: 6px;
  font-size: .8rem; color: #555; margin-top: 2px;
}
#ecm-modal .ecm-change-amt,
#ecm-modal .ecm-change-pct {
  font-variant-numeric: tabular-nums;
}
#ecm-modal .ecm-change-amt.up,   #ecm-modal .ecm-change-pct.up   { color: #e71909; }
#ecm-modal .ecm-change-amt.down, #ecm-modal .ecm-change-pct.down { color: #115bcb; }

/* ================= 경제 일정 ================= */
#ecm-modal .ecm-econ-wrap {}

#ecm-modal .ecm-event-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}

#ecm-modal .ecm-event-item {
  display: grid; grid-template-columns: 20px 46px 1fr; align-items: center; column-gap: 8px;
  padding: 8px 10px; border: 1px solid #eee; border-radius: 10px; background: #fff;
}
#ecm-modal .ecm-event-flag { width: 18px; height: 12px; border-radius: 2px; object-fit: cover; }
#ecm-modal .ecm-event-time { font-size: .82rem; color: #777; text-align: center; }
#ecm-modal .ecm-event-title { font-size: .82rem; color: #222; }
#ecm-modal .ecm-no-item { font-size: .86rem; color: #aaa; text-align: center; padding: 8px 0; border: 1px dashed #e5e5e5; border-radius: 10px; }

/* 오늘만 보이기 (제목 '오늘' 숨김 포함) — JS 수정 없이 CSS만으로 */
/*#ecm-modal .ecm-category-title { display: none !important; }*/
/*#ecm-modal .ecm-econ-block:nth-of-type(2),*/
/*#ecm-modal .ecm-econ-block:nth-of-type(3),*/
/*#ecm-modal .ecm-econ-block:nth-of-type(4) { display: none !important; }*/

/* 좁은 화면 보정 */
@media (max-width: 380px) {
  #ecm-modal .ecm-event-item { grid-template-columns: 18px 42px 1fr; }
}


/* ==== Index list: Left single-line Title (centered) + Right two-line ==== */
#ecm-modal .ecm-index-list{
  list-style:none; margin:0; padding:0;
  display:flex; flex-direction:column; gap:10px;
  width:100%;
}
#ecm-modal .ecm-index-item{
  display:grid;
  grid-template-columns: 24px minmax(0,1fr) auto; /* flag | name | right(two lines) */
  align-items:center; column-gap:10px;
  width:100%; box-sizing:border-box;
  padding:10px 12px; border:1px solid #eee; border-radius:10px; background:#fafafa;
}
#ecm-modal .ecm-flag{
  width:22px; height:14px; display:block; border-radius:2px; object-fit:cover; flex-shrink:0;
}

/* LEFT: name column (single line, vertically centered) */
#ecm-modal .ecm-name-col{
  display:flex; align-items:center; min-width:0; /* ← 전체 너비 활용 */
}
#ecm-modal .ecm-name{
  font-size:1.02rem; font-weight:700; color:#111; line-height:1.2;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* RIGHT: two-line block (value big on top, change small below) */
#ecm-modal .ecm-right{
  display:flex; flex-direction:column; align-items:flex-end; gap:2px;
}
#ecm-modal .ecm-right-value{
  font-size:1rem; font-weight:700; color:#111;
  font-variant-numeric: tabular-nums;
}
#ecm-modal .ecm-right-change{
  font-size:.8rem; color:#555; display:flex; gap:6px;
}
#ecm-modal .ecm-change-amt.up,   #ecm-modal .ecm-change-pct.up   { color:#e71909; }
#ecm-modal .ecm-change-amt.down, #ecm-modal .ecm-change-pct.down { color:#115bcb; }

/* 작은 화면 보정 */
@media (max-width:360px){
  #ecm-modal .ecm-index-item{ column-gap:8px; padding:9px 10px; }
  #ecm-modal .ecm-right-value{ font-size:.95rem; }
  #ecm-modal .ecm-right-change{ font-size:.78rem; }
}


/* ========== 지수 리스트 (작게 조정) ========== */
#ecm-modal .ecm-index-item {
  padding: 8px 10px;               /* 살짝 줄임 */
}

#ecm-modal .ecm-name {
  font-size: 0.85rem;               /* 기존 1.02rem → ↓ */
  font-weight: 600;
}

#ecm-modal .ecm-right-value {
  font-size: 0.9rem;                /* 기존 1rem → ↓ */
  font-weight: 600;
}

#ecm-modal .ecm-right-change {
  font-size: 0.75rem;               /* 기존 0.8rem → ↓ */
  color: #555;
}

/* 지수 리스트: 더 작게 & 낮게 */
#ecm-modal .ecm-index-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;                 /* 🔽 패딩 줄임 */
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fafafa;
  width: 100%;
  min-height: 34px;                 /* 🔽 카드 높이 강제 줄임 */
  box-sizing: border-box;
}

#ecm-modal .ecm-flag {
  width: 18px; height: 12px;
  flex-shrink: 0;
  border-radius: 2px;
  object-fit: cover;
}

#ecm-modal .ecm-name {
  font-size: 0.78rem;               /* 🔽 더 작게 */
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ecm-modal .ecm-right-value {
  font-size: 0.82rem;               /* 🔽 더 작게 */
  font-weight: 600;
  color: #111;
  font-variant-numeric: tabular-nums;
}

#ecm-modal .ecm-right-change {
  font-size: 0.7rem;                /* 🔽 더 작게 */
  color: #555;
  margin-top: 1px;                  /* 🔽 간격도 줄임 */
}

#ecm-modal .ecm-change-pct.up   { color: #e71909; }
#ecm-modal .ecm-change-pct.down { color: #115bcb; }

/* 지수 리스트: compact grid */
#ecm-modal .ecm-index-item {
  display: grid;
  grid-template-columns: 20px minmax(0,1fr) auto;  /* flag | name | 오른쪽 블럭 */
  align-items: center;
  column-gap: 8px;
  padding: 6px 8px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fafafa;
  min-height: 36px;
  box-sizing: border-box;
}

#ecm-modal .ecm-flag {
  width: 18px; height: 12px;
  border-radius: 2px; object-fit: cover;
}

/* 왼쪽: 지수명만 중앙정렬 */
#ecm-modal .ecm-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: center;  /* 세로 중앙 */
}

/* 오른쪽: 두 줄 블럭 */
#ecm-modal .ecm-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

#ecm-modal .ecm-right-value {
  font-size: 0.82rem;
  font-weight: 600;
  color: #111;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

#ecm-modal .ecm-right-change {
  font-size: 0.7rem;
  color: #555;
  line-height: 1.1;
}

#ecm-modal .ecm-change-pct.up   { color: #e71909; }
#ecm-modal .ecm-change-pct.down { color: #115bcb; }

