:root {
    /* Light Mode (Default) */
    --bg-body: #f4f6f8;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --border-color: #e0e0e0;
    --accent-color: #007bff;
    --accent-blue: #3b82f6;
    --bg-hover: rgba(0,0,0,0.05);
    --sentiment-buy: #e6f4ea;
    --sentiment-sell: #fce8e6;
    --sentiment-strong-buy: #ceead6;
    /* common.css 호환 변수 별칭 (admin.html 공유) */
    --bg: var(--bg-body);
    --card: var(--bg-card);
    --border: var(--border-color);
    --text: var(--text-primary);
    --muted: var(--text-secondary);
    --green: #22c55e;
    --red: #ef4444;
    --blue: #3b82f6;
    --yellow: #eab308;
    --purple: #a855f7;
    --cyan: #06b6d4;
    --orange: #f97316;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #333333;
    --accent-color: #4da3ff;
    --accent-blue: #60a5fa;
    --bg-hover: rgba(255,255,255,0.06);
    --sentiment-buy: #132f1c;
    --sentiment-sell: #3e1b1b;
    --sentiment-strong-buy: #0c3b19;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s, color 0.3s;
    margin: 0;
    font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 60px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    gap: 0;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* 로고 이미지 */
.nav-logo {
    height: 32px;
    width: auto;
    display: block;
}
/* 라이트 모드: 컬러 로고 / 다크 모드: 화이트 로고 */
.nav-logo-dark  { display: none; }
.nav-logo-light { display: block; }
[data-theme="dark"] .nav-logo-dark  { display: block; }
[data-theme="dark"] .nav-logo-light { display: none; }

.badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background-color: var(--accent-color);
    color: white;
    margin-left: 0.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    margin: 0 1rem;
    font-weight: 500;
}

.nav-links a.active, .nav-links a:hover {
    color: var(--accent-color);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-left: auto;
}

#clock, .nav-clock {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Status indicator dot */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: #10b981; box-shadow: 0 0 6px #10b981; }
.dot.off { background: #ef4444; }
.nav-status-text { font-size: 0.75rem; color: var(--text-secondary); }

/* Nav refresh / auto-refresh */
.refresh-btn {
    font-size: 0.75rem; padding: 0.2rem 0.6rem;
    border: 1px solid var(--border-color); border-radius: 4px;
    color: var(--text-secondary); cursor: pointer; background: none;
}
.refresh-btn:hover { border-color: var(--accent-color); color: var(--accent-color); }
.auto-refresh { font-size: 0.75rem; color: var(--text-secondary); }

/* Nav username */
.nav-username { font-size: 0.85rem; font-weight: 500; }

/* Nav logout button */
.nav-logout {
    background: none; border: 1px solid var(--border-color); color: var(--text-secondary);
    padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 0.75rem;
    transition: all 0.2s;
}
.nav-logout:hover { border-color: #ef4444; color: #ef4444; }

/* Role badge variants (matches common.css) */
.badge-admin { background: rgba(77,163,255,0.15); color: var(--accent-color); }
.badge-viewer { background: rgba(95,99,104,0.15); color: var(--text-secondary); }

/* Hamburger button */
.hamburger-btn {
    display: none; font-size: 1.3rem; padding: 4px 8px;
    cursor: pointer; border: none; background: none; color: var(--text-secondary);
}
.hamburger-btn.active { color: var(--text-primary); }

/* Mobile nav dropdown */
.mobile-nav {
    display: none; flex-direction: column;
    background: var(--bg-card); border-bottom: 1px solid var(--border-color);
    padding: 8px 16px; gap: 4px; position: relative; z-index: 100;
}
.mobile-nav.open { display: flex; }
.mobile-nav-item {
    padding: 10px 16px; text-decoration: none; color: var(--text-primary);
    border-radius: 6px; border: none; background: none;
    text-align: left; font-size: 0.9rem; cursor: pointer;
}
.mobile-nav-item:hover { background: var(--bg-body); }

/* Responsive: hamburger on mobile */
@media (max-width: 768px) {
    .hamburger-btn { display: block; }
    .main-tabs { display: none !important; }
    .nav-status-text, .auto-refresh, .nav-clock { display: none; }
    .refresh-btn { display: none; }
    .badge-admin, .badge-viewer { display: none; }
    .nav-logout { display: none; }
    .dot { display: none; }
}

button {
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-primary);
}

.btn-icon {
    font-size: 1.2rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background-color: rgba(0,0,0,0.1);
}

[data-theme="dark"] .btn-icon:hover {
    background-color: rgba(255,255,255,0.1);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-body);
    color: var(--text-secondary);
}

.btn-sm.active {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* panel-header 우측 그룹 (토글 + Updated 뱃지) */
.panel-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 업종/테마 세그먼트 토글 */
.group-toggle {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.btn-toggle {
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 500;
    border: none;
    background-color: var(--bg-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.btn-toggle + .btn-toggle {
    border-left: 1px solid var(--border-color);
}

.btn-toggle.active {
    background-color: var(--accent-color);
    color: white;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 60px);
    box-sizing: border-box;
}

.panel {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    position: relative; /* Context for absolute children */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 700;
}
/* Panel slide toggle */
.panel-slide-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}
.panel-slide-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.panel-show-tab {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-lr;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 8px 3px;
    border-radius: 4px;
    z-index: 5;
}
.panel-show-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.panel-show-left { left: 0; }
.panel-show-right { right: 0; }
.dashboard-grid.hide-left {
    grid-template-columns: 0 1fr 280px;
}
.dashboard-grid.hide-right {
    grid-template-columns: 280px 1fr 0;
}
.dashboard-grid.hide-left.hide-right {
    grid-template-columns: 0 1fr 0;
}
.dashboard-grid.hide-left .market-intel { display: none; }
.dashboard-grid.hide-left .panel-show-left { display: block; }
.dashboard-grid.hide-right .index-monitor { display: none; }
.dashboard-grid.hide-right .panel-show-right { display: block; }

.controls {
    display: flex;
    gap: 0.25rem;
}

/* ── Ranking 2-Split Layout ── */
.ranking-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.flow-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin-top: 16px;
}

/* 세로 구분선: 우측 열에 left border */
.ranking-col + .ranking-col,
.flow-col + .flow-col {
    border-left: 1px solid var(--border-color);
    padding-left: 12px;
}
.ranking-col:first-child,
.flow-col:first-child {
    padding-right: 12px;
}

/* 컬러 악센트 헤더 */
.ranking-col h3, .flow-col h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    margin-top: 0;
    padding-left: 8px;
}

/* 테마 = blue 악센트 */
.ranking-col:first-child h3,
.flow-col:first-child h3 {
    border-left: 3px solid #4da3ff;
}

/* 업종 = purple 악센트 */
.ranking-col + .ranking-col h3,
.flow-col + .flow-col h3 {
    border-left: 3px solid #cc5de8;
}

/* ── Market Score Inline (quant-lab 내부) ── */
.mkt-scoring-inline {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}
.mkt-scoring-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
.mkt-scoring-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 4px 0;
    padding-left: 8px;
    border-left: 3px solid #6366f1;
}
.mkt-scoring-card .strat-compact-table { font-size: 0.7rem; }
.mkt-scoring-card .strat-compact-table thead th { padding: 3px 4px; }
.mkt-scoring-card .strat-compact-table tbody td { padding: 3px 4px; }

.flow-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

/* 각 열 내부 카드: auto-fill (랭킹 영역 너비에 맞게 자동 배치) */
.ranking-col .theme-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* ── Theme Sort Toggle ── */
.tc-sort-toggle {
    display: inline-flex;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.7rem;
    margin-left: auto;
}
.tc-sort-btn {
    padding: 2px 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}
.tc-sort-btn.active {
    background: var(--accent-color, #6366f1);
    color: #fff;
}
.tc-sort-btn:hover:not(.active) {
    background: rgba(99,102,241,0.15);
}

/* ── Theme Cards Grid ── */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    align-content: start;
}

.tc-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    overflow: hidden;
}
.tc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
[data-theme="dark"] .tc-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

/* ── Card Header ── */
.tc-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.tc-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    flex-shrink: 0;
}
/* 등락률 기반 순위 박스 색상 */
.tc-rank.tc-rank-strong-up { background: linear-gradient(135deg, #ef4444, #dc2626); }
.tc-rank.tc-rank-up        { background: linear-gradient(135deg, #f87171, #ef4444); }
.tc-rank.tc-rank-down      { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.tc-rank.tc-rank-strong-down { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.tc-rank-delta {
    font-size: 0.65rem;
    font-weight: 700;
    margin-left: 2px;
    flex-shrink: 0;
}
.tc-rank-delta.delta-new  { color: #f59e0b; }
.tc-rank-delta.delta-up   { color: var(--red, #ef4444); }
.tc-rank-delta.delta-down { color: var(--blue, #3b82f6); }
.tc-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.tc-header-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}
.tc-amount-badge {
    font-size: 0.68rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    padding: 0.1rem 0.4rem 0.2rem;
    border-radius: 4px;
    background: #ef4444;
    color: #fff;
    white-space: nowrap;
}
.tc-badge {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: monospace;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    white-space: nowrap;
}
.tc-badge.up { color: #dc2626; background: rgba(220,38,38,0.08); }
.tc-badge.down { color: #2563eb; background: rgba(37,99,235,0.08); }

/* ── Stock List ── */
.tc-stocks {
    padding: 0.1rem 0;
}
.tc-stock-row {
    padding: 0.25rem 0.75rem;
    transition: background-color 0.15s;
}
.tc-stock-row:hover {
    background-color: rgba(0,0,0,0.02);
}
[data-theme="dark"] .tc-stock-row:hover {
    background-color: rgba(255,255,255,0.03);
}
.tc-stock-row + .tc-stock-row {
    border-top: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
}
.tc-stock-row.tc-highlight {
    background: linear-gradient(90deg, rgba(239,68,68,0.06), rgba(239,68,68,0.02));
    border-left: 2px solid #ef4444;
}
[data-theme="dark"] .tc-stock-row.tc-highlight {
    background: linear-gradient(90deg, rgba(239,68,68,0.12), rgba(239,68,68,0.04));
}
.tc-stock-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.tc-stock-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.1rem;
}
.tc-stock-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}
.tc-stock-pct {
    font-size: 0.75rem;
    font-weight: 700;
    font-family: monospace;
}
.tc-stock-pct.up { color: #dc2626; }
.tc-stock-pct.down { color: #2563eb; }
.tc-stock-pct.muted { color: var(--text-secondary); font-weight: 400; }
.tc-stock-price {
    font-size: 0.72rem;
    font-family: monospace;
    color: var(--text-secondary);
}
.tc-stock-amount {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-family: monospace;
}

/* ── Horizontal Candlestick Bar ── */
.tc-candle-track {
    position: relative;
    height: 6px;
    background: color-mix(in srgb, var(--border-color) 60%, transparent);
    border-radius: 3px;
    margin-top: 0.2rem;
    overflow: visible;
}
.tc-candle-center {
    position: absolute;
    left: 50%;
    top: -4px;
    width: 1px;
    height: calc(100% + 8px);
    background: var(--text-secondary);
    opacity: 0.5;
    z-index: 3;
}
.tc-candle-wick {
    position: absolute;
    top: 50%;
    height: 1px;
    transform: translateY(-50%);
    z-index: 1;
}
.tc-candle-wick.up { background: #dc2626; }
.tc-candle-wick.down { background: #2563eb; }
.tc-candle-body {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 3px;
    z-index: 2;
    transition: left 0.3s ease, width 0.3s ease;
}
.tc-candle-body.up { background: #dc2626; }
.tc-candle-body.down { background: #2563eb; }

/* ── Hidden rows (collapsed → expanded by .tc-expanded on parent card) ── */
.tc-card:not(.tc-expanded) .tc-stock-row.tc-hidden {
    display: none;
}

/* ── More Link ── */
.tc-more {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 0.2rem 0.75rem 0.3rem;
    cursor: pointer;
    border-top: 1px dashed var(--border-color);
    transition: color 0.15s;
    letter-spacing: 0.02em;
}
.tc-more:hover {
    color: var(--accent-color);
}
.tc-card.tc-expanded .tc-more {
    color: var(--accent-color);
    border-top-style: solid;
}

/* Drawer */
.drawer {
    position: fixed;
    top: 60px; /* Below navbar */
    right: -400px;
    width: 400px;
    height: calc(100% - 60px);
    background-color: var(--bg-card);
    box-shadow: -4px 0 10px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    padding: 1.5rem;
    border-left: 1px solid var(--border-color);
    box-sizing: border-box;
}

.drawer.open {
    right: 0;
}

/* Utils & Empty States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 150px;
    color: var(--text-secondary);
    font-style: normal;
    opacity: 0.7;
}

.loading::before {
    content: '☁️'; /* Fallback icon */
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* NSI Feed */
.nsi-feed {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.75rem;
}

.nsi-card {
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    border-left: 3px solid var(--border-color);
    background-color: var(--bg-body);
}

.nsi-card.nsi-positive { border-left-color: #dc2626; }
.nsi-card.nsi-negative { border-left-color: #2563eb; }
.nsi-card.nsi-neutral  { border-left-color: var(--text-secondary); }

.nsi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
    gap: 0.4rem;
}

.nsi-header-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.nsi-name-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    flex: 1;
}
.nsi-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.nsi-name-clickable {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.nsi-name-clickable:hover { color: #3b82f6; text-decoration: underline; }

.nsi-change-rate {
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* Candle row inside NSI card */
.nsi-candle-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.nsi-candle-price {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 52px;
}

.nsi-candle-track {
    flex: 1;
    height: 10px;
    margin-top: 0 !important;
}

.nsi-score-label {
    font-size: 0.7rem;
    font-weight: 700;
    font-family: monospace;
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.nsi-score-label.positive { color: #dc2626; }
.nsi-score-label.negative { color: #2563eb; }
.nsi-score-label.neutral  { color: var(--text-secondary); }

/* Score Bar */
.nsi-bar-track {
    position: relative;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    margin-bottom: 0.35rem;
    overflow: hidden;
}

.nsi-bar-center {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--text-secondary);
    opacity: 0.4;
}

.nsi-bar-fill {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.nsi-bar-fill.positive {
    left: 50%;
    background: linear-gradient(90deg, #dc2626, #b91c1c);
}

.nsi-bar-fill.negative {
    right: 50%;
    background: linear-gradient(270deg, #2563eb, #1d4ed8);
}

.nsi-events {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.nsi-event {
    font-size: 0.72rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.event-type {
    display: inline-block;
    font-size: 0.6rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background-color: var(--border-color);
    color: var(--text-primary);
    margin-right: 0.25rem;
    font-weight: 600;
    vertical-align: middle;
}
.event-type.event-positive { background: rgba(220,38,38,0.12); color: #dc2626; }
.event-type.event-negative { background: rgba(37,99,235,0.12); color: #2563eb; }
.event-type.event-neutral  { background: var(--border-color); color: var(--text-secondary); }
[data-theme="dark"] .event-type.event-positive { color: #f87171; }
[data-theme="dark"] .event-type.event-negative { color: #60a5fa; }

.nsi-event-link {
    color: var(--text-secondary);
    text-decoration: none;
}
.nsi-event-link:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* AI 분석 요약 버튼 */
.nsi-ai-btn {
    background: none;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1.3;
    letter-spacing: 0.02em;
    transition: background 0.15s, color 0.15s;
}
.nsi-ai-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

/* AI 분석 오버레이 */
.nsi-ai-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.nsi-ai-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.nsi-ai-overlay.active .nsi-ai-panel {
    transform: translateY(0);
}
.nsi-ai-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
}
.nsi-ai-panel {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--bg-card);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.25);
    padding: 0;
    transform: translateY(20px);
    transition: transform 0.25s ease;
}
@media (min-width: 600px) {
    .nsi-ai-overlay { align-items: center; }
    .nsi-ai-panel {
        border-radius: 12px;
        max-height: 70vh;
    }
}
.nsi-ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}
.nsi-ai-panel-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 0.9rem;
}
.nsi-ai-panel-title span:first-child {
    background: var(--accent-color);
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
}
.nsi-ai-panel-score {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}
.nsi-ai-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}
.nsi-ai-close:hover { color: var(--text-primary); }

/* 종합 판단 */
.nsi-ai-summary {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.nsi-ai-summary-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}
.nsi-ai-summary-text {
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--text-primary);
}

/* 개별 뉴스 분석 */
.nsi-ai-events-list {
    padding: 0.6rem 1rem 1rem;
}
.nsi-ai-events-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.nsi-ai-event-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}
.nsi-ai-event-row:last-child { border-bottom: none; }
.nsi-ai-event-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}
.nsi-ai-event-score {
    font-weight: 700;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
.nsi-ai-event-type {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(128,128,128,0.12);
    color: var(--text-secondary);
}
.nsi-ai-event-meta {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}
.nsi-ai-event-novelty {
    font-size: 0.62rem;
    color: var(--text-secondary);
}
.nsi-ai-event-headline {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0.2rem;
}
.nsi-ai-event-reasoning {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.nsi-updated {
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 400;
    padding: 0;
    margin-left: auto;
}

/* Drawer content */
.drawer .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.drawer-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.btn-close {
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.btn-close:hover {
    color: var(--text-primary);
}

.drawer-stock-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.drawer-stock-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
}

.drawer-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.drawer-stock-item:hover {
    background-color: var(--bg-body);
}

.drawer-stock-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.drawer-stock-code {
    font-size: 0.75rem;
    font-family: monospace;
    color: var(--text-secondary);
}

/* Mobile Tabbar */
.mobile-tabbar {
    display: none;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.mobile-tab {
    flex: 1;
    padding: 0.6rem 0;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.mobile-tab.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
}

/* Responsive adjustments — legacy rules (overridden by bottom breakpoints) */
@media (max-width: 900px) {
    .mobile-tabbar { display: flex; }
    #mobile-tabbar {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bg-card);
    }
}

@media (max-width: 480px) {
    #clock { display: none; }
    .theme-grid { grid-template-columns: 1fr !important; }
}

/* ── 메인 탭 네비게이션 ── */
.main-tabs {
    display: flex;
    gap: 4px;
    padding: 0 1rem;
    flex: 1;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}
.main-tab-btn {
    padding: 0.4rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-block;
}
.main-tab-btn:hover { color: var(--text-primary); background: rgba(128,128,128,0.1); }
.main-tab-btn.active { color: var(--accent-color); background: rgba(128,128,128,0.12); font-weight: 600; }

[data-theme="dark"] .main-tab-btn { color: rgba(255,255,255,0.6); }
[data-theme="dark"] .main-tab-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
[data-theme="dark"] .main-tab-btn.active { color: #fff; background: rgba(255,255,255,0.15); }

/* ── 서브탭 (트레이딩 내부) ── */
.sub-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.sub-tab-btn {
    padding: 0.5rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.sub-tab-btn:hover { color: var(--text-primary); }
.sub-tab-btn.active { color: var(--accent-color); border-bottom-color: #6366f1; }

[data-theme="dark"] .sub-tab-btn { color: rgba(255,255,255,0.5); }
[data-theme="dark"] .sub-tab-btn.active { color: #fff; }

/* ── 시장분석 모바일 서브탭 ── */
.market-subtabs { display: none; }

@media (max-width: 900px) {
    .market-subtabs {
        display: flex;
        gap: 0;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 0.5rem;
        padding: 0 0.5rem;
    }
    .market-subtab {
        flex: 1;
        padding: 0.6rem 0.5rem;
        background: transparent;
        border: none;
        border-bottom: 2px solid transparent;
        color: var(--text-secondary);
        font-size: 0.82rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.15s;
        text-align: center;
    }
    .market-subtab:hover { color: var(--text-primary); }
    .market-subtab.active { color: var(--accent-color); border-bottom-color: #6366f1; font-weight: 600; }

    [data-theme="dark"] .market-subtab { color: rgba(255,255,255,0.5); }
    [data-theme="dark"] .market-subtab.active { color: #fff; }

    /* 패널 전환은 app.js가 inline style로 직접 제어 */
}

/* ── Trading Subtabs ── */
.trading-subtabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}
.trading-subtab {
    padding: 0.6rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}
.trading-subtab:hover { color: var(--text-primary); }
.trading-subtab.active { color: var(--accent-color); border-bottom-color: #6366f1; font-weight: 600; }

[data-theme="dark"] .trading-subtab { color: rgba(255,255,255,0.5); }
[data-theme="dark"] .trading-subtab.active { color: #fff; }

/* Desktop: 매매내역 | 전략 2탭만 표시, 중간 탭 숨김 */
.trading-subtab[data-panel="history"],
.trading-subtab[data-panel="topscore"] { display: none; }

@media (max-width: 900px) {
    /* Mobile: 4탭 모두 표시 */
    .trading-subtab { flex: 1; font-size: 0.82rem; }
    .trading-subtab[data-panel="history"],
    .trading-subtab[data-panel="topscore"] { display: block; }
}

/* ── 페이지 패널 ── */
.page-panel { display: none; }
.page-panel.active { display: block; }

/* ── 트레이딩 서브탭 섹션 ── */
#page-trading .drawer-section { display: none; }
#page-trading .drawer-section.active { display: block; }

/* ── StockDrawer ── */
.stock-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 50vw;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1001;
    padding: 1rem;
    padding-bottom: 2rem;
    color: var(--text-primary);
    box-sizing: border-box;
}
.stock-drawer.open { transform: translateX(0); }
.stock-drawer .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.stock-drawer .drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
}
.stock-drawer .drawer-close:hover { color: var(--text-primary); }
.stock-drawer .drawer-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.stock-drawer .drawer-tab-btn {
    flex: 1;
    padding: 0.4rem 0;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s;
}
.stock-drawer .drawer-tab-btn:hover { color: var(--text-primary); }
.stock-drawer .drawer-tab-btn.active { color: var(--text-primary); font-weight: 600; border-bottom-color: #6366f1; }
.stock-drawer .drawer-section { display: none; }
.stock-drawer .drawer-section.active { display: block; }
.drawer-stock-code { color: var(--text-secondary); font-size: 0.75rem; }

/* ── stat-box ── */
.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
}
[data-theme="dark"] .stat-box { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.08); }
.stat-label { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 2px; }

/* ──────────────────────────────────────────
   CSS Variable Aliases (for trading.js statCard compat)
   ────────────────────────────────────────── */
:root {
    --surface: var(--bg-body);
    --border: var(--border-color);
    --text: var(--text-primary);
}

/* ──────────────────────────────────────────
   Toast Notification System
   ────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
    max-width: 360px;
    min-width: 220px;
    color: #fff;
}
.toast.toast-visible { opacity: 1; transform: translateY(0); }
.toast-success { background: #059669; }
.toast-error   { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info    { background: #2563eb; }
.toast-icon    { font-size: 0.9rem; flex-shrink: 0; }
.toast-msg     { flex: 1; line-height: 1.4; }
.toast-close   {
    background: none; border: none; color: rgba(255,255,255,0.8);
    font-size: 1.1rem; cursor: pointer; padding: 0; line-height: 1;
    flex-shrink: 0;
}
.toast-close:hover { color: #fff; }

@media (max-width: 640px) {
    #toast-container {
        left: 0; right: 0; bottom: 0;
        padding: 0.75rem;
    }
    .toast { max-width: 100%; border-radius: 6px; }
}

/* ──────────────────────────────────────────
   Sell Modal
   ────────────────────────────────────────── */
.sell-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0,0,0,0.55);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.sell-modal.open { display: flex; }

.sell-modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.sell-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.sell-modal-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}
.sell-modal-qty-display {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.sell-modal-close-btn {
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 1.2rem; cursor: pointer; padding: 0.2rem;
}
.sell-modal-close-btn:hover { color: var(--text-primary); }

.sell-modal-preset-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
.qty-preset-btn {
    flex: 1;
    padding: 0.45rem 0;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.qty-preset-btn.active, .qty-preset-btn:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239,68,68,0.06);
}

.sell-modal-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.sell-qty-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    text-align: right;
    outline: none;
}
.sell-qty-input:focus { border-color: var(--accent-color); }
.sell-qty-unit { font-size: 0.9rem; color: var(--text-secondary); flex-shrink: 0; }

.sell-modal-actions { display: flex; gap: 0.5rem; }
.sell-modal-btn-confirm {
    flex: 1;
    padding: 0.65rem;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.sell-modal-btn-confirm:hover { background: #dc2626; }
.sell-modal-btn-confirm:disabled { background: #aaa; cursor: not-allowed; }

/* ──────────────────────────────────────────
   SSE Live Status
   ────────────────────────────────────────── */
.sse-live {
    font-size: 0.7rem;
    font-weight: 600;
    color: #10b981;
    font-variant-numeric: normal;
}
.sse-live.offline { color: var(--text-secondary); }

/* ──────────────────────────────────────────
   Portfolio Stats Hero Grid
   ────────────────────────────────────────── */
.portfolio-stats-grid {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
@media (max-width: 640px) {
    .portfolio-stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ──────────────────────────────────────────
   Market Status Badge (nav)
   ────────────────────────────────────────── */
.market-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}
.market-badge-open   { background: rgba(16,185,129,0.15); color: #10b981; }
.market-badge-closed { background: rgba(160,160,160,0.15); color: var(--text-secondary); }
.market-badge-pre    { background: rgba(245,158,11,0.15); color: #f59e0b; }
.market-badge-nxt     { background: #7c3aed; color: #fff; }
.market-badge-holiday { background: #ef4444; color: #fff; }
.market-badge-pre.blink { animation: badge-blink 0.8s infinite; }
@keyframes badge-blink { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ──────────────────────────────────────────
   Holdings Mobile Card View
   ────────────────────────────────────────── */
.holding-cards { display: none; flex-direction: column; gap: 0.6rem; }
.holding-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
}
.hc-top, .hc-middle, .hc-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hc-top { margin-bottom: 0.3rem; }
.hc-middle { margin-bottom: 0.2rem; }
.hc-name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.hc-rate { font-size: 0.85rem; font-weight: 600; }
.hc-price { font-size: 1rem; font-weight: 600; color: var(--text-primary); font-family: 'Inter', monospace; }
.hc-pnl  { font-size: 0.85rem; font-weight: 600; }
.hc-buy  { font-size: 0.75rem; color: var(--text-secondary); }
.hc-pct  { font-size: 0.85rem; font-weight: 600; }
.hc-candle  { margin-top: 0.5rem; padding: 0 0.2rem; }
.hc-candle .tc-candle-wrap { width: 100% !important; }
.hc-candle .tc-candle-track { height: 12px; margin-top: 0; background: rgba(128,128,128,0.25); }
.hc-actions { margin-top: 0.5rem; }
.hc-actions .sell-btn {
    width: 100%; padding: 0.45rem;
    background: #ef4444; color: #fff;
    border: none; border-radius: 6px;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.hc-actions .sell-btn:hover { background: #dc2626; }

@media (max-width: 640px) {
    .holding-table { display: none; }
    .holding-cards { display: flex; }
}

/* ──────────────────────────────────────────
   Macro Tab Responsive Classes
   ────────────────────────────────────────── */
.macro-root { padding: 1rem; }
.macro-index-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.macro-chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.macro-sector-heatmap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0.75rem;
}
.macro-panel-mb { margin-bottom: 1rem; }

@media (max-width: 768px) {
    .macro-index-grid { grid-template-columns: repeat(4, 1fr); }
    .macro-chart-row  { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .macro-index-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── S&P 500 Treemap ── */
.treemap-container { width: 100%; overflow: hidden; }
.treemap-list-fallback { display: none; }
@media (max-width: 640px) {
    .treemap-container { display: none; }
    .treemap-list-fallback { display: block; }
}

/* ──────────────────────────────────────────
   Score Mini Bars (trading tab)
   ────────────────────────────────────────── */
.score-mini-wrap {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-top: 2px;
    overflow: hidden;
}
.score-mini-bar {
    height: 100%;
    background: #6366f1;
    border-radius: 2px;
    min-width: 2px;
    transition: width 0.3s ease;
}
.score-row-above { background: rgba(99,102,241,0.08); }
[data-theme="dark"] .score-row-above { background: rgba(99,102,241,0.15); }

/* ──────────────────────────────────────────
   NSI Sentiment Pill
   ────────────────────────────────────────── */
.nsi-sentiment-pill {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.12rem 0.4rem;
    border-radius: 20px;
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.nsi-sentiment-very-positive { background: rgba(220,38,38,0.15); color: #dc2626; }
.nsi-sentiment-positive       { background: rgba(239,68,68,0.12); color: #ef4444; }
.nsi-sentiment-neutral         { background: rgba(160,160,160,0.15); color: var(--text-secondary); }
.nsi-sentiment-negative        { background: rgba(37,99,235,0.12); color: #2563eb; }
.nsi-sentiment-very-negative   { background: rgba(29,78,216,0.15); color: #1d4ed8; }

/* ──────────────────────────────────────────
   Signal Feed
   ────────────────────────────────────────── */
.signal-feed { display: flex; flex-direction: column; gap: 0.4rem; padding-top: 0.5rem; }
.signal-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    border-left: 3px solid var(--border-color);
    background: var(--bg-body);
    font-size: 0.78rem;
}
.signal-item.buy  { border-left-color: #ef4444; background: rgba(239,68,68,0.04); }
.signal-item.sell { border-left-color: #3b82f6; background: rgba(59,130,246,0.04); }
[data-theme="dark"] .signal-item.buy  { background: rgba(239,68,68,0.07); }
[data-theme="dark"] .signal-item.sell { background: rgba(59,130,246,0.07); }

.signal-time    { font-size: 0.68rem; color: var(--text-secondary); flex-shrink: 0; min-width: 50px; font-family: monospace; }
.signal-content { flex: 1; display: flex; align-items: center; gap: 0.3rem; min-width: 0; overflow: hidden; }
.signal-type    { font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.signal-stock   { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-right   { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.signal-price   { font-size: 0.73rem; color: var(--text-secondary); font-family: monospace; }

/* ──────────────────────────────────────────
   Signal Strength Badges
   ────────────────────────────────────────── */
.signal-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    letter-spacing: 0.03em;
}
.signal-badge-strong { background: rgba(239,68,68,0.15); color: #ef4444; }
.signal-badge-medium { background: rgba(245,158,11,0.15); color: #f59e0b; }
.signal-badge-weak   { background: rgba(160,160,160,0.15); color: var(--text-secondary); }
.signal-icon-buy  { color: #ef4444; font-size: 0.75rem; margin-right: 2px; }
.signal-icon-sell { color: #3b82f6; font-size: 0.75rem; margin-right: 2px; }

/* ──────────────────────────────────────────
   Responsive Layout Overhaul
   ────────────────────────────────────────── */

/* ≥1101px — 3열: 280px Score + 1fr center + 280px NSI */
@media (min-width: 1101px) {
    .dashboard-grid {
        grid-template-columns: 280px 1fr 280px;
    }
    .market-intel { display: flex !important; }
}

/* 1100px — 2열: Score+center / NSI 아래로 */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 260px 1fr;
    }
    .market-intel {
        grid-column: 1 / -1;
        max-height: 300px;
    }
    .ranking-split, .flow-split {
        grid-template-columns: 1fr !important;
    }
    .ranking-col + .ranking-col,
    .flow-col + .flow-col {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid var(--border-color);
        padding-top: 12px;
        margin-top: 12px;
    }
    .ranking-col:first-child,
    .flow-col:first-child {
        padding-right: 0;
    }
    .mkt-scoring-split { grid-template-columns: 1fr; }
}

/* 900px 이하 — market-intel 내부 스크롤 제거 (모바일 서브탭 단독 표시) */
@media (max-width: 900px) {
    .market-intel {
        max-height: none;
        overflow-y: visible;
    }
}

/* 768px 이하 — 1열 */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* 640–1023px — 1열, mobile tabbar 표시 */
@media (max-width: 1023px) {
    body { overflow: auto; height: auto; min-height: 100vh; }
    .dashboard-grid {
        height: auto;
        overflow-y: visible;
    }
}

/* StockDrawer 모바일 전폭 */
@media (max-width: 768px) {
    .stock-drawer {
        width: 100vw;
        box-sizing: border-box;
        left: 0;
        right: 0;
    }
}

/* StockDrawer 하단 시트 (≤640px) */
@media (max-width: 640px) {
    #stock-drawer {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        top: auto !important;
        width: 100% !important;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-top: 1px solid var(--border-color);
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }
    #stock-drawer.open { transform: translateY(0); }
    .drawer-handle {
        width: 40px; height: 4px;
        background: var(--text-secondary);
        border-radius: 2px;
        margin: 8px auto;
    }
}

/* 640px 이하 테마 카드 간소화 + Apple HIG 최소 터치 영역 */
@media (max-width: 640px) {
    .tc-candle-track { height: 4px; }
    .tc-header { padding: 0.35rem 0.6rem; }
    .tc-stock-row { min-height: 44px; padding: 0.5rem 0.75rem; }
    .tc-stock-name { font-size: 0.85rem; }
    .theme-grid { gap: 0.5rem; }
    .navbar { padding: 0 0.75rem; }
    .nav-brand { font-size: 1rem; }
    /* AI News 오른쪽 잘림 방지 */
    .panel { min-width: 0; overflow-x: hidden; }
    .nsi-card { box-sizing: border-box; max-width: 100%; }
    .nsi-header-right { flex-shrink: 1; min-width: 0; }
    .nsi-sentiment-pill { white-space: nowrap; }
}

/* Sub-tab 모바일 스크롤 */
@media (max-width: 640px) {
    .sub-tabs { overflow-x: auto; white-space: nowrap; }
    .sub-tab-btn { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
}

/* ══════════════════════════════════════════
   Trading Dashboard Grid
   ══════════════════════════════════════════ */

#page-trading {
    overflow-y: auto;
    height: auto;
    min-height: calc(100vh - 56px);
}

.trading-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto;
    gap: 0.75rem;
    padding: 0.75rem;
    box-sizing: border-box;
    min-height: 0;
}

.trading-left {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.trading-center {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    overflow-y: visible;
}


.trd-pnl-panel {
    flex-shrink: 0;
    height: auto;
    overflow: visible;
}

.trd-scroll {
    flex: 1 1 0;
    overflow-y: auto;
    min-height: 0;
}

.trd-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
    flex-shrink: 0;
}

/* ── Portfolio Hero Card ── */
.trd-hero-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59,130,246,0.05) 100%);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

[data-theme="dark"] .trd-hero-card {
    background: linear-gradient(135deg, #1e2a3a 0%, #1a1a2e 100%);
    border-color: rgba(59,130,246,0.2);
}

.trd-hero-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
    letter-spacing: 0.03em;
}

.trd-hero-pct {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.trd-hero-amt {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
}

.trd-hero-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* ── Stat Row ── */
.trd-stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    flex-shrink: 0;
    margin-bottom: 0.25rem;
}

.trd-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    text-align: center;
}

.trd-stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.trd-stat-val {
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* ── Auto Strategy Status ── */
.trd-auto-status {
    padding: 0.5rem 0.75rem;
    background: rgba(16,185,129,0.05);
    border-top: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.trd-strategy-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.trd-strategy-name {
    font-weight: 600;
    color: var(--text-primary);
}

.trd-strategy-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: rgba(16,185,129,0.15);
    color: #10b981;
    letter-spacing: 0.02em;
}

.trd-strategy-meta {
    color: var(--text-secondary);
    margin-top: 0.15rem;
    font-size: 0.7rem;
}

/* ── History List ── */
.trd-hist-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.25rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.78rem;
    transition: background 0.12s;
}

.trd-hist-item:hover { background: var(--bg-hover); border-radius: 4px; }

.trd-hist-time {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-family: monospace;
    flex-shrink: 0;
    min-width: 34px;
}

.trd-hist-badge {
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    flex-shrink: 0;
    letter-spacing: 0.03em;
}

.trd-hist-badge.buy  { background: rgba(239,68,68,0.15);  color: #ef4444; }
.trd-hist-badge.sell { background: rgba(59,130,246,0.15); color: #3b82f6; }

.trd-hist-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-primary);
}

.trd-hist-detail {
    font-size: 0.68rem;
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}

/* ── Score List ── */
.trd-score-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.25rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.78rem;
    transition: background 0.12s;
}

.trd-score-item:hover { background: var(--bg-hover); border-radius: 4px; }

.trd-score-above {
    background: rgba(239,68,68,0.04);
}

[data-theme="dark"] .trd-score-above {
    background: rgba(239,68,68,0.07);
}

.trd-score-rank {
    font-size: 0.68rem;
    color: var(--text-secondary);
    min-width: 18px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.trd-score-info {
    flex: 1;
    min-width: 0;
}

.trd-score-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.15rem;
}

.trd-score-star {
    color: #f59e0b;
    font-size: 0.7rem;
}

.trd-score-val {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ── Trading Responsive ── */
@media (max-width: 1280px) {
    .trading-grid {
        grid-template-columns: 260px 1fr;
    }
}

@media (max-width: 768px) {
    .trading-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    .trading-left  { grid-column: 1; grid-row: 1; max-height: none; }
    .trading-center { grid-column: 1; grid-row: 2; }
    .trd-stat-row { grid-template-columns: repeat(3, 1fr); }
    .holding-table { display: none; }
    .holding-cards { display: flex !important; }
    #page-trading { height: auto; overflow-y: visible; }
}

/* ── Index Monitor ── */
.index-monitor {
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.idx-card {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.idx-card:last-child { border-bottom: none; }

.idx-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.idx-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}
.idx-time {
    font-size: 0.65rem;
    color: var(--text-secondary);
}
.idx-card-body {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 4px;
}
.idx-price {
    font-size: 0.95rem;
    font-weight: 700;
}
.idx-change {
    font-size: 0.75rem;
    font-weight: 500;
}
.idx-change.up { color: #dc2626; }
.idx-change.dn { color: #3b82f6; }
.idx-price.up  { color: #dc2626; }
.idx-price.dn  { color: #3b82f6; }
.idx-sparkline {
    width: 100%;
}
.idx-sparkline canvas {
    width: 100% !important;
    height: 50px !important;
}
.idx-spark-time {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-muted, #888);
    padding: 0 2px;
    line-height: 1;
}

.score-panel-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.3rem;
}
.score-nxt-weight {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.score-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.78rem;
}
.score-item:hover { background: var(--bg-hover); }
.score-rank {
    width: 1.4rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
    flex-shrink: 0;
}
.score-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.score-total {
    font-weight: 700;
    color: var(--accent-blue);
    min-width: 2.5rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
}
.score-nxt-icon { font-size: 0.7rem; width: 1rem; text-align: center; }
.score-nxt-match { color: #22c55e; }
.score-nxt-miss  { color: #ef4444; }
.score-nxt-none  { color: var(--text-secondary); }
.score-session-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-weight: 600;
}
.score-session-pre    { background: rgba(245,158,11,0.15); color: #f59e0b; }
.score-session-market { background: rgba(34,197,94,0.15);  color: #22c55e; }
.score-session-post   { background: rgba(139,92,246,0.15); color: #8b5cf6; }

/* ── Score Card (NSI-style) ── */
.score-feed { padding-top: 0.15rem; gap: 0.3rem; }
.score-card { cursor: pointer; padding: 0.4rem 0.6rem; }
.score-card .nsi-header { margin-bottom: 0.15rem; }
.score-card .nsi-name { flex: 1; text-align: left; }
.score-card.score-tier-high { border-left-color: #22c55e; }
.score-card.score-tier-mid  { border-left-color: #f59e0b; }
.score-card.score-tier-low  { border-left-color: var(--text-secondary); }

.score-card-rank {
    font-size: 0.65rem;
    color: var(--text-secondary);
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

/* 헤더 상승률 텍스트 */
.score-card-rate {
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.score-card-rate.up { color: #ef4444; }
.score-card-rate.dn { color: #3b82f6; }

/* 점수 pill (nsi-sentiment-pill 재사용, 색상만 override) */
.score-pill-high { background: rgba(34,197,94,0.15);   color: #22c55e; }
.score-pill-mid  { background: rgba(245,158,11,0.15);  color: #f59e0b; }
.score-pill-low  { background: rgba(107,114,128,0.15); color: var(--text-secondary); }

/* 5축 미니 바 */
.score-axes {
    display: flex;
    flex-direction: column;
    gap: 0.13rem;
    margin-top: 0.2rem;
}
.score-axis-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.score-axis-label {
    font-size: 0.62rem;
    color: var(--text-secondary);
    width: 1.8rem;
    flex-shrink: 0;
    text-align: right;
}
.score-axis-track {
    flex: 1;
    height: 4px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}
.score-axis-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s;
}
.score-axis-fill.up   { background: #22c55e; }
.score-axis-fill.mid  { background: #f59e0b; }
.score-axis-fill.down { background: #3b82f6; }
.score-axis-val {
    font-size: 0.62rem;
    color: var(--text-secondary);
    width: 2.8rem;
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
/* 상승률 바: 센터 기준 좌우 확장 */
.score-axis-track-center { position: relative; }
.score-axis-track-center .score-axis-fill { position: absolute; top: 0; height: 100%; }
.score-axis-center-mark {
    position: absolute;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    background: var(--text-secondary);
    opacity: 0.4;
}

/* ── NXT 전용 페이지 ── */
.nxt-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.nxt-summary-cards {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.nxt-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.55rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.nxt-stat-card .stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}
.nxt-stat-card .stat-val {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.2;
}
.nxt-stat-card .stat-val.up { color: var(--red); }
.nxt-stat-card .stat-val.dn { color: var(--accent-blue); }
.nxt-rank-table .up { color: #dc2626; }
.nxt-rank-table .dn { color: #3b82f6; }

/* NXT 타임라인 스텝 바 */
.nxt-tl-stepper {
    display: flex;
    align-items: flex-start;
    margin-top: 0.75rem;
}
.nxt-tl-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 88px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}
.nxt-tl-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-color);
    border: 2px solid var(--border-color);
    margin-bottom: 0.4rem;
    transition: background 0.2s;
}
.nxt-tl-step.active .nxt-tl-dot {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}
.nxt-tl-step.active {
    color: var(--text-primary);
    font-weight: 600;
}
.nxt-tl-line {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin-top: 5px;
    min-width: 30px;
}

.nxt-main-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
}
.nxt-rank-table .text-right { text-align: right; }
@media (max-width: 1100px) {
    .nxt-main-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .nxt-main-grid { grid-template-columns: 1fr; }
    .nxt-summary-cards { grid-template-columns: repeat(2, 1fr); }
}

.nxt-rank-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.nxt-rank-table thead tr {
    background: var(--bg-hover);
}
.nxt-rank-table th {
    padding: 0.5rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}
.nxt-rank-table td {
    padding: 0.45rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.nxt-rank-table tr.nxt-krx-highlight { background: rgba(59,130,246,0.06); }

.nxt-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}
.nxt-empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.nxt-empty-state h3 { color: var(--text-primary); margin: 0 0 0.5rem; font-size: 1.1rem; }
.nxt-empty-state p { margin: 0; font-size: 0.88rem; line-height: 1.5; }

.nxt-name-cell {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.nxt-name-cell:hover { color: var(--accent-blue); }

.nxt-cross-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
    gap: 0.4rem;
}
.nxt-cross-name { flex: 1; min-width: 0; }
.nxt-cross-price { font-size: 0.78rem; color: var(--text-secondary); white-space: nowrap; }
.nxt-cross-chg { white-space: nowrap; }

/* tc-candle NXT 페이지 오버라이드 (스코핑) */
.nxt-rank-table .tc-candle-track {
    height: 8px;
    width: 90px;
    background: rgba(128,128,128,0.15);
}
.score-updated { font-size: 0.65rem; color: var(--text-secondary); }


/* ═══════════════════════════════════════════
   Admin page shared styles (migrated from common.css)
   ═══════════════════════════════════════════ */

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 20px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-danger  { background: var(--red); color: white; }
.btn-danger:hover  { background: #dc2626; }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #16a34a; }
.btn-ghost {
    background: none; border: 1px solid var(--border-color); color: var(--text-secondary);
}
.btn-ghost:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-input {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--border-color); border-radius: 8px;
    background: var(--bg-body); color: var(--text-primary);
    font-size: 14px; outline: none; transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--blue); }
.form-input::placeholder { color: var(--text-secondary); }
select.form-input { cursor: pointer; }

/* ── Modal ── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 24px; width: 90%; max-width: 480px;
}
.modal-header {
    font-size: 18px; font-weight: 700; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
}
.modal-body { margin-bottom: 20px; overflow-y: auto; max-height: 60vh; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Spinner (admin loading) ── */
.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid var(--border-color); border-top-color: var(--blue);
    border-radius: 50%; animation: admin-spin 0.8s linear infinite;
}
@keyframes admin-spin { to { transform: rotate(360deg); } }

/* ── Badge variants (admin) ── */
.badge-buy   { background: rgba(34,197,94,0.15);   color: var(--green); }
.badge-sell  { background: rgba(239,68,68,0.15);   color: var(--red); }
.badge-skip  { background: rgba(160,160,160,0.15); color: var(--text-secondary); }
.badge-stop  { background: rgba(239,68,68,0.25);   color: #f87171; }
.badge-trail { background: rgba(234,179,8,0.15);   color: var(--yellow); }
.badge-tp    { background: rgba(34,197,94,0.2);    color: #4ade80; }
.badge-time  { background: rgba(59,130,246,0.15);  color: var(--blue); }
.badge-score { background: rgba(168,85,247,0.15);  color: var(--purple); }
.badge-active   { background: rgba(34,197,94,0.15);   color: var(--green); }
.badge-inactive { background: rgba(160,160,160,0.15); color: var(--text-secondary); }

/* ── Admin Layout ── */
.admin-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    min-height: calc(100vh - 60px);
}
.admin-sidebar { display: none; }
.admin-main {
    padding: 20px 24px;
    overflow-y: auto;
}
.admin-health-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}
.admin-etl-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 0.5rem;
}
.admin-etl-phase-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
/* Admin ETL 카드 */
.admin-etl-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: border-color 0.2s;
}
.admin-etl-card .etl-time   { margin-left: auto; }
.admin-etl-card .etl-status { min-width: 32px; text-align: right; }
.admin-etl-card.status-ok   { border-left: 3px solid var(--green); }
.admin-etl-card.status-err  { border-left: 3px solid var(--red); }
.admin-etl-card.status-none { border-left: 3px solid var(--muted); opacity: 0.7; }
.admin-etl-card .etl-name    { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); }
.admin-etl-card .etl-schedule { font-size: 0.62rem; color: var(--text-secondary); white-space: nowrap; }
.admin-etl-card .etl-time    { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); }
.admin-etl-card .etl-elapsed { font-size: 0.72rem; color: var(--text-secondary); }
.admin-etl-card.status-err .etl-elapsed { color: var(--orange); }
@media (max-width: 640px) { .admin-etl-card .etl-elapsed { display: none; } }
.admin-etl-card .etl-status  { font-size: 0.68rem; }
.admin-etl-card.status-ok   .etl-status { color: var(--green); }
.admin-etl-card.status-err  .etl-status { color: var(--red); }
.admin-etl-card.status-none .etl-status { color: var(--muted); }
.etl-phase-header { font-size: 0.72rem; font-weight: 700; padding: 0.3rem 0 0.15rem; letter-spacing: 0.05em; border-bottom: 2px solid var(--border-color); margin-bottom: 2px; }

/* System Health 아이템 */
.admin-health-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 160px;
    flex: 1 1 160px;
    max-width: 260px;
}
.admin-health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* 전략 가중치 진행 바 */
.weight-bar-list { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.75rem 0; }
.weight-bar-row  { display: flex; align-items: center; gap: 0.6rem; }
.weight-bar-label { font-size: 0.78rem; color: var(--text-secondary); min-width: 80px; }
.weight-bar-track {
    flex: 1;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    overflow: hidden;
}
.weight-bar-fill  {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.weight-bar-fill.threshold { background: var(--yellow, #f59e0b); }
.weight-bar-val  { font-size: 0.8rem; font-weight: 600; min-width: 28px; text-align: right; }

@media (max-width: 768px) {
    .admin-main { padding: 16px; }
    .admin-health-item { max-width: none; flex: 1 1 140px; }
}

/* ── Admin Card (tab panel wrapper, mirrors .panel) ── */
.admin-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* ── Admin Sections ── */
.admin-section { margin-bottom: 32px; }
.admin-section h2 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.admin-subsection {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
/* When subsection is the direct child of a card, reset spacing/border */
.admin-card > .admin-subsection {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.admin-subsection h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

/* ── Admin Tabs (underline style) ── */
.admin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.25rem;
}
.admin-tab-btn {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.admin-tab-btn:hover {
    color: var(--text-primary);
}
.admin-tab-btn.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: 600;
}
[data-theme="dark"] .admin-tab-btn { color: rgba(255,255,255,0.5); }
[data-theme="dark"] .admin-tab-btn:hover { color: rgba(255,255,255,0.8); }
[data-theme="dark"] .admin-tab-btn.active { color: #60a5fa; border-bottom-color: #60a5fa; }

/* ── Admin Tables ── */
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    font-size: 0.82rem;
}
.admin-table thead th {
    background: rgba(128,128,128,0.08);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
[data-theme="dark"] .admin-table thead th {
    background: rgba(255,255,255,0.12);
}
[data-theme="dark"] .admin-table {
    border-color: rgba(255,255,255,0.15);
}
.admin-table tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
[data-theme="dark"] .admin-table td,
[data-theme="dark"] .admin-table th {
    border-bottom-color: rgba(255,255,255,0.10);
}
.admin-table tbody tr:last-child td {
    border-bottom: none;
}
.admin-table tbody tr:hover {
    background: rgba(128,128,128,0.05);
}
[data-theme="dark"] .admin-table tbody tr:hover {
    background: rgba(255,255,255,0.10);
}
.admin-table tbody tr:nth-child(even) {
    background: rgba(128,128,128,0.025);
}
[data-theme="dark"] .admin-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.06);
}

/* ── Activity Log Filter ── */
.activity-filter {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.activity-filter input[type="date"] { width: auto; }
.activity-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ── Strategy Cards ── */
.strategy-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 20px; margin-bottom: 12px;
}
.strategy-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px;
}
.strategy-name { font-size: 16px; font-weight: 700; }
.weight-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px; margin: 12px 0;
}
.weight-item { text-align: center; }
.weight-label { font-size: 11px; color: var(--text-secondary); }
.weight-value { font-size: 20px; font-weight: 700; color: var(--purple); }

/* ══════════════════════════════════════════
   Mobile Responsive Patch (2026-02-27)
   스마트폰(≤430px) + 태블릿(768~1024px) 보강
   ══════════════════════════════════════════ */

@media (max-width: 480px) {
    /* Trading: stat row 2열로 축소 */
    .trd-stat-row { grid-template-columns: 1fr 1fr; }
    /* Trading: 패널 내부 패딩 축소 */
    .trading-grid { padding: 0.375rem; gap: 0.375rem; }
}

/* Task 3: Macro 패딩 축소 */
@media (max-width: 480px) {
    .macro-root { padding: 0.5rem; }
}
/* Task 4: 시장분석 탭 공통 패딩 */
@media (max-width: 768px) {
    .dashboard-grid { padding: 0.5rem; gap: 0.5rem; }
}

@media (max-width: 480px) {
    .panel { padding: 0.5rem; }
    .panel-header { padding: 0.4rem 0; margin-bottom: 0.4rem; }
    .portfolio-stats-grid { grid-template-columns: 1fr; }
    .panel-title { font-size: 0.85rem; }
}
/* Task 5: Admin 탭 480px */
@media (max-width: 480px) {
    .admin-health-grid { gap: 4px; }
    .admin-etl-grid    { grid-template-columns: 1fr; gap: 8px; }
    .admin-main { padding: 12px; }
    .admin-section { margin-bottom: 20px; }
    .strategy-card { padding: 12px; }
}
/* Task 6: NXT 탭 테이블 오버플로우 */
@media (max-width: 768px) {
    .nxt-rank-table { width: 100%; }
    .nxt-rank-table td, .nxt-rank-table th { white-space: nowrap; padding: 0.4rem 0.35rem; font-size: 0.72rem; }
    .nxt-main-grid .panel { min-width: 0; overflow-x: auto; }
    #nxt-root { padding: 0.5rem; }
    .nxt-main-grid { padding: 0.5rem; gap: 0.5rem; }
}

@media (max-width: 480px) {
    .nxt-rank-table td, .nxt-rank-table th { font-size: 0.68rem; padding: 0.3rem 0.25rem; }
}
/* Task 7: 태블릿 769~1024px */
@media (max-width: 1024px) and (min-width: 769px) {
    .panel { padding: 0.75rem; }
    .navbar { padding: 0 1rem; }
    .nav-user { gap: 0.5rem; }
}

/* ══════════════════════════════════════════
   Trading Tab — Account Section & Score Panel
   ══════════════════════════════════════════ */
.trd-account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    padding: 0.25rem 0;
}
.trd-account-item {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
}
/* ── Date Picker & History Tables ── */
.trd-date-picker {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: inherit;
}
.trd-date-picker::-webkit-calendar-picker-indicator {
    filter: invert(0.5);
}
/* 일별 매매 히스토리 + 매매 판단 로그 — 공통 컬럼 너비 통일 */
#daily-history-container .strat-compact-table,
#signalArea .strat-compact-table { table-layout: auto; }
/* 일별 매매 히스토리: 기본 우측, 앞 4컬럼 오버라이드 */
#daily-history-container .strat-compact-table thead th,
#daily-history-container .strat-compact-table tbody td { text-align: right; font-variant-numeric: tabular-nums; }
#daily-history-container .strat-compact-table thead th:nth-child(1),
#daily-history-container .strat-compact-table tbody td:nth-child(1) { text-align: left !important; white-space: nowrap; width: 115px; }
#daily-history-container .strat-compact-table thead th:nth-child(2),
#daily-history-container .strat-compact-table tbody td:nth-child(2) { text-align: left !important; width: 180px; }
#daily-history-container .strat-compact-table thead th:nth-child(3),
#daily-history-container .strat-compact-table tbody td:nth-child(3),
#daily-history-container .strat-compact-table thead th:nth-child(4),
#daily-history-container .strat-compact-table tbody td:nth-child(4) { text-align: center !important; white-space: nowrap; width: 70px; }
/* 매매 판단 로그: 앞 4컬럼 동일 너비 */
#signalArea .strat-compact-table thead th:nth-child(1),
#signalArea .strat-compact-table tbody td:nth-child(1) { width: 115px; }
#signalArea .strat-compact-table thead th:nth-child(2),
#signalArea .strat-compact-table tbody td:nth-child(2) { width: 180px; }
#signalArea .strat-compact-table thead th:nth-child(3),
#signalArea .strat-compact-table tbody td:nth-child(3),
#signalArea .strat-compact-table thead th:nth-child(4),
#signalArea .strat-compact-table tbody td:nth-child(4) { width: 70px; }
@media (max-width: 640px) {
    #daily-history-container .strat-compact-table,
    #signalArea .strat-compact-table { font-size: 0.72rem; }
    #daily-history-container .strat-compact-table thead th:nth-child(1),
    #daily-history-container .strat-compact-table tbody td:nth-child(1),
    #signalArea .strat-compact-table thead th:nth-child(1),
    #signalArea .strat-compact-table tbody td:nth-child(1) { width: 34px !important; font-size: 0.65rem; padding: 4px 2px; }
    .trd-daily-table thead th, .trd-daily-table tbody td { padding: 5px 3px; }
}

/* 금일 매매 + 종목별 히스토리 (기존 — 모바일 카드뷰 전환) */
.trd-hist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.trd-hist-table thead th {
    padding: 6px 4px;
    text-align: right;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
    white-space: nowrap;
}
.trd-hist-table thead th:first-child { text-align: left; }
.trd-hist-table tbody td {
    padding: 5px 4px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    font-variant-numeric: tabular-nums;
}
.trd-hist-table tbody td:first-child { text-align: left; }
.trd-hist-table tbody tr:hover { background: var(--bg-hover); }
.trd-hist-badge-buy {
    display: inline-block;
    background: rgba(239,68,68,0.15);
    color: #ef4444;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}
.trd-hist-badge-sell {
    display: inline-block;
    background: rgba(59,130,246,0.15);
    color: #3b82f6;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
}
.trd-cumulative-pos { color: #ef4444; }
.trd-cumulative-neg { color: #3b82f6; }

/* 트레이딩 히스토리 모바일 카드 뷰 */
.trd-hist-cards { display: none; flex-direction: column; gap: 0.5rem; }
.trd-hist-card {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.78rem;
}
@media (max-width: 640px) {
    .trd-hist-table { display: none; }
    .trd-hist-cards { display: flex; }
}

/* 일별 매매 히스토리 모드 버튼 */
.trd-date-mode { display: flex; gap: 0.25rem; }
.trd-date-mode button {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.75rem;
}
.trd-date-mode button.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

/* ── Today Trades (Kiwoom-style) ── */
.trd-day-summary-pc {
    display: grid;
    grid-template-columns: repeat(3, 1fr) repeat(3, 1fr);
    gap: 0.25rem 0.75rem;
    padding: 0.5rem 0 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    font-size: 0.72rem;
}
.trd-day-summary-pc .s-label { color: var(--text-secondary); margin-bottom: 0.1rem; }
.trd-day-summary-pc .s-val   { font-weight: 600; font-variant-numeric: tabular-nums; }

.trd-day-summary-mob {
    display: none;
    gap: 0.5rem;
    padding: 0.4rem 0 0.6rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    font-size: 0.78rem;
}
.trd-day-summary-mob .s-label { color: var(--text-secondary); font-size: 0.65rem; }
.trd-day-summary-mob .s-val   { font-weight: 700; }

/* PC 테이블 래퍼 */
.trd-day-table-wrap { overflow-x: auto; }

/* PC 그룹 헤더 테이블 */
.trd-day-table {
    width: 100%;
    font-size: 0.72rem;
    border-collapse: collapse;
}
/* 공통 헤더 */
.trd-day-table th,
.trd-day-mob-table th {
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    text-align: right;
}
.trd-day-table th { padding: 4px 5px; }
.trd-day-mob-table th { padding: 4px 4px; }
.trd-day-table th:first-child,
.trd-day-mob-table th:first-child { text-align: left; }

/* 공통 셀 */
.trd-day-table td,
.trd-day-mob-table td {
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.trd-day-table td { padding: 5px 5px; }
.trd-day-mob-table td { padding: 5px 4px; }
.trd-day-table td:first-child,
.trd-day-mob-table td:first-child { text-align: left; font-weight: 500; }

.trd-day-table th.grp-buy  { text-align: right; }
.trd-day-table th.grp-sell { text-align: right; }
.trd-day-table td.buy-cell  { }
.trd-day-table td.sell-cell { }
.trd-day-table tr:hover td  { background: var(--bg-hover); }

/* 모바일 단순 테이블 */
.trd-day-mob-table {
    display: none;
    width: 100%;
    font-size: 0.72rem;
    border-collapse: collapse;
}

/* 반응형: 모바일에서 전환 */
@media (max-width: 768px) {
    .trd-day-summary-pc  { display: none; }
    .trd-day-summary-mob { display: flex; justify-content: space-between; }
    .trd-day-table-wrap  { display: none; }
    .trd-day-mob-table   { display: table; }
}


/* ── Admin Strategy v3 Edit Form ── */
.admin-form-row { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; }
.admin-form-row label { min-width: 80px; font-size: 0.8rem; color: var(--text-secondary); }
.admin-input { flex: 1; background: var(--bg-card); border: 1px solid var(--border-color);
               border-radius: 4px; padding: 0.3rem 0.5rem; color: var(--text-primary); font-size: 0.85rem; }
.admin-input-sm { width: 120px; background: var(--bg-card); border: 1px solid var(--border-color);
                  border-radius: 4px; padding: 0.3rem 0.5rem; color: var(--text-primary); font-size: 0.85rem; }
.admin-input-xs { width: 55px; background: var(--bg-card); border: 1px solid var(--border-color);
                  border-radius: 4px; padding: 0.2rem 0.3rem; color: var(--text-primary); font-size: 0.85rem; }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 1rem; }
.sell-mode-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
.sell-mode-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
                 padding: 0.3rem 0.5rem; background: var(--bg-card); border-radius: 4px;
                 border: 1px solid var(--border-color); }
.sell-mode-row label { font-size: 0.8rem; }

/* ── Admin Layout Helpers ── */
.admin-health-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.admin-health-label  { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.admin-time-badge    { font-size: 0.7rem; color: var(--text-primary); font-weight: 600; background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; }
.admin-panel-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.admin-panel-title   { margin: 0; font-size: 0.95rem; font-weight: 600; }
.admin-panel-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.admin-etl-result {
    display: none; margin-top: 0.5rem; padding: 0.5rem;
    background: var(--bg-secondary); border-radius: 4px;
    font-size: 0.75rem; font-family: monospace;
    max-height: 120px; overflow-y: auto; white-space: pre-wrap;
}

/* ── Users Split Layout ── */
.admin-users-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}
@media (max-width: 768px) {
    .admin-users-split { grid-template-columns: 1fr; }
}

/* ── User Card (mobile) ── */
.user-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 6px;
}
.user-card-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.user-card-top .btn { margin-left: auto; }
.user-card-name {
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-top: 0.25rem;
}
.user-card-login {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* ── Activity Card (mobile) ── */
.activity-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 6px;
}
.activity-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.activity-card-top .badge { font-size: 0.72rem; }
.activity-card-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.activity-card-mid {
    font-size: 0.78rem;
    color: var(--text-primary);
    margin-top: 0.2rem;
}
.activity-card-detail {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Activity Filter mobile ── */
@media (max-width: 640px) {
    .activity-filter {
        flex-direction: column;
        align-items: stretch;
    }
    .activity-filter-dates {
        display: flex;
        align-items: center;
        gap: 0.4rem;
    }
    .activity-filter-dates input[type="date"] {
        flex: 1;
        min-width: 0;
    }
    .activity-filter .btn { align-self: flex-end; }
    .admin-input-sm {
        width: auto;
        min-width: 0;
        flex: 1;
    }
}

/* ── ETL Run Modal ── */
.etl-modal-dialog {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.etl-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.etl-modal-title { margin: 0; font-size: 0.95rem; font-weight: 600; }
.etl-modal-body  { padding: 1rem 1.25rem; overflow-y: auto; flex: 1; }
.etl-modal-status-row {
    display: flex;
    align-items: center;
    min-height: 1.8rem;
    margin-bottom: 0.5rem;
}
.etl-modal-times {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-family: monospace;
    letter-spacing: 0.02em;
}
.etl-modal-output {
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.75rem;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
}
.etl-spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: admin-spin 0.8s linear infinite;
    flex-shrink: 0;
}
.strategy-card.active { border-color: var(--green); }
.strategy-actions      { display: flex; gap: 8px; }
.strategy-drawer-title { margin: 0; font-size: 1rem; font-weight: 600; }

/* ── Score Help Tooltip ── */
.score-help-wrap { position: relative; display: inline-flex; align-items: center; }
.score-help-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 15px; height: 15px; border-radius: 50%;
    font-size: 0.6rem; font-weight: 700; line-height: 1;
    background: var(--border-color); color: var(--text-secondary);
    border: none; cursor: pointer; flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.score-help-btn:hover { background: var(--accent); color: #fff; }
.score-help-tooltip {
    display: none;
    position: fixed;
    z-index: 9999;
    background: #1a1a2e;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 12px 14px;
    width: 288px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.7);
    pointer-events: none;
}
[data-theme="light"] .score-help-tooltip {
    background: #f8f9fc;
    border-color: rgba(0,0,0,0.12);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.score-help-tooltip.visible { display: block; }
.score-help-title {
    font-size: 0.73rem; font-weight: 700;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 6px; margin-bottom: 8px;
    letter-spacing: 0.01em;
}
[data-theme="light"] .score-help-title { color: #1e293b; border-bottom-color: rgba(0,0,0,0.1); }
.score-help-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 5px 0;
    font-size: 0.71rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
[data-theme="light"] .score-help-row { border-bottom-color: rgba(0,0,0,0.05); }
.score-help-row:last-child { border-bottom: none; padding-bottom: 0; }
.score-help-row-top {
    display: flex; align-items: center; gap: 6px;
}
.score-help-lbl { font-weight: 700; color: #e2e8f0; font-size: 0.73rem; }
[data-theme="light"] .score-help-lbl { color: #1e293b; }
.score-help-wt {
    font-size: 0.65rem; font-weight: 600;
    color: #fff; background: var(--accent);
    padding: 1px 5px; border-radius: 3px;
}
.score-help-desc { color: #94a3b8; font-size: 0.68rem; line-height: 1.4; padding-left: 2px; }
[data-theme="light"] .score-help-desc { color: #64748b; }

/* ── TSI Badge ── */
.tsi-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.tsi-badge.tsi-high { background: rgba(255,140,0,0.18); color: #ff8c00; border: 1px solid rgba(255,140,0,0.35); }
.tsi-badge.tsi-mid  { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.tsi-badge.tsi-low  { background: rgba(255,255,255,0.06); color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.1); }
[data-theme="light"] .tsi-badge.tsi-high { background: rgba(255,140,0,0.12); color: #d97706; border-color: rgba(255,140,0,0.3); }
[data-theme="light"] .tsi-badge.tsi-mid  { background: rgba(59,130,246,0.1); color: #2563eb; border-color: rgba(59,130,246,0.25); }
[data-theme="light"] .tsi-badge.tsi-low  { background: rgba(0,0,0,0.05); color: #6b7280; border-color: rgba(0,0,0,0.12); }

/* ── Leader Star ── */
.leader-star {
    font-size: 0.65rem;
    color: #f59e0b;
    margin-right: 2px;
    line-height: 1;
}

/* ── Theme Breadth ── */
.theme-breadth {
    font-size: 0.62rem;
    color: var(--text-secondary);
    margin-left: 4px;
}
.theme-breadth.hot { color: #4ade80; }

/* ── Mobile: Task 10 ── */
@media (max-width: 768px) {
    .trd-pnl-panel .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .trd-pnl-panel [style*="height:210px"] {
        height: 160px !important;
    }
}
@media (max-width: 640px) {
    .trd-pnl-panel .panel-header > div { gap: 3px; }
    .trd-pnl-panel .btn-sm { padding: 0.2rem 0.4rem; font-size: 0.65rem; }
    .trd-pnl-panel .trd-date-picker { width: 100px; font-size: 0.65rem; }
    #stock-hist-filter-range { flex-wrap: wrap; }
}

/* ── Alert Bell ────────────────────────────────────────── */
.alert-bell-wrap { position: relative; display: flex; align-items: center; }
.alert-bell-btn {
  background: none; border: none; cursor: pointer; color: var(--text-secondary);
  padding: 4px; display: flex; align-items: center; position: relative;
}
.alert-bell-btn:hover { color: var(--text-primary); }
.alert-badge {
  position: absolute; top: -4px; right: -6px; background: var(--red); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  font-weight: 600;
}
.alert-dropdown {
  position: absolute; top: 36px; right: 0; width: 360px; max-height: 480px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 1000; overflow: hidden;
}
.alert-dropdown-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.alert-mark-all {
  background: none; border: none; color: var(--accent-color); cursor: pointer; font-size: 12px;
}
.alert-list { max-height: 420px; overflow-y: auto; }
.alert-item {
  padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background 0.15s;
}
.alert-item:hover { background: var(--bg-hover); }
.alert-item.unread { background: var(--card-bg-accent, rgba(59,130,246,0.05)); }
.alert-item.read { opacity: 0.6; }
.alert-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.alert-type { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.alert-sev-info { color: var(--accent-color); }
.alert-sev-warning { color: var(--orange, #f59e0b); }
.alert-sev-critical { color: var(--red); }
.alert-time { font-size: 11px; color: var(--text-secondary); }
.alert-title { font-size: 13px; font-weight: 500; line-height: 1.3; }
.alert-msg { font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.3; }
.alert-empty { padding: 24px; text-align: center; color: var(--text-secondary); font-size: 13px; }
@media (max-width: 768px) {
  .alert-dropdown {
    position: fixed;
    top: 52px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100vh - 70px);
  }
  .alert-list { max-height: calc(100vh - 130px); }
}

/* ── Strategy Section (trading page) ── */
.strategy-section { overflow-x: hidden; max-width: 100%; box-sizing: border-box; }
.strategy-section .panel { min-width: 0; overflow-x: hidden; }
.strategy-status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
@media (max-width: 768px) { .strategy-status-grid { grid-template-columns: 1fr; } }
.strat-settings-summary { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; font-size: 0.75rem; }
.strat-setting-item { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; border-radius: 6px; background: var(--bg-body); border: 1px solid var(--border-color); }
.strat-setting-label { color: var(--text-secondary); font-size: 0.65rem; letter-spacing: 0.02em; text-transform: uppercase; }
.strat-setting-val { font-weight: 600; font-size: 0.82rem; white-space: nowrap; }
.strat-setting-val.mono { font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace; font-size: 0.76rem; letter-spacing: -0.02em; }
.strat-settings-divider { grid-column: 1 / -1; height: 0; }
@media (max-width: 768px) { .strat-settings-summary { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .strat-settings-summary { grid-template-columns: 1fr; } }
.pill-count { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; margin-right: 6px; }
.pill-buy { background: rgba(239,68,68,0.15); color: #ef4444; }
.pill-hold { background: rgba(160,160,160,0.15); color: var(--text-secondary); }
.pill-skip { background: rgba(160,160,160,0.15); color: var(--text-secondary); }
.pill-sell { background: rgba(59,130,246,0.15); color: #3b82f6; }
.pill-cb { background: rgba(101,163,13,0.15); color: #65a30d; }
.pill-day { background: rgba(100,116,139,0.15); color: #64748b; }
.strat-compact-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; margin-top: 8px; table-layout: auto; }
.strat-compact-table thead th { padding: 4px 6px; text-align: left; color: var(--text-secondary); border-bottom: 1px solid var(--border-color); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strat-compact-table tbody td { padding: 4px 6px; border-bottom: 1px solid var(--border-color); overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.strat-compact-table tbody tr:hover { background: var(--bg-hover); }
.perf-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; margin-bottom: 12px; }
.perf-stat-item { text-align: center; padding: 8px; background: var(--bg-body); border-radius: 6px; }
.perf-stat-label { font-size: 0.7rem; color: var(--text-secondary); }
.perf-stat-value { font-size: 1.1rem; font-weight: 700; margin-top: 2px; }
.strat-empty { text-align: center; color: var(--text-secondary); padding: 2rem 1rem; font-size: 0.85rem; }
.factor-bar-wrap { display: flex; gap: 2px; align-items: center; }
.factor-bar { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }
@media (max-width: 768px) {
    .factor-bar { display: none; }
    /* 오늘의 스코어링 판정 컬럼 숨김 (총점 ✓로 충분) */
    #scoringArea .strat-compact-table th:last-child,
    #scoringArea .strat-compact-table td:last-child { display: none; }
}

/* === 매매내역 히스토리 패널 간격 === */
.trd-history { display: flex; flex-direction: column; gap: 0.75rem; }
.trd-history > .panel { margin: 0; }

/* === 매매성과 탭 === */
.performance-section { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.perf-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
.perf-summary-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}
.perf-card-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}
.perf-card-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.perf-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.perf-metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.perf-metric-value {
    font-size: 0.9rem;
    font-weight: 600;
}
.perf-filter-row {
    display: flex;
    gap: 0.5rem;
}
.perf-unified-filter {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
}
@media (max-width: 768px) {
    .perf-unified-filter { flex-wrap: wrap; }
}
.filter-pill {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-body);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}
.filter-pill:hover {
    border-color: var(--accent-color);
    color: var(--text-primary);
}
.filter-pill.active {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
    font-weight: 600;
}
.perf-split-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}
.perf-split-panel {
    min-width: 0;
}
.perf-split-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.perf-split-title {
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-secondary);
}
.perf-split-summary {
    display: flex;
    gap: 0.75rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.show-mob { display: none; }
@media (max-width: 768px) {
    .perf-summary-row { grid-template-columns: 1fr; }
    .perf-split-row { grid-template-columns: 1fr; }
    .hide-mob { display: none !important; }
    .show-mob { display: inline !important; }
    .perf-unified-filter { flex-wrap: wrap !important; }
}

/* === 전략 모바일 서브탭 === */
.strategy-mobile-subtabs {
    display: none;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.strategy-mobile-subtabs button {
    flex: 1;
    padding: 8px;
    text-align: center;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
}
.strategy-mobile-subtabs button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
@media (max-width: 900px) {
    .strategy-mobile-subtabs { display: flex; }
}
.factor-label { font-size: 9px; color: var(--text-secondary); margin-right: 1px; }
