/* ─── 타입 탭 ─────────────────────────────────────── */
.type-tabs { display: flex; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 20px; width: fit-content; }
.type-tab { padding: 8px 20px; border-radius: 7px; font-size: 14px; font-weight: 700; cursor: pointer; border: none; background: transparent; color: var(--text-muted); transition: all 0.15s; text-decoration: none; }
.type-tab.active { background: var(--primary); color: #fff; }
.type-tab:not(.active):hover { background: var(--bg); color: var(--text-main); }

/* ─── KPI ─────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.kpi-card.highlight { border-left: 4px solid var(--primary); }
.kpi-label { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--text-main); line-height: 1.1; }
.kpi-sub { font-size: 14px; color: var(--text-faint); margin-top: 4px; }
.kpi-section { margin-bottom: 24px; }

/* ─── 갱신 인상 구간 바 ───────────────────────────── */
.renew-band-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-top: 12px; }
.renew-band-title { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.renew-band-bar { display: flex; height: 36px; border-radius: 8px; overflow: hidden; gap: 2px; }
.renew-band-seg { display: flex; align-items: center; justify-content: center; transition: flex 0.3s; min-width: 0; overflow: hidden; }
.seg-freeze { background: #cbd5e1; }
.seg-low    { background: #fde047; }
.seg-mid    { background: #fdba74; }
.seg-high   { background: #f9a8d4; }
.seg-down   { background: #86efac; }
.renew-band-legend { display: flex; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.renew-band-legend span { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.renew-band-legend .legend-pct { font-weight: 700; color: var(--text-main); }
.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

/* ─── 인사이트 그리드 ─────────────────────────────── */
.insight-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 768px) { .insight-grid { grid-template-columns: 1fr; } }
.insight-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.insight-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.insight-card-title { font-size: 14px; font-weight: 700; color: var(--text-main); margin-bottom: 14px; }
.insight-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0 14px; }
.card-pagination { display: flex; align-items: center; gap: 6px; }
.pagination-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-muted); font-size: 14px; transition: all 0.2s; padding: 0; }
.pagination-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.pagination-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination-info { font-size: 12px; font-weight: 700; color: var(--text-main); min-width: 40px; text-align: center; }

/* 추이 차트 */
.trend-chart { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-bottom: 4px; }
.trend-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; justify-content: flex-end; }
.trend-bar-num { font-size: 12px; font-weight: 700; color: var(--text-muted); line-height: 1; }
.trend-bar-group:last-child .trend-bar-num { color: var(--primary); }
.trend-bar { width: 100%; border-radius: 3px 3px 0 0; background: #93c5fd; min-height: 4px; }
.trend-bar-group:last-child .trend-bar { background: var(--primary); }
.trend-label { font-size: 13px; color: var(--text-faint); margin-top: 2px; }
.trend-summary { font-size: 14px; color: var(--text-muted); padding-top: 8px; }

/* 면적대 */
.area-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.area-label { width: 110px; color: var(--text-muted); font-weight: 600; flex-shrink: 0; white-space: nowrap; font-size: 13px; }
.area-meta { flex-shrink: 0; text-align: right; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.area-meta strong { color: var(--text-main); font-weight: 700; }
.area-stack-wrap { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.area-stack-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; margin-bottom: 8px; }
.area-stack-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--text-muted); }
.area-stack-legend span { display: flex; align-items: center; gap: 4px; }
.area-stack-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* 동별 현황 */
.dong-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
.dong-name a { color: var(--primary); text-decoration: none; font-weight: 700; }
.dong-name a:hover { text-decoration: underline; }
.dong-bottom { display: flex; align-items: center; gap: 8px; }
.dong-stack-track { flex: 1; height: 10px; border-radius: 9999px; overflow: hidden; display: flex; background: var(--bg); border: 1px solid var(--border); }
.dong-stack-new { background: #60a5fa; height: 100%; }
.dong-stack-renew { background: #818cf8; height: 100%; }
.dong-meta { flex-shrink: 0; text-align: right; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.dong-meta strong { color: var(--text-main); font-weight: 700; }
.legend { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-faint); display: flex; gap: 12px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; vertical-align: middle; margin-right: 3px; }

/* ─── 타입 탭 반응형 ──────────────────────────────── */
@media (max-width: 480px) {
  .type-tabs { width: 100%; }
  .type-tab { padding: 8px 12px; font-size: 13px; flex: 1; text-align: center; }
}

/* ─── 필터 바 ─────────────────────────────────────── */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; }
.filter-select { font-size: 13px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; background: var(--surface); cursor: pointer; }
.filter-select:focus { outline: none; border-color: var(--primary); }
.filter-divider { width: 1px; height: 20px; background: var(--border); }
.apt-filter-active { display: flex; align-items: center; gap: 8px; padding: 8px 14px; margin-bottom: 12px; background: var(--primary-light); border: 1px solid var(--primary); border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--primary); }
.apt-filter-clear { color: var(--primary); font-size: 13px; font-weight: 600; text-decoration: none; margin-left: auto; }
.apt-filter-clear:hover { text-decoration: underline; }

/* ─── 테이블 ───────────────────────────────────────── */
.trade-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.trade-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.trade-table th { text-align: left; padding: 12px; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
.trade-table th.r { text-align: right; }
.trade-table th.c { text-align: center; }
.trade-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.trade-table tr:last-child td { border-bottom: none; }
.trade-table tr:hover td { background: var(--bg); }
.trade-table td.r { text-align: right; }
.trade-table td.c { text-align: center; }
.trade-table td.seq { color: var(--text-faint); font-weight: 700; text-align: center; width: 32px; }
.trade-table td.date { color: var(--text-faint); font-weight: 700; white-space: nowrap; text-align: center; }
.trade-table td.deposit { text-align: right; font-weight: 800; font-size: 15px; white-space: nowrap; }
.trade-table td.monthly { text-align: right; font-weight: 700; font-size: 14px; white-space: nowrap; color: #7c3aed; }
.trade-table td.change { text-align: right; font-size: 14px; font-weight: 600; white-space: nowrap; }
.trade-table td.expire { text-align: center; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.trade-table td.age { text-align: center; font-size: 13px; color: var(--text-muted); }
.apt-cell { display: flex; align-items: center; gap: 4px; }
.apt-link { color: var(--primary); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.apt-link:hover { text-decoration: underline; }
.change-up   { color: #dc2626; }
.change-down { color: #2563eb; }
.change-flat { color: var(--text-faint); }
.expire-near { color: var(--danger); font-weight: 700; }

/* ─── 뱃지 ────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge-new   { background: #DBEAFE; color: #1d4ed8; }
.badge-renew { background: #E0E7FF; color: #4338ca; }
.badge-rr    { background: #fef9c3; color: #854d0e; }
.apt-count-badge { font-size: 11px; font-weight: 600; color: var(--primary); background: var(--primary-light); border-radius: 4px; padding: 1px 5px; white-space: nowrap; flex-shrink: 0; }

/* ─── 더보기 ───────────────────────────────────────── */
.load-more-wrap { margin-top: 24px; text-align: center; }
.load-more-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; max-width: 480px; padding: 14px 24px; border-radius: 10px; border: 1px dashed var(--border); background: var(--surface); color: var(--text-muted); font-size: 14px; font-weight: 700; cursor: pointer; }
.load-more-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.load-more-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── 하단 네비게이션 ─────────────────────────────── */
.bottom-nav { margin-top: 36px; display: flex; flex-direction: column; gap: 16px; }
.back-link { font-size: 14px; font-weight: 600; color: var(--primary); text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.month-nav { display: flex; justify-content: space-between; align-items: center; }
.month-link { font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none; padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.month-link:hover { border-color: var(--primary); color: var(--primary); }
.month-current { font-size: 14px; font-weight: 700; }
.month-select  { font-size: 14px; font-weight: 700; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }

/* ─── 임대차 테이블 → 카드 전환 (모바일) ─────────── */
@media (max-width: 768px) {
  .trade-table-wrap { background: none; border: none; border-radius: 0; overflow: visible; }
  .trade-table, .trade-table thead, .trade-table tbody, .trade-table th, .trade-table tr { display: block; }
  .trade-table thead { display: none; }
  .trade-table tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    margin-bottom: 12px; padding: 16px; display: flex; flex-wrap: wrap; gap: 4px 0;
    position: relative;
  }
  .trade-table tr:hover td { background: transparent; }
  .trade-table td { border: none; padding: 0; }

  .trade-table td.seq { display: none; }
  .trade-table td.apt { order: 1; flex: 1; max-width: none; font-size: 14px; overflow: hidden; }
  .apt-link { max-width: none; }
  .trade-table td.dong { order: 2; margin-left: 6px; font-size: 12px; color: var(--text-muted); }
  .trade-table td.dong::before { content: "· "; }
  .trade-table td.c:not(.floor) { order: 3; margin-left: auto; }
  .trade-table td.deposit { order: 4; text-align: left; font-size: 18px; margin-top: 8px; }
  .trade-table td.monthly { order: 5; text-align: left; font-size: 15px; margin-top: 10px; margin-left: 8px; }
  .trade-table td.change { order: 6; width: 100%; text-align: left; font-size: 13px; margin-top: 2px; }
  .trade-table td.area { order: 7; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; }
  .trade-table td.floor { order: 8; text-align: left; font-size: 12px; }
  .trade-table td.floor::before { content: "· "; color: var(--text-faint); }
  .trade-table td.age { order: 9; text-align: left; font-size: 12px; }
  .trade-table td.age::before { content: "· "; color: var(--text-faint); }
  .trade-table td.expire { order: 10; margin-left: auto; font-size: 12px; }
  .trade-table td.date { order: 11; margin-left: 12px; font-size: 12px; }
}


