:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e6e9ee;
  --text: #1f2530;
  --muted: #8b93a1;
  --up: #d23b3b;       /* 한국 관습: 상승=빨강 */
  --down: #1f63d8;     /* 하락=파랑 */
  --accent: #111827;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Pretendard", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
a { color: inherit; text-decoration: none; }

/* 헤더 */
.site-header { background: linear-gradient(135deg, #141d2e 0%, #0d1420 100%); color: #fff; padding: 18px 0; }
.site-header h1 { margin: 0; font-size: 22px; }
.site-header .sub { margin: 4px 0 0; color: #b9c0cc; font-size: 13px; }
.back { display: inline-block; color: #aab2c0; font-size: 13px; }
.back:hover { color: #fff; }

/* 브랜드(Bong Stocks = 봉/캔들) */
.brand-accent { height: 3px; background: linear-gradient(90deg, var(--up) 0%, #9b3f86 50%, var(--down) 100%); }
.brand-row { display: flex; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; }
.brand-mark { display: inline-flex; }
.brand-svg { width: 34px; height: 34px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 23px; font-weight: 800; letter-spacing: -.01em; }
.brand-tag { font-size: 12px; color: #9aa6ba; margin-top: 4px; }
/* 상세·안내 페이지 상단의 작은 브랜드 바 */
.detail-brandbar { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.brand-sm { gap: 7px; }
.brand-sm .brand-svg { width: 22px; height: 22px; }
.brand-sm .brand-name { font-size: 16px; font-weight: 800; }
.detail-brandbar .back { margin-left: auto; }
/* 푸터 브랜드 */
.foot-brand { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-weight: 700; margin: 0 0 6px; }
.foot-brand .brand-svg { width: 18px; height: 18px; }
/* 업종 실질 점검(sector_view) — 지주·복합·KSIC 오분류일 때만 표시 */
.sector-view { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; }
.sv-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; margin-right: 6px;
  background: #2a2f3a; color: #cdd3dd; font-size: 12px; }
.sv-chip.sv-real { background: #3a2f1a; color: #f0c674; }
.sv-lens { color: #9aa3b2; }
.sv-reason { display: block; margin-top: 3px; color: #b9c0cc; }

/* 툴바 */
.toolbar { display: flex; gap: 10px; align-items: center; margin: 22px 0 16px; flex-wrap: wrap; }
#search { flex: 1; min-width: 220px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; background: #fff; }
#sector-filter, #level-filter, #market-filter { height: 38px; padding: 0 30px 0 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; font-size: 13px; color: var(--text); cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%238b93a1' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
#sector-filter:hover, #level-filter:hover, #market-filter:hover { border-color: #cfd5df; }
/* 컴팩트 세그먼트 토글(정렬) */
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; height: 38px;
  background: #eef1f5; border: 1px solid var(--border); border-radius: 10px; }
.seg-btn { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent;
  font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s, box-shadow .12s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-on { background: #fff; color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 29, 46, .1); }
.meta { color: var(--muted); font-size: 13px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin: 28px 0 8px; }
.pg-btn { min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--border); background: #fff;
  border-radius: 9px; color: var(--fg, #1a1a1a); font-size: 14px; cursor: pointer; transition: background .12s, border-color .12s; }
.pg-btn:hover:not(:disabled) { border-color: var(--accent, #2563eb); color: var(--accent, #2563eb); }
.pg-btn.active { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: #fff; font-weight: 600; }
.pg-btn:disabled { opacity: .4; cursor: default; }
.pg-gap { color: var(--muted); padding: 0 2px; }
.card-lvl { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; vertical-align: middle; }
.card-lvl.lvl-good { background: #e6f4ea; color: #1e7a3d; }
.card-lvl.lvl-bad { background: #fdecec; color: var(--up); }
.card-lvl.lvl-mid { background: #eef1f5; color: #5a6473; }
.card-rs { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; vertical-align: middle; background: #eef3fe; color: #2c52b5; }

/* 지수 대비 상대강도 readout(상세 페이지) */
.rs-readout { margin: 0 0 14px; }
.rs-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rs-num { font-size: 34px; font-weight: 800; line-height: 1; color: #2c52b5;
  min-width: 56px; text-align: center; }
.rs-cap { display: flex; flex-direction: column; gap: 2px; }
.rs-cap b { font-size: 14px; }
.rs-cap small { color: var(--muted); font-size: 11px; line-height: 1.35; max-width: 380px; }
.rs-top { margin-left: auto; padding: 4px 12px; border-radius: 999px; font-weight: 700;
  font-size: 13px; background: #eef3fe; color: #2c52b5; white-space: nowrap; }
.rs-vi { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }

/* 그리드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; transition: transform .08s, box-shadow .08s; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(20,30,50,.08); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; }
.card-name { font-weight: 600; font-size: 15px; }
.card-code { color: var(--muted); font-size: 12px; }
.card-sector { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.card-bottom { display: flex; justify-content: space-between; align-items: baseline; }
.card-price { font-weight: 600; }
.card-chg { font-size: 13px; font-weight: 600; }
.card-mcap { margin-top: 4px; color: var(--muted); font-size: 12px; }

/* 패널 */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px; margin: 16px 0; }
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.panel h2 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }

.price-head { display: flex; justify-content: space-between; align-items: center; }
.close { font-size: 28px; font-weight: 700; }
.change { font-size: 15px; font-weight: 600; margin-left: 10px; }
.mcap { color: var(--muted); font-size: 14px; }

/* key-value */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; }
.kv-row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 6px 0; }
.kv-k { color: var(--muted); font-size: 13px; }
.kv-v { font-weight: 600; font-size: 14px; }

/* 색 */
.up { color: var(--up); }
.down { color: var(--down); }

/* 차트 */
#chart { width: 100%; height: auto; display: block; }
.legend { margin-top: 8px; font-size: 12px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 14px; height: 3px; margin-right: 5px; vertical-align: middle; }
.lg { margin-right: 14px; }
.lg-c::before { background: #111827; }
.lg-20::before { background: #3b82f6; }
.lg-60::before { background: #e0a23b; }
.lg-idx::before { background: #9aa3af; }

/* 공시 */
.disc-list { list-style: none; margin: 0; padding: 0; }
.disc-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.disc-date { color: var(--muted); font-size: 12px; margin-right: 10px; }
.dchip { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-right: 8px;
  background: #eef1f5; color: #5a6473; }
.dchip.major { background: #ede7f6; color: #6b46c1; }
.disc-list a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* 푸터/면책 */
.notice { background: #fbfbfc; }
.sources { color: var(--muted); font-size: 12px; margin: 0 0 6px; }
.disclaimer { color: var(--muted); font-size: 12px; margin: 0; line-height: 1.6; }
.site-footer { margin-top: 30px; padding: 24px 0; border-top: 1px solid var(--border); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 한 줄 요약 */
.summary-box { background: #111827; color: #f3f5f8; border-radius: 14px;
  padding: 18px 20px; margin: 16px 0; }
.summary-box p { margin: 0; font-size: 16px; line-height: 1.6; font-weight: 500; }

/* 해석 문장 */
.read { margin: 12px 0 0; padding-top: 12px; border-top: 1px dashed var(--border);
  color: #3a4250; font-size: 14px; line-height: 1.7; }
.read[hidden] { display: none; }

/* 서브 헤딩 */
.sub-h { font-size: 13px; color: var(--muted); margin: 18px 0 8px;
  font-weight: 600; letter-spacing: .02em; }
.sub-h:first-child { margin-top: 0; }
.sub-h.pos { color: var(--up); }
.sub-h.neg { color: var(--down); }

/* 2열(관찰/유의) */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
.point-list { list-style: none; margin: 0; padding: 0; }
.point-list li { position: relative; padding: 6px 0 6px 16px; font-size: 14px;
  line-height: 1.6; border-bottom: 1px solid var(--border); }
.point-list li::before { content: "·"; position: absolute; left: 4px; color: var(--muted); }

/* 성장성 표 */
.growth-wrap { overflow-x: auto; }
.growth-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.growth-table th, .growth-table td { padding: 9px 8px; text-align: right;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.growth-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.growth-table th:first-child, .growth-table td.g-name { text-align: left; font-weight: 600; }
.acc { font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 6px; }
.acc.up { background: #fdecec; color: var(--up); }
.acc.down { background: #e9f0fc; color: var(--down); }

/* 지배구조 패널 */
.gov-top { font-size: 15px; margin: 0 0 6px; }
.gov-line { font-size: 14px; margin: 0 0 6px; color: var(--muted); }
.gov-line b { color: var(--fg, inherit); }
.gov-note { font-size: 13px; color: var(--muted); margin: 4px 0 10px; line-height: 1.55; }
.gov-tip { font-size: 13px; color: #334155; background: #f1f6fe; border: 1px solid #dce8fb;
  border-radius: 9px; padding: 10px 12px; margin: 6px 0 10px; line-height: 1.6; }
.gov-nav { margin: 12px 0 6px; }
.gov-disc { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; margin-left: 6px; }
.gov-disc.lvl-good { background: #fdecec; color: var(--up); }
.gov-disc.lvl-bad { background: #e9f0fc; color: var(--down); }
.gov-disc.lvl-mid { background: #eef0f3; color: var(--muted); }
.gov-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 4px; }
.gov-table th, .gov-table td { padding: 8px; text-align: left;
  border-bottom: 1px solid var(--border); }
.gov-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.gov-rt { text-align: right; font-weight: 600; white-space: nowrap; }
td.gov-rt { font-variant-numeric: tabular-nums; }
.gov-table a { color: var(--accent, #2563eb); text-decoration: none; }
.gov-table a:hover { text-decoration: underline; }

/* 목록 카드 요약 */
.card-summary { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-deep { font-size: 11px; color: #6b46c1; font-weight: 700; margin-left: 4px; }

/* 용어 풀이 */
.glossary summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent);
  list-style: none; padding: 2px 0; }
.glossary summary::-webkit-details-marker { display: none; }
.glossary summary::before { content: "▸ "; color: var(--muted); }
.glossary[open] summary::before { content: "▾ "; }
.glossary dl { margin: 12px 0 0; }
.glossary dt { font-weight: 700; font-size: 13px; color: var(--accent); margin-top: 10px; }
.glossary dd { margin: 2px 0 0; font-size: 13px; line-height: 1.6; color: #3a4250; }
.gl-note { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* 다차원 진단 */
.diag-axes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .diag-axes { grid-template-columns: 1fr; } }
.diag-ax { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.diag-head { display: flex; justify-content: space-between; align-items: center; }
.diag-label { font-weight: 600; font-size: 14px; }
.diag-lvl { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 8px; }
.diag-lvl.lvl-good { background: #e6f4ea; color: #1e7a3d; }
.diag-lvl.lvl-bad { background: #fdecec; color: var(--up); }
.diag-lvl.lvl-mid { background: #eef1f5; color: #5a6473; }
.diag-notes { margin: 8px 0 0; padding-left: 16px; }
.diag-notes li { font-size: 13px; line-height: 1.6; color: #3a4250; margin-bottom: 2px; }

/* 에이전트 심층 */
.badge-agent { font-size: 12px; font-weight: 700; background: #6b46c1; color: #fff;
  padding: 2px 8px; border-radius: 8px; vertical-align: middle; }
.agent-panel { border-left: 3px solid #6b46c1; }
.agent-panel h2 small { color: var(--muted); }
.ag-sec { margin-bottom: 14px; }
.ag-sec:last-child { margin-bottom: 0; }
.ag-text { margin: 6px 0 0; font-size: 14px; line-height: 1.75; color: #2a2f3a; }

/* 에이전트 이벤트 */
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.6; }
.ev-title { font-weight: 600; }
.ev-impact { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.ev-src { font-size: 12px; color: #6b46c1; }

/* 교차검증 칩 */
.vchip { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.vchip.ok { background: #e6f4ea; color: #1e7a3d; }
.vchip.bad { background: #fdecec; color: var(--up); }
.vchip.warn { background: #fff4e0; color: #b5730b; }

/* 상세 페이지 내부 탭(스크롤 대신 메뉴 전환) */
.detail-tabs { position: sticky; top: 0; z-index: 20; display: flex; gap: 4px; flex-wrap: wrap;
  max-width: 980px; margin: 0 auto; padding: 8px 16px; background: rgba(255,255,255,.92);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--border); }
.dtab { border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .1s, color .1s, border-color .1s; }
.dtab:hover { border-color: var(--accent, #2f6fed); color: var(--text, #1b2330); }
.dtab.active { background: var(--accent, #2f6fed); color: #fff; border-color: var(--accent, #2f6fed); }
.tab-hidden { display: none !important; }

/* 용어 인라인 도움말 */
.gterm { border-bottom: 1px dotted #c4ccd8; cursor: help; }
.gterm:hover, .gterm:focus { background: #eef4ff; outline: none; border-bottom-color: var(--accent, #2f6fed); }
.gterm-pop { position: absolute; z-index: 40; max-width: 280px; padding: 9px 11px;
  background: #1b2330; color: #f2f5fa; font-size: 12.5px; line-height: 1.5; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15,22,35,.28); }
