/* 상세 화면 전용 스타일. style.css 를 덮지 않고 얹기만 한다.
 *
 * 규칙은 style.css 와 같다. 색·간격·반경은 커스텀 프로퍼티만 쓰고, 클래스는
 * `블록-요소` 케밥 표기, 상태는 `is-*` 로만 붙인다. 값을 직접 박지 않으므로
 * 다크 모드가 따라온다.
 */

/* --- 헤더 ----------------------------------------------------------------- */

.detail-meta { margin: 0 0 10px; font-size: 11px; color: var(--muted); }

/* 기간 선택은 거래유형보다 한 단계 작다. 주(主)가 아니다. */
.segment-sm { margin-bottom: 6px; }
.segment-sm .segment-item { padding: 6px 0; font-size: 12px; }
.segment-sm .segment-item[aria-current="true"] {
  background: var(--accent-weak);
  color: var(--accent);
}

/* --- 권역 내 순위 ---------------------------------------------------------- */

.rankbox {
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-weak);
}

.rankbox-head { margin: 0; font-size: 10.5px; color: var(--muted); }

.rankbox-rank { margin: 3px 0 0; font-size: 13px; }
.rankbox-rank b { font-size: 17px; font-weight: 750; }
.rankbox-rank span { color: var(--muted); font-size: 11px; }

.peers { margin: 7px 0 0; padding: 0; list-style: none; }

.peer {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 3px 0;
  font-size: 12px;
}

.peer + .peer { border-top: 1px solid var(--line); }

.peer-rank {
  width: 14px;
  flex: none;
  color: var(--muted);
  font-size: 10.5px;
  text-align: right;
}

.peer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: none;
}

.peer-price { font-variant-numeric: tabular-nums; }

/* 순위 변동. 상승은 붉은색, 하락은 푸른색 — 가격 변동과 같은 방향의 색을 쓴다. */
.rank-delta,
.peer-delta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-delta.is-up,
.peer-delta.is-up { color: var(--up); }
.rank-delta.is-down,
.peer-delta.is-down { color: var(--dn); }
.rank-delta { margin-left: 6px; }
.peer-delta { margin-left: 4px; }

.peer.is-self { font-weight: 700; }
.peer.is-self .peer-name { color: var(--fg-strong); }

/* --- KPI ------------------------------------------------------------------ */

.kpi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 8px;
}

.kpi-card {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.kpi-label { display: block; font-size: 10px; color: var(--muted); }

.kpi-value {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-change { display: block; margin-top: 2px; font-size: 10.5px; }
.kpi-caption { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
.kpi-caption.is-stale { color: var(--warn); }

.kpi .is-up { color: var(--up); }
.kpi .is-down { color: var(--dn); }
.kpi .is-flat { color: var(--muted); }

.stalenote {
  margin: 0 0 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--warn-weak);
  color: var(--warn);
  font-size: 10.5px;
}

/* --- 차트 ------------------------------------------------------------------ */

.chart-svg { display: block; width: 100%; height: auto; }

.chart-axis { stroke: currentColor; stroke-opacity: 0.25; }
.chart-grid { stroke: currentColor; stroke-opacity: 0.1; stroke-dasharray: 3 3; }

.chart-glabel,
.chart-axislabel,
.chart-striplabel { fill: var(--muted); font-size: 7px; }

.chart-summary { fill: var(--muted); font-size: 7.5px; }
.chart-empty { fill: var(--muted); font-size: 11px; }

/* 월 중앙값이 주선(主線), 이동중앙값은 뒤에 깔리는 굵고 흐린 띠다. */
.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-dot { fill: var(--accent); }

/* 거래가 없는 구간을 잇는 보조선. 실선보다 얇고 흐린 점선이라 한눈에
   '관측값이 아니다'가 읽힌다. 값을 채운 게 아니라 양 끝을 이었을 뿐이다. */
.chart-bridge {
  stroke: var(--accent);
  stroke-opacity: 0.45;
  stroke-width: 1.2;
  stroke-dasharray: 3 3;
  stroke-linecap: round;
}

.chart-ma {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: 0.22;
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-ma-dot { fill: var(--accent); fill-opacity: 0.22; }

.chart-peakline { stroke: var(--up); stroke-opacity: 0.5; stroke-dasharray: 4 3; }
.chart-peaklabel { fill: var(--up); font-size: 7px; }
.chart-peak { fill: var(--up); }

/* 사용자가 그래프에서 바로 읽어야 하는 값이다. 흐리게 두지 않는다. */
.chart-count {
  fill: var(--fg);
  font-size: 8px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-count.is-tight { font-size: 6.8px; }
.chart-count.is-zero { fill: var(--muted); fill-opacity: 0.55; font-weight: 400; }

.chart-bar { fill: var(--accent); fill-opacity: 0.28; }

.chart-hit { fill: transparent; }

.chart-readout {
  margin: 2px 0 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 3px 0 0;
  font-size: 9.5px;
  color: var(--muted);
}

.legend-line::before,
.legend-bridge::before,
.legend-ma::before,
.legend-peak::before {
  display: inline-block;
  margin-right: 3px;
  vertical-align: 1px;
  content: "";
}

.legend-line::before { width: 9px; border-top: 2px solid var(--accent); }
.legend-bridge::before {
  width: 9px;
  border-top: 1.5px dashed var(--accent);
  opacity: 0.5;
}
.legend-ma::before {
  width: 9px;
  border-top: 5px solid var(--accent);
  opacity: 0.25;
}
.legend-peak::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--up);
}

/* --- 실거래 목록 ----------------------------------------------------------- */

.sect { margin: 14px 0 4px; font-size: 11px; font-weight: 650; color: var(--muted); }

.reclist { display: block; }

.rec {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.rec-date { width: 68px; flex: none; color: var(--muted); }
.rec-spec { color: var(--muted); }

.rec-amount {
  margin-left: auto;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 취소 거래는 남기되 살아 있는 가격처럼 보이면 안 된다. */
.rec.is-canceled { color: var(--muted); }
.rec.is-canceled .rec-amount { text-decoration: line-through; opacity: 0.6; font-weight: 400; }

.badge-canceled { background: var(--bg-elev); color: var(--muted); }

/* --- 비교 화면 ------------------------------------------------------------ */

/* 선 여섯 개까지. 색상만으로 구분하면 색각 이상에서 읽히지 않으므로
   대시 패턴을 함께 바꾼다. */
.cmp-line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.cmp-bridge { stroke-width: 1.1; stroke-opacity: 0.4; stroke-dasharray: 3 3; }
.cmp-dot { stroke: none; }

.cmp-0 { stroke: #d64545; fill: #d64545; }
.cmp-1 { stroke: #2f6fd0; fill: #2f6fd0; }
.cmp-2 { stroke: #1f9d76; fill: #1f9d76; stroke-dasharray: 7 3; }
.cmp-3 { stroke: #b06fc4; fill: #b06fc4; stroke-dasharray: 2 2.5; }
.cmp-4 { stroke: #c98a1f; fill: #c98a1f; stroke-dasharray: 9 2 2 2; }
.cmp-5 { stroke: #4b5563; fill: #4b5563; stroke-dasharray: 4 2 1 2; }
.cmp-line.cmp-0, .cmp-line.cmp-1 { stroke-dasharray: none; }

.chart-grid.is-base { stroke-opacity: 0.55; }

.cmpchart { display: block; margin-top: 4px; }

.cmplegend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 11px;
  color: var(--muted);
}

.cmplegend-item b { color: var(--fg-strong); font-variant-numeric: tabular-nums; }

.cmp-swatch {
  display: inline-block;
  width: 10px;
  height: 3px;
  margin-right: 4px;
  vertical-align: 2px;
  background: currentColor;
}
.cmp-swatch.cmp-0 { background: #d64545; }
.cmp-swatch.cmp-1 { background: #2f6fd0; }
.cmp-swatch.cmp-2 { background: #1f9d76; }
.cmp-swatch.cmp-3 { background: #b06fc4; }
.cmp-swatch.cmp-4 { background: #c98a1f; }
.cmp-swatch.cmp-5 { background: #4b5563; }

.comparenote { margin: 6px 0 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.comparenote b { color: var(--fg-strong); }

/* 단지가 늘면 가로로 넘친다. 페이지가 아니라 표만 스크롤한다. */
.cmptable-wrap { overflow-x: auto; margin-top: 4px; }

.cmptable { border-collapse: collapse; width: 100%; font-size: 12px; }
.cmptable th, .cmptable td {
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.cmptable thead th { font-size: 11px; color: var(--muted); text-align: right; }
.cmptable thead th a { color: var(--fg-strong); text-decoration: none; }
.cmptable th[scope="row"] { text-align: left; color: var(--muted); font-weight: 500; }
.cmptable td { font-variant-numeric: tabular-nums; }
.cmptable td.is-best { font-weight: 750; color: var(--fg-strong); }
.cmptable td.is-up { color: var(--up); }
.cmptable td.is-down { color: var(--dn); }


/* 거래가 너무 적어 선이 안 그려질 때. 빈 상자만 보여주면 고장으로 읽힌다. */
.thinnote {
  margin: 4px 0 0;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--warn-weak);
  color: var(--warn);
  font-size: 10.5px;
  line-height: 1.5;
}
.thinnote b { font-weight: 650; }
