/* nganh.css — Stylesheet cho trang Tín Hiệu Ngành */

.page-nganh .nganh-main {
    margin-left: 240px;
    padding: 24px 24px 0 24px; /* Removed bottom padding */
    min-height: 100vh;
    max-width: calc(100vw - 240px);
    display: flex;
    flex-direction: column;
}

.nganh-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.nganh-header h1 {
    font-size: clamp(18px, 4vw, 24px);
    font-weight: 800;
    color: var(--text-primary);
    background: linear-gradient(135deg, #00e5ff 0%, #00e676 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nganh-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nganh-header .update-time {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
}

body.light-theme .nganh-header .update-time {
    background: rgba(0,0,0,0.04);
}

.nganh-legend {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Bento Grid Layout */
.nganh-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    flex: 1;
}

.bento {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
}

.bento:hover {
    border-color: rgba(0, 230, 118, 0.2);
    box-shadow: 0 8px 32px rgba(0, 230, 118, 0.06);
    transform: translateY(-1px);
}

body.light-theme .bento {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

body.light-theme .bento:hover {
    border-color: rgba(0, 150, 80, 0.3);
    box-shadow: 0 8px 32px rgba(0, 150, 80, 0.08);
}

.bento-title {
    font-size: clamp(11.5px, 2vw, 13px);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.light-theme .bento-title { color: #1e293b; }

.bento-title .icon {
    font-size: 16px;
}

/* Sub-text mô tả bên dưới tiêu đề bento */
.bento-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

body.light-theme .bento-sub {
    color: #64748b;
}


/* ── Size variants (4-Row Layout) ───────────────────────────────── */
.bento-hero   { grid-column: span 12; min-height: 420px; }  /* ROW 1: Treemap full width */
.bento-8col   { grid-column: span 8;  min-height: 260px; }  /* ROW 4: X-Quang */
.bento-7col   { grid-column: span 7;  min-height: 260px; }
.bento-6col   { grid-column: span 6;  min-height: 260px; }
.bento-5col   { grid-column: span 5;  min-height: 260px; }
.bento-4col   { grid-column: span 4;  min-height: 260px; }  /* ROW 3+4: bộ 3 nhỏ + Seasonality */
.bento-full   { grid-column: span 12; min-height: 140px; }  /* ROW 2: Leader Hub */
.bento-action { grid-column: span 12; min-height: 200px; }  /* Dự phòng */
.bento-tall   { min-height: 320px; }                        /* ROW 4: Seasonality */

/* ── Leader Hub Tab Switcher (bắt buộc — mất là Tab không hoạt động) ── */
.leader-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 8px;
}

.leader-tab-btn {
    padding: 5px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
}

.leader-tab-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.leader-tab-btn.active {
    background: rgba(0, 230, 118, 0.12);
    border-color: rgba(0, 230, 118, 0.3);
    color: #00e676;
}

/* Tab content: mặc định ẩn — chỉ hiện khi có class .active */
.leader-tab-content {
    display: none;
}

.leader-tab-content.active {
    display: block;
}

body.light-theme .leader-tabs { border-bottom-color: rgba(0,0,0,0.06); }
body.light-theme .leader-tab-btn { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08); color: #64748b; }
body.light-theme .leader-tab-btn:hover { background: rgba(0,0,0,0.06); color: #1e293b; }
body.light-theme .leader-tab-btn.active { background: rgba(0,150,80,0.1); border-color: rgba(0,150,80,0.3); color: #16a34a; }

/* ─── RESPONSIVE BREAKPOINTS ─── */

/* Tablet landscape & small desktop */
@media (max-width: 1280px) {
    .bento-8col { grid-column: span 8; }
    .bento-7col { grid-column: span 7; }
    .bento-6col { grid-column: span 6; }
    .bento-5col { grid-column: span 5; }
    .bento-4col { grid-column: span 4; }
    .nganh-main { padding: 20px; }
}

/* Tablet portrait & large mobile */
@media (max-width: 1024px) {
    .page-nganh .nganh-main {
        margin-left: 0;
        max-width: 100vw;
        padding: 16px;
    }
    .bento-hero { min-height: 320px; }
    .bento-8col, .bento-7col, .bento-6col, .bento-5col { grid-column: span 12; }
    .bento-4col { grid-column: span 6; }
    .bento-tall { min-height: 280px; }
    .nganh-legend { display: none; }
}

/* Mobile */
@media (max-width: 768px) {
    .nganh-grid { gap: 12px; }
    .bento {
        padding: 14px;
        border-radius: 12px;
    }
    .bento-hero, .bento-8col, .bento-7col, .bento-6col, .bento-5col, .bento-4col, .bento-full, .bento-action, .bento-tall {
        grid-column: span 12;
        min-height: auto;
    }
    .bento-hero { min-height: 280px; }
    .nganh-header { gap: 8px; flex-wrap: nowrap !important; }
    .nganh-header h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .nganh-header-right { gap: 8px; flex-shrink: 0; }
    .nganh-header-right .btn-login-nav,
    .nganh-header-right .user-menu { display: none !important; }
    .update-time { display: none !important; }
    .treemap-cell text { font-size: 11px !important; }
    .phase-cell { padding: 8px; }
    .xray-input-group { flex-direction: column; }
    .xray-btn { width: 100%; }
}

/* Small mobile */
@media (max-width: 480px) {
    .nganh-main { padding: 10px; }
    .bento { padding: 12px; }
    .bento-title { font-size: 11px; }
    .xray-input, .xray-btn { font-size: 12px; padding: 8px 12px; }
}

/* Touch device: tăng tap target */
@media (hover: none) {
    .breadth-name { padding: 4px 0; min-height: 24px; }
    .xray-btn { padding: 12px 18px; min-height: 44px; }
}

/* Glow effect cho VSA spike (ý #1) */
@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(250, 204, 21, 0.25); }
    50% { box-shadow: 0 0 28px rgba(250, 204, 21, 0.55); }
}
.bento-glow {
    animation: glow-pulse 2.4s ease-in-out infinite;
    border-color: rgba(250, 204, 21, 0.4);
}

/* Alert styles */
.bento-alert-danger {
    border-color: rgba(239, 68, 68, 0.35);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.06), transparent 60%);
}

/* Tag styles */
.tag-leader {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
    margin-right: 4px;
    margin-bottom: 2px;
}

.tag-follower {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    margin-right: 4px;
    margin-bottom: 2px;
}

.tag-warning {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
    margin-left: 6px;
    animation: warning-pulse 1.5s ease-in-out infinite;
}

@keyframes warning-pulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; }
}

.tag-thien-thoi {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    color: #facc15;
    background: rgba(250, 204, 21, 0.1);
    border: 1px solid rgba(250, 204, 21, 0.4);
    text-shadow: 0 0 8px rgba(250, 204, 21, 0.4);
}

/* ── Leader Hub Tab Switcher ───────────────────────────────── */
.leader-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 4px;
}

.leader-tab-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
    text-align: center;
}

.leader-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

.leader-tab-btn.active {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
}

body.light-theme .leader-tabs {
    background: rgba(0,0,0,0.04);
}

body.light-theme .leader-tab-btn.active {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
}

.leader-tab-content {
    display: none;
}

.leader-tab-content.active {
    display: block;
}

/* FA-TA table (gộp vào Leader Hub tab) */
.fata-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
}

.fata-table th {
    padding: 6px 10px;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.fata-table td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    vertical-align: middle;
}

.fata-table tr:last-child td {
    border-bottom: none;
}

.fata-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

body.light-theme .fata-table th {
    border-bottom-color: rgba(0,0,0,0.08);
}

body.light-theme .fata-table td {
    border-bottom-color: rgba(0,0,0,0.04);
}


/* Lifecycle quadrant colors */
.phase-accumulation { color: #22d3ee; border-left-color: #22d3ee !important; }
.phase-markup { color: #22c55e; border-left-color: #22c55e !important; }
.phase-distribution { color: #f97316; border-left-color: #f97316 !important; }
.phase-depression { color: #ef4444; border-left-color: #ef4444 !important; }
.phase-sideway { color: #9ca3af; border-left-color: #9ca3af !important; }

/* Consensus bar */
.consensus-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    margin-top: 4px;
}
.consensus-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}

/* Sparkline container */
.sparkline-container {
    height: 32px;
    width: 100%;
    margin-top: 4px;
}

/* Z-score spring */
.zscore-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #22c55e 0%, #22c55e 30%, #facc15 50%, #facc15 70%, #ef4444 100%);
    position: relative;
    margin-top: 6px;
}
.zscore-marker {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 14px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(255,255,255,0.5);
    transition: left 0.5s ease;
}

/* RS Progress bar */
.rs-bar {
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    margin-top: 2px;
}
.rs-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #ef4444 0%, #facc15 50%, #22c55e 100%);
    transition: width 0.6s ease;
}

/* Treemap specific */
#treemap-chart {
    width: 100%;
    height: 350px;
    border-radius: 8px;
    overflow: hidden;
}

.treemap-cell text {
    pointer-events: none;
    user-select: none;
}

/* Phase grid */
.phase-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.phase-cell {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 10px;
    border-left: 3px solid;
    transition: all 0.2s;
}
.phase-cell:hover {
    background: rgba(255,255,255,0.05);
}
.phase-cell-title {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
}
.phase-cell-sectors {
    font-size: 10.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Breadth bar */
.breadth-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11px;
}
.breadth-name {
    flex: 0 0 110px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.breadth-bar {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
    display: flex;
}
.breadth-green {
    background: #22c55e;
}
.breadth-red {
    background: #ef4444;
}
.breadth-label {
    font-size: 10px;
    font-weight: 600;
    min-width: 32px;
    text-align: right;
}

/* Shift row */
.shift-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 11.5px;
}
.shift-name {
    flex: 0 0 120px;
    color: var(--text-primary);
    font-weight: 600;
}
.shift-bars {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
}
.shift-leader, .shift-follower {
    flex: 1;
    display: flex;
    align-items: center;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.fata-table td {
    padding: 7px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    vertical-align: middle;
}

.fata-table tr:last-child td {
    border-bottom: none;
}

.fata-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

body.light-theme .fata-table th {
    border-bottom-color: rgba(0,0,0,0.08);
}

body.light-theme .fata-table td {
    border-bottom-color: rgba(0,0,0,0.04);
}


/* Lifecycle quadrant colors */
.phase-accumulation { color: #22d3ee; border-left-color: #22d3ee !important; }
.phase-markup { color: #22c55e; border-left-color: #22c55e !important; }
.phase-distribution { color: #f97316; border-left-color: #f97316 !important; }
.phase-depression { color: #ef4444; border-left-color: #ef4444 !important; }
.phase-sideway { color: #9ca3af; border-left-color: #9ca3af !important; }

/* Consensus bar */
.consensus-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    margin-top: 4px;
}
.consensus-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}

/* Sparkline container */
.sparkline-container {
    height: 32px;
    width: 100%;
    margin-top: 4px;
}

/* Z-score spring */
.zscore-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #22c55e 0%, #22c55e 30%, #facc15 50%, #facc15 70%, #ef4444 100%);
    position: relative;
    margin-top: 6px;
}
.zscore-marker {
    position: absolute;
    top: -3px;
    width: 4px;
    height: 14px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(255,255,255,0.5);
    transition: left 0.5s ease;
}

/* RS Progress bar */
.rs-bar {
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    margin-top: 2px;
}
.rs-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #ef4444 0%, #facc15 50%, #22c55e 100%);
    transition: width 0.6s ease;
}

/* Treemap specific */
#treemap-chart {
    width: 100%;
    height: 350px;
    border-radius: 8px;
    overflow: hidden;
}

.treemap-cell text {
    pointer-events: none;
    user-select: none;
}

/* Phase grid */
.phase-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.phase-cell {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 10px;
    border-left: 3px solid;
    transition: all 0.2s;
}
.phase-cell:hover {
    background: rgba(255,255,255,0.05);
}
.phase-cell-title {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
}
.phase-cell-sectors {
    font-size: 10.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Breadth bar */
.breadth-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11px;
}
.breadth-name {
    flex: 0 0 110px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.breadth-bar {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.05);
    overflow: hidden;
    display: flex;
}
.breadth-green {
    background: #22c55e;
}
.breadth-red {
    background: #ef4444;
}
.breadth-label {
    font-size: 10px;
    font-weight: 600;
    min-width: 32px;
    text-align: right;
}

/* Shift row */
.shift-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 11.5px;
}
.shift-name {
    flex: 0 0 120px;
    color: var(--text-primary);
    font-weight: 600;
}
.shift-bars {
    flex: 1;
    display: flex;
    gap: 8px;
    align-items: center;
}
.shift-leader, .shift-follower {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
}
.shift-bar-mini {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    overflow: hidden;
}
.shift-bar-fill {
    height: 100%;
    border-radius: 2px;
}

/* ── Early Bird tích hợp vào Radar Tạo Lập ── */
@keyframes early-bird-blink {
    0%, 100% { opacity: 1; text-shadow: 0 0 8px rgba(250, 204, 21, 0.8); }
    50%       { opacity: 0.4; text-shadow: none; }
}
.early-bird-icon {
    animation: early-bird-blink 1.2s ease-in-out infinite;
    display: inline-block;
}
.early-bird-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    margin-bottom: 12px;
    background: rgba(250, 204, 21, 0.06);
    border: 1px solid rgba(250, 204, 21, 0.2);
    border-radius: 8px;
    font-size: 11px;
    align-items: center;
}
.early-bird-bar-empty {
    padding: 6px 10px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.02);
    border-radius: 8px;
    font-size: 10.5px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Seasonality ── */
.seasonality-card {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 6px;
    font-size: 11.5px;
}
body.light-theme .seasonality-card { background: rgba(0,0,0,0.02); }

/* ── Correlation matrix (Pearson) ── */
.corr-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 10.5px;
    width: max-content;
}
.corr-th-row {
    text-align: right;
    padding: 4px 10px 4px 4px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    font-size: 10.5px;
    border-right: 1px solid rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    background: #111827;
    position: sticky;
    left: 0;
    z-index: 2;
}
.corr-th-col {
    padding: 8px 4px 4px 4px;
    height: 120px;
    vertical-align: bottom;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.corr-col-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    letter-spacing: 0.2px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}
.corr-td {
    text-align: center;
    padding: 5px 4px;
    font-size: 10px;
    font-weight: 600;
    width: 38px;
    min-width: 38px;
    cursor: default;
    transition: opacity 0.15s;
    border-right: 1px solid rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-variant-numeric: tabular-nums;
}
.corr-td:hover { opacity: 0.8; }
.corr-td-diag {
    background: rgba(255,255,255,0.15);
    font-weight: 800;
    color: #fff;
}
body.light-theme .corr-th-row { color: #1e293b; background: #f8fafc; border-right-color: rgba(0,0,0,0.1); }
body.light-theme .corr-col-label { color: #1e293b; }
body.light-theme .corr-td-diag { background: rgba(0,0,0,0.12); color: #1e293b; }
body.light-theme .corr-table th { color: #64748b; }
body.light-theme .corr-table td { color: #334155; }

/* ── X-Ray Danh Mục ── */
.xray-result {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 10px;
    margin-top: 6px;
    font-size: 12px;
    border-left: 3px solid;
}
.xray-risk { border-left-color: #ef4444; }
.xray-safe { border-left-color: #22c55e; }
.xray-neutral { border-left-color: #9ca3af; }
.xray-input-group {
    display: flex;
    gap: 8px;
    margin: 8px 0 12px 0;
}
.xray-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}
.xray-input:focus {
    border-color: rgba(0,230,118,0.4);
    background: rgba(255,255,255,0.07);
}
.xray-btn {
    background: linear-gradient(135deg, #00e676 0%, #00e5ff 100%);
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    color: #000;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}
.xray-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,230,118,0.3);
}
.xray-vip-hook {
    margin-top: 12px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(250,204,21,0.1), rgba(0,229,255,0.05));
    border: 1px solid rgba(250,204,21,0.3);
    border-radius: 8px;
    font-size: 11px;
    color: #facc15;
}
body.light-theme .xray-input { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.12); color: #1e293b; }
body.light-theme .xray-input:focus { background: rgba(0,0,0,0.05); border-color: rgba(0,150,80,0.4); }
body.light-theme .xray-result { background: rgba(0,0,0,0.02); color: #334155; }
body.light-theme .xray-vip-hook { background: linear-gradient(135deg, rgba(250,204,21,0.12), rgba(0,229,255,0.06)); color: #b45309; }

/* ── FA-TA action table ── */
.fata-card {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    font-size: 11.5px;
    border-left: 3px solid;
}

.fata-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.5px;
    margin-top: 4px;
}
.fata-table thead th {
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 8px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.fata-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: background 0.15s;
}
.fata-table tbody tr:hover {
    background: rgba(250, 204, 21, 0.04);
}
.fata-table tbody td {
    padding: 7px 8px;
    vertical-align: middle;
}
body.light-theme .fata-table thead th { color: #64748b; border-bottom-color: rgba(0,0,0,0.08); }
body.light-theme .fata-table tbody tr { border-bottom-color: rgba(0,0,0,0.05); }
body.light-theme .fata-table tbody tr:hover { background: rgba(250,204,21,0.04); }

/* Export button */
.btn-export {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.4;
    transition: all 0.2s;
    z-index: 5;
}
.bento:hover .btn-export {
    opacity: 1;
    background: rgba(0, 230, 118, 0.1);
    border-color: rgba(0, 230, 118, 0.3);
}
.btn-export:hover {
    transform: scale(1.1);
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: 8px;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Footer */
.nganh-footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 11.5px;
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
}
.nganh-footer strong {
    color: var(--text-primary);
}

/* Leader top 3 cards */
.leader-card {
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid;
    transition: all 0.2s;
}
.leader-card:hover {
    background: rgba(255,255,255,0.05);
    transform: translateX(2px);
}
.leader-card-name {
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 4px;
}
.leader-card-meta {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Bull-trap alert items */
.bulltrap-item {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid #ef4444;
    border-radius: 4px;
    font-size: 11.5px;
}
.bulltrap-item strong {
    color: #ef4444;
    display: block;
    margin-bottom: 2px;
}
.bulltrap-empty {
    color: var(--text-muted);
    font-size: 12px;
    padding: 12px;
    text-align: center;
    font-style: italic;
}

/* Section subtitles inside bentos */
.bento-sub {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

/* Number badges */
.metric-strong { color: #22c55e; font-weight: 700; }
.metric-weak { color: #ef4444; font-weight: 700; }
.metric-neutral { color: #facc15; font-weight: 700; }


/* ═══════════════════════════════════════════════════════════
   LIGHT THEME — body.light-theme
   Match style.css + news_hub_v2.css pattern
   ═══════════════════════════════════════════════════════════ */

/* ── General text overrides ── */
body.light-theme .bento-sub { color: #64748b; }
body.light-theme .bulltrap-empty { color: #94a3b8; }
body.light-theme .leader-card-meta { color: #64748b; }
body.light-theme .breadth-name,
body.light-theme .shift-name { color: #334155; }
body.light-theme .early-bird-bar { background: rgba(250,204,21,0.08); border-color: rgba(250,204,21,0.3); }
body.light-theme .early-bird-bar-empty { background: rgba(0,0,0,0.02); color: #64748b; }

/* ── Header ── */
body.light-theme .nganh-header { border-bottom-color: rgba(0,0,0,0.08); }
body.light-theme .nganh-header .update-time { background: rgba(0,0,0,0.04); color: #64748b; }
body.light-theme .nganh-legend { color: #64748b; }
body.light-theme .nganh-footer { color: #94a3b8; border-top-color: rgba(0,0,0,0.08); }
body.light-theme .nganh-footer strong { color: #1e293b; }

/* ── Leader cards ── */
body.light-theme .leader-card { background: rgba(0,0,0,0.02); }
body.light-theme .leader-card:hover { background: rgba(0,0,0,0.04); }
body.light-theme .leader-card-name { color: #1e293b; }

/* ── Phase cells ── */
body.light-theme .phase-cell { background: rgba(0,0,0,0.02); }
body.light-theme .phase-cell-title { color: #1e293b; }
body.light-theme .phase-cell-sectors { color: #64748b; }

/* ── Breadth & bars ── */
body.light-theme .breadth-bar { background: rgba(0,0,0,0.06); }
body.light-theme .rs-bar { background: rgba(0,0,0,0.06); }
body.light-theme .shift-bar-mini { background: rgba(0,0,0,0.06); }
body.light-theme .zscore-track { opacity: 0.9; }

/* ── Bull-trap ── */
body.light-theme .bulltrap-item { background: rgba(239,68,68,0.06); }
body.light-theme .bulltrap-item strong { color: #dc2626; }

/* ── FA-TA cards ── */
body.light-theme .fata-card { background: rgba(0,0,0,0.02); }

/* ── Export button ── */
body.light-theme .btn-export {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.08);
}
body.light-theme .bento:hover .btn-export {
    background: rgba(0,150,80,0.08);
}

/* ── Skeleton shimmer ── */
body.light-theme .skeleton {
    background: linear-gradient(90deg, rgba(0,0,0,0.04) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 75%);
    background-size: 200% 100%;
}

/* ── Tags ── */
body.light-theme .tag-leader { background: rgba(34,211,238,0.12); color: #0891b2; }
body.light-theme .tag-follower { background: rgba(249,115,22,0.12); color: #ea580c; }
body.light-theme .tag-warning { background: rgba(239,68,68,0.12); color: #dc2626; }
body.light-theme .tag-thien-thoi {
    background: rgba(250,204,21,0.12);
    border-color: rgba(250,204,21,0.5);
    color: #b45309;
    text-shadow: none;
}

/* ── Treemap overrides (keep dark bg for readability) ── */
body.light-theme #treemap-chart {
    background: #ffffff; border: 1px solid #d9f99d; box-shadow: 0 4px 20px rgba(101, 163, 13, 0.05);
    border-radius: 8px;
}

/* ── Bento shadow on light ── */
body.light-theme .bento-alert-danger {
    background: linear-gradient(135deg, rgba(239,68,68,0.04), transparent 60%);
    border-color: rgba(239,68,68,0.25);
}

/* ── Glow stays in dark bg only ── */
body.light-theme .bento-glow {
    box-shadow: 0 0 18px rgba(250,204,21,0.2);
    animation: none;
}

/* ── Mobile: hide sidebar on light theme ── */
body.light-theme .app-sidebar {
    background: #f8fafc;
    border-right-color: rgba(0,0,0,0.06);
}

/* ═══════════════════════════════════════════════════════════
   HAMBURGER MENU (Mobile)
   Match style.css convention (class .show + transform)
   ═══════════════════════════════════════════════════════════ */
.nganh-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(17,24,39,0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    transition: all 0.2s;
    flex-shrink: 0;
}
.hamburger-btn:hover {
    background: rgba(0,230,118,0.15);
    border-color: rgba(0,230,118,0.3);
}

body.light-theme .hamburger-btn {
    background: rgba(255,255,255,0.95);
    border-color: rgba(0,0,0,0.1);
    color: #1e293b;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
}
.sidebar-overlay.active { display: block; }


/* ═══════════════════════════════════════════════════════════
   MA TRẬN TƯƠNG QUAN NGÀNH (.corr-table)
   ─────────────────────────────────────────────────────────
   Fix lỗi: tiêu đề hàng vỡ thành từng ký tự, tiêu đề cột bị cắt.
   ═══════════════════════════════════════════════════════════ */
.corr-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 10.5px;
    width: max-content;   /* Safari hỗ trợ width: max-content tốt hơn min-width */
}

/* Tiêu đề HÀNG (cột trái): tên ngành — KHÔNG được wrap */
.corr-th-row {
    text-align: right;
    padding: 4px 10px 4px 4px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;        /* ← Quan trọng: giữ tên trên 1 dòng */
    font-size: 10.5px;
    border-right: 1px solid rgba(255,255,255,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    background: #111827;        /* NỀN ĐẶC (SOLID) để khi scroll ngang không bị lộ chữ phía dưới (đặc biệt quan trọng trên iPhone) */
    position: sticky;
    left: 0;
    z-index: 2;
}

/* Tiêu đề CỘT NGANG (header trên cùng): chữ ngang hoàn toàn, từ trái qua phải, tự dãn độ rộng */
.corr-th-col {
    padding: 8px 6px;
    height: auto;
    vertical-align: middle;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.corr-col-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    letter-spacing: 0.2px;
}

/* Ô dữ liệu trong ma trận */
.corr-td {
    text-align: center;
    padding: 5px 4px;
    font-size: 10px;
    font-weight: 600;
    width: 38px;
    min-width: 38px; /* Ép Safari không bóp nhỏ ô */
    cursor: default;
    transition: opacity 0.15s;
    border-right: 1px solid rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-variant-numeric: tabular-nums;
}
.corr-td:hover { opacity: 0.8; }

/* Đường chéo (1.0) */
.corr-td-diag {
    background: rgba(255,255,255,0.15);
    font-weight: 800;
    color: #fff;
}

/* ── Light theme ── */
body.light-theme .corr-th-row {
    color: #1e293b;
    background: #f8fafc; /* NỀN ĐẶC cho chế độ sáng */
    border-right-color: rgba(0,0,0,0.1);
    border-bottom-color: rgba(0,0,0,0.04);
}
body.light-theme .corr-col-label {
    color: #1e293b;
}
body.light-theme .corr-td-diag {
    background: rgba(0,0,0,0.12);
    color: #1e293b;
}

@media (max-width: 1024px) {
    .hamburger-btn { display: flex; }
    
    .desktop-toggle { display: none !important; }

    /* Sidebar drawer — dùng transform như style.css để đồng bộ */
    .page-nganh .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .page-nganh .app-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }
}
/* === LIGHT THEME OVERRIDES FOR INLINE JAVASCRIPT COLORS === */

/* Gold/Yellow (#facc15, #eab308) -> Dark Amber (#b45309) */
body.light-theme [style*="color:#facc15"], 
body.light-theme [style*="color: #facc15"],
body.light-theme [style*="color:#eab308"], 
body.light-theme [style*="color: #eab308"] { 
    color: #b45309 !important; 
}
body.light-theme .leader-card[style*="border-left-color:#facc15"],
body.light-theme .leader-card[style*="border-left-color: #facc15"] {
    border-left-color: #b45309 !important;
}

/* Silver (#c0c0c0) -> Dark Gray (#475569) */
body.light-theme [style*="color:#c0c0c0"], 
body.light-theme [style*="color: #c0c0c0"] { 
    color: #475569 !important; 
}
body.light-theme .leader-card[style*="border-left-color:#c0c0c0"],
body.light-theme .leader-card[style*="border-left-color: #c0c0c0"] {
    border-left-color: #475569 !important;
}

/* Bronze (#cd7f32) -> Darker Brown (#92400e) */
body.light-theme [style*="color:#cd7f32"], 
body.light-theme [style*="color: #cd7f32"] { 
    color: #92400e !important; 
}
body.light-theme .leader-card[style*="border-left-color:#cd7f32"],
body.light-theme .leader-card[style*="border-left-color: #cd7f32"] {
    border-left-color: #92400e !important;
}

/* Cyan (#22d3ee) -> Dark Blue (#0284c7) */
body.light-theme [style*="color:#22d3ee"],
body.light-theme [style*="color: #22d3ee"] {
    color: #0284c7 !important;
}

/* Bright Orange (#f97316) -> Dark Orange (#c2410c) */
body.light-theme [style*="color:#f97316"],
body.light-theme [style*="color: #f97316"] {
    color: #c2410c !important;
}
body.light-theme .bulltrap-item[style*="border-left-color:#f97316"],
body.light-theme .bulltrap-item[style*="border-left-color: #f97316"],
body.light-theme .phase-cell[style*="border-left-color:#f97316"],
body.light-theme .phase-cell[style*="border-left-color: #f97316"] {
    border-left-color: #c2410c !important;
}

/* Bright Green (#22c55e, #4ade80) -> Dark Green (#16a34a) */
body.light-theme [style*="color:#22c55e"],
body.light-theme [style*="color: #22c55e"],
body.light-theme [style*="color:#4ade80"],
body.light-theme [style*="color: #4ade80"] {
    color: #16a34a !important;
}
body.light-theme .phase-cell[style*="border-left-color:#22c55e"],
body.light-theme .phase-cell[style*="border-left-color: #22c55e"] {
    border-left-color: #16a34a !important;
}

/* Bright Red (#ef4444) -> Dark Red (#dc2626) */
body.light-theme [style*="color:#ef4444"],
body.light-theme [style*="color: #ef4444"] {
    color: #dc2626 !important;
}
body.light-theme .phase-cell[style*="border-left-color:#ef4444"],
body.light-theme .phase-cell[style*="border-left-color: #ef4444"] {
    border-left-color: #dc2626 !important;
}

/* Phase Cell Cyan (#22d3ee) borders */
body.light-theme .phase-cell[style*="border-left-color:#22d3ee"],
body.light-theme .phase-cell[style*="border-left-color: #22d3ee"] {
    border-left-color: #0284c7 !important;
}

/* ── Sector Drill-down Drawer ── */
.sector-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    justify-content: flex-end; /* Căn sang phải */
    align-items: stretch; /* Căng chiều cao */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.sector-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.sector-modal-content {
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    border-radius: 24px 0 0 24px; /* Bo góc trái */
    width: 95%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
    transform: translateX(100%); /* Giấu sang phải */
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1); /* Hiệu ứng trượt mượt */
    overflow: hidden;
}
body.light-theme .sector-modal-content {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: -10px 0 40px rgba(0,0,0,0.1);
}
.sector-modal-overlay.active .sector-modal-content {
    transform: translateX(0);
}
.sector-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.1);
}
body.light-theme .sector-modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.06);
    background: rgba(0,0,0,0.02);
}
.sector-modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
}
.sector-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}
.sector-modal-close:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.1);
}
body.light-theme .sector-modal-close:hover {
    background: rgba(0,0,0,0.1);
}
.sector-modal-stats {
    display: flex;
    gap: 16px;
    padding: 12px 20px;
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.sector-modal-table-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px 20px;
}
.sector-modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}
.sector-modal-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 12px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
}
body.light-theme .sector-modal-table th { background: #fff; border-bottom: 1px solid rgba(0,0,0,0.06); }
.sector-modal-table td {
    padding: 12px 8px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
body.light-theme .sector-modal-table td { border-bottom: 1px solid rgba(0,0,0,0.03); }
.sector-modal-table tbody tr:hover td {
    background: rgba(255,255,255,0.02);
}
body.light-theme .sector-modal-table tbody tr:hover td {
    background: rgba(0,0,0,0.02);
}
.ticker-link {
    color: #22d3ee;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s;
}
.ticker-link:hover { color: #67e8f9; text-decoration: underline; }
body.light-theme .ticker-link { color: #0284c7; }
body.light-theme .ticker-link:hover { color: #0369a1; }
.badge-action {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 700;
    text-align: center;
    background: rgba(255,255,255,0.05);
}

/* Light theme for treemap tooltip */
body.light-theme #treemap-tooltip {
    background: #ffffff !important;
    color: #1e293b !important;
    border-color: rgba(0,0,0,0.15) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
}

.roc-badge {
    font-size: 9.5px;
    font-weight: 700;
    background: rgba(255,255,255,0.05);
    padding: 2px 4px;
    border-radius: 4px;
}
body.light-theme .roc-badge {
    background: rgba(0,0,0,0.05);
}
