html, body {
    margin: 0;
    padding: 0;
    width: 100%;
}

body {
    display: flex;
    justify-content: center;
    background: #e9ecef;
}

body.chart-only .app-container,
body.chart-only .sticky-options-panel {
    display: none;
}

body.chart-only .modal-overlay {
    background: #ffffff;
}

body.chart-only .modal-card {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
}

.app-container {
    --topbar-offset: 96px;
    width: 100%;
    max-width: 2720px;
    padding: 0px 20px 20px 20px;
    box-sizing: border-box;
}

.top-menu-bar {
    position: sticky;
    top: 0;
    z-index: 1000;

    display: flex;
    align-items: center;
    justify-content: space-between;

    height: 56px;
    padding: 0 20px;

    background: #f8f9fa;
    border-bottom: 1px solid lightblue;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

     /* 아래쪽만 둥글게 */
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
} 


.top-menu-bar {
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    
}

.top-menu-bar.hide {
    opacity: 0;
    
}

.top-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
}

.app-logo {
    width: 34px;
    height: 34px;
    display: block;
}

.app-title {
    font-weight: 600;
    font-size: 15px;
    color: #222;
}

.top-center {
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.account-tab {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 16px;
    cursor: pointer;
    white-space: nowrap;

    background: #e9ecef;
    color: #555;

    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.account-tab:hover {
    background: #dee2e6;
}

.account-tab.active {
    background: #5fae8b;
    color: white;
    border-color: rgba(0, 0, 0, 0.05);
    font-weight: 500;
}

.top-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.portfolio-toggle-box {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding: 3px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    font-size: 13px;
    min-height: 36px;
}

.portfolio-chart-item {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
}

.portfolio-chart-item .label { font-weight: bold; color: #666; margin-right: 5px; }

.btn-compare-toggle {
    padding: 4px 10px;
    border: 1px solid #e4e7eb;
    border-radius: 6px;
    background: #fff;
    color: #666;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
}

.treemap-toggle-box {
    display: inline-flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    padding: 3px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    font-size: 13px;
    min-height: 36px;
}

.treemap-chart-item {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
}

.treemap-chart-item .label { font-weight: bold; color: #666; margin-right: 5px; }
.user-info {
    font-size: 13px;
    color: #444;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.user-name {
    color: #1d8cf8;
    font-weight: 600;
}

.user-select {
    min-width: 120px;
    padding: 4px 8px;
    border: 1px solid #ccd3da;
    border-radius: 6px;
    font-size: 12px;
    color: #1d8cf8;
    background: #f6f8fa;
    display: none;
}

.user-avatar {
    display: inline-flex;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    color: #1d8cf8;
}

.user-avatar svg {
    width: 18px;
    height: 18px;
    display: block;
}

.auth-actions {
    display: none;
}

.auth-logout {
    display: none;
    align-items: center;
}

.auth-local {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-right: 4px;
    border-right: 1px solid #d2d6dc;
}

.auth-local input {
    width: 120px;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid #c8d0da;
    background: #fff;
    font-size: 12px;
    color: #222;
}

.btn-local {
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid #2d6cdf;
    background: #2d6cdf;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid #222;
    background: #111;
    color: #fff;
    cursor: pointer;
}

.btn-social svg {
    width: 18px;
    height: 18px;
    display: block;
}

.btn-social.google { background: #1a73e8; border-color: #1a73e8; }
.btn-social.facebook { background: #1877f2; border-color: #1877f2; }
.btn-social.naver { background: #03c75a; border-color: #03c75a; }
.btn-social.kakao { background: #fee500; border-color: #fee500; color: #111; }
.btn-social.dev { background: #6c757d; border-color: #6c757d; }
.btn-social.logout {
    background: linear-gradient(180deg, #2c2f36 0%, #1f2227 100%);
    color: #f2f4f7;
    border-color: #3a3f46;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.btn-social.logout:hover {
    background: linear-gradient(180deg, #343943 0%, #24282f 100%);
    border-color: #4a515b;
}

.layout-grid {
    width: 100%;
}

/* 800px 이상에서 2컬럼 */
@media (min-width: 1601px) {
    .layout-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 14px;
        align-items: start;
    }
}

@media (min-width: 1601px) and (max-width: 1750px) {
    .layout-grid {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
        gap: 14px;
    }
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

h2 {
    margin-bottom: 20px;
}

.section-header {
        /* 위쪽과 간격 */
    margin-top: 12px;
    width: 100%;
    display: flex;
    align-items: center; /* 세로 중앙 정렬 */

}

.sector-filter {
    position: relative;
    margin-left: 10px;
}

.sector-filter-toggle {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #d9d9d9;
    background: #fff;
    font-size: 11px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
}

.sector-filter-menu {
    position: absolute;
    top: 28px;
    left: 0;
    min-width: 160px;
    max-height: 240px;
    overflow: auto;
    background: #fff;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    padding: 8px 10px;
    z-index: 50;
}

.sector-filter-menu.hidden {
    display: none;
}

.sector-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #333;
    padding: 4px 2px;
    cursor: pointer;
}

.sector-filter-item input {
    accent-color: #2f8cff;
}

.market-mini-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(140px, 1fr));
    gap: 14px;
    margin: 8px 0 0px;
}

.mini-card {
    background: #fff;
    border: 1px solid #e2e6ea;
    border-radius: 10px;
    padding: 8px 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.mini-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
}

.mini-title {
    color: #3b4652;
    font-weight: 700;
}

.mini-interval {
    font-size: 10px;
    color: #98a2b3;
    font-weight: 700;
}

.mini-date {
    margin-left: 6px;
    color: #8a94a3;
}

.mini-change {
    margin-left: auto;
    font-weight: 700;
}

.mini-chart {
    margin-top: 6px;
    width: 100%;
    height: 102px;
    background: #f8fafc;
    border-radius: 6px;
}

.mini-chart svg {
    display: block;
}

@media (max-width: 1100px) {
    .market-mini-grid {
        grid-template-columns: repeat(4, minmax(140px, 1fr));
    }
}

@media (max-width: 720px) {
    .market-mini-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
    .mini-chart {
        height: 140px;
    }
}

.section-header-treemap {
        /* 위쪽과 간격 */
    margin-top: 1px;
    width: 100%;
    display: flex;
    align-items: center; /* 세로 중앙 정렬 */

}

.market-summary {
    margin-left: auto; /* 핵심: 왼쪽 마진을 자동으로 채워 우측으로 밀어냄 */
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 3px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    font-size: 13px;
    min-height: 36px;
}

    #usd-krw-rate-mobile {
        display: none;
    }

.sticky-options-panel {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 0;
    pointer-events: none;
    --sticky-btn-width: 86px;
    width: calc(var(--sticky-btn-width) + 24px);
    align-items: flex-end;
}

.sticky-options-controls {
    display: flex;
    justify-content: flex-end;
    gap: 2px;
    width: 100%;
    pointer-events: auto;
}

.sticky-options-toggle {
    display: inline-flex;
    width: auto;
    padding: 4px 6px;
    height: 28px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #f8f9fa;
    color: #666;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
}

.sticky-options-pin {
    display: inline-flex;
    width: auto;
    padding: 4px 5px;
    height: 28px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #ffffff;
    color: #6b7280;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
}

.sticky-options-pin[aria-pressed="true"] {
    background: #f2f7ff;
    border-color: #b9c6e8;
    color: #3b5bdc;
}

.sticky-options-toggle svg {
    width: 18px;
    height: 18px;
}

.sticky-options-pin svg {
    width: 16px;
    height: 16px;
}

.sticky-options-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
    width: 100%;
    align-items: center;
    text-align: center;
    align-self: flex-end;
}

.sticky-options-panel .chart-toggle,
.sticky-options-panel .chart-toggle--right {
    margin-left: 0;
    margin-right: 0;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: var(--sticky-btn-width);
}

.sticky-options-panel .btn-chart-toggle,
.sticky-options-panel .btn-heatmap-toggle,
.sticky-options-panel .btn-treemap-toggle,
.sticky-options-panel .btn-toggle {
    width: var(--sticky-btn-width);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    padding: 0;
    line-height: 1;
    height: 24px;
    min-height: 24px;
    box-sizing: border-box;
}

.sticky-flip-btn, .sticky-flip-out-btn {
    width: var(--sticky-btn-width);
    height: 24px;
    border: 1px solid #cdd2d9;
    border-radius: 4px;
    background: #f7fbff;
    color: #3b5bdc;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.sticky-flip-out-btn {
    padding: 5px 6px;
    margin: 1px;
    height: 28px;
}
.refresh-icon svg {
    width: 20px;
    height: 20px;
}

.sticky-options-panel .currency-toggle {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: var(--sticky-btn-width);
    align-items: center;
    margin-left: 0;
    padding: 0;
}

.sticky-options-panel .summary-item {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.sticky-options-panel .summary-item .value {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 10px;
    line-height: 1.2;
    white-space: normal;
    word-break: break-word;
}

.sticky-options-panel .chart-item .label,
.sticky-options-panel .summary-item .label {
    font-size: 10px;
}

.sticky-options-panel .chart-item {
    display: flex;
    justify-content: center;
    width: 100%;
    text-align: center;
}

.sticky-options-panel .summary-item .label {
    display: none;
}

@media (max-width: 1000px) {
    .sticky-options-panel {
        top: 60px;
        right: 20px;
    }
}

.sticky-options-panel .sticky-options-group {
    display: flex;
}

.sticky-options-panel:not(.is-open) .sticky-options-group {
    display: none;
}

.block {
    flex: 0;
    margin-right: 0px;
    /* 두 블록이 같은 너비 차지 */
}

.top-section .block {
    display: flex;
    min-height: 0;
    min-width: 0;
}

.top-section .card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    box-sizing: border-box;
}

#piechart-container,
#heatmap-container {
    flex: 1 1 0;
    min-height: 0;
}

#piechart-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.piechart-block #piechart-container {
    height: 90%;
    max-height: 90%;
}

.top-section {
    display: grid;
    grid-template-columns: 1fr; /* 기본은 한 줄 (800px 미만) */
    gap: 1rem;
    width: 100%;
    align-items: stretch;
}

@media (min-width: 1001px) {
    .top-section {
        grid-template-columns: 1fr 1fr; /* 두 칸을 동일 비율로 */
    }
    .left-column {
        display: flex;
        flex-direction: column;
        height: auto;
        max-height: none;
    }

    .left-column.no-treemap-header {
        height: auto;
        max-height: none;
    }

    .left-column .section-content {
        min-height: 0;
        height: auto;
        display: flex;
        flex-direction: column;
    }

    .left-column .top-section,
    .left-column .treemap-section {
        height: auto;
        flex: 0;
        min-height: 0;
    }

    .left-column .top-section .card,
    .left-column .treemap-section .card {
        height: auto;
        max-height: none;
    }

    .left-column .treemap-section {
        height: auto;
    }

    .left-column .treemap-section .block {
        height: auto;
    }

    #piechart-container,
    #heatmap-container {
        aspect-ratio: auto;
        min-height: 0;
    }

    #treemap-container {
        height: 100%;
        min-height: 0;
    }
}

@media (max-width: 1000px) {
    .modal-card {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    #piechart-container,
    #heatmap-container {
        flex: 1;
        width: 100%;
        height: 100%;
        max-height: 100%;
        aspect-ratio: auto;
        min-height: 0;
    }

    #heatmap-container {
        height: auto;
        overflow: hidden;
    }

    #treemap-container {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        aspect-ratio: auto;
    }

    .modal-toggle-group--mobile {
        display: inline-flex;
    }

    .modal-toggle--buttons {
        display: inline-flex;
    }

    .modal-toggle-select {
        display: none;
    }

    .chart-legend-bar {
        display: flex;
    }

    #stock-info-modal .chart-legend-bar {
        display: flex;
    }
}

#piechart {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

#piechart svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

#treemap-container {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* 최소 높이 */
    position: relative;
    border: 1px solid #ddd;
    background: white;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    border-radius: 0;
    overflow: hidden;
    aspect-ratio: auto;
}

.treemap-summary {
    margin-top: 20px;
    padding: 10px 10px 14px;
    margin-bottom: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fbfdff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
    display: grid;
    gap: 6px;
}

.treemap-summary.hidden {
    display: none;
}

.treemap-summary-row {
    display: grid;
    grid-template-columns: minmax(200px, 1.6fr) repeat(6, minmax(90px, 1fr));
    gap: 6px 10px;
    font-size: 14px;
    color: #4b5563;
    align-items: center;
    padding: 8px 8px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background 160ms ease, border-color 160ms ease;
}

.treemap-summary-row:nth-child(even) {
    background: #f6f9fc;
}

.treemap-summary-row:hover {
    background: #edf4ff;
    border-color: #d6e4ff;
}

.treemap-summary-header {
    font-weight: 700;
    color: #f8fafc;
    background: #1f2933;
    border: 1px solid #111827;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    font-size: 15px;
}

.treemap-summary-total {
    margin-top: 6px;
    border-top: 2px solid #d5e0ea;
    padding-top: 10px;
    font-weight: 700;
    background: #f1f6fb;
    border: 1px solid #dfe7f1;
    font-size: 15px;
}

.treemap-summary-cell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.treemap-summary-cell.numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.treemap-summary-cell.pnl-positive {
    color: #2f8f5a;
    font-weight: 600;
}

.treemap-summary-cell.pnl-negative {
    color: #d04f4f;
    font-weight: 600;
}

@media (max-width: 1100px) {
    .treemap-summary-row {
        grid-template-columns: minmax(160px, 1fr) repeat(6, minmax(70px, 1fr));
        font-size: 13px;
    }
}

.treemap-section .block,
.treemap-section .card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
}

.top-section .card {
    overflow: hidden;
}

.treemap-section .card {
    min-height: 360px;
    padding: 16px;
    padding-bottom: 14px;
    overflow: visible;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
}

.control {
    margin-bottom: 6px;
}

.control label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}

input[type=range] {
    width: 100%;
}

.node {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid white;
    overflow: hidden;
    font-size: 12px;
    font-weight: bold;
    padding: 4px;
    z-index: 2;
}

.pnl-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.context-menu {
    position: fixed;
    z-index: 4000;
    background: #ffffff;
    border: 1px solid #e4e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    padding: 6px;
    min-width: 140px;
}

.context-menu.hidden {
    display: none;
}

.context-menu button {
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 10px;
    text-align: left;
    font-size: 12px;
    color: #333;
    border-radius: 6px;
    cursor: pointer;
}

.context-menu button:hover {
    background: #f3f6fb;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3500;
}

.modal-overlay.hidden {
    display: none;
}

#stock-info-modal {
    display: flex !important;
}

#stock-info-modal.hidden {
    display: none !important;
}

.modal-card {
    background: #ffffff;
    border-radius: 12px;
    width: 95vw;
    height: 95vh;
    max-width: 1280px;
    max-height: 90vh;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 8px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #222;
}

.modal-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 8px 0;
}

.modal-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 0;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.modal-tab {
    border: 1px solid #e0e6ee;
    border-radius: 6px;
    background: #f7f9fb;
    color: #555;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
}

.modal-tab.active {
    background: #e9f2ff;
    border-color: #c7d5ee;
    color: #2f55cc;
}

.modal-controls {
    display: flex;
    gap: 12px;
    padding: 0;
    font-size: 12px;
    color: #555;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.modal-controls.is-mobile .modal-toggle--buttons {
    display: none;
}

.modal-controls.is-mobile .modal-toggle-select {
    display: inline-flex;
}

.modal-controls:not(.is-mobile) .modal-toggle-select {
    display: none;
}

.modal-controls.hidden {
    display: none;
}

.modal-toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.modal-toggle-group--mobile {
    display: inline-flex;
}

.modal-toggle-label {
    font-weight: 600;
    color: #666;
}

.modal-toggle {
    display: inline-flex;
    border: 1px solid #d9e1ea;
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
    flex-wrap: wrap;
}

.modal-toggle-select {
    display: none;
    border: 1px solid #d9e1ea;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 12px;
    background: #ffffff;
    color: #444;
}

.modal-toggle-btn {
    border: none;
    background: transparent;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #444;
}

.modal-toggle-btn.active {
    background: #e9f2ff;
    color: #2f55cc;
    font-weight: 600;
}

.modal-controls button {
    border: 1px solid #d9e1ea;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    background: #ffffff;
    cursor: pointer;
    color: #444;
}

.modal-controls button:hover {
    background: #f3f6fb;
}

.modal-close {
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    color: #555;
}

#stock-info-modal .modal-content {
    padding: 0px 0px 0px;
    overflow: auto;
    flex: 1;
    display: block;
    box-sizing: border-box;
}

#stock-info-modal .modal-content.chart-mode {
    display: flex;
    padding: 12px 0px 0px 0px;
    width: 100%;
    overflow: hidden;
    height: 100%;
}

.info-section {
    margin-bottom: 16px;
}

.info-section h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: #444;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.info-table th,
.info-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: top;
}

.info-table th {
    width: 35%;
    color: #666;
    font-weight: 600;
}

.modal-iframe {
    width: 100%;
    height: 60vh;
    border: none;
    border-radius: 8px;
}

.chart-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    min-width: 0;
    background: #f9fbff;
    border-radius: 12px;
    padding: 0px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.chart-legend-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 11px;
    color: #333;
    padding-bottom: 4px;
    justify-content: flex-start;
    margin-left: 12px;
}

.chart-legend-bar .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chart-legend-bar .legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.chart-scroll {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable both-edges;
}

.chart-scroll-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: calc(100% + 1px);
    min-height: 0;
}

.chart-scroll::-webkit-scrollbar {
    height: 0;
}

#stock-chart,
#stock-volume,
#stock-rsi {
    width: 100%;
}

#stock-chart {
    flex: 1;
    min-height: 0;
    position: relative;
}

#stock-volume,
#stock-rsi {
    position: relative;
    height: 60px;
}

#stock-chart svg,
#stock-volume svg,
#stock-rsi svg {
    width: 100%;
    display: block;
}

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(20, 22, 30, 0.9);
    color: #fff;
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 6px;
    line-height: 1.4;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    z-index: 5;
    opacity: 0;
    transition: opacity 120ms ease;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px;
    font-size: 12px;
    pointer-events: none;
    border-radius: 4px;
    z-index: 9999;
}

.treemap-group {
    position: absolute;
    box-sizing: border-box;
    border-left: 1px solid #7a8086;
    border-radius: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.treemap-group--edge-right {
    border-right: 1px solid #7a8086;
}

.treemap-group--edge-bottom {
    border-bottom: 1px solid #7a8086;
}

.treemap-group-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 14px;
    width: 100%;
    background: rgba(10, 15, 20, 0.55);
    display: flex;
    align-items: center;
    padding: 0 6px;
    box-sizing: border-box;
    border-top: 1px solid #6a7076;
    border-bottom: 1px solid #6a7076;
}

.treemap-group-label {
    position: absolute;
    position: static;
    font-size: 11px;
    font-weight: 700;
    color: #f4f6f8;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    pointer-events: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-header,
.section-header-treemap {
    display: flex;
    justify-content: left;
    align-items: center;
}

.collapse-btn {
    font-size: 14px;
    border: none;
    background: transparent;
    cursor: pointer;
}


.stock-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: white;
    object-fit: contain;
}

.stock-section {
    display: flex;
    gap: 4px;          /* 두 블록 사이 간격 */
}

.stock-section .block {
    flex: 1;            /* 기본적으로 1:1 비율 (50%) */
    min-width: 0;       /* flex 아이템 내부 컨텐츠 넘침 방지 */
}

/* 🔥 800px 이하일 때 적용되는 스타일 */
@media (max-width: 1000px) {
    .stock-section {
        flex-direction: column; /* 세로 방향으로 정렬 (두 줄) */
    }
    
    .stock-section .block {
        width: 100%;           /* 각 블록이 가로 전체를 차지 */
    }
    .stock-section .block:nth-child(2) {
        margin-top: 30px;
        padding-top: 20px;
        border-top: red 5px solid;
    }
    .user-name {
        display: none;
    }

    .user-select {
        display: inline-flex;
        min-width: 110px;
    }
    .refresh_interval label[for="refresh-select"] {
        display: none;
    }
}

.refresh_interval {
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-icon {
    font-size: 14px;
    font-weight: 700;
    color: #444;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}


.stock-row {
    display: grid;
    grid-template-columns: 34px 2fr 1fr 1fr ; /* 아이콘 + 4개 항목 */
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid #f1f3f5
    }

    .stock-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    }

    .stock-name {
    font-weight: bold;
    }

    .stock-value,
    .stock-quantity,
    .stock-return,
    .stock-cost,
    .stock-day-change {
    text-align: right;
}

.stock-value .eval {
    font-size: 13px;
    font-weight: 400;
    color: #111;
}

.stock-value .pnl {
    font-size: 12px;
    font-weight: 500;
}

.stock-value.profit .pnl {
    color: #2ecc71;
}

.stock-value.loss .pnl {
    color: #e74c3c;
}

.stock-return .price {
    font-size: 13px;
    font-weight: 400;
    color: #111;
}

.stock-return .pnl {
    font-size: 12px;
    font-weight: 500;
}

.stock-return.profit .pnl {
    color: #2ecc71;
}

.stock-return.loss .pnl {
    color: #e74c3c;
}

.stock-name {
    line-height: 1.25;
}

/* 티커 강조 */
.stock-name .ticker {
    font-size: 14px;
    font-weight: 600;
    color: #111;
}

/* 종목명은 살짝 톤 다운 */
.stock-name .ticker .name {
    font-size: 12px;
    font-weight: 400;
    color: #666;
}

/* 보유 수량 */
.stock-name .qty {
    margin-top: 2px;
    font-size: 11px;
    font-weight: 400;
    color: #888;
}


.stock-name .name {
    max-width: 180px;
    display: inline-block;
    vertical-align: bottom;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    font-size: 12px;
    color: #666;
}
/* hover 시 살짝 강조 */
.stock-name .name:hover {
    color: #111;
}

.stock-icon {
    width: 36px;
    height: 36px;
}

.stock-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f2f2f2;
    color: #555;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.section-header h2, .section-header-treemap h2 {
    font-family: "Trebuchet MS", "Helvetica Neue", Helvetica, Arial, sans-serif; /* finviz 느낌 */
    font-size: 18px;   /* 조금 작게 */
    font-weight: 600;  /* 적당히 굵게 */
    color: #333;       /* 진한 회색 */
    margin: 0;         /* 위아래 여백 제거 */
    letter-spacing: 0.5px; /* 살짝 간격 */
}

.section-title {
    font-size: 13px;
    cursor: pointer;
    padding-bottom: 4px;
    transition: all 0.15s ease;
    color: #111;
    font-weight: 600;
    border-bottom: 2px solid #5fae8b;
}


.tooltip-target {
    position: relative;
    cursor: default;
}

/* 툴팁 본체 */
.tooltip-target::after {
    content: attr(data-tooltip);

    position: absolute;
    bottom: 130%;
    left: 0;

    max-width: 260px;
    padding: 6px 8px;

    background: rgba(0, 0, 0, 0.85);
    color: #fff;

    font-size: 11px;
    font-weight: 400;
    line-height: 1.35;

    border-radius: 4px;
    white-space: normal;

    opacity: 0;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;

    z-index: 1000;
}

/* 화살표 */
.tooltip-target::before {
    content: "";

    position: absolute;
    bottom: 120%;
    left: 10px;

    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;

    opacity: 0;
    transition: opacity 0.15s ease;

    z-index: 1000;
}

/* hover */
.tooltip-target:hover::after,
.tooltip-target:hover::before {
    opacity: 1;
    transform: translateY(0);
}

.icon-text {
    width: 32px;
    height: 32px;
    border-radius: 50%;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 12px;
    font-weight: 600;
    color: #fff;
    position: relative;
}

.icon-text.domestic::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #e74c3c;
    box-shadow: 0 0 0 1px #fff;
}

.stock-card {
    margin-top: 14px;
    background: #ffffff;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 8px 20px rgba(0, 0, 0, 0.04);
}
.pnl-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 8px 20px rgba(0, 0, 0, 0.04);

    
}

#pnl-bar {
    width: 100%;
    min-height: 76px;
    height: 76px;
}

.pnl-card:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 12px 28px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease;
}

.stock-sort-tabs {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.sort-tab {
    font-size: 13px;
    font-weight: 500;
    color: #777;
    cursor: pointer;
    padding-bottom: 4px;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

.sort-tab:hover {
    color: #333;
}

.sort-tab.active {
    color: #111;
    font-weight: 600;
    border-bottom: 2px solid #5fae8b;
}

.sort-tab.asc::after {
    content: " ▲";
    font-size: 10px;
}

.sort-tab.desc::after {
    content: " ▼";
    font-size: 10px;
}


.btn-finviz {
    transform: translateY(-4px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: #f0f3f8; /* 밝은 회색 톤 */
    color: #444; /* 텍스트는 진한 회색 */
    border: 1px solid #cdd2d9; /* 정교한 보더 라인 */
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); /* 미세한 그림자 */
}

.btn-finviz:hover {
    background-color: #e4e9f0; /* 호버 시 약간 더 어두운 회색 */
    border-color: #adb5bd;
    color: #222;
}

.btn-finviz--icon {
    width: 22px;
    height: 22px;
    padding: 0;
    gap: 0;
    justify-content: center;
}

.btn-finviz:active {
    background-color: #dadfe6;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1); /* 눌리는 느낌 */
}

/* 다크모드 대응이 필요한 경우를 위한 버전 */
.dark-mode .btn-finviz {
    background-color: #2a2e39;
    color: #d1d4dc;
    border-color: #434651;
}

.dark-mode .btn-finviz:hover {
    background-color: #363a45;
}

.finviz-select {
    padding: 4px 8px;
    font-size: 13px;
    border: 1px solid #cdd2d9;
    border-radius: 4px;
    background-color: #f0f3f8;
    color: #444;
    cursor: pointer;
    font-weight: 600;
    outline: none;
}

.finviz-select:hover {
    border-color: #adb5bd;
}

.finviz-select:focus {
    border-color: #4caf50; /* 포인트 컬러 */
}

.market-summary {
    display: flex;
    gap: 10px;
    font-size: 13px;
    padding: 3px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: #f8f9fa;
    min-height: 32px;
}
.summary-item .label { font-weight: bold; color: #666; margin-right: 5px; }
.summary-item .value { color: #d14836; font-weight: 700; } /* 환율은 주로 강조색 사용 */

.currency-toggle {
    display: flex;
    margin-left: 15px;
    border: 1px solid #cdd2d9;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.btn-toggle {
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
    border: none;
    background: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: #4caf50; /* Finviz 강조색 (초록) */
    color: #fff;
}

.btn-toggle:not(.active):hover {
    background: #f0f3f8;
}

.chart-item .label { font-weight: bold; color: #666; margin-right: 5px; }
.chart-item .value { color: #d14836; font-weight: 700; } /* 환율은 주로 강조색 사용 */

.chart-toggle {
    display: flex;
    margin-left: 15px;
    border: 1px solid #cdd2d9;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.chart-toggle--right {
    margin-left: auto;
    margin-right: 8px;
}

.btn-chart-toggle,
.btn-heatmap-toggle,
.btn-treemap-toggle {
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
    border: none;
    background: #fff;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-chart-toggle.active,
.btn-heatmap-toggle.active,
.btn-treemap-toggle.active {
    background: #d14836; /* Finviz 강조색 (초록) */
    color: #fff;
}

.btn-chart-toggle:not(.active):hover,
.btn-heatmap-toggle:not(.active):hover,
.btn-treemap-toggle:not(.active):hover {
    background: #f0f3f8;
}

.treemap-toggle {
    display: flex;
    margin-left: auto;
    border: 1px solid #cdd2d9;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}


.ticker {
    cursor: pointer;
    transition: background-color 0.2s;
}

.ticker:hover {
    background-color: #f0f3f8; /* 살짝 강조되는 배경색 */
    text-decoration: underline; /* 밑줄 효과 */
    color: #2196f3; /* Finviz 느낌의 블루 톤 */
}

@media (max-width: 600px) {
    h2 { font-size: 1.5rem; } /* 제목 크기 조정 */
    p { font-size: 1rem; }    /* 본문 크기 유지 */
    body {
       zoom: 0.8; /* 전체를 1.2배 확대 */
        margin: 0px;
        padding: 0px;
    }
    .app-container {
        padding: 0px;;
    }
    .stock-section .stock-card {
        padding: 0px;
        margin: 0px;
    }
    .stock-row {
        zoom: 1.2;
        grid-template-columns: 28px 2fr 1fr 1fr ; /* 아이콘 + 4개 항목 */
        padding: 0.7rem 0.15rem;
    }

    .market-summary .summary-item {
        display: none;
    }

    #usd-krw-rate-mobile {
        display: inline;
    }
    
}
