/* ======================================= */
/* 0. Định nghĩa Biến Màu Sắc (THEME XANH TĂNG TRƯỞNG) */
/* ======================================= */
:root {
    /* --- MÀU CHÍNH (GREEN THEME) --- */
    /* Màu xanh lục đậm sang trọng (Financial Deep Green) */
    --primary-color: #115234;

    /* Màu khi di chuột (Đậm hơn chút) */
    --primary-color-hover: #093a22;

    /* Màu chữ khi active/link */
    --primary-text-active: #115234;

    /* --- MÀU NỀN (Giữ nguyên Flat White) --- */
    --bg-body: #f1f3f5;
    --bg-content: #FFFFFF;
    --bg-content-hover: #f9fafb;
    --bg-header: #f3f4f6;
    --bg-active-menu: #eff6ff;
    --bg-input-readonly: #f3f4f6;
    --bg-input: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-hover: rgba(0, 0, 0, 0.04);
    /* Added for mobile nav */

    /* --- MÀU CHỮ --- */
    --text-color-dark: #111827;
    --text-color-normal: #374151;
    --text-color-light: #6B7281;
    --text-color-icon: #4B5563;

    /* Link cũng theo tông xanh lá */
    --text-color-link: #115234;
    --text-color-inverted: #FFFFFF;

    /* --- MÀU VIỀN --- */
    --border-color-light: #e5e7eb;
    --border-color-input: #d1d5db;
    --border-color-divider: #f3f4f6;

    /* Shadow */
    --shadow-color: rgba(0, 0, 0, 0);
    --shadow-modal-backdrop: rgba(0, 0, 0, 0.6);

    /* --- SEMANTIC COLORS (NEW) --- */
    --primary-rgb: 17, 82, 52;
    --color-success: #115234;
    --color-danger: #ef476f;
    --color-warning: #f59e0b;
    --color-info: #0ea5e9;
    --color-zalo: #008CFF;

    /* RGB values for status transparency (Light Mode) */
    --success-rgb: 25, 135, 84;
    --danger-rgb: 239, 71, 111;
    --warning-rgb: 245, 158, 11;
    --info-rgb: 14, 165, 233;

    /* MÀU SẮC CHUẨN BẢNG GIÁ CHỨNG KHOÁN */
    --stock-ceil: #d946ef;     /* Trần: Tím */
    --stock-floor: #06b6d4;    /* Sàn: Xanh lơ (cyan) */
    --stock-ref: #f59e0b;      /* TC: Vàng */
    --stock-up: #10b981;       /* Tăng: Xanh lá */
    --stock-down: #ef476f;     /* Giảm: Đỏ */
    
    --stock-bg-up-flash: rgba(16, 185, 129, 0.25);
    --stock-bg-down-flash: rgba(239, 71, 111, 0.25);

    /* --- GLOBAL COMPONENT VARIABLES --- */
    --text-primary: #333333;
    /* Main text */
    --text-secondary: #666666;
    /* Secondary text */
    --table-head-bg: #f8f9fa;
    --border-color: #eeeeee;

    /* --- COMPACT NEUMORPHISM VARIABLES (NEW) --- */
    --app-padding-desktop: 15px;
    /* Lề trái/phải Desktop */
    --app-padding-mobile: 10px;
    /* Lề trái/phải Mobile */
    --app-top-padding-desktop: 15px;
    /* Lề trên Desktop */
    --app-top-padding-mobile: 15px;
    /* Lề trên Mobile */

    --app-side-padding: var(--app-padding-desktop);
    --app-top-padding: var(--app-top-padding-desktop);

    --app-gap: 12px;
    --app-max-width: 1400px;
    --border-radius-global: 10px;
    --card-radius: var(--border-radius-global);
    --input-radius: var(--border-radius-global);
    --btn-radius: var(--border-radius-global);
    --card-padding: 15px;

    /* --- SIZING STANDARDS (NEW) --- */
    --input-height: 38px;
    --btn-height: 38px;

    /* --- SHADOW STANDARDS (FLAT & CLEAN FINANCIAL UI) --- */
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-inset: none;

    /* --- TABLE STRIPING (NEW) --- */
    --table-stripe-even: rgba(0, 0, 0, 0.02);

    /* --- TRANSITION STANDARDS (NEW) --- */
    --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* --- AVATAR SIZING STANDARDS (NEW) --- */
    --avatar-size-sm: 32px;
    --avatar-size-md: 40px;
    --avatar-size-lg: 48px;
    --avatar-size-xl: 120px;
}

html {
    overflow-y: scroll; /* Force vertical scrollbar to prevent layout jump when switching tabs with different heights */
}

/* =========================================================
   CUSTOM SYSTEM SCROLLBAR (STANDARD & FLAT)
   ========================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-input, #d1d5db);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-color-light, #6B7281);
    border: 2px solid transparent;
    background-clip: padding-box;
}

html.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid transparent;
    background-clip: padding-box;
}

html.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Định nghĩa màu cho Chế độ Tối (Dark Mode) */
html.dark-mode {
    --primary-color: #e6b800;
    /* Giữ vàng ánh kim cho nhận diện thương hiệu tối */
    --primary-color-hover: #cca300;
    --primary-text-active: #ffd633;
    /* Xanh lá sáng hơn trên nền tối */

    /* Nền tối phẳng kiểu SaaS hiện đại (GitHub Style) */
    --bg-body: #0d1117;
    --bg-content: #0d1117;
    --bg-content-hover: rgba(255, 255, 255, 0.04);
    --bg-header: #161b22;
    --bg-active-menu: #161b22;
    --bg-input-readonly: #161b22;
    --bg-input: #161b22;
    --bg-card: #161b22;
    --bg-hover: rgba(255, 255, 255, 0.04);
    /* Added for mobile nav */

    /* Chữ Dark Mode */
    --text-color-dark: #f0f6fc;
    --text-color-normal: #c9d1d9;
    --text-color-light: #8b949e;
    --text-color-icon: #8b949e;
    --text-color-link: #ffd633;
    --text-color-inverted: #FFFFFF;

    /* Viền Dark Mode (Mờ tinh tế kiểu SaaS hiện đại) */
    --border-color-light: rgba(255, 255, 255, 0.08);
    --border-color-input: rgba(255, 255, 255, 0.15);
    --border-color-divider: rgba(255, 255, 255, 0.06);

    --shadow-color: rgba(0, 0, 0, 0.5);
    --shadow-modal-backdrop: rgba(0, 0, 0, 0.8);

    /* --- SEMANTIC COLORS (Dark Mode) --- */
    --color-success: #e6b800;
    --primary-rgb: 230, 184, 0;
    /* Lighter shade if needed, but 25, 135, 84 for consistency */
    --color-danger: #ef476f;
    --color-warning: #f59e0b;
    --color-info: #38bdf8;
    --color-zalo: #008CFF;

    /* RGB values for status transparency (Dark Mode contrast) */
    --success-rgb: 117, 183, 152;
    --danger-rgb: 242, 108, 137;
    --warning-rgb: 247, 195, 95;
    --info-rgb: 56, 189, 248;

    /* MÀU SẮC CHUẨN BẢNG GIÁ CHỨNG KHOÁN (Dark Mode) */
    --stock-ceil: #f472b6;     /* Tím hồng sáng hơn */
    --stock-floor: #22d3ee;    /* Xanh lơ sáng hơn */
    --stock-ref: #fbbf24;      /* Vàng sáng hơn */
    --stock-up: #34d399;       /* Xanh lá sáng hơn */
    --stock-down: #f87171;     /* Đỏ sáng hơn */

    /* --- GLOBAL COMPONENT VARIABLES (Dark Mode) --- */
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --table-head-bg: #252525;
    --border-color: #333333;

    /* --- SIZING STANDARDS (Dark Mode) --- */
    --input-height: 38px;
    --btn-height: 38px;

    /* --- COMPACT SHADOW VARIABLES (Dark Mode Flat UI) --- */
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-inset: none;

    /* --- TABLE STRIPING (Dark Mode) --- */
    --table-stripe-even: rgba(255, 255, 255, 0.03);
}

/* Tự động điều chỉnh Padding theo thiết bị */
@media (max-width: 768px) {
    :root {
        --app-side-padding: var(--app-padding-mobile);
        --app-top-padding: var(--app-top-padding-mobile);
    }
}

/* ======================================= */
/* 1. Reset và Typography cơ bản           */
/* ======================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body,
html {
    min-height: 100vh;
    background-color: var(--bg-body);
    color: var(--text-color-normal);
}

/* ======================================= */
/* 1.5 Custom Scrollbar (Toàn hệ thống)    */
/* ======================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color-input);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-color-light);
}

html.dark-mode ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

html.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ======================================= */
/* 2. Cấu Trúc Ứng Dụng (App Layout)       */
/* ======================================= */
.app-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    /* Fix grid blowout */
    min-height: 100vh;
    transition: grid-template-columns 0.3s ease;
    align-items: start;
    /* Ensure sticky works properly */
}

/* Make navbar span the rest of the layout */
.app-layout > .navbar {
    grid-column: 2 / -1;
    grid-row: 1;
}

/* Main content wrapper starts below navbar */
.app-layout > .main-content-wrapper {
    grid-column: 2 / 3;
    grid-row: 2;
}

/* Layout 2 (Right Sidebar) */
.app-layout.layout-2 {
    grid-template-columns: 280px minmax(0, 1fr) 304px; /* 280px + 24px right padding = 304px */
}

.app-layout.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

.app-layout.layout-2.sidebar-collapsed {
    grid-template-columns: 0 minmax(0, 1fr) 304px;
}

.app-layout.sidebar-collapsed .sidebar {
    width: 0;
    padding: 20px 0;
    /* Keep vertical padding or set to 0? Set to 0 to hide completely */
    padding: 0;
    overflow: hidden;
    border-right: none;
}

.main-content-wrapper {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
}

/* ======================================= */
/* 3. Sidebar Layout (FLAT STYLE)          */
/* ======================================= */
.sidebar {
    background-color: var(--bg-body);
    padding: 0 15px;
    /* Removed top/bottom padding to control header height strictly */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1001;
    border-right: 1px solid var(--border-color-light);
    transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease;
    width: 280px;
    /* Explicit width */
    grid-column: 1 / 2;
    grid-row: 1 / -1;
}

.sidebar-header {
    height: 55px;
    /* Match Navbar Height */
    display: flex;
    /* Ensure centering */
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    /* Remove vertical padding */
    border-bottom: 1px solid var(--border-color-light);
    margin-bottom: 15px;
    /* Logo sizing handled by .brand-logo */
}

.brand-logo {
    max-height: 30px;
    width: auto;
    display: block;
}

.mobile-menu-close {
    display: none;
}

.sidebar-menu {
    list-style: none;
}

.menu-heading {
    padding: 15px 10px 5px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-color-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin: 2px 8px;
    color: var(--text-color-normal);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-icon {
    font-size: 1.2em;
    margin-right: 10px;
    width: 20px;
    text-align: center;
    color: var(--text-color-icon);
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background-color: var(--bg-content-hover);
    color: var(--primary-color);
    box-shadow: none;
    transform: translateY(-1px);
    font-weight: 600;
}

html.dark-mode .sidebar-menu a:hover,
html.dark-mode .sidebar-menu a.active {
    background-color: var(--bg-content-hover) !important;
    color: #ffffff !important;
    box-shadow: none !important;
}

.sidebar-menu a.active .menu-icon,
.sidebar-menu a:hover .menu-icon {
    color: inherit !important;
}

/* ======================================= */
/* 3.1 Right Sidebar (Widget Area)         */
/* ======================================= */
.right-sidebar {
    background-color: var(--bg-body);
    padding: var(--app-top-padding) var(--app-side-padding) 20px 0;
    margin-left: 0; 
    z-index: 10;
    border-left: none; 
    width: 100%; 
    grid-column: 3 / 4;
    grid-row: 2;
    align-self: stretch; /* MUST stretch to main content height so the last widget has room to stick */
    /* Removed fixed height and overflow to allow it to scroll naturally with the page */
}

/* Kỹ thuật dính Widget cuối cùng (Sticky Last Widget) 
   Khi cuộn trang xuống, các widget trôi lên bình thường,
   nhưng riêng widget cuối cùng sẽ dính lại ở đỉnh màn hình để cột phải không bị trống */
.right-sidebar .widget-block:last-child {
    position: sticky;
    top: 75px; /* Dưới Navbar 55px + một khoảng margin nhỏ */
    z-index: 11;
}

/* Ẩn thanh cuộn của right-sidebar cho đẹp hơn */
.right-sidebar::-webkit-scrollbar {
    display: none;
}
.right-sidebar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

.widget-block {
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .app-layout.layout-2,
    .app-layout.sidebar-collapsed.layout-2 {
        grid-template-columns: 280px minmax(0, 1fr);
    }
    
    /* Trên màn hình nhỏ (ví dụ Mobile/Tablet), đưa Right Sidebar xuống dưới cùng */
    .right-sidebar {
        grid-column: 2 / -1; 
        grid-row: 3;
        width: 100%;
        height: auto;
        position: static;
        border-left: none;
        border-top: 1px solid var(--border-color-light);
        padding: 20px 15px;
        margin-left: 0;
    }
}
@media (max-width: 768px) {
    .app-layout.layout-2 {
        grid-template-columns: 1fr;
    }
    .right-sidebar {
        grid-column: 1 / -1;
    }
}

/* ======================================= */
/* 4. Navbar (FLAT & BORDERLESS)           */
/* ======================================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--app-side-padding) !important;
    height: 55px;
    background-color: var(--bg-body);
    border-bottom: 1px solid var(--border-color-light);
    box-shadow: none !important;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-left {
    display: flex;
    align-items: center;
}



/* Navbar Search Pill Style (New) */
.navbar-search-pill {
    display: flex;
    align-items: center;
    background: var(--bg-content-hover);
    border-radius: 50px;
    padding: 5px 18px;
    gap: 10px;
    width: 350px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    margin-right: 15px;
}

.navbar-search-pill:focus-within {
    background: var(--bg-body);
    box-shadow: none;
    border-color: var(--primary-color);
}

.navbar-search-pill button {
    background: none;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.navbar-search-pill button span {
    color: var(--text-color-light);
    font-size: 24px;
    /* Tăng lên 24px để đồng bộ với theme-btn */
    transition: color 0.2s;
}

.navbar-search-pill button:hover span {
    color: var(--primary-color);
}

.navbar-search-pill input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-color-normal);
    font-size: 0.9rem;
    width: 100%;
}

.navbar-search-pill input::placeholder {
    color: var(--text-color-light);
    opacity: 0.7;
}

@media (max-width: 992px) {
    .navbar-search-pill {
        width: 200px;
    }
}

@media (max-width: 768px) {
    .navbar-search-pill {
        width: auto;
        background: none;
        padding: 0;
        margin-right: 10px;
    }

    .navbar-search-pill input {
        display: none;
    }

    .navbar-search-pill button {
        padding: 5px;
        /* Thêm padding để có touch target giống theme-btn */
    }

    .navbar-search-pill:focus-within {
        box-shadow: none;
    }
}

.navbar-indices {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 0 20px;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.index-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.index-name {
    color: var(--text-color-light);
}

.index-price {
    color: var(--text-color-dark);
}

.index-change {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
}

.index-change.up {
    color: #22c55e;
}

.index-change.down {
    color: #ef4444;
}

.index-change .material-symbols-outlined {
    font-size: 14px;
}

.navbar-mobile-ticker {
    display: none;
}

@media (max-width: 1024px) {
    .navbar-indices {
        display: none;
    }

    .navbar-mobile-ticker {
        display: flex;
        position: fixed;
        top: 55px;
        left: 0;
        width: 100%;
        height: 35px;
        background-color: var(--bg-body);
        border-bottom: 1px solid var(--border-color-light);
        z-index: 999;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 15px;
        align-items: center;
        gap: 25px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        scrollbar-width: none;
        /* Ensure it's not hidden by 0 height */
        min-height: 35px;
    }

    .navbar-mobile-ticker::-webkit-scrollbar {
        display: none;
    }

    .navbar-mobile-ticker .index-item {
        flex-shrink: 0;
    }

    /* Hiệu ứng Marquee chạy tự động */
    .ticker-track {
        display: flex;
        gap: 25px;
        width: max-content;
        animation: marquee 20s linear infinite;
        padding-right: 25px;
    }

    /* Tạm dừng khi người dùng chạm vào */
    .navbar-mobile-ticker:active .ticker-track {
        animation-play-state: paused;
    }

    @keyframes marquee {
        0% {
            transform: translateX(0);
        }

        100% {
            transform: translateX(-50%);
        }
    }
}





.app-logo-img {
    height: 26px;
    margin-right: 15px;
    display: none;
}

.hamburger-menu {
    display: block;
    margin-right: 15px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-color-normal);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    font-size: 0.9rem;
    font-weight: 500;
}

.theme-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color-icon);
    transition: background-color 0.2s, color 0.2s;
}

.theme-btn:hover {
    background-color: var(--bg-content-hover);
    color: var(--text-color-dark);
}

.theme-btn .material-symbols-outlined {
    font-size: 24px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background-color: var(--primary-color);
    color: var(--text-color-inverted);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
}

.user-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 10;
    background: var(--bg-content);
    border: 1px solid var(--border-color-light);
    border-radius: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(5px);
    transition: opacity 0.2s, transform 0.2s;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color-divider);
}

/* [CẬP NHẬT] Style cho Item trong Dropdown (Flexbox + Icon) */
.dropdown-item {
    display: flex;
    /* Dùng Flex để icon và text ngang hàng */
    align-items: center;
    /* Căn giữa dọc */
    gap: 10px;
    /* Khoảng cách giữa icon và chữ */
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text-color-normal);
    font-size: 14px;
}

/* [CẬP NHẬT] Style icon Material Symbols trong dropdown */
.dropdown-item .material-symbols-outlined {
    font-size: 20px;
    color: var(--text-color-icon);
}

.dropdown-item:hover {
    background-color: var(--bg-content-hover);
    color: var(--text-color-dark);
    /* Hover chữ đậm hơn */
}

/* ========================================================= */
/* 5. Main Content (CLEAN & FLAT DASHBOARD STYLE)            */
/* ========================================================= */
.container {
    padding: var(--app-top-padding) var(--app-side-padding) var(--app-gap) var(--app-side-padding) !important;
    flex-grow: 1;
    width: 100% !important;
    margin: 0 auto;
}

/* Các khối Neumorphic chuẩn (Compact) */
.neumorph-card {
    background-color: var(--bg-body);
    border-radius: var(--card-radius);
    padding: var(--card-padding);
    box-shadow: var(--shadow-light);
    margin-bottom: var(--app-gap);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

html.dark-mode .neumorph-card {
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.neumorph-card:hover {
    transform: translateY(-2px);
}

/* Các khối nội dung phẳng (Flat Blocks) */
.filters-container,
.data-table-container,
.compare-table-container,
.card,
.panel {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;

    /* Padding/Margin Shorthand: Top Right Bottom Left */
    padding: 0 0 10px 0 !important;
    margin: 0 0 10px 0 !important;

    /* Vạch ngăn cách */
    border-bottom: 1px solid var(--border-color-light) !important;
}

/* Xóa vạch ngăn cách ở phần tử cuối cùng */
.main-content-wrapper>.container>div:last-child {
    border-bottom: none !important;
    margin-bottom: 0 !important;
}

/* Các class layout động */
.layout-fluid {
    max-width: none !important;
}

.layout-standard {
    max-width: var(--app-max-width) !important;
    margin: 0 auto !important;
}

.layout-auth {
    max-width: 500px !important;
    margin-top: 5vh !important;
}

/* Typography */
h1,
h2,
h3,
.page-header h1 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--text-color-dark);
    font-weight: 600;
}

/* Form Elements */
.quick-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.quick-filter-btn {
    padding: 5px 12px;
    border: none;
    background-color: var(--bg-content-hover);
    color: var(--text-color-normal);
    cursor: pointer;
    border-radius: 4px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s;
}

.quick-filter-btn:hover {
    background-color: var(--border-color-light);
}

.quick-filter-btn.active {
    background-color: var(--primary-color);
    color: var(--text-color-inverted);
}

.filter-horizontal-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.filter-horizontal-layout .filter-group {
    flex-grow: 1;
    min-width: 150px;
    max-width: 250px;
}

.filter-horizontal-layout .filter-actions {
    flex-grow: 0;
    display: flex;
    gap: 10px;
}

.filter-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-color-light);
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--border-color-input);
    border-radius: 0;
    width: 100%;
    background-color: transparent;
    color: var(--text-color-dark);
    font-weight: 500;
    height: var(--input-height);
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
}

.btn-primary {
    padding: 0 20px;
    height: var(--btn-height);
    border: none !important;
    border-radius: 12px;
    background: var(--primary-color);
    color: var(--text-color-inverted);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* GLOBAL HEADER DARK MODE BUTTON OVERRIDE */
html.dark-mode .btn-primary {
    background-color: #f0f0f0;
    color: #000000;
}

html.dark-mode .btn-primary:hover {
    background-color: #e0e0e0;
}

.btn-secondary {
    padding: 0 20px;
    height: var(--btn-height);
    border: 1px solid var(--border-color-input);
    border-radius: 4px;
    background-color: transparent;
    color: var(--text-color-normal);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* ======================================= */
/* 6. Data Tables (CLEAN STYLE)            */
/* ======================================= */
.data-table-container,
.compare-table-container {
    overflow-x: auto;
    border-bottom: none !important;
    /* Riêng bảng không cần gạch chân container */
}

#portfolio-table,
.compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

/* Header bảng */
#portfolio-table th,
.compare-table thead th {
    background-color: var(--bg-header);
    font-weight: 600;
    font-size: 13px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color-light);
    padding: 10px 12px !important;
    border: none;
    text-align: left;
}

/* Nội dung bảng */
#portfolio-table td,
.compare-table td {
    padding: 8px 12px !important;
    border-bottom: 1px solid var(--border-color-divider);
    font-size: 14px !important;
    color: var(--text-color-normal);
}

#portfolio-table tr:hover td {
    background-color: var(--bg-content-hover);
}

/* Phân trang */
/* Phân trang Neumorphic (Soft UI) */
.pagination-controls {
    display: flex;
    justify-content: flex-start;
    /* Căn trái tránh nút Zalo */
    align-items: center;
    gap: 15px;
    margin-top: 25px;
    font-size: 13.5px;
    color: var(--text-color-normal);
    flex-wrap: wrap;
}

.pagination-rows-per-page {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pagination-rows-per-page select {
    padding: 6px 32px 6px 12px;
    border: none !important;
    border-radius: 10px;
    color: var(--text-color-dark);
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.3s ease;

    /* Safari & Chrome Fix */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--bg-body) !important;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiM2NjY2NjYiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cG9seWxpbmUgcG9pbnRzPSI2IDkgMTIgMTUgMTggOSI+PC9wb2x5bGluZT48L3N2Zz4=") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
}

html.dark-mode .pagination-rows-per-page select {
    box-shadow: none;
    background-color: var(--bg-body) !important;
    background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNjY2NjY2MiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cG9seWxpbmUgcG9pbnRzPSI2IDkgMTIgMTUgMTggOSI+PC9wb2x5bGluZT48L3N2Zz4=") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
}

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

.pagination-nav button,
.btn-pagination {
    padding: 8px 16px;
    border: none !important;
    background: var(--bg-body) !important;
    color: var(--text-color-normal);
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

html.dark-mode .pagination-nav button,
html.dark-mode .btn-pagination {
    box-shadow: var(--shadow-light);
    color: var(--text-color-dark);
}

.pagination-nav button:hover:not(:disabled),
.btn-pagination:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
    color: var(--primary-color);
}

html.dark-mode .pagination-nav button:hover:not(:disabled),
html.dark-mode .btn-pagination:hover:not(:disabled) {
    box-shadow: var(--shadow-light);
    color: #ffffff;
}

.pagination-nav button:active:not(:disabled),
.btn-pagination:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.pagination-nav button:disabled,
.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
    background: transparent !important;
    color: var(--text-color-light);
}

#pageInfo {
    font-weight: 700;
    margin: 0 5px;
    color: var(--text-color-dark);
}

/* ======================================= */
/* 7. Responsive (Mobile)                  */
/* ======================================= */
@media (max-width: 768px) {
    .app-logo-img {
        display: block;
    }

    .sidebar-header {
        display: none;
    }

    .app-layout {
        grid-template-columns: minmax(0, 1fr);
        max-width: 100vw !important;
        overflow-x: hidden !important;
        display: block !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-280px);
        /* Khớp với độ rộng sidebar */
        border-right: 1px solid var(--border-color-light);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    /* [CẬP NHẬT] Cố định Navbar trên Mobile để không bị trôi khi vuốt */
    .navbar {
        position: fixed;
        /* Ghim chặt navbar */
        top: 0;
        left: 0;
        width: 100% !important;
        max-width: 100vw !important;
        /* z-index thấp hơn sidebar (1001) nhưng cao hơn nội dung (1) */
        z-index: 1000;
        border-bottom: 1px solid var(--border-color-light);
        box-sizing: border-box !important;
        display: flex !important;
        justify-content: space-between !important;
    }

    .navbar-left,
    .navbar-user {
        min-width: 0;
        flex-shrink: 1;
    }

    .navbar-user .nav-greeting {
        display: none;
        /* Mặc định ẩn trên màn hình cực nhỏ */
    }

    /* Hiện lại lời chào khi có đủ không gian (từ 380px trở lên) */
    @media (min-width: 380px) {
        .navbar-user .nav-greeting {
            display: inline-block;
            max-width: 70px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            vertical-align: middle;
            font-size: 13px;
        }
    }

    .app-logo-img {
        max-width: 100px !important;
        object-fit: contain;
    }

    .navbar-user {
        gap: 5px !important;
        justify-content: flex-end;
    }

    /* [CẬP NHẬT] Đẩy nội dung xuống để không bị Navbar che mất (Chỉ áp dụng trên mobile khi navbar là fixed) */
    .main-content-wrapper {
        padding-top: 90px;
        /* 55px Navbar + 35px Ticker */
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    .container {
        /* Đã gỡ bỏ padding cứng 5px để tuân thủ theo biến --app-top-padding-mobile */
        padding: var(--app-top-padding) var(--app-side-padding) var(--app-gap) var(--app-side-padding) !important;
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--shadow-modal-backdrop);
        z-index: 999;
        /* Đảm bảo overlay nằm dưới sidebar nhưng trên navbar */
        display: none;
    }

    .overlay.show {
        display: block;
    }

    /* Filter mobile */
    .filter-horizontal-layout {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .filter-horizontal-layout .filter-group,
    .filter-horizontal-layout .filter-actions {
        max-width: none;
        min-width: 100%;
    }

    /* Table Mobile (Card View) */
    #portfolio-table thead {
        display: none;
    }

    #portfolio-table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid var(--border-color-light);
        border-radius: 8px;
        background-color: var(--bg-content);
        padding: 15px;
    }

    #portfolio-table td {
        display: block;
        text-align: right;
        padding-left: 50% !important;
        position: relative;
        border-bottom: 1px dashed var(--border-color-divider);
        padding: 8px 0 !important;
    }

    #portfolio-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        text-align: left;
        font-weight: 600;
        color: var(--text-color-light);
        font-size: 12px;
        text-transform: uppercase;
    }
}

/* ======================================= */
/* 8. Fix Dark Mode Logo                   */
/* ======================================= */
/* ======================================= */
/* 8. Fix Dark Mode Logo                   */
/* ======================================= */
.brand-logo.logo-light {
    display: block;
}

.brand-logo.logo-dark {
    display: none;
}

html.dark-mode .brand-logo.logo-light {
    display: none;
}

html.dark-mode .brand-logo.logo-dark {
    display: block;
}

.app-logo-img.logo-light,
.app-logo-img.logo-dark {
    display: none;
}

@media (max-width: 768px) {
    .app-logo-img.logo-light {
        display: block;
    }

    html.dark-mode .app-logo-img.logo-light {
        display: none;
    }

    html.dark-mode .app-logo-img.logo-dark {
        display: block;
    }

    .mobile-menu-close {
        display: block;
        background: none;
        border: none;
        color: var(--text-color-normal);
        cursor: pointer;
    }

    /* [MỚI] Phân trang mobile xếp chồng */
    .pagination-controls {
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        justify-content: center !important;
        margin-top: 20px !important;
        width: 100%;
    }

    .pagination-rows-per-page {
        order: 2;
    }

    .pagination-nav {
        order: 1;
        width: 100%;
        justify-content: center;
    }
}

.pagination-nav {
    order: 1;
    width: 100%;
    justify-content: center;
}

/* ======================================= */
/* X. CHẾ ĐỘ NEUMORPHISM (CLASSIC STYLE)   */
/* ======================================= */
html.neumorphic-mode {
    /* Khôi phục bóng đổ lồi lõm âm dương Neumorphic cho Light mode */
    --card-shadow: none;
    --card-shadow-hover: none;
    --card-border: 1px solid var(--border-color-light) !important;

    /* Nền body sẫm hơn chút để card nổi bật lồi lên */
    --bg-body: #f0f4f0;

    /* Viền trong suốt */
    --border-color-light: transparent;
    --border-color-divider: rgba(0, 0, 0, 0.05);
}

html.neumorphic-mode.dark-mode {
    /* Khôi phục bóng đổ Neumorphic cho Dark mode */
    --card-shadow: none;
    --card-shadow-hover: none;
    --card-border: 1px solid var(--border-color-light) !important;

    --bg-body: #161816;
    --border-color-light: transparent;
    --border-color-divider: rgba(255, 255, 255, 0.05);
}

/* Hủy bỏ style màu sắc của M3 Filled Cards ở chế độ Neumorphism */
html.neumorphic-mode .ai-power-widget,
html.neumorphic-mode .announcement-card,
html.neumorphic-mode .right-widget-card,
html.neumorphic-mode .cta-card {
    background: var(--bg-card) !important;
    color: var(--text-color-normal) !important;
    border: none !important;
    box-shadow: none !important;
}

html.neumorphic-mode .ai-power-widget .card-title,
html.neumorphic-mode .announcement-card .card-title {
    color: var(--text-color-dark) !important;
}

html.neumorphic-mode .ai-power-widget .card-title .material-symbols-outlined,
html.neumorphic-mode .announcement-card .card-title .material-symbols-outlined {
    color: var(--primary-color) !important;
}

html.neumorphic-mode .ai-power-widget .ai-power-desc,
html.neumorphic-mode .announcement-card .item-meta {
    color: var(--text-color-light) !important;
}

/* Khôi phục nền item con trong card thông báo và widget right sidebar */
html.neumorphic-mode .announcement-card .db-list-item,
html.neumorphic-mode .right-widget-card .widget-user-item,
html.neumorphic-mode .right-widget-card .db-list-item {
    background: var(--bg-body) !important;
    border: none !important;
    box-shadow: none !important;
}

html.neumorphic-mode .announcement-card .item-title {
    color: var(--text-color-dark) !important;
    font-weight: normal;
}

/* Reset Stock Pills ở chế độ Neumorphism */
html.neumorphic-mode .stock-pill.pill-buy,
html.neumorphic-mode .stock-pill.pill-near {
    background: var(--bg-card) !important;
    color: var(--text-color-normal) !important;
    border: none !important;
    box-shadow: none !important;
}

html.neumorphic-mode .stock-pill.pill-buy .stock-symbol,
html.neumorphic-mode .stock-pill.pill-near .stock-symbol {
    color: var(--primary-color) !important;
}

html.neumorphic-mode .stock-pill.pill-buy .stock-status {
    background: rgba(var(--primary-rgb), 0.1) !important;
    color: var(--color-success) !important;
}

html.neumorphic-mode .stock-pill.pill-near .stock-status {
    background: rgba(245, 158, 11, 0.1) !important;
    color: var(--color-warning) !important;
}

html.neumorphic-mode .stock-pill.pill-buy .stock-target,
html.neumorphic-mode .stock-pill.pill-near .stock-target {
    color: var(--text-color-dark) !important;
}

html.neumorphic-mode .stock-pill.pill-buy .stock-upside,
html.neumorphic-mode .stock-pill.pill-near .stock-upside {
    color: var(--color-success) !important;
    opacity: 1 !important;
}

/* Reset Tool Items ở chế độ Neumorphism */
html.neumorphic-mode .tool-item {
    box-shadow: none !important;
    border: none !important;
}

html.neumorphic-mode .tool-item .material-symbols-outlined {
    background: rgba(var(--primary-rgb), 0.1) !important;
    color: var(--primary-color) !important;
}

/* =========================================================
   GLOBAL CSS UTILITIES (STANDARD)
   ========================================================= */

/* Alignment Utilities */
.mh-text-start { text-align: left !important; }
.mh-text-center { text-align: center !important; }
.mh-text-end { text-align: right !important; }

/* Structural Grid & Flexbox Utilities */
.mh-flex-row {
    display: flex !important;
    align-items: center;
    gap: 15px;
}

.mh-grid-2 {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .mh-grid-2 {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
}

.mh-form-group {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.mh-form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color-normal);
}

/* Animations Utilities */
.mh-fade-in {
    animation: mh-fade-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes mh-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Shimmer Loading Animation */
.mh-shimmer {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.03) 25%, 
        rgba(255, 255, 255, 0.08) 50%, 
        rgba(255, 255, 255, 0.03) 75%);
    background-size: 200% 100%;
    animation: mh-shimmer 1.5s infinite linear;
}

html:not(.dark-mode) .mh-shimmer {
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.03) 25%, 
        rgba(0, 0, 0, 0.06) 50%, 
        rgba(0, 0, 0, 0.03) 75%);
    background-size: 200% 100%;
}

@keyframes mh-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Transition Optimization */
.sidebar-menu a,
.navbar-search-pill,
.btn-circle-add,
.btn-circle-secondary,
.btn-circle-primary,
.quick-filter-btn {
    transition: var(--transition-smooth) !important;
}

/* --- Stock Market Price Colors Utility Classes --- */
.stock-ceil { color: var(--stock-ceil) !important; }
.stock-floor { color: var(--stock-floor) !important; }
.stock-ref { color: var(--stock-ref) !important; }
.stock-up { color: var(--stock-up) !important; }
.stock-down { color: var(--stock-down) !important; }

/* Đồng bộ các class màu chữ tiện ích khác */
.text-success { color: var(--stock-up) !important; }
.text-danger { color: var(--stock-down) !important; }
.text-warning { color: var(--stock-ref) !important; }

/* --- 14. GLOBAL BADGES & TAGS SYSTEM --- */
.mh-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px !important;
    font-size: 0.75rem !important; /* 12px */
    font-weight: 600 !important;
    line-height: 1 !important;
    border-radius: 6px !important;
    text-transform: none !important;
    border: 1px solid transparent !important;
    white-space: nowrap !important;
}

.mh-badge-success {
    background-color: rgba(25, 135, 84, 0.1) !important;
    color: var(--color-success, #115234) !important;
}

.mh-badge-danger {
    background-color: rgba(239, 71, 111, 0.1) !important;
    color: var(--color-danger, #ef476f) !important;
}

.mh-badge-warning {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: var(--color-warning, #f59e0b) !important;
}

.mh-badge-info {
    background-color: rgba(14, 165, 233, 0.1) !important;
    color: var(--color-info, #0ea5e9) !important;
}

.mh-badge-secondary {
    background-color: var(--bg-header) !important;
    color: var(--text-color-normal) !important;
    border: 1px solid var(--border-color-light) !important;
}

html.dark-mode .mh-badge-success {
    background-color: rgba(117, 183, 152, 0.15) !important;
    color: #34d399 !important;
}

html.dark-mode .mh-badge-danger {
    background-color: rgba(242, 108, 137, 0.15) !important;
    color: #f87171 !important;
}

html.dark-mode .mh-badge-warning {
    background-color: rgba(247, 195, 95, 0.15) !important;
    color: #fbbf24 !important;
}

html.dark-mode .mh-badge-info {
    background-color: rgba(56, 189, 248, 0.15) !important;
    color: #38bdf8 !important;
}