/* ──────────────────────────────────────────────────────────────
   국내주식 현황 페이지 CSS
   코인 페이지(trading_status.css) 스타일 계승
   ────────────────────────────────────────────────────────────── */
:root {
    --c-bg:       #f8fafc;
    --c-card:     #ffffff;
    --c-border:   #e5e7eb;
    --c-title:    #1e293b;
    --c-text:     #374151;
    --c-sub:      #6b7280;
    --c-pos:      #16a34a;
    --c-neg:      #dc2626;
    --c-neu:      #374151;
    --c-warn:     #d97706;
    --c-blue:     #2563eb;
    --c-radius:   10px;
    --c-shadow:   0 1px 4px rgba(0,0,0,.07);
}

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

#sk_wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 12px 40px;
    background: var(--c-bg);
    font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    font-size: 14px;
    color: var(--c-text);
}

/* ── 타이틀 ── */
.sk-page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.sk-page-title h2 { font-size: 20px; font-weight: 800; color: var(--c-title); }

.sk-mode-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 99px;
}
.sk-mode-badge.virtual { background: #eff6ff; color: var(--c-blue); border: 1px solid #bfdbfe; }
.sk-mode-badge.real    { background: #fef2f2; color: var(--c-neg); border: 1px solid #fecaca; }

.sk-live-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--c-pos);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 99px;
    padding: 3px 10px;
}
.sk-live-dot {
    width: 7px; height: 7px;
    background: var(--c-pos);
    border-radius: 50%;
    animation: blink 1.2s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ── 카드 ── */
.sk-card {
    background: var(--c-card);
    border-radius: var(--c-radius);
    border: 1px solid var(--c-border);
    box-shadow: var(--c-shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.sk-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--c-title);
    margin-bottom: 12px;
}
.sk-section-box {
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    padding: 12px;
    margin-top: 12px;
}
.sk-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--c-sub);
    margin-bottom: 10px;
}

/* ── 정보 배너 ── */
.sk-info-banner {
    background: linear-gradient(135deg, #f0f9ff 0%, #eff6ff 100%);
    border: 1px solid #bae6fd;
    border-radius: var(--c-radius);
    padding: 16px;
    margin-bottom: 14px;
}
.sk-info-banner .info-title { font-size: 15px; font-weight: 800; color: var(--c-title); margin-bottom: 12px; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.info-item { background: #fff; border-radius: 8px; padding: 10px 12px; border: 1px solid #e0f2fe; }
.info-item .label { font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--c-title); }
.info-item.visitor .label { color: #0369a1; }
.info-item.member  .label { color: #15803d; }
.info-item.admin   .label { color: #7c3aed; }
.info-item .desc ul { list-style: none; padding: 0; }
.info-item .desc li { font-size: 12px; color: var(--c-sub); padding: 2px 0; }
.info-item .desc li::before { content: '· '; color: #93c5fd; }
.login-msg { font-size: 13px; color: var(--c-sub); text-align: center; }
.login-btn-pill { display: inline-block; background: var(--c-blue); color: #fff; border-radius: 99px; padding: 4px 14px; font-size: 13px; font-weight: 700; text-decoration: none; }

/* ── 시장 현황 ── */
.sk-market-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media(max-width:600px) { .sk-market-grid { grid-template-columns: repeat(2, 1fr); } }
.sk-market-item { background: #f9fafb; border-radius: 8px; padding: 10px 12px; border: 1px solid var(--c-border); text-align: center; }
.sk-market-label { font-size: 11px; color: var(--c-sub); margin-bottom: 4px; font-weight: 600; }
.sk-market-val { font-size: 15px; font-weight: 800; color: var(--c-title); }
.sk-market-chg { font-size: 11px; margin-top: 2px; color: var(--c-sub); }

/* ── 색상 ── */
.pos  { color: var(--c-pos) !important; }
.neg  { color: var(--c-neg) !important; }
.neu  { color: var(--c-neu) !important; }
.warn { color: var(--c-warn) !important; }
.up   { color: var(--c-pos); }
.down { color: var(--c-neg); }

/* ── 수익 요약 ── */
.profit-all-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 4px; }
@media(max-width:600px) { .profit-all-summary { grid-template-columns: repeat(2, 1fr); } }
.profit-all-item { background: #f9fafb; border-radius: 8px; padding: 10px; border: 1px solid var(--c-border); text-align: center; }
.profit-all-label { font-size: 11px; color: var(--c-sub); margin-bottom: 4px; }
.profit-all-val { font-size: 18px; font-weight: 800; }

/* ── 기간별 ── */
.profit-period-wrap { display: flex; gap: 10px; flex-wrap: wrap; }
.profit-period-item { flex: 1; min-width: 80px; background: #fff; border: 1px solid var(--c-border); border-radius: 8px; padding: 10px; text-align: center; }
.profit-period-item .label { font-size: 11px; color: var(--c-sub); margin-bottom: 4px; }
.profit-period-item .pct   { font-size: 16px; font-weight: 700; }
.profit-period-item .cnt   { font-size: 11px; color: var(--c-sub); }

/* ── 종목별 수익률 행 ── */
.profit-coin-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f3f4f6; flex-wrap: wrap; }
.profit-coin-row:last-child { border-bottom: none; }
.profit-coin-name { font-size: 13px; font-weight: 700; color: var(--c-title); min-width: 80px; }
.profit-coin-code { font-size: 11px; color: var(--c-sub); }
.profit-coin-pct  { font-size: 14px; font-weight: 700; min-width: 70px; }
.profit-coin-count{ font-size: 12px; color: var(--c-sub); }
.profit-coin-win  { font-size: 12px; color: var(--c-sub); }
.profit-row-empty { font-size: 12px; color: var(--c-sub); padding: 8px 0; }

/* ── 미니 바 그래프 ── */
.profit-bar-wrap  { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.profit-bar-label { font-size: 12px; font-weight: 700; color: var(--c-title); min-width: 70px; padding-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profit-bars      { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.profit-bar-item  { display: flex; align-items: center; gap: 6px; }
.profit-bar-bg    { flex: 1; height: 10px; background: #f3f4f6; border-radius: 3px; overflow: hidden; }
.profit-bar-fill  { height: 100%; border-radius: 3px; transition: width .3s; }
.profit-bar-fill.pos { background: var(--c-pos); }
.profit-bar-fill.neg { background: var(--c-neg); }
.profit-bar-val   { font-size: 11px; font-weight: 600; min-width: 54px; text-align: right; }

/* ── 거래 내역 ── */
.sk-trade-box { display: flex; flex-direction: column; gap: 1px; max-height: 320px; overflow-y: auto; }
.trade-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; font-size: 12px; flex-wrap: wrap; }
.trade-row:hover { background: #f9fafb; }
.trade-row.empty { color: var(--c-sub); justify-content: center; }
.trade-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.trade-badge.buy  { background: #eff6ff; color: var(--c-blue); }
.trade-badge.sell { background: #fef2f2; color: var(--c-neg); }
.trade-name  { font-weight: 600; color: var(--c-title); min-width: 70px; }
.trade-price { color: var(--c-sub); }
.trade-time  { color: var(--c-sub); margin-left: auto; font-size: 11px; }

/* ── 감시 종목 테이블 ── */
.wl-table-wrap { overflow-x: auto; }
.wl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.wl-table th { background: #f9fafb; padding: 8px 10px; text-align: right; font-weight: 600; color: var(--c-sub); border-bottom: 1px solid var(--c-border); }
.wl-table th:first-child { text-align: left; }
.wl-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid #f3f4f6; }
.wl-table td:first-child { text-align: left; font-weight: 600; }
.wl-table tr:last-child td { border-bottom: none; }
.wl-table tr:hover td { background: #f9fafb; }
.wl-loading, .wl-empty { font-size: 13px; color: var(--c-sub); padding: 12px; text-align: center; }

/* ── 상태바 ── */
.sk-statusbar { display: flex; justify-content: space-between; font-size: 11px; color: var(--c-sub); margin-top: 8px; }
.upd { color: var(--c-blue); font-weight: 600; }

/* ══════════════════════════════════════════════════════════════ */
/* 관리자                                                         */
/* ══════════════════════════════════════════════════════════════ */
.sk-admin-header {
    display: flex; align-items: center; gap: 10px;
    background: linear-gradient(90deg, #1e293b 0%, #334155 100%);
    border-radius: var(--c-radius) var(--c-radius) 0 0;
    padding: 10px 16px;
    margin-top: 6px;
}
.sk-admin-badge { font-size: 12px; font-weight: 700; background: #f59e0b; color: #1e293b; border-radius: 99px; padding: 2px 10px; }

.admin-tab-wrap { display: flex; flex-wrap: wrap; gap: 2px; background: #f3f4f6; border: 1px solid var(--c-border); border-top: none; border-radius: 0 0 0 0; margin-bottom: 0; overflow: hidden; }
.sk-tab-btn { flex: 1; min-width: 80px; padding: 9px 4px; font-size: 12px; font-weight: 600; color: var(--c-sub); background: transparent; border: none; cursor: pointer; transition: .15s; white-space: nowrap; }
.sk-tab-btn:hover { background: #e5e7eb; color: var(--c-title); }
.sk-tab-btn.active { background: var(--c-card); color: var(--c-blue); border-bottom: 2px solid var(--c-blue); }

.sk-admin-panel { display: none; }
.sk-admin-panel.active { display: block; }

/* 시스템 그리드 */
.sys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.sys-hold-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.sys-item { background: #f9fafb; border-radius: 8px; padding: 10px; border: 1px solid var(--c-border); }
.sys-label { font-size: 11px; color: var(--c-sub); margin-bottom: 4px; font-weight: 600; }
.sys-val   { font-size: 14px; font-weight: 700; }
.sys-val.on  { color: var(--c-pos); }
.sys-val.off { color: var(--c-neg); }
.sys-sub   { font-size: 11px; color: var(--c-sub); margin-top: 2px; }

/* 2컬럼 그리드 */
.sk-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width:600px) { .sk-grid-2 { grid-template-columns: 1fr; } }

/* 제어 */
.ctrl-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctrl-row label { font-size: 12px; color: var(--c-sub); white-space: nowrap; min-width: 60px; }
.ctrl-row input { padding: 7px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 13px; }
.ctrl-btn { padding: 7px 14px; border: none; border-radius: 6px; font-size: 13px; font-weight: 700; cursor: pointer; transition: .15s; }
.ctrl-btn:hover { filter: brightness(.92); }
.buy-btn    { background: #eff6ff; color: var(--c-blue); border: 1px solid #bfdbfe; }
.sell-btn   { background: #fef2f2; color: var(--c-neg); border: 1px solid #fecaca; }
.save-btn   { background: #f0fdf4; color: var(--c-pos); border: 1px solid #bbf7d0; }
.pause-btn  { background: #fffbeb; color: var(--c-warn); border: 1px solid #fde68a; }
.resume-btn { background: #f0fdf4; color: var(--c-pos); border: 1px solid #bbf7d0; }
.ctrl-msg { font-size: 12px; padding: 4px 10px; border-radius: 6px; font-weight: 600; }
.ctrl-msg.ok  { background: #f0fdf4; color: var(--c-pos); }
.ctrl-msg.err { background: #fef2f2; color: var(--c-neg); }

/* 파라미터 */
.cfg-section-title { font-size: 12px; font-weight: 700; color: var(--c-sub); margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.cfg-toggle-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.cfg-toggle { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--c-title); cursor: pointer; background: #f9fafb; border: 1px solid var(--c-border); border-radius: 6px; padding: 5px 10px; }
.cfg-toggle input { accent-color: var(--c-blue); }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.cfg-field label { display: block; font-size: 11px; font-weight: 700; color: var(--c-sub); margin-bottom: 4px; }
.cfg-hint { font-weight: 400; color: #9ca3af; }
.cfg-field input { width: 100%; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 13px; color: var(--c-title); }
.cfg-field input:focus { outline: none; border-color: var(--c-blue); box-shadow: 0 0 0 2px #bfdbfe; }
.cfg-desc { font-size: 10px; color: #9ca3af; margin-top: 3px; }

/* 감시 종목 관리 */
.wl-add-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.wl-add-row input { flex: 1; min-width: 100px; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 13px; }
.wl-item { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #f3f4f6; }
.wl-item:last-child { border-bottom: none; }
.wl-code { font-size: 12px; color: var(--c-sub); min-width: 60px; }
.wl-name { flex: 1; font-size: 13px; font-weight: 600; }

/* ── 봇 로그 */
#spanel-log .sk-card {
    padding: 10px 8px 12px;
}

.bot-log-box {
    background: #0f172a;
    border-radius: 8px;
    padding: 14px 12px;
    width: calc(100% + 12px);
    margin: 0 -6px;
    height: 520px;
    max-height: 68vh;
    overflow-y: auto;
    overflow-x: hidden;
    font-family: 'D2Coding', 'Consolas', monospace;
}

.bot-log-row {
    font-size: 12.5px;
    line-height: 1.68;
    padding: 3px 0;
    color: #cbd5e1;
    font-weight: 560;
    letter-spacing: -0.01em;
    white-space: pre-wrap;
    word-break: break-all;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.bot-log-row:last-child {
    border-bottom: none;
}

.bot-log-row.info  { color: #dbeafe; }
.bot-log-row.buy  { color: #93c5fd; }
.bot-log-row.sell { color: #fca5a5; }
.bot-log-row.hold { color: #fde68a; }
.bot-log-row.err  { color: #fecaca; font-weight: 700; }
.bot-log-row.warn { color: #fcd34d; }
.bot-log-row.empty { color: #475569; text-align: center; padding: 20px; }

.log-time {
    color: #93c5fd;
    font-weight: 700;
}

.log-level {
    display: inline-block;
    padding: 1px 6px;
    margin: 0 2px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.level-INFO { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.level-WARNING { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.level-ERROR { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.level-DEBUG { background: rgba(148, 163, 184, 0.18); color: #cbd5e1; }
.level-VIRTUAL { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.level-REAL { background: rgba(244, 63, 94, 0.18); color: #fda4af; }

.log-keyword {
    color: #f8fafc;
    font-weight: 800;
}

.kw-BUY { color: #60a5fa; }
.kw-SELL { color: #f87171; }
.kw-HOLD, .kw-WAIT { color: #fbbf24; }

.log-metric {
    color: #c4b5fd;
    font-weight: 700;
}

.log-percent {
    color: #67e8f9;
    font-weight: 800;
}

.log-number {
    color: #e2e8f0;
    font-weight: 700;
}

.log-flag {
    color: #86efac;
    font-weight: 800;
}

@media (max-width: 600px) {
    #spanel-log .sk-card {
        padding: 8px 4px 10px;
    }

    .bot-log-box {
        width: calc(100% + 16px);
        margin: 0 -8px;
        height: 58vh;
        max-height: none;
        border-radius: 6px;
        padding: 14px 10px;
    }

    .bot-log-row {
        font-size: 13px;
        line-height: 1.72;
    }
}
