/* STOCK36 PRO - Dashboard Stylesheet */

:root {
    --bg-dark: #0b0e14;
    --card-bg: rgba(16, 20, 26, 0.65);
    --card-bg-sub: rgba(15, 23, 42, 0.6);
    --border-color: rgba(255, 255, 255, 0.06);
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    --primary-glow: rgba(0, 230, 118, 0.15);
    --text-highlight: #ffffff;
    
    /* VSA Colors */
    --color-buy: #00e676;
    --color-buy-bg: rgba(0, 230, 118, 0.1);
    --color-sell: #ff1744;
    --color-sell-bg: rgba(255, 23, 68, 0.1);
    --color-hold: #ffc400;
    --color-hold-bg: rgba(255, 196, 0, 0.1);
    --color-observe: #00e5ff;
    --color-observe-bg: rgba(0, 229, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    padding-bottom: 40px;
    overflow-x: hidden;
    position: relative;
    width: 100%;
    max-width: 100vw;
}

/* Background animated glow */
.bg-gradient-glow {
    position: absolute;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.1) 0%, rgba(0, 230, 118, 0.05) 50%, rgba(0,0,0,0) 100%);
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

/* Glassmorphism utility card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

/* App Header styling */
.app-header {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 32px;
    background: linear-gradient(135deg, var(--color-observe), var(--color-buy));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(0, 230, 118, 0.3));
}

.logo-text h1 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.logo-text h1 span {
    color: var(--color-buy);
    font-weight: 900;
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.3);
}

.logo-text p {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    font-weight: 500;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.03);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-indicator.online {
    background-color: var(--color-buy);
    box-shadow: 0 0 8px var(--color-buy);
}

.status-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 20px auto 0;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-x: hidden;
}

/* Scan Section styling */
.scan-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Nâng cả khối tìm kiếm lên lớp trên cùng để dropdown gợi ý
       luôn hiển thị đè lên bảng HUD và biểu đồ phía dưới */
    position: relative;
    z-index: 100;
}

.scan-form {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: block;
}

.input-wrapper {
    display: flex;
    gap: 12px;
}

.input-wrapper input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 18px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--color-observe);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.15);
}

.input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

/* ============================================================ */
/* DROPDOWN GỢI Ý MÃ CỔ PHIẾU (AUTOCOMPLETE)                    */
/* ============================================================ */
.autocomplete-dropdown {
    display: none; /* Mặc định ẩn, JS sẽ bật thành 'flex' khi có kết quả */
    position: absolute;
    top: calc(100% + 6px); /* Xổ xuống ngay dưới ô input */
    left: 0;
    right: 0;
    flex-direction: column;
    background: #0e1626;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    max-height: 340px;
    overflow-y: auto;
    z-index: 1000;
    padding: 6px;
    gap: 2px;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: rgba(0, 230, 118, 0.14);
}

.autocomplete-ticker {
    font-weight: 800;
    font-size: 14px;
    color: #00e676;
    min-width: 56px;
    letter-spacing: 0.5px;
}

.autocomplete-name {
    font-size: 13px;
    color: var(--text-secondary, #c4cad6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Tùy biến cho giao diện sáng (light theme) */
body.light-theme .autocomplete-dropdown {
    background: #ffffff;
    border-color: #d8dee9;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

body.light-theme .autocomplete-item:hover,
body.light-theme .autocomplete-item.active {
    background: rgba(0, 168, 89, 0.12);
}

body.light-theme .autocomplete-ticker {
    color: #00a859;
}

body.light-theme .autocomplete-name {
    color: #1a2030;
}

/* Highlight từ khóa tìm kiếm trong kết quả autocomplete */
.autocomplete-ticker mark,
.autocomplete-name mark {
    background: rgba(0, 230, 118, 0.2);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
    font-style: normal;
}

body.light-theme .autocomplete-ticker mark,
body.light-theme .autocomplete-name mark {
    background: rgba(0, 168, 89, 0.18);
}

#scan-btn {
    background: linear-gradient(135deg, #00b0ff, #00e676);
    border: none;
    border-radius: 8px;
    color: #000;
    font-weight: 700;
    font-size: 15px;
    padding: 0 28px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    box-shadow: 0 4px 15px rgba(0, 230, 118, 0.2);
}

#scan-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 230, 118, 0.35);
    filter: brightness(1.1);
}

#scan-btn:active {
    transform: translateY(0);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.vsa-radar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 10px 16px;
    border-radius: 8px;
    border-left: 3px solid var(--color-observe);
    font-size: 13px;
}

.radar-tag {
    font-weight: 700;
    color: var(--color-observe);
}

.radar-text {
    color: var(--text-primary);
    font-weight: 500;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Left Panel: Analysis Details */
.analysis-panel {
    display: flex;
    flex-direction: column;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 480px;
}

.empty-state-content {
    max-width: 280px;
}

.empty-state-content .large-icon {
    font-size: 64px;
    margin-bottom: 20px;
    display: block;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.2)); }
    50% { transform: scale(1.05); filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.4)); }
}

.empty-state-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-state-content p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Analysis Results Card */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

#result-ticker-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff 50%, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.action-banner {
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid transparent;
}

.action-banner h3 {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 4px;
}

.action-banner p {
    font-size: 12px;
    color: inherit;
    opacity: 0.85;
}

.action-banner.buy {
    background: var(--color-buy-bg);
    border-color: rgba(0, 230, 118, 0.2);
    color: var(--color-buy);
    box-shadow: 0 0 15px rgba(0, 230, 118, 0.05);
}

.action-banner.sell {
    background: var(--color-sell-bg);
    border-color: rgba(255, 23, 68, 0.2);
    color: var(--color-sell);
    box-shadow: 0 0 15px rgba(255, 23, 68, 0.05);
}

.action-banner.hold {
    background: var(--color-hold-bg);
    border-color: rgba(255, 196, 0, 0.2);
    color: var(--color-hold);
    box-shadow: 0 0 15px rgba(255, 196, 0, 0.05);
}

.action-banner.observe {
    background: var(--color-observe-bg);
    border-color: rgba(0, 229, 255, 0.2);
    color: var(--color-observe);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.05);
}

/* ==========================================================
   CẢNH BÁO DỮ LIỆU CŨ (STALE DATA WARNING)
   Hiển thị khi tín hiệu VSA chưa được cập nhật trong ngày
   ========================================================== */
.stale-data-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid;
    animation: stale-fade-in 0.4s ease;
    font-size: 12.5px;
    line-height: 1.5;
}

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

.stale-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.stale-text strong {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
}

/* Mức 1: 1 phiên chưa cập nhật — Vàng nhạt */
.stale-data-warning.stale-warning {
    background: rgba(255, 196, 0, 0.08);
    border-color: rgba(255, 196, 0, 0.25);
    color: #ffd54f;
}

/* Mức 2: 2-3 phiên chưa cập nhật — Cam */
.stale-data-warning.stale-danger {
    background: rgba(255, 107, 53, 0.1);
    border-color: rgba(255, 107, 53, 0.3);
    color: #ff8a65;
}

/* Mức 3: 4+ phiên chưa cập nhật — Đỏ, pulse nhẹ */
.stale-data-warning.stale-critical {
    background: rgba(255, 23, 68, 0.1);
    border-color: rgba(255, 23, 68, 0.35);
    color: #ff5252;
    animation: stale-fade-in 0.4s ease, stale-pulse 2.5s ease-in-out infinite;
}

@keyframes stale-pulse {
    0%, 100% { border-color: rgba(255, 23, 68, 0.35); }
    50%       { border-color: rgba(255, 23, 68, 0.7); box-shadow: 0 0 10px rgba(255, 23, 68, 0.15); }
}

/* Light theme adjustments */
body.light-theme .stale-data-warning.stale-warning {
    background: rgba(255, 196, 0, 0.12);
    color: #b8860b;
}
body.light-theme .stale-data-warning.stale-danger {
    background: rgba(255, 107, 53, 0.12);
    color: #d84315;
}
body.light-theme .stale-data-warning.stale-critical {
    background: rgba(255, 23, 68, 0.1);
    color: #c62828;
}



.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.metric-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.02);
    padding: 16px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.metric-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.score-container {
    display: flex;
    justify-content: center;
}

.score-ring {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-buy);
    text-shadow: 0 0 10px rgba(0, 230, 118, 0.2);
}

.score-ring.score-high { color: var(--color-buy); }
.score-ring.score-medium { color: var(--color-hold); }
.score-ring.score-low { color: var(--color-sell); }

.score-max {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.metric-val {
    font-size: 24px;
    font-weight: 800;
}

/* Price levels panel */
.price-levels-list {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.price-levels-list h4 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.level-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-size: 14px;
}

.level-row:last-child {
    border-bottom: none;
}

.level-label {
    color: var(--text-primary);
    font-weight: 500;
}

.level-val {
    font-weight: 700;
}

.green-text { color: var(--color-buy); }
.yellow-text { color: var(--color-hold); }
.green-glow-text { color: #00e5ff; }
.red-text { color: var(--color-sell); }
.text-white { color: var(--text-highlight); }

/* Right Panel: Chart styling */
.chart-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 480px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-header h3 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    font-weight: 500;
}

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

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

.legend-dot.ma20 { background-color: #29b6f6; }
.legend-dot.ma50 { background-color: #ab47bc; }
.legend-dot.supertrend { background-color: #ffca28; }

.chart-container {
    flex: 1;
    min-height: 380px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

/* Signals Table styling */
.signals-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.signals-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.signals-header h3 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.table-container {
    overflow-x: auto;
    width: 100%;
}

.signals-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.signals-table th {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.signals-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-weight: 500;
}

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

.signals-table .row-ticker {
    font-weight: 800;
    color: var(--text-highlight);
    cursor: pointer;
    transition: color 0.2s;
}

.signals-table .row-ticker:hover {
    color: var(--color-observe);
}

.action-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.action-pill.buy { background: var(--color-buy-bg); color: var(--color-buy); border: 1px solid rgba(0, 230, 118, 0.2); }
.action-pill.sell { background: var(--color-sell-bg); color: var(--color-sell); border: 1px solid rgba(255, 23, 68, 0.2); }
.action-pill.hold { background: var(--color-hold-bg); color: var(--color-hold); border: 1px solid rgba(255, 196, 0, 0.2); }
.action-pill.observe { background: var(--color-observe-bg); color: var(--color-observe); border: 1px solid rgba(0, 229, 255, 0.2); }

/* Glossary styling */
.glossary-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.glossary-section h3 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.glossary-item {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.01);
    padding: 16px;
    border-radius: 10px;
}

.glossary-item h5 {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-observe);
    margin-bottom: 8px;
}

.glossary-item p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* App Footer styling */
.app-footer {
    text-align: center;
    padding: 40px 20px 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }


/* Header Actions & Theme Toggle Button */
.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.08);
}

/* Light Theme Variables Override */
body.light-theme {
    --bg-dark: #f3f4f6;
    --card-bg: #ffffff;
    --card-bg-sub: rgba(243, 244, 246, 0.8);
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-muted: #374151; /* Darker grey for readability */
    --text-highlight: #000000;
    --primary-glow: rgba(16, 185, 129, 0.1);
    
    /* Tailwind text color overrides for Light Theme */
    --tw-text-opacity: 1;

    /* Override white text to be dark in light mode */
    --text-white: #111827;
    
    /* VSA Colors optimized for Light Mode (Darker & more readable) */
    --color-buy: #059669;
    --color-buy-bg: rgba(5, 150, 105, 0.1);
    --color-sell: #dc2626;
    --color-sell-bg: rgba(220, 38, 38, 0.1);
    --color-hold: #d97706;
    --color-hold-bg: rgba(217, 119, 6, 0.1);
    --color-observe: #0284c7;
    --color-observe-bg: rgba(2, 132, 199, 0.1);
}

body.light-theme .text-gray-400,
body.light-theme .text-gray-300,
body.light-theme .text-gray-500 {
    color: #374151 !important;
}

/* Light Theme Component Adjustments */
body.light-theme .bg-gradient-glow {
    background: radial-gradient(circle, rgba(0, 229, 255, 0.05) 0%, rgba(0, 230, 118, 0.03) 50%, rgba(0,0,0,0) 100%);
}

body.light-theme .glass-card {
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.04);
}

body.light-theme .glass-card:hover {
    border-color: rgba(0, 0, 0, 0.14);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.08);
}

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

body.light-theme .theme-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.04);
}

body.light-theme .header-status {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.03);
}

body.light-theme .input-wrapper input {
    background: rgba(255, 255, 255, 0.95);
    color: #1f2937;
    border-color: rgba(0, 0, 0, 0.14);
}

body.light-theme .input-wrapper input:focus {
    border-color: #00b0ff;
    box-shadow: 0 0 12px rgba(0, 176, 255, 0.15);
}

body.light-theme .input-wrapper input::placeholder {
    color: rgba(0, 0, 0, 0.35);
}

body.light-theme .vsa-radar {
    background: rgba(0, 0, 0, 0.02);
}

body.light-theme .metric-item {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.02);
}

body.light-theme .glossary-item {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.02);
}

body.light-theme #result-ticker-title {
    background: linear-gradient(135deg, #111827 50%, #4b5563);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .badge {
    background: rgba(0, 0, 0, 0.04);
    color: #4b5563;
}

body.light-theme .signals-table tr:hover td {
    background: rgba(0, 0, 0, 0.015);
}

body.light-theme .signals-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}


/* DETAIL PAGE LAYOUT STYLES */
.analysis-panel, .chart-panel, .profile-column, .ta-column, .fa-column, .ai-section-card {
    min-width: 0;
}

.detail-dashboard-grid {
    display: grid;
    grid-template-columns: 340px 1fr 440px;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1300px) {
    .detail-dashboard-grid {
        grid-template-columns: 320px 1fr;
    }
    .fa-column {
        grid-column: span 2;
    }
}

@media (max-width: 900px) {
    .detail-dashboard-grid {
        grid-template-columns: 1fr;
    }
    .profile-column, .ta-column, .fa-column {
        grid-column: span 1;
    }
}

/* Nav Link */
.nav-link {
    text-decoration: none;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Section Title */
.section-title-wrapper {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-observe);
    text-transform: uppercase;
}

/* Profile Column Brief Grid */
.profile-brief-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.profile-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-val {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.font-bold {
    font-weight: 700;
}

.link-text {
    color: var(--color-observe);
    text-decoration: none;
    transition: all 0.2s;
}

.link-text:hover {
    text-decoration: underline;
    filter: brightness(1.1);
}

/* Profile Text Box Sections */
.profile-text-section {
    margin-top: 16px;
}

.profile-text-section h4 {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.scrollable-text-box {
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    max-height: 150px;
    overflow-y: auto;
    word-break: break-word;
    overflow-wrap: break-word;
}

body.light-theme .scrollable-text-box {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.05);
}

/* Custom Scrollbar for scrollable boxes */
.scrollable-text-box::-webkit-scrollbar {
    width: 6px;
}

.scrollable-text-box::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable-text-box::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

body.light-theme .scrollable-text-box::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
}

/* TA Column Cards */
.result-summary-card {
    padding: 20px;
}

.chart-card-detail {
    padding: 20px;
}

/* FA Column Ratio Table */
.fa-table-wrapper {
    overflow-x: auto;
    width: 100%;
    margin-bottom: 16px;
}

.ratio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: center;
}

.ratio-table th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ratio-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    font-weight: 500;
    color: var(--text-primary);
}

body.light-theme .ratio-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

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

body.light-theme .ratio-table tr:hover td {
    background: rgba(0, 0, 0, 0.015);
}

.fa-note-box {
    background: rgba(0, 229, 255, 0.03);
    border: 1px solid rgba(0, 229, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
}

body.light-theme .fa-note-box {
    background: rgba(0, 176, 255, 0.03);
    border-color: rgba(0, 176, 255, 0.1);
}


/* AI ANALYSIS STYLES */
.ai-section-card {
    padding: 24px;
    background: rgba(18, 14, 33, 0.4); /* Giao diện tối pha sắc tím huyền ảo */
    border: 1px solid rgba(138, 43, 226, 0.2) !important; /* Viền tím */
    box-shadow: 0 8px 32px 0 rgba(138, 43, 226, 0.05) !important;
}

body.light-theme .ai-section-card {
    background: rgba(245, 243, 255, 0.82);
    border: 1px solid rgba(138, 43, 226, 0.15) !important;
    box-shadow: 0 8px 32px 0 rgba(138, 43, 226, 0.03) !important;
}

.ai-title-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(138, 43, 226, 0.15);
    padding-bottom: 14px;
    margin-bottom: 20px;
}

.ai-title-wrapper .section-title {
    color: #a855f7 !important; /* Tím ánh neon */
    font-weight: 800;
}

.ai-glow-icon {
    display: inline-block;
    filter: drop-shadow(0 0 5px rgba(168, 85, 247, 0.5));
}

.btn-refresh {
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    color: #c084fc;
    padding: 8px 16px;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-refresh:hover {
    background: rgba(168, 85, 247, 0.25);
    border-color: rgba(168, 85, 247, 0.6);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.2);
}

.btn-refresh:active {
    transform: scale(0.97);
}

.refresh-icon {
    display: inline-block;
    transition: transform 0.4s ease;
}

.btn-refresh:hover .refresh-icon {
    transform: rotate(180deg);
}

/* AI Content Typography */
.ai-content-box {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    word-break: break-word;
    overflow-wrap: break-word;
}

.ai-heading-3 {
    font-size: 15px;
    font-weight: 700;
    color: #c084fc;
    margin: 24px 0 12px 0;
    border-left: 3px solid #a855f7;
    padding-left: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

body.light-theme .ai-heading-3 {
    color: #7e22ce;
    border-left-color: #7e22ce;
}

.ai-heading-3:first-child {
    margin-top: 0;
}

.ai-para {
    margin-bottom: 14px;
    color: var(--text-primary);
}

.ai-list {
    margin-bottom: 16px;
    padding-left: 20px;
}

.ai-list-item {
    margin-bottom: 8px;
    color: var(--text-primary);
    list-style-type: disc;
}

/* AI Loading Component */
.ai-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    gap: 16px;
    color: var(--text-muted);
}

.pulse-loader {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #a855f7;
    box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(168, 85, 247, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(168, 85, 247, 0);
    }
}

.ai-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    padding-top: 14px;
    margin-top: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

body.light-theme .ai-footer {
    border-top-color: rgba(0, 0, 0, 0.04);
}


/* MOBILE RESPONSIVE OPTIMIZATIONS (DƯỚI 768PX — TABLET & ĐIỆN THOẠI) */
@media (max-width: 768px) {
    /* Ngăn chặn tràn ngang toàn cục */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .app-layout {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .main-content {
        overflow-x: hidden;
        max-width: 100vw;
        min-width: 0;
    }

    .app-container {
        padding: 0 12px;
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Dashboard grid stacking */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .detail-dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .tab-dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }

    .dashboard-more-info-grid {
        grid-template-columns: 1fr !important;
    }

    .finance-charts-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tabs cuộn ngang thay vì tràn trang */
    .analysis-tabs {
        width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .analysis-tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 8px 14px;
        font-size: 12.5px;
    }

    /* Chart header flex wrap */
    .chart-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .chart-header h3 {
        font-size: 12px;
    }

    /* Bảng tín hiệu cuộn ngang */
    .table-container,
    .fa-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .signals-table,
    .ratio-table {
        min-width: 600px;
    }

    /* Glass card padding thu nhỏ */
    .glass-card {
        padding: 16px !important;
        border-radius: 12px;
    }
    
    /* Ghi đè margin inline dư thừa ở mobile */
    .scan-section, .signals-section, .detail-overview, .detail-header, .news-container {
        margin-top: 12px !important;
        margin-bottom: 12px !important;
    }

    /* Biểu đồ nến chiều cao tối ưu */
    .chart-container {
        min-height: 280px;
    }
}

/* MOBILE RESPONSIVE OPTIMIZATIONS (DƯỚI 600PX — ĐIỆN THOẠI) */
@media (max-width: 600px) {
    /* Header centering & stack */
    .app-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
        padding: 16px 12px;
    }
    
    .header-logo {
        flex-direction: column;
        gap: 6px;
    }
    
    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    /* Scan Form & Button stacking - ngăn chặn nhảy chữ lệch phải */
    .input-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    
    .input-wrapper button {
        width: 100%;
        margin-left: 0;
    }
    
    .input-wrapper input {
        width: 100%;
        font-size: 16px; /* ≥16px để iOS không zoom khi focus */
        padding: 12px 14px;
    }
    
    #scan-btn {
        width: 100%;
        min-width: 100%;
        padding: 12px;
        font-size: 14px;
        min-height: 48px;
    }

    /* Radar Sectors layout */
    .vsa-radar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 12px;
    }

    /* Company Profile stacking */
    .profile-brief-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .profile-item {
        grid-column: span 1 !important;
    }

    /* Card padding optimization */
    .glass-card {
        padding: 14px;
        border-radius: 10px;
    }

    /* AI widget header stack */
    .ai-title-wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Ticker title nhỏ hơn */
    #result-ticker-title {
        font-size: 22px;
    }

    .action-banner h3 {
        font-size: 15px;
    }

    /* Metrics grid 1 cột trên điện thoại nhỏ */
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Section title nhỏ hơn */
    .section-title {
        font-size: 13px;
    }

    /* Level row font nhỏ hơn */
    .level-row {
        font-size: 13px;
    }

    /* Status bar stack dọc */
    .system-status-bar {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 14px;
    }

    .sys-status-right {
        flex-direction: column;
        gap: 6px;
    }

    .sys-info-sep {
        display: none;
    }

    /* Glossary grid 1 cột */
    .glossary-grid {
        grid-template-columns: 1fr !important;
    }

    /* Mobile header bám dính */
    .mobile-header {
        padding: 10px 14px;
    }

    .mobile-logo h1 {
        font-size: 16px;
    }

    /* Footer nhỏ hơn */
    .app-footer {
        padding: 24px 14px 0;
        font-size: 11px;
    }

    /* Recent ticker section */
    .recent-tickers-section,
    #dashboard-recent-tickers-section {
        padding: 14px !important;
    }
}

/* SIDEBAR NAVIGATION LAYOUT */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.app-sidebar {
    width: 280px;
    background: rgba(10, 14, 22, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme .app-sidebar {
    background: rgba(255, 255, 255, 0.95);
}

.main-content {
    flex: 1;
    margin-left: 280px;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.sidebar-logo {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-left: 12px;
    margin-bottom: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

body.light-theme .nav-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.nav-item.active {
    color: var(--color-buy);
    background: rgba(0, 230, 118, 0.08);
    box-shadow: inset 0 0 0 1px rgba(0, 230, 118, 0.15);
}

body.light-theme .nav-item.active {
    color: #1b5e20;
    background: rgba(0, 230, 118, 0.1);
    box-shadow: inset 0 0 0 1px rgba(0, 230, 118, 0.2);
}

.nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-item.disabled:hover {
    background: transparent;
    color: var(--text-muted);
}

.badge-coming {
    font-size: 8px;
    font-weight: 700;
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
    border: 1px solid rgba(168, 85, 247, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 500;
    line-height: 1.5;
}

.sidebar-footer .text-xs {
    font-size: 9px;
    margin-top: 4px;
    opacity: 0.7;
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: rgba(10, 14, 22, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 18px;
    position: sticky;
    top: 0;
    z-index: 90;
    align-items: center;
    justify-content: space-between;
}

body.light-theme .mobile-header {
    background: rgba(255, 255, 255, 0.95);
}

.mobile-logo h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.mobile-logo h1 span {
    color: var(--color-buy);
}

/* Hamburger toggle button */
.sidebar-toggle-btn {
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 4px;
    outline: none;
}

.sidebar-toggle-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.sidebar-toggle-btn.active span:nth-child(2) {
    opacity: 0;
}

.sidebar-toggle-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile overlay background */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9998;
    animation: fadeIn 0.25s ease-out;
}

.sidebar-overlay.show {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* RESPONSIVE LAYOUT OVERRIDES */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .mobile-header {
        display: flex;
    }
    .app-header {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .btn-refresh {
        width: 100%;
        justify-content: center;
    }
}

/* RECENT TICKERS THUMBNAIL CARDS */
.recent-tickers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.ticker-thumb-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

body.light-theme .ticker-thumb-card {
    background: rgba(0, 0, 0, 0.02);
}

.ticker-thumb-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-observe);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 229, 255, 0.08);
}

body.light-theme .ticker-thumb-card:hover {
    background: rgba(0, 0, 0, 0.04);
    box-shadow: 0 6px 16px rgba(0, 176, 255, 0.05);
}

.ticker-thumb-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ticker-thumb-symbol {
    font-size: 18px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
}

body.light-theme .ticker-thumb-symbol {
    color: #111827;
}

.ticker-thumb-action {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.ticker-thumb-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

/* ==========================================================================
   TỐI ƯU HÓA CHIỀU RỘNG KHUNG PHÂN TÍCH (EMPTY STATE & SEARCH BAR)
   ========================================================================== */
.app-container {
    width: 100%;
}

.app-container > .scan-section,
.app-container > .empty-state-container {
    width: 100% !important;
    max-width: 100% !important;
    align-self: stretch !important;
}

/* Đảm bảo ô input tìm kiếm và form co giãn phủ kín chiều rộng */
.scan-section .scan-form,
.scan-section .input-group,
.scan-section .input-wrapper {
    width: 100% !important;
}

.scan-section .input-wrapper input {
    flex: 1 !important;
}


/* ==========================================================================
   TAB NAVIGATION SYSTEM & NEW LAYOUTS FOR DETAIL PAGE
   ========================================================================== */
.analysis-tabs {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: rgba(10, 14, 22, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    width: fit-content;
}

body.light-theme .analysis-tabs {
    background: rgba(255, 255, 255, 0.7);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    outline: none;
}

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

body.light-theme .tab-btn:hover {
    background: rgba(0, 0, 0, 0.03);
}

.tab-btn.active {
    color: var(--color-buy);
    background: rgba(0, 230, 118, 0.08);
    box-shadow: inset 0 0 0 1px rgba(0, 230, 118, 0.15);
}

body.light-theme .tab-btn.active {
    color: #1b5e20;
    background: rgba(0, 230, 118, 0.1);
    box-shadow: inset 0 0 0 1px rgba(0, 230, 118, 0.2);
}

.tab-content {
    display: none;
    animation: tabFadeIn 0.35s ease-out;
}

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

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tab 1: Dashboard Layout */
.tab-dashboard-grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
}

.dash-left-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-card-dashboard {
    padding: 20px;
}

.dashboard-more-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.info-card-sub {
    padding: 20px;
}

@media (max-width: 1024px) {
    .tab-dashboard-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-more-info-grid {
        grid-template-columns: 1fr;
    }
}

/* Tab 2: Finance Layout */
.fa-column-full {
    padding: 24px;
}

.finance-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.chart-card-sub {
    padding: 20px;
}

.chart-card-sub h3, .chart-card-sub h4 {
    font-size: 13.5px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--color-observe);
}

@media (max-width: 900px) {
    .finance-charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Tab 3: News Layout */
.tab-news-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.ai-news-summary-card {
    padding: 24px;
    background: rgba(18, 14, 33, 0.4);
    border: 1px solid rgba(168, 85, 247, 0.2) !important;
    box-shadow: 0 8px 32px 0 rgba(168, 85, 247, 0.05) !important;
}

body.light-theme .ai-news-summary-card {
    background: rgba(245, 243, 255, 0.82);
    border: 1px solid rgba(168, 85, 247, 0.15) !important;
}

.raw-news-card {
    padding: 24px;
}

.raw-news-list-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.raw-news-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease-in-out;
}

body.light-theme .raw-news-item {
    background: rgba(0, 0, 0, 0.01);
}

.raw-news-item:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--color-observe);
    transform: translateY(-2px);
}

body.light-theme .raw-news-item:hover {
    background: rgba(0, 0, 0, 0.02);
}

.news-item-title {
    font-size: 14.5px;
    font-weight: 700;
    margin-bottom: 6px;
}

.news-item-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.news-item-title a:hover {
    color: var(--color-observe);
}

.news-item-head {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 8px;
}

.news-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* ==========================================================================
   INFINITE MARQUEE TICKER FOR RECENT ANALYZED STOCKS
   ========================================================================== */
.recent-tickers-section, #dashboard-recent-tickers-section {
    overflow: hidden !important;
    width: 100% !important;
    position: relative;
    padding: 20px !important;
    box-sizing: border-box;
}

/* Đổi grid tĩnh thành flex track chạy ngang vô tận */
.recent-tickers-section .recent-tickers-grid, 
#dashboard-recent-tickers-section .recent-tickers-grid {
    display: flex !important;
    grid-template-columns: none !important; /* Ghi đè cấu trúc grid cũ */
    width: max-content !important;
    gap: 15px !important;
    animation: recent-ticker-slide 45s linear infinite !important;
    padding-bottom: 5px;
}

/* Hover dừng chạy để người dùng click */
.recent-tickers-section:hover .recent-tickers-grid, 
#dashboard-recent-tickers-section:hover .recent-tickers-grid,
.recent-tickers-section .recent-tickers-grid:hover, 
#dashboard-recent-tickers-section .recent-tickers-grid:hover {
    animation-play-state: paused !important;
}

/* Card item co dãn cố định */
.recent-tickers-section .ticker-thumb-card, 
#dashboard-recent-tickers-section .ticker-thumb-card {
    flex-shrink: 0 !important;
    width: 230px !important;
    box-sizing: border-box;
}

/* Hiệu ứng trượt ngang vô tận */
@keyframes recent-ticker-slide {
    0% {
        transform: translate3d(0, 0, 0);
    }
    100% {
        /* Dịch chuyển đúng một nửa track để tạo vòng lặp liên tục */
        transform: translate3d(-50%, 0, 0);
    }
}

/* =====================================================
   SYSTEM STATUS BAR — Thông tin hệ thống cho user
===================================================== */
.system-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    margin-bottom: 20px;
    border-radius: 12px;
    background: rgba(0, 229, 255, 0.04);
    border: 1px solid rgba(0, 229, 255, 0.12);
    flex-wrap: wrap;
    gap: 10px;
}
.sys-status-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.sys-dot {
    width: 8px; height: 8px;
    border-radius: 50%; flex-shrink: 0;
}
.sys-dot.green { background: #00e676; box-shadow: 0 0 6px #00e676; animation: sysDotPulse 2s infinite; }
.sys-dot.orange { background: #ffc400; box-shadow: 0 0 6px #ffc400; }
.sys-dot.red { background: #ff1744; box-shadow: 0 0 6px #ff1744; }
@keyframes sysDotPulse {
    0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}
.sys-status-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.sys-info-item {
    font-size: 12px;
    color: var(--text-muted);
}
.sys-info-item strong {
    color: var(--text-primary);
    font-weight: 600;
}
.sys-info-sep {
    color: var(--border-color);
    font-size: 16px;
}

/* =====================================================
   ADMIN NAV BADGE
===================================================== */
.badge-admin {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.35);
    letter-spacing: 0.3px;
    margin-left: auto;
}
.nav-admin {
    opacity: 0.7;
    transition: opacity .2s;
}
.nav-admin:hover {
    opacity: 1 !important;
}

/* =====================================================
   SIGNALS TABLE - REDESIGN (Danh mục theo dõi)
   Phiên bản mới: Nhiều cột, filter tab, scroll-x mobile
===================================================== */

/* Header layout mới */
.signals-section .signals-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}
.signals-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Badge đếm số mã */
.signals-count-badge {
    display: inline-block;
    background: rgba(34, 197, 94, 0.18);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

/* Bộ lọc Tab */
.signals-filter-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 3px;
}
.sig-tab-btn {
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}
.sig-tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}
.sig-tab-btn.active {
    background: rgba(34, 197, 94, 0.18);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Table container - scroll ngang trên mobile */
.signals-section .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.signals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 900px;
}
.signals-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #0f172a; /* Use dark background so it covers table rows when scrolling */
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}
.signals-table tbody td {
    padding: 9px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    vertical-align: middle;
    white-space: nowrap;
}
.signals-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}
.signals-table .row-ticker {
    text-align: left;
    padding-left: 14px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}
.signals-table .row-ticker:hover { color: #22c55e; text-decoration: underline; }

/* Light theme */
.light-theme .signals-filter-tabs { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
.light-theme .sig-tab-btn { color: #64748b; }
.light-theme .sig-tab-btn.active { background: rgba(22,101,52,0.12); color: #166534; border-color: rgba(22,101,52,0.3); }
.light-theme .signals-table thead th { background: #f8fafc; color: #64748b; }
.light-theme .signals-table tbody td { border-bottom-color: rgba(0,0,0,0.06); }

/* Mobile */
@media (max-width: 640px) {
    .sig-tab-btn { font-size: 11px; padding: 4px 9px; }
    .signals-header-actions { width: 100%; justify-content: space-between; }
    .signals-table { font-size: 12px; }
    .signals-table thead th,
    .signals-table tbody td { padding: 7px 8px; }
}

/* PERIOD TOGGLE SWITCH */
.period-toggle {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 30px;
    position: relative;
    padding: 4px;
    border: 1px solid var(--border-color);
}
.period-toggle input {
    display: none;
}
.period-toggle label {
    position: relative;
    z-index: 2;
    padding: 6px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
}
.period-toggle input:checked + label {
    color: #fff;
}
.toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    bottom: 4px;
    width: calc(50% - 4px);
    background: var(--color-buy);
    border-radius: 30px;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
}
.period-toggle input#toggle-quarter:checked ~ .toggle-slider {
    transform: translateX(100%);
    background: #eab308;
}

/* ==========================================================================
   AI REPORT TAB — MỚI: LINE-CLAMP, MOATS, CATALYST/RISK GRID, KEY METRICS
   ========================================================================== */

/* --- KHỐI 0: GIỚI THIỆU DOANH NGHIỆP --- */
.ai-intro-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.75;
    transition: max-height 0.4s ease;
}
.ai-intro-text.clamped {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 7em;
}
.ai-intro-clamp-wrapper {
    overflow: hidden;
}
.ai-readmore-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    padding: 5px 14px;
    background: rgba(0, 229, 255, 0.07);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 20px;
    color: var(--color-observe);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ai-readmore-btn:hover {
    background: rgba(0, 229, 255, 0.14);
    border-color: var(--color-observe);
}
.ai-readmore-btn .readmore-arrow {
    font-size: 10px;
    transition: transform 0.3s ease;
}
.ai-readmore-btn.expanded .readmore-arrow {
    transform: rotate(180deg);
}

/* --- KHỐI 2: METRICS GRID MỞ RỘNG 8 Ô --- */
.ai-metrics-extended {
    grid-template-columns: repeat(4, 1fr) !important;
}
@media (max-width: 768px) {
    .ai-metrics-extended {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* --- KHỐI 3: MOATS TABLE --- */
.moats-table {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.moat-row {
    display: grid;
    grid-template-columns: 30px 1fr 80px 36px;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.moat-row:last-child { border-bottom: none; }
.moat-icon {
    font-size: 18px;
    text-align: center;
}
.moat-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.moat-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.moat-desc {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.moat-score-bar {
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.moat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00e5ff, #a855f7);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.moat-score-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--color-observe);
    text-align: right;
    white-space: nowrap;
}
body.light-theme .moat-name { color: #111827; }
body.light-theme .moat-row { border-bottom-color: rgba(0,0,0,0.06); }

/* --- KHỐI 4: CATALYST & RISK 2 CỘT --- */
.ai-catalyst-risk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.ai-catalyst-card,
.ai-risk-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ai-section-heading {
    font-size: 16px;
    font-weight: 800;
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ai-section-heading.buy { color: var(--color-buy); }
.ai-section-heading.sell { color: #ef4444; }
.ai-bullet-list {
    margin: 0;
    padding-left: 18px;
    font-size: 13.5px;
    line-height: 1.75;
    color: var(--text-white);
    flex: 1;
}
.ai-bullet-list.buy li::marker { color: var(--color-buy); }
.ai-bullet-list.sell li::marker { color: #ef4444; }
.ai-bullet-list li { margin-bottom: 6px; }
@media (max-width: 768px) {
    .ai-catalyst-risk-grid {
        grid-template-columns: 1fr;
    }
}

/* --- KHỐI 5B: PHƯƠNG PHÁP ĐỊNH GIÁ --- */
.valuation-methods-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.val-method-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.25);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #c084fc;
    cursor: default;
    transition: all 0.2s;
}
.val-method-tag:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: #c084fc;
}
body.light-theme .val-method-tag {
    background: rgba(168, 85, 247, 0.08);
    color: #7c3aed;
}

/* --- KHỐI 7: RESPONSIVE FA QUANT GRID --- */
@media (max-width: 768px) {
    .fa-quant-grid {
        grid-template-columns: 1fr !important;
    }
    .moat-row {
        grid-template-columns: 28px 1fr 60px 30px;
        gap: 8px;
    }
    /* Summary cards: 5 → 2 cột trên mobile */
    .fa-summary-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ═══════════════════════════════════════ */
/* AI NEWS — Tin tức doanh nghiệp         */
/* ═══════════════════════════════════════ */
.ai-news-title:hover {
    color: var(--color-observe) !important;
}
.ai-news-item {
    transition: background 0.15s ease;
}
.ai-news-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ═══════════════════════════════════════ */
/* SUMMARY CARDS GRID — Responsive        */
/* ═══════════════════════════════════════ */
@media (max-width: 640px) {
    .fa-summary-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (min-width: 641px) and (max-width: 900px) {
    .fa-summary-cards-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ═══════════════════════════════════════ */
/* DETAILS/SUMMARY Accordion              */
/* ═══════════════════════════════════════ */
details summary::-webkit-details-marker {
    display: none;
}
details[open] > summary > span:first-child {
    transform: rotate(90deg);
}
.ai-info-accordion summary:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}
#ai-fa-summary-details summary:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* ═══════════════════════════════════════ */
/* PDF EXPORT LAYOUT (Sử dụng với html2pdf)*/
/* ═══════════════════════════════════════ */
.pdf-export-layout {
    background: #ffffff !important;
    color: #1a202c !important;
    font-family: 'Inter', sans-serif !important;
    padding: 20px !important;
    width: 210mm; /* Khổ A4 */
    /* Không set min-height để html2pdf tự cắt trang */
}

.pdf-export-layout * {
    color: #1a202c !important; /* Force dark text for readability */
}

/* Tùy chỉnh màu sắc đặc biệt cho bản in */
.pdf-export-layout .pdf-text-buy { color: #059669 !important; font-weight: 700; }
.pdf-export-layout .pdf-text-sell { color: #dc2626 !important; font-weight: 700; }
.pdf-export-layout .pdf-text-hold { color: #d97706 !important; font-weight: 700; }
.pdf-export-layout .pdf-text-muted { color: #64748b !important; }
.pdf-export-layout .pdf-text-primary { color: #2563eb !important; font-weight: 800; }

.pdf-export-layout h1, .pdf-export-layout h2, .pdf-export-layout h3, .pdf-export-layout h4 {
    color: #0f172a !important;
}

.pdf-header {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 15px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.pdf-logo h1 {
    font-size: 24px;
    font-weight: 900;
    margin: 0;
    color: #0f172a !important;
}
.pdf-logo h1 span {
    color: #059669 !important;
}
.pdf-logo p {
    font-size: 11px;
    color: #64748b !important;
    letter-spacing: 1px;
    margin: 0;
}

.pdf-title {
    text-align: right;
}
.pdf-title h2 {
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 4px 0;
    text-transform: uppercase;
}
.pdf-title p {
    font-size: 12px;
    margin: 0;
    color: #64748b !important;
}

/* Thẻ báo cáo (Card) */
.pdf-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    page-break-inside: avoid; /* Tránh cắt đôi card khi sang trang */
}

.pdf-card-title {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    color: #1e293b !important;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

/* Biểu đồ */
.pdf-chart-container {
    width: 100%;
    text-align: center;
    margin: 10px 0;
}
.pdf-chart-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid #f1f5f9;
}

/* Bảng */
.pdf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 15px;
}
.pdf-table th {
    background: #f8fafc;
    color: #475569 !important;
    font-weight: 700;
    text-align: right;
    padding: 8px;
    border: 1px solid #e2e8f0;
}
.pdf-table th:first-child { text-align: left; }
.pdf-table td {
    padding: 8px;
    border: 1px solid #e2e8f0;
    text-align: right;
    font-weight: 500;
}
.pdf-table td:first-child { text-align: left; font-weight: 600; }

/* Các lưới (Grid) */
.pdf-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pdf-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.pdf-metric {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}
.pdf-metric-label {
    font-size: 11px;
    color: #64748b !important;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 4px;
}
.pdf-metric-val {
    font-size: 16px;
    font-weight: 800;
    color: #0f172a !important;
}

/* Footer */
.pdf-footer {
    margin-top: 30px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    font-size: 10px;
    color: #94a3b8 !important;
    text-align: justify;
    line-height: 1.5;
    page-break-inside: avoid;
}
.pdf-page-break {
    page-break-before: always;
}
