/* ============================================================
   K-TREND STOCK — k-trend.day 디자인 시스템
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; min-height: 100vh; overflow-x: hidden; }
body {
  font-family: 'Apple SD Gothic Neo','Malgun Gothic','Noto Sans KR',-apple-system,sans-serif;
  background: #0a0c10; color: #e2e4ed; font-size: 14px; line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 사이트 헤더 ── */
.site-header { background: #07090d; border-bottom: 1px solid #1a1d28; padding: 0 24px; }
.site-hd-inner { max-width: 1400px; margin: 0 auto; height: 48px; display: flex; align-items: center; gap: 32px; }
.site-logo { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; }
.logo-k    { color: #e84057; }
.logo-trend { color: #e2e4ed; }
.site-nav  { display: flex; gap: 24px; }
.nav-item  { font-size: 13px; color: #606480; transition: color .15s; }
.nav-item:hover, .nav-item.active { color: #fff; text-decoration: none; }
.nav-item.active { font-weight: 700; }

/* ── 페이지 헤더 ── */
.hd-title-bar { padding: 14px 24px 10px; border-bottom: 1px solid #1a1d28; }
.hd-title { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -.5px; }
.hd-sub   { font-size: 12px; color: #50546a; margin-top: 2px; }

/* ── 시장 지수 바 ── */
.market-bar {
  display: flex; align-items: center; padding: 9px 24px;
  background: #0d0f17; border-bottom: 1px solid #141720;
  overflow-x: auto; scrollbar-width: none;
}
.market-bar::-webkit-scrollbar { display: none; }
.mkt-block { display: flex; align-items: center; gap: 8px; padding-right: 20px; margin-right: 20px; border-right: 1px solid #1e2230; flex-shrink: 0; }
.mkt-block:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.mkt-name { font-size: 13px; font-weight: 700; color: #8890b0; }
.mkt-val  { font-size: 15px; font-weight: 800; color: #e2e4ed; letter-spacing: -.3px; }
.mkt-chg  { font-size: 12px; font-weight: 600; white-space: nowrap; }
.mkt-chg.up { color: #ff4a5a; } .mkt-chg.dn { color: #4a9eff; }
.mkt-vol  { font-size: 11px; color: #404468; margin-left: 4px; white-space: nowrap; }

/* ── 투자자 바 ── */
.inv-bar {
  display: flex; align-items: center; padding: 7px 24px;
  background: #0a0c14; border-bottom: 1px solid #141720;
  overflow-x: auto; scrollbar-width: none;
}
.inv-bar::-webkit-scrollbar { display: none; }
.inv-section { display: flex; align-items: center; flex-shrink: 0; }
.inv-section-label { font-size: 11px; color: #40445a; font-weight: 600; margin-right: 10px; white-space: nowrap; }
.inv-item  { display: flex; align-items: center; gap: 4px; margin-right: 12px; flex-shrink: 0; white-space: nowrap; }
.inv-dot   { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; }
.inv-name  { font-size: 11px; color: #606480; }
.inv-amt   { font-size: 11px; font-weight: 700; }
.inv-amt.up { color: #ff4a5a; } .inv-amt.dn { color: #4a9eff; }
.inv-sep   { width: 1px; height: 12px; background: #1e2230; margin: 0 14px; flex-shrink: 0; }

/* ── 툴바 ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; padding: 9px 24px; border-bottom: 1px solid #141720; gap: 8px; }
.sort-group { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.sort-label { font-size: 11px; color: #40445a; flex-shrink: 0; margin-right: 2px; }
.sort-btn { font-size: 12px; color: #606480; background: #161921; border: 1px solid #222536; border-radius: 6px; padding: 6px 13px; cursor: pointer; font-family: inherit; transition: all .15s; white-space: nowrap; }
.sort-btn.on { background: #252840; color: #fff; border-color: #3a3f5c; font-weight: 700; }
.sort-btn:hover:not(.on) { background: #1a1f2e; color: #b0b8d8; }
.rf-btn { display: flex; align-items: center; gap: 6px; background: #161921; border: 1px solid #252836; color: #8890b0; border-radius: 8px; padding: 8px 14px; font-size: 12px; cursor: pointer; font-family: inherit; white-space: nowrap; flex-shrink: 0; transition: all .2s; }
.rf-btn:hover { background: #1e2232; color: #fff; }
.rf-btn svg { width: 12px; height: 12px; }
.rf-btn.spin svg { animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ── 그리드 ── */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 12px 24px; }

/* ── 테마 카드 ── */
.theme-card { border-radius: 11px; overflow: hidden; border: 1px solid #1e2230; }

/* ── 카드 헤더 — 배경색은 JS hdStyle()로 동적 적용 ── */
.th-hd {
    padding: 10px 13px;
    transition: background .3s ease;
}
.th-name-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.th-name  { font-size: 14px; font-weight: 700; color: #fff; }
.th-rate  { font-size: 17px; font-weight: 800; color: #fff; margin-top: 3px; letter-spacing: -.4px; }
.hot-badge { font-size: 8px; font-weight: 800; background: rgba(255,255,255,.28); color: #fff; padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }

/* 컬럼 헤더 */
.col-hd { display: grid; grid-template-columns: 1fr 12px 55px 50px 46px 58px 52px; padding: 5px 12px; background: #0c0e18; border-bottom: 1px solid #1a1d28; align-items: center; }
.col-hd span { font-size: 9px; color: #404468; font-weight: 600; letter-spacing: .2px; }
.col-hd .r   { text-align: right; }

/* 종목 행 */
.stock-list { background: #0f1118; }
.stock-row {
    display: grid;
    grid-template-columns: 1fr 12px 55px 50px 46px 58px 52px;
    padding: 7px 12px;
    border-bottom: 1px solid #141720;
    border-left: 3px solid transparent;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: background .12s, border-left-color .15s;
    min-width: 0;
}
.stock-row:last-child { border-bottom: none; }
.stock-row:hover { background: #1a1f30; }
.stock-row.vip { background: #0f1118; border-bottom-color: #141720; }
.stock-row.vip:hover { background: #252010; }
.stock-row.vip::before { display: none; }

/* 텍스트 넘침 방지 */
.stock-row > * {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 시장 배지 */
.mkt-badge { font-size: 7px; font-weight: 700; border-radius: 3px; padding: 1px 3px; text-align: center; line-height: 1.4; flex-shrink: 0; }
.mkt-badge.kospi  { background: #1a2a4a; color: #5599dd; border: 1px solid #2a3a6a; }
.mkt-badge.kosdaq { background: #2a1a10; color: #dd8855; border: 1px solid #4a2a18; }

.s-name {
    font-size: 11px; color: #a0a8c0;
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; padding: 0 4px;
    min-width: 0;
}
.stock-row.vip .s-name { color: #f0d080; font-weight: 700; }
.s-cell { font-size: 10px; text-align: right; color: #565a7a; white-space: nowrap; }
.stock-row.vip .s-cell { color: #c89030; font-weight: 600; }
.s-rate { font-size: 11px; font-weight: 700; text-align: right; white-space: nowrap; }
.s-rate.up { color: #ff6070; } .s-rate.dn { color: #4a9eff; }
.s-cell.up { color: #ff6070 !important; }
.s-cell.dn { color: #4a9eff !important; }

/* 순위 화살표 */
.rank-num   { font-size: 10px; font-weight: 700; color: #a0a8c0; }
.rank-arrow { font-size: 8px; font-weight: 800; color: #404468; }
.rank-up    { color: #ff6070; }
.rank-dn    { color: #4a9eff; }

/* 등락률 변화 배지 */
.rate-diff {
    font-size: 9px; font-weight: 600;
    padding: 1px 4px; border-radius: 3px;
    margin-left: 4px; white-space: nowrap;
}
.rate-diff.up { background: rgba(255,96,112,.15); color: #ff6070; }
.rate-diff.dn { background: rgba(74,158,255,.15);  color: #4a9eff; }

/* ── 테마 범례 ── */
.global-legend {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 10px 14px; margin-bottom: 10px;
    background: #0c0e18;
    border-radius: 8px;
    border: 1px solid #1a1d2e;
}
.theme-legend {
    padding: 8px 12px 10px;
    display: flex; flex-wrap: wrap; gap: 5px;
    border-top: 1px solid #141720;
}
.theme-legend-item {
    font-size: 10px; font-weight: 600;
    padding: 3px 9px; border-radius: 4px;
    border: 1px solid; white-space: nowrap;
    cursor: default;
}
#theme-legend-wrap {
    padding: 10px 14px;
    border-top: 1px solid #1a1d2e;
}

/* ── 로딩 ── */
.loading { grid-column: 1/-1; padding: 50px 0; text-align: center; }
.ldots   { display: inline-flex; gap: 7px; }
.ldots i { width: 7px; height: 7px; border-radius: 50%; background: #e84057; display: block; animation: bk 1.2s infinite; }
.ldots i:nth-child(2) { animation-delay: .2s; } .ldots i:nth-child(3) { animation-delay: .4s; }
@keyframes bk { 0%, 80%, 100% { opacity: .15; } 40% { opacity: 1; } }
.ldots-txt { margin-top: 10px; font-size: 12px; color: #40445a; }

/* ── 푸터 ── */
.page-foot { padding: 12px 24px; border-top: 1px solid #141720; font-size: 11px; color: #303450; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.foot-sep  { color: #252840; }
.page-foot a { color: #404468; }
.page-foot a:hover { color: #8890b0; text-decoration: none; }
.foot-copy { width: 100%; color: #252840; margin-top: 4px; }

/* ── 뉴스 오버레이 ── */
.news-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; }
.news-overlay.open { display: block; }

/* ── 뉴스 패널 ── */
.news-panel {
    position: fixed; top: 0; right: 0;
    width: 380px; height: 100vh;
    background: #0a0c14;
    border-left: 1px solid #1a1d2e;
    display: flex; flex-direction: column;
    z-index: 900;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.news-panel.open { transform: translateX(0); }

.np-hd {
    display: flex; align-items: flex-start;
    justify-content: space-between;
    padding: 16px 18px 14px;
    border-bottom: 1px solid #1a1d28;
    flex-shrink: 0;
    background: #0c0e18;
    gap: 12px;
}
.np-hd-left    { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.np-stock-name { font-size: 17px; font-weight: 700; color: #fff; }
.np-stock-meta { display: flex; align-items: center; gap: 8px; }
.np-mkt        { font-size: 10px; font-weight: 700; border-radius: 3px; padding: 2px 5px; }
.np-mkt.kospi  { background: #1a2a4a; color: #5599dd; border: 1px solid #2a3a6a; }
.np-mkt.kosdaq { background: #2a1a10; color: #dd8855; border: 1px solid #4a2a18; }
#npRate { font-size: 14px; font-weight: 700; }

.np-close {
    background: #1a1d2e; border: 1px solid #252840;
    color: #606480; font-size: 11px; font-weight: 600;
    padding: 6px 12px; border-radius: 6px;
    cursor: pointer; white-space: nowrap;
    transition: all .15s; flex-shrink: 0;
}
.np-close:hover { background: #252840; color: #a0a8c0; }

.np-body { flex: 1; overflow-y: auto; padding: 0; background: #0a0c14; }
.np-body::-webkit-scrollbar { width: 3px; }
.np-body::-webkit-scrollbar-track { background: #0f1118; }
.np-body::-webkit-scrollbar-thumb { background: #252840; border-radius: 2px; }

.np-loading {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; padding: 40px 0;
    color: #404468; font-size: 12px;
}
.np-spinner {
    width: 22px; height: 22px;
    border: 2px solid #1e2235;
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.news-item { padding: 14px 18px; border-bottom: 1px solid #141720; cursor: pointer; transition: background .12s; }
.news-item:hover { background: #131620; }
.news-item:last-child { border-bottom: none; }
.ni-source-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ni-source { font-size: 10px; color: #505478; font-weight: 600; }
.ni-time   { font-size: 10px; color: #404060; }
.ni-title  { font-size: 13px; color: #c8ccde; line-height: 1.55; font-weight: 500; margin-bottom: 6px; }
.ni-summary { font-size: 11px; color: #505478; line-height: 1.6; }

.np-item {
    padding: 14px 16px; border-bottom: 1px solid #0f1118;
    cursor: pointer; transition: background .12s; position: relative;
}
.np-item::before {
    content: ''; position: absolute;
    left: 0; top: 0; bottom: 0; width: 3px;
    background: transparent; transition: background .12s;
}
.np-item:hover { background: #0f1220; }
.np-item:hover::before { background: #4a9eff; }
.np-item-title { font-size: 13px; color: #c8cde8; line-height: 1.55; margin-bottom: 6px; font-weight: 500; }
.np-item-desc {
    font-size: 11px; color: #505478; line-height: 1.6; margin-bottom: 6px;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}
.np-item-meta {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 10px; font-weight: 600; color: #4a9eff;
    background: rgba(74,158,255,.1);
    padding: 2px 8px; border-radius: 4px; margin-top: 2px;
}
.np-item-meta::before { display: none; }
.np-empty { color: #404468; font-size: 13px; text-align: center; padding: 40px 0; }
.np-hint { font-size: 10px; color: #303450; padding: 8px 18px; text-align: center; border-top: 1px solid #141720; flex-shrink: 0; }


/* 탭 S8 가로 (821~1300px) — 2컬럼 */
@media (min-width: 821px) and (max-width: 1300px) {
    #grid { grid-template-columns: 1fr 1fr !important; gap: 14px; }

    .col-hd,
    .stock-row {
        grid-template-columns: 1fr 12px 52px 48px 44px 56px 50px !important;
    }

    .s-name      { font-size: 12px !important; }
    .s-cell      { font-size: 11px !important; }
    .s-rate      { font-size: 11px !important; }
    .col-hd span { font-size: 10px !important; }
}

/* PC (1300px 이상) */
@media (min-width: 1300px) {
    #grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }

    .col-hd,
    .stock-row {
        grid-template-columns: 1fr 12px 60px 55px 50px 65px 58px !important;
    }
}
/* ── 반응형 ── */
@media (min-width: 821px) {
    .col-hd,
    .stock-row {
         grid-template-columns: 1fr 12px 55px 50px 46px 58px 52px !important;
    }
}
/* 탭 S8 세로 (800px) */
@media (min-width: 360px) and (max-width: 820px) {
    #grid { grid-template-columns: 1fr !important; gap: 8px; }

    /* 종목명 고정 100px */
    .col-hd,  
    .stock-row {     
     	display: grid;
    	grid-template-columns: minmax(90px, 2fr) 12px repeat(5, 1fr);
    	width: 100%;
     }

    .stock-row .s-name {
        width: 100px !important;
        max-width: 100px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 12px !important;
    }

    .s-cell      { font-size: 11px !important; }
    .s-rate      { font-size: 11px !important; }
    .col-hd span { font-size: 10px !important; }

    .grid { padding: 8px 10px !important; }
}


.rank-arrow-cell        { font-size: 10px; font-weight: 800; text-align: center; flex-shrink: 0; }
.rank-arrow-cell.rank-up { color: #ff6070; }
.rank-arrow-cell.rank-dn { color: #4a9eff; }

.th-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
    white-space: nowrap;
}
.th-name    { font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.th-idx     { font-size: 15px; font-weight: 800; color: #fff; flex-shrink: 0; }
.th-chg     { font-size: 11px; font-weight: 600; flex-shrink: 0; }
.th-chg.up  { color: #ffaaaa; }
.th-chg.dn  { color: #aaccff; }
.th-vol     { font-size: 10px; color: rgba(255,255,255,.5); flex-shrink: 0; }
.th-updated { font-size: 10px; color: rgba(255,255,255,.35); flex-shrink: 0; }
.hot-badge  { margin-left: auto; flex-shrink: 0; }

.th-chg.up { color: #ffaaaa; }
.th-chg.dn { color: #aaccff; }
.th-vol {
    font-size: 11px; color: rgba(255,255,255,.5);
    margin-left: 4px;
}

.th-updated {
    font-size: 10px;
    color: rgba(255,255,255,.4);
    margin-top: 5px;
}

.rank-arrow-cell {
    font-size: 10px;
    font-weight: 800;
    flex-shrink: 0;
    width: 10px;
}
.rank-arrow-cell.rank-up { color: #ff6070; }
.rank-arrow-cell.rank-dn { color: #4a9eff; }