.box-content .nav-link {
    padding: 6px 10px;
    font-weight: 500;
    background-color: var(--bg-thead);
    color: var(--text-main);
    transition: color ease-in-out 0.3s;
}
.box-content .nav-link.active {
    background-color: #f5a504;
}
.funds-table {
    width: 100%;
    overflow: auto;
    max-height: 686px;
}
.funds-table::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}
.funds-table table thead {
    position: sticky;
    top: -1px;
    z-index: 10;
}
.funds-table table thead tr td {
    background-color: var(--bg-thead);
    font-weight: 600;
    border: 1px solid var(--border-main);
    padding: 5px;
    text-align: center;
}
.funds-table table thead tr td span {
    font-size: 13px;
    font-weight: 400;
}
.funds-table table tr td {
    min-width: 100px;
    padding: 8px 15px;
    text-align: left;
    align-content: center;
}
.funds-table table tr td.fund-stt {
    max-width: 40px;
    min-width: 40px;
    text-align: center;
}
.funds-table table tr td.fund-name {
    position: sticky;
    left: 0;
    min-width: 200px;
    max-width: 320px; /* chặn width để tên dài cắt ... thay vì nở ô */
}
.funds-table table tr td.fund-name a > div {
    min-width: 0; /* cho phép flex con co lại -> ellipsis hoạt động */
    flex: 1;
}
.funds-table table tr td.fund-name p {
    color: var(--text-main);
}
.funds-table table tr td.fund-name a {
    color: var(--text-main);
    font-weight: 500;
    text-decoration: none;
    transition: color ease-in-out 0.3s;
}
.funds-table table tr td.fund-name a:hover {
    color: #f5a504;
}
.funds-table table tr td.fund-name img {
    width: 40px;
    height: 40px;
    margin-right: 8px;
    border-radius: 6px;
    padding: 5px;
    background-color: #efefef;
    object-fit: contain;
}
.funds-table table tr td.fund-name a span {
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.funds-table table tr td.fund-company {
    min-width: 185px;
}
.funds-table table tr td.fund-assets {
    font-weight: 600;
    min-width: 125px;
}
.funds-table table tr td.fund-nav {
    font-weight: 600;
    min-width: 105px;
}
.funds-table table tr td.fund-period {
    min-width: 105px;
}
.funds-table table tr td.fund-assets, .funds-table table tr td.fund-period, .funds-table table tr td.fund-nav {
    text-align: center;
}
.top-ten h2.color-gradient-heading {
    font-size: 22px;
}
.top-ten .top-tickers, .top-ten .top-industries {
    flex: 1;
    width: 100%;
}
.top-ten .market-table table thead {
    top: 0px;
}
.top-ten table tbody td.market-industry {
    text-align: left;
    padding-top: 18px;
    padding-bottom: 18px;
}
.top-ten table td.market-industry {
    min-width: 170px;
    position: sticky;
    left: 0;
}
.top-ten table td.market-symbol {
    position: sticky;
    left: 0;
    min-width: 100px !important;
}
.top-ten table td.market-industry a {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
    transition: color ease-in-out 0.3s;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    line-clamp: 1;
    box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-ten table td.market-industry a:hover {
    color: #f5a504;
}
.top-ten table td.market-value span {
    font-weight: 400;
}
.top-ten table td.market-volumn {
    min-width: 90px;
}
.top-ten table td.market-value {
    min-width: 110px;
}
.top-ten .market-table {
    width: 100%;
    overflow: auto;
}
.ty-ajax-loading-box {
    position: fixed !important;
}

/* Sparkline lịch sử %% tỷ trọng 12T (đồng bộ với fund-detail.css) */
/* Specificity phải thắng .funds-table table tr td (text-align left, min-width 100px) */
.funds-table table tr td.fund-chart-icon-col {
    min-width: 36px;
    width: 36px;
    padding: 8px 6px;
    text-align: center;
}
.fund-chart-icon-col {
    text-align: center;
    cursor: default;
}
.ratio-chart-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #aaa);
    cursor: pointer;
    transition: color 0.15s;
}
.ratio-chart-icon:hover {
    color: #22c55e;
}
#sparkline-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-box-white, #fff);
    border: 1px solid var(--border-main, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    padding: 10px 12px 8px;
    display: none;
    min-width: 230px;
}
body.dark-mode #sparkline-tooltip {
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
.sparkline-title {
    font-size: 11px;
    color: var(--text-muted, #888);
    margin-bottom: 4px;
}
.sparkline-title strong {
    color: var(--text-main, #333);
    font-weight: 600;
}
.sparkline-no-data {
    font-size: 11px;
    color: var(--text-muted, #888);
    padding: 12px 0;
    text-align: center;
}
.sparkline-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 4px 4px;
    text-align: center;
    color: var(--text-muted, #888);
    min-width: 180px;
}
.sparkline-gate p {
    margin: 0;
    font-size: 12px;
    color: var(--text-main, #444);
    line-height: 1.4;
}
#sparkline-tooltip .sparkline-gate-btn {
    display: inline-block;
    margin-top: 2px;
    padding: 4px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    background: var(--bg-box-white, #f5f5f5);
    border: 1px solid var(--border-main, #ddd);
    color: var(--text-main, #444);
    transition: background 0.15s, border-color 0.15s;
}
#sparkline-tooltip .sparkline-gate-btn:hover {
    background: var(--border-main, #e8e8e8);
    color: var(--text-main, #444);
}
#sparkline-tooltip .sparkline-gate-btn--upgrade {
    background: #f4a502;
    border-color: #f4a502;
    color: #fff;
}
#sparkline-tooltip .sparkline-gate-btn--upgrade:hover {
    background: #d99000;
    border-color: #d99000;
    color: #fff;
}

.funds-table table tr td.fund-chart-col {
    min-width: 36px;
    width: 36px;
    color: var(--text-muted, #aaa);
}
/* ── Sub-tab chuyển view: Danh sách quỹ <-> Phân tích hoạt động ────────────── */
/* h1 sát trái, tabs sát phải cùng 1 hàng; bộ lọc loại quỹ/công ty xuống dòng riêng */
.header-tab {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 16px;
}
.header-tab > h1 { margin-right: auto; }
.header-tab .funds-type-controls { flex-basis: 100%; }

.funds-view-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    background-color: var(--bg-button-chart);
    padding: 4px;
    border-radius: 999px;
    margin: 6px 0;
}
.funds-view-tabs button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background-color: initial;
    border: none;
    color: var(--text-button-chart);
    font-size: 14px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.funds-view-tabs button svg {
    width: 16px;
    height: 16px;
    opacity: 0.85;
}
.funds-view-tabs button:hover { color: var(--text-main); }
/* badge "New": .box-content .new-item nằm ở stock-ticker.css (không load ở trang này) nên
   tự set style gradient giống .header-tab .box-title .new-item ở các trang khác; canh giữa nút pill */
.funds-view-tabs .new-item {
    background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 6px;
    gap: 2px;
    text-transform: capitalize;
    margin-bottom: 0;
    align-self: center;
}
.funds-view-tabs button.active {
    background-color: var(--bg-box-white);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
/* Phân tích ẩn mặc định (attr đặt sẵn ở HTML -> không nháy trước khi JS chạy) */
.funds-analytics { display: none; }
.box-content[data-funds-view="analytics"] .funds-analytics { display: block; }
/* Mở Phân tích -> ẩn khu bảng + bộ lọc loại quỹ/công ty.
   !important để thắng .d-flex của Bootstrap (display:flex !important) trên .funds-type-controls */
.box-content[data-funds-view="analytics"] .tab-content,
.box-content[data-funds-view="analytics"] .funds-type-controls { display: none !important; }

/* ── 6 chart phân tích quỹ ───────────────────────────────────────────────── */
.funds-analytics { margin-top: 24px; }
.funds-analytics > h2.color-gradient-heading { font-size: 22px; margin-bottom: 12px; }
.funds-charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.funds-chart-card {
    position: relative;
    background: var(--bg-box-white);
    border: 1px solid var(--border-main);
    border-radius: 10px;
    padding: 14px 14px 8px;
}
.funds-chart-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-right: 30px; /* chừa chỗ icon save góc phải -> nút không đè lên */
}
.funds-chart-head h3 { width: 100%; } /* tiêu đề chiếm trọn dòng -> nút xuống dòng dưới */
.funds-chart-head .fund-period-btns { order: 1; } /* time-chart sát trái */
.funds-chart-head .fund-group-btns { order: 2; margin-left: auto; } /* type-chart sát phải */
.funds-chart-head h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-main);
    margin: 5px 0 10px 0;
}
.funds-chart-head h3 span { font-size: 13px; font-weight: 400; color: var(--text-muted); }
.fund-group-btns, .fund-period-btns {
    display: inline-flex;
    background-color: var(--bg-button-chart);
    padding: 3px;
    border-radius: 10px;
}
.fund-group-btns button, .fund-period-btns button {
    background-color: initial;
    border: none;
    color: var(--text-button-chart);
    font-size: 14px;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
}
.fund-group-btns button.active, .fund-period-btns button.active {
    background-color: var(--bg-box-white);
}
.fund-period-btns button { padding: 2px 6px; font-size: 13px; }
.funds-chart-card .signal-chart { width: 100%; height: 400px; }
.funds-chart-card .save-chart {
    position: absolute;
    top: 12px;
    right: 12px;
    cursor: pointer;
    color: var(--text-muted);
    z-index: 2;
}
.funds-chart-card .save-chart:hover { color: #f5a504; }
.funds-charts-locked {
    height: 320px;
    background: var(--bg-box-white);
    border: 1px solid var(--border-main);
    border-radius: 10px;
}
/* Header dính nổi (JS clone .funds-table) cho bảng quỹ trên mobile — đồng bộ cuộn ngang
   qua scrollLeft. Ghi đè phần overflow/max-height/position của .funds-table gốc. */
.funds-sticky-head {
    position: fixed !important;
    top: 0; /* JS đặt lại = đáy header site để không bị che */
    z-index: 999;
    max-height: none !important;
    overflow: hidden !important; /* cắt thân bảng, chỉ chừa thead; JS set scrollLeft đồng bộ ngang */
    display: none;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}
.funds-sticky-head table { margin-bottom: 0; }

/* Đổi theme: tắt mọi transition trong khoảnh khắc chuyển -> hết flash sáng (main.js gắn
   .theme-switching vào <html> ngay trước khi toggle dark-mode, gỡ ở frame kế) */
html.theme-switching * { transition: none !important; }

/* ── Tất cả @media gom CUỐI file (tránh bị các rule sau ghi đè) ───────────────
   Thứ tự max-width từ lớn -> nhỏ để rule nhỏ hơn thắng ở viewport tương ứng. */
@media (max-width: 991px) {
    .funds-charts { grid-template-columns: 1fr; }
    /* Mobile/tablet: bỏ vùng cuộn DỌC riêng của bảng -> trang tự cuộn (hết kẹt khi chạm
       tới cuối bảng); vẫn giữ cuộn NGANG cho bảng nhiều cột. */
    .funds-table { max-height: none; overflow-y: hidden; }
}
@media (max-width: 768px) {
    .funds-table table thead tr td {
        font-size: 15px;
    }
}
@media (max-width: 600px) {
    /* Tabs chuyển view: h1 trọn dòng trên, tabs xuống dòng riêng dạng segmented full-width,
       2 nút chia đều -> gọn & cân đối thay vì pill nhỏ lệch trái cạnh h1 */
    .header-tab > h1 { width: 100%; margin-right: 0; }
    .funds-view-tabs {
        width: 100%;
        margin-top: 10px;
    }
    .funds-view-tabs button {
        flex: 1;
        justify-content: center;
        gap: 5px;
        padding: 3px;
        font-size: 13px;
    }
}
@media (max-width: 480px) {
    .box-content .nav-link {
        font-size: 15px;
    }
    .funds-table table tr td {
        padding-left: 8px;
        padding-right: 8px;
    }
    .market-table table td.market-value {
        display: table-cell;
        min-width: 98px;
    }
    .top-ten table td.market-volumn {
        min-width: 75px;
    }
    .funds-table table tr td.fund-company {
        display: none;
    }
    .funds-table table tr td.fund-name {
        max-width: 160px;
        min-width: 160px;
    }
    .funds-table table tr td.fund-assets {
        min-width: 105px;
    }
    .funds-table table tr td.fund-period {
        min-width: 86px;
    }
    .funds-table table tr td.fund-nav {
        min-width: 95px;
    }
    .funds-table table tr td.fund-period, .funds-table table tr td.fund-nav, .funds-table table tr td.fund-assets {
        text-align: center;
    }
    .top-ten h2.color-gradient-heading {
        font-size: 20px;
    }
}
@media (max-width: 340px) {
    .top-ten h2.color-gradient-heading {
        font-size: 17px;
    }
}
@media (min-width: 992px) {
    .funds-sticky-head { display: none !important; }
}
