/* ── 페이지 헤더 ── */
.rank-hd { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); padding: 26px 20px 22px; border-bottom: 1px solid #bfdbfe; }
.rank-hd-inner { max-width: 1440px; margin: 0 auto; }
.rank-bc { font-size: 12px; color: #64748b; margin-bottom: 8px; }
.rank-bc a { color: #3b82f6; text-decoration: none; }
.rank-bc a:hover { text-decoration: underline; }
.rank-title { font-size: 22px; font-weight: 800; color: #1e40af; letter-spacing: -.5px; margin-bottom: 4px; }
.rank-desc  { font-size: 13px; color: #475569; }

/* ── 탭 ── */
.rank-tabs { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.rank-tab { padding: 7px 14px; font-size: 12px; font-weight: 700; text-decoration: none; background: #fff; border: 1px solid #e2e8f0; border-radius: 999px; color: #475569; }
.rank-tab.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.rank-tab:hover:not(.active) { background: #f1f5f9; color: #0f172a; }

/* ── KPI 스트립 (sticky) ── */
.rank-strip {
    background: linear-gradient(135deg, #0f2744 0%, #1e3a8a 100%);
    padding: 12px 20px;
    position: sticky; top: 64px; z-index: 200;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.rank-si-wrap {
    max-width: 1440px; margin: 0 auto;
    display: flex; align-items: stretch; gap: 10px;
}
.rank-si {
    display: flex; flex-direction: column; justify-content: center;
    padding: 7px 14px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    transition: background .15s, border-color .15s;
    min-width: 0;
}
.rank-si:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.14); }
.rank-si-primary {
    background: rgba(96,165,250,.14);
    border-color: rgba(96,165,250,.32);
}
.rank-si-primary:hover { background: rgba(96,165,250,.2); border-color: rgba(96,165,250,.45); }
.rank-si-lbl {
    font-size: 10px; color: rgba(255,255,255,.6); font-weight: 700;
    letter-spacing: .4px; margin-bottom: 3px;
    white-space: nowrap;
}
.rank-si-val {
    font-size: 15px; font-weight: 800; color: #fff;
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-si-val .mc-num { color: #93c5fd; font-size: 17px; }
.rank-si-val .mc-sep { color: rgba(255,255,255,.3); font-weight: 600; }
.rank-si-val .mc-tot { color: rgba(255,255,255,.55); font-size: 13px; font-weight: 700; }
.rank-si-badge {
    display: inline-flex; align-items: center;
    font-size: 11px; font-weight: 700;
    padding: 2px 8px; border-radius: 999px;
    background: rgba(239,68,68,.22); color: #fca5a5;
}
.sb-blue   { background: rgba(96,165,250,.28); color: #bfdbfe; }
.sb-red    { background: rgba(239,68,68,.22);  color: #fecaca; }
.rank-mn-nav { margin-left: auto; display: flex; align-items: center; }
.rank-mn-select {
    font-size: 13px; font-weight: 700; color: #fff;
    background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
    border-radius: 8px; padding: 7px 12px; cursor: pointer;
    transition: background .15s;
}
.rank-mn-select:hover { background: rgba(255,255,255,.18); }
.rank-mn-select option { background: #1e293b; color: #f1f5f9; font-weight: 600; }

/* ── 메인 레이아웃 ── */
.rank-body { max-width: 1440px; margin: 0 auto; padding: 18px 16px 48px; display: grid; grid-template-columns: 260px 1fr; gap: 12px; align-items: start; }

/* ── 사이드바 ── */
.rank-sb {
    position: sticky;
    top: 149px;
    max-height: calc(100vh - 149px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    scroll-behavior: smooth;
}
.rank-sb::-webkit-scrollbar { width: 4px; }
.rank-sb::-webkit-scrollbar-track { background: #f1f5f9; }
.rank-sb::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.rank-sb-hd { padding: 12px 14px; background: #1e293b; color: #fff; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: space-between; border-radius: 9px 9px 0 0; }
.rank-sb-rst { font-size: 11px; color: #94a3b8; background: none; border: none; cursor: pointer; font-weight: 600; }
.rank-sb-rst:hover { color: #fff; }
.rank-sb-mc { padding: 8px 14px; background: #f0fdf4; border-bottom: 1px solid #bbf7d0; font-size: 12px; color: #166534; font-weight: 700; text-align: center; }

/* ── 아코디언 ── */
.rank-acc-hd { display: flex; align-items: center; padding: 10px 14px; cursor: pointer; gap: 6px; background: #fafafa; border-bottom: 1px solid #f1f5f9; user-select: none; }
/* 사이드바 내부 tip-icon은 CSS pseudo 툴팁 비활성화 — JS로 body에 따로 띄움 */
.rank-sb .tip-icon::after, .rank-sb .tip-icon::before { display: none; }
.rank-tooltip-popup {
    position: absolute;
    background: #1e293b; color: #f1f5f9;
    font-size: 11px; font-weight: 400; line-height: 1.5;
    padding: 8px 12px; border-radius: 6px;
    width: 280px; max-width: calc(100vw - 16px);
    white-space: normal; text-align: left;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    z-index: 9999;
}
.rank-acc-hd:hover { background: #f0f9ff; }
.rank-acc-lbl { font-size: 12px; font-weight: 700; color: #334155; flex: 1; }
.rank-acc-val { font-size: 11px; font-weight: 800; color: #1d4ed8; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-acc-arr { font-size: 10px; color: #94a3b8; flex-shrink: 0; transition: transform .18s; }
.rank-acc-arr.open { transform: rotate(180deg); }
.rank-acc-body { padding: 11px 14px 13px; border-bottom: 1px solid #f1f5f9; }

/* 고급 필터 */
.rank-acc-hd.adv { background: #fffbeb; }
.rank-acc-hd.adv:hover { background: #fef3c7; }
.rank-acc-hd.adv .rank-acc-lbl { color: #92400e; }
.rank-acc-hd.adv .rank-acc-val { color: #d97706; }
.rank-acc-body.adv { background: #fffbeb; border-bottom-color: #fde68a; }
.rank-adv-lbl { font-size: 11px; font-weight: 700; color: #92400e; margin-bottom: 5px; display: flex; justify-content: space-between; }
.rank-adv-val { color: #d97706; }

/* ── 공통 슬라이더 ── */
.rank-sl-track { position: relative; height: 5px; background: #e2e8f0; border-radius: 3px; margin: 6px 0 4px; }
.rank-sl-fill  { position: absolute; top: 0; height: 100%; background: linear-gradient(90deg, #3b82f6, #1d4ed8); border-radius: 3px; }
.rank-sl-thumb { position: absolute; top: 50%; transform: translate(-50%,-50%); width: 16px; height: 16px; background: #fff; border: 2.5px solid #1d4ed8; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,.12); cursor: grab; z-index: 2; touch-action: none; transition: box-shadow .1s; }
.rank-sl-thumb:hover, .rank-sl-thumb.drag { box-shadow: 0 0 0 4px rgba(59,130,246,.2); cursor: grabbing; }
.rank-sl-ends  { display: flex; justify-content: space-between; font-size: 10px; color: #94a3b8; }

/* 가격 모드 토글 */
.rank-pm-row { display: flex; gap: 4px; margin-bottom: 8px; }
.rank-pm-btn { flex: 1; text-align: center; font-size: 11px; font-weight: 700; padding: 4px; border-radius: 4px; border: 1px solid #cbd5e1; background: #fff; color: #64748b; cursor: pointer; }
.rank-pm-btn.on { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

/* PM 범례 */
.rank-pm-legend { display: flex; gap: 3px; margin-top: 6px; }
.rank-pm-legend span { flex: 1; text-align: center; padding: 2px 3px; border-radius: 3px; font-size: 10px; font-weight: 700; }

/* 시도 드롭다운 */
.rank-sb-sel { width: 100%; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 5px; font-size: 12px; font-weight: 600; color: #334155; background: #fff; }

/* 체크 그룹 */
.rank-chk-grp { display: flex; gap: 4px; }
.rank-chk-item { flex: 1; text-align: center; padding: 5px 3px; border: 1.5px solid #cbd5e1; border-radius: 5px; font-size: 11px; font-weight: 700; color: #64748b; cursor: pointer; user-select: none; }
.rank-chk-item:hover { border-color: #93c5fd; }
.rank-chk-item.on { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }

/* 토글 그룹 */
.rank-tog-grp { display: flex; border: 1px solid #e2e8f0; border-radius: 5px; overflow: hidden; }
.rank-tog-btn { flex: 1; padding: 5px 3px; font-size: 11px; font-weight: 700; border: none; border-right: 1px solid #e2e8f0; background: #fff; color: #64748b; cursor: pointer; }
.rank-tog-btn:last-child { border-right: none; }
.rank-tog-btn:hover { background: #f8fafc; }
.rank-tog-btn.on { background: #1d4ed8; color: #fff; }

/* ── 우측 영역 ── */
.rank-main-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: calc(100vh - 110px); }

/* ── 랭킹 테이블 ── */
.rank-tbl-wrap { overflow: clip; }
table.rank-dt { width: 100%; min-width: 920px; border-collapse: collapse; font-size: 13px; }
.rank-dt th { padding: 9px 5px; background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 700; border-bottom: 2px solid #e2e8f0; text-align: right; white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 149px; z-index: 10; }
.rank-dt th:nth-child(1) { text-align: center; width: 40px; }
.rank-dt th:nth-child(2), .rank-dt th:nth-child(3) { text-align: left; }
.rank-dt th:hover { color: #1d4ed8; }
.rank-dt th.sort-active { color: #1d4ed8; }
.rank-dt th.sort-active::after { content: ' ▼'; font-size: 10px; }
.rank-dt th.sort-asc::after { content: ' ▲'; font-size: 10px; }
.rank-dt td { padding: 9px 5px; border-bottom: 1px solid #f1f5f9; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-dt td:nth-child(1) { text-align: center; }
.rank-dt td:nth-child(2) { text-align: left; }
.rank-dt td:nth-child(3) { text-align: left; }
.rank-dt tr:hover td { background: #f0f9ff; cursor: pointer; }
.rank-dt tr:last-child td { border-bottom: none; }

.rank-num { font-size: 13px; font-weight: 800; color: #94a3b8; }
.rank-num.r1 { color: #d97706; }
.rank-num.r2 { color: #94a3b8; }
.rank-num.r3 { color: #b45309; }

.rank-link { color: #2563eb; text-decoration: none; font-weight: 800; }
.rank-link:hover { color: #1d4ed8; text-decoration: underline; }
.rank-sido-link { color: #64748b; text-decoration: none; font-size: 12px; }
.rank-sido-link:hover { color: #1d4ed8; }

.diff-up { display: inline-block; background: #fee2e2; color: #dc2626; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.diff-dn { display: inline-block; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 3px; }
.diff-no { display: inline-block; color: #94a3b8; font-size: 11px; font-weight: 700; padding: 1px 5px; }

.area-s { display: inline-block; background: #dbeafe; color: #1d4ed8; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.area-m { display: inline-block; background: #e0e7ff; color: #4338ca; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.area-l { display: inline-block; background: #ede9fe; color: #7c3aed; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }

.rank-tbl-fn { font-size: 11px; color: #94a3b8; padding: 10px 14px; border-top: 1px solid #f1f5f9; background: #fafafa; line-height: 1.7; }

/* ── 드릴다운 ── */
.rank-drill-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 14px; }
.rank-drill-item { display: flex; align-items: center; justify-content: center; background: #f0f9ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 8px 4px; font-size: 12px; font-weight: 700; color: #1e40af; text-decoration: none; text-align: center; }
.rank-drill-item:hover { background: #dbeafe; border-color: #93c5fd; }

/* ── 카드 ── */
.rank-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; overflow: clip; }
.rank-ch { padding: 12px 16px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 8px; background: #fafafa; }
.rank-ct { font-size: 14px; font-weight: 800; color: #1e293b; }
.rank-cs { font-size: 12px; color: #94a3b8; margin-left: 2px; }

/* PM2.5 배지 */
.pm-good   { display: inline-block; background: #dcfce7; color: #15803d; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.pm-normal { display: inline-block; background: #fef9c3; color: #854d0e; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.pm-bad    { display: inline-block; background: #fee2e2; color: #991b1b; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }

/* PM 범례 색상 */
.rank-pm-legend .pm-g { background: #dcfce7; color: #15803d; }
.rank-pm-legend .pm-n { background: #fef9c3; color: #854d0e; }
.rank-pm-legend .pm-b { background: #fee2e2; color: #991b1b; }

/* ── 툴팁 아이콘 — 표시는 JS body 팝업이 담당 ── */
.tip-icon { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: #93c5fd; color: #1e3a8a; font-size: 9px; font-weight: 700; cursor: help; vertical-align: middle; margin-left: 4px; user-select: none; }

/* ── 2차 컬럼 서브 행 ── */
.rank-row-sec { display: none; }
.rank-row-sec td { background: #f8fafc; border-bottom: 1px solid #f1f5f9; }
.rank-sec-grid { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 4px; font-size: 12px; }
.rank-sec-item { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.rank-sec-lbl  { font-size: 11px; color: #94a3b8; font-weight: 600; }

/* ── 컬럼 더 보기 토글 버튼 (데스크탑에서 숨김) ── */
.rank-col-toggle {
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #1d4ed8;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 5px;
    padding: 4px 10px;
    cursor: pointer;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}
.rank-col-toggle:hover { background: #dbeafe; }

/* ── 모바일 필터 토글 버튼 (데스크탑에서 숨김) ── */
.rank-filter-toggle {
    display: none;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-content: space-between;
    background: #1e293b;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 11px 16px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    margin-bottom: 8px;
}
.rank-filter-toggle-right { display: flex; align-items: center; gap: 8px; }
.rank-filter-toggle-mc { font-size: 11px; color: rgba(255,255,255,.55); font-weight: 600; }
.rank-filter-toggle-arrow { font-size: 10px; transition: transform .2s; }
.rank-filter-toggle.open .rank-filter-toggle-arrow { transform: rotate(180deg); }

/* ── 반응형 ── */
@media (max-width: 1024px) {
    .rank-drill-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
    .rank-body { grid-template-columns: 1fr; padding: 12px 12px 48px; }
    .rank-sb { display: none; position: static; max-height: none; margin-bottom: 8px; }
    .rank-sb.open { display: block; }
    .rank-filter-toggle { display: flex; }
    .rank-main-col { min-height: 0; }
    .rank-drill-grid { grid-template-columns: repeat(4, 1fr); }
    table.rank-dt { min-width: unset; }
    .rank-col-toggle { display: inline-flex; }
    .rank-col-sec { display: none; }
    .rank-tbl-wrap.expanded .rank-row-sec { display: table-row; }
    .rank-row-sec.open { display: table-row; }
    .rank-dt tr.row-open > td { background: #eff6ff; }
}
@media (max-width: 580px) {
    .rank-dt th, .rank-dt td { font-size: 12px; padding: 7px 4px; }
    .rank-drill-grid { grid-template-columns: repeat(3, 1fr); }
    .rank-hd { padding: 18px 14px 14px; }
    .rank-title { font-size: 18px; letter-spacing: -.3px; }
    .rank-desc { font-size: 12px; }
    .rank-strip { padding: 8px 12px; }
    .rank-si-wrap { gap: 6px; flex-wrap: wrap; }
    .rank-si { padding: 5px 10px; }
    .rank-si-val { font-size: 13px; }
    .rank-si-val .mc-num { font-size: 15px; }
    .rank-mn-nav { margin-left: 0; width: 100%; }
    .rank-mn-select { width: 100%; }
}
@media (max-width: 420px) {
    .rank-dt th, .rank-dt td { font-size: 11px; padding: 6px 3px; }
    .rank-num { font-size: 11px; }
}
