/* ─── Card ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  height: 100%;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title, h3.card-title { font-size: 15px; font-weight: 700; }
.card-label, h3.card-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }

/* ─── Dark card (M6 진단) ──────────────────────────────── */
.card-dark {
  background: #0f172a; border: 1px solid #1e293b;
  border-radius: 12px; padding: 24px; color: #e2e8f0;
}
.dark-insight {
  background: #1e293b; border: 1px solid #334155;
  padding: 14px 16px; border-radius: 8px;
}
.dark-insight h4 { font-size: 14px; font-weight: 700; color: #e2e8f0; margin-bottom: 5px; }
.dark-insight p  { font-size: 13px; color: #94a3b8; line-height: 1.6; }
.dark-fact-list { list-style: none; }
.dark-fact-list li {
  font-size: 13px; color: #94a3b8; line-height: 1.7;
  padding: 2px 0 2px 10px; position: relative;
}
.dark-fact-list li::before { content: "·"; position: absolute; left: 0; color: #475569; }
.dark-fact-list li strong { color: #e2e8f0; }

/* ─── Insight box ──────────────────────────────────────── */
.insight-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 18px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.insight-box h4 { font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.insight-box p  { font-size: 13px; color: var(--text-muted); line-height: 1.7; }

/* ─── Data table ────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 9px 10px;
  color: var(--text-muted); font-weight: 600;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.current td { background: #f0f9ff; font-weight: 600; }
.data-table tr:hover td { background: var(--bg); }
.data-table td a { color: var(--primary); text-decoration: none; font-weight: inherit; cursor: pointer; }
.data-table td a:hover { text-decoration: underline; }

/* ─── Bar row ───────────────────────────────────────────── */
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.bar-label { width: 38px; color: var(--text-muted); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--bg); border-radius: 9999px; height: 8px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill  { height: 100%; border-radius: 9999px; }
.bar-pct   { width: 34px; text-align: right; font-weight: 600; font-size: 13px; }

/* ─── Deduct list (M8) ──────────────────────────────────── */
.deduct-list { list-style: none; }
.deduct-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.deduct-item:last-child { border-bottom: none; }
.deduct-name { color: var(--text-muted); }
.deduct-val  { font-weight: 700; }

/* ─── Feed (M11 타임라인) ───────────────────────────────── */
.feed-list { display: flex; flex-direction: column; gap: 12px; }
.feed-item { display: flex; gap: 10px; }
.feed-date {
  font-size: 12px; color: var(--text-faint); font-weight: 700;
  width: 36px; padding-top: 2px; flex-shrink: 0;
}
.feed-body {
  flex: 1; background: var(--bg);
  padding: 11px 13px; border-radius: 8px; border: 1px solid var(--border);
}
.feed-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.feed-apt { font-weight: 700; font-size: 13px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-apt-link { color: var(--primary); text-decoration: none; cursor: pointer; }
.feed-apt-link:hover { text-decoration: underline; }
.feed-tag {
  font-size: 12px; padding: 2px 7px; border-radius: 4px;
  font-weight: 600; background: var(--border); color: #475569;
}
.feed-tag.new-tag      { background: var(--primary-light); color: #1e40af; }
.feed-tag.renew-tag    { background: var(--warning-light); color: #92400e; }
.feed-tag.sell-tag     { background: var(--success-light); color: #065f46; }
.feed-tag.rebuild-tag  { background: var(--warning-light); color: #92400e; }
.feed-tag.record-tag   { background: #fee2e2; color: #991b1b; }
.feed-tag.jeonse-tag   { background: #eff6ff; color: #1d4ed8; }
.feed-tag.banjeonse-tag{ background: #faf5ff; color: #7c3aed; }
.feed-tag.wolse-tag    { background: #fff7ed; color: #c2410c; }
.feed-tag.cancel-tag   { background: #f1f5f9; color: #64748b; text-decoration: line-through; }
.feed-tag.danger-tag   { background: var(--danger-light); color: #991b1b; }
.feed-tag.convert-tag  { background: #fef3c7; color: #92400e; }
.feed-price { font-size: 15px; font-weight: 800; margin-bottom: 2px; }
.feed-desc  { font-size: 12px; color: var(--text-muted); }
.feed-record { font-size: 12px; color: #991b1b; font-weight: 600; margin-top: 2px; }

/* ─── Horizontal bar chart (M12 랭킹) ──────────────────── */
.hbar-list { list-style: none; }
.hbar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.hbar-item:last-child { border-bottom: none; }
.hbar-rank { width: 18px; font-size: 12px; font-weight: 700; color: var(--text-faint); text-align: center; flex-shrink: 0; }
.hbar-name { width: 68px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.hbar-name a { color: var(--primary); text-decoration: none; cursor: pointer; }
.hbar-name a:hover { text-decoration: underline; }
.hbar-track { flex: 1; background: var(--bg); border-radius: 9999px; height: 8px; overflow: hidden; border: 1px solid var(--border); }
.hbar-fill  { height: 100%; border-radius: 9999px; background: var(--primary); }
.hbar-pct   { width: 34px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: right; flex-shrink: 0; }

/* ─── Gauge (M8 SVG) ────────────────────────────────────── */
.gauge-wrapper { display: flex; justify-content: center; padding: 12px; border-radius: 8px; margin: 8px 0; }
.gauge-svg { width: 120px; height: 120px; }
.gauge-text { font-size: 18px; font-weight: 700; fill: #1f2937; }

/* ─── Divider ───────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ─── 하위 지역 탐색 섹션 ─────────────────────────────── */
.sub-region-section {
  margin-bottom: 36px;
}
.sub-region-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 14px;
}
.sub-region-label {
  font-size: 12px; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px;
}
.sub-region-title  { font-size: 15px; font-weight: 700; }
.sub-region-count  { font-size: 13px; font-weight: 400; color: var(--text-muted); margin-left: 4px; }
.sub-region-sort {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px;
  background: var(--surface); cursor: pointer;
}

/* ─── 테이블 ─────────────────────────────────────────── */
.sub-region-table-wrap { overflow-x: auto; }
.sub-region-table      { width: 100%; border-collapse: collapse; font-size: 13px; }
.sub-region-table th {
  text-align: left; padding: 8px 10px; color: var(--text-muted); font-weight: 600;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
.sub-region-table td {
  padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.sub-region-table tr:last-child td { border-bottom: none; }
.sub-region-table tr:hover td      { background: var(--bg); }
.sub-region-table td a             { color: var(--primary); text-decoration: none; font-weight: 700; cursor: pointer; }
.sub-region-table td a:hover       { text-decoration: underline; }

/* 컬럼 너비 */
.col-rank   { width: 28px; color: var(--text-faint); font-weight: 700; }
.col-name   { min-width: 80px; }
.col-price  { min-width: 130px; }
.col-jeonse { min-width: 70px; }
.col-volume { min-width: 110px; }
.col-score  { min-width: 70px; }
.col-link   { width: 50px; text-align: right; }

/* ─── 매매가 변동률 ──────────────────────────────────── */
.price-change { font-size: 12px; margin-left: 4px; font-weight: 500; }

/* ─── 전세가율 색상 점 ───────────────────────────────── */
.jeonse-dot    { font-size: 9px; margin-right: 3px; }
.dot-faint     { color: var(--text-faint); }
.dot-success   { color: var(--success); }
.dot-warning   { color: var(--warning); }
.dot-danger    { color: var(--danger); }
.dot-critical  { color: #7f1d1d; }

/* ─── 거래량 미니 막대 ───────────────────────────────── */
.mini-bar-wrap  { display: flex; align-items: center; gap: 6px; }
.mini-bar-track {
  flex: 1; min-width: 50px; background: var(--bg);
  border-radius: 9999px; height: 6px; overflow: hidden; border: 1px solid var(--border);
}
.mini-bar-fill  { height: 100%; border-radius: 9999px; background: var(--primary); }
.mini-bar-count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ─── 펼치기 버튼 ────────────────────────────────────── */
.sub-region-toggle {
  display: block; width: 100%; padding: 10px; margin-top: 4px;
  background: var(--bg); border: 1px dashed var(--border); border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; text-align: center; transition: all 0.15s;
}
.sub-region-toggle:hover {
  border-color: var(--primary); color: var(--primary); background: var(--primary-light);
}

/* ─── 폴백 칩 그리드 ─────────────────────────────────── */
.sub-region-no-data { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.sub-chip-grid      { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-chip {
  padding: 5px 12px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.sub-chip:hover  { border-color: var(--primary); color: var(--primary); }
.sub-link        { font-size: 12px; color: var(--primary); white-space: nowrap; cursor: pointer; }

/* ─── 전세가율 pill (하위 지역 탐색) ─────────────────────── */
.pill      { display: inline-block; padding: 2px 7px; border-radius: 9999px; font-size: 12px; font-weight: 600; }
.pill-down { background: var(--success-light); color: #065f46; }
.pill-mid  { background: var(--warning-light); color: #92400e; }
.pill-up   { background: var(--danger-light);  color: #991b1b; }

/* ─── 하위 지역 테이블 반응형 ───────────────────── */
@media (max-width: 768px) {
  .sub-region-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .sub-region-sort { align-self: flex-end; }
  .sub-region-section.card { padding: 14px 10px; }
  .sub-region-table { font-size: 11px; }
  .sub-region-table th { font-size: 11px; padding: 6px 3px; }
  .sub-region-table td { padding: 8px 3px; }
  .sub-region-table .col-name { min-width: 40px; }
  .sub-region-table .col-price { min-width: 60px; }
  .sub-region-table .col-jeonse,
  .sub-region-table .col-wolse,
  .sub-region-table .col-pm25 { min-width: auto; white-space: nowrap; }
  .sub-region-table .td-toggle { width: 24px; padding: 6px 1px; }
  .sub-region-table .row-toggle { font-size: 11px; padding: 1px 4px; }
  .sub-region-table .price-change { display: block; margin-left: 0; font-size: 10px; }

  /* data-table (이웃 동네 비교 등) */
  .data-table { font-size: 12px; }
  .data-table th { padding: 7px 6px; }
  .data-table td { padding: 9px 6px; }
}
