/* Stock page: 3-pane layout, resizable sash, mobile / tablet / desktop */

.splitter {
    /* Matches header-custom.css (.page-header.navbar is 52px). */
    --stock-header-height: 52px;
    --stock-left-min: 350px;
    --stock-right-width: 350px;
    --stock-right-min: 280px;
    --stock-pane-left: max(var(--stock-left-min), var(--stock-left-width, 22vw));
    --stock-pane-right: max(var(--stock-right-min), var(--stock-right-width, 350px));
}

.splitter > #first {
    container-type: inline-size;
    container-name: stock-left;
    min-width: 0;
    margin: 2px 0 2px 2px;
    padding-right: 0 !important;
}

.splitter > #second {
    container-type: inline-size;
    container-name: stock-center;
    min-width: 0;
    margin: 2px 0;
}

.splitter > #third {
    margin: 2px 2px 2px 0;
    padding-left: 0 !important;
}

#xuhuong-pie-col {
    min-width: 0;
    overflow: visible;
}

#xuhuong-pie-col #PieChart_Stocks_xuhuong {
    width: 350px;
    max-width: 100%;
    height: 260px;
    min-width: 0;
    flex-shrink: 1;
    box-sizing: border-box;
    padding: 0;
    overflow: visible;
}

#xuhuong-pie-col.is-legend-below #PieChart_Stocks_xuhuong {
    width: 100%;
    max-width: 100%;
    height: 242px;
    min-width: 0;
    flex-shrink: 1;
}

.stock-center-portlet {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    margin-bottom: 0 !important;
}

/* Tabs are inside the center portlet; the 15px .tab-header gap plus
   portlet-body height calc(100% - 35px) overflow-clips the bottom padding. */
.stock-center-header.tab-header {
    margin-bottom: 0;
    flex-shrink: 0;
}

/* Fill leftover space. Do not set height:auto — that makes height:100%
   children (tongquan grid) collapse to 0 and Highcharts draws nothing. */
.stock-center-portlet > .portlet-body {
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
    box-sizing: border-box;
    padding-bottom: 10px;
    overflow: hidden;
}

/* Only the active main tab may take space. ID+flex !important on a pane
   beats Angular .ng-hide and stacks 100%-height panes (gap above Biểu đồ). */
#second .portlet-body > .tab-content > .tab-pane:not(.active),
#second .portlet-body > .tab-content > .tab-pane.ng-hide {
    display: none !important;
}

/* TradingView keeps a live iframe after the Biểu đồ tab is left. display:none
   on the pane is not enough — Blink still reflows that iframe on window
   resize, which is what makes sash/window drag hitch after visiting Biểu đồ. */
html:not(.stock-bieudo-expanded) #tv_chart_main iframe {
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    content-visibility: hidden;
}

#first .tab-container,
#third .tab-container {
    width: 100%;
    align-items: center;
}

#portlet_tab_biendong .tabbable.tabbable-tabdrop {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#portlet_tab_biendong .tabbable.tabbable-tabdrop > .tab-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.stock-panel-toggle-icon {
    display: inline-block;
    width: 14px;
    height: 12px;
    box-sizing: border-box;
    border-left: 2px solid currentColor;
    background:
        linear-gradient(currentColor, currentColor) 5px 0 / 2px 100% no-repeat,
        linear-gradient(currentColor, currentColor) 11px 0 / 2px 100% no-repeat;
}

/* ===== Desktop panes (vw so they track viewport) ===== */
@media (min-width: 1200px) {
    .splitter {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .splitter > #first {
        flex: 0 0 var(--stock-pane-left);
        width: var(--stock-pane-left) !important;
        min-width: 0 !important;
        max-width: 42%;
        container-type: inline-size;
        container-name: stock-left;
        overflow: hidden;
        box-sizing: border-box;
        min-height: 0;
    }

    .splitter > #second {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    .splitter > #third {
        flex: 0 0 var(--stock-pane-right) !important;
        flex-shrink: 0 !important;
        width: var(--stock-pane-right) !important;
        min-width: var(--stock-pane-right) !important;
        max-width: var(--stock-pane-right) !important;
        overflow: hidden;
        box-sizing: border-box;
    }

    #portlet_tab_bieudoptkt.active {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    #portlet_tab_bieudoptkt.active #tradingview-center-container {
        flex: 1 1 auto;
        min-height: 0;
        height: auto !important;
    }

    #portlet_tab_bieudoptkt.active #tradingview-main-wrapper {
        flex: 1 1 auto;
        min-height: 0;
    }
}

/* ===== Sash: 8px gutters between panes ===== */
.splitter > #separator.splitter-sash,
.splitter > #separator2.splitter-sash {
    position: relative;
    flex: 0 0 8px !important;
    width: 8px !important;
    min-width: 8px !important;
    max-width: 8px !important;
    height: auto;
    align-self: stretch;
    margin: 2px 0 !important;
    padding: 0 !important;
    border: 0 !important;
    font-size: 0;
    line-height: 0;
    background: transparent !important;
    overflow: visible;
    cursor: col-resize;
    z-index: 200;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.splitter > #separator.splitter-sash::before,
.splitter > #separator2.splitter-sash::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -12px;
    width: 24px;
    cursor: col-resize;
}

.splitter-sash-line {
    display: none;
}

.splitter-sash-grip {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: 10px;
    height: 20px;
    box-sizing: border-box;
    margin: -10px 0 0 -5px;
    transform: none;
    opacity: 1;
    pointer-events: none;
    z-index: 3;
    transition: color 0.12s ease;
    color: #8c8c8c;
}

.splitter-sash-grip svg {
    display: block;
    width: 100%;
    height: 100%;
}

.splitter > #separator.splitter-sash:hover .splitter-sash-grip,
.splitter > #separator.splitter-sash.is-active .splitter-sash-grip,
.splitter > #separator2.splitter-sash:hover .splitter-sash-grip,
.splitter > #separator2.splitter-sash.is-active .splitter-sash-grip,
body.stock-sash-dragging .splitter > .splitter-sash .splitter-sash-grip {
    color: #2980b9;
}

body.stock-sash-dragging {
    cursor: col-resize !important;
    user-select: none !important;
}

body.stock-sash-dragging iframe {
    pointer-events: none !important;
}

/* Biểu đồ tab: hide left pane only. Instant — no width/flex transition
   (those lag sash drag, window resize, and leave a hole above the chart). */
html.stock-bieudo-expanded .splitter {
    --stock-pane-left: 0px;
}

@media (min-width: 768px) {
    html.stock-bieudo-expanded .splitter > #first,
    html.stock-bieudo-expanded .splitter > #separator.splitter-sash {
        display: none !important;
    }
}

/* ===== Center header: panel toggles + scrollable tabs ===== */
.stock-center-header {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding-right: 4px;
}

.stock-center-header .tab-container {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.stock-center-header .tab-container::-webkit-scrollbar {
    display: none;
}

.stock-panel-toggle {
    display: none;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
    margin: 7px 4px 0;
    padding: 0 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px 4px 0 0 !important;
    background: #fff;
    color: #262626;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
}

.stock-panel-toggle:hover,
.stock-panel-toggle.is-open {
    background: #e5eff7;
    border-color: #2980b9;
    color: #2980b9;
}

.stock-panel-close {
    display: none;
    margin-left: auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #595959;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.stock-panel-close:hover {
    background: #f0f0f0;
    color: #262626;
}

.stock-panel-backdrop {
    display: none;
    position: fixed;
    inset: var(--stock-header-height, 50px) 0 0 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 350;
}

body.stock-panel-open .stock-panel-backdrop {
    display: block;
}

/* ===== Tong quan chart grid ===== */
#tab_tongquan.tab-pane.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.tongquan-layout {
    --tongquan-gap: clamp(6px, 0.7vw, 12px);
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
        "vonhoa thanhtoan"
        "nganh  thanhtoan"
        "anhhuong cungcau";
    gap: var(--tongquan-gap);
    height: 100%;
    min-height: 0;
    width: 100%;
    padding: 0 0 4px;
    overflow: hidden;
}

.tongquan-chart {
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
}

.tongquan-chart-vonhoa { grid-area: vonhoa; }
.tongquan-chart-nganh { grid-area: nganh; }
.tongquan-chart-thanhtoan {
    grid-area: thanhtoan;
    min-height: 0;
    overflow: hidden;
}
.tongquan-chart-anhhuong { grid-area: anhhuong; }
.tongquan-chart-cungcau {
    grid-area: cungcau;
    min-height: 0;
    overflow: hidden;
}

@media (min-width: 992px) {
    /* Độ rộng + thanh khoản share the 2-row span so titles line up with the left column. */
    #tab_tongquan .tongquan-layout #chart_BienDongThanhKhoan {
        display: grid;
        grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
        gap: var(--tongquan-gap, clamp(6px, 0.7vw, 12px));
        height: 100%;
        min-height: 0;
        overflow: hidden;
        padding-top: 4px;
        box-sizing: border-box;
    }

    #tab_tongquan .tongquan-layout #chart_BienDongThanhKhoan .chart.chartMulti,
    #tab_tongquan .tongquan-layout #chart_GDKhoiNgoai .chart.chartMulti {
        height: 100% !important;
        min-height: 0;
        margin-bottom: 0 !important;
        transform: none !important;
        width: 100% !important;
        overflow: hidden;
    }

    #tab_tongquan .tongquan-layout #chart_CPTheoVonHoa,
    #tab_tongquan .tongquan-layout #chart_BienDongChiSoTheoNganh,
    #tab_tongquan .tongquan-layout #chart_CoPhieuAnhHuong {
        height: 100% !important;
        min-height: 0;
    }
}

#tab_tongquan .tongquan-layout #chart_BienDongThanhKhoan,
#tab_tongquan .tongquan-layout #chart_GDKhoiNgoai {
    overflow-x: hidden;
}

#chart_BienDongThanhKhoan .highcharts-title,
#chart_GDKhoiNgoai .highcharts-title {
    width: calc(100% - 16px) !important;
    max-width: none !important;
    overflow: visible !important;
    text-align: left !important;
    left: 8px !important;
}

#chart_BienDongThanhKhoan .highcharts-title > div,
#chart_GDKhoiNgoai .highcharts-title > div {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.hc-chart-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    position: relative;
}

.hc-chart-title {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.hc-chart-title-bar {
    width: 2px;
    height: 14px;
    flex-shrink: 0;
    background: #2980B9;
}

.hc-chart-title-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #000;
    font-size: 16px;
    font-weight: 500;
    line-height: 18px;
    cursor: default;
}

.hc-chart-stats {
    flex: 0 0 auto;
    white-space: nowrap;
    pointer-events: none;
    line-height: 18px;
}

.hc-chart-title-tip {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 4px);
    z-index: 50;
    background: #1f1f1f;
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.hc-chart-title.is-truncated:hover ~ .hc-chart-title-tip {
    display: block;
}

/* RSI / Phân tích kỹ thuật: keep gauge visible, follow sidebar width */
#ContentChiso .portlet-body {
    min-height: 0;
}

#ContentChiso .chart-container {
    flex: 1 1 auto !important;
    min-height: 160px !important;
}

#ContentChiso .rsi-container {
    flex: 0 0 auto;
    min-width: 0;
    overflow: visible;
}

#ContentChiso .rsi-container .rsi-main-section {
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

#ContentChiso .rsi-container .rsi-gauge-section {
    width: auto;
    flex-shrink: 0;
}

#ContentChiso .gauge-container,
#ContentChiso .gauge-chart {
    width: 145px;
    height: 140px;
    max-width: 145px;
    overflow: hidden;
}

#ContentChiso .stats-cards-grid {
    min-width: 0;
}

#ContentChiso .stats-card-label,
#ContentChiso .stats-card-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

@container stock-left (max-width: 279px) {
    #ContentChiso .rsi-container .rsi-main-section {
        flex-direction: column;
        align-items: stretch;
    }

    #ContentChiso .rsi-container .rsi-gauge-section {
        width: 100%;
        align-items: center;
    }

    #ContentChiso .gauge-container,
    #ContentChiso .gauge-chart {
        width: min(160px, 100%);
        height: 140px;
    }
}

/* ===== Tablet: left + center, right as drawer ===== */
@media (min-width: 768px) and (max-width: 1199px) {
    html,
    body {
        height: 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    /* Metronic offsets the container for a 46px header; Stock header is 52px
       (104px below 992px). Zero it so the fixed splitter can pin to the viewport. */
    .page-container {
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        height: 100%;
    }

    .splitter {
        --stock-header-height: 52px;
        --stock-left-width: 28vw;
        flex-wrap: nowrap;
        overflow: hidden;
        position: fixed;
        top: var(--stock-header-height);
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: auto !important;
        box-sizing: border-box;
        padding-top: 4px;
        padding-bottom: 8px;
    }

    .splitter > #first {
        flex: 0 0 var(--stock-pane-left);
        width: var(--stock-pane-left) !important;
        min-width: 0 !important;
        max-width: 40%;
        container-type: inline-size;
        container-name: stock-left;
        align-self: stretch;
        min-height: 0;
        height: auto !important;
        max-height: 100%;
        box-sizing: border-box;
        overflow: hidden !important;
    }

    .splitter > #second {
        flex: 1 1 auto;
        width: auto !important;
        min-width: 0 !important;
        min-height: 0 !important;
        align-self: stretch;
        height: auto !important;
        max-height: 100%;
        box-sizing: border-box !important;
        overflow: hidden !important;
    }

    #second .stock-center-portlet,
    #second .portlet-body > .tab-content,
    #second .portlet-body > .tab-content > .tab-pane.active:not(.ng-hide) {
        display: flex !important;
        flex-direction: column;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    #second .portlet-body > .tab-content > .tab-pane:not(.active),
    #second .portlet-body > .tab-content > .tab-pane.ng-hide {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        flex: none !important;
    }

    #portlet_tab_cophieu .bien-dong-container {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
    }

    #portlet_tab_cophieu .bien-dong-table-wrapper {
        min-width: 0;
        max-width: 100%;
    }

    #portlet_tab_bieudoptkt.active #tradingview-center-container {
        flex: 1 1 auto;
        min-height: 0;
        height: auto !important;
    }

    #portlet_tab_bieudoptkt.active #tradingview-main-wrapper {
        flex: 1 1 auto;
        min-height: 0;
    }

    #bien-dong-pagination,
    .bien-dong-pagination {
        flex-shrink: 0;
    }

    .actual-frame-container {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }

    .splitter > #third {
        position: fixed;
        top: var(--stock-header-height);
        right: 0;
        bottom: 0;
        width: min(86vw, 360px) !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 8px !important;
        z-index: 400;
        background: #fff;
        transform: translateX(100%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.22s ease;
        border-radius: 0 !important;
    }

    body.stock-right-open .splitter > #third {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
    }

    .splitter > #separator2.splitter-sash {
        display: none !important;
    }

    .stock-panel-toggle-right {
        display: inline-flex;
    }

    #third .stock-panel-close {
        display: inline-flex;
    }

    .tab-button {
        min-width: clamp(64px, 8vw, 84px);
        font-size: clamp(12px, 1.2vw, 14px);
        padding: 0 8px;
    }

    .center-tab-container {
        flex-wrap: wrap;
        gap: 4px 8px;
    }
}

/* Header becomes two rows (104px) below 992px — keep splitter under it. */
@media (min-width: 768px) and (max-width: 991px) {
    .splitter {
        --stock-header-height: 104px;
    }
}

/* Tablet portrait: stack tong quan charts */
@media (min-width: 768px) and (max-width: 991px) {
    .tongquan-layout {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas:
            "vonhoa"
            "nganh"
            "thanhtoan"
            "anhhuong"
            "cungcau";
        overflow: auto;
        height: 100%;
        align-content: start;
    }

    .tongquan-chart {
        height: clamp(240px, 32vw, 320px);
        min-height: 240px;
    }

    .tongquan-chart-thanhtoan {
        height: auto;
        min-height: 480px;
        overflow: visible;
    }

    #tab_tongquan,
    #tab_tongquan > .tongquan-layout {
        overflow: auto;
    }

    #tab_tongquan #chart_BienDongThanhKhoan,
    #tab_tongquan #chart_GDKhoiNgoai {
        overflow-y: visible !important;
    }
}

/* ===== Phone: document scroll, not a locked desktop shell ===== */
@media (max-width: 767px) {
    html,
    body {
        height: auto !important;
        min-height: 100%;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        position: relative !important;
        -webkit-overflow-scrolling: touch;
    }

    body.stock-panel-open {
        overflow: hidden !important;
    }

    .page-container {
        height: auto !important;
        overflow: visible !important;
        min-height: 0;
    }

    .page-header.navbar {
        height: 52px !important;
        min-height: 52px !important;
    }

    .page-header-inner {
        gap: 8px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        min-width: 0;
        overflow: hidden;
    }

    .header-brand-nav {
        gap: 8px !important;
        min-width: 0;
        flex-shrink: 1;
    }

    .header-brand-nav > a img {
        width: 32px !important;
        height: 32px !important;
    }

    .header-nav-extra,
    .header-guide-link {
        display: none !important;
    }

    .header-actions {
        gap: 6px !important;
        flex-shrink: 0;
    }

    .header-search-box {
        width: min(132px, 34vw) !important;
    }

    .header-search-box input {
        font-size: 13px !important;
    }

    .tan-loc-btn .tan-loc-icon {
        width: 28px;
        height: 28px;
    }

    .splitter {
        position: relative !important;
        top: auto;
        left: auto;
        right: auto;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: calc(100vh - 52px);
        overflow: visible !important;
        padding-top: 0;
        background: #fff;
    }

    .splitter > #separator.splitter-sash,
    .splitter > #separator2.splitter-sash,
    .stock-panel-toggle,
    .stock-panel-close,
    .stock-panel-backdrop {
        display: none !important;
    }

    .splitter > #first,
    .splitter > #third {
        position: fixed;
        top: 52px;
        bottom: 0;
        z-index: 400;
        height: calc(100vh - 52px) !important;
        width: min(88vw, 380px) !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;
        margin: 0 !important;
        background: #fff;
        transition: transform 0.22s ease;
        border-radius: 0 !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .splitter > #first {
        left: 0;
        padding: 0 8px !important;
        transform: translateX(-110%);
    }

    .splitter > #third {
        right: 0;
        padding: 0 8px !important;
        transform: translateX(110%);
    }

    body.stock-left-open .splitter > #first {
        transform: translateX(0);
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.12);
    }

    body.stock-right-open .splitter > #third {
        transform: translateX(0);
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
    }

    .splitter > #second,
    div#second {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        margin: 0 !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    .stock-panel-toggle {
        display: inline-flex;
    }

    #first .stock-panel-close,
    #third .stock-panel-close {
        display: inline-flex;
    }

    .stock-center-header {
        position: sticky;
        top: 52px;
        z-index: 20;
        background: #fff;
        padding-right: 4px;
    }

    .stock-center-header .tab-container {
        gap: 2px;
        padding-left: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .tab-button {
        min-width: auto;
        flex-shrink: 0;
        padding: 0 10px;
        font-size: 13px;
        height: 36px;
    }

    .center-tab-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 8px;
    }

    .center-tab-nav {
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        gap: 8px;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .center-tab-controls {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .center-tab-item {
        height: 36px;
        flex-shrink: 0;
    }

    #second .stock-center-portlet,
    #second .portlet.box.blue,
    #second .portlet-body,
    #second .tab-content,
    #second .tab-pane,
    #second .tabbable,
    #portlet_tab_biendong,
    #portlet_tab_biendong .tab-content,
    #tab_tongquan,
    #tab_tongquan > .tongquan-layout {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    #second .portlet-body {
        flex: none !important;
        display: block !important;
    }

    #second .tab-content {
        display: block !important;
    }

    .tongquan-layout {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas:
            "vonhoa"
            "nganh"
            "thanhtoan"
            "anhhuong"
            "cungcau";
        gap: 16px;
        padding: 8px 8px 24px;
        align-content: start;
        width: 100%;
    }

    .tongquan-chart {
        height: 260px;
        min-height: 240px;
        width: 100%;
        touch-action: pan-y;
    }

    .tongquan-chart-thanhtoan {
        height: auto;
        min-height: 420px;
        overflow: visible;
    }

    #tab_tongquan #chart_BienDongThanhKhoan,
    #tab_tongquan #chart_GDKhoiNgoai {
        overflow-y: visible !important;
    }

    .actual-frame-card {
        flex: 0 0 42vw;
        min-width: 140px;
    }

    .market-summary-text,
    .market-summary-up,
    .market-summary-down,
    .market-summary-fix {
        font-size: 11px;
    }

    #portlet_tab_bieudoptkt {
        min-height: 70vh;
    }

    .bien-dong-table-wrapper {
        overflow-x: auto;
        max-height: none;
    }
}

@media (max-width: 480px) {
    .splitter > #first,
    .splitter > #third {
        width: 92vw !important;
    }

    .tongquan-chart {
        height: clamp(200px, 62vw, 280px);
    }

    .stock-panel-toggle span:not(.stock-panel-toggle-icon) {
        display: none;
    }

    .stock-panel-toggle {
        width: 36px;
        padding: 0;
    }
}

/* Small screens: keep center tabs usable */
@media (max-width: 1199px) {
    #header-tabs {
        flex-wrap: nowrap;
    }

    #sub-tabs {
        float: none !important;
    }
}
