/* POLI WIKI — 디자인 시스템
   밝은 배경 · 네이비/블루 강조 · 둥근 카드 · 높은 정보 밀도 · 정당색은 태그 수준만 */

:root {
  --navy: #0f2043;
  --navy-2: #16295a;
  --blue: #1e5aa8;
  --blue-2: #2563eb;
  --blue-soft: #eaf1fb;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1c2333;
  --text-2: #5b6577;
  --text-3: #8a93a6;
  --green: #1d9e6b;
  --red: #d64545;
  --orange: #e08a1e;
  --purple: #7c5cbf;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 32, 67, 0.06);
  --sidebar-w: 236px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--blue-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 레이아웃 ── */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content {
  flex: 1;
  padding: 20px 28px 60px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ── 헤더 ── */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px;
}
.brand .logo-name { font-size: 19px; font-weight: 800; color: var(--navy); letter-spacing: -0.3px; }
.brand .logo-sub { font-size: 11px; color: var(--text-3); font-weight: 500; }

.top-search {
  flex: 1; max-width: 560px;
  display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; gap: 8px;
}
.top-search input { flex: 1; border: none; outline: none; background: transparent; font-size: 14px; }
.top-search .icon { color: var(--text-3); }

.top-links { margin-left: auto; display: flex; gap: 18px; font-size: 13px; color: var(--text-2); }
.top-links a { color: var(--text-2); }

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: #dfe6f5;
  flex-shrink: 0;
  padding: 16px 10px 30px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .menu-group { margin-bottom: 14px; }
.sidebar .menu-group-title {
  font-size: 11px; letter-spacing: 0.6px; color: #7f8db3;
  padding: 4px 12px; font-weight: 700;
}
.sidebar a.menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: 8px;
  color: #dfe6f5; font-size: 13.5px; margin-bottom: 2px;
}
.sidebar a.menu-item:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.sidebar a.menu-item.active { background: #fff; color: var(--navy); font-weight: 700; }
.sidebar .sub { padding-left: 26px; }
.sidebar .sub a { font-size: 12.5px; color: #b9c4de; padding: 5px 12px; }
.sidebar .sub a.active { color: #fff; font-weight: 600; background: rgba(255,255,255,0.1); }

/* ── 카드 ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 800; color: var(--navy); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .link-all { margin-left: auto; font-size: 12.5px; font-weight: 500; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── 프로필 카드 ── */
.profile-card { display: grid; grid-template-columns: 150px 1.2fr 2fr 1.4fr; gap: 22px; align-items: start; }
.profile-photo { width: 140px; height: 168px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); background: #eef2f8; }
.profile-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.profile-basic h1 { font-size: 26px; font-weight: 800; color: var(--navy); display: flex; align-items: center; gap: 10px; }
.profile-basic .party-name { color: var(--blue); font-size: 16px; font-weight: 700; margin: 2px 0 8px; }
.profile-basic .meta-line { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13.5px; margin-bottom: 4px; }
.profile-basic .meta-line b { color: var(--text); }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: #fbfcfe;
}
.metric .m-label { font-size: 12px; color: var(--text-3); font-weight: 600; }
.metric .m-value { font-size: 22px; font-weight: 800; color: var(--navy); }
.metric .m-sub { font-size: 11.5px; color: var(--text-2); }

/* ── 탭 ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn {
  border: none; background: none; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-2);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  font-family: inherit;
}
.tab-btn:hover { color: var(--blue); }
.tab-btn.active { color: var(--blue-2); border-bottom-color: var(--blue-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 표 ── */
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 12px; color: var(--text-3); font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbfe; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── 배지 ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.green { background: #e5f5ee; color: var(--green); }
.badge.red { background: #fbeaea; color: var(--red); }
.badge.orange { background: #fdf3e3; color: var(--orange); }
.badge.purple { background: #f0eafb; color: var(--purple); }
.badge.gray { background: #eef0f4; color: var(--text-2); }
.badge.navy { background: var(--navy); color: #fff; }
.badge.sample { background: #dbe7fb; color: var(--blue); border: 1px dashed var(--blue-2); }

.party-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text);
}
.party-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ── 타임라인 ── */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px;
  background: var(--border); border-radius: 2px;
}
.tl-item { position: relative; padding-bottom: 14px; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 5px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--blue); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--blue-soft);
}
.tl-date { font-size: 12px; color: var(--text-3); font-weight: 600; }
.tl-title { font-size: 13.5px; font-weight: 700; }
.tl-detail { font-size: 12.5px; color: var(--text-2); }

/* ── 사건 카드 ── */
.event-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.event-item .ev-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.event-item .ev-date { font-size: 12px; color: var(--text-3); font-weight: 700; font-variant-numeric: tabular-nums; }
.event-item .ev-title { font-weight: 700; font-size: 13.5px; }
.event-item .ev-desc { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.event-item .ev-src { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }
.event-item .ev-src a { color: var(--blue); }

/* ── 검색 ── */
.hero-search {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-radius: 16px; padding: 44px 32px; text-align: center; color: #fff;
  margin-bottom: 24px;
}
.hero-search h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.3px; }
.hero-search p { color: #aeb9d8; font-size: 14px; margin: 8px 0 22px; }
.search-box {
  max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 999px; padding: 6px 8px 6px 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.search-box input { flex: 1; border: none; outline: none; font-size: 15px; }
.search-box button {
  background: var(--blue-2); color: #fff; border: none; border-radius: 999px;
  padding: 9px 22px; font-size: 14px; font-weight: 700; cursor: pointer;
}

/* ── 필터 ── */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 5px 13px; font-size: 12.5px; color: var(--text-2); cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue-soft); border-color: var(--blue-2); color: var(--blue-2); font-weight: 700; }

/* ── 유틸 ── */
.muted { color: var(--text-3); font-size: 12.5px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.text-right { text-align: right; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); background: #eef2f8; }
.avatar.sm { width: 30px; height: 30px; }
.empty { color: var(--text-3); font-size: 13px; padding: 24px; text-align: center; }

/* ── 진행 바 ── */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .bar-label { width: 110px; font-size: 12.5px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 14px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; border-radius: 999px; }
.bar-row .bar-val { width: 70px; font-size: 12.5px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ── 푸터 ── */
.footer {
  border-top: 1px solid var(--border); background: var(--card);
  padding: 16px 28px; font-size: 12px; color: var(--text-3);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.footer .disclaimer { display: flex; align-items: center; gap: 6px; }

/* 실데이터 전환 후: 가상 데이터 배지·안내문 자동 숨김 (ui.js 가 body.real-only 토글) */
body.real-only .badge.sample,
body.real-only .disclaimer { display: none !important; }

/* ── 라이프사이클 ── */
.lifecycle { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.lc-step {
  display: flex; align-items: center; gap: 8px;
  background: #f7f9fc; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 12px;
}
.lc-step .lc-label { color: var(--text-2); font-weight: 600; }
.lc-step .lc-value { font-weight: 800; color: var(--navy); }
.lc-arrow { color: var(--text-3); }

/* ── 반응형 (데스크톱 우선) ── */
@media (max-width: 1100px) {
  .profile-card { grid-template-columns: 130px 1fr 1.6fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .profile-card { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .top-links { display: none; }
}

/* ══════════ 선거 데이터 분석 (analysis) ══════════ */
.an-page h1 { font-size: 22px; margin: 0 0 4px; }
.an-sub { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
.an-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); margin-bottom: 16px; }
.an-meta b { color: var(--text-2); }

/* 요약 카드 */
.an-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.an-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.an-card .an-c-head { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--text-3); margin-bottom: 8px; }
.an-card .an-c-val { font-size: 22px; font-weight: 800; color: var(--text-1); }
.an-card .an-c-val small { font-size: 12px; font-weight: 600; color: var(--text-3); }
.an-card .an-c-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.an-card.notavail { opacity: .65; }
.badge.sev-OBSERVE { background: #fdf3d7; color: #a16207; }
.badge.sev-ANOMALY { background: #fee2d5; color: #c2410c; }
.badge.sev-ANOMALY_HIGH { background: #fde3e3; color: #b91c1c; }
.badge.sev-NORMAL { background: #eef1f6; color: var(--text-3); }
.badge.sev-composite { background: #7c1d1d; color: #fff; }

/* 정보 아이콘 + 툴팁 */
.info-ic { display: inline-flex; width: 16px; height: 16px; border-radius: 50%; background: #dbe4f5; color: var(--blue); font-size: 11px; font-weight: 800; align-items: center; justify-content: center; cursor: help; position: relative; flex: none; }
.tip { position: relative; }
.tip .tip-box { display: none; position: absolute; z-index: 60; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); width: 260px; background: #132247; color: #fff; border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.55; box-shadow: 0 8px 24px rgba(15,32,67,.25); }
.tip .tip-box .tip-title { font-weight: 700; margin-bottom: 4px; color: #9db7ea; font-size: 11.5px; }
.tip:hover .tip-box, .tip:focus .tip-box { display: block; }

/* 분석 레이아웃 */
.an-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.an-map-box, .an-panel { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.an-panel h3 { font-size: 14.5px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.an-table th { text-align: left; color: var(--text-3); font-weight: 600; font-size: 11.5px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.an-table td { padding: 8px; border-bottom: 1px solid #eef1f6; }
.an-table tr.clickable { cursor: pointer; }
.an-table tr.clickable:hover td { background: #f6f9ff; }
.an-table .rank { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* 필터 */
.an-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.an-filters select, .an-filters .chip { font-size: 12.5px; }
.an-filters .chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }
.an-filters .chip.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* 지역 상세 패널 */
.an-detail { border-left: 3px solid var(--blue); }
.an-detail .d-name { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.an-detail .d-sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 12px; }
.an-detail .d-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed #eef1f6; }
.an-detail .d-row .k { color: var(--text-3); }
.an-detail .d-row .v { font-weight: 700; }
.an-detail .d-section { font-size: 12px; font-weight: 700; color: var(--blue); margin: 14px 0 6px; }
.an-detail .d-signal { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; }
.an-detail .d-signal .sev-badge { font-size: 11px; padding: 1px 8px; border-radius: 999px; }
.an-detail .d-signal .tip { cursor: help; }

/* 지도 */
.an-map-svg { width: 100%; height: auto; }
.an-map-svg .sido { stroke: #fff; stroke-width: 1.5; cursor: pointer; }
.an-map-svg .dot { cursor: pointer; stroke: #fff; stroke-width: 1; }
.an-map-svg .dot:hover { stroke: #132247; stroke-width: 2; }
.an-legend { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--text-3); margin-top: 8px; }
.an-legend .lg-row { display: flex; align-items: center; gap: 6px; }
.an-legend .lg-sq { width: 12px; height: 12px; border-radius: 3px; }

/* 차트 */
.an-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.an-chart { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.an-chart h4 { font-size: 13.5px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.an-chart .chart-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-3); margin-top: 8px; flex-wrap: wrap; }
.an-chart .chart-legend .lg { display: flex; align-items: center; gap: 5px; }

/* 한계 배너 */
.an-limits { background: #eef4ff; border: 1px solid #d3e2ff; border-radius: 12px; padding: 10px 14px; font-size: 12.5px; color: var(--text-2); margin-top: 18px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.an-empty { color: var(--text-3); font-size: 13px; padding: 20px; text-align: center; }

/* 방법론 페이지 */
.meth h2 { font-size: 18px; margin: 22px 0 8px; }
.meth p, .meth li { font-size: 13.5px; line-height: 1.7; color: var(--text-2); }
.meth .warn { background: #fff7e8; border: 1px solid #f5dfb0; border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
