:root {
  --bg: #0b0f1a; --panel: #131a2a; --card: #111827; --line: #253049; --text: #e5e9f2; --muted: #8a94ab;
  --accent: #7c83ff; --ok: #22c55e; --up: #ef4444; --down: #3b82f6; --bar: #3b6fd6; --yoy: #22d3ee; --warn: #f59e0b;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f7fb; --panel: #ffffff; --card: #ffffff; --line: #dfe4ee; --text: #172033; --muted: #5d6882;
    --bar: #4c7fe0; --yoy: #0891b2;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Pretendard, -apple-system, "Apple SD Gothic Neo", sans-serif; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; } .brand b { color: var(--accent); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; }
nav a.on { color: var(--text); background: var(--panel); box-shadow: inset 0 -2px var(--accent); }
.src { margin-left: auto; color: var(--muted); font-size: 12px; }
.view { display: none; padding: 16px 20px 40px; max-width: 1600px; margin: 0 auto; }
.view.on { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.grow { flex: 1 1 220px; }
.lbl { font-size: 12px; color: var(--muted); width: 36px; align-self: center; }
input, select, button, .btn { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-height: 36px; }
input[type=number] { width: 96px; }
.unit { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
button, .btn { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 7px 22px; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
.ghost { background: transparent; color: var(--muted); }
.presets { min-width: 240px; }
.tog { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 8px; cursor: pointer; user-select: none; }
.tog input { display: none; }
.tog i { width: 30px; height: 17px; border-radius: 9px; background: var(--line); position: relative; transition: .15s; }
.tog i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: .15s; }
.tog input:checked + i { background: var(--accent); } .tog input:checked + i::after { left: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chips.scroll { max-height: 92px; overflow: auto; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); cursor: pointer; background: transparent; min-height: 0; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { opacity: .7; margin-left: 4px; }
.meta { color: var(--muted); font-size: 12px; margin: 14px 2px 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card .hd { display: flex; align-items: center; gap: 6px; }
.card .hd .sp { flex: 1; }
.card .small { font-size: 11px; padding: 2px 8px; min-height: 0; border-radius: 6px; }
.star { background: transparent; border: 1px solid var(--line); color: var(--muted); font-size: 13px; min-height: 0; padding: 2px 8px; }
.star.on { color: #facc15; border-color: #facc15; }
/* 캔버스 크기를 CSS 로 강제하면 Chart.js 해상도와 어긋나 글자가 뭉개진다 → 높이는 래퍼가 갖고 캔버스는 Chart.js 가 맞춘다 */
.card .cv { position: relative; height: 200px; }
.card .nm { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.card .code { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--line); color: var(--text); }
.tag.p { background: var(--warn); color: #111; }
.big { font-size: 22px; font-weight: 700; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.stats span { padding: 2px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); }
.up { color: var(--up); } .down { color: var(--down); }
.empty { grid-column: 1/-1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 70px 10px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; font-size: 28px; text-align: center; }
.empty b { font-size: 15px; color: var(--text); } .empty span { font-size: 12px; max-width: 460px; }
.pager { display: flex; justify-content: center; gap: 4px; margin-top: 18px; flex-wrap: wrap; }
.pager button { min-width: 36px; justify-content: center; }
.pager button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.kpi .k { color: var(--muted); font-size: 12px; } .kpi .v { font-size: 20px; font-weight: 700; }
.two { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } .grid { grid-template-columns: 1fr; } }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.box h3 { margin: 0 0 8px; font-size: 14px; }
.chartbox { height: 360px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--card); }
.tbl { max-height: 420px; overflow: auto; }
tr.click { cursor: pointer; } tr.click:hover { background: var(--bg); }
.bar-s { height: 6px; background: var(--bar); border-radius: 3px; }
@media (max-width: 600px) { .view, .top { padding-left: 16px; padding-right: 16px; } .grid { grid-template-columns: 1fr; } }

/* Bluehole / epic Finance inspired research panels. */
:root { --bg:#111419; --panel:#191d23; --card:#191d23; --line:#303741; --text:#f4f7fb; --muted:#929ba8; --accent:#168ce3; --bar:#3aa7ff; }
.top { flex-wrap:wrap; gap:12px; border-radius:0; background:#0f1216; }
.top nav { flex-wrap:wrap; gap:4px; }
.top .brand { font-size:14px; letter-spacing:1px; }
.top .src { width:100%; text-align:right; }
.panel,.box,.card,.kpi { border-radius:6px; }
.research-heading { margin:14px 0 22px; }
.research-heading h1 { font-size:27px; letter-spacing:-.6px; margin:8px 0; }
.research-heading p,.subtle { color:var(--muted); font-size:12px; }
.eyebrow { color:#3aa7ff; font-size:10px; font-weight:700; letter-spacing:2px; }
.research-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin:14px 0; }
.two-charts { grid-template-columns:repeat(2,minmax(0,1fr)); }
.full-charts { grid-template-columns:minmax(0,1fr); }
.full-charts .chartbox,.large-chart .chartbox { height:420px; }
#rs-collect-status { line-height:1.7; }
#rs-lag-interpretation { line-height:1.9; }
.wide { grid-column:1/-1; }
.research-grid .box { padding:18px; }
.research-grid h3 { font-size:14px; margin-bottom:16px; }
.chartbox { position:relative; }
.small-chart { height:220px; }
.chart-empty { position:absolute; inset:0; display:grid; place-items:center; padding:16px; text-align:center; line-height:1.7; background:#191d23ed; color:var(--muted); font-size:12px; }
.scope-note { font-size:12px; line-height:1.7; color:#a8b6c7; background:#3aa7ff0a; border-left:2px solid #3aa7ff; padding:10px 14px; }
a { color:#66baff; }
.kpi .meta { margin:7px 0 0; font-size:11px; }
.section-gap { margin-top:14px; }
summary { cursor:pointer; padding:6px 0; font-size:12px; color:var(--muted); }
#rs-hs { max-width:100%; }
[hidden] { display:none !important; }
@media(max-width:900px) { .research-grid { grid-template-columns:1fr; } .top .src { display:none; } }
@media(max-width:600px) { .top nav { overflow-x:auto; flex-wrap:nowrap; width:100%; padding-bottom:6px; } .top nav a { white-space:nowrap; font-size:12px; } .research-heading h1 { font-size:23px; } .kpis { grid-template-columns:repeat(2,minmax(0,1fr)); } .kpi .v { font-size:18px; } select { max-width:100%; } .row > label { min-width:0; } .chartbox { height:280px; } }
@media(max-width:600px) { .full-charts .chartbox,.large-chart .chartbox { height:320px; } }

.panel { grid-template-columns:minmax(0,1fr); min-width:0; }
.row { min-width:0; }

:root { color-scheme:dark; }

#rs-product-table td:nth-child(2),#rs-product-table td:nth-child(3){white-space:normal;text-align:left;min-width:150px;max-width:280px} #rs-product-table td:nth-child(3){min-width:220px}

.surge-heading{display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap}
#ps-counts{grid-template-columns:repeat(3,minmax(0,1fr));margin-top:16px}
.surge-table-wrap{overflow-x:auto;border:1px solid var(--line);border-radius:6px;background:var(--card)}
#ps-table th,#ps-table td{padding:13px 14px;text-align:left}
#ps-table td:nth-child(2),#ps-table td:nth-child(3){white-space:normal;min-width:130px;max-width:290px}
#ps-table .subtle{margin-top:5px;font-size:11px}
#ps-table .surge-growth{min-width:150px;color:var(--bar);font-size:18px}
#ps-table .bar-s{margin-top:7px;max-width:160px}
#ps-table tbody tr:hover{background:#3aa7ff08}
#ps-table .surge-empty{text-align:center;padding:32px;color:var(--muted)}
