:root {
    --bg-dark: #0a0b10;
    --bg-card: #15161e;
    --bg-card-hover: #1e202a;
    --bg-sidebar: #0f1016;
    
    --text-main: #f1f2f5;
    --text-muted: #8b92a5;
    
    --accent: #3f68e0;
    --accent-hover: #4e78f3;
    
    --pos: #f94d5d;  /* Red for positive in KR */
    --neg: #2e8af6;  /* Blue for negative in KR */
    
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    
    --font-stack: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-stack);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 24px;
}

.logo i {
    color: var(--pos);
    font-size: 24px;
}

.search-box {
    position: relative;
    margin-bottom: 32px;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 10px 10px 36px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 13px;
    transition: all 0.2s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.08);
}

.menu-section {
    margin-bottom: 32px;
}

.menu-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    padding-left: 8px;
}

.menu-section ul {
    list-style: none;
}

.menu-section li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.menu-section li a:hover {
    background-color: rgba(255,255,255,0.04);
    color: var(--text-main);
}

.menu-section li.active a {
    background-color: var(--accent);
    color: #fff;
}

.menu-section li.active a i {
    color: #fff;
}

.menu-section li a i {
    font-size: 16px;
    color: var(--text-muted);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.user-menu:hover {
    color: var(--text-main);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* Header */
.content-header {
    padding: 32px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: linear-gradient(to bottom, rgba(21, 22, 30, 0.8), var(--bg-dark));
}

.header-title .theme-badge {
    display: inline-block;
    background: rgba(249, 77, 93, 0.15);
    color: var(--pos);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 12px;
}

.header-title h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-stats {
    display: flex;
    gap: 24px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.stat-item .label {
    font-size: 11px;
    color: var(--text-muted);
}

.stat-item .value {
    font-size: 16px;
    font-weight: 700;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.text { color: var(--text-main); }

/* Table */
.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 24px 40px;
}

/* Custom Scrollbar for table */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.table-container::-webkit-scrollbar-track {
    background: transparent;
}
.table-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}
.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 1100px;
}

th {
    position: sticky;
    top: 0;
    background-color: var(--bg-dark);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    padding: 16px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
    white-space: nowrap;
}

th.right, td.right {
    text-align: right;
}

th.center, td.center {
    text-align: center;
}

td {
    padding: 18px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

tbody tr:hover td {
    background-color: var(--bg-card-hover);
}

.stock-name-cell, .theme-name-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.stock-name {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    cursor: pointer;
}

.stock-code {
    font-size: 11px;
    color: var(--text-muted);
}

.price-main {
    font-size: 15px;
    font-weight: 700;
}

.price-sub {
    font-size: 12px;
    margin-top: 4px;
}

.hl-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}
.hl-values {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 12px;
}
.hl-low { color: var(--neg); }
.hl-high { color: var(--text-main); }

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 250px;
}

.theme-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all 0.2s;
    cursor: pointer;
}
.theme-tag:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.theme-tag.highlight {
    border-color: var(--accent);
    color: var(--accent);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 4px;
    transition: background-color 0.2s;
}
.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border-top: 1px solid var(--border);
    background-color: var(--bg-dark);
}

.page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.page-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.page-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 모바일 상단바 - PC에서는 숨김 */
.mobile-topbar {
    display: none;
}

.sidebar-overlay {
    display: none;
}

/* ===== 모바일 반응형 (햄버거 메뉴 방식) ===== */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }

    /* 상단바: 햄버거 버튼 + 로고 */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        position: sticky;
        top: 0;
        z-index: 200;
        background-color: var(--bg-sidebar);
        border-bottom: 1px solid var(--border);
        padding: 12px 16px;
    }

    .menu-toggle-btn {
        background: none;
        border: none;
        color: var(--text-main);
        font-size: 24px;
        display: flex;
        align-items: center;
        cursor: pointer;
        padding: 4px;
    }

    .mobile-logo {
        display: flex;
        align-items: center;
        gap: 8px;
        font-weight: 900;
        letter-spacing: 1px;
        font-size: 16px;
    }
    .mobile-logo i { color: var(--pos); font-size: 20px; }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        width: 100%;
    }

    /* 사이드바: 평소엔 화면 왼쪽 밖에 숨겨둠 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 80%;
        max-width: 300px;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        border-right: 1px solid var(--border);
        border-bottom: none;
    }

    /* JS가 이 클래스를 붙이면 슬라이드로 나타남 */
    .sidebar.open {
        transform: translateX(0);
    }

    /* 사이드바 열렸을 때 뒤 배경 어둡게 */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 250;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        width: 100%;
        min-width: 0;
    }

    .content-header {
        padding: 20px;
    }

    .header-title h1 {
        font-size: 20px;
    }

    .table-container {
        padding: 16px;
    }
}
